OLD | NEW |
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 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 void VCMProcessTimer::Processed() { | 43 void VCMProcessTimer::Processed() { |
44 _latestMs = _clock->TimeInMilliseconds(); | 44 _latestMs = _clock->TimeInMilliseconds(); |
45 } | 45 } |
46 } // namespace vcm | 46 } // namespace vcm |
47 | 47 |
48 namespace { | 48 namespace { |
49 // This wrapper provides a way to modify the callback without the need to expose | 49 // This wrapper provides a way to modify the callback without the need to expose |
50 // a register method all the way down to the function calling it. | 50 // a register method all the way down to the function calling it. |
51 class EncodedImageCallbackWrapper : public EncodedImageCallback { | 51 class EncodedImageCallbackWrapper : public EncodedImageCallback { |
52 public: | 52 public: |
53 EncodedImageCallbackWrapper() | 53 EncodedImageCallbackWrapper() : callback_(nullptr) {} |
54 : cs_(CriticalSectionWrapper::CreateCriticalSection()), | |
55 callback_(nullptr) {} | |
56 | 54 |
57 virtual ~EncodedImageCallbackWrapper() {} | 55 virtual ~EncodedImageCallbackWrapper() {} |
58 | 56 |
59 void Register(EncodedImageCallback* callback) { | 57 void Register(EncodedImageCallback* callback) { |
60 CriticalSectionScoped cs(cs_.get()); | 58 rtc::CritScope lock(&cs_); |
61 callback_ = callback; | 59 callback_ = callback; |
62 } | 60 } |
63 | 61 |
64 virtual Result OnEncodedImage(const EncodedImage& encoded_image, | 62 virtual Result OnEncodedImage(const EncodedImage& encoded_image, |
65 const CodecSpecificInfo* codec_specific_info, | 63 const CodecSpecificInfo* codec_specific_info, |
66 const RTPFragmentationHeader* fragmentation) { | 64 const RTPFragmentationHeader* fragmentation) { |
67 CriticalSectionScoped cs(cs_.get()); | 65 rtc::CritScope lock(&cs_); |
68 if (callback_) { | 66 if (callback_) { |
69 return callback_->OnEncodedImage(encoded_image, codec_specific_info, | 67 return callback_->OnEncodedImage(encoded_image, codec_specific_info, |
70 fragmentation); | 68 fragmentation); |
71 } | 69 } |
72 return Result(Result::ERROR_SEND_FAILED); | 70 return Result(Result::ERROR_SEND_FAILED); |
73 } | 71 } |
74 | 72 |
75 private: | 73 private: |
76 std::unique_ptr<CriticalSectionWrapper> cs_; | 74 rtc::CriticalSection cs_; |
77 EncodedImageCallback* callback_ GUARDED_BY(cs_); | 75 EncodedImageCallback* callback_ GUARDED_BY(cs_); |
78 }; | 76 }; |
79 | 77 |
80 class VideoCodingModuleImpl : public VideoCodingModule { | 78 class VideoCodingModuleImpl : public VideoCodingModule { |
81 public: | 79 public: |
82 VideoCodingModuleImpl(Clock* clock, | 80 VideoCodingModuleImpl(Clock* clock, |
83 EventFactory* event_factory, | 81 EventFactory* event_factory, |
84 NackSender* nack_sender, | 82 NackSender* nack_sender, |
85 KeyFrameRequestSender* keyframe_request_sender, | 83 KeyFrameRequestSender* keyframe_request_sender, |
86 EncodedImageCallback* pre_decode_image_callback) | 84 EncodedImageCallback* pre_decode_image_callback) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // new jitter buffer is in place. | 278 // new jitter buffer is in place. |
281 VideoCodingModule* VideoCodingModule::Create(Clock* clock, | 279 VideoCodingModule* VideoCodingModule::Create(Clock* clock, |
282 EventFactory* event_factory) { | 280 EventFactory* event_factory) { |
283 RTC_DCHECK(clock); | 281 RTC_DCHECK(clock); |
284 RTC_DCHECK(event_factory); | 282 RTC_DCHECK(event_factory); |
285 return new VideoCodingModuleImpl(clock, event_factory, nullptr, nullptr, | 283 return new VideoCodingModuleImpl(clock, event_factory, nullptr, nullptr, |
286 nullptr); | 284 nullptr); |
287 } | 285 } |
288 | 286 |
289 } // namespace webrtc | 287 } // namespace webrtc |
OLD | NEW |