Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Steve Lhomme
VLC
Commits
2741ffe6
Commit
2741ffe6
authored
Nov 02, 2015
by
François Cartegnie
🤞
Browse files
demux: adaptative: fix splitted bandwidth stats
And avoids creating stats from non http chunks (smooth)
parent
0deb1edc
Changes
22
Hide whitespace changes
Inline
Side-by-side
modules/demux/adaptative/PlaylistManager.cpp
View file @
2741ffe6
...
...
@@ -49,6 +49,7 @@ PlaylistManager::PlaylistManager( demux_t *p_demux_,
AbstractAdaptationLogic
::
LogicType
type
)
:
conManager
(
NULL
),
logicType
(
type
),
logic
(
NULL
),
playlist
(
pl
),
streamFactory
(
factory
),
p_demux
(
p_demux_
),
...
...
@@ -79,6 +80,9 @@ bool PlaylistManager::setupPeriod()
if
(
!
currentPeriod
)
return
false
;
if
(
!
logic
&&
!
(
logic
=
createLogic
(
logicType
,
conManager
)))
return
false
;
std
::
vector
<
BaseAdaptationSet
*>
sets
=
currentPeriod
->
getAdaptationSets
();
std
::
vector
<
BaseAdaptationSet
*>::
iterator
it
;
for
(
it
=
sets
.
begin
();
it
!=
sets
.
end
();
++
it
)
...
...
@@ -86,10 +90,6 @@ bool PlaylistManager::setupPeriod()
BaseAdaptationSet
*
set
=
*
it
;
if
(
set
&&
streamFactory
)
{
AbstractAdaptationLogic
*
logic
=
createLogic
(
logicType
);
if
(
!
logic
)
continue
;
SegmentTracker
*
tracker
=
new
(
std
::
nothrow
)
SegmentTracker
(
logic
,
set
);
if
(
!
tracker
)
{
...
...
@@ -98,7 +98,7 @@ bool PlaylistManager::setupPeriod()
}
AbstractStream
*
st
=
streamFactory
->
create
(
p_demux
,
set
->
getStreamFormat
(),
logic
,
tracker
,
conManager
);
tracker
,
conManager
);
if
(
!
st
)
{
delete
tracker
;
...
...
@@ -391,7 +391,7 @@ int PlaylistManager::doControl(int i_query, va_list args)
return
VLC_SUCCESS
;
}
AbstractAdaptationLogic
*
PlaylistManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
)
AbstractAdaptationLogic
*
PlaylistManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
,
HTTPConnectionManager
*
conn
)
{
switch
(
type
)
{
...
...
@@ -402,7 +402,11 @@ AbstractAdaptationLogic *PlaylistManager::createLogic(AbstractAdaptationLogic::L
return
new
(
std
::
nothrow
)
AlwaysLowestAdaptationLogic
();
case
AbstractAdaptationLogic
::
Default
:
case
AbstractAdaptationLogic
::
RateBased
:
return
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
0
,
0
);
{
RateBasedAdaptationLogic
*
logic
=
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
0
,
0
);
conn
->
setDownloadRateObserver
(
logic
);
return
logic
;
}
default:
return
NULL
;
}
...
...
modules/demux/adaptative/PlaylistManager.h
View file @
2741ffe6
...
...
@@ -74,10 +74,12 @@ namespace adaptative
bool
setupPeriod
();
void
unsetPeriod
();
/* local factories */
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
);
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
,
HTTPConnectionManager
*
);
HTTPConnectionManager
*
conManager
;
AbstractAdaptationLogic
::
LogicType
logicType
;
AbstractAdaptationLogic
*
logic
;
AbstractPlaylist
*
playlist
;
AbstractStreamFactory
*
streamFactory
;
demux_t
*
p_demux
;
...
...
modules/demux/adaptative/Streams.cpp
View file @
2741ffe6
...
...
@@ -20,7 +20,6 @@
#include
"Streams.hpp"
#include
"http/HTTPConnection.hpp"
#include
"http/HTTPConnectionManager.h"
#include
"logic/AbstractAdaptationLogic.h"
#include
"playlist/SegmentChunk.hpp"
#include
"SegmentTracker.hpp"
#include
"plumbing/SourceStream.hpp"
...
...
@@ -30,13 +29,11 @@
using
namespace
adaptative
;
using
namespace
adaptative
::
http
;
using
namespace
adaptative
::
logic
;
AbstractStream
::
AbstractStream
(
demux_t
*
demux_
,
const
StreamFormat
&
format_
)
{
p_realdemux
=
demux_
;
format
=
format_
;
adaptationLogic
=
NULL
;
currentChunk
=
NULL
;
eof
=
false
;
dead
=
false
;
...
...
@@ -71,7 +68,6 @@ AbstractStream::AbstractStream(demux_t * demux_, const StreamFormat &format_)
AbstractStream
::~
AbstractStream
()
{
delete
currentChunk
;
delete
adaptationLogic
;
delete
segmentTracker
;
delete
demuxer
;
...
...
@@ -80,10 +76,8 @@ AbstractStream::~AbstractStream()
}
void
AbstractStream
::
bind
(
AbstractAdaptationLogic
*
logic
,
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
conn
)
void
AbstractStream
::
bind
(
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
conn
)
{
adaptationLogic
=
logic
;
segmentTracker
=
tracker
;
connManager
=
conn
;
}
...
...
@@ -226,7 +220,7 @@ bool AbstractStream::isDisabled() const
AbstractStream
::
status
AbstractStream
::
demux
(
mtime_t
nz_deadline
,
bool
send
)
{
/* Ensure it is configured */
if
(
!
adaptationLogic
||
!
segmentTracker
||
!
connManager
||
dead
)
if
(
!
segmentTracker
||
!
connManager
||
dead
)
return
AbstractStream
::
status_eof
;
if
(
flushing
)
...
...
@@ -322,8 +316,7 @@ block_t * AbstractStream::readNextBlock(size_t toread)
const
bool
b_segment_head_chunk
=
(
chunk
->
getBytesRead
()
==
0
);
mtime_t
time
;
block_t
*
block
=
chunk
->
read
(
toread
,
&
time
);
block_t
*
block
=
chunk
->
read
(
toread
);
if
(
block
==
NULL
)
{
currentChunk
=
NULL
;
...
...
@@ -331,7 +324,6 @@ block_t * AbstractStream::readNextBlock(size_t toread)
return
NULL
;
}
adaptationLogic
->
updateDownloadRate
(
block
->
i_buffer
,
time
);
if
(
chunk
->
getBytesToRead
()
==
0
)
{
currentChunk
=
NULL
;
...
...
modules/demux/adaptative/Streams.hpp
View file @
2741ffe6
...
...
@@ -43,18 +43,12 @@ namespace adaptative
class
HTTPConnectionManager
;
}
namespace
logic
{
class
AbstractAdaptationLogic
;
}
namespace
playlist
{
class
SegmentChunk
;
}
using
namespace
http
;
using
namespace
logic
;
using
namespace
playlist
;
class
AbstractStream
:
public
ChunksSource
,
...
...
@@ -63,8 +57,7 @@ namespace adaptative
public:
AbstractStream
(
demux_t
*
,
const
StreamFormat
&
);
virtual
~
AbstractStream
();
void
bind
(
AbstractAdaptationLogic
*
,
SegmentTracker
*
,
HTTPConnectionManager
*
);
void
bind
(
SegmentTracker
*
,
HTTPConnectionManager
*
);
void
setLanguage
(
const
std
::
string
&
);
void
setDescription
(
const
std
::
string
&
);
...
...
@@ -105,7 +98,6 @@ namespace adaptative
demux_t
*
p_realdemux
;
StreamFormat
format
;
AbstractAdaptationLogic
*
adaptationLogic
;
HTTPConnectionManager
*
connManager
;
/* not owned */
SegmentTracker
*
segmentTracker
;
...
...
@@ -128,8 +120,7 @@ namespace adaptative
public:
virtual
~
AbstractStreamFactory
()
{}
virtual
AbstractStream
*
create
(
demux_t
*
,
const
StreamFormat
&
,
AbstractAdaptationLogic
*
,
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
=
0
;
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
=
0
;
};
}
#endif // STREAMS_HPP
modules/demux/adaptative/http/Chunk.cpp
View file @
2741ffe6
...
...
@@ -90,15 +90,12 @@ size_t AbstractChunk::getBytesToRead() const
return
source
->
getContentLength
()
-
bytesRead
;
}
block_t
*
AbstractChunk
::
read
(
size_t
size
,
mtime_t
*
time
)
block_t
*
AbstractChunk
::
read
(
size_t
size
)
{
if
(
!
source
)
return
NULL
;
*
time
=
mdate
();
block_t
*
block
=
source
->
read
(
size
);
*
time
=
mdate
()
-
*
time
;
if
(
block
)
{
if
(
bytesRead
==
0
)
...
...
@@ -173,7 +170,9 @@ block_t * HTTPChunkSource::consume(size_t readsize)
if
(
!
p_block
)
return
NULL
;
mtime_t
time
=
mdate
();
ssize_t
ret
=
connection
->
read
(
p_block
->
p_buffer
,
readsize
);
time
=
mdate
()
-
time
;
if
(
ret
<
0
)
{
block_Release
(
p_block
);
...
...
@@ -183,6 +182,7 @@ block_t * HTTPChunkSource::consume(size_t readsize)
{
p_block
->
i_buffer
=
(
size_t
)
ret
;
consumed
+=
p_block
->
i_buffer
;
connManager
->
updateDownloadRate
(
p_block
->
i_buffer
,
time
);
}
return
p_block
;
...
...
@@ -240,7 +240,9 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
if
(
!
p_block
)
return
;
mtime_t
time
=
mdate
();
ssize_t
ret
=
connection
->
read
(
p_block
->
p_buffer
,
readsize
);
time
=
mdate
()
-
time
;
if
(
ret
<
0
)
{
block_Release
(
p_block
);
...
...
@@ -250,6 +252,7 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
p_block
->
i_buffer
=
(
size_t
)
ret
;
buffered
+=
p_block
->
i_buffer
;
block_ChainAppend
(
&
p_buffer
,
p_block
);
connManager
->
updateDownloadRate
(
p_block
->
i_buffer
,
time
);
}
}
...
...
modules/demux/adaptative/http/Chunk.h
View file @
2741ffe6
...
...
@@ -65,7 +65,7 @@ namespace adaptative
size_t
getBytesRead
()
const
;
size_t
getBytesToRead
()
const
;
virtual
block_t
*
read
(
size_t
,
mtime_t
*
);
virtual
block_t
*
read
(
size_t
);
virtual
void
onDownload
(
block_t
**
)
=
0
;
protected:
...
...
modules/demux/adaptative/http/HTTPConnectionManager.cpp
View file @
2741ffe6
...
...
@@ -33,7 +33,8 @@
using
namespace
adaptative
::
http
;
HTTPConnectionManager
::
HTTPConnectionManager
(
vlc_object_t
*
stream
)
:
stream
(
stream
)
stream
(
stream
),
rateObserver
(
NULL
)
{
}
HTTPConnectionManager
::~
HTTPConnectionManager
()
...
...
@@ -100,3 +101,14 @@ HTTPConnection * HTTPConnectionManager::getConnection(const std::string &scheme,
conn
->
setUsed
(
true
);
return
conn
;
}
void
HTTPConnectionManager
::
updateDownloadRate
(
size_t
size
,
mtime_t
time
)
{
if
(
rateObserver
)
rateObserver
->
updateDownloadRate
(
size
,
time
);
}
void
HTTPConnectionManager
::
setDownloadRateObserver
(
IDownloadRateObserver
*
obs
)
{
rateObserver
=
obs
;
}
modules/demux/adaptative/http/HTTPConnectionManager.h
View file @
2741ffe6
...
...
@@ -29,6 +29,8 @@
# include "config.h"
#endif
#include
"../logic/IDownloadRateObserver.h"
#include
<vlc_common.h>
#include
<vector>
#include
<string>
...
...
@@ -39,7 +41,7 @@ namespace adaptative
{
class
HTTPConnection
;
class
HTTPConnectionManager
class
HTTPConnectionManager
:
public
IDownloadRateObserver
{
public:
HTTPConnectionManager
(
vlc_object_t
*
stream
);
...
...
@@ -51,9 +53,13 @@ namespace adaptative
const
std
::
string
&
hostname
,
uint16_t
port
);
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
);
/* reimpl */
void
setDownloadRateObserver
(
IDownloadRateObserver
*
);
private:
std
::
vector
<
HTTPConnection
*>
connectionPool
;
vlc_object_t
*
stream
;
IDownloadRateObserver
*
rateObserver
;
HTTPConnection
*
getConnection
(
const
std
::
string
&
hostname
,
uint16_t
port
,
int
);
};
...
...
modules/demux/adaptative/logic/IDownloadRateObserver.h
View file @
2741ffe6
...
...
@@ -33,15 +33,12 @@
namespace
adaptative
{
namespace
logic
class
IDownloadRateObserver
{
class
IDownloadRateObserver
{
public:
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
)
=
0
;
virtual
~
IDownloadRateObserver
(){}
};
}
public:
virtual
void
updateDownloadRate
(
size_t
,
mtime_t
)
=
0
;
virtual
~
IDownloadRateObserver
(){}
};
}
#endif
/* IDOWNLOADRATEOBSERVER_H_ */
modules/demux/adaptative/tools/Retrieve.cpp
View file @
2741ffe6
...
...
@@ -37,8 +37,7 @@ block_t * Retrieve::HTTP(vlc_object_t *obj, const std::string &uri)
return
NULL
;
}
mtime_t
time
;
block_t
*
block
=
datachunk
->
read
(
1
<<
21
,
&
time
);
block_t
*
block
=
datachunk
->
read
(
1
<<
21
);
delete
datachunk
;
return
block
;
}
modules/demux/dash/DASHManager.cpp
View file @
2741ffe6
...
...
@@ -34,6 +34,7 @@
#include
"xml/DOMParser.h"
#include
"../adaptative/logic/RateBasedAdaptationLogic.h"
#include
"../adaptative/tools/Helper.h"
#include
"../adaptative/http/HTTPConnectionManager.h"
#include
<vlc_stream.h>
#include
<vlc_demux.h>
#include
<vlc_meta.h>
...
...
@@ -200,7 +201,8 @@ bool DASHManager::isDASH(stream_t *stream)
return
false
;
}
AbstractAdaptationLogic
*
DASHManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
)
AbstractAdaptationLogic
*
DASHManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
,
HTTPConnectionManager
*
conn
)
{
switch
(
type
)
{
...
...
@@ -214,9 +216,11 @@ AbstractAdaptationLogic *DASHManager::createLogic(AbstractAdaptationLogic::Logic
{
int
width
=
var_InheritInteger
(
p_demux
,
"adaptative-width"
);
int
height
=
var_InheritInteger
(
p_demux
,
"adaptative-height"
);
return
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
width
,
height
);
RateBasedAdaptationLogic
*
logic
=
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
width
,
height
);
conn
->
setDownloadRateObserver
(
logic
);
return
logic
;
}
default:
return
PlaylistManager
::
createLogic
(
type
);
return
PlaylistManager
::
createLogic
(
type
,
conn
);
}
}
modules/demux/dash/DASHManager.h
View file @
2741ffe6
...
...
@@ -42,7 +42,8 @@ namespace dash
virtual
~
DASHManager
();
virtual
bool
updatePlaylist
();
//reimpl
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
);
//reimpl
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
,
HTTPConnectionManager
*
);
//reimpl
static
bool
isDASH
(
stream_t
*
);
...
...
modules/demux/dash/DASHStream.cpp
View file @
2741ffe6
...
...
@@ -69,8 +69,7 @@ AbstractDemuxer * DASHStream::createDemux(const StreamFormat &format)
}
AbstractStream
*
DASHStreamFactory
::
create
(
demux_t
*
realdemux
,
const
StreamFormat
&
format
,
AbstractAdaptationLogic
*
logic
,
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
manager
)
const
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
manager
)
const
{
AbstractStream
*
stream
;
try
...
...
@@ -79,6 +78,6 @@ AbstractStream * DASHStreamFactory::create(demux_t *realdemux, const StreamForma
}
catch
(
int
)
{
return
NULL
;
}
stream
->
bind
(
logic
,
tracker
,
manager
);
stream
->
bind
(
tracker
,
manager
);
return
stream
;
}
modules/demux/dash/DASHStream.hpp
View file @
2741ffe6
...
...
@@ -44,8 +44,7 @@ namespace dash
{
public:
virtual
AbstractStream
*
create
(
demux_t
*
,
const
StreamFormat
&
,
AbstractAdaptationLogic
*
,
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
;
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
;
};
}
...
...
modules/demux/hls/HLSManager.cpp
View file @
2741ffe6
...
...
@@ -25,6 +25,7 @@
#include
"HLSManager.hpp"
#include
"../adaptative/logic/RateBasedAdaptationLogic.h"
#include
"../adaptative/tools/Retrieve.hpp"
#include
"../adaptative/http/HTTPConnectionManager.h"
#include
"playlist/Parser.hpp"
#include
<vlc_stream.h>
#include
<vlc_demux.h>
...
...
@@ -102,7 +103,8 @@ bool HLSManager::isHTTPLiveStreaming(stream_t *s)
return
false
;
}
AbstractAdaptationLogic
*
HLSManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
)
AbstractAdaptationLogic
*
HLSManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
,
HTTPConnectionManager
*
conn
)
{
switch
(
type
)
{
...
...
@@ -116,9 +118,11 @@ AbstractAdaptationLogic *HLSManager::createLogic(AbstractAdaptationLogic::LogicT
{
int
width
=
var_InheritInteger
(
p_demux
,
"adaptative-width"
);
int
height
=
var_InheritInteger
(
p_demux
,
"adaptative-height"
);
return
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
width
,
height
);
RateBasedAdaptationLogic
*
logic
=
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
width
,
height
);
conn
->
setDownloadRateObserver
(
logic
);
return
logic
;
}
default:
return
PlaylistManager
::
createLogic
(
type
);
return
PlaylistManager
::
createLogic
(
type
,
conn
);
}
}
modules/demux/hls/HLSManager.hpp
View file @
2741ffe6
...
...
@@ -35,7 +35,8 @@ namespace hls
AbstractStreamFactory
*
,
logic
::
AbstractAdaptationLogic
::
LogicType
type
);
virtual
~
HLSManager
();
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
);
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
,
HTTPConnectionManager
*
);
static
bool
isHTTPLiveStreaming
(
stream_t
*
);
};
...
...
modules/demux/hls/HLSStreams.cpp
View file @
2741ffe6
...
...
@@ -121,8 +121,7 @@ block_t * HLSStream::checkBlock(block_t *p_block, bool b_first)
}
AbstractStream
*
HLSStreamFactory
::
create
(
demux_t
*
realdemux
,
const
StreamFormat
&
format
,
AbstractAdaptationLogic
*
logic
,
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
manager
)
const
SegmentTracker
*
tracker
,
HTTPConnectionManager
*
manager
)
const
{
HLSStream
*
stream
;
try
...
...
@@ -131,6 +130,6 @@ AbstractStream * HLSStreamFactory::create(demux_t *realdemux, const StreamFormat
}
catch
(
int
)
{
return
NULL
;
}
stream
->
bind
(
logic
,
tracker
,
manager
);
stream
->
bind
(
tracker
,
manager
);
return
stream
;
}
modules/demux/hls/HLSStreams.hpp
View file @
2741ffe6
...
...
@@ -52,8 +52,7 @@ namespace hls
{
public:
virtual
AbstractStream
*
create
(
demux_t
*
,
const
StreamFormat
&
,
AbstractAdaptationLogic
*
,
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
;
SegmentTracker
*
,
HTTPConnectionManager
*
)
const
;
};
}
...
...
modules/demux/smooth/SmoothManager.cpp
View file @
2741ffe6
...
...
@@ -186,7 +186,8 @@ bool SmoothManager::isSmoothStreaming(stream_t *stream)
return
ret
;
}
AbstractAdaptationLogic
*
SmoothManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
)
AbstractAdaptationLogic
*
SmoothManager
::
createLogic
(
AbstractAdaptationLogic
::
LogicType
type
,
HTTPConnectionManager
*
conn
)
{
switch
(
type
)
{
...
...
@@ -203,6 +204,6 @@ AbstractAdaptationLogic *SmoothManager::createLogic(AbstractAdaptationLogic::Log
return
new
(
std
::
nothrow
)
RateBasedAdaptationLogic
(
width
,
height
);
}
default:
return
PlaylistManager
::
createLogic
(
type
);
return
PlaylistManager
::
createLogic
(
type
,
conn
);
}
}
modules/demux/smooth/SmoothManager.hpp
View file @
2741ffe6
...
...
@@ -37,7 +37,8 @@ namespace smooth
virtual
~
SmoothManager
();
virtual
bool
updatePlaylist
();
//reimpl
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
);
virtual
AbstractAdaptationLogic
*
createLogic
(
AbstractAdaptationLogic
::
LogicType
,
HTTPConnectionManager
*
);
static
bool
isSmoothStreaming
(
stream_t
*
);
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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