CreateVideoCodecFactoryTest.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "pch.h"
  2. #include "Codec/CreateVideoCodecFactory.h"
  3. #include "GraphicsDeviceContainer.h"
  4. namespace unity
  5. {
  6. namespace webrtc
  7. {
  8. class CreateVideoCodecFactoryTest : public testing::TestWithParam<UnityGfxRenderer>
  9. {
  10. public:
  11. CreateVideoCodecFactoryTest()
  12. : container_(CreateGraphicsDeviceContainer(GetParam()))
  13. , device_(container_->device())
  14. {
  15. arrayImpl_ = {
  16. kInternalImpl, kNvCodecImpl, kAndroidMediaCodecImpl, kVideoToolboxImpl
  17. };
  18. }
  19. protected:
  20. void SetUp() override
  21. {
  22. if (!device_)
  23. GTEST_SKIP() << "The graphics driver is not installed on the device.";
  24. }
  25. std::unique_ptr<GraphicsDeviceContainer> container_;
  26. std::vector<std::string> arrayImpl_;
  27. IGraphicsDevice* device_;
  28. };
  29. TEST_P(CreateVideoCodecFactoryTest, CreateVideoEncoderFactory)
  30. {
  31. std::map<std::string, std::unique_ptr<VideoEncoderFactory>> factories;
  32. for (auto impl : arrayImpl_)
  33. {
  34. auto factory = CreateVideoEncoderFactory(impl, device_, nullptr);
  35. if (factory)
  36. factories.emplace(impl, factory);
  37. }
  38. EXPECT_GT(factories.size(), 0);
  39. }
  40. TEST_P(CreateVideoCodecFactoryTest, CreateVideoDecoderFactory)
  41. {
  42. std::map<std::string, std::unique_ptr<VideoDecoderFactory>> factories;
  43. for (auto impl : arrayImpl_)
  44. {
  45. auto factory = CreateVideoDecoderFactory(impl, device_, nullptr);
  46. if (factory)
  47. factories.emplace(impl, factory);
  48. }
  49. EXPECT_GT(factories.size(), 0);
  50. }
  51. TEST_P(CreateVideoCodecFactoryTest, FindCodecFactory)
  52. {
  53. std::map<std::string, std::unique_ptr<VideoEncoderFactory>> factories;
  54. for (auto impl : arrayImpl_)
  55. {
  56. auto factory = CreateVideoEncoderFactory(impl, device_, nullptr);
  57. if (factory)
  58. factories.emplace(impl, factory);
  59. }
  60. // return nullptr when unknown mimetype
  61. SdpVideoFormat format("test");
  62. EXPECT_TRUE(!FindCodecFactory(factories, format));
  63. // return value when unknown implementation_name
  64. SdpVideoFormat format2("VP8");
  65. format.parameters.emplace(kSdpKeyNameCodecImpl, "unknown");
  66. EXPECT_TRUE(FindCodecFactory(factories, format2));
  67. }
  68. TEST_P(CreateVideoCodecFactoryTest, GetSupportedFormatsInFactories)
  69. {
  70. std::map<std::string, std::unique_ptr<VideoEncoderFactory>> factories;
  71. for (auto impl : arrayImpl_)
  72. {
  73. auto factory = CreateVideoEncoderFactory(impl, device_, nullptr);
  74. if (factory)
  75. factories.emplace(impl, factory);
  76. }
  77. std::vector <webrtc::SdpVideoFormat> formats = GetSupportedFormatsInFactories(factories);
  78. EXPECT_GT(formats.size(), 0);
  79. }
  80. INSTANTIATE_TEST_SUITE_P(GfxDevice, CreateVideoCodecFactoryTest, testing::ValuesIn(supportedGfxDevices));
  81. } // namespace webrtc
  82. } // namespace unity