H264ProfileLevelIdTest.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "pch.h"
  2. #include "Codec/H264ProfileLevelId.h"
  3. namespace unity
  4. {
  5. namespace webrtc
  6. {
  7. TEST(H264ProfileLevelId, TestSupportedLevel)
  8. {
  9. EXPECT_EQ(H264Level::kLevel2_1, *H264SupportedLevel(320 * 240, 25, 4000 * 1200));
  10. EXPECT_EQ(H264Level::kLevel3_1, *H264SupportedLevel(1280 * 720, 30, 14000 * 1200));
  11. EXPECT_EQ(H264Level::kLevel4_2, *H264SupportedLevel(1920 * 1080, 60, 50000 * 1200));
  12. EXPECT_EQ(H264Level::kLevel5_2, *H264SupportedLevel(3840 * 2160, 60, 50000 * 1200));
  13. }
  14. TEST(H264ProfileLevelId, TestSupportedLevelInvalid)
  15. {
  16. EXPECT_FALSE(H264SupportedLevel(0, 0, 0));
  17. EXPECT_FALSE(H264SupportedLevel(3840 * 2160, 90, 50000 * 1200));
  18. }
  19. TEST(H264ProfileLevelId, TestSupportedFramerate)
  20. {
  21. EXPECT_GE(SupportedMaxFramerate(H264Level::kLevel2_1, 320 * 240), 25);
  22. EXPECT_GE(SupportedMaxFramerate(H264Level::kLevel3_1, 1280 * 720), 30);
  23. EXPECT_GE(SupportedMaxFramerate(H264Level::kLevel4_2, 1920 * 1080), 60);
  24. EXPECT_GE(SupportedMaxFramerate(H264Level::kLevel5_2, 2560 * 1440), 90);
  25. EXPECT_GE(SupportedMaxFramerate(H264Level::kLevel5_2, 3840 * 2160), 60);
  26. }
  27. const char kProfileLevelId[] = "profile-level-id";
  28. TEST(H264ProfileLevelId, H264IsSameProfile)
  29. {
  30. SdpVideoFormat format1("H264");
  31. H264ProfileLevelId id1(H264Profile::kProfileBaseline, H264Level::kLevel4_1);
  32. format1.parameters.emplace(kProfileLevelId, H264ProfileLevelIdToString(id1).value());
  33. SdpVideoFormat format2("H264");
  34. H264ProfileLevelId id2(H264Profile::kProfileBaseline, H264Level::kLevel5_1);
  35. format2.parameters.emplace(kProfileLevelId, H264ProfileLevelIdToString(id2).value());
  36. // ignore level
  37. EXPECT_TRUE(H264IsSameProfile(format1.parameters, format2.parameters));
  38. SdpVideoFormat format3("H264");
  39. H264ProfileLevelId id3(H264Profile::kProfileHigh, H264Level::kLevel4_1);
  40. format3.parameters.emplace(kProfileLevelId, H264ProfileLevelIdToString(id3).value());
  41. // not ignore profile
  42. EXPECT_FALSE(H264IsSameProfile(format1.parameters, format3.parameters));
  43. }
  44. }
  45. }