Add a function to create a bookmark app from a WebApplicationInfo.
[chromium-blink-merge.git] / ppapi / api / ppb_media_stream_audio_track.idl
blob0f7aa725854799d2511b19f6cff1d8a4e9c1149d
1 /* Copyright 2014 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
6 /**
7 * Defines the <code>PPB_MediaStreamAudioTrack</code> interface. Used for
8 * receiving audio samples from a MediaStream audio track in the browser.
9 */
11 [generate_thunk]
13 label Chrome {
14 [channel=dev] M34 = 0.1,
15 M35 = 0.1
18 /**
19 * This enumeration contains audio track attributes which are used by
20 * <code>Configure()</code>.
22 enum PP_MediaStreamAudioTrack_Attrib {
23 /**
24 * Attribute list terminator.
26 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE = 0,
28 /**
29 * The maximum number of buffers to hold audio samples.
30 * Note: this is only used as advisory; the browser may allocate more or fewer
31 * based on available resources. How many buffers depends on usage -
32 * request at least 2 to make sure latency doesn't cause lost samples. If
33 * the plugin expects to hold on to more than one buffer at a time (e.g. to do
34 * multi-buffer processing), it should request that many more.
36 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS = 1,
38 /**
39 * The sample rate of audio data in buffers. The attribute value is a
40 * <code>PP_AudioBuffer_SampleRate</code>.
42 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE = 2,
44 /**
45 * The sample size of audio data in buffers in bytes. The attribute value is a
46 * <code>PP_AudioBuffer_SampleSize</code>.
48 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE = 3,
50 /**
51 * The number of channels in audio buffers.
53 * Supported values: 1, 2
55 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS = 4,
57 /**
58 * The duration of an audio buffer in milliseconds.
60 * Valid range: 10 to 10000
62 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 5
65 [version=0.1]
66 interface PPB_MediaStreamAudioTrack {
67 /**
68 * Determines if a resource is a MediaStream audio track resource.
70 * @param[in] resource The <code>PP_Resource</code> to test.
72 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
73 * resource is a Mediastream audio track resource or <code>PP_FALSE</code>
74 * otherwise.
76 PP_Bool IsMediaStreamAudioTrack([in] PP_Resource resource);
78 /**
79 * Configures underlying buffers for incoming audio samples.
80 * If the application doesn't want to drop samples, then the
81 * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS</code> should be
82 * chosen such that inter-buffer processing time variability won't overrun all
83 * the input buffers. If all buffers are filled, then samples will be
84 * dropped. The application can detect this by examining the timestamp on
85 * returned buffers. If <code>Configure()</code> is not called, default
86 * settings will be used.
87 * Example usage from plugin code:
88 * @code
89 * int32_t attribs[] = {
90 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 4,
91 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10,
92 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE};
93 * track_if->Configure(track, attribs, callback);
94 * @endcode
96 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
97 * resource.
98 * @param[in] attrib_list A list of attribute name-value pairs in which each
99 * attribute is immediately followed by the corresponding desired value.
100 * The list is terminated by
101 * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE</code>.
102 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
103 * completion of <code>Configure()</code>.
105 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
107 int32_t Configure([in] PP_Resource audio_track,
108 [in] int32_t[] attrib_list,
109 [in] PP_CompletionCallback callback);
112 * Gets attribute value for a given attribute name.
114 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
115 * resource.
116 * @param[in] attrib A <code>PP_MediaStreamAudioTrack_Attrib</code> for
117 * querying.
118 * @param[out] value A int32_t for storing the attribute value on success.
119 * Otherwise, the value will not be changed.
121 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
123 int32_t GetAttrib([in] PP_Resource audio_track,
124 [in] PP_MediaStreamAudioTrack_Attrib attrib,
125 [out] int32_t value);
128 * Returns the track ID of the underlying MediaStream audio track.
130 * @param[in] audio_track The <code>PP_Resource</code> to check.
132 * @return A <code>PP_Var</code> containing the MediaStream track ID as
133 * a string.
135 PP_Var GetId([in] PP_Resource audio_track);
138 * Checks whether the underlying MediaStream track has ended.
139 * Calls to GetBuffer while the track has ended are safe to make and will
140 * complete, but will fail.
142 * @param[in] audio_track The <code>PP_Resource</code> to check.
144 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
145 * MediaStream track has ended or <code>PP_FALSE</code> otherwise.
147 [on_failure=PP_TRUE]
148 PP_Bool HasEnded([in] PP_Resource audio_track);
151 * Gets the next audio buffer from the MediaStream track.
152 * If internal processing is slower than the incoming buffer rate, new buffers
153 * will be dropped from the incoming stream. Once all buffers are full,
154 * audio samples will be dropped until <code>RecycleBuffer()</code> is called
155 * to free a slot for another buffer.
156 * If there are no audio data in the input buffer,
157 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the
158 * <code>callback</code> will be called, when a new buffer of audio samples
159 * is received or an error happens.
161 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
162 * resource.
163 * @param[out] buffer A <code>PP_Resource</code> corresponding to
164 * an AudioBuffer resource.
165 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
166 * completion of GetBuffer().
168 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
170 int32_t GetBuffer([in] PP_Resource audio_track,
171 [out] PP_Resource buffer,
172 [in] PP_CompletionCallback callback);
175 * Recycles a buffer returned by <code>GetBuffer()</code>, so the track can
176 * reuse the buffer. And the buffer will become invalid. The caller should
177 * release all references it holds to <code>buffer</code> and not use it
178 * anymore.
180 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio
181 * resource.
182 * @param[in] buffer A <code>PP_Resource</code> corresponding to
183 * an AudioBuffer resource returned by <code>GetBuffer()</code>.
185 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
187 int32_t RecycleBuffer([in] PP_Resource audio_track,
188 [in] PP_Resource buffer);
191 * Closes the MediaStream audio track and disconnects it from the audio
192 * source. After calling <code>Close()</code>, no new buffers will be
193 * received.
195 * @param[in] audio_track A <code>PP_Resource</code> corresponding to a
196 * MediaStream audio track resource.
198 void Close([in] PP_Resource audio_track);