From 6720f7a5aecf339255e94efe8798c1fff62926d9 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 20 Jan 2014 10:33:24 +0100 Subject: [PATCH] Moved boolean cast to readOnlyMeta, fix'ed bugs regarding FLV metadata generation. --- lib/dtsc.h | 2 +- lib/flv_tag.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/dtsc.h b/lib/dtsc.h index ddb86047..d95e643c 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -202,6 +202,7 @@ namespace DTSC { public: readOnlyMeta(); readOnlyMeta(JSON::Value & meta); + inline operator bool() const {return vod || live;} std::map tracks; bool vod; bool live; @@ -218,7 +219,6 @@ namespace DTSC { Meta(); Meta(const readOnlyMeta & meta); Meta(JSON::Value & meta); - inline operator bool() const {return vod || live;} std::map tracks; void update(JSON::Value & pack); void send(Socket::Connection & conn); diff --git a/lib/flv_tag.cpp b/lib/flv_tag.cpp index c635f767..15f8b15a 100644 --- a/lib/flv_tag.cpp +++ b/lib/flv_tag.cpp @@ -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("times", AMF::AMF0_STRICT_ARRAY)); int total_byterate = 0; - if (videoRef){ + if (videoRef.trackID > 0){ total_byterate += videoRef.bps; } - if (audioRef){ + if (audioRef.trackID > 0){ total_byterate += audioRef.bps; } 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); } - if (videoRef){ + if (videoRef.trackID > 0){ amfdata.getContentP(1)->addContent(AMF::Object("hasVideo", 1, AMF::AMF0_BOOL)); if (videoRef.codec == "H264"){ 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("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("audiodelay", 0, AMF::AMF0_NUMBER)); if (audioRef.codec == "AAC"){