| OLD | NEW |
| 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 |
| 11 #include "webrtc/base/checks.h" |
| 11 #include "webrtc/common_types.h" | 12 #include "webrtc/common_types.h" |
| 12 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 13 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" | 14 #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" |
| 14 #include "webrtc/modules/video_coding/main/source/encoded_frame.h" | 15 #include "webrtc/modules/video_coding/main/source/encoded_frame.h" |
| 15 #include "webrtc/modules/video_coding/main/source/jitter_buffer.h" | 16 #include "webrtc/modules/video_coding/main/source/jitter_buffer.h" |
| 16 #include "webrtc/modules/video_coding/main/source/packet.h" | 17 #include "webrtc/modules/video_coding/main/source/packet.h" |
| 17 #include "webrtc/modules/video_coding/main/source/video_coding_impl.h" | 18 #include "webrtc/modules/video_coding/main/source/video_coding_impl.h" |
| 18 #include "webrtc/system_wrappers/interface/clock.h" | 19 #include "webrtc/system_wrappers/interface/clock.h" |
| 19 #include "webrtc/system_wrappers/interface/logging.h" | 20 #include "webrtc/system_wrappers/interface/logging.h" |
| 20 #include "webrtc/system_wrappers/interface/trace_event.h" | 21 #include "webrtc/system_wrappers/interface/trace_event.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 181 |
| 181 // Enable or disable a video protection method. | 182 // Enable or disable a video protection method. |
| 182 // Note: This API should be deprecated, as it does not offer a distinction | 183 // Note: This API should be deprecated, as it does not offer a distinction |
| 183 // between the protection method and decoding with or without errors. If such a | 184 // between the protection method and decoding with or without errors. If such a |
| 184 // behavior is desired, use the following API: SetReceiverRobustnessMode. | 185 // behavior is desired, use the following API: SetReceiverRobustnessMode. |
| 185 int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection, | 186 int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection, |
| 186 bool enable) { | 187 bool enable) { |
| 187 // By default, do not decode with errors. | 188 // By default, do not decode with errors. |
| 188 _receiver.SetDecodeErrorMode(kNoErrors); | 189 _receiver.SetDecodeErrorMode(kNoErrors); |
| 189 switch (videoProtection) { | 190 switch (videoProtection) { |
| 190 case kProtectionNack: | 191 case kProtectionNack: { |
| 191 case kProtectionNackReceiver: { | 192 DCHECK(enable); |
| 192 CriticalSectionScoped cs(_receiveCritSect); | 193 _receiver.SetNackMode(kNack, -1, -1); |
| 193 if (enable) { | |
| 194 // Enable NACK and always wait for retransmits. | |
| 195 _receiver.SetNackMode(kNack, -1, -1); | |
| 196 } else { | |
| 197 _receiver.SetNackMode(kNoNack, -1, -1); | |
| 198 } | |
| 199 break; | 194 break; |
| 200 } | 195 } |
| 201 | 196 |
| 202 case kProtectionKeyOnLoss: { | 197 case kProtectionKeyOnLoss: { |
| 203 CriticalSectionScoped cs(_receiveCritSect); | 198 CriticalSectionScoped cs(_receiveCritSect); |
| 204 if (enable) { | 199 if (enable) { |
| 205 _keyRequestMode = kKeyOnLoss; | 200 _keyRequestMode = kKeyOnLoss; |
| 206 _receiver.SetDecodeErrorMode(kWithErrors); | 201 _receiver.SetDecodeErrorMode(kWithErrors); |
| 207 } else if (_keyRequestMode == kKeyOnLoss) { | 202 } else if (_keyRequestMode == kKeyOnLoss) { |
| 208 _keyRequestMode = kKeyOnError; // default mode | 203 _keyRequestMode = kKeyOnError; // default mode |
| (...skipping 10 matching lines...) Expand all Loading... |
| 219 } else if (_keyRequestMode == kKeyOnKeyLoss) { | 214 } else if (_keyRequestMode == kKeyOnKeyLoss) { |
| 220 _keyRequestMode = kKeyOnError; // default mode | 215 _keyRequestMode = kKeyOnError; // default mode |
| 221 } else { | 216 } else { |
| 222 return VCM_PARAMETER_ERROR; | 217 return VCM_PARAMETER_ERROR; |
| 223 } | 218 } |
| 224 break; | 219 break; |
| 225 } | 220 } |
| 226 | 221 |
| 227 case kProtectionNackFEC: { | 222 case kProtectionNackFEC: { |
| 228 CriticalSectionScoped cs(_receiveCritSect); | 223 CriticalSectionScoped cs(_receiveCritSect); |
| 229 if (enable) { | 224 DCHECK(enable); |
| 230 // Enable hybrid NACK/FEC. Always wait for retransmissions | 225 _receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs, -1); |
| 231 // and don't add extra delay when RTT is above | 226 _receiver.SetDecodeErrorMode(kNoErrors); |
| 232 // kLowRttNackMs. | |
| 233 _receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs, -1); | |
| 234 _receiver.SetDecodeErrorMode(kNoErrors); | |
| 235 _receiver.SetDecodeErrorMode(kNoErrors); | |
| 236 } else { | |
| 237 _receiver.SetNackMode(kNoNack, -1, -1); | |
| 238 } | |
| 239 break; | 227 break; |
| 240 } | 228 } |
| 241 case kProtectionNackSender: | |
| 242 case kProtectionFEC: | 229 case kProtectionFEC: |
| 243 // Ignore encoder modes. | |
| 244 return VCM_OK; | |
| 245 case kProtectionNone: | 230 case kProtectionNone: |
| 246 // TODO(pbos): Implement like sender and remove enable parameter. Ignored | 231 // No receiver-side protection. |
| 247 // for now. | 232 DCHECK(enable); |
| 233 _receiver.SetNackMode(kNoNack, -1, -1); |
| 234 _receiver.SetDecodeErrorMode(kWithErrors); |
| 248 break; | 235 break; |
| 249 } | 236 } |
| 250 return VCM_OK; | 237 return VCM_OK; |
| 251 } | 238 } |
| 252 | 239 |
| 253 // Register a receive callback. Will be called whenever there is a new frame | 240 // Register a receive callback. Will be called whenever there is a new frame |
| 254 // ready for rendering. | 241 // ready for rendering. |
| 255 int32_t VideoReceiver::RegisterReceiveCallback( | 242 int32_t VideoReceiver::RegisterReceiveCallback( |
| 256 VCMReceiveCallback* receiveCallback) { | 243 VCMReceiveCallback* receiveCallback) { |
| 257 CriticalSectionScoped cs(_receiveCritSect); | 244 CriticalSectionScoped cs(_receiveCritSect); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 } | 611 } |
| 625 | 612 |
| 626 void VideoReceiver::RegisterPreDecodeImageCallback( | 613 void VideoReceiver::RegisterPreDecodeImageCallback( |
| 627 EncodedImageCallback* observer) { | 614 EncodedImageCallback* observer) { |
| 628 CriticalSectionScoped cs(_receiveCritSect); | 615 CriticalSectionScoped cs(_receiveCritSect); |
| 629 pre_decode_image_callback_ = observer; | 616 pre_decode_image_callback_ = observer; |
| 630 } | 617 } |
| 631 | 618 |
| 632 } // namespace vcm | 619 } // namespace vcm |
| 633 } // namespace webrtc | 620 } // namespace webrtc |
| OLD | NEW |