video_quality_test.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright (c) 2015 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. #ifndef VIDEO_VIDEO_QUALITY_TEST_H_
  11. #define VIDEO_VIDEO_QUALITY_TEST_H_
  12. #include <map>
  13. #include <memory>
  14. #include <string>
  15. #include <vector>
  16. #include "api/fec_controller.h"
  17. #include "api/rtc_event_log/rtc_event_log_factory.h"
  18. #include "api/task_queue/task_queue_base.h"
  19. #include "api/task_queue/task_queue_factory.h"
  20. #include "api/test/frame_generator_interface.h"
  21. #include "api/test/video_quality_test_fixture.h"
  22. #include "api/video/video_bitrate_allocator_factory.h"
  23. #include "call/fake_network_pipe.h"
  24. #include "media/engine/internal_decoder_factory.h"
  25. #include "media/engine/internal_encoder_factory.h"
  26. #include "test/call_test.h"
  27. #include "test/layer_filtering_transport.h"
  28. #include "video/video_analyzer.h"
  29. #include "modules/video_coding/codecs/nvidia/NvVideoEncoderFactory.h"
  30. #ifdef WEBRTC_WIN
  31. #include "modules/audio_device/win/core_audio_utility_win.h"
  32. #endif
  33. namespace webrtc {
  34. class VideoQualityTest : public test::CallTest,
  35. public VideoQualityTestFixtureInterface {
  36. public:
  37. explicit VideoQualityTest(
  38. std::unique_ptr<InjectionComponents> injection_components);
  39. void RunWithAnalyzer(const Params& params) override;
  40. void RunWithRenderers(const Params& params) override;
  41. const std::map<uint8_t, webrtc::MediaType>& payload_type_map() override {
  42. return payload_type_map_;
  43. }
  44. static void FillScalabilitySettings(
  45. Params* params,
  46. size_t video_idx,
  47. const std::vector<std::string>& stream_descriptors,
  48. int num_streams,
  49. size_t selected_stream,
  50. int num_spatial_layers,
  51. int selected_sl,
  52. InterLayerPredMode inter_layer_pred,
  53. const std::vector<std::string>& sl_descriptors);
  54. // Helper static methods.
  55. static VideoStream DefaultVideoStream(const Params& params, size_t video_idx);
  56. static VideoStream DefaultThumbnailStream();
  57. static std::vector<int> ParseCSV(const std::string& str);
  58. protected:
  59. std::map<uint8_t, webrtc::MediaType> payload_type_map_;
  60. // No-op implementation to be able to instantiate this class from non-TEST_F
  61. // locations.
  62. void TestBody() override;
  63. // Helper methods accessing only params_.
  64. std::string GenerateGraphTitle() const;
  65. void CheckParamsAndInjectionComponents();
  66. // Helper methods for setting up the call.
  67. void CreateCapturers();
  68. std::unique_ptr<test::FrameGeneratorInterface> CreateFrameGenerator(
  69. size_t video_idx);
  70. void SetupThumbnailCapturers(size_t num_thumbnail_streams);
  71. std::unique_ptr<VideoDecoder> CreateVideoDecoder(
  72. const SdpVideoFormat& format);
  73. std::unique_ptr<VideoEncoder> CreateVideoEncoder(const SdpVideoFormat& format,
  74. VideoAnalyzer* analyzer);
  75. void SetupVideo(Transport* send_transport, Transport* recv_transport);
  76. void SetupThumbnails(Transport* send_transport, Transport* recv_transport);
  77. void StartAudioStreams();
  78. void StartThumbnails();
  79. void StopThumbnails();
  80. void DestroyThumbnailStreams();
  81. // Helper method for creating a real ADM (using hardware) for all platforms.
  82. rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice();
  83. void InitializeAudioDevice(Call::Config* send_call_config,
  84. Call::Config* recv_call_config,
  85. bool use_real_adm);
  86. void SetupAudio(Transport* transport);
  87. void StartEncodedFrameLogs(VideoReceiveStream* stream);
  88. virtual std::unique_ptr<test::LayerFilteringTransport> CreateSendTransport();
  89. virtual std::unique_ptr<test::DirectTransport> CreateReceiveTransport();
  90. std::vector<std::unique_ptr<rtc::VideoSourceInterface<VideoFrame>>>
  91. thumbnail_capturers_;
  92. Clock* const clock_;
  93. const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
  94. RtcEventLogFactory rtc_event_log_factory_;
  95. test::FunctionVideoDecoderFactory video_decoder_factory_;
  96. std::unique_ptr<VideoDecoderFactory> decoder_factory_;
  97. test::FunctionVideoEncoderFactory video_encoder_factory_;
  98. test::FunctionVideoEncoderFactory video_encoder_factory_with_analyzer_;
  99. std::unique_ptr<VideoBitrateAllocatorFactory>
  100. video_bitrate_allocator_factory_;
  101. std::unique_ptr<NvVideoEncoderFactory> encoder_factory_;
  102. std::vector<VideoSendStream::Config> thumbnail_send_configs_;
  103. std::vector<VideoEncoderConfig> thumbnail_encoder_configs_;
  104. std::vector<VideoSendStream*> thumbnail_send_streams_;
  105. std::vector<VideoReceiveStream::Config> thumbnail_receive_configs_;
  106. std::vector<VideoReceiveStream*> thumbnail_receive_streams_;
  107. int receive_logs_;
  108. int send_logs_;
  109. Params params_;
  110. std::unique_ptr<InjectionComponents> injection_components_;
  111. // Set non-null when running with analyzer.
  112. std::unique_ptr<VideoAnalyzer> analyzer_;
  113. // Note: not same as similarly named member in CallTest. This is the number of
  114. // separate send streams, the one in CallTest is the number of substreams for
  115. // a single send stream.
  116. size_t num_video_streams_;
  117. #ifdef WEBRTC_WIN
  118. // Windows Core Audio based ADM needs to run on a COM initialized thread.
  119. // Only referenced in combination with --audio --use_real_adm flags.
  120. std::unique_ptr<webrtc_win::ScopedCOMInitializer> com_initializer_;
  121. #endif
  122. };
  123. } // namespace webrtc
  124. #endif // VIDEO_VIDEO_QUALITY_TEST_H_