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
4497a587
Commit
4497a587
authored
Nov 07, 2015
by
François Cartegnie
🤞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: adaptative: account and split bandwidth usage
parent
62cbf970
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
12 deletions
+36
-12
modules/demux/adaptative/SegmentTracker.cpp
modules/demux/adaptative/SegmentTracker.cpp
+1
-0
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
+5
-2
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
+1
-1
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
+1
-1
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
+21
-3
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
+5
-3
No files found.
modules/demux/adaptative/SegmentTracker.cpp
View file @
4497a587
...
...
@@ -60,6 +60,7 @@ SegmentTracker::~SegmentTracker()
void
SegmentTracker
::
setAdaptationLogic
(
AbstractAdaptationLogic
*
logic_
)
{
logic
=
logic_
;
registerListener
(
logic
);
}
void
SegmentTracker
::
reset
()
...
...
modules/demux/adaptative/logic/AbstractAdaptationLogic.h
View file @
4497a587
...
...
@@ -26,6 +26,7 @@
#define ABSTRACTADAPTATIONLOGIC_H_
#include "IDownloadRateObserver.h"
#include "../SegmentTracker.hpp"
namespace
adaptative
{
...
...
@@ -39,14 +40,16 @@ namespace adaptative
{
using
namespace
playlist
;
class
AbstractAdaptationLogic
:
public
IDownloadRateObserver
class
AbstractAdaptationLogic
:
public
IDownloadRateObserver
,
public
SegmentTrackerListenerInterface
{
public:
AbstractAdaptationLogic
();
virtual
~
AbstractAdaptationLogic
();
virtual
BaseRepresentation
*
get
Curren
tRepresentation
(
BaseAdaptationSet
*
)
const
=
0
;
virtual
BaseRepresentation
*
get
Nex
tRepresentation
(
BaseAdaptationSet
*
,
BaseRepresentation
*
)
const
=
0
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
virtual
void
trackerEvent
(
const
SegmentTrackerEvent
&
)
{}
enum
LogicType
{
...
...
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.cpp
View file @
4497a587
...
...
@@ -36,7 +36,7 @@ AlwaysBestAdaptationLogic::AlwaysBestAdaptationLogic () :
{
}
BaseRepresentation
*
AlwaysBestAdaptationLogic
::
get
Curren
tRepresentation
(
BaseAdaptationSet
*
adaptSet
)
const
BaseRepresentation
*
AlwaysBestAdaptationLogic
::
get
Nex
tRepresentation
(
BaseAdaptationSet
*
adaptSet
,
BaseRepresentation
*
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
adaptSet
);
...
...
modules/demux/adaptative/logic/AlwaysBestAdaptationLogic.h
View file @
4497a587
...
...
@@ -36,7 +36,7 @@ namespace adaptative
public:
AlwaysBestAdaptationLogic
();
virtual
BaseRepresentation
*
get
Curren
tRepresentation
(
BaseAdaptationSet
*
)
const
;
virtual
BaseRepresentation
*
get
Nex
tRepresentation
(
BaseAdaptationSet
*
,
BaseRepresentation
*
)
const
;
};
}
}
...
...
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.cpp
View file @
4497a587
...
...
@@ -28,7 +28,7 @@ AlwaysLowestAdaptationLogic::AlwaysLowestAdaptationLogic():
{
}
BaseRepresentation
*
AlwaysLowestAdaptationLogic
::
get
Curren
tRepresentation
(
BaseAdaptationSet
*
adaptSet
)
const
BaseRepresentation
*
AlwaysLowestAdaptationLogic
::
get
Nex
tRepresentation
(
BaseAdaptationSet
*
adaptSet
,
BaseRepresentation
*
)
const
{
RepresentationSelector
selector
;
return
selector
.
select
(
adaptSet
,
0
);
...
...
modules/demux/adaptative/logic/AlwaysLowestAdaptationLogic.hpp
View file @
4497a587
...
...
@@ -31,7 +31,7 @@ namespace adaptative
public:
AlwaysLowestAdaptationLogic
();
virtual
BaseRepresentation
*
get
Curren
tRepresentation
(
BaseAdaptationSet
*
)
const
;
virtual
BaseRepresentation
*
get
Nex
tRepresentation
(
BaseAdaptationSet
*
,
BaseRepresentation
*
)
const
;
};
}
}
...
...
modules/demux/adaptative/logic/RateBasedAdaptationLogic.cpp
View file @
4497a587
...
...
@@ -40,15 +40,22 @@ RateBasedAdaptationLogic::RateBasedAdaptationLogic (int w, int h) :
{
width
=
w
;
height
=
h
;
usedBps
=
0
;
}
BaseRepresentation
*
RateBasedAdaptationLogic
::
get
Curren
tRepresentation
(
BaseAdaptationSet
*
adaptSet
)
const
BaseRepresentation
*
RateBasedAdaptationLogic
::
get
Nex
tRepresentation
(
BaseAdaptationSet
*
adaptSet
,
BaseRepresentation
*
currep
)
const
{
if
(
adaptSet
==
NULL
)
return
NULL
;
size_t
availBps
=
currentBps
+
((
currep
)
?
currep
->
getBandwidth
()
:
0
);
if
(
availBps
>
usedBps
)
availBps
-=
usedBps
;
else
availBps
=
0
;
RepresentationSelector
selector
;
BaseRepresentation
*
rep
=
selector
.
select
(
adaptSet
,
current
Bps
,
width
,
height
);
BaseRepresentation
*
rep
=
selector
.
select
(
adaptSet
,
avail
Bps
,
width
,
height
);
if
(
rep
==
NULL
)
{
rep
=
selector
.
select
(
adaptSet
);
...
...
@@ -79,13 +86,24 @@ void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
currentBps
=
bpsAvg
*
3
/
4
;
}
void
RateBasedAdaptationLogic
::
trackerEvent
(
const
SegmentTrackerEvent
&
event
)
{
if
(
event
.
type
==
SegmentTrackerEvent
::
SWITCHING
)
{
if
(
event
.
u
.
switching
.
prev
)
usedBps
-=
event
.
u
.
switching
.
prev
->
getBandwidth
();
if
(
event
.
u
.
switching
.
next
)
usedBps
+=
event
.
u
.
switching
.
next
->
getBandwidth
();
}
}
FixedRateAdaptationLogic
::
FixedRateAdaptationLogic
(
size_t
bps
)
:
AbstractAdaptationLogic
()
{
currentBps
=
bps
;
}
BaseRepresentation
*
FixedRateAdaptationLogic
::
get
Curren
tRepresentation
(
BaseAdaptationSet
*
adaptSet
)
const
BaseRepresentation
*
FixedRateAdaptationLogic
::
get
Nex
tRepresentation
(
BaseAdaptationSet
*
adaptSet
,
BaseRepresentation
*
)
const
{
if
(
adaptSet
==
NULL
)
return
NULL
;
...
...
modules/demux/adaptative/logic/RateBasedAdaptationLogic.h
View file @
4497a587
...
...
@@ -39,8 +39,9 @@ namespace adaptative
public:
RateBasedAdaptationLogic
(
int
,
int
);
BaseRepresentation
*
getCurrentRepresentation
(
BaseAdaptationSet
*
)
const
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
BaseRepresentation
*
getNextRepresentation
(
BaseAdaptationSet
*
,
BaseRepresentation
*
)
const
;
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
/* reimpl */
virtual
void
trackerEvent
(
const
SegmentTrackerEvent
&
);
/* reimpl */
private:
int
width
;
...
...
@@ -49,6 +50,7 @@ namespace adaptative
size_t
bpsRemainder
;
size_t
bpsSamplecount
;
size_t
currentBps
;
size_t
usedBps
;
};
class
FixedRateAdaptationLogic
:
public
AbstractAdaptationLogic
...
...
@@ -56,7 +58,7 @@ namespace adaptative
public:
FixedRateAdaptationLogic
(
size_t
);
BaseRepresentation
*
get
Curren
tRepresentation
(
BaseAdaptationSet
*
)
const
;
BaseRepresentation
*
get
Nex
tRepresentation
(
BaseAdaptationSet
*
,
BaseRepresentation
*
)
const
;
private:
size_t
currentBps
;
...
...
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