question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

peerConnectionAddTransceiver should allow config direction with kind option

See original GitHub issue

In Js, it allow to create receive only audio or video transceiver like:

peer.addTransceiver('audio', {
     direction: 'recvonly'
});

But in react-native-webrtc it force to create new transceiver without init paramaters incase kind is set

https://github.com/react-native-webrtc/react-native-webrtc/blob/f78f3e6d10a234ba33e50c99c5df7f6c0480db0a/ios/RCTWebRTC/WebRTCModule%2BRTCPeerConnection.m#L480-L495

Therefore I think react-native-webrtc should support the beheviour. It is simply by only create a transceiverInit variable like:

        if (kind) {
            if ([kind  isEqual: @"audio"]) {
                type = RTCRtpMediaTypeAudio;
            } else if ([kind  isEqual: @"video"]) {
                type = RTCRtpMediaTypeVideo;
            }
            
            NSDictionary *initOptions = [options objectForKey:@"init"];
            RTCRtpTransceiverInit *transceiverInit = [RTCRtpTransceiverInit new];
           
            if (initOptions) {
                NSString *dirrection = [initOptions objectForKey:@"direction"];
                if ([dirrection isEqual: @"sendrecv"]) {
                    [transceiverInit setDirection:RTCRtpTransceiverDirectionSendRecv];
                } else if ([dirrection isEqual: @"sendonly"]) {
                     [transceiverInit setDirection:RTCRtpTransceiverDirectionSendOnly];
                } else if ([dirrection isEqual: @"recvonly"]) {
                     [transceiverInit setDirection:RTCRtpTransceiverDirectionRecvOnly];
                } else if ([dirrection isEqual: @"inactive"]) {
                     [transceiverInit setDirection:RTCRtpTransceiverDirectionInactive];
                }
            }
            
            transceiver = [peerConnection addTransceiverOfType:type init:transceiverInit];
        } else if (trackId) {

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
saghulcommented, Dec 11, 2022

Thanks folks! ❤️

0reactions
8BallBomBomcommented, Dec 12, 2022

@giangndm-bluesea Thanks for the report. This issue has been resolved with the next beta release going out soon 👍🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exploring RTCRtpTransceiver. - Advancing WebRTC
Transceivers more accurately reflect the SDP-rooted network behaviors of an RTCPeerConnection. E.g. addTransceiver() (or addTrack ) now creates ...
Read more >
addTransceiver woes · Issue #1662 · w3c/webrtc-pc - GitHub
addTransceiver () with kind should set the direction to recvonly. ... says its null initially and that changes only by setting a description....
Read more >
Webrtc with transceivers - nterreri | Blog
A transceiver is a permanent pairing of a receiver and a sender. Receivers and senders are a plain JS abstraction over the underlying...
Read more >
AddStream, AddTrack & AddTranceiver - WebRTC Course
Check out what is the best option to check audio levels of incoming audio ... Philipp: Now let's look at AddTrack versus AddTransceiver, ......
Read more >
PSA: Spec-compliant Simulcast using addTransceiver API
Users can now call addTransceiver on the peer connection and specify multiple send ... Layers can be paused by setting the active attribute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found