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 const int kNumCores = 1; | |
22 | |
23 void SetDefaultSettings(VideoCodec* codec_settings) { | |
24 codec_settings->codecType = kVideoCodecH264; | |
25 codec_settings->maxFramerate = 60; | |
26 codec_settings->width = 640; | |
27 codec_settings->height = 480; | |
28 // If frame dropping is false, we get a warning that bitrate can't | |
29 // be controlled for RC_QUALITY_MODE; RC_BITRATE_MODE and RC_TIMESTAMP_MODE | |
30 codec_settings->H264()->frameDroppingOn = true; | |
31 codec_settings->targetBitrate = 2000; | |
32 codec_settings->maxBitrate = 4000; | |
33 } | |
34 | |
35 TEST(H264EncoderImplTest, CanInitializeWithDefaultParameters) { | |
36 H264EncoderImpl encoder(cricket::VideoCodec("H264")); | |
37 VideoCodec codec_settings; | |
38 SetDefaultSettings(&codec_settings); | |
39 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
40 encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize)); | |
41 EXPECT_EQ(H264PacketizationMode::NonInterleaved, | |
42 encoder.PacketizationModeForTesting()); | |
43 } | |
44 | |
45 TEST(H264EncoderImplTest, CanInitializeWithNonInterleavedModeExplicitly) { | |
46 cricket::VideoCodec codec("H264"); | |
47 codec.SetParam(cricket::kH264FmtpPacketizationMode, "1"); | |
48 H264EncoderImpl encoder(codec); | |
49 VideoCodec codec_settings; | |
50 SetDefaultSettings(&codec_settings); | |
51 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
52 encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize)); | |
53 EXPECT_EQ(H264PacketizationMode::NonInterleaved, | |
54 encoder.PacketizationModeForTesting()); | |
55 } | |
56 | |
57 TEST(H264EncoderImplTest, CanInitializeWithSingleNalUnitModeExplicitly) { | |
58 cricket::VideoCodec codec("H264"); | |
59 codec.SetParam(cricket::kH264FmtpPacketizationMode, "0"); | |
60 H264EncoderImpl encoder(codec); | |
61 VideoCodec codec_settings; | |
62 SetDefaultSettings(&codec_settings); | |
63 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
64 encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize)); | |
65 EXPECT_EQ(H264PacketizationMode::SingleNalUnit, | |
66 encoder.PacketizationModeForTesting()); | |
67 } | |
68 | |
69 TEST(H264EncoderImplTest, CanInitializeWithRemovedParameter) { | |
70 cricket::VideoCodec codec("H264"); | |
71 codec.RemoveParam(cricket::kH264FmtpPacketizationMode); | |
72 H264EncoderImpl encoder(codec); | |
73 VideoCodec codec_settings; | |
74 SetDefaultSettings(&codec_settings); | |
75 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, | |
76 encoder.InitEncode(&codec_settings, kNumCores, kMaxPayloadSize)); | |
77 EXPECT_EQ(H264PacketizationMode::SingleNalUnit, | |
78 encoder.PacketizationModeForTesting()); | |
79 } | |
80 | |
81 } // anonymous namespace | |
82 | |
83 } // namespace webrtc | |
OLD | NEW |