handled unknown size of segment for live stream

Change-Id: I7dcc08e38c6cd31a55693b39ace414c14399d1b5
This commit is contained in:
Hwasoo Lee
2010-11-16 16:17:10 -05:00
parent 85353469f8
commit 8db600e1c9

View File

@@ -11,9 +11,6 @@
#include <cstring> #include <cstring>
#include <new> #include <new>
#include <climits> #include <climits>
//#include <windows.h>
//#include "odbgstream.hpp"
//using std::endl;
mkvparser::IMkvReader::~IMkvReader() mkvparser::IMkvReader::~IMkvReader()
{ {
@@ -111,7 +108,6 @@ long long mkvparser::ReadUInt(IMkvReader* pReader, long long pos, long& len)
return result; return result;
} }
long long mkvparser::GetUIntLength( long long mkvparser::GetUIntLength(
IMkvReader* pReader, IMkvReader* pReader,
long long pos, long long pos,
@@ -153,7 +149,6 @@ long long mkvparser::GetUIntLength(
return 0; //success return 0; //success
} }
long long mkvparser::SyncReadUInt( long long mkvparser::SyncReadUInt(
IMkvReader* pReader, IMkvReader* pReader,
long long pos, long long pos,
@@ -878,7 +873,7 @@ long long Segment::CreateInstance(
//TODO: if we liberalize the behavior of ReadUInt, we can //TODO: if we liberalize the behavior of ReadUInt, we can
//probably eliminate having to use GetUIntLength here. //probably eliminate having to use GetUIntLength here.
const long long size = ReadUInt(pReader, pos, len); long long size = ReadUInt(pReader, pos, len);
if (size < 0) if (size < 0)
return size; return size;
@@ -887,17 +882,25 @@ long long Segment::CreateInstance(
//Pos now points to start of payload //Pos now points to start of payload
if ((pos + size) > total)
return E_FILE_FORMAT_INVALID;
if (id == 0x08538067) //Segment ID if (id == 0x08538067) //Segment ID
{ {
//Handle "unknown size" for live streaming of webm files.
const long long unknown_size = (1LL << (7 * len)) - 1;
if (size == unknown_size)
size = total - pos;
else if ((pos + size) > total)
return E_FILE_FORMAT_INVALID;
pSegment = new Segment(pReader, pos, size); pSegment = new Segment(pReader, pos, size);
assert(pSegment); //TODO assert(pSegment); //TODO
return 0; //success return 0; //success
} }
if ((pos + size) > total)
return E_FILE_FORMAT_INVALID;
pos += size; //consume payload pos += size; //consume payload
} }