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.
6 /* From ppb_media_stream_video_track.idl modified Wed Feb 19 11:06:48 2014. */
8 #ifndef PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_
9 #define PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_macros.h"
14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_var.h"
18 #define PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1 \
19 "PPB_MediaStreamVideoTrack;0.1" /* dev */
22 * Defines the <code>PPB_MediaStreamVideoTrack</code> interface. Used for
23 * receiving video frames from a MediaStream video track in the browser.
24 * This interface is still in development (Dev API status) and may change.
33 * This enumeration contains video track attributes which are used by
34 * <code>Configure()</code>.
38 * Attribute list terminator.
40 PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE
= 0,
42 * The maximum number of frames to hold in the input buffer.
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 -
45 * request at least 2 to make sure latency doesn't cause lost frames. If
46 * the plugin expects to hold on to more than one frame at a time (e.g. to do
47 * multi-frame processing), it should request that many more.
48 * If this attribute is not specified or value 0 is specified for this
49 * attribute, the default value will be used.
51 PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES
= 1,
53 * The width of video frames in pixels. It should be a multiple of 4.
54 * If the specified size is different from the video source (webcam),
55 * frames will be scaled to specified size.
56 * If this attribute is not specified or value 0 is specified, the original
57 * frame size of the video track will be used.
59 * Maximum value: 4096 (4K resolution).
61 PP_MEDIASTREAMVIDEOTRACK_ATTRIB_WIDTH
= 2,
63 * The height of video frames in pixels. It should be a multiple of 4.
64 * If the specified size is different from the video source (webcam),
65 * frames will be scaled to specified size.
66 * If this attribute is not specified or value 0 is specified, the original
67 * frame size of the video track will be used.
69 * Maximum value: 4096 (4K resolution).
71 PP_MEDIASTREAMVIDEOTRACK_ATTRIB_HEIGHT
= 3,
73 * The format of video frames. The attribute value is
74 * a <code>PP_VideoFrame_Format</code>. If the specified format is different
75 * from the video source (webcam), frames will be converted to specified
77 * If this attribute is not specified or value
78 * <code>PP_VIDEOFRAME_FORMAT_UNKNOWN</code> is specified, the orignal frame
79 * format of the video track will be used.
81 PP_MEDIASTREAMVIDEOTRACK_ATTRIB_FORMAT
= 4
82 } PP_MediaStreamVideoTrack_Attrib
;
88 * @addtogroup Interfaces
91 struct PPB_MediaStreamVideoTrack_0_1
{ /* dev */
93 * Determines if a resource is a MediaStream video track resource.
95 * @param[in] resource The <code>PP_Resource</code> to test.
97 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
98 * resource is a Mediastream video track resource or <code>PP_FALSE</code>
101 PP_Bool (*IsMediaStreamVideoTrack
)(PP_Resource resource
);
103 * Configures underlying frame buffers for incoming frames.
104 * If the application doesn't want to drop frames, then the
105 * <code>PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES</code> should be
106 * chosen such that inter-frame processing time variability won't overrun the
107 * input buffer. If the buffer is overfilled, then frames will be dropped.
108 * The application can detect this by examining the timestamp on returned
109 * frames. If some attributes are not specified, default values will be used
110 * for those unspecified attributes. If <code>Configure()</code> is not
111 * called, default settings will be used.
112 * Example usage from plugin code:
114 * int32_t attribs[] = {
115 * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_BUFFERED_FRAMES, 4,
116 * PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE};
117 * track_if->Configure(track, attribs, callback);
120 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video
122 * @param[in] attrib_list A list of attribute name-value pairs in which each
123 * attribute is immediately followed by the corresponding desired value.
124 * The list is terminated by
125 * <code>PP_MEDIASTREAMVIDEOTRACK_ATTRIB_NONE</code>.
126 * @param[in] callback <code>PP_CompletionCallback</code> to be called upon
127 * completion of <code>Configure()</code>.
129 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
130 * Returns <code>PP_ERROR_INPROGRESS</code> if there is a pending call of
131 * <code>Configure()</code> or <code>GetFrame()</code>, or the plugin
132 * holds some frames which are not recycled with <code>RecycleFrame()</code>.
133 * If an error is returned, all attributes and the underlying buffer will not
136 int32_t (*Configure
)(PP_Resource video_track
,
137 const int32_t attrib_list
[],
138 struct PP_CompletionCallback callback
);
140 * Gets attribute value for a given attribute name.
142 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video
144 * @param[in] attrib A <code>PP_MediaStreamVideoTrack_Attrib</code> for
146 * @param[out] value A int32_t for storing the attribute value on success.
147 * Otherwise, the value will not be changed.
149 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
151 int32_t (*GetAttrib
)(PP_Resource video_track
,
152 PP_MediaStreamVideoTrack_Attrib attrib
,
155 * Returns the track ID of the underlying MediaStream video track.
157 * @param[in] video_track The <code>PP_Resource</code> to check.
159 * @return A <code>PP_Var</code> containing the MediaStream track ID as
162 struct PP_Var (*GetId
)(PP_Resource video_track
);
164 * Checks whether the underlying MediaStream track has ended.
165 * Calls to GetFrame while the track has ended are safe to make and will
166 * complete, but will fail.
168 * @param[in] video_track The <code>PP_Resource</code> to check.
170 * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
171 * MediaStream track has ended or <code>PP_FALSE</code> otherwise.
173 PP_Bool (*HasEnded
)(PP_Resource video_track
);
175 * Gets the next video frame from the MediaStream track.
176 * If internal processing is slower than the incoming frame rate, new frames
177 * will be dropped from the incoming stream. Once the input buffer is full,
178 * frames will be dropped until <code>RecycleFrame()</code> is called to free
179 * a spot for another frame to be buffered.
180 * If there are no frames in the input buffer,
181 * <code>PP_OK_COMPLETIONPENDING</code> will be returned immediately and the
182 * <code>callback</code> will be called when a new frame is received or an
185 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video
187 * @param[out] frame A <code>PP_Resource</code> corresponding to a VideoFrame
189 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
190 * completion of GetFrame().
192 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
193 * Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames buffer
194 * was not allocated successfully.
196 int32_t (*GetFrame
)(PP_Resource video_track
,
198 struct PP_CompletionCallback callback
);
200 * Recycles a frame returned by <code>GetFrame()</code>, so the track can
201 * reuse the underlying buffer of this frame. And the frame will become
202 * invalid. The caller should release all references it holds to
203 * <code>frame</code> and not use it anymore.
205 * @param[in] video_track A <code>PP_Resource</code> corresponding to a video
207 * @param[in] frame A <code>PP_Resource</code> corresponding to a VideoFrame
208 * resource returned by <code>GetFrame()</code>.
210 * @return An int32_t containing a result code from <code>pp_errors.h</code>.
212 int32_t (*RecycleFrame
)(PP_Resource video_track
, PP_Resource frame
);
214 * Closes the MediaStream video track and disconnects it from video source.
215 * After calling <code>Close()</code>, no new frames will be received.
217 * @param[in] video_track A <code>PP_Resource</code> corresponding to a
218 * MediaStream video track resource.
220 void (*Close
)(PP_Resource video_track
);
226 #endif /* PPAPI_C_PPB_MEDIA_STREAM_VIDEO_TRACK_H_ */