• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "rtc_base/constructor_magic.h"
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.
27 class SendAudioStream {
28  public:
29   RTC_DISALLOW_COPY_AND_ASSIGN(SendAudioStream);
30   ~SendAudioStream();
31   void Start();
32   void Stop();
33   void SetMuted(bool mute);
34   ColumnPrinter StatsPrinter();
35 
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);
44   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.
51 class ReceiveAudioStream {
52  public:
53   RTC_DISALLOW_COPY_AND_ASSIGN(ReceiveAudioStream);
54   ~ReceiveAudioStream();
55   void Start();
56   void Stop();
57   AudioReceiveStream::Stats GetStats() const;
58 
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);
67   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.
75 class AudioStreamPair {
76  public:
77   RTC_DISALLOW_COPY_AND_ASSIGN(AudioStreamPair);
78   ~AudioStreamPair();
send()79   SendAudioStream* send() { return &send_stream_; }
receive()80   ReceiveAudioStream* receive() { return &receive_stream_; }
81 
82  private:
83   friend class Scenario;
84   AudioStreamPair(CallClient* sender,
85                   rtc::scoped_refptr<AudioEncoderFactory> encoder_factory,
86                   CallClient* receiver,
87                   rtc::scoped_refptr<AudioDecoderFactory> decoder_factory,
88                   AudioStreamConfig config);
89 
90  private:
91   const AudioStreamConfig config_;
92   SendAudioStream send_stream_;
93   ReceiveAudioStream receive_stream_;
94 };
95 }  // namespace test
96 }  // namespace webrtc
97 
98 #endif  // TEST_SCENARIO_AUDIO_STREAM_H_
99