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

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

Issue 842293003: Pepper: Define PPB_VideoEncoder API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update and add comments. Created 5 years, 11 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
OLDNEW
(Empty)
1 // Copyright (c) 2015 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_encoder.h"
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_video_encoder.h"
9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module.h"
12 #include "ppapi/cpp/module_impl.h"
13
14 namespace pp {
15
16 namespace {
17
18 template <>
19 const char* interface_name<PPB_VideoEncoder_0_1>() {
20 return PPB_VIDEOENCODER_INTERFACE_0_1;
21 }
22
23 } // namespace
24
25 VideoEncoder::VideoEncoder() {
26 }
27
28 VideoEncoder::VideoEncoder(const InstanceHandle& instance) {
29 if (has_interface<PPB_VideoEncoder_0_1>()) {
30 PassRefFromConstructor(
31 get_interface<PPB_VideoEncoder_0_1>()->Create(instance.pp_instance()));
32 }
33 }
34
35 VideoEncoder::VideoEncoder(const VideoEncoder& other) : Resource(other) {
36 }
37
38 int32_t VideoEncoder::GetSupportedProfiles(
39 const CompletionCallbackWithOutput<
40 std::vector<PP_SupportedVideoProfile> >& cc) {
41 if (has_interface<PPB_VideoEncoder_0_1>()) {
42 return get_interface<PPB_VideoEncoder_0_1>()->GetSupportedProfiles(
43 pp_resource(), cc.output(), cc.pp_completion_callback());
44 }
45 return cc.MayForce(PP_ERROR_NOINTERFACE);
46 }
47
48 int32_t VideoEncoder::Initialize(const PP_VideoFrame_Format& input_format,
49 const PP_Size& input_visible_size,
50 const PP_VideoProfile& output_profile,
51 const uint32_t initial_bitrate,
52 PP_HardwareAcceleration acceleration,
53 const CompletionCallback& cc) {
54 if (has_interface<PPB_VideoEncoder_0_1>()) {
55 return get_interface<PPB_VideoEncoder_0_1>()->Initialize(
56 pp_resource(), input_format, &input_visible_size, output_profile,
57 initial_bitrate, acceleration, cc.pp_completion_callback());
58 }
59 return cc.MayForce(PP_ERROR_NOINTERFACE);
60 }
61
62 int32_t VideoEncoder::GetInputFramesRequired() {
63 if (has_interface<PPB_VideoEncoder_0_1>()) {
64 return get_interface<PPB_VideoEncoder_0_1>()->GetInputFramesRequired(
65 pp_resource());
66 }
67 return PP_ERROR_NOINTERFACE;
68 }
69
70
71 int32_t VideoEncoder::GetVideoFrame(
72 const CompletionCallbackWithOutput<VideoFrame>& cc) {
73 if (has_interface<PPB_VideoEncoder_0_1>()) {
74 return get_interface<PPB_VideoEncoder_0_1>()->GetVideoFrame(
75 pp_resource(), cc.output(), cc.pp_completion_callback());
76 }
77 return cc.MayForce(PP_ERROR_NOINTERFACE);
78 }
79
80 int32_t VideoEncoder::Encode(
81 const VideoFrame& video_frame,
82 bool force_keyframe,
83 const CompletionCallback& cc) {
84 if (has_interface<PPB_VideoEncoder_0_1>()) {
85 return get_interface<PPB_VideoEncoder_0_1>()->Encode(
86 pp_resource(), video_frame.pp_resource(), PP_FromBool(force_keyframe),
87 cc.pp_completion_callback());
88 }
89 return cc.MayForce(PP_ERROR_NOINTERFACE);
90 }
91
92 int32_t VideoEncoder::GetBitstreamBuffer(
93 const CompletionCallbackWithOutput<PP_BitstreamBuffer>& cc) {
94 if (has_interface<PPB_VideoEncoder_0_1>()) {
95 return get_interface<PPB_VideoEncoder_0_1>()->GetBitstreamBuffer(
96 pp_resource(), cc.output(), cc.pp_completion_callback());
97 }
98 return cc.MayForce(PP_ERROR_NOINTERFACE);
99 }
100
101 void VideoEncoder::RecycleBitstreamBuffer(
102 const PP_BitstreamBuffer& bitstream_buffer) {
103 if (has_interface<PPB_VideoEncoder_0_1>()) {
104 get_interface<PPB_VideoEncoder_0_1>()->RecycleBitstreamBuffer(
105 pp_resource(), &bitstream_buffer);
106 }
107 }
108
109 void VideoEncoder::RequestEncodingParametersChange(
110 uint32_t bitrate,
111 uint32_t framerate) {
112 if (has_interface<PPB_VideoEncoder_0_1>()) {
113 get_interface<PPB_VideoEncoder_0_1>()->RequestEncodingParametersChange(
114 pp_resource(), bitrate, framerate);
115 }
116 }
117
118 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698