Fixed support for MP4 files without CTTS box in a track header.

This commit is contained in:
Thulinma 2015-09-25 00:36:09 +02:00
parent 5819e9cac8
commit 5c3ff12946
4 changed files with 15 additions and 8 deletions

View file

@ -1374,6 +1374,7 @@ namespace DTSC {
}
void Meta::update(long long packTime, long long packOffset, long long packTrack, long long packDataSize, long long packBytePos, bool isKeyframe, long long packSendSize, unsigned long segment_size, const char * ivec){
DONTEVEN_MSG("Updating meta with: t=%lld, o=%lld, s=%lld, t=%lld, p=%lld", packTime, packOffset, packDataSize, packTrack, packBytePos);
if (!packSendSize){
//time and trackID are part of the 20-byte header.
//the container object adds 4 bytes (plus 2+namelen for each content, see below)

View file

@ -23,6 +23,7 @@ namespace Mist {
offsetIndex = 0;
offsetPos = 0;
sttsBox.clear();
hasCTTS = false;
cttsBox.clear();
stszBox.clear();
stcoBox.clear();
@ -75,6 +76,7 @@ namespace Mist {
tmp = std::string(stblLoopPeek.asBox() ,stblLoopPeek.boxedSize());
cttsBox.clear();
cttsBox.read(tmp);
hasCTTS = true;
}else if (stblBoxType == "stsz"){
tmp = std::string(stblLoopPeek.asBox() ,stblLoopPeek.boxedSize());
stszBox.clear();
@ -163,15 +165,17 @@ namespace Mist {
offsetIndex = 0;
offsetPos = 0;
}
MP4::CTTSEntry tmpCTTS;
while (offsetIndex < cttsBox.getEntryCount()){
tmpCTTS = cttsBox.getCTTSEntry(offsetIndex);
if ((index - offsetPos) < tmpCTTS.sampleCount){
timeOffset = (tmpCTTS.sampleOffset*1000)/timeScale;
break;
if (hasCTTS){
MP4::CTTSEntry tmpCTTS;
while (offsetIndex < cttsBox.getEntryCount()){
tmpCTTS = cttsBox.getCTTSEntry(offsetIndex);
if ((index - offsetPos) < tmpCTTS.sampleCount){
timeOffset = (tmpCTTS.sampleOffset*1000)/timeScale;
break;
}
offsetPos += tmpCTTS.sampleCount;
++offsetIndex;
}
offsetPos += tmpCTTS.sampleCount;
++offsetIndex;
}
//next lines are common for next-getting and seeking

View file

@ -63,6 +63,7 @@ namespace Mist {
MP4::STCO stcoBox;
MP4::STSZ stszBox;
MP4::STTS sttsBox;
bool hasCTTS;
MP4::CTTS cttsBox;
MP4::STSC stscBox;
long unsigned int timeScale;

View file

@ -264,6 +264,7 @@ namespace Mist {
}
//Save the current write position
size_t curOffset = pagesByTrack[tid][curPageNum[tid]].curOffset;
DONTEVEN_MSG("Buffering packet on page %lu for track %lu~>%lu: %d bytes @ %lu: %s", curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset);
//Do nothing when there is not enough free space on the page to add the packet.
if (pagesByTrack[tid][curPageNum[tid]].dataSize - curOffset < pack.getDataLen()) {
FAIL_MSG("Trying to buffer a packet on page %lu for track %lu~>%lu, but we have a size mismatch. The packet is %d bytes long, so won't fit at offset %lu on a page of %llu bytes!", curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset, pagesByTrack[tid][curPageNum[tid]].dataSize);