mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
HTTP-TS: Support guess_has_av for audio only stream. v6.0.141 (#4063)
## Describe ##
http_remux feature support config `has_audio`, `has_video` &
`guess_has_av` prop.
282d94d7bb/trunk/src/app/srs_app_http_stream.cpp (L630-L632)
Take `http_flv` as example, `srs` can accept both RTMP streams with only
audio, only video or both audio and video streams. It is controlled by
above three properties.
But `guess_has_av` is not implemented by `http_ts`. The problem is that
if I want publish a RTMP stream with audio or video track, the
`has_audio` and `has_video`, which are default true/on, must to be
config to match the RTMP stream, otherwise the `mpegts.js` player can't
play the `http-ts` stream.
## How to reproduce ##
1. `export SRS_VHOST_HTTP_REMUX_HAS_AUDIO=on; export
SRS_VHOST_HTTP_REMUX_HAS_VIDEO=on; export
SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV=on; ./objs/srs -c
conf/http.ts.live.conf`
2. publish rtmp stream without video: `ffmpeg -re -stream_loop -1 -i
srs/trunk/doc/source.200kbps.768x320.flv -vn -acodec copy -f flv
rtmp://localhost/live/livestream`
3. open chrome browser, open
`http://localhost:8080/players/srs_player.html?schema=http`, go to
`LivePlayer`, input URL: `http://localhost:8080/live/livestream.ts`,
click play.
4. the `http://localhost:8080/live/livestream.ts` can not play.
## Solution ##
Let `http-ts` support `guess_has_av`, `http-flv` already supported. The
`guess_has_av` default value is ture/on, so the `http-ts|flv` can play
any streams with audio, video or both.
---------
Co-authored-by: Winlin <winlinvip@gmail.com>
This commit is contained in:
parent
d50fb1563a
commit
eb788a62ad
6 changed files with 35 additions and 1 deletions
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue