-1

I have started with https://doc-kurento.readthedocs.io/en/6.13.2/tutorials/java/tutorial-groupcall.html

Currently, in UI i give user option to decide whether they want only audio or audio+video call. Based on the selection, the constraints for getUserMedia() are passed and this works fine if all the user select same kind of call type.

But, say user 1 select only audio and user 2 selects audio+video, then user 1 receives audio from user 2 while on user 2 end, the html video element keeps loading.

Findings: I believe this is SDP offer issue, since offer from user 1 and respective SDP answer from user2 does not contain m=video since user 1 has opted only for audio call (this works fine)

But, offer from user 2 and respective SDP answer from user 1 does contain m=video.

So, what i want is, user 2 receive audio from 1, even though user 2 selected video call.

Rohit Patel
  • 148
  • 1
  • 8
  • Can you check if the media stream of User 1 on User 2's browser to see if the stream has video tracks? the stream shouldn't have video tracks, it should only have audio tracks. – vijay krishna Jun 02 '20 at 17:53
  • To my surprise, when i check tracks , using getRemoteStream().getTracks(), i am getting both video and audio tracks even for audio call. Below is the console output: `stream.getTracks()` – Rohit Patel Jun 05 '20 at 03:44
  • Below is the console output: `stream.getTracks()` `0: MediaStreamTrackcontentHint: ""enabled: trueid: "4782a52e-159c-4300-9c27-ddfa20343797"kind: "audio"label: "Default - Microphone (Realtek High Definition Audio)"muted: false` `1: MediaStreamTrack enabled: true id: "22690dcf-28a0-4e98-83ee-3bcc45f76aad" kind: "video" label: "HP Truevision HD (064e:930b)"muted: false' – Rohit Patel Jun 05 '20 at 03:51
  • reason why even in only audio call users were receiving both AV tracks, was that by default, `kurentoUtils` was adding audio and video as true. So, while creating peerConnection to receive remote data, no constraints were passed in code. Now, i have added required constraints. So, user who joined as AV, receives both tracks from remote and user who joined as only audio, get only audio. – Rohit Patel Jun 06 '20 at 03:19

1 Answers1

0

Your stream has both Audio and Video tracks. for some reason, html video element doesn't play audio in this case because it's not getting video and just audio (because the other guy disabled the video). There's two ways you fix it.

  1. Fixing by manipulating mediaStream. You can create a mediaStream that has only audio tracks when the user has disabled the video.

    const audioStream = new MediaStream(); mediaStream.addTrack(originalStream.getAudioTracks()[0]); /* display audioStream in video element*/

  2. Fixing by generating sdp to right mediaConstraints You can generate the sdp by passing mediaConstraints as {audio:true,video:false} when creating WebRtcPeer using kurentoUtils. That'll just get you the audio track.

vijay krishna
  • 514
  • 4
  • 14
  • does this means that the receiver end will need to know what kind of call the remote user has joined and accordingly decide whether above mentioned fix need to applied. Is there a way (SDP/stream/track attributes) from which i can find it out, or need to handle in some sort of messages over socket. Also, I am not sure if i understand the second fix and renegotiating stuff, any reference or docs will help. Thanks – Rohit Patel Jun 06 '20 at 03:24
  • I've updated my answer. Sorry, I was thinking about video disable scenario. You can ignore the renegotiating part for your requirement. And for 1st method, You're better off handling it through socket. Keep track of publisher mediaConstrains and use the same mediaConstraints on subscriber's end when creating WebRtcPeer. – vijay krishna Jun 06 '20 at 16:45
  • finally figured it out, as per your suggestion @vijay krishna Thanks – Rohit Patel Jun 15 '20 at 13:22
  • `sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.AUDIO);` `if(sender.isVideoCall()){` `sender.getOutgoingWebRtcPeer().connect(incoming, MediaType.VIDEO);` `}` Keeping track of call type using message over ws. – Rohit Patel Jun 15 '20 at 13:27