Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

p2p sample code breaks with latest M104: preferCodecs causes setLocal/RemoteDescription error: Failed to parse: "". Reason: Failed to parse audio codecs correctly. #292

Open
chenzx opened this issue Jan 11, 2023 · 1 comment

Comments

@chenzx
Copy link

chenzx commented Jan 11, 2023

Due to networking limit, i cannot build OWT android sdk, so i use a prebuilt 3rd bundle: https://github.com/webrtc-sdk/android

I do not use the owt-server but write a simple nodejs version for test. (The server part should be irrelevant, since it only forwards signaling messages)

& Also due to only 1 android emulator there, i modified the p2p client sample code to let Activity contains 2 clients: one for publisher, the other consumer.

The key WebRTC signaling setup is:

  1. publisher call createOffer to get SDP offer
  2. publisher call preferCodecs to modify the SDP <--- HERE
  3. publisher call setLocalDescription and then send SDP to consumer via signaling server
  4. consumer receives SDP and call setRemoteDescription

The preferCodecs is very problematic, since it add 2 codecs for audio & video: ~/repo/open-webrtc-toolkit/owt-client-android/src/sdk/base/src/main/java/owt/base/PeerConnectionChannel.java

    private SessionDescription preferCodecs(SessionDescription sdp, boolean video) {
        LinkedHashSet<String> preferredCodecs = new LinkedHashSet<>();
        if (video) {
            for (VideoCodec codec : this.videoCodecs) {
                preferredCodecs.add(codec.name);
            }
            preferredCodecs.add("red");
            preferredCodecs.add("ulpfec");
        } else {
            for (AudioCodec codec : audioCodecs) {
                preferredCodecs.add(codec.name);
            }
            preferredCodecs.add("CN");
            preferredCodecs.add("telephone-event");
        }
        return preferCodec(sdp, preferredCodecs, video);
    }

Note: I enable the WebRTC logging by Logging.enableLogToDebugOutput(Logging.Severity.LS_VERBOSE);, & AV1 codec needs added to ~/repo/open-webrtc-toolkit/owt-client-android/src/sdk/base/src/main/java/owt/base/MediaCodecs.java

The error log:

...
W/webrtc_sdp.cc: (line 3581): Ignore rtpmap line that did not appear in the <fmt> of the m-line: a=rtpmap:63 red/48000/2
E/webrtc_sdp.cc: (line 414): Failed to parse: "". Reason: Failed to parse audio codecs correctly.

So i remove the preferCodecs logic: ~/repo/open-webrtc-toolkit/owt-client-android/src/sdk/base/src/main/java/owt/base/PeerConnectionChannel.java

    //SdpObserver
    @Override
    public void onCreateSuccess(final SessionDescription sessionDescription) {
        localSdp = sessionDescription;

//        if (audioCodecs != null) {
//            localSdp = preferCodecs(localSdp, false);
//        }
//
//        if (videoCodecs != null) {
//            localSdp = preferCodecs(localSdp, true);
//        }
...

Now p2p connection is successful.

@chenzx
Copy link
Author

chenzx commented Jan 11, 2023

PS: I'm try using OWT android lib for P2P mode (vs SFU) remote desktop streaming, not for chat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant