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