michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIDOMWindow; michael@0: michael@0: [uuid(194b55d9-39c0-45c6-b8ef-b8049f978ea5)] michael@0: interface nsIAudioChannelAgentCallback : nsISupports michael@0: { michael@0: /** michael@0: * Notified when the playable status of channel is changed. michael@0: * michael@0: * @param canPlay michael@0: * Callback from agent to notify component of the playable status michael@0: * of the channel. If canPlay is muted state, component SHOULD stop michael@0: * playing media associated with this channel as soon as possible. if michael@0: * it is faded state then the volume of media should be reduced. michael@0: */ michael@0: void canPlayChanged(in long canPlay); michael@0: michael@0: /** michael@0: * Notified when the window volume/mute is changed michael@0: */ michael@0: void windowVolumeChanged(); michael@0: }; michael@0: michael@0: /** michael@0: * This interface provides an agent for gecko components to participate michael@0: * in the audio channel service. Gecko components are responsible for michael@0: * 1. Indicating what channel type they are using (via the init() member michael@0: * function). michael@0: * 2. Before playing, checking the playable status of the channel. michael@0: * 3. Notifying the agent when they start/stop using this channel. michael@0: * 4. Notifying the agent of changes to the visibility of the component using michael@0: * this channel. michael@0: * michael@0: * The agent will invoke a callback to notify Gecko components of michael@0: * 1. Changes to the playable status of this channel. michael@0: */ michael@0: michael@0: [uuid(2b0222a5-8f7b-49d2-9ab8-cd01b744b23e)] michael@0: interface nsIAudioChannelAgent : nsISupports michael@0: { michael@0: const long AUDIO_AGENT_CHANNEL_NORMAL = 0; michael@0: const long AUDIO_AGENT_CHANNEL_CONTENT = 1; michael@0: const long AUDIO_AGENT_CHANNEL_NOTIFICATION = 2; michael@0: const long AUDIO_AGENT_CHANNEL_ALARM = 3; michael@0: const long AUDIO_AGENT_CHANNEL_TELEPHONY = 4; michael@0: const long AUDIO_AGENT_CHANNEL_RINGER = 5; michael@0: const long AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION = 6; michael@0: michael@0: const long AUDIO_AGENT_CHANNEL_ERROR = 1000; michael@0: michael@0: const long AUDIO_AGENT_STATE_NORMAL = 0; michael@0: const long AUDIO_AGENT_STATE_MUTED = 1; michael@0: const long AUDIO_AGENT_STATE_FADED = 2; michael@0: michael@0: /** michael@0: * Before init() is called, this returns AUDIO_AGENT_CHANNEL_ERROR. michael@0: */ michael@0: readonly attribute long audioChannelType; michael@0: michael@0: /** michael@0: * Initialize the agent with a channel type. michael@0: * Note: This function should only be called once. michael@0: * michael@0: * @param window michael@0: * The window michael@0: * @param channelType michael@0: * Audio Channel Type listed as above michael@0: * @param callback michael@0: * 1. Once the playable status changes, agent uses this callback function michael@0: * to notify Gecko component. michael@0: * 2. The callback is allowed to be null. Ex: telephony doesn't need to michael@0: * listen change of the playable status. michael@0: * 3. The AudioChannelAgent keeps a strong reference to the callback michael@0: * object. michael@0: */ michael@0: void init(in nsIDOMWindow window, in long channelType, michael@0: in nsIAudioChannelAgentCallback callback); michael@0: michael@0: /** michael@0: * This method is just like init(), except the audio channel agent keeps a michael@0: * weak reference to the callback object. michael@0: * michael@0: * In order for this to work, |callback| must implement michael@0: * nsISupportsWeakReference. michael@0: */ michael@0: void initWithWeakCallback(in nsIDOMWindow window, in long channelType, michael@0: in nsIAudioChannelAgentCallback callback); michael@0: michael@0: /** michael@0: * This method is just like init(), and specify the channel is associated michael@0: * with video. michael@0: * michael@0: * @param weak michael@0: * true if weak reference should be hold. michael@0: */ michael@0: void initWithVideo(in nsIDOMWindow window, in long channelType, michael@0: in nsIAudioChannelAgentCallback callback, in boolean weak); michael@0: michael@0: /** michael@0: * Notify the agent that we want to start playing. michael@0: * Note: Gecko component SHOULD call this function first then start to michael@0: * play audio stream only when return value is true. michael@0: * michael@0: * michael@0: * @return michael@0: * normal state: the agent has registered with audio channel service and michael@0: * the component should start playback. michael@0: * muted state: the agent has registered with audio channel service but michael@0: * the component should not start playback. michael@0: * faded state: the agent has registered with audio channel service the michael@0: * component should start playback as well as reducing the volume. michael@0: */ michael@0: long startPlaying(); michael@0: michael@0: /** michael@0: * Notify the agent we no longer want to play. michael@0: * michael@0: * Note : even if startPlaying() returned false, the agent would still be michael@0: * registered with the audio channel service and receive callbacks for status changes. michael@0: * So stopPlaying must still eventually be called to unregister the agent with the michael@0: * channel service. michael@0: */ michael@0: void stopPlaying(); michael@0: michael@0: /** michael@0: * Notify the agent of the visibility state of the window using this agent. michael@0: * @param visible michael@0: * True if the window associated with the agent is visible. michael@0: */ michael@0: void setVisibilityState(in boolean visible); michael@0: michael@0: /** michael@0: * Retrieve the volume from the window. michael@0: */ michael@0: readonly attribute float windowVolume; michael@0: }; michael@0: