Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 /// A constructor used when you have received a <code>PP_Resource</code> as a | |
| 32 /// return value that has had 1 ref added for you. | |
| 33 /// | |
| 34 /// @para[in] resource A <code>PPB_MediaStreamVideoTrack</code> resource. | |
|
yzshen1
2013/12/26 17:52:22
para -> param
Peng
2013/12/26 18:33:41
Done.
| |
| 35 MediaStreamVideoTrack(PassRef, PP_Resource resource); | |
| 36 | |
| 37 ~MediaStreamVideoTrack(); | |
| 38 | |
| 39 /// Configures underlaying frame buffers for incoming frames. | |
| 40 /// If the application doesn't want to drop frames, then the | |
| 41 /// |max_buffered_frames| should be chosen such that inter-frame | |
| 42 /// processing time variability won't overrun the input buffer. If the buffer | |
| 43 /// is overfilled, then frames will be dropped. The application can detect | |
| 44 /// this by examining the timestamp on returned frames. If |Configure()| is | |
| 45 /// not used, default settings will be used. | |
| 46 /// | |
| 47 /// @param[in] max_buffered_frames The maximum number of video frames to | |
| 48 /// hold in input buffer. | |
| 49 /// | |
| 50 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 51 int32_t Configure(uint32_t max_buffered_frames); | |
| 52 | |
| 53 /// Returns the track ID of the underlying MediaStream video track. | |
| 54 std::string GetId() const; | |
| 55 | |
| 56 /// Checks whether the underlying MediaStream track has ended. | |
| 57 /// Calls to GetFrame while the track has ended are safe to make and will | |
| 58 /// complete, but will fail. | |
| 59 bool HasEnded() const; | |
| 60 | |
| 61 /// Gets the next video frame from the MediaStream track. | |
| 62 /// If internal processing is slower than the incoming frame rate, new frames | |
| 63 /// will be dropped from the incoming stream. Once the input buffer is full, | |
| 64 /// frames will be dropped until |RecycleFrame()| is called to free a spot for | |
| 65 /// another frame to be buffered. If the caller holds a frame returned by | |
| 66 /// the previous call of |GetFrame()|, <code>PP_ERROR_INGROGRESS</code> will | |
| 67 /// be returned. The caller should recycle the previous frame, before getting | |
| 68 /// the next frame. | |
| 69 /// | |
| 70 /// @param[in] callback A <code>PP_CompletionCallback</code> to be called upon | |
| 71 /// completion of |GetFrame()|. If success, a VideoFrame will be passed into | |
| 72 /// the completion callback function. | |
| 73 /// | |
| 74 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 75 /// Returns PP_ERROR_NOMEMORY if |frame_buffer_size| frames buffer was not | |
| 76 /// allocated successfully. | |
| 77 int32_t GetFrame( | |
| 78 const CompletionCallbackWithOutput<VideoFrame>& cc); | |
| 79 | |
| 80 /// Recycles a frame returned by |GetFrame()|, so the track can reuse | |
| 81 /// the underlaying buffer of this frame. And the frame will become invalid. | |
| 82 /// The caller should release all references it holds to |frame|, and not use | |
| 83 /// it anymore. | |
| 84 /// | |
| 85 /// @param[in] frame A VideoFrame returned by |GetFrame()|. | |
| 86 /// | |
| 87 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 88 int32_t RecycleFrame(const VideoFrame& frame); | |
| 89 | |
| 90 /// Closes the MediaStream video track, and disconnects it from video source. | |
| 91 /// After calling |Close()|, no new frames will be received. | |
| 92 /// | |
| 93 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. | |
| 94 int32_t Close(); | |
| 95 | |
| 96 }; | |
| 97 | |
| 98 } // namespace pp | |
| 99 | |
| 100 #endif // PPAPI_CPP_MEDIA_STREAM_VIDEO_TRACK_H_ | |
| OLD | NEW |