| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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/modules/video_coding/protection_bitrate_calculator.h" | 11 #include "webrtc/modules/video_coding/protection_bitrate_calculator.h" |
| 12 #include "webrtc/system_wrappers/include/clock.h" | 12 #include "webrtc/system_wrappers/include/clock.h" |
| 13 #include "webrtc/test/gtest.h" | 13 #include "webrtc/test/gtest.h" |
| 14 | 14 |
| 15 namespace webrtc { | 15 namespace webrtc { |
| 16 | 16 |
| 17 static const int kCodecBitrateBps = 100000; | 17 static const int kCodecBitrateBps = 100000; |
| 18 | 18 |
| 19 class ProtectionBitrateCalculatorTest : public ::testing::Test { | 19 class ProtectionBitrateCalculatorTest : public ::testing::Test { |
| 20 protected: | 20 protected: |
| 21 enum { | 21 enum { |
| 22 kSampleRate = 90000 // RTP timestamps per second. | 22 kSampleRate = 90000 // RTP timestamps per second. |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 class ProtectionCallback : public VCMProtectionCallback { | 25 class ProtectionCallback : public VCMProtectionCallback { |
| 26 public: | 26 public: |
| 27 int ProtectionRequest(const FecProtectionParams* delta_params, | 27 void ProtectionRequest(const FecProtectionParams& delta_params, |
| 28 const FecProtectionParams* key_params, | 28 const FecProtectionParams& key_params, |
| 29 uint32_t* sent_video_rate_bps, | 29 uint32_t* sent_video_rate_bps, |
| 30 uint32_t* sent_nack_rate_bps, | 30 uint32_t* sent_nack_rate_bps, |
| 31 uint32_t* sent_fec_rate_bps) override { | 31 uint32_t* sent_fec_rate_bps) override { |
| 32 *sent_video_rate_bps = kCodecBitrateBps; | 32 *sent_video_rate_bps = kCodecBitrateBps; |
| 33 *sent_nack_rate_bps = nack_rate_bps_; | 33 *sent_nack_rate_bps = nack_rate_bps_; |
| 34 *sent_fec_rate_bps = fec_rate_bps_; | 34 *sent_fec_rate_bps = fec_rate_bps_; |
| 35 return 0; | |
| 36 } | 35 } |
| 37 | 36 |
| 38 uint32_t fec_rate_bps_ = 0; | 37 uint32_t fec_rate_bps_ = 0; |
| 39 uint32_t nack_rate_bps_ = 0; | 38 uint32_t nack_rate_bps_ = 0; |
| 40 }; | 39 }; |
| 41 | 40 |
| 42 // Note: simulated clock starts at 1 seconds, since parts of webrtc use 0 as | 41 // Note: simulated clock starts at 1 seconds, since parts of webrtc use 0 as |
| 43 // a special case (e.g. frame rate in media optimization). | 42 // a special case (e.g. frame rate in media optimization). |
| 44 ProtectionBitrateCalculatorTest() | 43 ProtectionBitrateCalculatorTest() |
| 45 : clock_(1000), media_opt_(&clock_, &protection_callback_) {} | 44 : clock_(1000), media_opt_(&clock_, &protection_callback_) {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 90 |
| 92 media_opt_.SetProtectionMethod(false /*enable_fec*/, false /* enable_nack */); | 91 media_opt_.SetProtectionMethod(false /*enable_fec*/, false /* enable_nack */); |
| 93 media_opt_.SetEncodingData(640, 480, 1, 1000); | 92 media_opt_.SetEncodingData(640, 480, 1, 1000); |
| 94 | 93 |
| 95 uint32_t target_bitrate = | 94 uint32_t target_bitrate = |
| 96 media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); | 95 media_opt_.SetTargetRates(kMaxBitrateBps, 30, 128, 100); |
| 97 EXPECT_EQ(kMaxBitrateBps, target_bitrate); | 96 EXPECT_EQ(kMaxBitrateBps, target_bitrate); |
| 98 } | 97 } |
| 99 | 98 |
| 100 } // namespace webrtc | 99 } // namespace webrtc |
| OLD | NEW |