awslabs / amazon-kinesis-video-streams-webrtc-sdk-c

Amazon Kinesis Video Streams Webrtc SDK is for developers to install and customize realtime communication between devices and enable secure streaming of video, audio to Kinesis Video Streams.
https://awslabs.github.io/amazon-kinesis-video-streams-webrtc-sdk-c/group__PublicMemberFunctions.html
Apache License 2.0
1.01k stars 304 forks source link

[BUG] Can not show video in firefox #817

Closed huyhoangk50 closed 3 years ago

huyhoangk50 commented 3 years ago

Describe the bug In PeerConnection.c, in function addTransceiver we set

RTC_RTP_TRANSCEIVER_DIRECTION direction = RTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV;

That means the PeerConnection requires sending and receiving the audio/video track. But if the it's peer does not send any stream, in firefox it will show the error.

Answer tried to set recv when offer did not set send

Should we add the parameter to the variable direction in the function addTransceiver instead of fixing it.

Desktop (please complete the following information):

hassanctech commented 3 years ago

Can you please describe your setup for when you hit this issue. While the direction parameter is initialized to RTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV for the local transceiver at the time we build the local description (which is what's used to build the answer) we adjust the direction according to the offer, here: https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c/blob/master/src/source/PeerConnection/SessionDescription.c#L464-L475

Are you using the master sample as is or have you made any modifications?

huyhoangk50 commented 3 years ago

@hassanctech actually I am trying to encode video to vp8 format and send it through webrtc. It's kind of complex to reproduce here. Also I did not complete it. Let me standardize it and send back to you.

Moreover for the firefox, I cannot show h264 video on this too. To reproduce that.

hassanctech commented 3 years ago

Curious if this is because of a change recently introduced in Firefox, do you have Firefox 80.0 or newer? There's a bug for this. Can you confirm that you hit the same issue with Firefox 79.0?

huyhoangk50 commented 3 years ago

I use Firefox 80.0, too. So it is the same bug.

disa6302 commented 3 years ago

@huyhoangk50 ,

Can you try with an older Firefox version and see if you still see the issue?

We are aware there is a problem with Firefox version >=80.0

huyhoangk50 commented 3 years ago

@disa6302 It seems do not work in firefox 79.0.

I did not see the official release for firefox 79.0 for ubutu 18.0.1 in apt release list. So, the way I installed the version 79.0 is: downloading from https://ftp.mozilla.org/pub/firefox/releases/79.0/linux-x86_64/en-US/. Bellow is the error code generated when I did the same process.

[2020-09-25T03:42:31.283Z] [INFO] [VIEWER] Received SDP answer
[2020-09-25T03:42:31.283Z] [ERROR] InvalidAccessError: Answer and offer have different media types at m-line 0
[2020-09-25T03:42:31.284Z] [INFO] [VIEWER] Received ICE candidate
[2020-09-25T03:42:31.284Z] [INFO] [VIEWER] Received ICE candidate
[2020-09-25T03:42:31.284Z] [ERROR] InvalidStateError: No remoteDescription.
[2020-09-25T03:42:31.284Z] [ERROR] InvalidStateError: No remoteDescription.
[2020-09-25T03:42:31.321Z] [INFO] [VIEWER] Generated ICE candidate
[2020-09-25T03:42:31.321Z] [INFO] [VIEWER] Sending ICE candidate
[2020-09-25T03:42:31.373Z] [INFO] [VIEWER] Generated ICE candidate
[2020-09-25T03:42:31.373Z] [INFO] [VIEWER] Sending ICE candidate
[2020-09-25T03:42:31.490Z] [INFO] [VIEWER] Received ICE candidate
[2020-09-25T03:42:31.491Z] [ERROR] InvalidStateError: No remoteDescription.
[2020-09-25T03:42:31.554Z] [INFO] [VIEWER] Generated ICE candidate
huyhoangk50 commented 3 years ago

More over If I do not enable video/audio in the test page it will generate the error, which is the same as I mention in this bug report.

[2020-09-25T03:48:42.061Z] [INFO] [VIEWER] Received SDP answer
[2020-09-25T03:48:42.064Z] [ERROR] InvalidAccessError: Answer tried to set recv when offer did not set send

For my project, if I hard code RTC_RTP_TRANSCEIVER_DIRECTION direction = RTC_RTP_TRANSCEIVER_DIRECTION_SENDONLY in PeerConnection.c it will work. (in firefox 80.0, encoder=vp8, os ubuntu 18.04)

disa6302 commented 3 years ago

@huyhoangk50 ,

Firefox is strict with the transceiver direction. FYI, You need not hard code in PeerConnection.c.

You can add these two lines before this to set direction and pass it in:

RtcRtpTransceiverInit rtcRtpTransceiverInit;
rtcRtpTransceiverInit.direction = RTC_RTP_TRANSCEIVER_DIRECTION_SENDONLY;

and pass rtcRtpTransceiverInit in addTransceiver() like this:

CHK_STATUS(addTransceiver(pSampleStreamingSession->pPeerConnection, &audioTrack, &rtcRtpTransceiverInit, &pSampleStreamingSession->pAudioRtcRtpTransceiver));

You can do this for the respective video and audio transceivers.

huyhoangk50 commented 3 years ago

Yeah, I just temporary fixed that to see, if it would work.

hassanctech commented 3 years ago

@huyhoangk50 Latest master now has the fix for Firefox, please try that. But the behavior you're mentioning that it didn't work at all I cannot reproduce that, when I run the master sample I can run Chrome/Safari/ FF v79 and v80/v81 (with latest master) with no issue. Is there any custom modification that you've made? If you could please try again with latest master and let me know if you are still seeing this issue?

MushMal commented 3 years ago

Could you try the latest commit?

rajnada commented 3 years ago

KVSWEBRTC LIVE STREAMING IS NOT WORKING IN FIREFOX BROWSER

when i try to play video in firefox. I will get answer and then received "event" in which i got "stream: restricted" attribute, while same video works perfectly on google chrome and i also got media stream object

Logs of Mozila Firefox:-

this is a screenshot of Mozila Firefox log for a reference :- https://prnt.sc/112azpx

Logs of Google chrome:-

this is a screenshot of google chrome log for a reference :- https://prnt.sc/112ay7m

answer which i received :-

answer => {type: "answer", sdp: "v=0 ↵o=- 461485223 2 IN IP4 127.0.0.1 ↵s=- ↵t=0 0 …x/90000 ↵a=fmtp:118 apt=123 ↵a=rtcp-fb:123 nack ↵"}sdp: "v=0 ↵o=- 461485223 2 IN IP4 127.0.0.1 ↵s=- ↵t=0 0 ↵a=group:BUNDLE 0 1 ↵a=msid-semantic: WMS myKvsVideoStream ↵m=audio 9 UDP/TLS/RTP/SAVPF 0 ↵c=IN IP4 127.0.0.1 ↵a=msid:myKvsVideoStream myAudioTrack ↵a=ssrc:534900171 cname:u+sFyw1MPSrSqi6F ↵a=ssrc:534900171 msid:myKvsVideoStream myAudioTrack ↵a=ssrc:534900171 mslabel:myKvsVideoStream ↵a=ssrc:534900171 label:myAudioTrack ↵a=rtcp:9 IN IP4 0.0.0.0 ↵a=ice-ufrag:Mz3o ↵a=ice-pwd:QVRV2NtgRaAQvNahNU2OSQQy ↵a=ice-options:trickle ↵a=fingerprint:sha-256 FD:CA:06:7D:2C:6F:DF:9B:DB:2C:C8:DA:88:96:25:C8:6D:1F:B6:C4:FB:B2:5D:9E:35:34:A4:0F:F5:42:80:B5 ↵a=setup:active ↵a=mid:0 ↵a=sendrecv ↵a=rtcp-mux ↵a=rtcp-rsize ↵a=rtpmap:0 PCMU/8000 ↵a=rtcp-fb:0 nack ↵m=video 9 UDP/TLS/RTP/SAVPF 123 118 ↵c=IN IP4 127.0.0.1 ↵a=msid:myKvsVideoStream myVideoTrackRTX ↵a=ssrc-group:FID 2062660401 318622851 ↵a=ssrc:2062660401 cname:u+sFyw1MPSrSqi6F ↵a=ssrc:2062660401 msid:myKvsVideoStream myVideoTrack ↵a=ssrc:2062660401 mslabel:myKvsVideoStream ↵a=ssrc:2062660401 label:myVideoTrack ↵a=ssrc:318622851 cname:u+sFyw1MPSrSqi6F ↵a=ssrc:318622851 msid:myKvsVideoStream myVideoTrackRTX ↵a=ssrc:318622851 mslabel:myKvsVideoStreamRTX ↵a=ssrc:318622851 label:myVideoTrackRTX ↵a=rtcp:9 IN IP4 0.0.0.0 ↵a=ice-ufrag:Mz3o ↵a=ice-pwd:QVRV2NtgRaAQvNahNU2OSQQy ↵a=ice-options:trickle ↵a=fingerprint:sha-256 FD:CA:06:7D:2C:6F:DF:9B:DB:2C:C8:DA:88:96:25:C8:6D:1F:B6:C4:FB:B2:5D:9E:35:34:A4:0F:F5:42:80:B5 ↵a=setup:active ↵a=mid:1 ↵a=sendrecv ↵a=rtcp-mux ↵a=rtcp-rsize ↵a=rtpmap:123 H264/90000 ↵a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f ↵a=rtpmap:118 rtx/90000 ↵a=fmtp:118 apt=123 ↵a=rtcp-fb:123 nack ↵"type: "answer"proto: Object

Can anyone help me for this situation thank you in advance :)