From 4b379d2f0e1b9f6edc96d056c398e146431a30d6 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Tue, 21 May 2024 16:30:01 +0800 Subject: [PATCH 1/2] let http-remux ts stream support guess_has_av feature; --- trunk/src/app/srs_app_http_stream.cpp | 7 +++++++ trunk/src/app/srs_app_http_stream.hpp | 1 + trunk/src/kernel/srs_kernel_ts.cpp | 23 +++++++++++++++++++++++ trunk/src/kernel/srs_kernel_ts.hpp | 2 ++ 4 files changed, 33 insertions(+) diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 181ee14c09..62e9523143 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -238,11 +238,17 @@ void SrsTsStreamEncoder::set_has_audio(bool v) { enc->set_has_audio(v); } + void SrsTsStreamEncoder::set_has_video(bool v) { enc->set_has_video(v); } +void SrsTsStreamEncoder::set_guess_has_av(bool v) +{ + enc->set_guess_has_av(v); +} + SrsFlvStreamEncoder::SrsFlvStreamEncoder() { header_written = false; @@ -653,6 +659,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess enc = new SrsTsStreamEncoder(); ((SrsTsStreamEncoder*)enc)->set_has_audio(has_audio); ((SrsTsStreamEncoder*)enc)->set_has_video(has_video); + ((SrsTsStreamEncoder*)enc)->set_guess_has_av(guess_has_av); } 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 138eb003c4..e73e9255c2 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -113,6 +113,7 @@ class SrsTsStreamEncoder : public ISrsBufferEncoder public: void set_has_audio(bool v); void set_has_video(bool v); + void set_guess_has_av(bool v); }; // Transmux RTMP with AAC stream to HTTP AAC Streaming. diff --git a/trunk/src/kernel/srs_kernel_ts.cpp b/trunk/src/kernel/srs_kernel_ts.cpp index a2fca00eab..ff81294465 100644 --- a/trunk/src/kernel/srs_kernel_ts.cpp +++ b/trunk/src/kernel/srs_kernel_ts.cpp @@ -3183,6 +3183,7 @@ SrsTsTransmuxer::SrsTsTransmuxer() context = new SrsTsContext(); tscw = NULL; has_audio_ = has_video_ = true; + guess_has_av_ = true; } SrsTsTransmuxer::~SrsTsTransmuxer() @@ -3196,11 +3197,28 @@ SrsTsTransmuxer::~SrsTsTransmuxer() void SrsTsTransmuxer::set_has_audio(bool v) { has_audio_ = v; + + if (tscw != NULL && !v) { + tscw->set_acodec(SrsAudioCodecIdForbidden); + } } void SrsTsTransmuxer::set_has_video(bool v) { has_video_ = v; + + if (tscw != NULL && !v) { + tscw->set_vcodec(SrsVideoCodecIdForbidden); + } +} + +void SrsTsTransmuxer::set_guess_has_av(bool v) +{ + guess_has_av_ = v; + if (tscw != NULL && v) { + tscw->set_acodec(SrsAudioCodecIdForbidden); + tscw->set_vcodec(SrsVideoCodecIdForbidden); + } } srs_error_t SrsTsTransmuxer::initialize(ISrsStreamWriter* fw) @@ -3218,6 +3236,11 @@ srs_error_t SrsTsTransmuxer::initialize(ISrsStreamWriter* fw) SrsAudioCodecId acodec = has_audio_ ? SrsAudioCodecIdAAC : SrsAudioCodecIdForbidden; SrsVideoCodecId vcodec = has_video_ ? SrsVideoCodecIdAVC : SrsVideoCodecIdForbidden; + if (guess_has_av_) { + acodec = SrsAudioCodecIdForbidden; + vcodec = SrsVideoCodecIdForbidden; + } + srs_freep(tscw); tscw = new SrsTsContextWriter(fw, context, acodec, vcodec); diff --git a/trunk/src/kernel/srs_kernel_ts.hpp b/trunk/src/kernel/srs_kernel_ts.hpp index e79f07f9ef..d80f112367 100644 --- a/trunk/src/kernel/srs_kernel_ts.hpp +++ b/trunk/src/kernel/srs_kernel_ts.hpp @@ -1333,6 +1333,7 @@ class SrsTsTransmuxer ISrsStreamWriter* writer; bool has_audio_; bool has_video_; + bool guess_has_av_; private: SrsFormat* format; SrsTsMessageCache* tsmc; @@ -1344,6 +1345,7 @@ class SrsTsTransmuxer public: void set_has_audio(bool v); void set_has_video(bool v); + void set_guess_has_av(bool v); public: // Initialize the underlayer file stream. // @param fw the writer to use for ts encoder, user must free it. From 21e33cd6b9bbc6b368390e5c5da0901b4df6ce98 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 24 Jul 2024 10:25:31 +0800 Subject: [PATCH 2/2] Update release to v6.0.141 --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version6.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 4af10b113b..653c053a3c 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-07-24, Merge [#4063](https://github.com/ossrs/srs/pull/4063): let http-remux ts stream support guess_has_av feature;. v6.0.141 (#4063) * v6.0, 2024-07-24, Merge [#4116](https://github.com/ossrs/srs/pull/4116): Dockerfile: Consistently use proper ENV syntax using "=". v6.0.140 (#4116) * v6.0, 2024-07-24, Merge [#4126](https://github.com/ossrs/srs/pull/4126): Edge: Improve stability for state and fd closing. v6.0.139 (#4126) * v6.0, 2024-07-13, Merge [#4111](https://github.com/ossrs/srs/pull/4111): DASH: Fix time unit error for disposing. v6.0.138 (#4111) diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 9b6cb83cea..d6c8534e92 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 140 +#define VERSION_REVISION 141 #endif