Added support of local audio streams for more than one media player in Chrome 27.0.1436.1 canary

1,061 views
Skip to first unread message

Vikas Marwaha

unread,
Mar 11, 2013, 3:35:23 PM3/11/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
Hi,

Rendering of a local media stream in a <video> or <audio> element has been supported for a while now in Chrome. However, the 'muted' attribute of the media element has so far been enabled automatically to ensure that users are not surprised by hearing the captured audio being played back on the local machine. Local audio rendering can be useful e.g when testing the microphone and speaker configuration and should be done with a headset since no echo control is enabled. 

Starting with today's Chrome Canary ( version 27.0.1436.1 ), we are removing the existing auto-mute functionality to comply with the W3C standard better. Avoiding local audio feedback in these situations is easy. Simply set the muted attribute either in the tag itself or from JS. e.g <video autoplay="true" muted="true"/>.

The latest version also supports multiple local renderers, i.e., one local media stream can be used by many audio/video elements all rendering the same local stream where the volume and mute state of each stream can be set individually.


/Vikas

Shaun

unread,
Mar 27, 2013, 11:10:00 AM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
As of Canary 27.0.1454.0, which I got today setting muted no longer works. We can verify this across multiple machines. Should we file this as an issue?

Dennis

unread,
Mar 27, 2013, 11:31:11 AM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
Hmm I've been just setting the media track enabled flag to false/true in order to mute/unmute.  

e.g. stream.getAudioTracks()[0].enabled = false;

Henrik Andreasson

unread,
Mar 27, 2013, 11:41:44 AM3/27/13
to discuss...@googlegroups.com
Tried 27.0.1454.1 (Official Build 190875canary on Windows and muting an audio/video tag which renders the local stream works for me.

James Mortensen

unread,
Mar 27, 2013, 11:51:57 AM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
Dennis,

Are you on Canary 27.0.1454.0?   Is that the local stream you're invoking enabled=false on or the remote stream?  When I mute the local stream, the echo goes away, but the other party also stops receiving my audio, and when I set enabled = false on the remote stream, I stop hearing the remote party.

Shaun and I are on Mac OS.  Are you on Windows?

Thanks,
James

Dennis

unread,
Mar 27, 2013, 12:25:00 PM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
Yes, using latest canary.  You need to derive a new media stream from the localStream and use the parent stream for local rendering and the derived stream for the peer connection.  

element.src = webkitURL.createObjectURL(localstream); // render the local (parent) media stream
newLocalStream = new webkitMediaStream(localstream); // creates new derived media stream with the same tracks
pc1.addStream(newLocalStream);                       // send the remote peer the derived media stream

// this will mute local rendering of audio, but audio continues to be sent to peer 
localStream.getAudioTracks()[0].audioTrack.enabled = false; 

// stops sending audio to the peer (well technically I think its still sent, but they are just audio packets zeroed out or silence packets)
newLocalStream.getAudioTracks()[0].audioTrack.enabled = false; 


Henrik Andreasson

unread,
Mar 27, 2013, 12:52:08 PM3/27/13
to Dennis, discuss...@googlegroups.com, Justin Uberti
Dennis, it is not clear to me why you clone the local media stream if all you want to do is to be able to mute it locally. Why not simply mute the audio element instead?

James Mortensen

unread,
Mar 27, 2013, 12:56:22 PM3/27/13
to discuss...@googlegroups.com, Dennis, Justin Uberti
Henrik, 

We're actually using the <video> element for this. There is no <audio> element.  Can you perhaps show an example of what you mean?  I'm not 100% sure we're on the same page.

Thanks! :)
James

James Mortensen

unread,
Mar 27, 2013, 1:12:33 PM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
Hi Dennis,

When we try to clone the audio stream, we don't actually see an audioTrack property in the getAudioTracks array:

var lstream = jssip.session.getLocalStreams()[0]

newLocalStream
= new webkitMediaStream(lstream);

jssip
.session.rtcMediaHandler.peerConnection.addStream(newLocalStream);
   
Error: SyntaxError: DOM Exception 12

lStream.getAudioTracks()[0].audioTrack
>> this shows as undefined


It would be great if someone from Google could weigh in and let us know if we need to file a ticket for this issue.  Based on Vikas's description above, the "official" solution doesn't work.

Thank you,

James

Vikas

unread,
Mar 27, 2013, 1:24:29 PM3/27/13
to discuss-webrtc
Hi James,

I think Henrik mean't that you can mute locally using below code:-

<video id="vid1" autoplay="true" muted="true"></video>

We do that in the pc1 demo.

/Vikas

On Mar 27, 9:56 am, James Mortensen <james.morten...@a-cti.com> wrote:
> Henrik,
>
> We're actually using the <video> element for this. There is no <audio>
> element.  Can you perhaps show an example of what you mean?  I'm not 100%
> sure we're on the same page.
>
> Thanks! :)
> James
>
>
>
>
>
>
>
> On Wednesday, March 27, 2013 9:52:08 AM UTC-7, Henrik Andreassson wrote:
>
> > Dennis, it is not clear to me why you clone the local media stream if all
> > you want to do is to be able to mute it locally. Why not simply mute the
> > audio element instead?
>
> >>>> e.g. stream.getAudioTracks()[0].**enabled = false;
>
> >>>> On Wednesday, March 27, 2013 11:10:00 AM UTC-4, Shaun wrote:
>
> >>>>> As of Canary 27.0.1454.0, which I got today setting muted no longer
> >>>>> works. We can verify this across multiple machines. Should we file this as
> >>>>> an issue?
>
> >>>>> On Monday, March 11, 2013 12:35:23 PM UTC-7, vikas wrote:
>
> >>>>>> *Hi,*
> >>>>>> *
> >>>>>> *
> >>>>>> *Rendering of a local media stream in a <video> or <audio> element
> >>>>>> has been supported for a while now in Chrome. However, the 'muted'
> >>>>>> attribute of the media element has so far been enabled automatically to
> >>>>>> ensure that users are not surprised by hearing the captured audio being
> >>>>>> played back on the local machine. Local audio rendering can be useful e.g
> >>>>>> when testing the microphone and speaker configuration and should be done
> >>>>>> with a headset since no echo control is enabled. *
> >>>>>> *
> >>>>>> *
> >>>>>> *Starting with today's Chrome Canary (** version 27.0.1436.1 **), we
> >>>>>> are removing the existing auto-mute functionality to comply with the W3C
> >>>>>> standard better. Avoiding local audio feedback in these situations is easy.
> >>>>>> Simply set the muted attribute either in the tag itself or from JS. e.g
> >>>>>> <video autoplay="true" muted="true"/>.*
> >>>>>> *
> >>>>>> *
> >>>>>> *The latest version also supports multiple local renderers, i.e.,
> >>>>>> one local media stream can be used by many audio/video elements all
> >>>>>> rendering the same local stream where the volume and mute state of each
> >>>>>> stream can be set individually.*
> >>>>>> *
> >>>>>> *
> >>>>>> *You can refer tohttps://webrtc.googlecode.com/svn/trunk/samples/js/
> >>>>>> demos/html/local-audio-rendering.html as an example.*
> >>>>>> *
> >>>>>> *
> >>>>>> */Vikas*

Dennis

unread,
Mar 27, 2013, 1:25:56 PM3/27/13
to discuss...@googlegroups.com, Justin Uberti, Henrik Andreasson
my bad, remove the 'audioTrack', so it should look like this:


// this will mute local rendering of audio, but audio continues to be sent to peer 
localStream.getAudioTracks()[0].enabled = false; 

// stops sending audio to the peer (well technically I think its still sent, but they are just audio packets zeroed out or silence packets)
newLocalStream.getAudioTracks()[0].enabled = false; 

Vikas

unread,
Mar 27, 2013, 1:39:14 PM3/27/13
to discuss-webrtc
Hi,

I am not sure why you are creating a cloned mediaStream. The behavior
you see looks expected. If you mute an audioTrack then i think silence
packets would be sent. As i understand you want to get rid of the
local echo. For that using muted property in the video tag is a good
option. The muted property seems to be working fine for me on the
latest canary on Mac. If it doesn't work for you, feel free to file a
bug.

/Vikas
> >>>>> *Hi,*
> >>>>> *
> >>>>> *
> >>>>> *Rendering of a local media stream in a <video> or <audio> element
> >>>>> has been supported for a while now in Chrome. However, the 'muted'
> >>>>> attribute of the media element has so far been enabled automatically to
> >>>>> ensure that users are not surprised by hearing the captured audio being
> >>>>> played back on the local machine. Local audio rendering can be useful e.g
> >>>>> when testing the microphone and speaker configuration and should be done
> >>>>> with a headset since no echo control is enabled. *
> >>>>> *
> >>>>> *
> >>>>> *Starting with today's Chrome Canary (** version 27.0.1436.1 **), we
> >>>>> are removing the existing auto-mute functionality to comply with the W3C
> >>>>> standard better. Avoiding local audio feedback in these situations is easy.
> >>>>> Simply set the muted attribute either in the tag itself or from JS. e.g
> >>>>> <video autoplay="true" muted="true"/>.*
> >>>>> *
> >>>>> *
> >>>>> *The latest version also supports multiple local renderers, i.e., one
> >>>>> local media stream can be used by many audio/video elements all rendering
> >>>>> the same local stream where the volume and mute state of each stream can be
> >>>>> set individually.*
> >>>>> *
> >>>>> *
> >>>>> *You can refer to
> >>>>>https://webrtc.googlecode.com/svn/trunk/samples/js/demos/html/local-a...as

Dennis

unread,
Mar 27, 2013, 1:57:42 PM3/27/13
to discuss...@googlegroups.com
cloned media stream could be a subset of localStream..  localStream could have both audio and video, where cloned media stream could just be audio-only.

James Mortensen

unread,
Mar 27, 2013, 3:02:30 PM3/27/13
to discuss...@googlegroups.com
Hi Vikas,

We already have in place the fix you suggested from your original message in this thread.  We have both autoplay="true" and muted="true"

The problem is that this was working great in the previous version of Canary... meaning yesterday it worked.  Today's update broke this functionality.  

To be clear, I understand the atomute was shut off, and we did fix this as you suggested.  This is a regression.

Would the commit log show anything that the team may have done to break this since yesterday's Canary?

Let me know if you have any other questions or need more clarification.

Thanks again! :)

James

Vikas

unread,
Mar 27, 2013, 3:16:16 PM3/27/13
to discuss-webrtc
Hi James,

I tested with pc1.html ( http://webrtc.googlecode.com/svn/trunk/samples/js/demos/html/pc1.html
) on Version 27.0.1454.1 canary on Win7. Just click start, you should
hear no local audio as its muted. Then right click on the local video
element and select Unmute you should start hearing audio back.

Are you also on the same version of canary, what platform you tested
on?

/Vikas



On Mar 27, 12:02 pm, James Mortensen <james.morten...@a-cti.com>
wrote:

Henrik Andreasson

unread,
Mar 27, 2013, 4:03:53 PM3/27/13
to discuss...@googlegroups.com
James: nothing has been modified in Chrome recently that would affect muting of local audio streams on a media element. The demo that Vikas mentions above works for me as well using the latest Canary on Windows 7.


--

---
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.
For more options, visit https://groups.google.com/groups/opt_out.



James Mortensen

unread,
Mar 27, 2013, 4:36:28 PM3/27/13
to discuss...@googlegroups.com
Hi Vikas,

Platform: Mac OS X 10.8
Browser: Chrome Canary Version 27.0.1454.0 canary
Context: Running this in a packaged app.

However, if I visit your test page in Canary http://webrtc.googlecode.com/svn/trunk/samples/js/demos/html/pc1.html, as soon as I click Start, I hear the ECHO.  I right click the local video and "unmute" is one option, but "mute" does not appear.  If I "unmute", nothing changes, and still there is no "mute" option when right clicking.

This appears to work correctly in Chrome Stable.  When I load http://webrtc.googlecode.com/svn/trunk/samples/js/demos/html/pc1.html in Stable and click "Start' I hear no echo.  If I right click, I see the option to unmute. When I unmute, I hear the echo as expected.

When I right click again in Stable, the mute option is available, and I can mute the local audio once again.  

Vikas, if you're testing on Windows 7, then it sounds like this regression only affects Mac OS.

James

Vikas Marwaha

unread,
Mar 27, 2013, 5:39:54 PM3/27/13
to discuss...@googlegroups.com
Hi James,

Thanks for the feedback. It looks like a regression on Mac. I can recreate it as well. Filed a bug. 

/Vikas


--
Reply all
Reply to author
Forward
0 new messages