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_DESTINATION_PRIVATE_H_ |
6 #define PPAPI_CPP_VIDEO_READER_H_ | 6 #define PPAPI_CPP_PRIVATE_VIDEO_DESTINATION_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_VideoDestination_Private</code> interface |
| 17 /// for a video destination resource, which sends video frames to a MediaStream |
| 18 /// video track in the browser. |
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>VideoDestination_Private</code> class contains methods for |
| 26 /// creating video destination resources and using them to send video frames to |
| 27 /// a MediaStream video track in the browser. |
| 28 class VideoDestination_Private : public Resource { |
| 29 public: |
| 30 /// Default constructor for creating a <code>VideoDestination_Private</code> |
| 31 /// object. |
| 32 VideoDestination_Private(); |
24 | 33 |
25 /// The <code>VideoReader</code> class represents a video reader resource. | 34 /// Constructor for creating a <code>VideoDestination_Private</code> for an |
26 class VideoReader : public Resource { | 35 /// instance. |
27 public: | 36 explicit VideoDestination_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>VideoDestination_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>VideoDestination_Private</code>. |
37 VideoReader(const VideoReader& other); | 41 VideoDestination_Private(const VideoDestination_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 destination. |
43 VideoReader(PassRef, PP_Resource resource); | 47 VideoDestination_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 destination for putting 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 |
50 /// completion of Open. | 54 /// called upon 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 destination isn't a valid video |
54 const CompletionCallback& cc); | 58 /// destination. |
| 59 /// Returns PP_ERROR_INPROGRESS if destination is already open. |
| 60 /// Returns PP_ERROR_FAILED if the MediaStream doesn't exist or if there is |
| 61 /// some other browser error. |
| 62 int32_t Open(const Var& stream_url, const CompletionCallback& cc); |
55 | 63 |
56 /// Gets the next frame of video from the reader's stream. | 64 /// Puts a frame to the video destination. |
57 /// | 65 /// |
58 /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be | 66 /// After this call, you should take care to release your references to the |
59 /// called upon completion of GetNextFrame. | 67 /// image embedded in the video frame. If you paint to the image after |
| 68 /// PutFrame(), there is the possibility of artifacts because the browser may |
| 69 /// still be copying the frame to the stream. |
60 /// | 70 /// |
61 /// @return A return code from <code>pp_errors.h</code>. | 71 /// @param[in] frame A <code>VideoFrame_Private</code> holding the video |
62 int32_t GetFrame(const CompletionCallbackWithOutput<VideoFrame>& cc); | 72 /// frame to send to the destination. |
| 73 /// |
| 74 /// @return An int32_t containing a result code from <code>pp_errors.h</code>. |
| 75 /// Returns PP_ERROR_BADRESOURCE if destination isn't a valid video |
| 76 /// destination. |
| 77 /// Returns PP_ERROR_FAILED if destination is not open, if the video frame has |
| 78 /// an invalid image data resource, or if some other browser error occurs. |
| 79 int32_t PutFrame(const VideoFrame_Private& frame); |
63 | 80 |
64 /// Closes the reader's current stream. | 81 /// Closes the video destination. |
65 void Close(); | 82 void Close(); |
66 }; | 83 }; |
67 | 84 |
68 } // namespace pp | 85 } // namespace pp |
69 | 86 |
70 #endif // PPAPI_CPP_VIDEO_READER_H_ | 87 #endif // PPAPI_CPP_PRIVATE_VIDEO_DESTINATION_PRIVATE_H_ |
OLD | NEW |