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

Side by Side Diff: ppapi/cpp/video_writer.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: Add missed initializer. 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_writer.h"
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_video_writer.h"
9 #include "ppapi/cpp/instance_handle.h"
10 #include "ppapi/cpp/module.h"
11 #include "ppapi/cpp/module_impl.h"
12 #include "ppapi/cpp/var.h"
13 #include "ppapi/cpp/video_frame.h"
14
15 namespace pp {
16
17 namespace {
18
19 template <> const char* interface_name<PPB_VideoWriter_1_0>() {
yzshen1 2013/04/04 23:48:12 Please update the version number.
bbudge 2013/04/04 23:53:36 Done.
20 return PPB_VIDEOWRITER_INTERFACE_1_0;
21 }
22
23 } // namespace
24
25 // VideoWriter -----------------------------------------------------------------
26
27 VideoWriter::VideoWriter() {
28 }
29
30 VideoWriter::VideoWriter(const InstanceHandle& instance) {
31 if (!has_interface<PPB_VideoWriter_1_0>())
32 return;
33 PassRefFromConstructor(get_interface<PPB_VideoWriter_1_0>()->Create(
34 instance.pp_instance()));
35 }
36
37 VideoWriter::VideoWriter(const VideoWriter& other)
38 : Resource(other) {
39 }
40
41 VideoWriter::VideoWriter(PassRef, PP_Resource resource)
42 : Resource(PASS_REF, resource) {
43 }
44
45 int32_t VideoWriter::Open(const std::string& stream_id,
46 const CompletionCallback& cc) {
47 if (has_interface<PPB_VideoWriter_1_0>()) {
48 Var id(stream_id);
49 int32_t result =
50 get_interface<PPB_VideoWriter_1_0>()->Open(
51 pp_resource(),
52 id.pp_var(), cc.pp_completion_callback());
53 return result;
54 }
55 return cc.MayForce(PP_ERROR_NOINTERFACE);
56 }
57
58 int32_t VideoWriter::PutFrame(const VideoFrame& frame) {
59 if (has_interface<PPB_VideoWriter_1_0>()) {
60 return get_interface<PPB_VideoWriter_1_0>()->PutFrame(
61 pp_resource(),
62 &frame.pp_video_frame());
63 }
64 return PP_ERROR_NOINTERFACE;
65 }
66
67 void VideoWriter::Close() {
68 if (has_interface<PPB_VideoWriter_1_0>()) {
69 get_interface<PPB_VideoWriter_1_0>()->Close(pp_resource());
70 }
71 }
72
73 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698