Eyevinn / webrtc-player

WebRTC (recvonly) player
MIT License
87 stars 18 forks source link

Set WebRTC specific parameters #54

Closed zapf2000 closed 1 year ago

zapf2000 commented 1 year ago

Up to now, there is no option to set audio modes (mono/stereo and other Opus related parameters). Player always downmixes stereo streams to mono.

on WHIP side: a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 cbr=1;maxaveragebitrate=131072;minptime=10;sprop-stereo=1;stereo=1;useinbandfec=1

on WHEP side: a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 minptime=10;useinbandfec=1

No chance to set the custom parameters stereo=1 or sprop-stereo=1 on client side, so playback is always mono. Also created some audio file to verify. Audio Test.zip

birme commented 1 year ago

I am guessing that this option is needed when the client side is the one generating the SDP offer? If the server would generate the SDP offer (which may be an option that was prematurely removed from the WHEP spec in my opinion) I think you would not need to set the option.

birme commented 1 year ago

I am leaving to @marcusspangenberg to confirm that I have understood it correctly

zapf2000 commented 1 year ago

The problem persists on all chrome browsers. Firefox defaults to stereo mode. So chrome clients have to tell the server the options in SDP offer. That's how firefox log looks like: a=sendrecv a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level a=extmap:2/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level a=extmap:3 urn:ietf:params:rtp-hdrext:sdes:mid a=fmtp:109 maxplaybackrate=48000;stereo=1;useinbandfec=1 a=fmtp:101 0-15

birme commented 1 year ago

I understand. In client-side offer mode there is no way today to control it but could be implemented of course. My suggestion meanwhile is to use the server-side offer mode. That means that the server would generate the SDP offer and the client will adapt

zapf2000 commented 1 year ago

yes, i already adressed that issue to the server developers. only ovenmediaengine and ant media server has fixed this already. but both don't support av1 streaming yet and i currently work on low latency av1 broadcasting. https://github.com/AirenSoft/OvenMediaEngine/issues/203 old issue but still up to date on mediamtx, srs and other open source servers.

svensson00 commented 1 year ago

To accelerate the development/fix of this problem at this stage we would need funding. @zapf2000, would you be interested to contribute with funding? We would estimate the effort to a 2 week sprint.

zapf2000 commented 1 year ago

Why program anything new? There is already a solution. you just have to implement it in your code. See https://github.com/AirenSoft/OvenPlayer/blob/master/src/js/api/provider/html5/providers/WebRTCLoader.js lines 197-235 and lines 330-344. first a check is done if SDP offer contains Opus stereo, then a custom SDP answer is created that forces stereo mode. 75% of all users use Chrome or a Chromium fork, so this is a very common problem when broadcasting high quality via webrtc.

birme commented 1 year ago

I think you are missing the point re client side offering mode. Anyway I am happy to review a PR from you if you have an idea on what to do.