Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / ppapi / cpp / private / video_frame_private.h
blob7413876e7d648a99e5f94a7b6c82031dbb17ba5c
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.
5 #ifndef PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_
6 #define PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_
8 #include <string.h>
10 #include "ppapi/c/pp_time.h"
11 #include "ppapi/c/private/pp_video_frame_private.h"
12 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/image_data.h"
14 #include "ppapi/cpp/pass_ref.h"
16 /// @file
17 /// This file defines the struct used to hold a video frame.
19 namespace pp {
21 /// The <code>PP_VideoFrame_Private</code> struct represents a video frame.
22 /// Video sources and destinations use frames to transfer video to and from
23 /// the browser.
24 class VideoFrame_Private {
25 public:
26 /// Default constructor for creating a <code>VideoFrame_Private</code> object.
27 VideoFrame_Private();
29 /// Constructor that takes an existing <code>PP_VideoFrame_Private</code>
30 /// structure. The 'image_data' PP_Resource field in the structure will be
31 /// managed by this instance.
32 VideoFrame_Private(PassRef, const PP_VideoFrame_Private& pp_video_frame);
34 /// Constructor that takes an existing <code>ImageData</code> instance and
35 /// a timestamp.
36 VideoFrame_Private(const ImageData& image_data, PP_TimeTicks timestamp);
38 /// The copy constructor for <code>VideoFrame_Private</code>.
39 ///
40 /// @param[in] other A reference to a <code>VideoFrame_Private</code>.
41 VideoFrame_Private(const VideoFrame_Private& other);
43 ~VideoFrame_Private();
45 /// The assignment operator for <code>VideoFrame_Private</code>.
46 ///
47 /// @param[in] other A reference to a <code>VideoFrame_Private</code>.
48 VideoFrame_Private& operator=(const VideoFrame_Private& other);
50 const PP_VideoFrame_Private& pp_video_frame() const {
51 return video_frame_;
54 ImageData image_data() const {
55 return image_data_;
57 void set_image_data(const ImageData& image_data) {
58 image_data_ = image_data;
59 // The assignment above manages the underlying PP_Resources. Copy the new
60 // one into our internal video frame struct.
61 video_frame_.image_data = image_data_.pp_resource();
64 PP_TimeTicks timestamp() const { return video_frame_.timestamp; }
65 void set_timestamp(PP_TimeTicks timestamp) {
66 video_frame_.timestamp = timestamp;
69 private:
70 ImageData image_data_; // This manages the PP_Resource in video_frame_.
71 PP_VideoFrame_Private video_frame_;
74 namespace internal {
76 // A specialization of CallbackOutputTraits to provide the callback system the
77 // information on how to handle pp::VideoFrame_Private. This converts
78 // PP_VideoFrame_Private to pp::VideoFrame_Private when passing to the plugin,
79 // and specifically manages the PP_Resource embedded in the video_frame_ field.
80 template<>
81 struct CallbackOutputTraits<pp::VideoFrame_Private> {
82 typedef PP_VideoFrame_Private* APIArgType;
83 typedef PP_VideoFrame_Private StorageType;
85 static inline APIArgType StorageToAPIArg(StorageType& t) {
86 return &t;
89 static inline pp::VideoFrame_Private StorageToPluginArg(StorageType& t) {
90 return pp::VideoFrame_Private(PASS_REF, t);
93 static inline void Initialize(StorageType* t) {
94 VideoFrame_Private dummy;
95 *t = dummy.pp_video_frame();
99 } // namespace internal
101 } // namespace pp
103 #endif // PPAPI_CPP_PRIVATE_VIDEO_FRAME_PRIVATE_H_