Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
3eb5817a
Commit
3eb5817a
authored
Dec 03, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stream_filter: dash: refactor adaptation logic classes
and clean useless includes
parent
9df6750e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
154 deletions
+43
-154
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
...m_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
+33
-1
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
...eam_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
+4
-2
modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
...am_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
+0
-1
modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h
...ream_filter/dash/adaptationlogic/AdaptationLogicFactory.h
+0
-1
modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
...filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
+3
-50
modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
...m_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
+1
-19
modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
...lter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
+1
-34
modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
...lter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
+0
-5
modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
..._filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
+1
-36
modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
...am_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
+0
-5
No files found.
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.cpp
View file @
3eb5817a
...
...
@@ -28,11 +28,13 @@
#include "AbstractAdaptationLogic.h"
using
namespace
dash
::
logic
;
using
namespace
dash
::
xml
;
using
namespace
dash
::
mpd
;
using
namespace
dash
::
http
;
AbstractAdaptationLogic
::
AbstractAdaptationLogic
(
MPD
*
mpd_
)
:
mpd
(
mpd_
),
currentPeriod
(
mpd
->
getFirstPeriod
()),
count
(
0
),
bpsAvg
(
0
),
bpsLastChunk
(
0
),
bufferedMicroSec
(
0
),
...
...
@@ -44,6 +46,36 @@ AbstractAdaptationLogic::~AbstractAdaptationLogic ()
{
}
Chunk
*
AbstractAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
!
currentPeriod
)
return
NULL
;
const
Representation
*
rep
=
getCurrentRepresentation
(
type
);
if
(
rep
==
NULL
)
return
NULL
;
std
::
vector
<
ISegment
*>
segments
=
rep
->
getSegments
();
if
(
count
==
segments
.
size
()
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
count
=
0
;
return
getNextChunk
(
type
);
}
if
(
segments
.
size
()
>
count
)
{
ISegment
*
seg
=
segments
.
at
(
count
);
Chunk
*
chunk
=
seg
->
toChunk
();
//In case of UrlTemplate, we must stay on the same segment.
if
(
seg
->
isSingleShot
()
==
true
)
count
++
;
seg
->
done
();
return
chunk
;
}
return
NULL
;
}
void
AbstractAdaptationLogic
::
bufferLevelChanged
(
mtime_t
bufferedMicroSec
,
int
bufferedPercent
)
{
this
->
bufferedMicroSec
=
bufferedMicroSec
;
...
...
modules/stream_filter/dash/adaptationlogic/AbstractAdaptationLogic.h
View file @
3eb5817a
...
...
@@ -26,12 +26,10 @@
#define ABSTRACTADAPTATIONLOGIC_H_
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
#include "http/Chunk.h"
#include "mpd/MPD.h"
#include "mpd/Period.h"
#include "mpd/Representation.h"
#include "mpd/Segment.h"
struct
stream_t
;
...
...
@@ -45,6 +43,8 @@ namespace dash
AbstractAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
~
AbstractAdaptationLogic
();
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
virtual
void
downloadRateChanged
(
uint64_t
bpsAvg
,
uint64_t
bpsLastChunk
);
virtual
void
bufferLevelChanged
(
mtime_t
bufferedMicroSec
,
int
bufferedPercent
);
...
...
@@ -54,6 +54,8 @@ namespace dash
protected:
dash
::
mpd
::
MPD
*
mpd
;
dash
::
mpd
::
Period
*
currentPeriod
;
size_t
count
;
private:
int
bpsAvg
;
...
...
modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.cpp
View file @
3eb5817a
...
...
@@ -31,7 +31,6 @@
#include "adaptationlogic/AlwaysLowestAdaptationLogic.hpp"
using
namespace
dash
::
logic
;
using
namespace
dash
::
xml
;
using
namespace
dash
::
mpd
;
IAdaptationLogic
*
AdaptationLogicFactory
::
create
(
IAdaptationLogic
::
LogicType
logic
,
...
...
modules/stream_filter/dash/adaptationlogic/AdaptationLogicFactory.h
View file @
3eb5817a
...
...
@@ -26,7 +26,6 @@
#define ADAPTATIONLOGICFACTORY_H_
#include "adaptationlogic/IAdaptationLogic.h"
#include "xml/Node.h"
struct
stream_t
;
...
...
modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.cpp
View file @
3eb5817a
...
...
@@ -26,65 +26,18 @@
#endif
#include "AlwaysBestAdaptationLogic.h"
#include "Representationselectors.hpp"
using
namespace
dash
::
logic
;
using
namespace
dash
::
xml
;
using
namespace
dash
::
http
;
using
namespace
dash
::
mpd
;
AlwaysBestAdaptationLogic
::
AlwaysBestAdaptationLogic
(
MPD
*
mpd
)
:
AbstractAdaptationLogic
(
mpd
)
{
initSchedule
();
}
AlwaysBestAdaptationLogic
::~
AlwaysBestAdaptationLogic
()
{
}
Chunk
*
AlwaysBestAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
streams
[
type
].
count
<
streams
[
type
].
schedule
.
size
()
)
{
Chunk
*
chunk
=
new
Chunk
();
chunk
->
setUrl
(
streams
[
type
].
schedule
.
at
(
streams
[
type
].
count
)
->
getUrlSegment
());
streams
[
type
].
count
++
;
return
chunk
;
}
return
NULL
;
}
const
Representation
*
AlwaysBestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
{
if
(
streams
[
type
].
count
<
streams
[
type
].
schedule
.
size
()
)
return
streams
[
type
].
schedule
.
at
(
streams
[
type
].
count
)
->
getRepresentation
();
return
NULL
;
}
void
AlwaysBestAdaptationLogic
::
initSchedule
()
{
if
(
mpd
)
{
std
::
vector
<
Period
*>
periods
=
mpd
->
getPeriods
();
if
(
periods
.
empty
())
return
;
RepresentationSelector
selector
;
for
(
int
type
=
0
;
type
<
Streams
::
count
;
type
++
)
{
streams
[
type
].
count
=
0
;
Representation
*
best
=
selector
.
select
(
periods
.
front
(),
static_cast
<
Streams
::
Type
>
(
type
));
if
(
best
)
{
std
::
vector
<
ISegment
*>
segments
=
best
->
getSegments
();
std
::
vector
<
ISegment
*>::
const_iterator
segIt
;
for
(
segIt
=
segments
.
begin
();
segIt
!=
segments
.
end
();
segIt
++
)
{
streams
[
type
].
schedule
.
push_back
(
*
segIt
);
}
}
}
}
RepresentationSelector
selector
;
return
selector
.
select
(
currentPeriod
,
type
);
}
modules/stream_filter/dash/adaptationlogic/AlwaysBestAdaptationLogic.h
View file @
3eb5817a
...
...
@@ -26,13 +26,6 @@
#define ALWAYSBESTADAPTATIONLOGIC_H_
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "Representationselectors.hpp"
#include "http/Chunk.h"
#include "xml/Node.h"
#include "mpd/Period.h"
#include "mpd/Segment.h"
#include "Streams.hpp"
#include <vector>
namespace
dash
{
...
...
@@ -42,19 +35,8 @@ namespace dash
{
public:
AlwaysBestAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
~
AlwaysBestAdaptationLogic
();
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
const
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
private:
struct
{
std
::
vector
<
mpd
::
ISegment
*>
schedule
;
size_t
count
;
mpd
::
Representation
*
bestRepresentation
;
}
streams
[
Streams
::
count
];
void
initSchedule
();
virtual
const
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
};
}
}
...
...
modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.cpp
View file @
3eb5817a
...
...
@@ -21,46 +21,13 @@
#include "Representationselectors.hpp"
using
namespace
dash
::
logic
;
using
namespace
dash
::
http
;
using
namespace
dash
::
mpd
;
AlwaysLowestAdaptationLogic
::
AlwaysLowestAdaptationLogic
(
mpd
::
MPD
*
mpd
)
:
AbstractAdaptationLogic
(
mpd
),
currentPeriod
(
mpd
->
getFirstPeriod
()),
count
(
0
)
AbstractAdaptationLogic
(
mpd
)
{
}
Chunk
*
AlwaysLowestAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
!
currentPeriod
)
return
NULL
;
const
Representation
*
rep
=
getCurrentRepresentation
(
type
);
if
(
rep
==
NULL
)
return
NULL
;
std
::
vector
<
ISegment
*>
segments
=
rep
->
getSegments
();
if
(
count
==
segments
.
size
()
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
count
=
0
;
return
getNextChunk
(
type
);
}
if
(
segments
.
size
()
>
count
)
{
ISegment
*
seg
=
segments
.
at
(
count
);
Chunk
*
chunk
=
seg
->
toChunk
();
//In case of UrlTemplate, we must stay on the same segment.
if
(
seg
->
isSingleShot
()
==
true
)
count
++
;
seg
->
done
();
return
chunk
;
}
return
NULL
;
}
const
Representation
*
AlwaysLowestAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
{
RepresentationSelector
selector
;
...
...
modules/stream_filter/dash/adaptationlogic/AlwaysLowestAdaptationLogic.hpp
View file @
3eb5817a
...
...
@@ -31,12 +31,7 @@ namespace dash
public:
AlwaysLowestAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
virtual
const
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
private:
dash
::
mpd
::
Period
*
currentPeriod
;
size_t
count
;
};
}
}
...
...
modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.cpp
View file @
3eb5817a
...
...
@@ -32,50 +32,15 @@
#include <vlc_variables.h>
using
namespace
dash
::
logic
;
using
namespace
dash
::
xml
;
using
namespace
dash
::
http
;
using
namespace
dash
::
mpd
;
RateBasedAdaptationLogic
::
RateBasedAdaptationLogic
(
MPD
*
mpd
)
:
AbstractAdaptationLogic
(
mpd
),
count
(
0
),
currentPeriod
(
mpd
->
getFirstPeriod
())
AbstractAdaptationLogic
(
mpd
)
{
width
=
var_InheritInteger
(
mpd
->
getVLCObject
(),
"dash-prefwidth"
);
height
=
var_InheritInteger
(
mpd
->
getVLCObject
(),
"dash-prefheight"
);
}
Chunk
*
RateBasedAdaptationLogic
::
getNextChunk
(
Streams
::
Type
type
)
{
if
(
this
->
currentPeriod
==
NULL
)
return
NULL
;
const
Representation
*
rep
=
getCurrentRepresentation
(
type
);
if
(
!
rep
)
return
NULL
;
std
::
vector
<
ISegment
*>
segments
=
rep
->
getSegments
();
if
(
this
->
count
==
segments
.
size
()
)
{
currentPeriod
=
mpd
->
getNextPeriod
(
currentPeriod
);
this
->
count
=
0
;
return
getNextChunk
(
type
);
}
if
(
segments
.
size
()
>
this
->
count
)
{
ISegment
*
seg
=
segments
.
at
(
this
->
count
);
Chunk
*
chunk
=
seg
->
toChunk
();
//In case of UrlTemplate, we must stay on the same segment.
if
(
seg
->
isSingleShot
()
==
true
)
this
->
count
++
;
seg
->
done
();
return
chunk
;
}
return
NULL
;
}
const
Representation
*
RateBasedAdaptationLogic
::
getCurrentRepresentation
(
Streams
::
Type
type
)
const
{
if
(
currentPeriod
==
NULL
)
...
...
modules/stream_filter/dash/adaptationlogic/RateBasedAdaptationLogic.h
View file @
3eb5817a
...
...
@@ -26,8 +26,6 @@
#define RATEBASEDADAPTATIONLOGIC_H_
#include "adaptationlogic/AbstractAdaptationLogic.h"
#include "xml/Node.h"
#include "http/Chunk.h"
#define MINBUFFER 30
...
...
@@ -40,12 +38,9 @@ namespace dash
public:
RateBasedAdaptationLogic
(
mpd
::
MPD
*
mpd
);
virtual
dash
::
http
::
Chunk
*
getNextChunk
(
Streams
::
Type
);
const
dash
::
mpd
::
Representation
*
getCurrentRepresentation
(
Streams
::
Type
)
const
;
private:
size_t
count
;
dash
::
mpd
::
Period
*
currentPeriod
;
int
width
;
int
height
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment