3

I am creating a voice only (no video) chat application. I have created my own node.js/socket.io based server for signaling.

For WebRTC, I am using the following pod: https://cocoapods.org/pods/WebRTC

I have been successful in creating peer connection, adding local stream, setting local/remote sdp, and send/receive ice candidates. The "didAddStream" delegate method is also called successfully having audio tracks but I am stuck here. I don't know what should I do with the audio track. What should be the next step? How would I send/receive audio on both sides?

Also, if I integrate CallKit, what changes do I need to make.

halfer
  • 19,824
  • 17
  • 99
  • 186
Aftab Baig
  • 279
  • 5
  • 16

1 Answers1

3

I got stuck on this one too. You have to retain the RTCMediaStream object in order for the audio to play. You don't need to do anything with the RTCAudioTrack, it will play automatically. I simply assign it to property so it can get retained. See my example here: https://github.com/redfearnk/WebRTCVideoChat/blob/master/WebRTCVideoChat/WebRTCClient.swift#L143

Kyle Redfearn
  • 2,172
  • 16
  • 34
  • 3
    Yes, that's what I found finally. You don't have to do anything, the audio will automatically start playing. I am planning to write a blog about WebRTC in iOS native apps (using swift) with a standalone Node.JS socket server integrated with CallKit. Thank you very much for your answer though. – Aftab Baig Sep 20 '17 at 20:52
  • Great idea! I'd love to see it – Kyle Redfearn Sep 20 '17 at 22:22
  • Loca RTCAudioTrack starts playing automatically to. Do you know how to turn off it locally? Because I hear myself. – WorieN Apr 20 '18 at 15:59
  • I am trying to implement VoIP with call recording. How difficult is that? How to implement server-side code and client-side(swift) code. Would be great help if you can share anything. – Sanket Pandya Oct 26 '18 at 13:19
  • please post the link to blog here @AftabBaig – Saif Oct 26 '18 at 13:34
  • @AftabBaig Do you have an example for this Audio Call? Please share with me. I am getting stuck on this. – Parth Patel Sep 05 '19 at 06:24
  • @ParthPatel sorry for the late reply. I am no more working on this project so it is not in my machine currently. I will send you the code in a day or 2 if that works. – Aftab Baig Sep 24 '19 at 13:04
  • @AftabBaig Thanks a lot for your help. – Parth Patel Sep 24 '19 at 18:16
  • @AftabBaig if it's possible, please share the code with me as well. Thanks. You can send it to my emai: eddie.marvin116@gmail.com – Eddie Mar 15 '23 at 11:38