Commit 0aa14f99 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: pass content-type though streams

(cherry picked from commit 44751cd7)
parent 66df1d29
......@@ -29,6 +29,7 @@ namespace adaptive
public:
virtual ~ChunksSource() {}
virtual block_t *readNextBlock() = 0;
virtual std::string getContentType() = 0;
};
}
......
......@@ -449,6 +449,16 @@ AbstractStream::status AbstractStream::dequeue(mtime_t nz_deadline, mtime_t *pi_
return AbstractStream::status_buffering;
}
std::string AbstractStream::getContentType()
{
if (currentChunk == NULL && !eof)
currentChunk = segmentTracker->getNextChunk(!fakeesout->restarting(), connManager);
if(currentChunk)
return currentChunk->getContentType();
else
return std::string();
}
block_t * AbstractStream::readNextBlock()
{
if (currentChunk == NULL && !eof)
......
......@@ -92,8 +92,11 @@ namespace adaptive
mtime_t getPlaybackTime() const;
void runUpdates();
/* Used by demuxers fake streams */
virtual std::string getContentType(); /* impl */
virtual block_t *readNextBlock(); /* impl */
/**/
virtual void fillExtraFMTInfo( es_format_t * ) const; /* impl */
virtual void trackerEvent(const SegmentTrackerEvent &); /* impl */
......
......@@ -59,6 +59,11 @@ const BytesRange & AbstractChunkSource::getBytesRange() const
return bytesRange;
}
std::string AbstractChunkSource::getContentType() const
{
return std::string();
}
AbstractChunk::AbstractChunk(AbstractChunkSource *source_)
{
bytesRead = 0;
......@@ -70,6 +75,11 @@ AbstractChunk::~AbstractChunk()
delete source;
}
std::string AbstractChunk::getContentType()
{
return source->getContentType();
}
size_t AbstractChunk::getBytesRead() const
{
return this->bytesRead;
......@@ -204,6 +214,11 @@ block_t * HTTPChunkSource::read(size_t readsize)
return p_block;
}
std::string HTTPChunkSource::getContentType() const
{
return connection->getContentType();
}
bool HTTPChunkSource::prepare()
{
if(prepared)
......
......@@ -52,6 +52,7 @@ namespace adaptive
virtual bool hasMoreData () const = 0;
void setBytesRange (const BytesRange &);
const BytesRange & getBytesRange () const;
virtual std::string getContentType () const;
protected:
size_t contentLength;
......@@ -63,6 +64,7 @@ namespace adaptive
public:
virtual ~AbstractChunk();
std::string getContentType ();
size_t getBytesRead () const;
uint64_t getStartByteInFile () const;
bool isEmpty () const;
......@@ -90,6 +92,7 @@ namespace adaptive
virtual block_t * readBlock (); /* impl */
virtual block_t * read (size_t); /* impl */
virtual bool hasMoreData () const; /* impl */
virtual std::string getContentType () const; /* reimpl */
static const size_t CHUNK_SIZE = 32768;
......
......@@ -65,6 +65,16 @@ stream_t * ChunksSourceStream::makeStream()
return p_stream;
}
std::string ChunksSourceStream::getContentType()
{
if(!b_eof && !p_block)
{
p_block = source->readNextBlock();
b_eof = !p_block;
}
return source->getContentType();
}
ssize_t ChunksSourceStream::Read(uint8_t *buf, size_t size)
{
size_t i_copied = 0;
......@@ -112,8 +122,9 @@ int ChunksSourceStream::seek_Callback(stream_t *, uint64_t)
return VLC_EGENERIC;
}
int ChunksSourceStream::control_Callback(stream_t *, int i_query, va_list args)
int ChunksSourceStream::control_Callback(stream_t *s, int i_query, va_list args)
{
ChunksSourceStream *me = reinterpret_cast<ChunksSourceStream *>(s->p_sys);
switch( i_query )
{
case STREAM_GET_SIZE:
......@@ -127,13 +138,25 @@ int ChunksSourceStream::control_Callback(stream_t *, int i_query, va_list args)
*va_arg( args, bool * ) = false;
return VLC_SUCCESS;
case STREAM_GET_CONTENT_TYPE:
{
std::string type = me->getContentType();
if(!type.empty())
{
*va_arg( args, char ** ) = strdup(type.c_str());
return VLC_SUCCESS;
}
}
break;
case STREAM_GET_PTS_DELAY:
*(va_arg( args, uint64_t * )) = DEFAULT_PTS_DELAY;
return VLC_SUCCESS;
default:
return VLC_EGENERIC;
break;
}
return VLC_EGENERIC;
}
void ChunksSourceStream::delete_Callback(stream_t *)
......
......@@ -22,6 +22,7 @@
#include <vlc_common.h>
#include <vlc_block.h>
#include <string>
namespace adaptive
{
......@@ -44,6 +45,7 @@ namespace adaptive
virtual void Reset(); /* impl */
protected:
std::string getContentType();
ssize_t Read(uint8_t *, size_t);
private:
......
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