blob: ae263131a7fa553b4ed7107c39ce2f810da8dc41 [file] [log] [blame]
johanb0a11112016-12-08 11:57:171/*
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 Bonadei92ea95e2017-09-15 04:47:3111#include "modules/video_coding/h264_sprop_parameter_sets.h"
johanb0a11112016-12-08 11:57:1712
13#include <vector>
pbosc7c26a02017-01-02 16:42:3214
Mirko Bonadei92ea95e2017-09-15 04:47:3115#include "test/gtest.h"
johanb0a11112016-12-08 11:57:1716
17namespace webrtc {
18
Mirko Bonadei6a489f22019-04-09 13:11:1219class H264SpropParameterSetsTest : public ::testing::Test {
johanb0a11112016-12-08 11:57:1720 public:
21 H264SpropParameterSets h264_sprop;
22};
23
24TEST_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
34TEST_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