Commit 327d2c09 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: pass adaptationset ID from chunks to rate observers

parent 3fc55ff7
......@@ -116,7 +116,8 @@ block_t * AbstractChunk::read(size_t size)
return doRead(size, false);
}
HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManager *manager) :
HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManager *manager,
const ID &id) :
AbstractChunkSource(),
connection (NULL),
connManager (manager),
......@@ -124,6 +125,7 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManag
{
prepared = false;
eof = false;
sourceid = id;
if(!init(url))
eof = true;
}
......@@ -195,7 +197,7 @@ block_t * HTTPChunkSource::read(size_t readsize)
consumed += p_block->i_buffer;
if((size_t)ret < readsize)
eof = true;
connManager->updateDownloadRate(p_block->i_buffer, time);
connManager->updateDownloadRate(sourceid, p_block->i_buffer, time);
}
return p_block;
......@@ -231,8 +233,9 @@ block_t * HTTPChunkSource::readBlock()
return read(HTTPChunkSource::CHUNK_SIZE);
}
HTTPChunkBufferedSource::HTTPChunkBufferedSource(const std::string& url, AbstractConnectionManager *manager) :
HTTPChunkSource(url, manager),
HTTPChunkBufferedSource::HTTPChunkBufferedSource(const std::string& url, AbstractConnectionManager *manager,
const ID &sourceid) :
HTTPChunkSource(url, manager, sourceid),
p_head (NULL),
pp_tail (&p_head),
buffered (0)
......@@ -334,7 +337,7 @@ void HTTPChunkBufferedSource::bufferize(size_t readsize)
if(rate.size)
{
connManager->updateDownloadRate(rate.size, rate.time);
connManager->updateDownloadRate(sourceid, rate.size, rate.time);
}
vlc_cond_signal(&avail);
......@@ -443,8 +446,9 @@ block_t * HTTPChunkBufferedSource::read(size_t readsize)
return p_block;
}
HTTPChunk::HTTPChunk(const std::string &url, AbstractConnectionManager *manager):
AbstractChunk(new HTTPChunkSource(url, manager))
HTTPChunk::HTTPChunk(const std::string &url, AbstractConnectionManager *manager,
const ID &id):
AbstractChunk(new HTTPChunkSource(url, manager, id))
{
}
......
......@@ -27,6 +27,7 @@
#include "BytesRange.hpp"
#include "ConnectionParams.hpp"
#include "../ID.hpp"
#include <vector>
#include <string>
#include <stdint.h>
......@@ -82,7 +83,8 @@ namespace adaptive
class HTTPChunkSource : public AbstractChunkSource
{
public:
HTTPChunkSource(const std::string &url, AbstractConnectionManager *);
HTTPChunkSource(const std::string &url, AbstractConnectionManager *,
const ID &);
virtual ~HTTPChunkSource();
virtual block_t * readBlock (); /* impl */
......@@ -98,6 +100,7 @@ namespace adaptive
size_t consumed; /* read pointer */
bool prepared;
bool eof;
ID sourceid;
private:
bool init(const std::string &);
......@@ -109,7 +112,8 @@ namespace adaptive
friend class Downloader;
public:
HTTPChunkBufferedSource(const std::string &url, AbstractConnectionManager *);
HTTPChunkBufferedSource(const std::string &url, AbstractConnectionManager *,
const ID &);
virtual ~HTTPChunkBufferedSource();
virtual block_t * readBlock (); /* reimpl */
virtual block_t * read (size_t); /* reimpl */
......@@ -134,7 +138,8 @@ namespace adaptive
class HTTPChunk : public AbstractChunk
{
public:
HTTPChunk(const std::string &url, AbstractConnectionManager *);
HTTPChunk(const std::string &url, AbstractConnectionManager *,
const ID &);
virtual ~HTTPChunk();
virtual void onDownload (block_t **) {} /* impl */
......
......@@ -46,10 +46,10 @@ AbstractConnectionManager::~AbstractConnectionManager()
}
void AbstractConnectionManager::updateDownloadRate(size_t size, mtime_t time)
void AbstractConnectionManager::updateDownloadRate(const ID &sourceid, size_t size, mtime_t time)
{
if(rateObserver)
rateObserver->updateDownloadRate(size, time);
rateObserver->updateDownloadRate(sourceid, size, time);
}
void AbstractConnectionManager::setDownloadRateObserver(IDownloadRateObserver *obs)
......
......@@ -51,7 +51,7 @@ namespace adaptive
virtual void start(AbstractChunkSource *) = 0;
virtual void cancel(AbstractChunkSource *) = 0;
virtual void updateDownloadRate(size_t, mtime_t); /* impl */
virtual void updateDownloadRate(const ID &, size_t, mtime_t); /* impl */
void setDownloadRateObserver(IDownloadRateObserver *);
protected:
......
......@@ -37,6 +37,6 @@ AbstractAdaptationLogic::~AbstractAdaptationLogic ()
{
}
void AbstractAdaptationLogic::updateDownloadRate (size_t, mtime_t)
void AbstractAdaptationLogic::updateDownloadRate (const ID &, size_t, mtime_t)
{
}
......@@ -48,7 +48,7 @@ namespace adaptive
virtual ~AbstractAdaptationLogic ();
virtual BaseRepresentation* getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const = 0;
virtual void updateDownloadRate (size_t, mtime_t);
virtual void updateDownloadRate (const ID &, size_t, mtime_t);
virtual void trackerEvent (const SegmentTrackerEvent &) {}
enum LogicType
......
......@@ -29,10 +29,12 @@
namespace adaptive
{
class ID;
class IDownloadRateObserver
{
public:
virtual void updateDownloadRate(size_t, mtime_t) = 0;
virtual void updateDownloadRate(const ID &, size_t, mtime_t) = 0;
virtual ~IDownloadRateObserver(){}
};
}
......
......@@ -83,7 +83,7 @@ BaseRepresentation *RateBasedAdaptationLogic::getNextRepresentation(BaseAdaptati
return rep;
}
void RateBasedAdaptationLogic::updateDownloadRate(size_t size, mtime_t time)
void RateBasedAdaptationLogic::updateDownloadRate(const ID &, size_t size, mtime_t time)
{
if(unlikely(time == 0))
return;
......
......@@ -39,7 +39,7 @@ namespace adaptive
virtual ~RateBasedAdaptationLogic ();
BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *) const;
virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */
virtual void updateDownloadRate(const ID &, size_t, mtime_t); /* reimpl */
virtual void trackerEvent(const SegmentTrackerEvent &); /* reimpl */
private:
......
......@@ -53,6 +53,11 @@ StreamFormat BaseRepresentation::getStreamFormat() const
return StreamFormat();
}
BaseAdaptationSet * BaseRepresentation::getAdaptationSet()
{
return adaptationSet;
}
uint64_t BaseRepresentation::getBandwidth () const
{
return bandwidth;
......
......@@ -54,6 +54,7 @@ namespace adaptive
* Will be a valid value, as the parser refuses Representation
* without bandwidth.
*/
BaseAdaptationSet* getAdaptationSet ();
uint64_t getBandwidth () const;
void setBandwidth ( uint64_t bandwidth );
const std::list<std::string> & getCodecs () const;
......
......@@ -27,6 +27,7 @@
#endif
#include "Segment.h"
#include "BaseAdaptationSet.h"
#include "BaseRepresentation.h"
#include "AbstractPlaylist.hpp"
#include "SegmentChunk.hpp"
......@@ -69,7 +70,8 @@ void ISegment::onChunkDownload(block_t **, SegmentChunk *, BaseRepresentation *)
SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *rep, AbstractConnectionManager *connManager)
{
const std::string url = getUrlSegment().toString(index, rep);
HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager);
HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager,
rep->getAdaptationSet()->getID());
if( source )
{
if(startByte != endByte)
......
......@@ -37,7 +37,7 @@ block_t * Retrieve::HTTP(vlc_object_t *obj, const std::string &uri)
HTTPChunk *datachunk;
try
{
datachunk = new HTTPChunk(uri, &connManager);
datachunk = new HTTPChunk(uri, &connManager, ID());
} catch (int) {
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment