Moved boolean cast to readOnlyMeta, fix'ed bugs regarding FLV metadata generation.

This commit is contained in:
Erik Zandvliet 2014-01-20 10:33:24 +01:00
parent 9ddc2fc794
commit 6720f7a5ae
2 changed files with 5 additions and 5 deletions

View file

@ -202,6 +202,7 @@ namespace DTSC {
public: public:
readOnlyMeta(); readOnlyMeta();
readOnlyMeta(JSON::Value & meta); readOnlyMeta(JSON::Value & meta);
inline operator bool() const {return vod || live;}
std::map<int,readOnlyTrack> tracks; std::map<int,readOnlyTrack> tracks;
bool vod; bool vod;
bool live; bool live;
@ -218,7 +219,6 @@ namespace DTSC {
Meta(); Meta();
Meta(const readOnlyMeta & meta); Meta(const readOnlyMeta & meta);
Meta(JSON::Value & meta); Meta(JSON::Value & meta);
inline operator bool() const {return vod || live;}
std::map<int,Track> tracks; std::map<int,Track> tracks;
void update(JSON::Value & pack); void update(JSON::Value & pack);
void send(Socket::Connection & conn); void send(Socket::Connection & conn);

View file

@ -606,10 +606,10 @@ bool FLV::Tag::DTSCMetaInit(DTSC::Stream & S, DTSC::Track & videoRef, DTSC::Trac
keys.addContent(AMF::Object("filepositions", AMF::AMF0_STRICT_ARRAY)); keys.addContent(AMF::Object("filepositions", AMF::AMF0_STRICT_ARRAY));
keys.addContent(AMF::Object("times", AMF::AMF0_STRICT_ARRAY)); keys.addContent(AMF::Object("times", AMF::AMF0_STRICT_ARRAY));
int total_byterate = 0; int total_byterate = 0;
if (videoRef){ if (videoRef.trackID > 0){
total_byterate += videoRef.bps; total_byterate += videoRef.bps;
} }
if (audioRef){ if (audioRef.trackID > 0){
total_byterate += audioRef.bps; total_byterate += audioRef.bps;
} }
for (int i = 0; i < videoRef.lastms / 1000; ++i){ //for each second in the file for (int i = 0; i < videoRef.lastms / 1000; ++i){ //for each second in the file
@ -618,7 +618,7 @@ bool FLV::Tag::DTSCMetaInit(DTSC::Stream & S, DTSC::Track & videoRef, DTSC::Trac
} }
amfdata.getContentP(1)->addContent(keys); amfdata.getContentP(1)->addContent(keys);
} }
if (videoRef){ if (videoRef.trackID > 0){
amfdata.getContentP(1)->addContent(AMF::Object("hasVideo", 1, AMF::AMF0_BOOL)); amfdata.getContentP(1)->addContent(AMF::Object("hasVideo", 1, AMF::AMF0_BOOL));
if (videoRef.codec == "H264"){ if (videoRef.codec == "H264"){
amfdata.getContentP(1)->addContent(AMF::Object("videocodecid", (std::string)"avc1")); amfdata.getContentP(1)->addContent(AMF::Object("videocodecid", (std::string)"avc1"));
@ -634,7 +634,7 @@ bool FLV::Tag::DTSCMetaInit(DTSC::Stream & S, DTSC::Track & videoRef, DTSC::Trac
amfdata.getContentP(1)->addContent(AMF::Object("videoframerate", (double)videoRef.fpks / 1000.0, AMF::AMF0_NUMBER)); amfdata.getContentP(1)->addContent(AMF::Object("videoframerate", (double)videoRef.fpks / 1000.0, AMF::AMF0_NUMBER));
amfdata.getContentP(1)->addContent(AMF::Object("videodatarate", (double)videoRef.bps * 128.0, AMF::AMF0_NUMBER)); amfdata.getContentP(1)->addContent(AMF::Object("videodatarate", (double)videoRef.bps * 128.0, AMF::AMF0_NUMBER));
} }
if (audioRef){ if (audioRef.trackID > 0){
amfdata.getContentP(1)->addContent(AMF::Object("hasAudio", 1, AMF::AMF0_BOOL)); amfdata.getContentP(1)->addContent(AMF::Object("hasAudio", 1, AMF::AMF0_BOOL));
amfdata.getContentP(1)->addContent(AMF::Object("audiodelay", 0, AMF::AMF0_NUMBER)); amfdata.getContentP(1)->addContent(AMF::Object("audiodelay", 0, AMF::AMF0_NUMBER));
if (audioRef.codec == "AAC"){ if (audioRef.codec == "AAC"){