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/media_stream_video_track.h" | |
6 | |
7 #include "ppapi/c/pp_errors.h" | |
8 #include "ppapi/c/ppb_media_stream_video_track.h" | |
9 #include "ppapi/cpp/completion_callback.h" | |
10 #include "ppapi/cpp/module_impl.h" | |
11 #include "ppapi/cpp/var.h" | |
12 #include "ppapi/cpp/video_frame.h" | |
13 | |
14 namespace pp { | |
15 | |
16 namespace { | |
17 | |
18 template <> const char* interface_name<PPB_MediaStreamVideoTrack_0_1>() { | |
19 return PPB_MEDIASTREAMVIDEOTRACK_INTERFACE_0_1; | |
20 } | |
21 | |
22 } // namespace | |
23 | |
24 MediaStreamVideoTrack::MediaStreamVideoTrack() { | |
25 } | |
26 | |
27 MediaStreamVideoTrack::MediaStreamVideoTrack(PassRef, PP_Resource resource) | |
28 : Resource(PASS_REF, resource) { | |
29 } | |
30 | |
31 MediaStreamVideoTrack::~MediaStreamVideoTrack() { | |
32 } | |
33 | |
34 int32_t MediaStreamVideoTrack::Configure(uint32_t frame_buffer_size) { | |
35 if (has_interface<PPB_MediaStreamVideoTrack_0_1>()) { | |
36 return get_interface<PPB_MediaStreamVideoTrack_0_1>()->Configure( | |
37 pp_resource(), frame_buffer_size); | |
38 } | |
39 return PP_ERROR_NOINTERFACE; | |
40 } | |
41 | |
42 std::string MediaStreamVideoTrack::GetId() const { | |
43 if (has_interface<PPB_MediaStreamVideoTrack_0_1>()) { | |
44 pp::Var id(PASS_REF, get_interface<PPB_MediaStreamVideoTrack_0_1>()->GetId( | |
45 pp_resource())); | |
46 if (id.is_string()) | |
47 return id.AsString(); | |
48 } | |
49 return std::string(); | |
50 } | |
51 | |
52 bool MediaStreamVideoTrack::HasEnded() const { | |
53 if (has_interface<PPB_MediaStreamVideoTrack_0_1>()) { | |
54 return PP_ToBool(get_interface<PPB_MediaStreamVideoTrack_0_1>()->HasEnded( | |
55 pp_resource())); | |
56 } | |
57 return true; | |
58 } | |
59 | |
60 int32_t MediaStreamVideoTrack::GetFrame( | |
61 const CompletionCallbackWithOutput<VideoFrame>& cc) { | |
62 if (has_interface<PPB_MediaStreamVideoTrack_0_1>()) { | |
63 return get_interface<PPB_MediaStreamVideoTrack_0_1>()->GetFrame( | |
64 pp_resource(), | |
65 cc.output(), | |
66 cc.pp_completion_callback()); | |
67 } | |
68 return cc.MayForce(PP_ERROR_NOINTERFACE); | |
69 } | |
yzshen1
2013/12/20 23:37:43
it seems you haven't updated this file. I will rev
Peng
2013/12/23 02:41:49
Done.
| |
70 | |
71 } // namespace pp | |
OLD | NEW |