Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: webrtc/voice_engine/test/auto_test/fakes/conference_transport.h

Issue 3008273002: Replace voe_conference_test. (Closed)
Patch Set: rebase Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2015 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
11 #ifndef WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_CONFERENCE_TRANSPORT_H_
12 #define WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_CONFERENCE_TRANSPORT_H_
13
14 #include <deque>
15 #include <map>
16 #include <memory>
17 #include <utility>
18
19 #include "webrtc/common_types.h"
20 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
21 #include "webrtc/rtc_base/basictypes.h"
22 #include "webrtc/rtc_base/criticalsection.h"
23 #include "webrtc/rtc_base/platform_thread.h"
24 #include "webrtc/system_wrappers/include/event_wrapper.h"
25 #include "webrtc/test/gtest.h"
26 #include "webrtc/voice_engine/include/voe_base.h"
27 #include "webrtc/voice_engine/include/voe_codec.h"
28 #include "webrtc/voice_engine/include/voe_file.h"
29 #include "webrtc/voice_engine/include/voe_network.h"
30 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
31 #include "webrtc/voice_engine/test/auto_test/fakes/loudest_filter.h"
32
33 namespace webrtc {
34 namespace voetest {
35
36 static const size_t kMaxPacketSizeByte = 1500;
37
38 // This class is to simulate a conference call. There are two Voice Engines, one
39 // for local channels and the other for remote channels. There is a simulated
40 // reflector, which exchanges RTCP with local channels. For simplicity, it
41 // also uses the Voice Engine for remote channels. One can add streams by
42 // calling AddStream(), which creates a remote sender channel and a local
43 // receive channel. The remote sender channel plays a file as microphone in a
44 // looped fashion. Received streams are mixed and played.
45
46 class ConferenceTransport: public webrtc::Transport {
47 public:
48 ConferenceTransport();
49 virtual ~ConferenceTransport();
50
51 /* SetRtt()
52 * Set RTT between local channels and reflector.
53 *
54 * Input:
55 * rtt_ms : RTT in milliseconds.
56 */
57 void SetRtt(unsigned int rtt_ms);
58
59 /* AddStream()
60 * Adds a stream in the conference.
61 *
62 * Input:
63 * file_name : name of the file to be added as microphone input.
64 * format : format of the input file.
65 *
66 * Returns stream id.
67 */
68 unsigned int AddStream(std::string file_name, webrtc::FileFormats format);
69
70 /* RemoveStream()
71 * Removes a stream with specified ID from the conference.
72 *
73 * Input:
74 * id : stream id.
75 *
76 * Returns false if the specified stream does not exist, true if succeeds.
77 */
78 bool RemoveStream(unsigned int id);
79
80 /* StartPlayout()
81 * Starts playing out the stream with specified ID, using the default device.
82 *
83 * Input:
84 * id : stream id.
85 *
86 * Returns false if the specified stream does not exist, true if succeeds.
87 */
88 bool StartPlayout(unsigned int id);
89
90 /* GetReceiverStatistics()
91 * Gets RTCP statistics of the stream with specified ID.
92 *
93 * Input:
94 * id : stream id;
95 * stats : pointer to a CallStatistics to store the result.
96 *
97 * Returns false if the specified stream does not exist, true if succeeds.
98 */
99 bool GetReceiverStatistics(unsigned int id, webrtc::CallStatistics* stats);
100
101 // Inherit from class webrtc::Transport.
102 bool SendRtp(const uint8_t* data,
103 size_t len,
104 const webrtc::PacketOptions& options) override;
105 bool SendRtcp(const uint8_t *data, size_t len) override;
106
107 private:
108 struct Packet {
109 enum Type { Rtp, Rtcp, } type_;
110
111 Packet() : len_(0) {}
112 Packet(Type type, const void* data, size_t len, int64_t time_ms)
113 : type_(type), len_(len), send_time_ms_(time_ms) {
114 EXPECT_LE(len_, kMaxPacketSizeByte);
115 memcpy(data_, data, len_);
116 }
117
118 uint8_t data_[kMaxPacketSizeByte];
119 size_t len_;
120 int64_t send_time_ms_;
121 };
122
123 static bool Run(void* transport) {
124 return static_cast<ConferenceTransport*>(transport)->DispatchPackets();
125 }
126
127 int GetReceiverChannelForSsrc(unsigned int sender_ssrc) const;
128 void StorePacket(Packet::Type type, const void* data, size_t len);
129 void SendPacket(const Packet& packet);
130 bool DispatchPackets();
131
132 rtc::CriticalSection pq_crit_;
133 rtc::CriticalSection stream_crit_;
134 const std::unique_ptr<webrtc::EventWrapper> packet_event_;
135 rtc::PlatformThread thread_;
136
137 unsigned int rtt_ms_;
138 unsigned int stream_count_;
139
140 std::map<unsigned int, std::pair<int, int>> streams_
141 RTC_GUARDED_BY(stream_crit_);
142 std::deque<Packet> packet_queue_ RTC_GUARDED_BY(pq_crit_);
143
144 int local_sender_; // Channel Id of local sender
145 int reflector_;
146
147 webrtc::VoiceEngine* local_voe_;
148 webrtc::VoEBase* local_base_;
149 webrtc::VoERTP_RTCP* local_rtp_rtcp_;
150 webrtc::VoENetwork* local_network_;
151 rtc::scoped_refptr<webrtc::AudioProcessing> local_apm_;
152
153 webrtc::VoiceEngine* remote_voe_;
154 webrtc::VoEBase* remote_base_;
155 webrtc::VoECodec* remote_codec_;
156 webrtc::VoERTP_RTCP* remote_rtp_rtcp_;
157 webrtc::VoENetwork* remote_network_;
158 webrtc::VoEFile* remote_file_;
159 rtc::scoped_refptr<webrtc::AudioProcessing> remote_apm_;
160 LoudestFilter loudest_filter_;
161
162 const std::unique_ptr<webrtc::RtpHeaderParser> rtp_header_parser_;
163 };
164
165 } // namespace voetest
166 } // namespace webrtc
167
168 #endif // WEBRTC_VOICE_ENGINE_TEST_AUTO_TEST_FAKES_CONFERENCE_TRANSPORT_H_
OLDNEW
« no previous file with comments | « webrtc/voice_engine/BUILD.gn ('k') | webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698