johan | b0a1111 | 2016-12-08 11:57:17 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #include "modules/video_coding/h264_sprop_parameter_sets.h" |
johan | b0a1111 | 2016-12-08 11:57:17 | [diff] [blame] | 12 | |
| 13 | #include <vector> |
pbos | c7c26a0 | 2017-01-02 16:42:32 | [diff] [blame] | 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 15 | #include "test/gtest.h" |
johan | b0a1111 | 2016-12-08 11:57:17 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
Mirko Bonadei | 6a489f2 | 2019-04-09 13:11:12 | [diff] [blame] | 19 | class H264SpropParameterSetsTest : public ::testing::Test { |
johan | b0a1111 | 2016-12-08 11:57:17 | [diff] [blame] | 20 | public: |
| 21 | H264SpropParameterSets h264_sprop; |
| 22 | }; |
| 23 | |
| 24 | TEST_F(H264SpropParameterSetsTest, Base64DecodeSprop) { |
| 25 | // Example sprop string from https://tools.ietf.org/html/rfc3984 . |
| 26 | EXPECT_TRUE(h264_sprop.DecodeSprop("Z0IACpZTBYmI,aMljiA==")); |
| 27 | static const std::vector<uint8_t> raw_sps{0x67, 0x42, 0x00, 0x0A, 0x96, |
| 28 | 0x53, 0x05, 0x89, 0x88}; |
| 29 | static const std::vector<uint8_t> raw_pps{0x68, 0xC9, 0x63, 0x88}; |
| 30 | EXPECT_EQ(raw_sps, h264_sprop.sps_nalu()); |
| 31 | EXPECT_EQ(raw_pps, h264_sprop.pps_nalu()); |
| 32 | } |
| 33 | |
| 34 | TEST_F(H264SpropParameterSetsTest, InvalidData) { |
| 35 | EXPECT_FALSE(h264_sprop.DecodeSprop(",")); |
| 36 | EXPECT_FALSE(h264_sprop.DecodeSprop("")); |
| 37 | EXPECT_FALSE(h264_sprop.DecodeSprop(",iA==")); |
| 38 | EXPECT_FALSE(h264_sprop.DecodeSprop("iA==,")); |
| 39 | EXPECT_TRUE(h264_sprop.DecodeSprop("iA==,iA==")); |
| 40 | EXPECT_FALSE(h264_sprop.DecodeSprop("--,--")); |
| 41 | EXPECT_FALSE(h264_sprop.DecodeSprop(",,")); |
| 42 | EXPECT_FALSE(h264_sprop.DecodeSprop("iA==")); |
| 43 | } |
| 44 | |
| 45 | } // namespace webrtc |