diff --git a/lib/mp4.cpp b/lib/mp4.cpp index 6c8dc234..36d9d986 100644 --- a/lib/mp4.cpp +++ b/lib/mp4.cpp @@ -1641,9 +1641,34 @@ namespace MP4{ std::string AVCC::asAnnexB( ) { std::stringstream r; r << (char)0x00 << (char)0x00 << (char)0x00 << (char)0x01; - r << getSPS( ); + r.write( getSPS( ), getSPSLen() ); r << (char)0x00 << (char)0x00 << (char)0x00 << (char)0x01; - r << getPPS( ); + r.write( getPPS( ), getPPSLen() ); return r.str(); } + + void AVCC::setPayload( std::string newPayload ) { + if( ! reserve( 0, payloadSize(), newPayload.size() ) ) { return; } + memcpy( (char*)payload(), (char*)newPayload.c_str(), newPayload.size() ); + } + + SDTP::SDTP() { + memcpy(data + 4, "sdtp", 4); + } + + void SDTP::setVersion( long newVersion ) { + setInt8( newVersion, 0 ); + } + + long SDTP::getVersion( ) { + return getInt8( 0 ); + } + + void SDTP::setValue( long newValue, size_t index ) { + setInt8( newValue, index ); + } + + long SDTP::getValue( size_t index ) { + getInt8( index ); + } }; diff --git a/lib/mp4.h b/lib/mp4.h index 6ff69bca..30fbd30d 100644 --- a/lib/mp4.h +++ b/lib/mp4.h @@ -275,7 +275,6 @@ namespace MP4{ std::string toPrettyString(long indent = 0); }; - class AVCC : public Box { public: AVCC(); @@ -298,6 +297,16 @@ namespace MP4{ long getPPSLen( ); char* getPPS( ); std::string asAnnexB( ); + void setPayload( std::string newPayload ); std::string toPrettyString(long indent = 0); }; + + class SDTP : public Box { + public: + SDTP(); + void setVersion( long newVersion ); + long getVersion( ); + void setValue( long newValue, size_t index ); + long getValue( size_t index ); + }; };