Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 * | |
| 10 */ | |
| 11 | |
| 12 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" | |
| 13 | |
| 14 #include "webrtc/test/gtest.h" | |
| 15 | |
| 16 namespace webrtc { | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 const int kMaxPayloadSize = 1024; | |
| 21 | |
| 22 void SetDefaultSettings(VideoCodec* codec_settings) { | |
| 23 codec_settings->codecType = kVideoCodecH264; | |
| 24 codec_settings->maxFramerate = 60; | |
| 25 codec_settings->width = 640; | |
| 26 codec_settings->height = 480; | |
| 27 // If frame dropping is false, we get a warning that bitrate can't | |
| 28 // be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE | |
| 29 codec_settings->H264()->frameDroppingOn = true; | |
| 30 codec_settings->targetBitrate = 2000; | |
| 31 codec_settings->maxBitrate = 4000; | |
| 32 } | |
| 33 | |
| 34 TEST(H264EncoderImplTest, CanInitializeWithDefaultParameters) { | |
| 35 H264EncoderImpl encoder(cricket::VideoCodec("H264")); | |
| 36 VideoCodec codec_settings; | |
| 37 SetDefaultSettings(&codec_settings); | |
| 38 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 39 encoder.InitEncode(&codec_settings, 1, kMaxPayloadSize)); | |
|
hbos
2016/12/02 10:21:27
nit: kNumCodes = 1
| |
| 40 EXPECT_EQ(H264PacketizationMode::NonInterleaved, | |
| 41 encoder.PacketizationModeForTesting()); | |
| 42 } | |
| 43 | |
| 44 TEST(H264EncoderImplTest, CanInitializeWithPacketizationMode1Explicitly) { | |
|
hbos
2016/12/02 10:21:26
nit/optional: Naming difference "mode" vs enum nam
hta-webrtc
2016/12/02 11:09:01
Done.
| |
| 45 cricket::VideoCodec codec("H264"); | |
| 46 codec.SetParam(cricket::kH264FmtpPacketizationMode, "1"); | |
| 47 H264EncoderImpl encoder(codec); | |
| 48 VideoCodec codec_settings; | |
| 49 SetDefaultSettings(&codec_settings); | |
| 50 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 51 encoder.InitEncode(&codec_settings, 1, kMaxPayloadSize)); | |
| 52 EXPECT_EQ(H264PacketizationMode::NonInterleaved, | |
| 53 encoder.PacketizationModeForTesting()); | |
| 54 } | |
| 55 | |
| 56 TEST(H264EncoderImplTest, CanInitializeWithPacketizationMode0Explicitly) { | |
| 57 cricket::VideoCodec codec("H264"); | |
| 58 codec.SetParam(cricket::kH264FmtpPacketizationMode, "0"); | |
| 59 H264EncoderImpl encoder(codec); | |
| 60 VideoCodec codec_settings; | |
| 61 SetDefaultSettings(&codec_settings); | |
| 62 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 63 encoder.InitEncode(&codec_settings, 1, kMaxPayloadSize)); | |
| 64 EXPECT_EQ(H264PacketizationMode::SingleNalUnit, | |
| 65 encoder.PacketizationModeForTesting()); | |
| 66 } | |
| 67 | |
| 68 TEST(H264EncoderImplTest, CanInitializeWithPacketizationMode0RemovedParameter) { | |
| 69 cricket::VideoCodec codec("H264"); | |
| 70 codec.RemoveParam(cricket::kH264FmtpPacketizationMode); | |
| 71 H264EncoderImpl encoder(codec); | |
| 72 VideoCodec codec_settings; | |
| 73 SetDefaultSettings(&codec_settings); | |
| 74 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
| 75 encoder.InitEncode(&codec_settings, 1, kMaxPayloadSize)); | |
| 76 EXPECT_EQ(H264PacketizationMode::SingleNalUnit, | |
| 77 encoder.PacketizationModeForTesting()); | |
| 78 } | |
| 79 | |
| 80 } // anonymous namespace | |
| 81 | |
| 82 } // namespace webrtc | |
| OLD | NEW |