Bug 1242874 - part1 : create suspened types. r=baku

MozReview-Commit-ID: FUAPZAdPVse
This commit is contained in:
Alastor Wu
2016-05-03 09:50:24 +08:00
parent 4220f200ec
commit f3f3aeec61
7 changed files with 96 additions and 0 deletions

View File

@@ -6,6 +6,55 @@
interface mozIDOMWindow; interface mozIDOMWindow;
typedef uint32_t nsSuspendedTypes;
[scriptable, builtinclass, uuid(2822a840-f009-11e5-a837-0800200c9a66)]
interface nsISuspendedTypes : nsISupports
{
/**
* The suspended enum is used in three different situations,
* - platform audio focus (Fennec/B2G)
* - remote media control (Fennec)
* - block auto-play video in non-active page
*
* Note: the "remote side" must control the AudioChannelAgent using
* nsIAudioChannelAgentCallback.windowSuspendChanged() callback instead using
* play/pause methods or any button in the webpage.
*
* - SUSPENDED_PAUSE :
* It's used when transiently losing audio focus, the media can't be resumed
* until we gain the audio focus again. It would change the internal state of
* MediaElement when it's being suspended/resumed, and it would trigger the
* related JS event. eg. "play" and "pause" event.
*
* - SUSPENDED_BLOCK
* It's used to prevent auto-playing media in inactive page in order to
* reduce the power consumption, and the media can't be resumed until the
* page becomes active again. It would change the internal state of
* MediaElement when it's being blocked/resumed, so it won't trigger the
* related JS event. eg. "play" and "pause" event.
*
* - SUSPENDED_PAUSE_DISPOSABLE
* It's used for remote media-control to pause the playing media and when we
* lose audio focus permanently. It's disposable suspended, so the media can
* be resumed arbitrary after that. Same as SUSPENDED_PAUSE, it would change
* the internal state of MediaElement when it's being suspended.
*
* - SUSPENDED_STOP_DISPOSABLE
* It's used for remote media-control to stop the playing media. The remote
* control would disappear after stopping the media, so we would disconnect
* the audio channel agent. It's disposable suspended, so the media can be
* resumed arbitrary after that. Same as SUSPENDED_PAUSE, it would change
* the internal state of MediaElement when it's being suspended.
*/
const uint32_t NONE_SUSPENDED = 0;
const uint32_t SUSPENDED_PAUSE = 1;
const uint32_t SUSPENDED_BLOCK = 2;
const uint32_t SUSPENDED_PAUSE_DISPOSABLE = 3;
const uint32_t SUSPENDED_STOP_DISPOSABLE = 4;
};
[uuid(15c05894-408e-4798-b527-a8c32d9c5f8c)] [uuid(15c05894-408e-4798-b527-a8c32d9c5f8c)]
interface nsIAudioChannelAgentCallback : nsISupports interface nsIAudioChannelAgentCallback : nsISupports
{ {
@@ -14,6 +63,11 @@ interface nsIAudioChannelAgentCallback : nsISupports
*/ */
void windowVolumeChanged(in float aVolume, in bool aMuted); void windowVolumeChanged(in float aVolume, in bool aMuted);
/**
* Notified when the window needs to be suspended or resumed.
*/
void windowSuspendChanged(in uint32_t aSuspend);
/** /**
* Notified when the capture state is changed. * Notified when the capture state is changed.
*/ */

View File

@@ -468,6 +468,13 @@ FMRadio::WindowVolumeChanged(float aVolume, bool aMuted)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
FMRadio::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// TODO : implementation.
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
FMRadio::WindowAudioCaptureChanged(bool aCapture) FMRadio::WindowAudioCaptureChanged(bool aCapture)
{ {

View File

@@ -5134,6 +5134,13 @@ NS_IMETHODIMP HTMLMediaElement::WindowVolumeChanged(float aVolume, bool aMuted)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HTMLMediaElement::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// TODO : implementation.
return NS_OK;
}
#ifdef MOZ_EME #ifdef MOZ_EME
MediaKeys* MediaKeys*
HTMLMediaElement::GetMediaKeys() const HTMLMediaElement::GetMediaKeys() const

View File

@@ -529,6 +529,13 @@ AudioDestinationNode::WindowVolumeChanged(float aVolume, bool aMuted)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
AudioDestinationNode::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// TODO : implementation.
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
AudioDestinationNode::WindowAudioCaptureChanged(bool aCapture) AudioDestinationNode::WindowAudioCaptureChanged(bool aCapture)
{ {

View File

@@ -733,6 +733,13 @@ nsSpeechTask::WindowVolumeChanged(float aVolume, bool aMuted)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsSpeechTask::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// TODO : implementation.
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsSpeechTask::WindowAudioCaptureChanged(bool aCapture) nsSpeechTask::WindowAudioCaptureChanged(bool aCapture)
{ {

View File

@@ -1848,6 +1848,13 @@ nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
return rv; return rv;
} }
NS_IMETHODIMP
nsNPAPIPluginInstance::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// TODO : implementation.
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsNPAPIPluginInstance::WindowAudioCaptureChanged(bool aCapture) nsNPAPIPluginInstance::WindowAudioCaptureChanged(bool aCapture)
{ {

View File

@@ -718,6 +718,13 @@ Telephony::WindowVolumeChanged(float aVolume, bool aMuted)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
Telephony::WindowSuspendChanged(nsSuspendedTypes aSuspend)
{
// Not support yet.
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
Telephony::WindowAudioCaptureChanged(bool aCapture) Telephony::WindowAudioCaptureChanged(bool aCapture)
{ {