Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 16 | #include "rtc_base/constructor_magic.h" |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 17 | #include "test/scenario/call_client.h" |
| 18 | #include "test/scenario/column_printer.h" |
| 19 | #include "test/scenario/network_node.h" |
| 20 | #include "test/scenario/scenario_config.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | namespace test { |
| 24 | |
| 25 | // SendAudioStream represents sending of audio. It can be used for starting the |
| 26 | // stream if neccessary. |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 27 | class SendAudioStream { |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 28 | public: |
| 29 | RTC_DISALLOW_COPY_AND_ASSIGN(SendAudioStream); |
| 30 | ~SendAudioStream(); |
| 31 | void Start(); |
Sebastian Jansson | bdfadd6 | 2019-02-08 13:34:57 +0100 | [diff] [blame] | 32 | void Stop(); |
Sebastian Jansson | ad87194 | 2019-01-16 17:21:28 +0100 | [diff] [blame] | 33 | void SetMuted(bool mute); |
Sebastian Jansson | 359d60a | 2018-10-25 16:22:02 +0200 | [diff] [blame] | 34 | ColumnPrinter StatsPrinter(); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 35 | |
| 36 | private: |
| 37 | friend class Scenario; |
| 38 | friend class AudioStreamPair; |
| 39 | friend class ReceiveAudioStream; |
| 40 | SendAudioStream(CallClient* sender, |
| 41 | AudioStreamConfig config, |
| 42 | rtc::scoped_refptr<AudioEncoderFactory> encoder_factory, |
| 43 | Transport* send_transport); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 44 | AudioSendStream* send_stream_ = nullptr; |
| 45 | CallClient* const sender_; |
| 46 | const AudioStreamConfig config_; |
| 47 | uint32_t ssrc_; |
| 48 | }; |
| 49 | |
| 50 | // ReceiveAudioStream represents an audio receiver. It can't be used directly. |
Sebastian Jansson | 800e121 | 2018-10-22 11:49:03 +0200 | [diff] [blame] | 51 | class ReceiveAudioStream { |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 52 | public: |
| 53 | RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream); |
| 54 | ~ReceiveAudioStream(); |
Sebastian Jansson | 49a7843 | 2018-11-20 16:15:29 +0100 | [diff] [blame] | 55 | void Start(); |
Sebastian Jansson | bdfadd6 | 2019-02-08 13:34:57 +0100 | [diff] [blame] | 56 | void Stop(); |
Sebastian Jansson | f4481c8 | 2019-04-09 12:48:34 +0200 | [diff] [blame] | 57 | AudioReceiveStream::Stats GetStats() const; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 58 | |
| 59 | private: |
| 60 | friend class Scenario; |
| 61 | friend class AudioStreamPair; |
| 62 | ReceiveAudioStream(CallClient* receiver, |
| 63 | AudioStreamConfig config, |
| 64 | SendAudioStream* send_stream, |
| 65 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, |
| 66 | Transport* feedback_transport); |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 67 | AudioReceiveStream* receive_stream_ = nullptr; |
| 68 | CallClient* const receiver_; |
| 69 | const AudioStreamConfig config_; |
| 70 | }; |
| 71 | |
| 72 | // AudioStreamPair represents an audio streaming session. It can be used to |
| 73 | // access underlying send and receive classes. It can also be used in calls to |
| 74 | // the Scenario class. |
| 75 | class AudioStreamPair { |
| 76 | public: |
| 77 | RTC_DISALLOW_COPY_AND_ASSIGN(AudioStreamPair); |
| 78 | ~AudioStreamPair(); |
| 79 | SendAudioStream* send() { return &send_stream_; } |
| 80 | ReceiveAudioStream* receive() { return &receive_stream_; } |
| 81 | |
| 82 | private: |
| 83 | friend class Scenario; |
| 84 | AudioStreamPair(CallClient* sender, |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 85 | rtc::scoped_refptr<AudioEncoderFactory> encoder_factory, |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 86 | CallClient* receiver, |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 87 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, |
| 88 | AudioStreamConfig config); |
| 89 | |
| 90 | private: |
| 91 | const AudioStreamConfig config_; |
Sebastian Jansson | 98b07e9 | 2018-09-27 13:47:01 +0200 | [diff] [blame] | 92 | SendAudioStream send_stream_; |
| 93 | ReceiveAudioStream receive_stream_; |
| 94 | }; |
| 95 | } // namespace test |
| 96 | } // namespace webrtc |
| 97 | |
| 98 | #endif // TEST_SCENARIO_AUDIO_STREAM_H_ |