blob: b561cb4c70cf07314b2080217c34418837084cb3 [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
Steve Anton10542f22019-01-11 09:11:00 -080016#include "rtc_base/constructor_magic.h"
Sebastian Jansson98b07e92018-09-27 13:47:01 +020017#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
22namespace webrtc {
23namespace test {
24
25// SendAudioStream represents sending of audio. It can be used for starting the
26// stream if neccessary.
Sebastian Jansson800e1212018-10-22 11:49:03 +020027class SendAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020028 public:
29 RTC_DISALLOW_COPY_AND_ASSIGN(SendAudioStream);
30 ~SendAudioStream();
31 void Start();
Sebastian Janssonbdfadd62019-02-08 13:34:57 +010032 void Stop();
Sebastian Janssonad871942019-01-16 17:21:28 +010033 void SetMuted(bool mute);
Sebastian Jansson359d60a2018-10-25 16:22:02 +020034 ColumnPrinter StatsPrinter();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020035
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 Jansson98b07e92018-09-27 13:47:01 +020044 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 Jansson800e1212018-10-22 11:49:03 +020051class ReceiveAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020052 public:
53 RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
54 ~ReceiveAudioStream();
Sebastian Jansson49a78432018-11-20 16:15:29 +010055 void Start();
Sebastian Janssonbdfadd62019-02-08 13:34:57 +010056 void Stop();
Sebastian Janssonf4481c82019-04-09 12:48:34 +020057 AudioReceiveStream::Stats GetStats() const;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020058
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 Jansson98b07e92018-09-27 13:47:01 +020067 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.
75class 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 Jansson98b07e92018-09-27 13:47:01 +020085 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020086 CallClient* receiver,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020087 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
88 AudioStreamConfig config);
89
90 private:
91 const AudioStreamConfig config_;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020092 SendAudioStream send_stream_;
93 ReceiveAudioStream receive_stream_;
94};
95} // namespace test
96} // namespace webrtc
97
98#endif // TEST_SCENARIO_AUDIO_STREAM_H_