tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

h264_sprop_parameter_sets_unittest.cc (1620B)


      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 
     11 #include "modules/video_coding/h264_sprop_parameter_sets.h"
     12 
     13 #include <cstdint>
     14 #include <vector>
     15 
     16 #include "test/gtest.h"
     17 
     18 namespace webrtc {
     19 
     20 class H264SpropParameterSetsTest : public ::testing::Test {
     21 public:
     22  H264SpropParameterSets h264_sprop;
     23 };
     24 
     25 TEST_F(H264SpropParameterSetsTest, Base64DecodeSprop) {
     26  // Example sprop string from https://tools.ietf.org/html/rfc3984 .
     27  EXPECT_TRUE(h264_sprop.DecodeSprop("Z0IACpZTBYmI,aMljiA=="));
     28  static const std::vector<uint8_t> raw_sps{0x67, 0x42, 0x00, 0x0A, 0x96,
     29                                            0x53, 0x05, 0x89, 0x88};
     30  static const std::vector<uint8_t> raw_pps{0x68, 0xC9, 0x63, 0x88};
     31  EXPECT_EQ(raw_sps, h264_sprop.sps_nalu());
     32  EXPECT_EQ(raw_pps, h264_sprop.pps_nalu());
     33 }
     34 
     35 TEST_F(H264SpropParameterSetsTest, InvalidData) {
     36  EXPECT_FALSE(h264_sprop.DecodeSprop(","));
     37  EXPECT_FALSE(h264_sprop.DecodeSprop(""));
     38  EXPECT_FALSE(h264_sprop.DecodeSprop(",iA=="));
     39  EXPECT_FALSE(h264_sprop.DecodeSprop("iA==,"));
     40  EXPECT_TRUE(h264_sprop.DecodeSprop("iA==,iA=="));
     41  EXPECT_FALSE(h264_sprop.DecodeSprop("--,--"));
     42  EXPECT_FALSE(h264_sprop.DecodeSprop(",,"));
     43  EXPECT_FALSE(h264_sprop.DecodeSprop("iA=="));
     44 }
     45 
     46 }  // namespace webrtc