Added (simplistic) compatibility for QuickTime-style ISOBMF files

This commit is contained in:
Thulinma 2022-11-18 02:17:53 +01:00
parent 7c36de707f
commit a2700aad17
2 changed files with 28 additions and 7 deletions

View file

@ -1357,7 +1357,11 @@ namespace MP4{
void HDLR::setName(std::string newName){setString(newName, 24);}
std::string HDLR::getName(){return getString(24);}
std::string HDLR::getName(){
std::string tmpName = getString(24);
if (tmpName[0] == tmpName.size()-1){tmpName.erase(0, 1);}
return tmpName;
}
std::string HDLR::toPrettyString(uint32_t indent){
std::stringstream r;
@ -2695,7 +2699,11 @@ namespace MP4{
setString(newCompressorName, 42);
}
std::string VisualSampleEntry::getCompressorName(){return getString(42);}
std::string VisualSampleEntry::getCompressorName(){
std::string tmpName = getString(42);
if (tmpName[0] == tmpName.size()-1){tmpName.erase(0, 1);}
return tmpName;
}
void VisualSampleEntry::setDepth(uint16_t newDepth){setInt16(newDepth, 74);}
@ -2839,6 +2847,8 @@ namespace MP4{
return result;
}
uint16_t AudioSampleEntry::getVersion() const{return getInt16(8);}
void AudioSampleEntry::setCodec(const char *newCodec){memcpy(data + 4, newCodec, 4);}
void AudioSampleEntry::setChannelCount(uint16_t newChannelCount){
@ -2861,9 +2871,9 @@ namespace MP4{
uint32_t AudioSampleEntry::getSampleRate(){return getInt32(24) >> 16;}
void AudioSampleEntry::setCodecBox(Box &newBox){setBox(newBox, 28);}
void AudioSampleEntry::setCodecBox(Box &newBox){setBox(newBox, getBoxOffset());}
Box &AudioSampleEntry::getCodecBox(){return getBox(28);}
Box &AudioSampleEntry::getCodecBox(){return getBox(getBoxOffset());}
/*LTS-START*/
Box &AudioSampleEntry::getSINFBox(){
@ -2872,12 +2882,21 @@ namespace MP4{
}
/*LTS-END*/
size_t AudioSampleEntry::getBoxOffset() const{
size_t offset = 28;
//Quicktime-specific box versions. We should really only do this if we see a "qt " ftyp
/// \TODO Do this properly at some point :-(
if (getVersion() == 1){offset = 28 + 16;}
if (getVersion() == 2){offset = 28 + 36;}
return offset;
}
size_t AudioSampleEntry::getBoxEntryCount(){
if (payloadSize() < 36){// if the EntryBox is not big enough to hold any box
return 0;
}
size_t count = 0;
size_t offset = 28;
size_t offset = getBoxOffset();
while (offset <= payloadSize() - 8){
offset += getBoxLen(offset);
count++;
@ -2889,7 +2908,7 @@ namespace MP4{
static Box ret = Box((char *)"\000\000\000\010erro", false);
if (index >= getBoxEntryCount()){return ret;}
size_t count = 0;
size_t offset = 28;
size_t offset = getBoxOffset();
while (offset < payloadSize()){
if (count == index){return getBox(offset);}
offset += getBoxLen(offset);
@ -2904,7 +2923,7 @@ namespace MP4{
WARN_MSG("This function can not leave empty spaces, appending at index %zu nstead!", index);
}
size_t count = 0;
size_t offset = 28;
size_t offset = getBoxOffset();
while (offset < payloadSize()){
if (count == index){
setBox(box, offset);

View file

@ -714,6 +714,7 @@ namespace MP4{
///\todo set default values
AudioSampleEntry();
AudioSampleEntry(const DTSC::Meta &M, size_t idx);
uint16_t getVersion() const;
void initialize();
void setCodec(const char *newCodec);
void setChannelCount(uint16_t newChannelCount);
@ -725,6 +726,7 @@ namespace MP4{
void setSampleRate(uint32_t newSampleRate);
uint16_t toAACInit();
uint32_t getSampleRate();
size_t getBoxOffset() const;
void setCodecBox(Box &newBox);
Box &getCodecBox();
Box &getSINFBox(); /*LTS*/