Updated mp4 to parse some information from JSON-style metadata, guesses values if not present.
This commit is contained in:
parent
48bf3d189a
commit
4ac7c54698
2 changed files with 10 additions and 4 deletions
11
lib/mp4.cpp
11
lib/mp4.cpp
|
@ -1,7 +1,8 @@
|
||||||
#include "mp4.h"
|
|
||||||
#include <stdlib.h> //for malloc and free
|
#include <stdlib.h> //for malloc and free
|
||||||
#include <string.h> //for memcpy
|
#include <string.h> //for memcpy
|
||||||
#include <arpa/inet.h> //for htonl and friends
|
#include <arpa/inet.h> //for htonl and friends
|
||||||
|
#include "mp4.h"
|
||||||
|
#include "json.h"
|
||||||
|
|
||||||
/// Contains all MP4 format related code.
|
/// Contains all MP4 format related code.
|
||||||
namespace MP4{
|
namespace MP4{
|
||||||
|
@ -363,12 +364,16 @@ void ASRT::WriteContent( ) {
|
||||||
SetPayload((uint32_t)4,Box::uint32_to_uint8((isUpdate ? 1 : 0)));
|
SetPayload((uint32_t)4,Box::uint32_to_uint8((isUpdate ? 1 : 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenerateLiveBootstrap( uint32_t CurMediaTime ) {
|
std::string GenerateLiveBootstrap( JSON::Value & metadata ) {
|
||||||
AFRT afrt;
|
AFRT afrt;
|
||||||
afrt.SetUpdate(false);
|
afrt.SetUpdate(false);
|
||||||
afrt.SetTimeScale(1000);
|
afrt.SetTimeScale(1000);
|
||||||
afrt.AddQualityEntry("");
|
afrt.AddQualityEntry("");
|
||||||
afrt.AddFragmentRunEntry(1, 0 , 4000); //FirstFragment, FirstFragmentTimestamp,Fragment Duration in milliseconds
|
if (!metadata.isMember("video") || !metadata["video"].isMember("keyms")){
|
||||||
|
afrt.AddFragmentRunEntry(1, 0, 1000); //FirstFragment, FirstFragmentTimestamp,Fragment Duration in milliseconds
|
||||||
|
}else{
|
||||||
|
afrt.AddFragmentRunEntry(1, 0, metadata["video"]["keyms"].asInt()); //FirstFragment, FirstFragmentTimestamp,Fragment Duration in milliseconds
|
||||||
|
}
|
||||||
afrt.WriteContent();
|
afrt.WriteContent();
|
||||||
|
|
||||||
ASRT asrt;
|
ASRT asrt;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "json.h"
|
||||||
|
|
||||||
/// Contains all MP4 format related code.
|
/// Contains all MP4 format related code.
|
||||||
namespace MP4{
|
namespace MP4{
|
||||||
|
@ -125,7 +126,7 @@ namespace MP4{
|
||||||
Box * Container;
|
Box * Container;
|
||||||
};//ASRT Box
|
};//ASRT Box
|
||||||
|
|
||||||
std::string GenerateLiveBootstrap( uint32_t CurMediaTime );
|
std::string GenerateLiveBootstrap( JSON::Value & metadata );
|
||||||
std::string mdatFold(std::string data);
|
std::string mdatFold(std::string data);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue