2012-12-05 23:57:00 -08:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
|
2014-03-11 03:46:04 -07:00
|
|
|
interface nsIDOMWindow;
|
|
|
|
|
2015-07-09 07:40:08 -07:00
|
|
|
[uuid(5fe83b24-38b9-4901-a4a1-d1bd57d3fe18)]
|
2012-12-05 23:57:00 -08:00
|
|
|
interface nsIAudioChannelAgentCallback : nsISupports
|
|
|
|
{
|
2014-03-11 03:46:55 -07:00
|
|
|
/**
|
|
|
|
* Notified when the window volume/mute is changed
|
|
|
|
*/
|
2015-07-10 09:38:44 -07:00
|
|
|
void windowVolumeChanged(in float aVolume, in bool aMuted);
|
2015-07-09 07:40:08 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notified when the capture state is changed.
|
|
|
|
*/
|
|
|
|
void windowAudioCaptureChanged();
|
2012-12-05 23:57:00 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This interface provides an agent for gecko components to participate
|
|
|
|
* in the audio channel service. Gecko components are responsible for
|
2014-03-11 03:46:04 -07:00
|
|
|
* 1. Indicating what channel type they are using (via the init() member
|
|
|
|
* function).
|
2012-12-05 23:57:00 -08:00
|
|
|
* 2. Before playing, checking the playable status of the channel.
|
|
|
|
* 3. Notifying the agent when they start/stop using this channel.
|
|
|
|
* 4. Notifying the agent of changes to the visibility of the component using
|
2014-03-11 03:46:04 -07:00
|
|
|
* this channel.
|
2012-12-05 23:57:00 -08:00
|
|
|
*
|
|
|
|
* The agent will invoke a callback to notify Gecko components of
|
|
|
|
* 1. Changes to the playable status of this channel.
|
|
|
|
*/
|
|
|
|
|
2015-03-15 21:01:50 -07:00
|
|
|
[uuid(ee39a34b-a5c7-4b30-b1ac-cd64ceedef67)]
|
2012-12-05 23:57:00 -08:00
|
|
|
interface nsIAudioChannelAgent : nsISupports
|
|
|
|
{
|
|
|
|
const long AUDIO_AGENT_CHANNEL_NORMAL = 0;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_CONTENT = 1;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_NOTIFICATION = 2;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_ALARM = 3;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_TELEPHONY = 4;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_RINGER = 5;
|
|
|
|
const long AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION = 6;
|
2015-03-15 21:01:50 -07:00
|
|
|
const long AUDIO_AGENT_CHANNEL_SYSTEM = 7;
|
2012-12-05 23:57:00 -08:00
|
|
|
|
|
|
|
const long AUDIO_AGENT_CHANNEL_ERROR = 1000;
|
|
|
|
|
2013-09-02 02:45:44 -07:00
|
|
|
const long AUDIO_AGENT_STATE_NORMAL = 0;
|
|
|
|
const long AUDIO_AGENT_STATE_MUTED = 1;
|
|
|
|
const long AUDIO_AGENT_STATE_FADED = 2;
|
|
|
|
|
2012-12-05 23:57:00 -08:00
|
|
|
/**
|
|
|
|
* Before init() is called, this returns AUDIO_AGENT_CHANNEL_ERROR.
|
|
|
|
*/
|
|
|
|
readonly attribute long audioChannelType;
|
|
|
|
|
2015-07-10 09:38:51 -07:00
|
|
|
%{C++
|
|
|
|
inline int32_t AudioChannelType() {
|
|
|
|
int32_t channel;
|
|
|
|
return NS_SUCCEEDED(GetAudioChannelType(&channel)) ? channel : AUDIO_AGENT_CHANNEL_ERROR;
|
|
|
|
}
|
|
|
|
%}
|
|
|
|
|
2012-12-05 23:57:00 -08:00
|
|
|
/**
|
|
|
|
* Initialize the agent with a channel type.
|
|
|
|
* Note: This function should only be called once.
|
|
|
|
*
|
2014-03-11 03:46:04 -07:00
|
|
|
* @param window
|
|
|
|
* The window
|
2012-12-05 23:57:00 -08:00
|
|
|
* @param channelType
|
|
|
|
* Audio Channel Type listed as above
|
|
|
|
* @param callback
|
2014-03-11 03:46:04 -07:00
|
|
|
* 1. Once the playable status changes, agent uses this callback function
|
|
|
|
* to notify Gecko component.
|
|
|
|
* 2. The callback is allowed to be null. Ex: telephony doesn't need to
|
|
|
|
* listen change of the playable status.
|
|
|
|
* 3. The AudioChannelAgent keeps a strong reference to the callback
|
|
|
|
* object.
|
2012-12-05 23:57:00 -08:00
|
|
|
*/
|
2014-03-11 03:46:04 -07:00
|
|
|
void init(in nsIDOMWindow window, in long channelType,
|
|
|
|
in nsIAudioChannelAgentCallback callback);
|
2012-12-05 23:57:00 -08:00
|
|
|
|
2013-04-03 13:35:05 -07:00
|
|
|
/**
|
|
|
|
* This method is just like init(), except the audio channel agent keeps a
|
|
|
|
* weak reference to the callback object.
|
|
|
|
*
|
|
|
|
* In order for this to work, |callback| must implement
|
|
|
|
* nsISupportsWeakReference.
|
|
|
|
*/
|
2014-03-11 03:46:04 -07:00
|
|
|
void initWithWeakCallback(in nsIDOMWindow window, in long channelType,
|
|
|
|
in nsIAudioChannelAgentCallback callback);
|
2013-04-03 13:35:05 -07:00
|
|
|
|
2012-12-05 23:57:00 -08:00
|
|
|
/**
|
|
|
|
* Notify the agent that we want to start playing.
|
|
|
|
* Note: Gecko component SHOULD call this function first then start to
|
|
|
|
* play audio stream only when return value is true.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
2013-09-02 02:45:44 -07:00
|
|
|
* normal state: the agent has registered with audio channel service and
|
|
|
|
* the component should start playback.
|
|
|
|
* muted state: the agent has registered with audio channel service but
|
|
|
|
* the component should not start playback.
|
|
|
|
* faded state: the agent has registered with audio channel service the
|
|
|
|
* component should start playback as well as reducing the volume.
|
2012-12-05 23:57:00 -08:00
|
|
|
*/
|
2015-07-11 00:24:26 -07:00
|
|
|
void notifyStartedPlaying(out float volume, out bool muted);
|
2012-12-05 23:57:00 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify the agent we no longer want to play.
|
|
|
|
*
|
2015-07-11 00:24:26 -07:00
|
|
|
* Note : even if notifyStartedPlaying() returned false, the agent would
|
|
|
|
* still be registered with the audio channel service and receive callbacks
|
|
|
|
* for status changes. So notifyStoppedPlaying must still eventually be
|
|
|
|
* called to unregister the agent with the channel service.
|
2012-12-05 23:57:00 -08:00
|
|
|
*/
|
2015-07-11 00:24:26 -07:00
|
|
|
void notifyStoppedPlaying();
|
2012-12-05 23:57:00 -08:00
|
|
|
};
|