From 84b2293c9ce4afc050ffc9cec337ae8e7c6e8632 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Mon, 2 Oct 2023 20:11:12 +0200 Subject: [PATCH 001/170] fix typo in README (#2446) --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index d4cf6bd1c13..aba5c7572d0 100644 --- a/README.md +++ b/README.md @@ -781,8 +781,6 @@ In order to use the UDP-multicast transport protocol, append `?vlcmulticast` to vlc --network-caching=50 rtsp://localhost:8554/mystream?vlcmulticast ``` -You can change the transport protocol by using the `--rtsp_` flag: - ##### Ubuntu bug The VLC shipped with Ubuntu 21.10 doesn't support playing RTSP due to a license issue (see [here](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982299) and [here](https://stackoverflow.com/questions/69766748/cvlc-cannot-play-rtsp-omxplayer-instead-can)). To fix the issue, remove the default VLC instance and install the snap version: From 34cdef1c49f0df048cef7e936c2f9720cb8288e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:11:26 +0200 Subject: [PATCH 002/170] build(deps): bump github.com/abema/go-mp4 from 1.1.0 to 1.1.1 (#2447) Bumps [github.com/abema/go-mp4](https://github.com/abema/go-mp4) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/abema/go-mp4/releases) - [Commits](https://github.com/abema/go-mp4/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/abema/go-mp4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 978256acee0..0105443ccc5 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( code.cloudfoundry.org/bytefmt v0.0.0 - github.com/abema/go-mp4 v1.1.0 + github.com/abema/go-mp4 v1.1.1 github.com/alecthomas/kong v0.8.0 github.com/aler9/writerseeker v1.1.0 github.com/bluenviron/gohlslib v1.0.3 diff --git a/go.sum b/go.sum index df46e2e0cde..8fb4ace511e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/abema/go-mp4 v1.1.0 h1:wr2uc6ENLtYNw/nRmjIYkAc6ZuAUe88FAUYAeZhcAgE= -github.com/abema/go-mp4 v1.1.0/go.mod h1:vPl9t5ZK7K0x68jh12/+ECWBCXoWuIDtNgPtU2f04ws= +github.com/abema/go-mp4 v1.1.1 h1:OfzkdMO6SWTBR1ltNSVwlTHatrAK9I3iYLQfkdEMMuc= +github.com/abema/go-mp4 v1.1.1/go.mod h1:vPl9t5ZK7K0x68jh12/+ECWBCXoWuIDtNgPtU2f04ws= github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0= github.com/alecthomas/kong v0.8.0 h1:ryDCzutfIqJPnNn0omnrgHLbAggDQM2VWHikE1xqK7s= github.com/alecthomas/kong v0.8.0/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= From 4ba2dc1b34312510f4f9297729adca1b626488ed Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Tue, 3 Oct 2023 13:00:46 +0200 Subject: [PATCH 003/170] apidocs: remove invalid value from PathSourceOrReader (#2450) --- apidocs/openapi.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/apidocs/openapi.yaml b/apidocs/openapi.yaml index 9c775973fd2..391c57a5ee5 100644 --- a/apidocs/openapi.yaml +++ b/apidocs/openapi.yaml @@ -403,7 +403,6 @@ components: - rpiCameraSource - rtmpConn - rtmpSource - - rtmpsSession - rtspSession - rtspSource - rtspsSession From 215f88e2dd4573ceb785aad621df402082addd7d Mon Sep 17 00:00:00 2001 From: Rui Lopes Date: Wed, 4 Oct 2023 16:00:15 +0100 Subject: [PATCH 004/170] webrtc: add Location header to CORS-allowed headers (#2453) --- internal/core/webrtc_http_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/core/webrtc_http_server.go b/internal/core/webrtc_http_server.go index e5689635b9f..fe47bfcab28 100644 --- a/internal/core/webrtc_http_server.go +++ b/internal/core/webrtc_http_server.go @@ -262,7 +262,7 @@ func (s *webRTCHTTPServer) onRequest(ctx *gin.Context) { } ctx.Writer.Header().Set("Content-Type", "application/sdp") - ctx.Writer.Header().Set("Access-Control-Expose-Headers", "ETag, Accept-Patch, Link") + ctx.Writer.Header().Set("Access-Control-Expose-Headers", "ETag, Accept-Patch, Link, Location") ctx.Writer.Header().Set("ETag", res.sx.secret.String()) ctx.Writer.Header().Set("ID", res.sx.uuid.String()) ctx.Writer.Header().Set("Accept-Patch", "application/trickle-ice-sdpfrag") From 7b75e5cbe92cd5653fcea5b09c58bd7bd6687376 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:36:25 +0200 Subject: [PATCH 005/170] build(deps): bump github.com/pion/interceptor from 0.1.20 to 0.1.21 (#2456) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0105443ccc5..ee123364f8c 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/notedit/rtmp v0.0.2 github.com/pion/ice/v2 v2.3.11 - github.com/pion/interceptor v0.1.20 + github.com/pion/interceptor v0.1.21 github.com/pion/rtcp v1.2.10 github.com/pion/rtp v1.8.2 github.com/pion/sdp/v3 v3.0.6 diff --git a/go.sum b/go.sum index 8fb4ace511e..12144be5ee3 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ github.com/pion/ice/v2 v2.3.11 h1:rZjVmUwyT55cmN8ySMpL7rsS8KYsJERsrxJLLxpKhdw= github.com/pion/ice/v2 v2.3.11/go.mod h1:hPcLC3kxMa+JGRzMHqQzjoSj3xtE9F+eoncmXLlCL4E= github.com/pion/interceptor v0.1.18/go.mod h1:tpvvF4cPM6NGxFA1DUMbhabzQBxdWMATDGEUYOR9x6I= -github.com/pion/interceptor v0.1.20 h1:gORAnvlXu1f4Bx+TcXe8UJ37Jqb/tkNQ6E83NNqYZh0= -github.com/pion/interceptor v0.1.20/go.mod h1:wkbPYAak5zKsfpVDYMtEfWEy8D4zL+rpxCxPImLOg3Y= +github.com/pion/interceptor v0.1.21 h1:owpNzUHITYK5IqP83LoPECO5Rq6uK4io7dGUx1SQJoo= +github.com/pion/interceptor v0.1.21/go.mod h1:wkbPYAak5zKsfpVDYMtEfWEy8D4zL+rpxCxPImLOg3Y= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= github.com/pion/mdns v0.0.8 h1:HhicWIg7OX5PVilyBO6plhMetInbzkVJAhbdJiAeVaI= From a6f929d1110c40f95f7ba9cdb3a4c077bebccd4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:37:30 +0200 Subject: [PATCH 006/170] build(deps): bump golang.org/x/crypto from 0.13.0 to 0.14.0 (#2465) --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ee123364f8c..b75b75e217e 100644 --- a/go.mod +++ b/go.mod @@ -25,8 +25,8 @@ require ( github.com/pion/sdp/v3 v3.0.6 github.com/pion/webrtc/v3 v3.2.21 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.13.0 - golang.org/x/term v0.12.0 + golang.org/x/crypto v0.14.0 + golang.org/x/term v0.13.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -66,7 +66,7 @@ require ( github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/net v0.15.0 // indirect - golang.org/x/sys v0.12.0 // indirect + golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 12144be5ee3..59f92dbf244 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -249,8 +249,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -260,8 +260,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From c37fd38f5ca1ccc137ff26e5e5bdabf0f9aa29bd Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 6 Oct 2023 21:06:29 +0200 Subject: [PATCH 007/170] webrtc: print lost packets (#2468) --- internal/core/webrtc_incoming_track.go | 12 +++++++++++- internal/core/webrtc_session.go | 2 +- internal/core/webrtc_source.go | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/core/webrtc_incoming_track.go b/internal/core/webrtc_incoming_track.go index 4f4187f2c41..3e4cd8f1436 100644 --- a/internal/core/webrtc_incoming_track.go +++ b/internal/core/webrtc_incoming_track.go @@ -7,11 +7,14 @@ import ( "github.com/bluenviron/gortsplib/v4/pkg/description" "github.com/bluenviron/gortsplib/v4/pkg/format" + "github.com/bluenviron/gortsplib/v4/pkg/liberrors" + "github.com/bluenviron/gortsplib/v4/pkg/rtplossdetector" "github.com/bluenviron/gortsplib/v4/pkg/rtptime" "github.com/pion/rtcp" "github.com/pion/rtp" "github.com/pion/webrtc/v3" + "github.com/bluenviron/mediamtx/internal/logger" "github.com/bluenviron/mediamtx/internal/stream" ) @@ -112,7 +115,8 @@ func (webrtcTrackWrapper) PTSEqualsDTS(*rtp.Packet) bool { return true } -func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.GlobalDecoder) { +func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime.GlobalDecoder, log logger.Writer) { + lossDetector := rtplossdetector.New() trackWrapper := &webrtcTrackWrapper{clockRate: int(t.track.Codec().ClockRate)} go func() { @@ -122,6 +126,12 @@ func (t *webRTCIncomingTrack) start(stream *stream.Stream, timeDecoder *rtptime. return } + lost := lossDetector.Process(pkt) + if lost != 0 { + log.Log(logger.Warn, (liberrors.ErrClientRTPPacketsLost{Lost: lost}).Error()) + // do not return + } + // sometimes Chrome sends empty RTP packets. ignore them. if len(pkt.Payload) == 0 { continue diff --git a/internal/core/webrtc_session.go b/internal/core/webrtc_session.go index 493a9921bb2..937b3e66e03 100644 --- a/internal/core/webrtc_session.go +++ b/internal/core/webrtc_session.go @@ -410,7 +410,7 @@ func (s *webRTCSession) runPublish() (int, error) { timeDecoder := rtptime.NewGlobalDecoder() for _, track := range tracks { - track.start(rres.stream, timeDecoder) + track.start(rres.stream, timeDecoder, s) } select { diff --git a/internal/core/webrtc_source.go b/internal/core/webrtc_source.go index a9bc04f0684..e888c12fd2b 100644 --- a/internal/core/webrtc_source.go +++ b/internal/core/webrtc_source.go @@ -158,7 +158,7 @@ func (s *webRTCSource) run(ctx context.Context, cnf *conf.PathConf, _ chan *conf timeDecoder := rtptime.NewGlobalDecoder() for _, track := range tracks { - track.start(rres.stream, timeDecoder) + track.start(rres.stream, timeDecoder, s) } select { From 412a48ac74c2d82a883582719b9881b97063d072 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 6 Oct 2023 22:09:08 +0200 Subject: [PATCH 008/170] webrtc: fix reading Opus stereo tracks with Chrome (#2043) (#2470) --- internal/core/webrtc_manager.go | 2 +- internal/core/webrtc_publish_index.html | 25 ++++++-------- internal/core/webrtc_read_index.html | 46 ++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 16 deletions(-) diff --git a/internal/core/webrtc_manager.go b/internal/core/webrtc_manager.go index 87f5da91822..f2a64a7419a 100644 --- a/internal/core/webrtc_manager.go +++ b/internal/core/webrtc_manager.go @@ -88,7 +88,7 @@ var audioCodecs = []webrtc.RTPCodecParameters{ MimeType: webrtc.MimeTypeOpus, ClockRate: 48000, Channels: 2, - SDPFmtpLine: "minptime=10;useinbandfec=1", + SDPFmtpLine: "minptime=10;useinbandfec=1;stereo=1;sprop-stereo=1", }, PayloadType: 111, }, diff --git a/internal/core/webrtc_publish_index.html b/internal/core/webrtc_publish_index.html index c0458f46d92..cce2f48a796 100644 --- a/internal/core/webrtc_publish_index.html +++ b/internal/core/webrtc_publish_index.html @@ -276,7 +276,7 @@ }; const editAnswer = (answer, videoCodec, audioCodec, videoBitrate, audioBitrate, audioVoice) => { - const sections = answer.split('m='); + const sections = answer.sdp.split('m='); for (let i = 0; i < sections.length; i++) { const section = sections[i]; @@ -287,7 +287,7 @@ } } - return sections.join('m='); + answer.sdp = sections.join('m='); }; class Transmitter { @@ -377,19 +377,16 @@ return; } - answer = new RTCSessionDescription({ - type: 'answer', - sdp: editAnswer( - answer.sdp, - document.getElementById('video_codec').value, - document.getElementById('audio_codec').value, - document.getElementById('video_bitrate').value, - document.getElementById('audio_bitrate').value, - document.getElementById('audio_voice').value, - ), - }); + editAnswer( + answer, + document.getElementById('video_codec').value, + document.getElementById('audio_codec').value, + document.getElementById('video_bitrate').value, + document.getElementById('audio_bitrate').value, + document.getElementById('audio_voice').value, + ); - this.pc.setRemoteDescription(new RTCSessionDescription(answer)); + this.pc.setRemoteDescription(answer); if (this.queuedCandidates.length !== 0) { this.sendLocalCandidates(this.queuedCandidates); diff --git a/internal/core/webrtc_read_index.html b/internal/core/webrtc_read_index.html index a08dc1c6495..46672883dbb 100644 --- a/internal/core/webrtc_read_index.html +++ b/internal/core/webrtc_read_index.html @@ -64,6 +64,48 @@ return ret; }; +const enableStereoOpus = (section) => { + let opusPayloadFormat = ''; + let lines = section.split('\r\n'); + + for (let i = 0; i < lines.length; i++) { + if (lines[i].startsWith('a=rtpmap:') && lines[i].toLowerCase().includes('opus/')) { + opusPayloadFormat = lines[i].slice('a=rtpmap:'.length).split(' ')[0]; + break; + } + } + + if (opusPayloadFormat === '') { + return section; + } + + for (let i = 0; i < lines.length; i++) { + if (lines[i].startsWith('a=fmtp:' + opusPayloadFormat + ' ')) { + if (!lines[i].includes('stereo')) { + lines[i] += ';stereo=1'; + } + if (!lines[i].includes('sprop-stereo')) { + lines[i] += ';sprop-stereo=1'; + } + } + } + + return lines.join('\r\n'); +}; + +const editOffer = (offer) => { + const sections = offer.sdp.split('m='); + + for (let i = 0; i < sections.length; i++) { + const section = sections[i]; + if (section.startsWith('audio')) { + sections[i] = enableStereoOpus(section); + } + } + + offer.sdp = sections.join('m='); +}; + const generateSdpFragment = (offerData, candidates) => { const candidatesByMedia = {}; for (const candidate of candidates) { @@ -139,6 +181,8 @@ } onLocalOffer(offer) { + editOffer(offer); + this.offerData = parseOffer(offer.sdp); this.pc.setLocalDescription(offer); @@ -186,7 +230,7 @@ return; } - this.pc.setRemoteDescription(new RTCSessionDescription(answer)); + this.pc.setRemoteDescription(answer); if (this.queuedCandidates.length !== 0) { this.sendLocalCandidates(this.queuedCandidates); From 3b4cac5af79dad4e40731c93237560b82229a51d Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 6 Oct 2023 23:00:15 +0200 Subject: [PATCH 009/170] webrtc: disallow publishing screen on devices that don't support it (#2066) (#2471) --- internal/core/webrtc_publish_index.html | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/core/webrtc_publish_index.html b/internal/core/webrtc_publish_index.html index cce2f48a796..09b55b270c1 100644 --- a/internal/core/webrtc_publish_index.html +++ b/internal/core/webrtc_publish_index.html @@ -523,15 +523,18 @@ } } - // add screen - const opt = document.createElement('option'); - opt.value = "screen"; - opt.text = "screen"; - document.getElementById('video_device').appendChild(opt); - - // set default - document.getElementById('video_device').value = document.getElementById('video_device').children[1].value; - if (document.getElementById('audio_device').children.length > 1) { + if (navigator.mediaDevices.getDisplayMedia !== undefined) { + const opt = document.createElement('option'); + opt.value = "screen"; + opt.text = "screen"; + document.getElementById('video_device').appendChild(opt); + } + + if (document.getElementById('video_device').children.length !== 0) { + document.getElementById('video_device').value = document.getElementById('video_device').children[1].value; + } + + if (document.getElementById('audio_device').children.length !== 0) { document.getElementById('audio_device').value = document.getElementById('audio_device').children[1].value; } }); From 64f41855376a774a97d106fc31518b4f04bb5fb3 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 6 Oct 2023 23:31:36 +0200 Subject: [PATCH 010/170] webrtc: optimize publish page for mobile devices (#2066) (#2472) --- internal/core/webrtc_publish_index.html | 81 +++++++++++++++++-------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/internal/core/webrtc_publish_index.html b/internal/core/webrtc_publish_index.html index 09b55b270c1..19afe3a9771 100644 --- a/internal/core/webrtc_publish_index.html +++ b/internal/core/webrtc_publish_index.html @@ -8,7 +8,6 @@ margin: 0; padding: 0; height: 100%; - overflow: hidden; } body { display: flex; @@ -21,11 +20,12 @@ min-height: 0; } #controls { - height: 200px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; + min-height: 200px; + padding: 10px; } #device { flex-direction: column; @@ -35,6 +35,14 @@ display: flex; gap: 20px; justify-content: center; + flex-wrap: wrap; +} +#device > div > div { + display: flex; + gap: 20px; +} +#error-message { + text-align: center; } select { width: 200px; @@ -50,31 +58,43 @@