audio_stream.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright 2018 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 TEST_SCENARIO_AUDIO_STREAM_H_
  11. #define TEST_SCENARIO_AUDIO_STREAM_H_
  12. #include <memory>
  13. #include <string>
  14. #include <vector>
  15. #include "rtc_base/constructor_magic.h"
  16. #include "test/scenario/call_client.h"
  17. #include "test/scenario/column_printer.h"
  18. #include "test/scenario/network_node.h"
  19. #include "test/scenario/scenario_config.h"
  20. namespace webrtc {
  21. namespace test {
  22. // SendAudioStream represents sending of audio. It can be used for starting the
  23. // stream if neccessary.
  24. class SendAudioStream {
  25. public:
  26. RTC_DISALLOW_COPY_AND_ASSIGN(SendAudioStream);
  27. ~SendAudioStream();
  28. void Start();
  29. void Stop();
  30. void SetMuted(bool mute);
  31. ColumnPrinter StatsPrinter();
  32. private:
  33. friend class Scenario;
  34. friend class AudioStreamPair;
  35. friend class ReceiveAudioStream;
  36. SendAudioStream(CallClient* sender,
  37. AudioStreamConfig config,
  38. rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
  39. Transport* send_transport);
  40. AudioSendStream* send_stream_ = nullptr;
  41. CallClient* const sender_;
  42. const AudioStreamConfig config_;
  43. uint32_t ssrc_;
  44. };
  45. // ReceiveAudioStream represents an audio receiver. It can't be used directly.
  46. class ReceiveAudioStream {
  47. public:
  48. RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
  49. ~ReceiveAudioStream();
  50. void Start();
  51. void Stop();
  52. AudioReceiveStream::Stats GetStats() const;
  53. private:
  54. friend class Scenario;
  55. friend class AudioStreamPair;
  56. ReceiveAudioStream(CallClient* receiver,
  57. AudioStreamConfig config,
  58. SendAudioStream* send_stream,
  59. rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
  60. Transport* feedback_transport);
  61. AudioReceiveStream* receive_stream_ = nullptr;
  62. CallClient* const receiver_;
  63. const AudioStreamConfig config_;
  64. };
  65. // AudioStreamPair represents an audio streaming session. It can be used to
  66. // access underlying send and receive classes. It can also be used in calls to
  67. // the Scenario class.
  68. class AudioStreamPair {
  69. public:
  70. RTC_DISALLOW_COPY_AND_ASSIGN(AudioStreamPair);
  71. ~AudioStreamPair();
  72. SendAudioStream* send() { return &send_stream_; }
  73. ReceiveAudioStream* receive() { return &receive_stream_; }
  74. private:
  75. friend class Scenario;
  76. AudioStreamPair(CallClient* sender,
  77. rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
  78. CallClient* receiver,
  79. rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
  80. AudioStreamConfig config);
  81. private:
  82. const AudioStreamConfig config_;
  83. SendAudioStream send_stream_;
  84. ReceiveAudioStream receive_stream_;
  85. };
  86. } // namespace test
  87. } // namespace webrtc
  88. #endif // TEST_SCENARIO_AUDIO_STREAM_H_