Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: ppapi/cpp/video_frame.h

Issue 13461010: Add PP_VideoFrame, PPB_VideoReader, and PPB_VideoWriter APIs to Pepper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revise API after design review, address review comments. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_VIDEO_FRAME_H_
6 #define PPAPI_CPP_VIDEO_FRAME_H_
7
8 #include "ppapi/c/pp_time.h"
9 #include "ppapi/c/pp_video_frame.h"
10 #include "ppapi/cpp/completion_callback.h"
11 #include "ppapi/cpp/image_data.h"
12 #include "ppapi/cpp/pass_ref.h"
13
14 /// @file
15 /// This file defines the video frame struct used by video readers and writers.
16
17 namespace pp {
18
19 // VideoFrame ------------------------------------------------------------------
20
21 /// The <code>VideoFrame</code> class represents a frame of video in a stream.
22 class VideoFrame {
23 public:
24 /// Default constructor for creating a <code>VideoFrame</code> object.
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
32 /// The copy constructor for <code>VideoFrame</code>.
33 ///
34 /// @param[in] other A reference to a <code>VideoFrame</code>.
35 VideoFrame(const VideoFrame& other);
36
37 ~VideoFrame();
38
39 VideoFrame& operator=(const VideoFrame& other);
40
41 const PP_VideoFrame& pp_video_frame() const {
42 return video_frame_;
43 }
44
45 ImageData image_data() const {
46 return image_data_;
47 }
48 void set_image_data(const ImageData& image_data) {
49 image_data_ = image_data;
50 // The assignment above manages the underlying PP_Resources. Copy the new
51 // one into our internal video frame struct.
52 video_frame_.image_data = image_data_.pp_resource();
53 }
54
55 PP_TimeTicks timestamp() const { return video_frame_.timestamp; }
56 void set_timestamp(PP_TimeTicks timestamp) {
57 video_frame_.timestamp = timestamp;
58 }
59
60 private:
61 ImageData image_data_; // This manages the PP_Resource in video_frame_.
62 PP_VideoFrame video_frame_;
63 };
64
65 namespace internal {
66
67 // A specialization of CallbackOutputTraits to provide the callback system the
68 // information on how to handle pp::VideoFrame. This converts PP_VideoFrame to
69 // pp::VideoFrame when passing to the plugin, and specifically manages the
70 // PP_Resource embedded in the video_frame_ field.
71 template<>
72 struct CallbackOutputTraits<pp::VideoFrame> {
73 typedef PP_VideoFrame* APIArgType;
74 typedef PP_VideoFrame StorageType;
75
76 static inline APIArgType StorageToAPIArg(StorageType& t) {
77 return &t;
78 }
79
80 static inline pp::VideoFrame StorageToPluginArg(StorageType& t) {
81 return pp::VideoFrame(PASS_REF, t);
82 }
83 };
84
85 } // namespace internal
86
87 } // namespace pp
88
89 #endif // PPAPI_CPP_VIDEO_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698