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

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: Created 5 years, 10 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(const CompletionCallbackWithOutput<
39 std::vector<PP_VideoProfileDescription>>& cc) {
40 if (has_interface<PPB_VideoEncoder_0_1>()) {
41 return get_interface<PPB_VideoEncoder_0_1>()->GetSupportedProfiles(
42 pp_resource(), cc.output(), cc.pp_completion_callback());
43 }
44 return cc.MayForce(PP_ERROR_NOINTERFACE);
45 }
46
47 int32_t VideoEncoder::Initialize(const PP_VideoFrame_Format& input_format,
48 const PP_Size& input_visible_size,
49 const PP_VideoProfile& output_profile,
50 const uint32_t initial_bitrate,
51 PP_HardwareAcceleration acceleration,
52 const CompletionCallback& cc) {
53 if (has_interface<PPB_VideoEncoder_0_1>()) {
54 return get_interface<PPB_VideoEncoder_0_1>()->Initialize(
55 pp_resource(), input_format, &input_visible_size, output_profile,
56 initial_bitrate, acceleration, cc.pp_completion_callback());
57 }
58 return cc.MayForce(PP_ERROR_NOINTERFACE);
59 }
60
61 int32_t VideoEncoder::GetFramesRequired() {
62 if (has_interface<PPB_VideoEncoder_0_1>()) {
63 return get_interface<PPB_VideoEncoder_0_1>()->GetFramesRequired(
64 pp_resource());
65 }
66 return PP_ERROR_NOINTERFACE;
67 }
68
69 int32_t VideoEncoder::GetFrameCodedSize(PP_Size* coded_size) {
70 if (has_interface<PPB_VideoEncoder_0_1>()) {
71 return get_interface<PPB_VideoEncoder_0_1>()->GetFrameCodedSize(
72 pp_resource(), coded_size);
73 }
74 return PP_ERROR_NOINTERFACE;
75 }
76
77 int32_t VideoEncoder::GetVideoFrame(
78 const CompletionCallbackWithOutput<VideoFrame>& cc) {
79 if (has_interface<PPB_VideoEncoder_0_1>()) {
80 return get_interface<PPB_VideoEncoder_0_1>()->GetVideoFrame(
81 pp_resource(), cc.output(), cc.pp_completion_callback());
82 }
83 return cc.MayForce(PP_ERROR_NOINTERFACE);
84 }
85
86 int32_t VideoEncoder::Encode(const VideoFrame& video_frame,
87 bool force_keyframe,
88 const CompletionCallback& cc) {
89 if (has_interface<PPB_VideoEncoder_0_1>()) {
90 return get_interface<PPB_VideoEncoder_0_1>()->Encode(
91 pp_resource(), video_frame.pp_resource(), PP_FromBool(force_keyframe),
92 cc.pp_completion_callback());
93 }
94 return cc.MayForce(PP_ERROR_NOINTERFACE);
95 }
96
97 int32_t VideoEncoder::GetBitstreamBuffer(
98 const CompletionCallbackWithOutput<PP_BitstreamBuffer>& cc) {
99 if (has_interface<PPB_VideoEncoder_0_1>()) {
100 return get_interface<PPB_VideoEncoder_0_1>()->GetBitstreamBuffer(
101 pp_resource(), cc.output(), cc.pp_completion_callback());
102 }
103 return cc.MayForce(PP_ERROR_NOINTERFACE);
104 }
105
106 void VideoEncoder::RecycleBitstreamBuffer(
107 const PP_BitstreamBuffer& bitstream_buffer) {
108 if (has_interface<PPB_VideoEncoder_0_1>()) {
109 get_interface<PPB_VideoEncoder_0_1>()->RecycleBitstreamBuffer(
110 pp_resource(), &bitstream_buffer);
111 }
112 }
113
114 void VideoEncoder::RequestEncodingParametersChange(uint32_t bitrate,
115 uint32_t framerate) {
116 if (has_interface<PPB_VideoEncoder_0_1>()) {
117 get_interface<PPB_VideoEncoder_0_1>()->RequestEncodingParametersChange(
118 pp_resource(), bitrate, framerate);
119 }
120 }
121
122 void VideoEncoder::Close() {
123 if (has_interface<PPB_VideoEncoder_0_1>()) {
124 get_interface<PPB_VideoEncoder_0_1>()->Close(pp_resource());
125 }
126 }
127
128 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/video_encoder.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698