Fixes to HTTP parser lib, DTSCMeta keysizes, MP4 headers and 4+GiB MP4 file output by Oswald de Bruin

This commit is contained in:
Thulinma 2015-04-02 11:16:23 +02:00
parent 3f6e465d6e
commit f9201cbf9a
7 changed files with 114 additions and 32 deletions

View file

@ -1422,10 +1422,10 @@ namespace DTSC {
std::string tmp;
tmp.reserve(keySizes.size() * 4);
for (unsigned int i = 0; i < keySizes.size(); i++){
tmp += ((char)keySizes[i] >> 24);
tmp += ((char)keySizes[i] >> 16);
tmp += ((char)keySizes[i] >> 8);
tmp += ((char)keySizes[i]);
tmp += (char)(keySizes[i] >> 24);
tmp += (char)(keySizes[i] >> 16);
tmp += (char)(keySizes[i] >> 8);
tmp += (char)(keySizes[i]);
}
writePointer(p, tmp.data(), tmp.size());
writePointer(p, "\000\005parts\002", 8);
@ -1492,10 +1492,10 @@ namespace DTSC {
std::string tmp;
tmp.reserve(keySizes.size() * 4);
for (unsigned int i = 0; i < keySizes.size(); i++){
tmp += ((char)keySizes[i] >> 24);
tmp += ((char)keySizes[i] >> 16);
tmp += ((char)keySizes[i] >> 8);
tmp += ((char)keySizes[i]);
tmp += (char)(keySizes[i] >> 24);
tmp += (char)(keySizes[i] >> 16);
tmp += (char)(keySizes[i] >> 8);
tmp += (char)(keySizes[i]);
}
conn.SendNow(tmp.data(), tmp.size());
conn.SendNow("\000\005parts\002", 8);
@ -1631,10 +1631,10 @@ namespace DTSC {
tmp = "";
tmp.reserve(keySizes.size() * 4);
for (unsigned int i = 0; i < keySizes.size(); i++){
tmp += ((char)(keySizes[i] >> 24));
tmp += ((char)(keySizes[i] >> 16));
tmp += ((char)(keySizes[i] >> 8));
tmp += ((char)keySizes[i]);
tmp += (char)((keySizes[i] >> 24));
tmp += (char)((keySizes[i] >> 16));
tmp += (char)((keySizes[i] >> 8));
tmp += (char)(keySizes[i]);
}
result["keysizes"] = tmp;
tmp = "";

View file

@ -309,10 +309,10 @@ void HTTP::Parser::SetHeader(std::string i, std::string v) {
}
/// Sets header i to integer value v.
void HTTP::Parser::SetHeader(std::string i, int v) {
void HTTP::Parser::SetHeader(std::string i, long long v) {
Trim(i);
char val[23]; //ints are never bigger than 22 chars as decimal
sprintf(val, "%i", v);
sprintf(val, "%lld", v);
headers[i] = val;
}

View file

@ -20,7 +20,7 @@ namespace HTTP {
std::string GetVar(std::string i);
std::string getUrl();
void SetHeader(std::string i, std::string v);
void SetHeader(std::string i, int v);
void SetHeader(std::string i, long long v);
void SetVar(std::string i, std::string v);
void SetBody(std::string s);
void SetBody(char * buffer, int len);

View file

@ -817,6 +817,20 @@ namespace MP4 {
return (getData()[0] == 0x40);
}
std::string DCDescriptor::getCodec(){
switch(getData()[0]){
case 0x40:
return "AAC";
break;
case 0x69:
case 0x6B:
return "MP3";
break;
default:
return "UNKNOWN";
}
}
std::string DCDescriptor::toPrettyString(uint32_t indent){
std::stringstream r;
r << std::string(indent, ' ') << "[" << (int)data[0] << "] DecoderConfig Descriptor (" << getDataSize() << ")" << std::endl;
@ -893,10 +907,10 @@ namespace MP4 {
ESDS::ESDS(std::string init) {
///\todo Do this better, in a non-hardcoded way.
memcpy(data + 4, "esds", 4);
reserve(payloadOffset, 0, init.size() ? init.size()+26 : 24);
reserve(payloadOffset, 0, init.size() ? init.size()+29 : 26);
unsigned int i = 12;
data[i++] = 3;//ES_DescrTag
data[i++] = init.size() ? init.size()+20 : 18;//size
data[i++] = init.size() ? init.size()+23 : 21;//size
data[i++] = 0;//es_id
data[i++] = 2;//es_id
data[i++] = 0;//priority
@ -907,7 +921,7 @@ namespace MP4 {
}else{
data[i++] = 0x69;//objType MP3
}
data[i++] = 0x14;//streamType audio (5<<2)
data[i++] = 0x15;//streamType audio (5<<2 + 1)
data[i++] = 0;//buffer size
data[i++] = 0;//buffer size
data[i++] = 0;//buffer size
@ -923,13 +937,21 @@ namespace MP4 {
data[i++] = 0x5;//DecSpecificInfoTag
data[i++] = init.size();
memcpy(data+i, init.data(), init.size());
i += init.size();
}
data[i++] = 6;//SLConfigDescriptor
data[i++] = 1;//size
data[i++] = 2;//predefined, reserverd for use in MP4 files
}
bool ESDS::isAAC(){
return getESDescriptor().getDecoderConfig().isAAC();
}
std::string ESDS::getCodec(){
return getESDescriptor().getDecoderConfig().getCodec();
}
std::string ESDS::getInitData(){
return getESDescriptor().getDecoderConfig().getSpecific().toString();
}
@ -2195,6 +2217,7 @@ namespace MP4 {
for (unsigned int i = getEntryCount(); i < no; i++) {
setInt64(0, 8 + (i * 8));//filling up undefined entries of 64 bits
}
setEntryCount(no + 1);
}
setInt32(newCTTSEntry.sampleCount, 8 + no * 8);
setInt32(newCTTSEntry.sampleOffset, 8 + (no * 8) + 4);
@ -2213,7 +2236,7 @@ namespace MP4 {
std::string CTTS::toPrettyString(uint32_t indent) {
std::stringstream r;
r << std::string(indent, ' ') << "[stts] Sample Table Box (" << boxedSize() << ")" << std::endl;
r << std::string(indent, ' ') << "[ctts] Composition Time To Sample Box (" << boxedSize() << ")" << std::endl;
r << fullBox::toPrettyString(indent);
r << std::string(indent + 1, ' ') << "EntryCount: " << getEntryCount() << std::endl;
for (unsigned int i = 0; i < getEntryCount(); i++) {

View file

@ -152,6 +152,7 @@ namespace MP4 {
public:
DCDescriptor (const char* pointer, const unsigned long length, const bool master = false);
bool isAAC(); ///< Returns true if this track is AAC.
std::string getCodec();
DSDescriptor getSpecific();
std::string toPrettyString(uint32_t indent = 0);///< put it into a pretty string
};
@ -176,6 +177,7 @@ namespace MP4 {
ESDS(std::string init);
ESDescriptor getESDescriptor();
bool isAAC();
std::string getCodec();
std::string getInitData();
std::string toPrettyString(uint32_t indent = 0);
};