MP4 progressive connector cleanups, fixes and simplification.
This commit is contained in:
parent
bb16647467
commit
bda368b75f
1 changed files with 163 additions and 229 deletions
|
@ -49,21 +49,15 @@ namespace Connector_HTTP {
|
||||||
std::string DTSCMeta2MP4Header(DTSC::Meta & metaData, std::set<int> & tracks, long long & size){
|
std::string DTSCMeta2MP4Header(DTSC::Meta & metaData, std::set<int> & tracks, long long & size){
|
||||||
std::stringstream header;
|
std::stringstream header;
|
||||||
//ftyp box
|
//ftyp box
|
||||||
/// \todo fill ftyp with non hardcoded values from file
|
|
||||||
MP4::FTYP ftypBox;
|
MP4::FTYP ftypBox;
|
||||||
ftypBox.setMajorBrand(0x6D703431);//mp41
|
|
||||||
ftypBox.setMinorVersion(0);
|
|
||||||
ftypBox.setCompatibleBrands(0x69736f6d,0);
|
|
||||||
ftypBox.setCompatibleBrands(0x69736f32,1);
|
|
||||||
ftypBox.setCompatibleBrands(0x61766331,2);
|
|
||||||
ftypBox.setCompatibleBrands(0x6D703431,3);
|
|
||||||
header << std::string(ftypBox.asBox(),ftypBox.boxedSize());
|
header << std::string(ftypBox.asBox(),ftypBox.boxedSize());
|
||||||
|
|
||||||
uint64_t mdatSize = 0;
|
uint64_t mdatSize = 0;
|
||||||
//moov box
|
//moov box
|
||||||
MP4::MOOV moovBox;{
|
MP4::MOOV moovBox;
|
||||||
|
unsigned int moovOffset = 0;
|
||||||
|
{
|
||||||
//calculating longest duration
|
//calculating longest duration
|
||||||
long long int fileDuration = 0;
|
|
||||||
long long int firstms = -1;
|
long long int firstms = -1;
|
||||||
long long int lastms = -1;
|
long long int lastms = -1;
|
||||||
for (std::set<int>::iterator it = tracks.begin(); it != tracks.end(); it++) {
|
for (std::set<int>::iterator it = tracks.begin(); it != tracks.end(); it++) {
|
||||||
|
@ -74,222 +68,163 @@ namespace Connector_HTTP {
|
||||||
firstms = metaData.tracks[*it].firstms;
|
firstms = metaData.tracks[*it].firstms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileDuration = lastms - firstms;
|
MP4::MVHD mvhdBox(lastms - firstms);
|
||||||
//MP4::MVHD mvhdBox(fileDuration);
|
moovBox.setContent(mvhdBox, moovOffset++);
|
||||||
MP4::MVHD mvhdBox;
|
|
||||||
mvhdBox.setVersion(0);
|
|
||||||
mvhdBox.setCreationTime(0);
|
|
||||||
mvhdBox.setModificationTime(0);
|
|
||||||
mvhdBox.setTimeScale(1000);
|
|
||||||
mvhdBox.setRate(0x10000);
|
|
||||||
mvhdBox.setDuration(fileDuration);
|
|
||||||
mvhdBox.setTrackID(0);
|
|
||||||
mvhdBox.setVolume(256);
|
|
||||||
mvhdBox.setMatrix(0x00010000,0);
|
|
||||||
mvhdBox.setMatrix(0,1);
|
|
||||||
mvhdBox.setMatrix(0,2);
|
|
||||||
mvhdBox.setMatrix(0,3);
|
|
||||||
mvhdBox.setMatrix(0x00010000,4);
|
|
||||||
mvhdBox.setMatrix(0,5);
|
|
||||||
mvhdBox.setMatrix(0,6);
|
|
||||||
mvhdBox.setMatrix(0,7);
|
|
||||||
mvhdBox.setMatrix(0x40000000,8);
|
|
||||||
moovBox.setContent(mvhdBox, 0);
|
|
||||||
}
|
}
|
||||||
{//start arbitrary track addition for headeri
|
for (std::set<int>::iterator it = tracks.begin(); it != tracks.end(); it++) {
|
||||||
int boxOffset = 1;
|
MP4::TRAK trakBox;
|
||||||
for (std::set<int>::iterator it = tracks.begin(); it != tracks.end(); it++) {
|
{
|
||||||
int timescale = 0;
|
|
||||||
MP4::TRAK trakBox;
|
|
||||||
{
|
{
|
||||||
|
MP4::TKHD tkhdBox(*it, metaData.tracks[*it].lastms - metaData.tracks[*it].firstms, metaData.tracks[*it].width, metaData.tracks[*it].height);
|
||||||
|
trakBox.setContent(tkhdBox, 0);
|
||||||
|
}{
|
||||||
|
MP4::MDIA mdiaBox;
|
||||||
|
unsigned int mdiaOffset = 0;
|
||||||
{
|
{
|
||||||
MP4::TKHD tkhdBox;
|
MP4::MDHD mdhdBox(metaData.tracks[*it].lastms - metaData.tracks[*it].firstms);
|
||||||
tkhdBox.setVersion(0);
|
mdiaBox.setContent(mdhdBox, mdiaOffset++);
|
||||||
tkhdBox.setFlags(15);
|
}//MDHD box
|
||||||
tkhdBox.setTrackID(*it);
|
{
|
||||||
tkhdBox.setDuration(metaData.tracks[*it].lastms - metaData.tracks[*it].firstms);
|
MP4::HDLR hdlrBox(metaData.tracks[*it].type, metaData.tracks[*it].getIdentifier());
|
||||||
|
mdiaBox.setContent(hdlrBox, mdiaOffset++);
|
||||||
if (metaData.tracks[*it].type == "video"){
|
}//hdlr box
|
||||||
tkhdBox.setWidth(metaData.tracks[*it].width << 16);
|
{
|
||||||
tkhdBox.setHeight(metaData.tracks[*it].height << 16);
|
MP4::MINF minfBox;
|
||||||
tkhdBox.setVolume(0);
|
unsigned int minfOffset = 0;
|
||||||
}else{
|
if (metaData.tracks[*it].type== "video"){
|
||||||
tkhdBox.setVolume(256);
|
MP4::VMHD vmhdBox;
|
||||||
tkhdBox.setAlternateGroup(1);
|
vmhdBox.setFlags(1);
|
||||||
}
|
minfBox.setContent(vmhdBox,minfOffset++);
|
||||||
tkhdBox.setMatrix(0x00010000,0);
|
}else if (metaData.tracks[*it].type == "audio"){
|
||||||
tkhdBox.setMatrix(0,1);
|
MP4::SMHD smhdBox;
|
||||||
tkhdBox.setMatrix(0,2);
|
minfBox.setContent(smhdBox,minfOffset++);
|
||||||
tkhdBox.setMatrix(0,3);
|
}//type box
|
||||||
tkhdBox.setMatrix(0x00010000,4);
|
|
||||||
tkhdBox.setMatrix(0,5);
|
|
||||||
tkhdBox.setMatrix(0,6);
|
|
||||||
tkhdBox.setMatrix(0,7);
|
|
||||||
tkhdBox.setMatrix(0x40000000,8);
|
|
||||||
trakBox.setContent(tkhdBox, 0);
|
|
||||||
}{
|
|
||||||
MP4::MDIA mdiaBox;
|
|
||||||
{
|
{
|
||||||
MP4::MDHD mdhdBox(0);/// \todo fix constructor mdhd in lib
|
MP4::DINF dinfBox;
|
||||||
mdhdBox.setCreationTime(0);
|
MP4::DREF drefBox;
|
||||||
mdhdBox.setModificationTime(0);
|
dinfBox.setContent(drefBox,0);
|
||||||
//Calculating media time based on sampledelta. Probably cheating, but it works...
|
minfBox.setContent(dinfBox,minfOffset++);
|
||||||
timescale = ((double)(42 * metaData.tracks[*it].parts.size() ) / (metaData.tracks[*it].lastms - metaData.tracks[*it].firstms)) * 1000;
|
}//dinf box
|
||||||
mdhdBox.setTimeScale(timescale);
|
|
||||||
mdhdBox.setDuration((metaData.tracks[*it].lastms - metaData.tracks[*it].firstms) * ((double)timescale / 1000));
|
|
||||||
mdiaBox.setContent(mdhdBox, 0);
|
|
||||||
}//MDHD box
|
|
||||||
{
|
{
|
||||||
MP4::HDLR hdlrBox;/// \todo fix constructor hdlr in lib
|
MP4::STBL stblBox;
|
||||||
|
unsigned int offset = 0;
|
||||||
|
{
|
||||||
|
MP4::STSD stsdBox;
|
||||||
|
stsdBox.setVersion(0);
|
||||||
|
if (metaData.tracks[*it].type == "video"){//boxname = codec
|
||||||
|
MP4::VisualSampleEntry vse;
|
||||||
|
if (metaData.tracks[*it].codec == "H264"){
|
||||||
|
vse.setCodec("avc1");
|
||||||
|
}
|
||||||
|
vse.setDataReferenceIndex(1);
|
||||||
|
vse.setWidth(metaData.tracks[*it].width);
|
||||||
|
vse.setHeight(metaData.tracks[*it].height);
|
||||||
|
MP4::AVCC avccBox;
|
||||||
|
avccBox.setPayload(metaData.tracks[*it].init);
|
||||||
|
vse.setCLAP(avccBox);
|
||||||
|
stsdBox.setEntry(vse,0);
|
||||||
|
}else if(metaData.tracks[*it].type == "audio"){//boxname = codec
|
||||||
|
MP4::AudioSampleEntry ase;
|
||||||
|
if (metaData.tracks[*it].codec == "AAC"){
|
||||||
|
ase.setCodec("mp4a");
|
||||||
|
ase.setDataReferenceIndex(1);
|
||||||
|
}
|
||||||
|
ase.setSampleRate(metaData.tracks[*it].rate);
|
||||||
|
ase.setChannelCount(metaData.tracks[*it].channels);
|
||||||
|
ase.setSampleSize(metaData.tracks[*it].size);
|
||||||
|
//MP4::ESDS esdsBox(metaData.tracks[*it].init, metaData.tracks[*it].bps);
|
||||||
|
MP4::ESDS esdsBox;
|
||||||
|
|
||||||
|
//outputting these values first, so malloc isn't called as often.
|
||||||
|
esdsBox.setESHeaderStartCodes(metaData.tracks[*it].init);
|
||||||
|
esdsBox.setSLValue(2);
|
||||||
|
|
||||||
|
esdsBox.setESDescriptorTypeLength(32+metaData.tracks[*it].init.size());
|
||||||
|
esdsBox.setESID(2);
|
||||||
|
esdsBox.setStreamPriority(0);
|
||||||
|
esdsBox.setDecoderConfigDescriptorTypeLength(18 + metaData.tracks[*it].init.size());
|
||||||
|
esdsBox.setByteObjectTypeID(0x40);
|
||||||
|
esdsBox.setStreamType(5);
|
||||||
|
esdsBox.setReservedFlag(1);
|
||||||
|
esdsBox.setBufferSize(1250000);
|
||||||
|
esdsBox.setMaximumBitRate(10000000);
|
||||||
|
esdsBox.setAverageBitRate(metaData.tracks[*it].bps * 8);
|
||||||
|
esdsBox.setConfigDescriptorTypeLength(5);
|
||||||
|
esdsBox.setSLConfigDescriptorTypeTag(0x6);
|
||||||
|
esdsBox.setSLConfigExtendedDescriptorTypeTag(0x808080);
|
||||||
|
esdsBox.setSLDescriptorTypeLength(1);
|
||||||
|
ase.setCodecBox(esdsBox);
|
||||||
|
stsdBox.setEntry(ase,0);
|
||||||
|
}
|
||||||
|
stblBox.setContent(stsdBox,offset++);
|
||||||
|
}//stsd box
|
||||||
|
{
|
||||||
|
MP4::STTS sttsBox;
|
||||||
|
sttsBox.setVersion(0);
|
||||||
|
if (metaData.tracks[*it].parts.size()){
|
||||||
|
for (unsigned int part = 0; part < metaData.tracks[*it].parts.size(); part++){
|
||||||
|
MP4::STTSEntry newEntry;
|
||||||
|
newEntry.sampleCount = 1;
|
||||||
|
newEntry.sampleDelta = metaData.tracks[*it].parts[part].getDuration();
|
||||||
|
sttsBox.setSTTSEntry(newEntry, part);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stblBox.setContent(sttsBox,offset++);
|
||||||
|
}//stts box
|
||||||
if (metaData.tracks[*it].type == "video"){
|
if (metaData.tracks[*it].type == "video"){
|
||||||
hdlrBox.setHandlerType(0x76696465);//vide
|
//STSS Box here
|
||||||
}else if (metaData.tracks[*it].type == "audio"){
|
MP4::STSS stssBox;
|
||||||
hdlrBox.setHandlerType(0x736F756E);//soun
|
stssBox.setVersion(0);
|
||||||
}
|
int tmpCount = 0;
|
||||||
hdlrBox.setName(metaData.tracks[*it].getIdentifier());
|
int tmpItCount = 0;
|
||||||
mdiaBox.setContent(hdlrBox, 1);
|
for ( std::deque< DTSC::Key>::iterator tmpIt = metaData.tracks[*it].keys.begin(); tmpIt != metaData.tracks[*it].keys.end(); tmpIt ++) {
|
||||||
}//hdlr box
|
stssBox.setSampleNumber(tmpCount,tmpItCount);
|
||||||
{
|
tmpCount += tmpIt->getParts();
|
||||||
MP4::MINF minfBox;
|
tmpItCount ++;
|
||||||
unsigned int minf_offset = 0;
|
}
|
||||||
if (metaData.tracks[*it].type== "video"){
|
stblBox.setContent(stssBox,offset++);
|
||||||
MP4::VMHD vmhdBox;
|
}//stss box
|
||||||
vmhdBox.setFlags(1);
|
|
||||||
minfBox.setContent(vmhdBox,minf_offset++);
|
|
||||||
}else if (metaData.tracks[*it].type == "audio"){
|
|
||||||
MP4::SMHD smhdBox;
|
|
||||||
minfBox.setContent(smhdBox,minf_offset++);
|
|
||||||
}//type box
|
|
||||||
{
|
{
|
||||||
MP4::DINF dinfBox;
|
MP4::STSC stscBox;
|
||||||
MP4::DREF drefBox;/// \todo fix constructor dref in lib
|
stscBox.setVersion(0);
|
||||||
drefBox.setVersion(0);
|
MP4::STSCEntry stscEntry;
|
||||||
MP4::URL urlBox;
|
stscEntry.firstChunk = 1;
|
||||||
urlBox.setFlags(1);
|
stscEntry.samplesPerChunk = 1;
|
||||||
drefBox.setDataEntry(urlBox,0);
|
stscEntry.sampleDescriptionIndex = 1;
|
||||||
dinfBox.setContent(drefBox,0);
|
stscBox.setSTSCEntry(stscEntry, 0);
|
||||||
minfBox.setContent(dinfBox,minf_offset++);
|
stblBox.setContent(stscBox,offset++);
|
||||||
}//dinf box
|
}//stsc box
|
||||||
{
|
{
|
||||||
MP4::STBL stblBox;
|
uint32_t total = 0;
|
||||||
unsigned int offset = 0;
|
MP4::STSZ stszBox;
|
||||||
{
|
stszBox.setVersion(0);
|
||||||
MP4::STSD stsdBox;
|
total = 0;
|
||||||
stsdBox.setVersion(0);
|
for (std::deque< DTSC::Part>::iterator partIt = metaData.tracks[*it].parts.begin(); partIt != metaData.tracks[*it].parts.end(); partIt ++) {
|
||||||
if (metaData.tracks[*it].type == "video"){//boxname = codec
|
stszBox.setEntrySize(partIt->getSize(), total);//in bytes in file
|
||||||
MP4::VisualSampleEntry vse;
|
size += partIt->getSize();
|
||||||
if (metaData.tracks[*it].codec == "H264"){
|
total++;
|
||||||
vse.setCodec("avc1");
|
}
|
||||||
}
|
stblBox.setContent(stszBox,offset++);
|
||||||
vse.setDataReferenceIndex(1);
|
}//stsz box
|
||||||
vse.setWidth(metaData.tracks[*it].width);
|
//add STCO boxes here
|
||||||
vse.setHeight(metaData.tracks[*it].height);
|
{
|
||||||
MP4::AVCC avccBox;
|
MP4::STCO stcoBox;
|
||||||
avccBox.setPayload(metaData.tracks[*it].init);
|
stcoBox.setVersion(1);
|
||||||
vse.setCLAP(avccBox);
|
//Inserting empty values on purpose here, will be fixed later.
|
||||||
stsdBox.setEntry(vse,0);
|
if (metaData.tracks[*it].parts.size() != 0){
|
||||||
}else if(metaData.tracks[*it].type == "audio"){//boxname = codec
|
stcoBox.setChunkOffset(0, metaData.tracks[*it].parts.size() - 1);//this inserts all empty entries at once
|
||||||
MP4::AudioSampleEntry ase;
|
}
|
||||||
if (metaData.tracks[*it].codec == "AAC"){
|
stblBox.setContent(stcoBox,offset++);
|
||||||
ase.setCodec("mp4a");
|
}//stco box
|
||||||
ase.setDataReferenceIndex(1);
|
minfBox.setContent(stblBox,minfOffset++);
|
||||||
}
|
}//stbl box
|
||||||
ase.setSampleRate(metaData.tracks[*it].rate);
|
mdiaBox.setContent(minfBox, mdiaOffset++);
|
||||||
ase.setChannelCount(metaData.tracks[*it].channels);
|
}//minf box
|
||||||
ase.setSampleSize(metaData.tracks[*it].size);
|
trakBox.setContent(mdiaBox, 1);
|
||||||
//MP4::ESDS esdsBox(metaData.tracks[*it].init, metaData.tracks[*it].bps);
|
}
|
||||||
MP4::ESDS esdsBox;
|
}//trak Box
|
||||||
|
moovBox.setContent(trakBox, moovOffset++);
|
||||||
//outputting these values first, so malloc isn't called as often.
|
}
|
||||||
esdsBox.setESHeaderStartCodes(metaData.tracks[*it].init);
|
|
||||||
esdsBox.setSLValue(2);
|
|
||||||
|
|
||||||
esdsBox.setESDescriptorTypeLength(32+metaData.tracks[*it].init.size());
|
|
||||||
esdsBox.setESID(2);
|
|
||||||
esdsBox.setStreamPriority(0);
|
|
||||||
esdsBox.setDecoderConfigDescriptorTypeLength(18 + metaData.tracks[*it].init.size());
|
|
||||||
esdsBox.setByteObjectTypeID(0x40);
|
|
||||||
esdsBox.setStreamType(5);
|
|
||||||
esdsBox.setReservedFlag(1);
|
|
||||||
esdsBox.setBufferSize(1250000);
|
|
||||||
esdsBox.setMaximumBitRate(10000000);
|
|
||||||
esdsBox.setAverageBitRate(metaData.tracks[*it].bps * 8);
|
|
||||||
esdsBox.setConfigDescriptorTypeLength(5);
|
|
||||||
esdsBox.setSLConfigDescriptorTypeTag(0x6);
|
|
||||||
esdsBox.setSLConfigExtendedDescriptorTypeTag(0x808080);
|
|
||||||
esdsBox.setSLDescriptorTypeLength(1);
|
|
||||||
ase.setCodecBox(esdsBox);
|
|
||||||
stsdBox.setEntry(ase,0);
|
|
||||||
}
|
|
||||||
stblBox.setContent(stsdBox,offset++);
|
|
||||||
}//stsd box
|
|
||||||
/// \todo update following stts lines
|
|
||||||
{
|
|
||||||
MP4::STTS sttsBox;//current version probably causes problems
|
|
||||||
sttsBox.setVersion(0);
|
|
||||||
MP4::STTSEntry newEntry;
|
|
||||||
newEntry.sampleCount = metaData.tracks[*it].parts.size();
|
|
||||||
//42, Used as magic number for timescale calculation
|
|
||||||
newEntry.sampleDelta = 42;
|
|
||||||
sttsBox.setSTTSEntry(newEntry, 0);
|
|
||||||
stblBox.setContent(sttsBox,offset++);
|
|
||||||
}//stts box
|
|
||||||
if (metaData.tracks[*it].type == "video"){
|
|
||||||
//STSS Box here
|
|
||||||
MP4::STSS stssBox;
|
|
||||||
stssBox.setVersion(0);
|
|
||||||
int tmpCount = 0;
|
|
||||||
int tmpItCount = 0;
|
|
||||||
for ( std::deque< DTSC::Key>::iterator tmpIt = metaData.tracks[*it].keys.begin(); tmpIt != metaData.tracks[*it].keys.end(); tmpIt ++) {
|
|
||||||
stssBox.setSampleNumber(tmpCount,tmpItCount);
|
|
||||||
tmpCount += tmpIt->getParts();
|
|
||||||
tmpItCount ++;
|
|
||||||
}
|
|
||||||
stblBox.setContent(stssBox,offset++);
|
|
||||||
}//stss box
|
|
||||||
{
|
|
||||||
MP4::STSC stscBox;
|
|
||||||
stscBox.setVersion(0);
|
|
||||||
MP4::STSCEntry stscEntry;
|
|
||||||
stscEntry.firstChunk = 1;
|
|
||||||
stscEntry.samplesPerChunk = 1;
|
|
||||||
stscEntry.sampleDescriptionIndex = 1;
|
|
||||||
stscBox.setSTSCEntry(stscEntry, 0);
|
|
||||||
stblBox.setContent(stscBox,offset++);
|
|
||||||
}//stsc box
|
|
||||||
{
|
|
||||||
uint32_t total = 0;
|
|
||||||
MP4::STSZ stszBox;
|
|
||||||
stszBox.setVersion(0);
|
|
||||||
total = 0;
|
|
||||||
for (std::deque< DTSC::Part>::iterator partIt = metaData.tracks[*it].parts.begin(); partIt != metaData.tracks[*it].parts.end(); partIt ++) {
|
|
||||||
stszBox.setEntrySize(partIt->getSize(), total);//in bytes in file
|
|
||||||
size += partIt->getSize();
|
|
||||||
total++;
|
|
||||||
}
|
|
||||||
stblBox.setContent(stszBox,offset++);
|
|
||||||
}//stsz box
|
|
||||||
//add STCO boxes here
|
|
||||||
{
|
|
||||||
MP4::STCO stcoBox;
|
|
||||||
stcoBox.setVersion(1);
|
|
||||||
//Inserting empty values on purpose here, will be fixed later.
|
|
||||||
if (metaData.tracks[*it].parts.size() != 0){
|
|
||||||
stcoBox.setChunkOffset(0, metaData.tracks[*it].parts.size() - 1);//this inserts all empty entries at once
|
|
||||||
}
|
|
||||||
stblBox.setContent(stcoBox,offset++);
|
|
||||||
}//stco box
|
|
||||||
minfBox.setContent(stblBox,minf_offset++);
|
|
||||||
}//stbl box
|
|
||||||
mdiaBox.setContent(minfBox, 2);
|
|
||||||
}//minf box
|
|
||||||
trakBox.setContent(mdiaBox, 1);
|
|
||||||
}
|
|
||||||
}//trak Box
|
|
||||||
moovBox.setContent(trakBox, boxOffset);
|
|
||||||
boxOffset++;
|
|
||||||
}
|
|
||||||
}//end arbitrary track addition
|
|
||||||
//initial offset length ftyp, length moov + 8
|
//initial offset length ftyp, length moov + 8
|
||||||
unsigned long long int byteOffset = ftypBox.boxedSize() + moovBox.boxedSize() + 8;
|
unsigned long long int byteOffset = ftypBox.boxedSize() + moovBox.boxedSize() + 8;
|
||||||
//update all STCO from the following map;
|
//update all STCO from the following map;
|
||||||
|
@ -298,24 +233,24 @@ namespace Connector_HTTP {
|
||||||
for (unsigned int i = 1; i < moovBox.getContentCount(); i++){
|
for (unsigned int i = 1; i < moovBox.getContentCount(); i++){
|
||||||
//10 lines to get the STCO box.
|
//10 lines to get the STCO box.
|
||||||
MP4::TRAK checkTrakBox;
|
MP4::TRAK checkTrakBox;
|
||||||
MP4::MDIA checkMdiaBox;
|
MP4::Box checkMdiaBox;
|
||||||
MP4::TKHD checkTkhdBox;
|
MP4::Box checkTkhdBox;
|
||||||
MP4::MINF checkMinfBox;
|
MP4::MINF checkMinfBox;
|
||||||
MP4::STBL checkStblBox;
|
MP4::STBL checkStblBox;
|
||||||
//MP4::STCO checkStcoBox;
|
//MP4::STCO checkStcoBox;
|
||||||
checkTrakBox = ((MP4::TRAK&)moovBox.getContent(i));
|
checkTrakBox = ((MP4::TRAK&)moovBox.getContent(i));
|
||||||
for (unsigned int j = 0; j < checkTrakBox.getContentCount(); j++){
|
for (unsigned int j = 0; j < checkTrakBox.getContentCount(); j++){
|
||||||
if (checkTrakBox.getContent(j).isType("mdia")){
|
if (checkTrakBox.getContent(j).isType("mdia")){
|
||||||
checkMdiaBox = ((MP4::MDIA&)checkTrakBox.getContent(j));
|
checkMdiaBox = checkTrakBox.getContent(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (checkTrakBox.getContent(j).isType("tkhd")){
|
if (checkTrakBox.getContent(j).isType("tkhd")){
|
||||||
checkTkhdBox = ((MP4::TKHD&)checkTrakBox.getContent(j));
|
checkTkhdBox = checkTrakBox.getContent(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int j = 0; j < checkMdiaBox.getContentCount(); j++){
|
for (unsigned int j = 0; j < ((MP4::MDIA&)checkMdiaBox).getContentCount(); j++){
|
||||||
if (checkMdiaBox.getContent(j).isType("minf")){
|
if (((MP4::MDIA&)checkMdiaBox).getContent(j).isType("minf")){
|
||||||
checkMinfBox = ((MP4::MINF&)checkMdiaBox.getContent(j));
|
checkMinfBox = ((MP4::MINF&)((MP4::MDIA&)checkMdiaBox).getContent(j));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +262,7 @@ namespace Connector_HTTP {
|
||||||
}
|
}
|
||||||
for (unsigned int j = 0; j < checkStblBox.getContentCount(); j++){
|
for (unsigned int j = 0; j < checkStblBox.getContentCount(); j++){
|
||||||
if (checkStblBox.getContent(j).isType("stco")){
|
if (checkStblBox.getContent(j).isType("stco")){
|
||||||
checkStcoBoxes.insert( std::pair<int, MP4::STCO>(checkTkhdBox.getTrackID(), ((MP4::STCO&)checkStblBox.getContent(j)) ));
|
checkStcoBoxes.insert( std::pair<int, MP4::STCO>(((MP4::TKHD&)checkTkhdBox).getTrackID(), ((MP4::STCO&)checkStblBox.getContent(j)) ));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,13 +298,12 @@ namespace Connector_HTTP {
|
||||||
//remove highest keyPart
|
//remove highest keyPart
|
||||||
sortSet.erase(sortSet.begin());
|
sortSet.erase(sortSet.begin());
|
||||||
}
|
}
|
||||||
//calculating the offset where the STCO box will be in the main MOOV box
|
|
||||||
//needed for probable optimise
|
mdatSize = totalByteOffset+8;
|
||||||
mdatSize = totalByteOffset;
|
|
||||||
|
|
||||||
header << std::string(moovBox.asBox(),moovBox.boxedSize());
|
header << std::string(moovBox.asBox(),moovBox.boxedSize());
|
||||||
|
|
||||||
header << (char)((mdatSize>>24) & 0x000000FF) << (char)((mdatSize>>16) & 0x000000FF) << (char)((mdatSize>>8) & 0x000000FF) << (char)(mdatSize & 0x000000FF) << "mdat";
|
header << (char)((mdatSize>>24) & 0xFF) << (char)((mdatSize>>16) & 0xFF) << (char)((mdatSize>>8) & 0xFF) << (char)(mdatSize & 0xFF) << "mdat";
|
||||||
//end of header
|
//end of header
|
||||||
|
|
||||||
size += header.str().size();
|
size += header.str().size();
|
||||||
|
|
Loading…
Add table
Reference in a new issue