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

Side by Side Diff: ppapi/cpp/video.cc

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: 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 #include "ppapi/cpp/video.h"
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_var.h"
9 #include "ppapi/c/ppb_video_reader.h"
10 #include "ppapi/c/ppb_video_writer.h"
11 #include "ppapi/cpp/completion_callback.h"
12 #include "ppapi/cpp/image_data.h"
13 #include "ppapi/cpp/instance_handle.h"
14 #include "ppapi/cpp/module.h"
15 #include "ppapi/cpp/module_impl.h"
16 #include "ppapi/cpp/var.h"
17
18 namespace pp {
19
20 namespace {
21
22 template <> const char* interface_name<PPB_VideoReader_1_0>() {
23 return PPB_VIDEOREADER_INTERFACE_1_0;
24 }
25 template <> const char* interface_name<PPB_VideoWriter_1_0>() {
26 return PPB_VIDEOWRITER_INTERFACE_1_0;
27 }
28
29 } // namespace
30
31 // VideoFrame ------------------------------------------------------------------
32
33 VideoFrame::VideoFrame() {
34 video_frame_.image_data = image_data_.pp_resource();
35 set_timestamp(0);
36 }
37
38 VideoFrame::VideoFrame(
39 PassRef,
40 const PP_VideoFrame& pp_video_frame) {
41 video_frame_ = pp_video_frame;
42 image_data_ = ImageData(PASS_REF, pp_video_frame.image_data);
43 }
44
45 VideoFrame::VideoFrame(const VideoFrame& other) {
46 set_image_data(other.image_data());
47 set_timestamp(other.timestamp());
48 }
49
50 VideoFrame::~VideoFrame() {
51 }
52
53 VideoFrame& VideoFrame::operator=(const VideoFrame& other) {
54 if (this == &other)
55 return *this;
56
57 video_frame_ = other.video_frame_;
58 // Be careful about the refcount of the resource, the assignment above doesn't
59 // copy a ref. The assignments below take a ref to the new image data and copy
60 // the PP_Resource into the wrapped video frame.
61 image_data_ = other.image_data();
62 video_frame_.image_data = image_data_.pp_resource();
yzshen1 2013/04/02 19:28:39 It seems line 62 is not needed because line 57 has
bbudge 2013/04/03 10:42:29 Done.
63
64 return *this;
65 }
66
67 // VideoReader -----------------------------------------------------------------
68
69 VideoReader::VideoReader() {
70 }
71
72 VideoReader::VideoReader(const InstanceHandle& instance) {
73 if (!has_interface<PPB_VideoReader_1_0>())
74 return;
75 PassRefFromConstructor(get_interface<PPB_VideoReader_1_0>()->Create(
76 instance.pp_instance()));
77 }
78
79 VideoReader::VideoReader(const VideoReader& other)
80 : Resource(other) {
81 }
82
83 VideoReader::VideoReader(PassRef, PP_Resource resource)
84 : Resource(PASS_REF, resource) {
85 }
86
87 int32_t VideoReader::Open(const Var& stream_id,
88 const CompletionCallback& cc) {
89 if (has_interface<PPB_VideoReader_1_0>()) {
90 int32_t result =
91 get_interface<PPB_VideoReader_1_0>()->Open(
92 pp_resource(),
93 stream_id.pp_var(), cc.pp_completion_callback());
94 return result;
95 }
96 return cc.MayForce(PP_ERROR_NOINTERFACE);
97 }
98
99 int32_t VideoReader::Close() {
100 if (has_interface<PPB_VideoReader_1_0>()) {
101 return get_interface<PPB_VideoReader_1_0>()->Close(pp_resource());
102 }
103 return PP_ERROR_NOINTERFACE;
104 }
105
106 int32_t VideoReader::GetNextFrame(
107 const CompletionCallbackWithOutput<VideoFrame>& cc) {
108 if (has_interface<PPB_VideoReader_1_0>()) {
109 return get_interface<PPB_VideoReader_1_0>()->GetNextFrame(
110 pp_resource(),
111 cc.output(), cc.pp_completion_callback());
112 }
113 return cc.MayForce(PP_ERROR_NOINTERFACE);
114 }
115
yzshen1 2013/04/02 19:28:39 The writer implementation is missing.
bbudge 2013/04/03 10:42:29 Done.
116 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698