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

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

Issue 1528503003: Lint enabled for webrtc/modules/video_coding folder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 <algorithm>
12
11 #include "webrtc/common_types.h" 13 #include "webrtc/common_types.h"
12 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 14 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
13 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
14 #include "webrtc/modules/video_coding/encoded_frame.h" 16 #include "webrtc/modules/video_coding/encoded_frame.h"
15 #include "webrtc/modules/video_coding/jitter_buffer.h" 17 #include "webrtc/modules/video_coding/jitter_buffer.h"
16 #include "webrtc/modules/video_coding/packet.h" 18 #include "webrtc/modules/video_coding/packet.h"
17 #include "webrtc/modules/video_coding/video_coding_impl.h" 19 #include "webrtc/modules/video_coding/video_coding_impl.h"
mflodman 2015/12/17 13:05:39 Should be on top.
mflodman 2015/12/18 12:44:26 You missed this comment.
18 #include "webrtc/system_wrappers/include/clock.h" 20 #include "webrtc/system_wrappers/include/clock.h"
19 21
20 namespace webrtc { 22 namespace webrtc {
21 namespace vcm { 23 namespace vcm {
22 24
23 int64_t 25 int64_t VCMProcessTimer::Period() const {
24 VCMProcessTimer::Period() const { 26 return _periodMs;
25 return _periodMs;
26 } 27 }
27 28
28 int64_t 29 int64_t VCMProcessTimer::TimeUntilProcess() const {
29 VCMProcessTimer::TimeUntilProcess() const { 30 const int64_t time_since_process = _clock->TimeInMilliseconds() - _latestMs;
30 const int64_t time_since_process = _clock->TimeInMilliseconds() - _latestMs; 31 const int64_t time_until_process = _periodMs - time_since_process;
31 const int64_t time_until_process = _periodMs - time_since_process; 32 return std::max<int64_t>(time_until_process, 0);
32 return std::max<int64_t>(time_until_process, 0);
33 } 33 }
34 34
35 void 35 void VCMProcessTimer::Processed() {
36 VCMProcessTimer::Processed() { 36 _latestMs = _clock->TimeInMilliseconds();
37 _latestMs = _clock->TimeInMilliseconds();
38 } 37 }
39 } // namespace vcm 38 } // namespace vcm
40 39
41 namespace { 40 namespace {
42 // This wrapper provides a way to modify the callback without the need to expose 41 // This wrapper provides a way to modify the callback without the need to expose
43 // a register method all the way down to the function calling it. 42 // a register method all the way down to the function calling it.
44 class EncodedImageCallbackWrapper : public EncodedImageCallback { 43 class EncodedImageCallbackWrapper : public EncodedImageCallback {
45 public: 44 public:
46 EncodedImageCallbackWrapper() 45 EncodedImageCallbackWrapper()
47 : cs_(CriticalSectionWrapper::CreateCriticalSection()), callback_(NULL) {} 46 : cs_(CriticalSectionWrapper::CreateCriticalSection()), callback_(NULL) {}
48 47
49 virtual ~EncodedImageCallbackWrapper() {} 48 virtual ~EncodedImageCallbackWrapper() {}
50 49
51 void Register(EncodedImageCallback* callback) { 50 void Register(EncodedImageCallback* callback) {
52 CriticalSectionScoped cs(cs_.get()); 51 CriticalSectionScoped cs(cs_.get());
53 callback_ = callback; 52 callback_ = callback;
54 } 53 }
55 54
56 // TODO(andresp): Change to void as return value is ignored. 55 // TODO(andresp): Change to void as return value is ignored.
57 virtual int32_t Encoded(const EncodedImage& encoded_image, 56 virtual int32_t Encoded(const EncodedImage& encoded_image,
58 const CodecSpecificInfo* codec_specific_info, 57 const CodecSpecificInfo* codec_specific_info,
59 const RTPFragmentationHeader* fragmentation) { 58 const RTPFragmentationHeader* fragmentation) {
60 CriticalSectionScoped cs(cs_.get()); 59 CriticalSectionScoped cs(cs_.get());
61 if (callback_) 60 if (callback_)
62 return callback_->Encoded( 61 return callback_->Encoded(encoded_image, codec_specific_info,
63 encoded_image, codec_specific_info, fragmentation); 62 fragmentation);
64 return 0; 63 return 0;
65 } 64 }
66 65
67 private: 66 private:
68 rtc::scoped_ptr<CriticalSectionWrapper> cs_; 67 rtc::scoped_ptr<CriticalSectionWrapper> cs_;
69 EncodedImageCallback* callback_ GUARDED_BY(cs_); 68 EncodedImageCallback* callback_ GUARDED_BY(cs_);
70 }; 69 };
71 70
72 class VideoCodingModuleImpl : public VideoCodingModule { 71 class VideoCodingModuleImpl : public VideoCodingModule {
73 public: 72 public:
74 VideoCodingModuleImpl(Clock* clock, 73 VideoCodingModuleImpl(Clock* clock,
75 EventFactory* event_factory, 74 EventFactory* event_factory,
76 bool owns_event_factory, 75 bool owns_event_factory,
77 VideoEncoderRateObserver* encoder_rate_observer, 76 VideoEncoderRateObserver* encoder_rate_observer,
78 VCMQMSettingsCallback* qm_settings_callback) 77 VCMQMSettingsCallback* qm_settings_callback)
79 : VideoCodingModule(), 78 : VideoCodingModule(),
80 sender_(clock, 79 sender_(clock,
81 &post_encode_callback_, 80 &post_encode_callback_,
82 encoder_rate_observer, 81 encoder_rate_observer,
83 qm_settings_callback), 82 qm_settings_callback),
84 receiver_(clock, event_factory), 83 receiver_(clock, event_factory),
85 own_event_factory_(owns_event_factory ? event_factory : NULL) {} 84 own_event_factory_(owns_event_factory ? event_factory : NULL) {}
86 85
87 virtual ~VideoCodingModuleImpl() { 86 virtual ~VideoCodingModuleImpl() { own_event_factory_.reset(); }
88 own_event_factory_.reset();
89 }
90 87
91 int64_t TimeUntilNextProcess() override { 88 int64_t TimeUntilNextProcess() override {
92 int64_t sender_time = sender_.TimeUntilNextProcess(); 89 int64_t sender_time = sender_.TimeUntilNextProcess();
93 int64_t receiver_time = receiver_.TimeUntilNextProcess(); 90 int64_t receiver_time = receiver_.TimeUntilNextProcess();
94 assert(sender_time >= 0); 91 assert(sender_time >= 0);
95 assert(receiver_time >= 0); 92 assert(receiver_time >= 0);
96 return VCM_MIN(sender_time, receiver_time); 93 return VCM_MIN(sender_time, receiver_time);
97 } 94 }
98 95
99 int32_t Process() override { 96 int32_t Process() override {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 311 }
315 312
316 VideoCodingModule* VideoCodingModule::Create( 313 VideoCodingModule* VideoCodingModule::Create(
317 Clock* clock, 314 Clock* clock,
318 VideoEncoderRateObserver* encoder_rate_observer, 315 VideoEncoderRateObserver* encoder_rate_observer,
319 VCMQMSettingsCallback* qm_settings_callback) { 316 VCMQMSettingsCallback* qm_settings_callback) {
320 return new VideoCodingModuleImpl(clock, new EventFactoryImpl, true, 317 return new VideoCodingModuleImpl(clock, new EventFactoryImpl, true,
321 encoder_rate_observer, qm_settings_callback); 318 encoder_rate_observer, qm_settings_callback);
322 } 319 }
323 320
324 VideoCodingModule* VideoCodingModule::Create( 321 VideoCodingModule* VideoCodingModule::Create(Clock* clock,
325 Clock* clock, 322 EventFactory* event_factory) {
326 EventFactory* event_factory) {
327 assert(clock); 323 assert(clock);
328 assert(event_factory); 324 assert(event_factory);
329 return new VideoCodingModuleImpl(clock, event_factory, false, nullptr, 325 return new VideoCodingModuleImpl(clock, event_factory, false, nullptr,
330 nullptr); 326 nullptr);
331 } 327 }
332 328
333 void VideoCodingModule::Destroy(VideoCodingModule* module) { 329 void VideoCodingModule::Destroy(VideoCodingModule* module) {
334 if (module != NULL) { 330 if (module != NULL) {
335 delete static_cast<VideoCodingModuleImpl*>(module); 331 delete static_cast<VideoCodingModuleImpl*>(module);
336 } 332 }
337 } 333 }
338 } // namespace webrtc 334 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698