blob: 2fc1fb7a3435515f8add151789a04cdff94140a9 [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 Janssonad871942019-01-16 17:21:28 +010032 void SetMuted(bool mute);
Sebastian Jansson359d60a2018-10-25 16:22:02 +020033 ColumnPrinter StatsPrinter();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020034
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 Jansson98b07e92018-09-27 13:47:01 +020043 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 Jansson800e1212018-10-22 11:49:03 +020050class ReceiveAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020051 public:
52 RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
53 ~ReceiveAudioStream();
Sebastian Jansson49a78432018-11-20 16:15:29 +010054 void Start();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020055
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 Jansson98b07e92018-09-27 13:47:01 +020064 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.
72class 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 Jansson98b07e92018-09-27 13:47:01 +020082 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020083 CallClient* receiver,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020084 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
85 AudioStreamConfig config);
86
87 private:
88 const AudioStreamConfig config_;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020089 SendAudioStream send_stream_;
90 ReceiveAudioStream receive_stream_;
91};
92} // namespace test
93} // namespace webrtc
94
95#endif // TEST_SCENARIO_AUDIO_STREAM_H_