Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: ppapi/cpp/media_stream_video_track.h

Issue 107083004: [PPAPI] API definition for video media stream artifacts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Update Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 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
5 #ifndef PPAPI_CPP_MEDIA_STREAM_VIDEO_TRACK_H_
6 #define PPAPI_CPP_MEDIA_STREAM_VIDEO_TRACK_H_
7
8 #include <string>
9
10 #include "ppapi/c/pp_stdint.h"
11 #include "ppapi/cpp/resource.h"
12
13 /// @file
14 /// This file defines the <code>MediaStreamVideoTrack</code> interface for a
15 /// video source resource, which receives video frames from a MediaStream video
16 /// track in the browser.
17
18 namespace pp {
19
20 class VideoFrame;
21 template <typename T> class CompletionCallbackWithOutput;
22
23 /// The <code>MediaStreamVideoTrack</code> class contains methods for
24 /// receiving video frames from a MediaStream video track in the browser.
25 class MediaStreamVideoTrack : public Resource {
26 public:
27 /// Default constructor for creating an is_null()
28 /// <code>MediaStreamVideoTrack</code> object.
29 MediaStreamVideoTrack();
30
31 /// The copy constructor for <code>MediaStreamVideoTrack</code>.
32 ///
33 /// @param[in] other A reference to a <code>MediaStreamVideoTrack</code>.
34 MediaStreamVideoTrack(const MediaStreamVideoTrack& other);
35
36 /// Constructs a <code>MediaStreamVideoTrack</code> from
37 /// a <code>Resource</code>.
38 ///
39 /// @param[in] resource A <code>Resource</code> containing a file system.
40 explicit MediaStreamVideoTrack(const Resource& resource);
41
42 /// A constructor used when you have received a <code>PP_Resource</code> as a
43 /// return value that has had 1 ref added for you.
44 ///
45 /// @param[in] resource A <code>PPB_MediaStreamVideoTrack</code> resource.
46 MediaStreamVideoTrack(PassRef, PP_Resource resource);
47
48 ~MediaStreamVideoTrack();
49
50 /// Configures underlaying frame buffers for incoming frames.
51 /// If the application doesn't want to drop frames, then the
52 /// <code>max_buffered_frames</code> should be chosen such that inter-frame
53 /// processing time variability won't overrun the input buffer. If the buffer
54 /// is overfilled, then frames will be dropped. The application can detect
55 /// this by examining the timestamp on returned frames.
56 /// If <code>Configure()</code> is not used, default settings will be used.
57 ///
58 /// @param[in] max_buffered_frames The maximum number of video frames to
59 /// hold in input buffer.
60 ///
61 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
62 int32_t Configure(uint32_t max_buffered_frames);
63
64 /// Returns the track ID of the underlying MediaStream video track.
65 std::string GetId() const;
66
67 /// Checks whether the underlying MediaStream track has ended.
68 /// Calls to GetFrame while the track has ended are safe to make and will
69 /// complete, but will fail.
70 bool HasEnded() const;
71
72 /// Gets the next video frame from the MediaStream track.
73 /// If internal processing is slower than the incoming frame rate, new frames
74 /// will be dropped from the incoming stream. Once the input buffer is full,
75 /// frames will be dropped until <code>RecycleFrame()</code> is called to free
76 /// a spot for another frame to be buffered.
77 /// If there is no frames in the input buffer,
78 /// <code>PP_OK_COMPLETIONPENDIN</code> will be returned immediatelly. And the
yzshen1 2013/12/27 17:40:08 PP_OK_COMPLETIONPENDIN*G*, immediate*l*y
Peng 2013/12/27 21:21:43 Done.
79 /// <code>callback</code> will be called, when a new frame is received or some
80 /// error happens.
81 /// If the caller holds a frame returned by the previous call of
82 /// <code>GetFrame()</code>, <code>PP_ERROR_INGROGRESS</code> will be
83 /// returned. The caller should recycle the previous frame, before getting
84 /// the next frame.
85 ///
86 /// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
87 /// completion of <code>GetFrame()</code>. If success, a VideoFrame will be
88 /// passed into the completion callback function.
89 ///
90 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
91 /// Returns PP_ERROR_NOMEMORY if <code>max_buffered_frames</code> frames
92 /// buffer was not allocated successfully.
93 int32_t GetFrame(
94 const CompletionCallbackWithOutput<VideoFrame>& callback);
95
96 /// Recycles a frame returned by <code>GetFrame()</code>, so the track can
97 /// reuse the underlaying buffer of this frame. And the frame will become
98 /// invalid. The caller should release all references it holds to
99 /// <code>frame</code>, and not use it anymore.
100 ///
101 /// @param[in] frame A VideoFrame returned by <code>GetFrame()</code>.
102 ///
103 /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
104 int32_t RecycleFrame(const VideoFrame& frame);
105
106 /// Closes the MediaStream video track, and disconnects it from video source.
107 /// After calling <code>Close()</code>, no new frames will be received.
108 void Close();
109
110 /// Checks whether a <code>Resource</code> is a MediaStream video track,
111 /// to test whether it is appropriate for use with the
112 /// <code>MediaStreamVideoTrack</code> constructor.
113 ///
114 /// @param[in] resource A <code>Resource</code> to test.
115 ///
116 /// @return True if <code>resource</code> is a MediaStream video track.
117 static bool IsMediaStreamVideoTrack(const Resource& resource);
yzshen1 2013/12/27 17:40:08 It seems we don't have this method for other cpp A
Peng 2013/12/27 21:21:43 It is useful for passing js object to NaCl.
118 };
119
120 } // namespace pp
121
122 #endif // PPAPI_CPP_MEDIA_STREAM_VIDEO_TRACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698