openwebrtc-ios-sdk icon indicating copy to clipboard operation
openwebrtc-ios-sdk copied to clipboard

Error : Cannot send video as audio

Open ShGup opened this issue 10 years ago • 5 comments

Hi, Using the SDK, We are trying to publish both Audio and Video. nativeHandler.startGetCaptureSourcesForAudio(true, video: true)

However, when I try to handle the answer received, following error is encountered:

0:06:19.694238000 [334m 837[00m 0x1036df070 [31;01mERROR [00m [00m owrtransportagent owr_transport_agent.c:703:handle_new_send_source:[00m Cannot send video as audio

0:07:14.218096000 [334m 837[00m 0x1036df070 [31;01mERROR [00m [00m owrtransportagent owr_transport_agent.c:703:handle_new_send_source:[00m Cannot send audio as video

(If I only try to Set Capture Source as Audio, things work fine. )

I tied matching the answer SDP from your native-demo project and my project and they both look similar. The only difference was the order of mediaDescriptions was reversed. In my answer, audio was the first media and yours video was the first media. (I dont think that should matter though). Let me know if you need my sample answer sdp

ShGup avatar Aug 29 '15 18:08 ShGup

Alright.. Looks like I found the issue. It is indeed the order of media in the answer received.

handleAnswerReceived() function: for (item = media_sessions; item; item = item->next) { media_session = OWR_MEDIA_SESSION(item->data); ...

now the media_sessions are in the order of "Video" and "Audio". My sdp answer generated from server was in the order of "Audio" and "Video"

So the "audio" payload was sent with "Video" media session and hence creating the problem.

(Just to quickly test, i reversed the media_sessions list and tried. It worked)

A simple fix would be in this line:

NSDictionary *mediaDescription = sdp[@"mediaDescriptions"][i++]; mtype = [mediaDescription[@"type"] UTF8String];

instead of using variable i, find that media description object in answer whose mtype = media_session source type.

ShGup avatar Aug 30 '15 19:08 ShGup

You're welcome to make a patch and pull request for this fix. Perhaps take the first video session and set the video source on it, and the first audio session and set the audio source on it. Or something more flexible if you're interested in implementing it.

superdump avatar Aug 31 '15 07:08 superdump

Sure thing :) I'll be glad to fix this.

ShGup avatar Sep 01 '15 19:09 ShGup

Nice @ShGup, looking forward to it!

stefanalund avatar Sep 01 '15 20:09 stefanalund

@ShGup we would really appreciate a PR for your fix. Let us know if you are unable to do it and we will add it to our TODO list. Thanks in advance.

stefanalund avatar Oct 25 '15 10:10 stefanalund