[vlc-commits] demux: adaptive: add source stream peek method
Francois Cartegnie
git at videolan.org
Thu May 9 17:41:07 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Apr 19 18:28:30 2019 +0200| [d0c6bbb5affcce58e78239bb82ec8ac8cf8f60c1] | committer: Francois Cartegnie
demux: adaptive: add source stream peek method
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d0c6bbb5affcce58e78239bb82ec8ac8cf8f60c1
---
modules/demux/adaptive/plumbing/SourceStream.cpp | 13 +++++++++++++
modules/demux/adaptive/plumbing/SourceStream.hpp | 2 ++
2 files changed, 15 insertions(+)
diff --git a/modules/demux/adaptive/plumbing/SourceStream.cpp b/modules/demux/adaptive/plumbing/SourceStream.cpp
index 13e082f802..8b100e1e82 100644
--- a/modules/demux/adaptive/plumbing/SourceStream.cpp
+++ b/modules/demux/adaptive/plumbing/SourceStream.cpp
@@ -144,6 +144,19 @@ std::string ChunksSourceStream::getContentType()
return source->getContentType();
}
+size_t ChunksSourceStream::Peek(const uint8_t **pp, size_t sz)
+{
+ if(!b_eof && !p_block)
+ {
+ p_block = source->readNextBlock();
+ b_eof = !p_block;
+ }
+ if(!p_block)
+ return 0;
+ *pp = p_block->p_buffer;
+ return std::min(p_block->i_buffer, sz);
+}
+
ssize_t ChunksSourceStream::Read(uint8_t *buf, size_t size)
{
size_t i_copied = 0;
diff --git a/modules/demux/adaptive/plumbing/SourceStream.hpp b/modules/demux/adaptive/plumbing/SourceStream.hpp
index 27317e17ff..da8c3644c5 100644
--- a/modules/demux/adaptive/plumbing/SourceStream.hpp
+++ b/modules/demux/adaptive/plumbing/SourceStream.hpp
@@ -35,6 +35,7 @@ namespace adaptive
virtual ~AbstractSourceStream() {}
virtual stream_t *makeStream() = 0;
virtual void Reset() = 0;
+ virtual size_t Peek(const uint8_t **, size_t) = 0;
};
class AbstractChunksSourceStream : public AbstractSourceStream
@@ -70,6 +71,7 @@ namespace adaptive
protected:
virtual ssize_t Read(uint8_t *, size_t); /* impl */
virtual int Seek(uint64_t); /* impl */
+ virtual size_t Peek(const uint8_t **, size_t); /* impl */
virtual std::string getContentType(); /* impl */
private:
More information about the vlc-commits
mailing list