# Add audio track to existing stream/connection

**URL:** <https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342>\
**Category:** General\
**Created:** [November 1, 2019, 11:50pm UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342 "2019-11-01T23:50:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jam985](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jam985](https://react-native-webrtc.discourse.group/u/jam985)\
**Post date:** [November 1, 2019, 11:50pm UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/1 "2019-11-01T23:50:08Z")

</div>

Hi all,

I am working on a mobile app that uses React Native WebRTC (this particular issue is focused on iOS). There is a use case in the app where, while a WebRTC session is in progress, I need to temporarily take the microphone input away from WebRTC for another feature. Currently, when I go back to the WebRTC session after doing this, audio from the microphone is no longer heard on the other end of the connection. This makes sense, as the audio track was taken away. I’d like to readd the microphone without interrupting the rest of the connection (receiving audio and video, sending video). Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)\
**Post date:** [November 2, 2019, 9:29am UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/2 "2019-11-02T09:29:45Z")

</div>

I think removing the track and create ing a new offer with offerToReceiveAudio set to true should work.

Then when you want the audio back, add the track again, and renegotiate.

---

<div class="post-metadata">

**Author:** ![jam985](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jam985](https://react-native-webrtc.discourse.group/u/jam985)\
**Post date:** [November 4, 2019, 5:54pm UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/3 "2019-11-04T17:54:26Z")

</div>

Thanks for the response, @sagul! Would there be anyway to readd the audio track without a full renegotiation? Was hoping to not interrupt the rest of the WebRTC connection.

---

<div class="post-metadata">

**Author:** ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)\
**Post date:** [November 5, 2019, 9:45am UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/4 "2019-11-05T09:45:23Z")

</div>

I don’t think so. Doing an O/A cycle shouldn’t disrupt your existing WebRTC connection, as it’s not re-established.

---

<div class="post-metadata">

**Author:** ![baconcheese113](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/baconcheese113/32/123_2.png) [@baconcheese113](https://react-native-webrtc.discourse.group/u/baconcheese113)\
**Post date:** [November 16, 2019, 10:28pm UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/5 "2019-11-16T22:28:13Z")

</div>

On that point, from my understanding so far… the latest `addtracks` functionality isn’t supported. [https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addTrack)

Instead still using the `addstream` functionality [https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream](https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream)

Can you speak at all about plans to support `MediaStreamTrack` or something similar that doesn’t require re-negotiation? I’d love to switch over the example project that I posted about to using tracks since `addstream` is deprecated on web.

Sorry if I’m very misinformed about what is/isn’t supported already

---

<div class="post-metadata">

**Author:** ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)\
**Post date:** [November 18, 2019, 2:13pm UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/6 "2019-11-18T14:13:15Z")

</div>

We will most likely skip the track APIs and go directly to transceivers. No ETA for that though.

---

<div class="post-metadata">

**Author:** ![benpeke](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/benpeke/32/109_2.png) [@benpeke](https://react-native-webrtc.discourse.group/u/benpeke)\
**Post date:** [November 19, 2019, 12:49am UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/7 "2019-11-19T00:49:33Z")

</div>

There is an API [replaceTrack](https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpSender/replaceTrack) but I could not find it in RNWebRTC, is this something that could be added? It sounds like this would solve this issue.

---

<div class="post-metadata">

**Author:** ![saghul](https://yyz2.discourse-cdn.com/free1/user_avatar/react-native-webrtc.discourse.group/saghul/32/4_2.png) [@saghul](https://react-native-webrtc.discourse.group/u/saghul)\
**Post date:** [November 19, 2019, 8:13am UTC](https://react-native-webrtc.discourse.group/t/add-audio-track-to-existing-stream-connection/342/8 "2019-11-19T08:13:59Z")

</div>

That function is part of the sensers API which is a prerequisite for transceivers. So yeah, we should be able to have it. When? I don’t know.
