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 27 matching lines...) Expand all Loading... | |
38 _latestMs = _clock->TimeInMilliseconds(); | 38 _latestMs = _clock->TimeInMilliseconds(); |
39 } | 39 } |
40 } // namespace vcm | 40 } // namespace vcm |
41 | 41 |
42 namespace { | 42 namespace { |
43 // This wrapper provides a way to modify the callback without the need to expose | 43 // This wrapper provides a way to modify the callback without the need to expose |
44 // a register method all the way down to the function calling it. | 44 // a register method all the way down to the function calling it. |
45 class EncodedImageCallbackWrapper : public EncodedImageCallback { | 45 class EncodedImageCallbackWrapper : public EncodedImageCallback { |
46 public: | 46 public: |
47 EncodedImageCallbackWrapper() | 47 EncodedImageCallbackWrapper() |
48 : cs_(CriticalSectionWrapper::CreateCriticalSection()), callback_(NULL) {} | 48 : cs_(CriticalSectionWrapper::CreateCriticalSection()) {} |
49 | 49 |
50 virtual ~EncodedImageCallbackWrapper() {} | 50 virtual ~EncodedImageCallbackWrapper() {} |
51 | 51 |
52 void Register(EncodedImageCallback* callback) { | 52 void Register(EncodedImageCallback* callback) { |
53 CriticalSectionScoped cs(cs_.get()); | 53 CriticalSectionScoped cs(cs_.get()); |
54 callback_ = callback; | 54 callback_ = callback; |
55 } | 55 } |
56 | 56 |
57 virtual int32_t Encoded(const EncodedImage& encoded_image, | 57 virtual Result OnEncodedImage(const EncodedImage& encoded_image, |
58 const CodecSpecificInfo* codec_specific_info, | 58 const CodecSpecificInfo* codec_specific_info, |
59 const RTPFragmentationHeader* fragmentation) { | 59 const RTPFragmentationHeader* fragmentation) { |
60 CriticalSectionScoped cs(cs_.get()); | 60 CriticalSectionScoped cs(cs_.get()); |
61 if (callback_) | 61 if (callback_) { |
62 return callback_->Encoded(encoded_image, codec_specific_info, | 62 return callback_->OnEncodedImage(encoded_image, codec_specific_info, |
63 fragmentation); | 63 fragmentation); |
64 return 0; | 64 } |
65 return Result(Result::ERROR_SEND_FAILED); | |
65 } | 66 } |
66 | 67 |
67 private: | 68 private: |
68 std::unique_ptr<CriticalSectionWrapper> cs_; | 69 std::unique_ptr<CriticalSectionWrapper> cs_; |
69 EncodedImageCallback* callback_ GUARDED_BY(cs_); | 70 EncodedImageCallback* callback_ GUARDED_BY(cs_) = nullptr; |
stefan-webrtc
2016/07/18 16:51:27
Prefer if you set this in the constructor initiali
Sergey Ulanov
2016/07/21 00:09:39
Done.
| |
70 }; | 71 }; |
71 | 72 |
72 class VideoCodingModuleImpl : public VideoCodingModule { | 73 class VideoCodingModuleImpl : public VideoCodingModule { |
73 public: | 74 public: |
74 VideoCodingModuleImpl(Clock* clock, | 75 VideoCodingModuleImpl(Clock* clock, |
75 EventFactory* event_factory, | 76 EventFactory* event_factory, |
76 VideoEncoderRateObserver* encoder_rate_observer, | 77 VideoEncoderRateObserver* encoder_rate_observer, |
77 NackSender* nack_sender, | 78 NackSender* nack_sender, |
78 KeyFrameRequestSender* keyframe_request_sender, | 79 KeyFrameRequestSender* keyframe_request_sender, |
79 EncodedImageCallback* pre_decode_image_callback) | 80 EncodedImageCallback* pre_decode_image_callback) |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 EventFactory* event_factory, | 311 EventFactory* event_factory, |
311 NackSender* nack_sender, | 312 NackSender* nack_sender, |
312 KeyFrameRequestSender* keyframe_request_sender) { | 313 KeyFrameRequestSender* keyframe_request_sender) { |
313 assert(clock); | 314 assert(clock); |
314 assert(event_factory); | 315 assert(event_factory); |
315 return new VideoCodingModuleImpl(clock, event_factory, nullptr, nack_sender, | 316 return new VideoCodingModuleImpl(clock, event_factory, nullptr, nack_sender, |
316 keyframe_request_sender, nullptr); | 317 keyframe_request_sender, nullptr); |
317 } | 318 } |
318 | 319 |
319 } // namespace webrtc | 320 } // namespace webrtc |
OLD | NEW |