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

Side by Side Diff: webrtc/modules/video_coding/generic_encoder.cc

Issue 2089773002: Add EncodedImageCallback::OnEncodedImage(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: addressed feedback Created 4 years, 5 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
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/video_coding/generic_encoder.h" 11 #include "webrtc/modules/video_coding/generic_encoder.h"
12 12
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
17 #include "webrtc/base/trace_event.h" 17 #include "webrtc/base/trace_event.h"
18 #include "webrtc/engine_configurations.h" 18 #include "webrtc/engine_configurations.h"
19 #include "webrtc/modules/video_coding/encoded_frame.h" 19 #include "webrtc/modules/video_coding/encoded_frame.h"
20 #include "webrtc/modules/video_coding/media_optimization.h" 20 #include "webrtc/modules/video_coding/media_optimization.h"
21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" 21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24
24 VCMGenericEncoder::VCMGenericEncoder( 25 VCMGenericEncoder::VCMGenericEncoder(
25 VideoEncoder* encoder, 26 VideoEncoder* encoder,
26 VideoEncoderRateObserver* rate_observer, 27 VideoEncoderRateObserver* rate_observer,
27 VCMEncodedFrameCallback* encoded_frame_callback, 28 VCMEncodedFrameCallback* encoded_frame_callback,
28 bool internal_source) 29 bool internal_source)
29 : encoder_(encoder), 30 : encoder_(encoder),
30 rate_observer_(rate_observer), 31 rate_observer_(rate_observer),
31 vcm_encoded_frame_callback_(encoded_frame_callback), 32 vcm_encoded_frame_callback_(encoded_frame_callback),
32 internal_source_(internal_source), 33 internal_source_(internal_source),
33 encoder_params_({0, 0, 0, 0}), 34 encoder_params_({0, 0, 0, 0}),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 134
134 VCMEncodedFrameCallback::VCMEncodedFrameCallback( 135 VCMEncodedFrameCallback::VCMEncodedFrameCallback(
135 EncodedImageCallback* post_encode_callback, 136 EncodedImageCallback* post_encode_callback,
136 media_optimization::MediaOptimization* media_opt) 137 media_optimization::MediaOptimization* media_opt)
137 : internal_source_(false), 138 : internal_source_(false),
138 post_encode_callback_(post_encode_callback), 139 post_encode_callback_(post_encode_callback),
139 media_opt_(media_opt) {} 140 media_opt_(media_opt) {}
140 141
141 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {} 142 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {}
142 143
143 int32_t VCMEncodedFrameCallback::Encoded( 144 EncodedImageCallback::Result VCMEncodedFrameCallback::OnEncodedImage(
144 const EncodedImage& encoded_image, 145 const EncodedImage& encoded_image,
145 const CodecSpecificInfo* codec_specific, 146 const CodecSpecificInfo* codec_specific,
146 const RTPFragmentationHeader* fragmentation_header) { 147 const RTPFragmentationHeader* fragmentation_header) {
147 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded", 148 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded",
148 "timestamp", encoded_image._timeStamp); 149 "timestamp", encoded_image._timeStamp);
149 int ret_val = post_encode_callback_->Encoded(encoded_image, codec_specific, 150 Result result = post_encode_callback_->OnEncodedImage(
150 fragmentation_header); 151 encoded_image, codec_specific, fragmentation_header);
151 if (ret_val < 0) 152 if (result.error != Result::OK)
152 return ret_val; 153 return result;
153 154
154 if (media_opt_) { 155 if (media_opt_) {
155 media_opt_->UpdateWithEncodedData(encoded_image); 156 media_opt_->UpdateWithEncodedData(encoded_image);
156 if (internal_source_) 157 if (internal_source_) {
157 return media_opt_->DropFrame(); // Signal to encoder to drop next frame. 158 // Signal to encoder to drop next frame.
159 result.drop_next_frame = media_opt_->DropFrame();
160 }
158 } 161 }
159 return VCM_OK; 162 return result;
160 } 163 }
161 164
162 } // namespace webrtc 165 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698