Play sound in stereo on iOS

499 views
Skip to first unread message

Rob Crabtree

unread,
Feb 9, 2016, 3:15:12 PM2/9/16
to discuss-webrtc
I can't get stereo sound working on iOS. Is it supported, or is there something I need to do?

This article helped us get stereo sound working on our web client, but the same concept didn't help with the iOS client.


I tried modifying constraints as well as modifying the local sdp. Here's what I have on iOS.

private func initializeConstraints() -> RTCMediaConstraints {
    let mandatoryConstraints
= [
       
RTCPair(key: "OfferToReceiveAudio", value: "true"),
       
RTCPair(key: "OfferToReceiveVideo", value: "false"),
       
RTCPair(key: "echoCancellation", value: "false"),
       
RTCPair(key: "googEchoCancellation", value: "false")
   
]
    let optionalConstraints
= [
       
RTCPair(key: "internalSctpDataChannels", value: "true"),
       
RTCPair(key: "DtlsSrtpKeyAgreement", value: "true")
   
]
   
return RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: optionalConstraints)
}


func peerConnection
(peerConnection: RTCPeerConnection!, didCreateSessionDescription sdp: RTCSessionDescription!, error: NSError?) {
    LOGD
("created sdp")


    guard error
== nil else {
        LOGE
("error creating session description: \(error!)")
       
delegate.onError(self, description: "Error creating sdp")
       
return
   
}


    dispatch_async
(dispatch_get_main_queue()) {
        let replaceThis
= "fmtp:111 minptime=10; useinbandfec=1"
        let replaceWith
= "fmtp:111 minptime=10; useinbandfec=1; stereo=1; sprop-stereo=1"
        let sdpDescriptionWithStereo
= sdp.description.stringByReplacingOccurrencesOfString(replaceThis, withString: replaceWith)
        let sdpWithStereo
= RTCSessionDescription(type: sdp.type, sdp: sdpDescriptionWithStereo)
        peerConnection
.setLocalDescriptionWithDelegate(self, sessionDescription: sdpWithStereo)


       
self.delegate.onLocalSDP(self, type: sdp.type, sdp: sdpDescriptionWithStereo)
   
}
}


The sdp modification code is hacky, but it does modify the sdp as intended. However, sound is still not played in stereo on my headphones.

Any ideas on how to proceed?

Thanks

Henrik Andreasson

unread,
Feb 10, 2016, 3:54:23 AM2/10/16
to discuss...@googlegroups.com
If you are using the native WebRTC library on iOS, the audio layer currently does not support opening up the CoreAudio layer in stereo.
Same is true for the capture (microphone) side. Main reason is to save resources. 

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/f1c3789e-652f-4ff9-955d-90ce844d13b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

何知翰

unread,
Sep 24, 2017, 4:53:54 AM9/24/17
to discuss-webrtc
hi, Henrik Andreassson
Is there any way to mix both music and microphone sound to other peer in ios? thank you

在 2016年2月10日星期三 UTC+8下午4:54:23,Henrik Andreassson写道:

Henrik Andreasson

unread,
Sep 25, 2017, 6:15:14 AM9/25/17
to discuss-webrtc
Stereo audio is not supported on iOS today.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/9ec71fc9-11e8-4451-8246-6425ed095b4c%40googlegroups.com.

何知翰

unread,
Sep 26, 2017, 2:09:18 AM9/26/17
to discuss-webrtc
oh, God...
Is it possible to add a music track to peer, so we can let user sing with background music and share to others?

Thanks

在 2017年9月25日星期一 UTC+8下午6:15:14,Henrik Andreassson写道:

Henrik Andreasson

unread,
Sep 26, 2017, 5:42:21 AM9/26/17
to discuss-webrtc
All parts of WebRTC are designed for voice and not music.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/c4199ad4-68d0-43e8-bf30-8ccdae488e2a%40googlegroups.com.

何知翰

unread,
Sep 26, 2017, 11:41:50 PM9/26/17
to discuss-webrtc
OK, thank you for your replay, Henrik Andreassson
But I want to know is there any way to mix local audio file with the mic?
I want to try.

在 2017年9月26日星期二 UTC+8下午5:42:21,Henrik Andreassson写道:

Zachary Saraf

unread,
Apr 1, 2019, 10:03:11 AM4/1/19
to discuss-webrtc
Are there any plans to add in stereo functionality in the iOS framework in the near future?

Sourabh Madlur

unread,
Apr 1, 2019, 10:30:05 PM4/1/19
to discuss...@googlegroups.com
Hello saraf,

I did successfully establish peer connection and streaming also started on both peers. But I am not able to see stream on my ios device. Could you please help me out?

I am sorry I am asking question on wrong thread. Please help me.

Regards:
Sourabh

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages