Read enough bytes before detecting the container type
The input source may produce inputs with very small sizes. Demuxer needs to accumulate enough bytes before trying to detect the container type. Issue: https://github.com/google/edash-packager/issues/11 Change-Id: Ie25339832a826e78f39b3b25abb98c1ad89e3021
This commit is contained in:
parent
f494f1f760
commit
299bb97490
|
@ -57,10 +57,17 @@ Status Demuxer::Initialize() {
|
||||||
"Cannot open file for reading " + file_name_);
|
"Cannot open file for reading " + file_name_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine media container.
|
// Read enough bytes before detecting the container.
|
||||||
int64_t bytes_read = media_file_->Read(buffer_.get(), kInitBufSize);
|
size_t bytes_read = 0;
|
||||||
if (bytes_read <= 0)
|
while (bytes_read < kInitBufSize) {
|
||||||
|
int64_t read_result =
|
||||||
|
media_file_->Read(buffer_.get() + bytes_read, kInitBufSize);
|
||||||
|
if (read_result < 0)
|
||||||
return Status(error::FILE_FAILURE, "Cannot read file " + file_name_);
|
return Status(error::FILE_FAILURE, "Cannot read file " + file_name_);
|
||||||
|
if (read_result == 0)
|
||||||
|
break;
|
||||||
|
bytes_read += read_result;
|
||||||
|
}
|
||||||
MediaContainerName container = DetermineContainer(buffer_.get(), bytes_read);
|
MediaContainerName container = DetermineContainer(buffer_.get(), bytes_read);
|
||||||
|
|
||||||
// Initialize media parser.
|
// Initialize media parser.
|
||||||
|
|
Loading…
Reference in New Issue