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

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

Issue 1853813002: Add support for writing raw encoder output to .ivf files. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Set pre-decode image callback on construction Created 4 years, 8 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
(...skipping 11 matching lines...) Expand all
22 #include "webrtc/system_wrappers/include/clock.h" 22 #include "webrtc/system_wrappers/include/clock.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 namespace vcm { 25 namespace vcm {
26 26
27 VideoSender::VideoSender(Clock* clock, 27 VideoSender::VideoSender(Clock* clock,
28 EncodedImageCallback* post_encode_callback, 28 EncodedImageCallback* post_encode_callback,
29 VideoEncoderRateObserver* encoder_rate_observer, 29 VideoEncoderRateObserver* encoder_rate_observer,
30 VCMQMSettingsCallback* qm_settings_callback) 30 VCMQMSettingsCallback* qm_settings_callback)
31 : clock_(clock), 31 : clock_(clock),
32 process_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
33 _encoder(nullptr), 32 _encoder(nullptr),
34 _encodedFrameCallback(post_encode_callback), 33 _encodedFrameCallback(post_encode_callback),
35 _mediaOpt(clock_), 34 _mediaOpt(clock_),
36 _sendStatsCallback(nullptr), 35 _sendStatsCallback(nullptr),
37 _codecDataBase(encoder_rate_observer, &_encodedFrameCallback), 36 _codecDataBase(encoder_rate_observer, &_encodedFrameCallback),
38 frame_dropper_enabled_(true), 37 frame_dropper_enabled_(true),
39 _sendStatsTimer(1000, clock_), 38 _sendStatsTimer(1000, clock_),
40 current_codec_(), 39 current_codec_(),
41 qm_settings_callback_(qm_settings_callback), 40 qm_settings_callback_(qm_settings_callback),
42 protection_callback_(nullptr), 41 protection_callback_(nullptr),
43 encoder_params_({0, 0, 0, 0}), 42 encoder_params_({0, 0, 0, 0}),
44 encoder_has_internal_source_(false), 43 encoder_has_internal_source_(false),
45 next_frame_types_(1, kVideoFrameDelta) { 44 next_frame_types_(1, kVideoFrameDelta) {
46 // Allow VideoSender to be created on one thread but used on another, post 45 // Allow VideoSender to be created on one thread but used on another, post
47 // construction. This is currently how this class is being used by at least 46 // construction. This is currently how this class is being used by at least
48 // one external project (diffractor). 47 // one external project (diffractor).
49 _mediaOpt.EnableQM(qm_settings_callback_ != nullptr); 48 _mediaOpt.EnableQM(qm_settings_callback_ != nullptr);
50 _mediaOpt.Reset(); 49 _mediaOpt.Reset();
51 main_thread_.DetachFromThread(); 50 main_thread_.DetachFromThread();
52 } 51 }
53 52
54 VideoSender::~VideoSender() {} 53 VideoSender::~VideoSender() {}
55 54
56 void VideoSender::Process() { 55 void VideoSender::Process() {
57 if (_sendStatsTimer.TimeUntilProcess() == 0) { 56 if (_sendStatsTimer.TimeUntilProcess() == 0) {
58 _sendStatsTimer.Processed(); 57 _sendStatsTimer.Processed();
59 CriticalSectionScoped cs(process_crit_sect_.get()); 58 rtc::CritScope cs(&process_crit_);
60 if (_sendStatsCallback != nullptr) { 59 if (_sendStatsCallback != nullptr) {
61 uint32_t bitRate = _mediaOpt.SentBitRate(); 60 uint32_t bitRate = _mediaOpt.SentBitRate();
62 uint32_t frameRate = _mediaOpt.SentFrameRate(); 61 uint32_t frameRate = _mediaOpt.SentFrameRate();
63 _sendStatsCallback->SendStatistics(bitRate, frameRate); 62 _sendStatsCallback->SendStatistics(bitRate, frameRate);
64 } 63 }
65 } 64 }
66 65
67 { 66 {
68 rtc::CritScope cs(&params_crit_); 67 rtc::CritScope cs(&params_crit_);
69 // Force an encoder parameters update, so that incoming frame rate is 68 // Force an encoder parameters update, so that incoming frame rate is
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 _encodedFrameCallback.SetMediaOpt(&_mediaOpt); 225 _encodedFrameCallback.SetMediaOpt(&_mediaOpt);
227 _encodedFrameCallback.SetTransportCallback(transport); 226 _encodedFrameCallback.SetTransportCallback(transport);
228 return VCM_OK; 227 return VCM_OK;
229 } 228 }
230 229
231 // Register video output information callback which will be called to deliver 230 // Register video output information callback which will be called to deliver
232 // information about the video stream produced by the encoder, for instance the 231 // information about the video stream produced by the encoder, for instance the
233 // average frame rate and bit rate. 232 // average frame rate and bit rate.
234 int32_t VideoSender::RegisterSendStatisticsCallback( 233 int32_t VideoSender::RegisterSendStatisticsCallback(
235 VCMSendStatisticsCallback* sendStats) { 234 VCMSendStatisticsCallback* sendStats) {
236 CriticalSectionScoped cs(process_crit_sect_.get()); 235 rtc::CritScope cs(&process_crit_);
237 _sendStatsCallback = sendStats; 236 _sendStatsCallback = sendStats;
238 return VCM_OK; 237 return VCM_OK;
239 } 238 }
240 239
241 // Register a video protection callback which will be called to deliver the 240 // Register a video protection callback which will be called to deliver the
242 // requested FEC rate and NACK status (on/off). 241 // requested FEC rate and NACK status (on/off).
243 // Note: this callback is assumed to only be registered once and before it is 242 // Note: this callback is assumed to only be registered once and before it is
244 // used in this class. 243 // used in this class.
245 int32_t VideoSender::RegisterProtectionCallback( 244 int32_t VideoSender::RegisterProtectionCallback(
246 VCMProtectionCallback* protection_callback) { 245 VCMProtectionCallback* protection_callback) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // 10 kbps. 377 // 10 kbps.
379 int window_bps = std::max(threshold_bps / 10, 10000); 378 int window_bps = std::max(threshold_bps / 10, 10000);
380 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps); 379 _mediaOpt.SuspendBelowMinBitrate(threshold_bps, window_bps);
381 } 380 }
382 381
383 bool VideoSender::VideoSuspended() const { 382 bool VideoSender::VideoSuspended() const {
384 return _mediaOpt.IsVideoSuspended(); 383 return _mediaOpt.IsVideoSuspended();
385 } 384 }
386 } // namespace vcm 385 } // namespace vcm
387 } // namespace webrtc 386 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698