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()), | 48 : cs_(CriticalSectionWrapper::CreateCriticalSection()), callback_(NULL) {} |
49 callback_(nullptr) {} | |
50 | 49 |
51 virtual ~EncodedImageCallbackWrapper() {} | 50 virtual ~EncodedImageCallbackWrapper() {} |
52 | 51 |
53 void Register(EncodedImageCallback* callback) { | 52 void Register(EncodedImageCallback* callback) { |
54 CriticalSectionScoped cs(cs_.get()); | 53 CriticalSectionScoped cs(cs_.get()); |
55 callback_ = callback; | 54 callback_ = callback; |
56 } | 55 } |
57 | 56 |
58 virtual Result OnEncodedImage(const EncodedImage& encoded_image, | 57 virtual int32_t Encoded(const EncodedImage& encoded_image, |
59 const CodecSpecificInfo* codec_specific_info, | 58 const CodecSpecificInfo* codec_specific_info, |
60 const RTPFragmentationHeader* fragmentation) { | 59 const RTPFragmentationHeader* fragmentation) { |
61 CriticalSectionScoped cs(cs_.get()); | 60 CriticalSectionScoped cs(cs_.get()); |
62 if (callback_) { | 61 if (callback_) |
63 return callback_->OnEncodedImage(encoded_image, codec_specific_info, | 62 return callback_->Encoded(encoded_image, codec_specific_info, |
64 fragmentation); | 63 fragmentation); |
65 } | 64 return 0; |
66 return Result(Result::ERROR_SEND_FAILED); | |
67 } | 65 } |
68 | 66 |
69 private: | 67 private: |
70 std::unique_ptr<CriticalSectionWrapper> cs_; | 68 std::unique_ptr<CriticalSectionWrapper> cs_; |
71 EncodedImageCallback* callback_ GUARDED_BY(cs_); | 69 EncodedImageCallback* callback_ GUARDED_BY(cs_); |
72 }; | 70 }; |
73 | 71 |
74 class VideoCodingModuleImpl : public VideoCodingModule { | 72 class VideoCodingModuleImpl : public VideoCodingModule { |
75 public: | 73 public: |
76 VideoCodingModuleImpl(Clock* clock, | 74 VideoCodingModuleImpl(Clock* clock, |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 EventFactory* event_factory, | 289 EventFactory* event_factory, |
292 NackSender* nack_sender, | 290 NackSender* nack_sender, |
293 KeyFrameRequestSender* keyframe_request_sender) { | 291 KeyFrameRequestSender* keyframe_request_sender) { |
294 assert(clock); | 292 assert(clock); |
295 assert(event_factory); | 293 assert(event_factory); |
296 return new VideoCodingModuleImpl(clock, event_factory, nack_sender, | 294 return new VideoCodingModuleImpl(clock, event_factory, nack_sender, |
297 keyframe_request_sender, nullptr); | 295 keyframe_request_sender, nullptr); |
298 } | 296 } |
299 | 297 |
300 } // namespace webrtc | 298 } // namespace webrtc |
OLD | NEW |