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