Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP-TS: Support guess_has_av for audio only stream. v6.0.141 #4063

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v6-changes"></a>

## 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)
Expand Down
7 changes: 7 additions & 0 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,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;
Expand Down Expand Up @@ -677,6 +683,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
enc_raw = new SrsTsStreamEncoder();
((SrsTsStreamEncoder*)enc_raw)->set_has_audio(has_audio);
((SrsTsStreamEncoder*)enc_raw)->set_has_video(has_video);
((SrsTsStreamEncoder*)enc_raw)->set_guess_has_av(guess_has_av);
} else {
return srs_error_new(ERROR_HTTP_LIVE_STREAM_EXT, "invalid pattern=%s", entry->pattern.c_str());
}
Expand Down
1 change: 1 addition & 0 deletions trunk/src/app/srs_app_http_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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.
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 140
#define VERSION_REVISION 141

#endif
23 changes: 23 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3176,6 +3176,7 @@ SrsTsTransmuxer::SrsTsTransmuxer()
context = new SrsTsContext();
tscw = NULL;
has_audio_ = has_video_ = true;
guess_has_av_ = true;
}

SrsTsTransmuxer::~SrsTsTransmuxer()
Expand All @@ -3189,11 +3190,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)
Expand All @@ -3211,6 +3229,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);

Expand Down
2 changes: 2 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ class SrsTsTransmuxer
ISrsStreamWriter* writer;
bool has_audio_;
bool has_video_;
bool guess_has_av_;
private:
SrsFormat* format;
SrsTsMessageCache* tsmc;
Expand All @@ -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.
Expand Down
Loading