Open Bug 709883 Opened 13 years ago Updated 2 years ago

Pause/Mute media on incoming WebRTC call

Categories

(Core :: WebRTC: Audio/Video, defect)

defect

Tracking

()

backlog parking-lot

People

(Reporter: derf, Unassigned)

References

Details

A common feature of smartphone media players is to pause or mute when the phone receives an incoming call. This would be helpful for WebRTC as well (at least as a user-controllable option), though it may be a challenge to identify which <audio>/<video> tags correspond to something like traditional media playback, and which might actually be part of the call itself.
Blocks: webrtc
About audio, bug 795237 could be used to identify a usage category.
As an additional note, at least on PulseAudio, it makes more sense to tag the stream appropriately based on the type (media.role property) and let PulseAudio take care of this policy. Our current default is to request "video" and "music" streams to pause when we get a "phone" stream.

We recently added support for ducking (not on by default), so we could even do fancier things such as ducking video/music when a notification sound occurs.
Component: Video/Audio → WebRTC: Audio/Video
Assignee: nobody → rjesup
Target Milestone: --- → mozilla28
Randell and I were talking, and Roc is a better fit for this work.  We may reassign it after talking further with Roc.  I'd still like to get this done in time for Gecko 28.
Assignee: rjesup → roc
This requires hooking up PeerConnection to an AudioChannelAgent. (And making AudioChannelService work on desktop/Android.) Marco, can you or Steve do that?
After discussing with Steven Lee, please refer to quick note as below

  1. if we focused on "pause/mute media element when WebRTC call is coming" then it is doable. (just like what we did for camera recording, phone call and FM)

  2. But once we let WebRTC join "content" channel type then itself will be blocked by ringer or phone call too.

     * Steven tried to survey the behavior on "Facetime in iOS", it will pop up a window for prompting user to choice Facetime or Phone Call.
     * This mean that we need UX to define the scenarios between interaction with different media sources then we can just make sure the audio competing policy now is suitable for WebRTC.

Thanks.
(In reply to Robert O'Callahan (:roc) (Mozilla Corporation) from comment #4)
> (And making AudioChannelService work on desktop/Android.) Marco, can you or 
> Steve do that?

If we enable AudioChannelService on desktop/Android then we will change a behavior of media playback and that is 

  "According to web page didn't explicitly assign mozAudioChannel so it will be a normal channel type. Then all media in the page will be paused once it falls to background."

Is this audio competing policy on all your expectation?
Here is the flow of a webrtc incoming call.
1. ring tone
2. a. user decides to take this call
   b. create peerconnection
   c. try to connect to the caller 
3. connected

In step 1, App should create an audio element with AUDIO_AGENT_CHANNEL_RINGER type, it pauses/mutes the media.
In step 2, because of it takes some time to connect to the other peer so that "audio element should keep playing ring tone to prevent other music apps silence."
In step 3, we should register webrtc to AudioChannel as AUDIO_AGENT_CHANNEL_TELEPHONY. It also mutes the music.
This is already be handled for at least Hello in the B2G app, and I think for more than that.  Steven, can you update the status here?
Assignee: roc → nobody
backlog: --- → parking-lot
Flags: needinfo?(slee)
Target Milestone: mozilla28 → ---
For that we need to enable the AudioChannelService on desktop. It's just a preference to flip (it's ON on b2g,that's why it works there) and some (easy) code to write, and it's needed for this, the tab capture bug, and maybe another spec that's cooking at the whatwg and that I'm following: https://mediasession.spec.whatwg.org/. 

I've tested that it works as intended on desktop, modulo some behaviour that are not ideal for us here but that are fixable.
Hi Alastor,

Can you check the status here? Thanks.
Flags: needinfo?(slee) → needinfo?(alwu)
Hi, all,
The media would be pause in B2G if the WebRTC uses the Telephony audio channel type, and doesn't unregister it during the call.
Flags: needinfo?(alwu)
Hi Team,

Recently I'm working on WebRTC in which I've made Caller & Receiver end in my native android app.

I'm trying to do mute a call like Skype or Hangout but not able to mute the WebRTC call after adding remote stream with my local stream.

I tried "localMS.removeTrack(audioTrack);" this thing but I'm unable to do anything for muting a call.

Also one thing i would like to ask to all of you that How can we disconnect call from both end. In my app when one user is disconnecting call then another user still on local & remote stream(hanged up or paused) then how can we remove remote stream from both user end when someone disconnect the call.

Thanks & Regards,
Chitransh Mathur

Sr. Android Developer
Flags: needinfo?(chitransh.mathur)
chitransh - If you want to ask for help with your app, either post to the dev.media mailing list/Google Group (mozilla.dev.media), or ask on IRC (irc.mozilla.org, #media) or on the public-webrtc mailing list (perhaps the best place).   Short answer: use mediastreamtrack.enabled = false; to mute (to silence/black)
Flags: needinfo?(chitransh.mathur)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.