OLD | NEW |
1 /* Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 /* From ppb_media_stream_audio_track.idl modified Thu Jan 23 14:08:10 2014. */ | 6 /* From ppb_media_stream_audio_track.idl modified Fri Feb 7 14:38:28 2014. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ | 8 #ifndef PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ |
9 #define PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ | 9 #define PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ |
10 | 10 |
11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
13 #include "ppapi/c/pp_macros.h" | 13 #include "ppapi/c/pp_macros.h" |
14 #include "ppapi/c/pp_resource.h" | 14 #include "ppapi/c/pp_resource.h" |
15 #include "ppapi/c/pp_stdint.h" | 15 #include "ppapi/c/pp_stdint.h" |
16 #include "ppapi/c/pp_var.h" | 16 #include "ppapi/c/pp_var.h" |
17 | 17 |
18 #define PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1 \ | 18 #define PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1 \ |
19 "PPB_MediaStreamAudioTrack;0.1" /* dev */ | 19 "PPB_MediaStreamAudioTrack;0.1" /* dev */ |
20 /** | 20 /** |
21 * @file | 21 * @file |
22 * Defines the <code>PPB_MediaStreamAudioTrack</code> interface. Used for | 22 * Defines the <code>PPB_MediaStreamAudioTrack</code> interface. Used for |
23 * receiving audio frames from a MediaStream audio track in the browser. | 23 * receiving audio samples from a MediaStream audio track in the browser. |
24 * This interface is still in development (Dev API status) and may change. | 24 * This interface is still in development (Dev API status) and may change. |
25 */ | 25 */ |
26 | 26 |
27 | 27 |
28 /** | 28 /** |
29 * @addtogroup Enums | 29 * @addtogroup Enums |
30 * @{ | 30 * @{ |
31 */ | 31 */ |
32 /** | 32 /** |
33 * This enumeration contains audio track attributes which are used by | 33 * This enumeration contains audio track attributes which are used by |
34 * <code>Configure()</code>. | 34 * <code>Configure()</code>. |
35 */ | 35 */ |
36 typedef enum { | 36 typedef enum { |
37 /** | 37 /** |
38 * Attribute list terminator. | 38 * Attribute list terminator. |
39 */ | 39 */ |
40 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE = 0, | 40 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE = 0, |
41 /** | 41 /** |
42 * The maximum number of frames to hold in the input buffer. | 42 * The maximum number of buffers to hold audio samples. |
43 * Note: this is only used as advisory; the browser may allocate more or fewer | 43 * Note: this is only used as advisory; the browser may allocate more or fewer |
44 * based on available resources. How many frames to buffer depends on usage - | 44 * based on available resources. How many buffers depends on usage - |
45 * request at least 2 to make sure latency doesn't cause lost frames. If | 45 * request at least 2 to make sure latency doesn't cause lost samples. If |
46 * the plugin expects to hold on to more than one frame at a time (e.g. to do | 46 * the plugin expects to hold on to more than one buffer at a time (e.g. to do |
47 * multi-frame processing), it should request that many more. | 47 * multi-buffer processing), it should request that many more. |
48 */ | 48 */ |
49 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERED_FRAMES = 1, | 49 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS = 1, |
50 /** | 50 /** |
51 * The sample rate of audio frames. The attribute value is a | 51 * The sample rate of audio data in buffers. The attribute value is a |
52 * <code>PP_AudioFrame_SampleRate</code>. | 52 * <code>PP_AudioBuffer_SampleRate</code>. |
53 */ | 53 */ |
54 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE = 2, | 54 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_RATE = 2, |
55 /** | 55 /** |
56 * The sample size of audio frames in bytes. The attribute value is a | 56 * The sample size of audio data in buffers in bytes. The attribute value is a |
57 * <code>PP_AudioFrame_SampleSize</code>. | 57 * <code>PP_AudioBuffer_SampleSize</code>. |
58 */ | 58 */ |
59 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE = 3, | 59 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_SAMPLE_SIZE = 3, |
60 /** | 60 /** |
61 * The number of channels in audio frames. | 61 * The number of channels in audio buffers. |
62 * | 62 * |
63 * Supported values: 1, 2 | 63 * Supported values: 1, 2 |
64 */ | 64 */ |
65 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS = 4, | 65 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_CHANNELS = 4, |
66 /** | 66 /** |
67 * The duration of audio frames in milliseconds. | 67 * The duration of an audio buffer in milliseconds. |
68 * | 68 * |
69 * Valid range: 10 to 10000 | 69 * Valid range: 10 to 10000 |
70 */ | 70 */ |
71 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 5 | 71 PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION = 5 |
72 } PP_MediaStreamAudioTrack_Attrib; | 72 } PP_MediaStreamAudioTrack_Attrib; |
73 /** | 73 /** |
74 * @} | 74 * @} |
75 */ | 75 */ |
76 | 76 |
77 /** | 77 /** |
78 * @addtogroup Interfaces | 78 * @addtogroup Interfaces |
79 * @{ | 79 * @{ |
80 */ | 80 */ |
81 struct PPB_MediaStreamAudioTrack_0_1 { /* dev */ | 81 struct PPB_MediaStreamAudioTrack_0_1 { /* dev */ |
82 /** | 82 /** |
83 * Determines if a resource is a MediaStream audio track resource. | 83 * Determines if a resource is a MediaStream audio track resource. |
84 * | 84 * |
85 * @param[in] resource The <code>PP_Resource</code> to test. | 85 * @param[in] resource The <code>PP_Resource</code> to test. |
86 * | 86 * |
87 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 87 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
88 * resource is a Mediastream audio track resource or <code>PP_FALSE</code> | 88 * resource is a Mediastream audio track resource or <code>PP_FALSE</code> |
89 * otherwise. | 89 * otherwise. |
90 */ | 90 */ |
91 PP_Bool (*IsMediaStreamAudioTrack)(PP_Resource resource); | 91 PP_Bool (*IsMediaStreamAudioTrack)(PP_Resource resource); |
92 /** | 92 /** |
93 * Configures underlying frame buffers for incoming frames. | 93 * Configures underlying buffers for incoming audio samples. |
94 * If the application doesn't want to drop frames, then the | 94 * If the application doesn't want to drop samples, then the |
95 * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERED_FRAMES</code> should be | 95 * <code>PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS</code> should be |
96 * chosen such that inter-frame processing time variability won't overrun the | 96 * chosen such that inter-buffer processing time variability won't overrun all |
97 * input buffer. If the buffer is overfilled, then frames will be dropped. | 97 * the input buffers. If all buffers are filled, then samples will be |
98 * The application can detect this by examining the timestamp on returned | 98 * dropped. The application can detect this by examining the timestamp on |
99 * frames. If <code>Configure()</code> is not called, default settings will be | 99 * returned buffers. If <code>Configure()</code> is not called, default |
100 * used. | 100 * settings will be used. |
101 * Example usage from plugin code: | 101 * Example usage from plugin code: |
102 * @code | 102 * @code |
103 * int32_t attribs[] = { | 103 * int32_t attribs[] = { |
104 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERED_FRAMES, 4, | 104 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_BUFFERS, 4, |
105 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10, | 105 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_DURATION, 10, |
106 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE}; | 106 * PP_MEDIASTREAMAUDIOTRACK_ATTRIB_NONE}; |
107 * track_if->Configure(track, attribs, callback); | 107 * track_if->Configure(track, attribs, callback); |
108 * @endcode | 108 * @endcode |
109 * | 109 * |
110 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio | 110 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
111 * resource. | 111 * resource. |
112 * @param[in] attrib_list A list of attribute name-value pairs in which each | 112 * @param[in] attrib_list A list of attribute name-value pairs in which each |
113 * attribute is immediately followed by the corresponding desired value. | 113 * attribute is immediately followed by the corresponding desired value. |
114 * The list is terminated by | 114 * The list is terminated by |
(...skipping 25 matching lines...) Expand all Loading... |
140 * Returns the track ID of the underlying MediaStream audio track. | 140 * Returns the track ID of the underlying MediaStream audio track. |
141 * | 141 * |
142 * @param[in] audio_track The <code>PP_Resource</code> to check. | 142 * @param[in] audio_track The <code>PP_Resource</code> to check. |
143 * | 143 * |
144 * @return A <code>PP_Var</code> containing the MediaStream track ID as | 144 * @return A <code>PP_Var</code> containing the MediaStream track ID as |
145 * a string. | 145 * a string. |
146 */ | 146 */ |
147 struct PP_Var (*GetId)(PP_Resource audio_track); | 147 struct PP_Var (*GetId)(PP_Resource audio_track); |
148 /** | 148 /** |
149 * Checks whether the underlying MediaStream track has ended. | 149 * Checks whether the underlying MediaStream track has ended. |
150 * Calls to GetFrame while the track has ended are safe to make and will | 150 * Calls to GetBuffer while the track has ended are safe to make and will |
151 * complete, but will fail. | 151 * complete, but will fail. |
152 * | 152 * |
153 * @param[in] audio_track The <code>PP_Resource</code> to check. | 153 * @param[in] audio_track The <code>PP_Resource</code> to check. |
154 * | 154 * |
155 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 155 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
156 * MediaStream track has ended or <code>PP_FALSE</code> otherwise. | 156 * MediaStream track has ended or <code>PP_FALSE</code> otherwise. |
157 */ | 157 */ |
158 PP_Bool (*HasEnded)(PP_Resource audio_track); | 158 PP_Bool (*HasEnded)(PP_Resource audio_track); |
159 /** | 159 /** |
160 * Gets the next audio frame from the MediaStream track. | 160 * Gets the next audio buffer from the MediaStream track. |
161 * If internal processing is slower than the incoming frame rate, new frames | 161 * If internal processing is slower than the incoming buffer rate, new buffers |
162 * will be dropped from the incoming stream. Once the input buffer is full, | 162 * will be dropped from the incoming stream. Once all buffers are full, |
163 * frames will be dropped until <code>RecycleFrame()</code> is called to free | 163 * audio samples will be dropped until <code>RecycleBuffer()</code> is called |
164 * a spot for another frame to be buffered. | 164 * to free a slot for another buffer. |
165 * If there are no frames in the input buffer, | 165 * If there are no audio data in the input buffer, |
166 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the | 166 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the |
167 * <code>callback</code> will be called, when a new frame is received or an | 167 * <code>callback</code> will be called, when a new buffer of audio samples |
168 * error happens. | 168 * is received or an error happens. |
169 * | 169 * |
170 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio | 170 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
171 * resource. | 171 * resource. |
172 * @param[out] frame A <code>PP_Resource</code> corresponding to an AudioFrame | 172 * @param[out] buffer A <code>PP_Resource</code> corresponding to |
173 * resource. | 173 * an AudioBuffer resource. |
174 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 174 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
175 * completion of GetFrame(). | 175 * completion of GetBuffer(). |
176 * | 176 * |
177 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 177 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
178 * Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames buffer | |
179 * was not allocated successfully. | |
180 */ | 178 */ |
181 int32_t (*GetFrame)(PP_Resource audio_track, | 179 int32_t (*GetBuffer)(PP_Resource audio_track, |
182 PP_Resource* frame, | 180 PP_Resource* buffer, |
183 struct PP_CompletionCallback callback); | 181 struct PP_CompletionCallback callback); |
184 /** | 182 /** |
185 * Recycles a frame returned by <code>GetFrame()</code>, so the track can | 183 * Recycles a buffer returned by <code>GetBuffer()</code>, so the track can |
186 * reuse the underlying buffer of this frame. And the frame will become | 184 * reuse the buffer. And the buffer will become invalid. The caller should |
187 * invalid. The caller should release all references it holds to | 185 * release all references it holds to <code>buffer</code> and not use it |
188 * <code>frame</code> and not use it anymore. | 186 * anymore. |
189 * | 187 * |
190 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio | 188 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
191 * resource. | 189 * resource. |
192 * @param[in] frame A <code>PP_Resource</code> corresponding to an AudioFrame | 190 * @param[in] buffer A <code>PP_Resource</code> corresponding to |
193 * resource returned by <code>GetFrame()</code>. | 191 * an AudioBuffer resource returned by <code>GetBuffer()</code>. |
194 * | 192 * |
195 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 193 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
196 */ | 194 */ |
197 int32_t (*RecycleFrame)(PP_Resource audio_track, PP_Resource frame); | 195 int32_t (*RecycleBuffer)(PP_Resource audio_track, PP_Resource buffer); |
198 /** | 196 /** |
199 * Closes the MediaStream audio track and disconnects it from the audio | 197 * Closes the MediaStream audio track and disconnects it from the audio |
200 * source. After calling <code>Close()</code>, no new frames will be received. | 198 * source. After calling <code>Close()</code>, no new buffers will be |
| 199 * received. |
201 * | 200 * |
202 * @param[in] audio_track A <code>PP_Resource</code> corresponding to a | 201 * @param[in] audio_track A <code>PP_Resource</code> corresponding to a |
203 * MediaStream audio track resource. | 202 * MediaStream audio track resource. |
204 */ | 203 */ |
205 void (*Close)(PP_Resource audio_track); | 204 void (*Close)(PP_Resource audio_track); |
206 }; | 205 }; |
207 /** | 206 /** |
208 * @} | 207 * @} |
209 */ | 208 */ |
210 | 209 |
211 #endif /* PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ */ | 210 #endif /* PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ */ |
212 | 211 |
OLD | NEW |