diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 7f620fa96..81542f2ae 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -1460,23 +1460,23 @@ vhost http.remux.srs.com { drop_if_not_match on; # Whether stream has audio track, used as default value for stream metadata, for example, FLV header contains # this flag. Sometimes you might want to force the metadata by disable guess_has_av. - # See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # TODO: Only support HTTP-FLV stream right now. + # For HTTP-FLV, use this as default value for FLV header audio flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_AUDIO for all vhosts. # Default: on has_audio on; # Whether stream has video track, used as default value for stream metadata, for example, FLV header contains # this flag. Sometimes you might want to force the metadata by disable guess_has_av. - # See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # TODO: Only support HTTP-FLV stream right now. + # For HTTP-FLV, use this as default value for FLV header video flag. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, use this as default value for PMT table. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 # Overwrite by env SRS_VHOST_HTTP_REMUX_HAS_VIDEO for all vhosts. # Default: on has_video on; # Whether guessing stream about audio or video track, used to generate the flags in, such as FLV header. If # guessing, depends on sequence header and frames in gop cache, so it might be incorrect especially your stream # is not regular. If not guessing, use the configured default value has_audio and has_video. - # See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 - # TODO: Only support HTTP-FLV stream right now. + # For HTTP-FLV, enable guessing for av header flag, because FLV can't change the header. See https://github.com/ossrs/srs/issues/939#issuecomment-1351385460 + # For HTTP-TS, ignore guessing because TS refresh the PMT when codec changed. See https://github.com/ossrs/srs/issues/939#issuecomment-1365086204 # Overwrite by env SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV for all vhosts. # Default: on guess_has_av on; diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 3b122e650..2eb000016 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v5.0, 2022-12-26, For [#465](https://github.com/ossrs/srs/issues/465): TS: Support disable audio or video to make mpegts.js happy. v6.0.9 * v5.0, 2022-12-26, For [#465](https://github.com/ossrs/srs/issues/465): TS: Fix bug for codec detecting for HTTP-TS. v6.0.8 * v5.0, 2022-12-25, For [#296](https://github.com/ossrs/srs/issues/296): Fix [#3338](https://github.com/ossrs/srs/issues/3338): MP3: Support play HTTP-MP3 by H5(srs-player). v6.0.7 * v6.0, 2022-12-17, Merge 5.0: FLV header and SRT bugfix. v6.0.6 diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index e8bb3f778..2363652e2 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -234,6 +234,15 @@ srs_error_t SrsTsStreamEncoder::dump_cache(SrsLiveConsumer* /*consumer*/, SrsRtm return srs_success; } +void SrsTsStreamEncoder::set_has_audio(bool v) +{ + enc->set_has_audio(v); +} +void SrsTsStreamEncoder::set_has_video(bool v) +{ + enc->set_has_video(v); +} + SrsFlvStreamEncoder::SrsFlvStreamEncoder() { header_written = false; @@ -636,6 +645,8 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess w->header()->set_content_type("video/MP2T"); enc_desc = "TS"; enc = new SrsTsStreamEncoder(); + ((SrsTsStreamEncoder*)enc)->set_has_audio(has_audio); + ((SrsTsStreamEncoder*)enc)->set_has_video(has_video); } else { return srs_error_new(ERROR_HTTP_LIVE_STREAM_EXT, "invalid pattern=%s", entry->pattern.c_str()); } diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index d01bbe3b1..0058b52f6 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -110,6 +110,9 @@ public: public: virtual bool has_cache(); virtual srs_error_t dump_cache(SrsLiveConsumer* consumer, SrsRtmpJitterAlgorithm jitter); +public: + void set_has_audio(bool v); + void set_has_video(bool v); }; // Transmux RTMP with AAC stream to HTTP AAC Streaming. diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index c28577e78..dd35a6e6a 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 8 +#define VERSION_REVISION 9 #endif diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index 2d7145b1a..f2dcaaa46 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -3176,6 +3176,7 @@ SrsTsTransmuxer::SrsTsTransmuxer() tsmc = new SrsTsMessageCache(); context = new SrsTsContext(); tscw = NULL; + has_audio_ = has_video_ = true; } SrsTsTransmuxer::~SrsTsTransmuxer() @@ -3186,6 +3187,16 @@ SrsTsTransmuxer::~SrsTsTransmuxer() srs_freep(context); } +void SrsTsTransmuxer::set_has_audio(bool v) +{ + has_audio_ = v; +} + +void SrsTsTransmuxer::set_has_video(bool v) +{ + has_video_ = v; +} + srs_error_t SrsTsTransmuxer::initialize(ISrsStreamWriter* fw) { srs_error_t err = srs_success; @@ -3197,11 +3208,13 @@ srs_error_t SrsTsTransmuxer::initialize(ISrsStreamWriter* fw) srs_assert(fw); writer = fw; - + + SrsAudioCodecId acodec = has_audio_ ? SrsAudioCodecIdAAC : SrsAudioCodecIdForbidden; + SrsVideoCodecId vcodec = has_video_ ? SrsVideoCodecIdAVC : SrsVideoCodecIdForbidden; + srs_freep(tscw); - // TODO: FIXME: Support config the codec. - tscw = new SrsTsContextWriter(fw, context, SrsAudioCodecIdAAC, SrsVideoCodecIdAVC); - + tscw = new SrsTsContextWriter(fw, context, acodec, vcodec); + return err; } diff --git a/trunk/src/kernel/srs_kernel_ts.hpp b/trunk/src/kernel/srs_kernel_ts.hpp index f1c73a2e6..cf2272efa 100644 --- a/trunk/src/kernel/srs_kernel_ts.hpp +++ b/trunk/src/kernel/srs_kernel_ts.hpp @@ -1332,6 +1332,8 @@ class SrsTsTransmuxer { private: ISrsStreamWriter* writer; + bool has_audio_; + bool has_video_; private: SrsFormat* format; SrsTsMessageCache* tsmc; @@ -1340,6 +1342,9 @@ private: public: SrsTsTransmuxer(); virtual ~SrsTsTransmuxer(); +public: + void set_has_audio(bool v); + void set_has_video(bool v); public: // Initialize the underlayer file stream. // @param fw the writer to use for ts encoder, user must free it.