blob: 430e33347065b6ec476d89f6f106fdeb7f70f03b [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 Jansson359d60a2018-10-25 16:22:02 +020032 ColumnPrinter StatsPrinter();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020033
34 private:
35 friend class Scenario;
36 friend class AudioStreamPair;
37 friend class ReceiveAudioStream;
38 SendAudioStream(CallClient* sender,
39 AudioStreamConfig config,
40 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
41 Transport* send_transport);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020042 AudioSendStream* send_stream_ = nullptr;
43 CallClient* const sender_;
44 const AudioStreamConfig config_;
45 uint32_t ssrc_;
46};
47
48// ReceiveAudioStream represents an audio receiver. It can't be used directly.
Sebastian Jansson800e1212018-10-22 11:49:03 +020049class ReceiveAudioStream {
Sebastian Jansson98b07e92018-09-27 13:47:01 +020050 public:
51 RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
52 ~ReceiveAudioStream();
Sebastian Jansson49a78432018-11-20 16:15:29 +010053 void Start();
Sebastian Jansson98b07e92018-09-27 13:47:01 +020054
55 private:
56 friend class Scenario;
57 friend class AudioStreamPair;
58 ReceiveAudioStream(CallClient* receiver,
59 AudioStreamConfig config,
60 SendAudioStream* send_stream,
61 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
62 Transport* feedback_transport);
Sebastian Jansson98b07e92018-09-27 13:47:01 +020063 AudioReceiveStream* receive_stream_ = nullptr;
64 CallClient* const receiver_;
65 const AudioStreamConfig config_;
66};
67
68// AudioStreamPair represents an audio streaming session. It can be used to
69// access underlying send and receive classes. It can also be used in calls to
70// the Scenario class.
71class AudioStreamPair {
72 public:
73 RTC_DISALLOW_COPY_AND_ASSIGN(AudioStreamPair);
74 ~AudioStreamPair();
75 SendAudioStream* send() { return &send_stream_; }
76 ReceiveAudioStream* receive() { return &receive_stream_; }
77
78 private:
79 friend class Scenario;
80 AudioStreamPair(CallClient* sender,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020081 rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020082 CallClient* receiver,
Sebastian Jansson98b07e92018-09-27 13:47:01 +020083 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
84 AudioStreamConfig config);
85
86 private:
87 const AudioStreamConfig config_;
Sebastian Jansson98b07e92018-09-27 13:47:01 +020088 SendAudioStream send_stream_;
89 ReceiveAudioStream receive_stream_;
90};
91} // namespace test
92} // namespace webrtc
93
94#endif // TEST_SCENARIO_AUDIO_STREAM_H_