blob: 2110c1d5cbc4f6fc4d7eaa6010dcd7ed5f47345c [file] [log] [blame]
Sebastian Jansson98b07e92018-09-27 13:47:01 +02001/*
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
Sebastian Jansson98b07e92018-09-27 13:47:01 +020016#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
21namespace webrtc {
22namespace test {
23
24// SendAudioStream represents sending of audio. It can be used for starting the
25// stream if neccessary.
Sebastian Jansson800e1212018-10-22 11:49:03 +020026class SendAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020027 public:
Sebastian Jansson98b07e92018-09-27 13:47:01 +020028 ~SendAudioStream();
Artem Titov6cae2d52022-01-26 15:01:10 +000029
30 SendAudioStream(const SendAudioStream&) = delete;
31 SendAudioStream& operator=(const SendAudioStream&) = delete;
32
Sebastian Jansson98b07e92018-09-27 13:47:01 +020033 void Start();
Sebastian Janssonbdfadd62019-02-08 13:34:57 +010034 void Stop();
Sebastian Janssonad871942019-01-16 17:21:28 +010035 void SetMuted(bool mute);
Sebastian Jansson359d60a2018-10-25 16:22:02 +020036 ColumnPrinter StatsPrinter();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020037
38 private:
39 friend class Scenario;
40 friend class AudioStreamPair;
41 friend class ReceiveAudioStream;
42 SendAudioStream(CallClient* sender,
43 AudioStreamConfig config,
44 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
45 Transport* send_transport);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020046 AudioSendStream* send_stream_ = nullptr;
47 CallClient* const sender_;
48 const AudioStreamConfig config_;
49 uint32_t ssrc_;
50};
51
52// ReceiveAudioStream represents an audio receiver. It can't be used directly.
Sebastian Jansson800e1212018-10-22 11:49:03 +020053class ReceiveAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020054 public:
Sebastian Jansson98b07e92018-09-27 13:47:01 +020055 ~ReceiveAudioStream();
Artem Titov6cae2d52022-01-26 15:01:10 +000056
57 ReceiveAudioStream(const ReceiveAudioStream&) = delete;
58 ReceiveAudioStream& operator=(const ReceiveAudioStream&) = delete;
59
Sebastian Jansson49a78432018-11-20 16:15:29 +010060 void Start();
Sebastian Janssonbdfadd62019-02-08 13:34:57 +010061 void Stop();
Sebastian Janssonf4481c82019-04-09 12:48:34 +020062 AudioReceiveStream::Stats GetStats() const;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020063
64 private:
65 friend class Scenario;
66 friend class AudioStreamPair;
67 ReceiveAudioStream(CallClient* receiver,
68 AudioStreamConfig config,
69 SendAudioStream* send_stream,
70 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
71 Transport* feedback_transport);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020072 AudioReceiveStream* receive_stream_ = nullptr;
73 CallClient* const receiver_;
74 const AudioStreamConfig config_;
75};
76
77// AudioStreamPair represents an audio streaming session. It can be used to
78// access underlying send and receive classes. It can also be used in calls to
79// the Scenario class.
80class AudioStreamPair {
81 public:
Sebastian Jansson98b07e92018-09-27 13:47:01 +020082 ~AudioStreamPair();
Artem Titov6cae2d52022-01-26 15:01:10 +000083
84 AudioStreamPair(const AudioStreamPair&) = delete;
85 AudioStreamPair& operator=(const AudioStreamPair&) = delete;
86
Sebastian Jansson98b07e92018-09-27 13:47:01 +020087 SendAudioStream* send() { return &send_stream_; }
88 ReceiveAudioStream* receive() { return &receive_stream_; }
89
90 private:
91 friend class Scenario;
92 AudioStreamPair(CallClient* sender,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020093 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020094 CallClient* receiver,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020095 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
96 AudioStreamConfig config);
97
98 private:
99 const AudioStreamConfig config_;
Sebastian Jansson98b07e92018-09-27 13:47:01 +0200100 SendAudioStream send_stream_;
101 ReceiveAudioStream receive_stream_;
102};
103} // namespace test
104} // namespace webrtc
105
106#endif // TEST_SCENARIO_AUDIO_STREAM_H_