| 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_FRAME_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_ |
| 6 #define PPAPI_CPP_VIDEO_FRAME_H_ | 6 #define PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_time.h" | 8 #include "ppapi/c/pp_time.h" |
| 9 #include "ppapi/c/pp_video_frame.h" | 9 #include "ppapi/c/private/pp_video_frame_private.h" |
| 10 #include "ppapi/cpp/completion_callback.h" | 10 #include "ppapi/cpp/completion_callback.h" |
| 11 #include "ppapi/cpp/image_data.h" | 11 #include "ppapi/cpp/image_data.h" |
| 12 #include "ppapi/cpp/pass_ref.h" | 12 #include "ppapi/cpp/pass_ref.h" |
| 13 | 13 |
| 14 /// @file | 14 /// @file |
| 15 /// This file defines the video frame struct used by video readers and writers. | 15 /// This file defines the struct used to hold a video frame. |
| 16 | 16 |
| 17 namespace pp { | 17 namespace pp { |
| 18 | 18 |
| 19 // VideoFrame ------------------------------------------------------------------ | 19 /// The <code>PP_VideoFrame_Private</code> struct represents a video frame. |
| 20 /// Video sources and destinations use frames to transfer video to and from |
| 21 /// the browser. |
| 22 class VideoFrame_Private { |
| 23 public: |
| 24 /// Default constructor for creating a <code>VideoFrame_Private</code> object. |
| 25 VideoFrame_Private(); |
| 20 | 26 |
| 21 /// The <code>VideoFrame</code> class represents a frame of video in a stream. | 27 /// Constructor that takes an existing <code>PP_VideoFrame_Private</code> |
| 22 class VideoFrame { | 28 /// structure. The 'image_data' PP_Resource field in the structure will be |
| 23 public: | 29 /// managed by this instance. |
| 24 /// Default constructor for creating a <code>VideoFrame</code> object. | 30 VideoFrame_Private(PassRef, const PP_VideoFrame_Private& pp_video_frame); |
| 25 VideoFrame(); | |
| 26 | |
| 27 /// Constructor that takes an existing <code>PP_VideoFrame</code> structure. | |
| 28 /// The 'image_data' PP_Resource field in the structure will be managed by | |
| 29 /// this instance. | |
| 30 VideoFrame(PassRef, const PP_VideoFrame& pp_video_frame); | |
| 31 | 31 |
| 32 /// Constructor that takes an existing <code>ImageData</code> instance and | 32 /// Constructor that takes an existing <code>ImageData</code> instance and |
| 33 /// a timestamp. | 33 /// a timestamp. |
| 34 VideoFrame(const ImageData& image_data, PP_TimeTicks timestamp); | 34 VideoFrame_Private(const ImageData& image_data, PP_TimeTicks timestamp); |
| 35 | 35 |
| 36 /// The copy constructor for <code>VideoFrame</code>. | 36 /// The copy constructor for <code>VideoFrame_Private</code>. |
| 37 /// | 37 /// |
| 38 /// @param[in] other A reference to a <code>VideoFrame</code>. | 38 /// @param[in] other A reference to a <code>VideoFrame_Private</code>. |
| 39 VideoFrame(const VideoFrame& other); | 39 VideoFrame_Private(const VideoFrame_Private& other); |
| 40 | 40 |
| 41 ~VideoFrame(); | 41 ~VideoFrame_Private(); |
| 42 | 42 |
| 43 VideoFrame& operator=(const VideoFrame& other); | 43 /// The assignment operator for <code>VideoFrame_Private</code>. |
| 44 /// |
| 45 /// @param[in] other A reference to a <code>VideoFrame_Private</code>. |
| 46 VideoFrame_Private& operator=(const VideoFrame_Private& other); |
| 44 | 47 |
| 45 const PP_VideoFrame& pp_video_frame() const { | 48 const PP_VideoFrame_Private& pp_video_frame() const { |
| 46 return video_frame_; | 49 return video_frame_; |
| 47 } | 50 } |
| 48 | 51 |
| 49 ImageData image_data() const { | 52 ImageData image_data() const { |
| 50 return image_data_; | 53 return image_data_; |
| 51 } | 54 } |
| 52 void set_image_data(const ImageData& image_data) { | 55 void set_image_data(const ImageData& image_data) { |
| 53 image_data_ = image_data; | 56 image_data_ = image_data; |
| 54 // The assignment above manages the underlying PP_Resources. Copy the new | 57 // The assignment above manages the underlying PP_Resources. Copy the new |
| 55 // one into our internal video frame struct. | 58 // one into our internal video frame struct. |
| 56 video_frame_.image_data = image_data_.pp_resource(); | 59 video_frame_.image_data = image_data_.pp_resource(); |
| 57 } | 60 } |
| 58 | 61 |
| 59 PP_TimeTicks timestamp() const { return video_frame_.timestamp; } | 62 PP_TimeTicks timestamp() const { return video_frame_.timestamp; } |
| 60 void set_timestamp(PP_TimeTicks timestamp) { | 63 void set_timestamp(PP_TimeTicks timestamp) { |
| 61 video_frame_.timestamp = timestamp; | 64 video_frame_.timestamp = timestamp; |
| 62 } | 65 } |
| 63 | 66 |
| 64 private: | 67 private: |
| 65 ImageData image_data_; // This manages the PP_Resource in video_frame_. | 68 ImageData image_data_; // This manages the PP_Resource in video_frame_. |
| 66 PP_VideoFrame video_frame_; | 69 PP_VideoFrame_Private video_frame_; |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 namespace internal { | 72 namespace internal { |
| 70 | 73 |
| 71 // A specialization of CallbackOutputTraits to provide the callback system the | 74 // A specialization of CallbackOutputTraits to provide the callback system the |
| 72 // information on how to handle pp::VideoFrame. This converts PP_VideoFrame to | 75 // information on how to handle pp::VideoFrame_Private. This converts |
| 73 // pp::VideoFrame when passing to the plugin, and specifically manages the | 76 // PP_VideoFrame_Private to pp::VideoFrame_Private when passing to the plugin, |
| 74 // PP_Resource embedded in the video_frame_ field. | 77 // and specifically manages the PP_Resource embedded in the video_frame_ field. |
| 75 template<> | 78 template<> |
| 76 struct CallbackOutputTraits<pp::VideoFrame> { | 79 struct CallbackOutputTraits<pp::VideoFrame_Private> { |
| 77 typedef PP_VideoFrame* APIArgType; | 80 typedef PP_VideoFrame_Private* APIArgType; |
| 78 typedef PP_VideoFrame StorageType; | 81 typedef PP_VideoFrame_Private StorageType; |
| 79 | 82 |
| 80 static inline APIArgType StorageToAPIArg(StorageType& t) { | 83 static inline APIArgType StorageToAPIArg(StorageType& t) { |
| 81 return &t; | 84 return &t; |
| 82 } | 85 } |
| 83 | 86 |
| 84 static inline pp::VideoFrame StorageToPluginArg(StorageType& t) { | 87 static inline pp::VideoFrame_Private StorageToPluginArg(StorageType& t) { |
| 85 return pp::VideoFrame(PASS_REF, t); | 88 return pp::VideoFrame_Private(PASS_REF, t); |
| 86 } | 89 } |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 } // namespace internal | 92 } // namespace internal |
| 90 | 93 |
| 91 } // namespace pp | 94 } // namespace pp |
| 92 | 95 |
| 93 #endif // PPAPI_CPP_VIDEO_FRAME_H_ | 96 #endif // PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_ |
| OLD | NEW |