| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/cpp/video_writer.h" | 5 #include "ppapi/cpp/private/video_destination_private.h" |
| 6 | 6 |
| 7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_video_writer.h" | 8 #include "ppapi/c/private/ppb_video_destination_private.h" |
| 9 #include "ppapi/cpp/instance_handle.h" | 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
| 11 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
| 12 #include "ppapi/cpp/private/video_frame_private.h" |
| 12 #include "ppapi/cpp/var.h" | 13 #include "ppapi/cpp/var.h" |
| 13 #include "ppapi/cpp/video_frame.h" | |
| 14 | 14 |
| 15 namespace pp { | 15 namespace pp { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 template <> const char* interface_name<PPB_VideoWriter_0_1>() { | 19 template <> const char* interface_name<PPB_VideoDestination_Private_0_1>() { |
| 20 return PPB_VIDEOWRITER_INTERFACE_0_1; | 20 return PPB_VIDEODESTINATION_PRIVATE_INTERFACE_0_1; |
| 21 } | 21 } |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 // VideoWriter ----------------------------------------------------------------- | 25 VideoDestination_Private::VideoDestination_Private() { |
| 26 | |
| 27 VideoWriter::VideoWriter() { | |
| 28 } | 26 } |
| 29 | 27 |
| 30 VideoWriter::VideoWriter(const InstanceHandle& instance) { | 28 VideoDestination_Private::VideoDestination_Private( |
| 31 if (!has_interface<PPB_VideoWriter_0_1>()) | 29 const InstanceHandle& instance) { |
| 30 if (!has_interface<PPB_VideoDestination_Private_0_1>()) |
| 32 return; | 31 return; |
| 33 PassRefFromConstructor(get_interface<PPB_VideoWriter_0_1>()->Create( | 32 PassRefFromConstructor( |
| 34 instance.pp_instance())); | 33 get_interface<PPB_VideoDestination_Private_0_1>()->Create( |
| 34 instance.pp_instance())); |
| 35 } | 35 } |
| 36 | 36 |
| 37 VideoWriter::VideoWriter(const VideoWriter& other) | 37 VideoDestination_Private::VideoDestination_Private( |
| 38 const VideoDestination_Private& other) |
| 38 : Resource(other) { | 39 : Resource(other) { |
| 39 } | 40 } |
| 40 | 41 |
| 41 VideoWriter::VideoWriter(PassRef, PP_Resource resource) | 42 VideoDestination_Private::VideoDestination_Private(PassRef, |
| 43 PP_Resource resource) |
| 42 : Resource(PASS_REF, resource) { | 44 : Resource(PASS_REF, resource) { |
| 43 } | 45 } |
| 44 | 46 |
| 45 int32_t VideoWriter::Open(const CompletionCallbackWithOutput<Var>& cc) { | 47 int32_t VideoDestination_Private::Open(const Var& stream_url, |
| 46 if (has_interface<PPB_VideoWriter_0_1>()) { | 48 const CompletionCallback& cc) { |
| 49 if (has_interface<PPB_VideoDestination_Private_0_1>()) { |
| 47 int32_t result = | 50 int32_t result = |
| 48 get_interface<PPB_VideoWriter_0_1>()->Open( | 51 get_interface<PPB_VideoDestination_Private_0_1>()->Open( |
| 49 pp_resource(), | 52 pp_resource(), |
| 50 cc.output(), cc.pp_completion_callback()); | 53 stream_url.pp_var(), |
| 54 cc.pp_completion_callback()); |
| 51 return result; | 55 return result; |
| 52 } | 56 } |
| 53 return cc.MayForce(PP_ERROR_NOINTERFACE); | 57 return cc.MayForce(PP_ERROR_NOINTERFACE); |
| 54 } | 58 } |
| 55 | 59 |
| 56 int32_t VideoWriter::PutFrame(const VideoFrame& frame) { | 60 int32_t VideoDestination_Private::ReceiveFrame( |
| 57 if (has_interface<PPB_VideoWriter_0_1>()) { | 61 const VideoFrame_Private& frame) { |
| 58 return get_interface<PPB_VideoWriter_0_1>()->PutFrame( | 62 if (has_interface<PPB_VideoDestination_Private_0_1>()) { |
| 63 return get_interface<PPB_VideoDestination_Private_0_1>()->ReceiveFrame( |
| 59 pp_resource(), | 64 pp_resource(), |
| 60 &frame.pp_video_frame()); | 65 &frame.pp_video_frame()); |
| 61 } | 66 } |
| 62 return PP_ERROR_NOINTERFACE; | 67 return PP_ERROR_NOINTERFACE; |
| 63 } | 68 } |
| 64 | 69 |
| 65 void VideoWriter::Close() { | 70 void VideoDestination_Private::Close() { |
| 66 if (has_interface<PPB_VideoWriter_0_1>()) { | 71 if (has_interface<PPB_VideoDestination_Private_0_1>()) { |
| 67 get_interface<PPB_VideoWriter_0_1>()->Close(pp_resource()); | 72 get_interface<PPB_VideoDestination_Private_0_1>()->Close(pp_resource()); |
| 68 } | 73 } |
| 69 } | 74 } |
| 70 | 75 |
| 71 } // namespace pp | 76 } // namespace pp |
| OLD | NEW |