Jump to content
  • 0

Adding Audio tracks to already broadcast Stream


Alex A
 Share

Question

Hi,

So i have a stream object (created from a canvas) which i am broadcasting - and i want to add audiotracks to it, while it is broadcasting.

It seems to do nothing by adding audiotracks to the stream variable once  broadcast has started, so is there a way to get access to the 'stream' object of a broadcast to add audio tracks from other streams ? while it is already broadcasting ?

I tried 'getstreaminfo' and it doesn't return anything useful... what is 'gotStream' ? but it expects a stream not a streamid ... so what do i use to gain access to the stream so i can execute getAudioTracks and addTrack methods ?

thanks!

Alex.
Link to comment
Share on other sites

  • Answers 2
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

2 answers to this question

Recommended Posts

  • 0
below is what i am trying to do - i want to ADD the audio of any incoming streams to one single main stream (box0).

For example below excerpt i want stream "box0" (which is what i am broadcasting from this client) to contain it's original audio track AND a new audio track which belongs to an incoming stream.

The below code does NOT work - no error is thrown, however the remote stream does not end up containing both tracks, merged or otherwise.


else if (info == "newStreamAvailable") {
if (obj.streamId !="box0") {

var newCombinedAudioStream=webRTCAdaptor.mixAudioStreams(myVideoStream, obj.stream, "box0");
webRTCAdaptor.updateLocalAudioStream(newCombinedAudioStream, "box0");

}

}


So the question has TWO parts;

First; How can I update the streaming object of a live stream currently being broadcast (is it updateLocalAudioStream or updateAudioStream !?)

Second; How can I add multiple tracks to this stream object while it is being broadcast so that the remote viewer plays all the tracks ?

Any ideas ?

Thanks!

Link to comment
Share on other sites

  • 0

Hi Alex,

Have a good day.

You can check our WebRTC Stream publish process -> https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/js/webrtc_adaptor.js#L233 You can find how can AMS handle Audio processes.

For example:
if(audioTrack.length > 0 ){
var mixedStream = this.mixAudioStreams(stream, audioStream, streamId);
this.updateAudioTrack(mixedStream,streamId,null);
}
else{
this.updateAudioTrack(audioStream,streamId,null);
}

Also please check our https://github.com/ant-media/StreamApp/blob/master/src/main/webapp/merge_streams.html page.

I hope, I could help you.

Best Regards,
Selim
Link to comment
Share on other sites

 Share

×
×
  • Create New...