OLD | NEW |
---|---|
(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_reader.h" | |
6 | |
7 #include "ppapi/c/pp_errors.h" | |
8 #include "ppapi/c/ppb_video_reader.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_VideoReader_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_VIDEOREADER_INTERFACE_1_0; | |
21 } | |
22 | |
23 } // namespace | |
24 | |
25 // VideoReader ----------------------------------------------------------------- | |
26 | |
27 VideoReader::VideoReader() { | |
28 } | |
29 | |
30 VideoReader::VideoReader(const InstanceHandle& instance) { | |
31 if (!has_interface<PPB_VideoReader_1_0>()) | |
32 return; | |
33 PassRefFromConstructor(get_interface<PPB_VideoReader_1_0>()->Create( | |
34 instance.pp_instance())); | |
35 } | |
36 | |
37 VideoReader::VideoReader(const VideoReader& other) | |
38 : Resource(other) { | |
39 } | |
40 | |
41 VideoReader::VideoReader(PassRef, PP_Resource resource) | |
42 : Resource(PASS_REF, resource) { | |
43 } | |
44 | |
45 int32_t VideoReader::Open(const std::string& stream_id, | |
46 const CompletionCallback& cc) { | |
47 if (has_interface<PPB_VideoReader_1_0>()) { | |
48 Var id(stream_id); | |
49 int32_t result = | |
50 get_interface<PPB_VideoReader_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 VideoReader::GetFrame( | |
59 const CompletionCallbackWithOutput<VideoFrame>& cc) { | |
60 if (has_interface<PPB_VideoReader_1_0>()) { | |
61 return get_interface<PPB_VideoReader_1_0>()->GetFrame( | |
62 pp_resource(), | |
63 cc.output(), cc.pp_completion_callback()); | |
64 } | |
65 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
66 } | |
67 | |
68 void VideoReader::Close() { | |
69 if (has_interface<PPB_VideoReader_1_0>()) { | |
70 get_interface<PPB_VideoReader_1_0>()->Close(pp_resource()); | |
71 } | |
72 } | |
73 | |
74 } // namespace pp | |
OLD | NEW |