video_quality_test.h 5.6 KB

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