Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "nsISupports.idl" |
michael@0 | 6 | |
michael@0 | 7 | interface nsIDOMWindow; |
michael@0 | 8 | |
michael@0 | 9 | [uuid(194b55d9-39c0-45c6-b8ef-b8049f978ea5)] |
michael@0 | 10 | interface nsIAudioChannelAgentCallback : nsISupports |
michael@0 | 11 | { |
michael@0 | 12 | /** |
michael@0 | 13 | * Notified when the playable status of channel is changed. |
michael@0 | 14 | * |
michael@0 | 15 | * @param canPlay |
michael@0 | 16 | * Callback from agent to notify component of the playable status |
michael@0 | 17 | * of the channel. If canPlay is muted state, component SHOULD stop |
michael@0 | 18 | * playing media associated with this channel as soon as possible. if |
michael@0 | 19 | * it is faded state then the volume of media should be reduced. |
michael@0 | 20 | */ |
michael@0 | 21 | void canPlayChanged(in long canPlay); |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Notified when the window volume/mute is changed |
michael@0 | 25 | */ |
michael@0 | 26 | void windowVolumeChanged(); |
michael@0 | 27 | }; |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * This interface provides an agent for gecko components to participate |
michael@0 | 31 | * in the audio channel service. Gecko components are responsible for |
michael@0 | 32 | * 1. Indicating what channel type they are using (via the init() member |
michael@0 | 33 | * function). |
michael@0 | 34 | * 2. Before playing, checking the playable status of the channel. |
michael@0 | 35 | * 3. Notifying the agent when they start/stop using this channel. |
michael@0 | 36 | * 4. Notifying the agent of changes to the visibility of the component using |
michael@0 | 37 | * this channel. |
michael@0 | 38 | * |
michael@0 | 39 | * The agent will invoke a callback to notify Gecko components of |
michael@0 | 40 | * 1. Changes to the playable status of this channel. |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | [uuid(2b0222a5-8f7b-49d2-9ab8-cd01b744b23e)] |
michael@0 | 44 | interface nsIAudioChannelAgent : nsISupports |
michael@0 | 45 | { |
michael@0 | 46 | const long AUDIO_AGENT_CHANNEL_NORMAL = 0; |
michael@0 | 47 | const long AUDIO_AGENT_CHANNEL_CONTENT = 1; |
michael@0 | 48 | const long AUDIO_AGENT_CHANNEL_NOTIFICATION = 2; |
michael@0 | 49 | const long AUDIO_AGENT_CHANNEL_ALARM = 3; |
michael@0 | 50 | const long AUDIO_AGENT_CHANNEL_TELEPHONY = 4; |
michael@0 | 51 | const long AUDIO_AGENT_CHANNEL_RINGER = 5; |
michael@0 | 52 | const long AUDIO_AGENT_CHANNEL_PUBLICNOTIFICATION = 6; |
michael@0 | 53 | |
michael@0 | 54 | const long AUDIO_AGENT_CHANNEL_ERROR = 1000; |
michael@0 | 55 | |
michael@0 | 56 | const long AUDIO_AGENT_STATE_NORMAL = 0; |
michael@0 | 57 | const long AUDIO_AGENT_STATE_MUTED = 1; |
michael@0 | 58 | const long AUDIO_AGENT_STATE_FADED = 2; |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Before init() is called, this returns AUDIO_AGENT_CHANNEL_ERROR. |
michael@0 | 62 | */ |
michael@0 | 63 | readonly attribute long audioChannelType; |
michael@0 | 64 | |
michael@0 | 65 | /** |
michael@0 | 66 | * Initialize the agent with a channel type. |
michael@0 | 67 | * Note: This function should only be called once. |
michael@0 | 68 | * |
michael@0 | 69 | * @param window |
michael@0 | 70 | * The window |
michael@0 | 71 | * @param channelType |
michael@0 | 72 | * Audio Channel Type listed as above |
michael@0 | 73 | * @param callback |
michael@0 | 74 | * 1. Once the playable status changes, agent uses this callback function |
michael@0 | 75 | * to notify Gecko component. |
michael@0 | 76 | * 2. The callback is allowed to be null. Ex: telephony doesn't need to |
michael@0 | 77 | * listen change of the playable status. |
michael@0 | 78 | * 3. The AudioChannelAgent keeps a strong reference to the callback |
michael@0 | 79 | * object. |
michael@0 | 80 | */ |
michael@0 | 81 | void init(in nsIDOMWindow window, in long channelType, |
michael@0 | 82 | in nsIAudioChannelAgentCallback callback); |
michael@0 | 83 | |
michael@0 | 84 | /** |
michael@0 | 85 | * This method is just like init(), except the audio channel agent keeps a |
michael@0 | 86 | * weak reference to the callback object. |
michael@0 | 87 | * |
michael@0 | 88 | * In order for this to work, |callback| must implement |
michael@0 | 89 | * nsISupportsWeakReference. |
michael@0 | 90 | */ |
michael@0 | 91 | void initWithWeakCallback(in nsIDOMWindow window, in long channelType, |
michael@0 | 92 | in nsIAudioChannelAgentCallback callback); |
michael@0 | 93 | |
michael@0 | 94 | /** |
michael@0 | 95 | * This method is just like init(), and specify the channel is associated |
michael@0 | 96 | * with video. |
michael@0 | 97 | * |
michael@0 | 98 | * @param weak |
michael@0 | 99 | * true if weak reference should be hold. |
michael@0 | 100 | */ |
michael@0 | 101 | void initWithVideo(in nsIDOMWindow window, in long channelType, |
michael@0 | 102 | in nsIAudioChannelAgentCallback callback, in boolean weak); |
michael@0 | 103 | |
michael@0 | 104 | /** |
michael@0 | 105 | * Notify the agent that we want to start playing. |
michael@0 | 106 | * Note: Gecko component SHOULD call this function first then start to |
michael@0 | 107 | * play audio stream only when return value is true. |
michael@0 | 108 | * |
michael@0 | 109 | * |
michael@0 | 110 | * @return |
michael@0 | 111 | * normal state: the agent has registered with audio channel service and |
michael@0 | 112 | * the component should start playback. |
michael@0 | 113 | * muted state: the agent has registered with audio channel service but |
michael@0 | 114 | * the component should not start playback. |
michael@0 | 115 | * faded state: the agent has registered with audio channel service the |
michael@0 | 116 | * component should start playback as well as reducing the volume. |
michael@0 | 117 | */ |
michael@0 | 118 | long startPlaying(); |
michael@0 | 119 | |
michael@0 | 120 | /** |
michael@0 | 121 | * Notify the agent we no longer want to play. |
michael@0 | 122 | * |
michael@0 | 123 | * Note : even if startPlaying() returned false, the agent would still be |
michael@0 | 124 | * registered with the audio channel service and receive callbacks for status changes. |
michael@0 | 125 | * So stopPlaying must still eventually be called to unregister the agent with the |
michael@0 | 126 | * channel service. |
michael@0 | 127 | */ |
michael@0 | 128 | void stopPlaying(); |
michael@0 | 129 | |
michael@0 | 130 | /** |
michael@0 | 131 | * Notify the agent of the visibility state of the window using this agent. |
michael@0 | 132 | * @param visible |
michael@0 | 133 | * True if the window associated with the agent is visible. |
michael@0 | 134 | */ |
michael@0 | 135 | void setVisibilityState(in boolean visible); |
michael@0 | 136 | |
michael@0 | 137 | /** |
michael@0 | 138 | * Retrieve the volume from the window. |
michael@0 | 139 | */ |
michael@0 | 140 | readonly attribute float windowVolume; |
michael@0 | 141 | }; |
michael@0 | 142 |