| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef PPAPI_CPP_VIDEO_READER_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_ |
| 6 #define PPAPI_CPP_VIDEO_READER_H_ | 6 #define PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
| 11 #include "ppapi/cpp/completion_callback.h" | 11 #include "ppapi/cpp/completion_callback.h" |
| 12 #include "ppapi/cpp/pass_ref.h" | 12 #include "ppapi/cpp/pass_ref.h" |
| 13 #include "ppapi/cpp/resource.h" | 13 #include "ppapi/cpp/resource.h" |
| 14 | 14 |
| 15 /// @file | 15 /// @file |
| 16 /// This file defines the API to create and use video stream readers. | 16 /// This file defines the <code>PPB_VideoSource_Private</code> interface for a |
| 17 /// video source resource. A video source receives video frames from a |
| 18 /// MediaStream video track. |
| 17 | 19 |
| 18 namespace pp { | 20 namespace pp { |
| 19 | 21 |
| 20 class InstanceHandle; | 22 class InstanceHandle; |
| 21 class VideoFrame; | 23 class VideoFrame_Private; |
| 22 | 24 |
| 23 // VideoReader ----------------------------------------------------------------- | 25 /// The <code>VideoSource_Private</code> class contains methods for creating |
| 26 /// video source resources and using them to receive video frames from a |
| 27 /// MediaStream in the browser. |
| 28 class VideoSource_Private : public Resource { |
| 29 public: |
| 30 /// Default constructor for creating a <code>VideoSource_Private</code> |
| 31 /// object. |
| 32 VideoSource_Private(); |
| 24 | 33 |
| 25 /// The <code>VideoReader</code> class represents a video reader resource. | 34 /// Constructor for creating a <code>VideoSource_Private</code> for an |
| 26 class VideoReader : public Resource { | 35 /// instance. |
| 27 public: | 36 explicit VideoSource_Private(const InstanceHandle& instance); |
| 28 /// Default constructor for creating a <code>VideoReader</code> object. | |
| 29 VideoReader(); | |
| 30 | 37 |
| 31 /// Constructor for creating a <code>VideoReader</code> for an instance. | 38 /// The copy constructor for <code>VideoSource_Private</code>. |
| 32 explicit VideoReader(const InstanceHandle& instance); | |
| 33 | |
| 34 /// The copy constructor for <code>VideoReader</code>. | |
| 35 /// | 39 /// |
| 36 /// @param[in] other A reference to a <code>VideoReader</code>. | 40 /// @param[in] other A reference to a <code>VideoSource_Private</code>. |
| 37 VideoReader(const VideoReader& other); | 41 VideoSource_Private(const VideoSource_Private& other); |
| 38 | 42 |
| 39 /// A constructor used when you have received a PP_Resource as a return | 43 /// A constructor used when you have received a PP_Resource as a return |
| 40 /// value that has had its reference count incremented for you. | 44 /// value that has had its reference count incremented for you. |
| 41 /// | 45 /// |
| 42 /// @param[in] resource A PP_Resource corresponding to a video reader. | 46 /// @param[in] resource A PP_Resource corresponding to a video source. |
| 43 VideoReader(PassRef, PP_Resource resource); | 47 VideoSource_Private(PassRef, PP_Resource resource); |
| 44 | 48 |
| 45 /// Opens a stream for reading video and associates it with the given id. | 49 /// Opens a video source to emit frames. |
| 46 /// | 50 /// |
| 47 /// @param[in] stream_id A <code>Var</code> uniquely identifying the stream | 51 /// @param[in] stream_url A <code>Var</code> string holding a URL identifying |
| 48 /// to read from. | 52 /// a MediaStream. |
| 49 /// @param[in] callback A <code>CompletionCallback</code> to be called upon | 53 /// @param[in] callback A <code>CompletionCallback</code> to be called upon |
| 50 /// completion of Open. | 54 /// completion of Open(). |
| 51 /// | 55 /// |
| 52 /// @return A return code from <code>pp_errors.h</code>. | 56 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 53 int32_t Open(const Var& stream_id, | 57 /// Returns PP_ERROR_BADRESOURCE if source isn't a valid video source. |
| 58 /// Returns PP_ERROR_INPROGRESS if source is already open. |
| 59 /// Returns PP_ERROR_FAILED if the MediaStream doesn't exist or if there is |
| 60 /// some other browser error. |
| 61 int32_t Open(const Var& stream_url, |
| 54 const CompletionCallback& cc); | 62 const CompletionCallback& cc); |
| 55 | 63 |
| 56 /// Gets the next frame of video from the reader's stream. | 64 /// Passes a frame from the video source to the plugin. |
| 57 /// | 65 /// |
| 66 /// @param[out] frame A <code>VideoFrame_Private</code> to hold a video |
| 67 /// frame from the source. |
| 58 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be | 68 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be |
| 59 /// called upon completion of GetNextFrame. | 69 /// called upon completion of ReceiveFrame(). |
| 60 /// | 70 /// |
| 61 /// @return A return code from <code>pp_errors.h</code>. | 71 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 62 int32_t GetFrame(const CompletionCallbackWithOutput<VideoFrame>& cc); | 72 /// Returns PP_ERROR_BADRESOURCE if source isn't a valid video source. |
| 73 /// Returns PP_ERROR_FAILED if the source is not open, or if some other |
| 74 /// browser error occurs. |
| 75 int32_t EmitFrame( |
| 76 const CompletionCallbackWithOutput<VideoFrame_Private>& cc); |
| 63 | 77 |
| 64 /// Closes the reader's current stream. | 78 /// Closes the video source. |
| 65 void Close(); | 79 void Close(); |
| 66 }; | 80 }; |
| 67 | 81 |
| 68 } // namespace pp | 82 } // namespace pp |
| 69 | 83 |
| 70 #endif // PPAPI_CPP_VIDEO_READER_H_ | 84 #endif // PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_ |
| OLD | NEW |