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_video_track.idl modified Fri Dec 27 17:28:11 2013. */ | 6 /* From ppb_media_stream_audio_track.idl modified Tue Jan 7 17:05:06 2014. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ | 8 #ifndef PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ |
9 #define PPAPI_C_PPB_MEDIA_STREAM_VIDEO_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_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1 \ | 18 #define PPB_MEDIASTREAMAUDIOTRACK_INTERFACE_0_1 \ |
19 "PPB_MediaStreamVideoTrack;0.1" /* dev */ | 19 "PPB_MediaStreamAudioTrack;0.1" /* dev */ |
20 /** | 20 /** |
21 * @file | 21 * @file |
22 * Defines the <code>PPB_MediaStreamVideoTrack</code> interface. Used for | 22 * Defines the <code>PPB_MediaStreamAudioTrack</code> interface. Used for |
23 * receiving video frames from a MediaStream video track in the browser. | 23 * receiving audio frames 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 Interfaces | 29 * @addtogroup Interfaces |
30 * @{ | 30 * @{ |
31 */ | 31 */ |
32 /** | 32 /** |
33 */ | 33 */ |
34 struct PPB_MediaStreamVideoTrack_0_1 { /* dev */ | 34 struct PPB_MediaStreamAudioTrack_0_1 { /* dev */ |
35 /** | 35 /** |
36 * Determines if a resource is a MediaStream video track resource. | 36 * Determines if a resource is a MediaStream audio track resource. |
37 * | 37 * |
38 * @param[in] resource The <code>PP_Resource</code> to test. | 38 * @param[in] resource The <code>PP_Resource</code> to test. |
39 * | 39 * |
40 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 40 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
41 * resource is a Mediastream video track resource or <code>PP_FALSE</code> | 41 * resource is a Mediastream audio track resource or <code>PP_FALSE</code> |
42 * otherwise. | 42 * otherwise. |
43 */ | 43 */ |
44 PP_Bool (*IsMediaStreamVideoTrack)(PP_Resource resource); | 44 PP_Bool (*IsMediaStreamAudioTrack)(PP_Resource resource); |
45 /** | 45 /** |
46 * Configures underlying frame buffers for incoming frames. | 46 * Configures underlying frame buffers for incoming frames. |
47 * If the application doesn't want to drop frames, then the | 47 * If the application doesn't want to drop frames, then the |
48 * <code>max_buffered_frames</code> should be chosen such that inter-frame | 48 * <code>max_buffered_frames</code> should be chosen such that inter-frame |
49 * processing time variability won't overrun the input buffer. If the buffer | 49 * processing time variability won't overrun the input buffer. If the buffer |
50 * is overfilled, then frames will be dropped. The application can detect | 50 * is overfilled, then frames will be dropped. The application can detect |
51 * this by examining the timestamp on returned frames. | 51 * this by examining the timestamp on returned frames. |
52 * If <code>Configure()</code> is not used, default settings will be used. | 52 * If <code>Configure()</code> is not used, default settings will be used. |
53 * | 53 * |
54 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video | 54 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
55 * resource. | 55 * resource. |
56 * @param[in] max_buffered_frames The maximum number of video frames to | 56 * @param[in] samples_per_frame The number of audio samples in an audio frame. |
| 57 * @param[in] max_buffered_frames The maximum number of audio frames to |
57 * hold in the input buffer. | 58 * hold in the input buffer. |
58 * | 59 * |
59 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 60 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
60 */ | 61 */ |
61 int32_t (*Configure)(PP_Resource video_track, uint32_t max_buffered_frames); | 62 int32_t (*Configure)(PP_Resource audio_track, |
| 63 uint32_t samples_per_frame, |
| 64 uint32_t max_buffered_frames); |
62 /** | 65 /** |
63 * Returns the track ID of the underlying MediaStream video track. | 66 * Returns the track ID of the underlying MediaStream audio track. |
64 * | 67 * |
65 * @param[in] video_track The <code>PP_Resource</code> to check. | 68 * @param[in] audio_track The <code>PP_Resource</code> to check. |
66 * | 69 * |
67 * @return A <code>PP_Var</code> containing the MediaStream track ID as | 70 * @return A <code>PP_Var</code> containing the MediaStream track ID as |
68 * a string. | 71 * a string. |
69 */ | 72 */ |
70 struct PP_Var (*GetId)(PP_Resource video_track); | 73 struct PP_Var (*GetId)(PP_Resource audio_track); |
71 /** | 74 /** |
72 * Checks whether the underlying MediaStream track has ended. | 75 * Checks whether the underlying MediaStream track has ended. |
73 * Calls to GetFrame while the track has ended are safe to make and will | 76 * Calls to GetFrame while the track has ended are safe to make and will |
74 * complete, but will fail. | 77 * complete, but will fail. |
75 * | 78 * |
76 * @param[in] video_track The <code>PP_Resource</code> to check. | 79 * @param[in] audio_track The <code>PP_Resource</code> to check. |
77 * | 80 * |
78 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given | 81 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given |
79 * MediaStream track has ended or <code>PP_FALSE</code> otherwise. | 82 * MediaStream track has ended or <code>PP_FALSE</code> otherwise. |
80 */ | 83 */ |
81 PP_Bool (*HasEnded)(PP_Resource video_track); | 84 PP_Bool (*HasEnded)(PP_Resource audio_track); |
82 /** | 85 /** |
83 * Gets the next video frame from the MediaStream track. | 86 * Gets the next audio frame from the MediaStream track. |
84 * If internal processing is slower than the incoming frame rate, new frames | 87 * If internal processing is slower than the incoming frame rate, new frames |
85 * will be dropped from the incoming stream. Once the input buffer is full, | 88 * will be dropped from the incoming stream. Once the input buffer is full, |
86 * frames will be dropped until <code>RecycleFrame()</code> is called to free | 89 * frames will be dropped until <code>RecycleFrame()</code> is called to free |
87 * a spot for another frame to be buffered. | 90 * a spot for another frame to be buffered. |
88 * If there are no frames in the input buffer, | 91 * If there are no frames in the input buffer, |
89 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the | 92 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the |
90 * <code>callback</code> will be called, when a new frame is received or an | 93 * <code>callback</code> will be called, when a new frame is received or an |
91 * error happens. | 94 * error happens. |
92 * If the caller holds a frame returned by the previous call of | |
93 * <code>GetFrame()</code>, <code>PP_ERROR_INPROGRESS</code> will be returned. | |
94 * The caller should recycle the previous frame before getting the next frame. | |
95 * | 95 * |
96 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video | 96 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
97 * resource. | 97 * resource. |
98 * @param[out] frame A <code>PP_Resource</code> corresponding to a VideoFrame | 98 * @param[out] frame A <code>PP_Resource</code> corresponding to an AudioFrame |
99 * resource. | 99 * resource. |
100 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | 100 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
101 * completion of GetFrame(). | 101 * completion of GetFrame(). |
102 * | 102 * |
103 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 103 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
104 * Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames buffer | 104 * Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames buffer |
105 * was not allocated successfully. | 105 * was not allocated successfully. |
106 */ | 106 */ |
107 int32_t (*GetFrame)(PP_Resource video_track, | 107 int32_t (*GetFrame)(PP_Resource audio_track, |
108 PP_Resource* frame, | 108 PP_Resource* frame, |
109 struct PP_CompletionCallback callback); | 109 struct PP_CompletionCallback callback); |
110 /** | 110 /** |
111 * Recycles a frame returned by <code>GetFrame()</code>, so the track can | 111 * Recycles a frame returned by <code>GetFrame()</code>, so the track can |
112 * reuse the underlying buffer of this frame. And the frame will become | 112 * reuse the underlying buffer of this frame. And the frame will become |
113 * invalid. The caller should release all references it holds to | 113 * invalid. The caller should release all references it holds to |
114 * <code>frame</code> and not use it anymore. | 114 * <code>frame</code> and not use it anymore. |
115 * | 115 * |
116 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video | 116 * @param[in] audio_track A <code>PP_Resource</code> corresponding to an audio |
117 * resource. | 117 * resource. |
118 * @param[in] frame A <code>PP_Resource</code> corresponding to a VideoFrame | 118 * @param[in] frame A <code>PP_Resource</code> corresponding to an AudioFrame |
119 * resource returned by <code>GetFrame()</code>. | 119 * resource returned by <code>GetFrame()</code>. |
120 * | 120 * |
121 * @return An int32_t containing a result code from <code>pp_errors.h</code>. | 121 * @return An int32_t containing a result code from <code>pp_errors.h</code>. |
122 */ | 122 */ |
123 int32_t (*RecycleFrame)(PP_Resource video_track, PP_Resource frame); | 123 int32_t (*RecycleFrame)(PP_Resource audio_track, PP_Resource frame); |
124 /** | 124 /** |
125 * Closes the MediaStream video track and disconnects it from video source. | 125 * Closes the MediaStream audio track and disconnects it from the audio |
126 * After calling <code>Close()</code>, no new frames will be received. | 126 * source. After calling <code>Close()</code>, no new frames will be received. |
127 * | 127 * |
128 * @param[in] video_track A <code>PP_Resource</code> corresponding to a | 128 * @param[in] audio_track A <code>PP_Resource</code> corresponding to a |
129 * MediaStream video track resource. | 129 * MediaStream audio track resource. |
130 */ | 130 */ |
131 void (*Close)(PP_Resource video_track); | 131 void (*Close)(PP_Resource audio_track); |
132 }; | 132 }; |
133 /** | 133 /** |
134 * @} | 134 * @} |
135 */ | 135 */ |
136 | 136 |
137 #endif /* PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ */ | 137 #endif /* PPAPI_C_PPB_MEDIA_STREAM_AUDIO_TRACK_H_ */ |
138 | 138 |
OLD | NEW |