Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Steve Lhomme
VLC
Commits
458adc37
Commit
458adc37
authored
Jul 21, 2015
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: adaptative: handle alternative streams
parent
69361064
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
129 additions
and
80 deletions
+129
-80
modules/demux/adaptative/PlaylistManager.cpp
modules/demux/adaptative/PlaylistManager.cpp
+38
-9
modules/demux/adaptative/PlaylistManager.h
modules/demux/adaptative/PlaylistManager.h
+5
-0
modules/demux/adaptative/SegmentTracker.cpp
modules/demux/adaptative/SegmentTracker.cpp
+8
-8
modules/demux/adaptative/SegmentTracker.hpp
modules/demux/adaptative/SegmentTracker.hpp
+4
-6
modules/demux/adaptative/Streams.cpp
modules/demux/adaptative/Streams.cpp
+28
-3
modules/demux/adaptative/Streams.hpp
modules/demux/adaptative/Streams.hpp
+4
-1
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
+2
-3
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
+2
-2
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.h
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.h
+1
-1
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.cpp
...es/demux/adaptative/logic/AlwaysLowestAdaptationLogic.cpp
+2
-2
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.hpp
...es/demux/adaptative/logic/AlwaysLowestAdaptationLogic.hpp
+1
-1
modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
+8
-8
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
+2
-2
modules/demux/adaptative/logic/Representationselectors.cpp
modules/demux/adaptative/logic/Representationselectors.cpp
+19
-29
modules/demux/adaptative/logic/Representationselectors.hpp
modules/demux/adaptative/logic/Representationselectors.hpp
+5
-5
No files found.
modules/demux/adaptative/PlaylistManager.cpp
View file @
458adc37
...
...
@@ -51,31 +51,37 @@ PlaylistManager::PlaylistManager( AbstractPlaylist *pl,
stream
(
stream
),
nextPlaylistupdate
(
0
)
{
currentPeriod
=
playlist
->
getFirstPeriod
();
}
PlaylistManager
::~
PlaylistManager
()
{
delete
conManager
;
delete
streamOutputFactory
;
unsetPeriod
();
}
void
PlaylistManager
::
unsetPeriod
()
{
std
::
vector
<
Stream
*>::
iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
++
it
)
delete
*
it
;
streams
.
clear
();
}
bool
PlaylistManager
::
s
tart
(
demux_t
*
demux
)
bool
PlaylistManager
::
s
etupPeriod
(
)
{
const
BasePeriod
*
period
=
playlist
->
getFirstPeriod
();
if
(
!
period
)
if
(
!
currentPeriod
)
return
false
;
for
(
int
i
=
0
;
i
<
StreamTypeCount
;
i
++
)
std
::
vector
<
BaseAdaptationSet
*>
sets
=
currentPeriod
->
getAdaptationSets
();
std
::
vector
<
BaseAdaptationSet
*>::
iterator
it
;
for
(
it
=
sets
.
begin
();
it
!=
sets
.
end
();
++
it
)
{
StreamType
type
=
static_cast
<
StreamType
>
(
i
);
const
BaseAdaptationSet
*
set
=
period
->
getAdaptationSet
(
type
);
BaseAdaptationSet
*
set
=
*
it
;
if
(
set
)
{
Stream
*
st
=
new
(
std
::
nothrow
)
Stream
(
demux
,
type
,
set
->
getStreamFormat
());
Stream
*
st
=
new
(
std
::
nothrow
)
Stream
(
p_
demux
,
set
->
getStreamFormat
());
if
(
!
st
)
continue
;
AbstractAdaptationLogic
*
logic
=
createLogic
(
logicType
);
...
...
@@ -85,7 +91,7 @@ bool PlaylistManager::start(demux_t *demux)
continue
;
}
SegmentTracker
*
tracker
=
new
(
std
::
nothrow
)
SegmentTracker
(
logic
,
playli
st
);
SegmentTracker
*
tracker
=
new
(
std
::
nothrow
)
SegmentTracker
(
logic
,
s
e
t
);
try
{
if
(
!
tracker
||
!
streamOutputFactory
)
...
...
@@ -101,6 +107,15 @@ bool PlaylistManager::start(demux_t *demux)
}
}
}
return
true
;
}
bool
PlaylistManager
::
start
(
demux_t
*
demux_
)
{
p_demux
=
demux_
;
if
(
!
setupPeriod
())
return
false
;
conManager
=
new
(
std
::
nothrow
)
HTTPConnectionManager
(
VLC_OBJECT
(
stream
));
if
(
!
conManager
)
...
...
@@ -119,7 +134,17 @@ Stream::status PlaylistManager::demux(mtime_t nzdeadline, bool send)
std
::
vector
<
Stream
*>::
iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
++
it
)
{
Stream
::
status
i_ret
=
(
*
it
)
->
demux
(
conManager
,
nzdeadline
,
send
);
Stream
*
st
=
*
it
;
if
(
st
->
isDisabled
())
{
if
(
st
->
isSelected
()
&&
!
st
->
isEOF
())
st
->
reactivate
(
getPCR
());
else
continue
;
}
Stream
::
status
i_ret
=
st
->
demux
(
conManager
,
nzdeadline
,
send
);
if
(
i_ret
==
Stream
::
status_buffering
)
{
...
...
@@ -141,6 +166,8 @@ mtime_t PlaylistManager::getPCR() const
std
::
vector
<
Stream
*>::
const_iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
++
it
)
{
if
((
*
it
)
->
isDisabled
())
continue
;
if
(
pcr
==
VLC_TS_INVALID
||
pcr
>
(
*
it
)
->
getPCR
())
pcr
=
(
*
it
)
->
getPCR
();
}
...
...
@@ -153,6 +180,8 @@ mtime_t PlaylistManager::getFirstDTS() const
std
::
vector
<
Stream
*>::
const_iterator
it
;
for
(
it
=
streams
.
begin
();
it
!=
streams
.
end
();
++
it
)
{
if
((
*
it
)
->
isDisabled
())
continue
;
if
(
dts
==
VLC_TS_INVALID
||
dts
>
(
*
it
)
->
getFirstDTS
())
dts
=
(
*
it
)
->
getFirstDTS
();
}
...
...
modules/demux/adaptative/PlaylistManager.h
View file @
458adc37
...
...
@@ -31,6 +31,7 @@ namespace adaptative
namespace
playlist
{
class
AbstractPlaylist
;
class
BasePeriod
;
}
namespace
http
...
...
@@ -67,6 +68,8 @@ namespace adaptative
virtual
bool
updatePlaylist
();
protected:
bool
setupPeriod
();
void
unsetPeriod
();
/* local factories */
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
);
...
...
@@ -75,8 +78,10 @@ namespace adaptative
AbstractPlaylist
*
playlist
;
AbstractStreamOutputFactory
*
streamOutputFactory
;
stream_t
*
stream
;
demux_t
*
p_demux
;
std
::
vector
<
Stream
*>
streams
;
mtime_t
nextPlaylistupdate
;
BasePeriod
*
currentPeriod
;
};
}
...
...
modules/demux/adaptative/SegmentTracker.cpp
View file @
458adc37
...
...
@@ -20,6 +20,7 @@
#include "SegmentTracker.hpp"
#include "playlist/AbstractPlaylist.hpp"
#include "playlist/BaseRepresentation.h"
#include "playlist/BaseAdaptationSet.h"
#include "playlist/Segment.h"
#include "logic/AbstractAdaptationLogic.h"
...
...
@@ -27,15 +28,14 @@ using namespace adaptative;
using
namespace
adaptative
::
logic
;
using
namespace
adaptative
::
playlist
;
SegmentTracker
::
SegmentTracker
(
AbstractAdaptationLogic
*
logic_
,
AbstractPlaylist
*
playlist_
)
SegmentTracker
::
SegmentTracker
(
AbstractAdaptationLogic
*
logic_
,
BaseAdaptationSet
*
adaptSet
)
{
count
=
0
;
initializing
=
true
;
indexed
=
false
;
prevRepresentation
=
NULL
;
setAdaptationLogic
(
logic_
);
playlist
=
playlist_
;
currentPeriod
=
playlist
->
getFirstPeriod
();
adaptationSet
=
adaptSet
;
}
SegmentTracker
::~
SegmentTracker
()
...
...
@@ -54,19 +54,19 @@ void SegmentTracker::resetCounter()
prevRepresentation
=
NULL
;
}
SegmentChunk
*
SegmentTracker
::
getNextChunk
(
StreamType
type
,
bool
switch_allowed
)
SegmentChunk
*
SegmentTracker
::
getNextChunk
(
bool
switch_allowed
)
{
BaseRepresentation
*
rep
;
ISegment
*
segment
;
if
(
!
currentPeriod
)
if
(
!
adaptationSet
)
return
NULL
;
if
(
!
switch_allowed
||
(
prevRepresentation
&&
prevRepresentation
->
getSwitchPolicy
()
==
SegmentInformation
::
SWITCH_UNAVAILABLE
)
)
rep
=
prevRepresentation
;
else
rep
=
logic
->
getCurrentRepresentation
(
type
,
currentPeriod
);
rep
=
logic
->
getCurrentRepresentation
(
adaptationSet
);
if
(
rep
==
NULL
)
return
NULL
;
...
...
@@ -96,9 +96,8 @@ SegmentChunk * SegmentTracker::getNextChunk(StreamType type, bool switch_allowed
segment
=
rep
->
getSegment
(
BaseRepresentation
::
INFOTYPE_MEDIA
,
count
);
if
(
!
segment
)
{
currentPeriod
=
playlist
->
getNextPeriod
(
currentPeriod
);
resetCounter
();
return
getNextChunk
(
type
,
switch_allowed
)
;
return
NULL
;
}
SegmentChunk
*
chunk
=
segment
->
toChunk
(
count
,
rep
);
...
...
@@ -135,6 +134,7 @@ mtime_t SegmentTracker::getSegmentStart() const
void
SegmentTracker
::
pruneFromCurrent
()
{
AbstractPlaylist
*
playlist
=
adaptationSet
->
getPlaylist
();
if
(
playlist
->
isLive
())
playlist
->
pruneBySegmentNumber
(
count
);
}
modules/demux/adaptative/SegmentTracker.hpp
View file @
458adc37
...
...
@@ -36,8 +36,7 @@ namespace adaptative
namespace
playlist
{
class
AbstractPlaylist
;
class
BasePeriod
;
class
BaseAdaptationSet
;
class
BaseRepresentation
;
class
SegmentChunk
;
}
...
...
@@ -48,12 +47,12 @@ namespace adaptative
class
SegmentTracker
{
public:
SegmentTracker
(
AbstractAdaptationLogic
*
,
AbstractPlaylis
t
*
);
SegmentTracker
(
AbstractAdaptationLogic
*
,
BaseAdaptationSe
t
*
);
~
SegmentTracker
();
void
setAdaptationLogic
(
AbstractAdaptationLogic
*
);
void
resetCounter
();
SegmentChunk
*
getNextChunk
(
StreamType
,
bool
);
SegmentChunk
*
getNextChunk
(
bool
);
bool
setPosition
(
mtime_t
,
bool
,
bool
);
mtime_t
getSegmentStart
()
const
;
void
pruneFromCurrent
();
...
...
@@ -63,8 +62,7 @@ namespace adaptative
bool
indexed
;
uint64_t
count
;
AbstractAdaptationLogic
*
logic
;
AbstractPlaylist
*
playlist
;
BasePeriod
*
currentPeriod
;
BaseAdaptationSet
*
adaptationSet
;
BaseRepresentation
*
prevRepresentation
;
};
}
...
...
modules/demux/adaptative/Streams.cpp
View file @
458adc37
...
...
@@ -31,15 +31,16 @@ using namespace adaptative;
using
namespace
adaptative
::
http
;
using
namespace
adaptative
::
logic
;
Stream
::
Stream
(
demux_t
*
demux_
,
const
StreamType
type_
,
const
StreamFormat
&
format_
)
Stream
::
Stream
(
demux_t
*
demux_
,
const
StreamFormat
&
format_
)
{
p_demux
=
demux_
;
type
=
type_
;
type
=
StreamType
::
UNKNOWN
;
format
=
format_
;
output
=
NULL
;
adaptationLogic
=
NULL
;
currentChunk
=
NULL
;
eof
=
false
;
disabled
=
false
;
segmentTracker
=
NULL
;
streamOutputFactory
=
NULL
;
}
...
...
@@ -129,7 +130,12 @@ SegmentChunk * Stream::getChunk()
{
if
(
currentChunk
==
NULL
&&
output
)
{
currentChunk
=
segmentTracker
->
getNextChunk
(
type
,
output
->
switchAllowed
());
if
(
esCount
()
&&
!
isSelected
())
{
disabled
=
true
;
return
NULL
;
}
currentChunk
=
segmentTracker
->
getNextChunk
(
output
->
switchAllowed
());
if
(
currentChunk
==
NULL
)
eof
=
true
;
}
...
...
@@ -146,6 +152,25 @@ bool Stream::isSelected() const
return
output
&&
output
->
isSelected
();
}
bool
Stream
::
reactivate
(
mtime_t
basetime
)
{
if
(
setPosition
(
basetime
,
false
))
{
disabled
=
false
;
return
true
;
}
else
{
eof
=
true
;
/* can't reactivate */
return
false
;
}
}
bool
Stream
::
isDisabled
()
const
{
return
disabled
;
}
Stream
::
status
Stream
::
demux
(
HTTPConnectionManager
*
connManager
,
mtime_t
nz_deadline
,
bool
send
)
{
if
(
!
output
)
...
...
modules/demux/adaptative/Streams.hpp
View file @
458adc37
...
...
@@ -61,7 +61,7 @@ namespace adaptative
class
Stream
{
public:
Stream
(
demux_t
*
,
const
StreamType
,
const
StreamFormat
&
);
Stream
(
demux_t
*
,
const
StreamFormat
&
);
~
Stream
();
bool
operator
==
(
const
Stream
&
)
const
;
static
StreamType
mimeToType
(
const
std
::
string
&
mime
);
...
...
@@ -75,6 +75,8 @@ namespace adaptative
int
esCount
()
const
;
bool
seekAble
()
const
;
bool
isSelected
()
const
;
bool
reactivate
(
mtime_t
);
bool
isDisabled
()
const
;
typedef
enum
{
status_eof
,
status_buffering
,
status_demuxed
}
status
;
status
demux
(
HTTPConnectionManager
*
,
mtime_t
,
bool
);
bool
setPosition
(
mtime_t
,
bool
);
...
...
@@ -91,6 +93,7 @@ namespace adaptative
AbstractAdaptationLogic
*
adaptationLogic
;
SegmentTracker
*
segmentTracker
;
SegmentChunk
*
currentChunk
;
bool
disabled
;
bool
eof
;
const
AbstractStreamOutputFactory
*
streamOutputFactory
;
...
...
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
View file @
458adc37
...
...
@@ -26,14 +26,13 @@
#define ABSTRACTADAPTATIONLOGIC_H_
#include "IDownloadRateObserver.h"
#include "../StreamsType.hpp"
namespace
adaptative
{
namespace
playlist
{
class
BaseRepresentation
;
class
Base
Period
;
class
Base
AdaptationSet
;
}
namespace
logic
...
...
@@ -46,7 +45,7 @@ namespace adaptative
AbstractAdaptationLogic
();
virtual
~
AbstractAdaptationLogic
();
virtual
BaseRepresentation
*
getCurrentRepresentation
(
StreamType
,
BasePeriod
*
)
const
=
0
;
virtual
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
=
0
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
enum
LogicType
...
...
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
View file @
458adc37
...
...
@@ -36,8 +36,8 @@ AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic () :
{
}
BaseRepresentation
*
AlwaysBestAdaptationLogic
::
getCurrentRepresentation
(
a
daptati
ve
::
StreamType
type
,
BasePeriod
*
period
)
const
BaseRepresentation
*
AlwaysBestAdaptationLogic
::
getCurrentRepresentation
(
BaseA
daptati
onSet
*
adaptSet
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
period
,
type
);
return
selector
.
select
(
adaptSet
);
}
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.h
View file @
458adc37
...
...
@@ -36,7 +36,7 @@ namespace adaptative
public:
AlwaysBestAdaptationLogic
();
virtual
BaseRepresentation
*
getCurrentRepresentation
(
StreamType
,
BasePeriod
*
)
const
;
virtual
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
;
};
}
}
...
...
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.cpp
View file @
458adc37
...
...
@@ -28,8 +28,8 @@ AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic():
{
}
BaseRepresentation
*
AlwaysLowestAdaptationLogic
::
getCurrentRepresentation
(
a
daptati
ve
::
StreamType
type
,
BasePeriod
*
period
)
const
BaseRepresentation
*
AlwaysLowestAdaptationLogic
::
getCurrentRepresentation
(
BaseA
daptati
onSet
*
adaptSet
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
period
,
type
,
0
);
return
selector
.
select
(
adaptSet
,
0
);
}
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.hpp
View file @
458adc37
...
...
@@ -31,7 +31,7 @@ namespace adaptative
public:
AlwaysLowestAdaptationLogic
();
virtual
BaseRepresentation
*
getCurrentRepresentation
(
StreamType
,
BasePeriod
*
)
const
;
virtual
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
;
};
}
}
...
...
modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
View file @
458adc37
...
...
@@ -47,16 +47,16 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
stabilizer
=
16
;
}
BaseRepresentation
*
RateBasedAdaptationLogic
::
getCurrentRepresentation
(
a
daptati
ve
::
StreamType
type
,
BasePeriod
*
period
)
const
BaseRepresentation
*
RateBasedAdaptationLogic
::
getCurrentRepresentation
(
BaseA
daptati
onSet
*
adaptSet
)
const
{
if
(
period
==
NULL
)
if
(
adaptSet
==
NULL
)
return
NULL
;
RepresentationSelector
selector
;
BaseRepresentation
*
rep
=
selector
.
select
(
period
,
type
,
currentBps
,
width
,
height
);
BaseRepresentation
*
rep
=
selector
.
select
(
adaptSet
,
currentBps
,
width
,
height
);
if
(
rep
==
NULL
)
{
rep
=
selector
.
select
(
period
,
type
);
rep
=
selector
.
select
(
adaptSet
);
if
(
rep
==
NULL
)
return
NULL
;
}
...
...
@@ -98,16 +98,16 @@ FixedRateAdaptationLogic::FixedRateAdaptationLogic(size_t bps) :
currentBps
=
bps
;
}
BaseRepresentation
*
FixedRateAdaptationLogic
::
getCurrentRepresentation
(
a
daptati
ve
::
StreamType
type
,
BasePeriod
*
period
)
const
BaseRepresentation
*
FixedRateAdaptationLogic
::
getCurrentRepresentation
(
BaseA
daptati
onSet
*
adaptSet
)
const
{
if
(
period
==
NULL
)
if
(
adaptSet
==
NULL
)
return
NULL
;
RepresentationSelector
selector
;
BaseRepresentation
*
rep
=
selector
.
select
(
period
,
type
,
currentBps
);
BaseRepresentation
*
rep
=
selector
.
select
(
adaptSet
,
currentBps
);
if
(
rep
==
NULL
)
{
rep
=
selector
.
select
(
period
,
type
);
rep
=
selector
.
select
(
adaptSet
);
if
(
rep
==
NULL
)
return
NULL
;
}
...
...
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
View file @
458adc37
...
...
@@ -39,7 +39,7 @@ namespace adaptative
public:
RateBasedAdaptationLogic
(
int
,
int
);
BaseRepresentation
*
getCurrentRepresentation
(
StreamType
,
BasePeriod
*
)
const
;
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
private:
...
...
@@ -57,7 +57,7 @@ namespace adaptative
public:
FixedRateAdaptationLogic
(
size_t
);
BaseRepresentation
*
getCurrentRepresentation
(
StreamType
,
BasePeriod
*
)
const
;
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
;
private:
size_t
currentBps
;
...
...
modules/demux/adaptative/logic/Representationselectors.cpp
View file @
458adc37
...
...
@@ -29,57 +29,47 @@ RepresentationSelector::RepresentationSelector()
{
}
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
Period
*
period
,
adaptative
::
StreamType
type
)
const
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
AdaptationSet
*
adaptSet
)
const
{
return
select
(
period
,
type
,
std
::
numeric_limits
<
uint64_t
>::
max
());
return
select
(
adaptSet
,
std
::
numeric_limits
<
uint64_t
>::
max
());
}
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
Period
*
period
,
adaptative
::
StreamType
type
,
uint64_t
bitrate
)
const
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
AdaptationSet
*
adaptSet
,
uint64_t
bitrate
)
const
{
if
(
period
==
NULL
)
if
(
adaptSet
==
NULL
)
return
NULL
;
std
::
vector
<
BaseAdaptationSet
*>
adaptSets
=
period
->
getAdaptationSets
(
type
);
BaseRepresentation
*
best
=
NULL
;
std
::
vector
<
BaseAdaptationSet
*>::
const_iterator
adaptIt
;
for
(
adaptIt
=
adaptSets
.
begin
();
adaptIt
!=
adaptSets
.
end
();
++
adaptIt
)
std
::
vector
<
BaseRepresentation
*>
reps
=
adaptSet
->
getRepresentations
();
BaseRepresentation
*
candidate
=
select
(
reps
,
(
best
)
?
best
->
getBandwidth
()
:
0
,
bitrate
)
;
if
(
candidate
)
{
std
::
vector
<
BaseRepresentation
*>
reps
=
(
*
adaptIt
)
->
getRepresentations
();
BaseRepresentation
*
candidate
=
select
(
reps
,
(
best
)
?
best
->
getBandwidth
()
:
0
,
bitrate
);
if
(
candidate
)
{
if
(
candidate
->
getBandwidth
()
>
bitrate
)
/* none matched, returned lowest */
return
candidate
;
best
=
candidate
;
}
if
(
candidate
->
getBandwidth
()
>
bitrate
)
/* none matched, returned lowest */
return
candidate
;
best
=
candidate
;
}
return
best
;
}
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
Period
*
period
,
adaptative
::
StreamType
type
,
uint64_t
bitrate
,
BaseRepresentation
*
RepresentationSelector
::
select
(
Base
AdaptationSet
*
adaptSet
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
{
if
(
period
==
NULL
)
if
(
adaptSet
==
NULL
)
return
NULL
;
std
::
vector
<
BaseRepresentation
*>
resMatchReps
;
/* subset matching WxH */
std
::
vector
<
Base
Adap
tation
Set
*>
adaptSet
s
=
period
->
getAdaptationSets
(
type
);
std
::
vector
<
Base
Adap
tation
Set
*>::
const_iterator
adapt
It
;
for
(
adaptIt
=
adaptSets
.
begin
();
adaptIt
!=
adaptSet
s
.
end
();
++
adapt
It
)
std
::
vector
<
Base
Represen
tation
*>
reps
=
adaptSet
->
getRepresentations
(
);
std
::
vector
<
Base
Represen
tation
*>::
const_iterator
rep
It
;
for
(
repIt
=
reps
.
begin
();
repIt
!=
rep
s
.
end
();
++
rep
It
)
{
std
::
vector
<
BaseRepresentation
*>
reps
=
(
*
adaptIt
)
->
getRepresentations
();
std
::
vector
<
BaseRepresentation
*>::
const_iterator
repIt
;
for
(
repIt
=
reps
.
begin
();
repIt
!=
reps
.
end
();
++
repIt
)
{
if
((
*
repIt
)
->
getWidth
()
==
width
&&
(
*
repIt
)
->
getHeight
()
==
height
)
resMatchReps
.
push_back
(
*
repIt
);
}
if
((
*
repIt
)
->
getWidth
()
==
width
&&
(
*
repIt
)
->
getHeight
()
==
height
)
resMatchReps
.
push_back
(
*
repIt
);
}
if
(
resMatchReps
.
empty
())
return
select
(
period
,
type
,
bitrate
);
return
select
(
adaptSet
,
bitrate
);
else
return
select
(
resMatchReps
,
0
,
bitrate
);
}
...
...
modules/demux/adaptative/logic/Representationselectors.hpp
View file @
458adc37
...
...
@@ -20,15 +20,15 @@
#ifndef REPRESENTATIONSELECTORS_HPP
#define REPRESENTATIONSELECTORS_HPP
#include "../Streams.hpp"
#include <vector>
#include <vlc_common.h>
namespace
adaptative
{
namespace
playlist
{
class
BaseRepresentation
;
class
Base
Period
;
class
Base
AdaptationSet
;
}
namespace
logic
...
...
@@ -40,9 +40,9 @@ namespace adaptative
public:
RepresentationSelector
();
virtual
~
RepresentationSelector
()
{}
virtual
BaseRepresentation
*
select
(
Base
Period
*
period
,
StreamType
)
const
;
virtual
BaseRepresentation
*
select
(
Base
Period
*
period
,
StreamType
,
uint64_t
bitrate
)
const
;
virtual
BaseRepresentation
*
select
(
Base
Period
*
period
,
StreamType
,
uint64_t
bitrate
,
virtual
BaseRepresentation
*
select
(
Base
AdaptationSet
*
)
const
;
virtual
BaseRepresentation
*
select
(
Base
AdaptationSet
*
,
uint64_t
bitrate
)
const
;
virtual
BaseRepresentation
*
select
(
Base
AdaptationSet
*
,
uint64_t
bitrate
,
int
width
,
int
height
)
const
;
protected:
virtual
BaseRepresentation
*
select
(
std
::
vector
<
BaseRepresentation
*>&
reps
,
...
...
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