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

Side by Side Diff: talk/media/base/videoengine_unittest.h

Issue 1587193006: Move talk/media to webrtc/media (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Disable sign-compare warning on Win Clang Created 4 years, 11 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 * libjingle
3 * Copyright 2014 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ // NOLINT
29 #define TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_
30
31 #include <string>
32 #include <vector>
33
34 #include "talk/media/base/fakenetworkinterface.h"
35 #include "talk/media/base/fakevideocapturer.h"
36 #include "talk/media/base/fakevideorenderer.h"
37 #include "talk/media/base/mediachannel.h"
38 #include "talk/media/base/streamparams.h"
39 #include "talk/media/webrtc/fakewebrtccall.h"
40 #include "webrtc/base/bytebuffer.h"
41 #include "webrtc/base/gunit.h"
42 #include "webrtc/base/timeutils.h"
43 #include "webrtc/call.h"
44
45 #define EXPECT_FRAME_WAIT(c, w, h, t) \
46 EXPECT_EQ_WAIT((c), renderer_.num_rendered_frames(), (t)); \
47 EXPECT_EQ((w), renderer_.width()); \
48 EXPECT_EQ((h), renderer_.height()); \
49 EXPECT_EQ(0, renderer_.errors()); \
50
51 #define EXPECT_FRAME_ON_RENDERER_WAIT(r, c, w, h, t) \
52 EXPECT_EQ_WAIT((c), (r).num_rendered_frames(), (t)); \
53 EXPECT_EQ((w), (r).width()); \
54 EXPECT_EQ((h), (r).height()); \
55 EXPECT_EQ(0, (r).errors()); \
56
57 #define EXPECT_GT_FRAME_ON_RENDERER_WAIT(r, c, w, h, t) \
58 EXPECT_TRUE_WAIT((r).num_rendered_frames() >= (c) && \
59 (w) == (r).width() && \
60 (h) == (r).height(), (t)); \
61 EXPECT_EQ(0, (r).errors());
62
63 static const uint32_t kTimeout = 5000U;
64 static const uint32_t kDefaultReceiveSsrc = 0;
65 static const uint32_t kSsrc = 1234u;
66 static const uint32_t kRtxSsrc = 4321u;
67 static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
68
69 inline bool IsEqualRes(const cricket::VideoCodec& a, int w, int h, int fps) {
70 return a.width == w && a.height == h && a.framerate == fps;
71 }
72
73 inline bool IsEqualCodec(const cricket::VideoCodec& a,
74 const cricket::VideoCodec& b) {
75 return a.id == b.id && a.name == b.name &&
76 IsEqualRes(a, b.width, b.height, b.framerate);
77 }
78
79 namespace std {
80 inline std::ostream& operator<<(std::ostream& s, const cricket::VideoCodec& c) {
81 s << "{" << c.name << "(" << c.id << "), "
82 << c.width << "x" << c.height << "x" << c.framerate << "}";
83 return s;
84 }
85 } // namespace std
86
87 inline int TimeBetweenSend(const cricket::VideoCodec& codec) {
88 return static_cast<int>(
89 cricket::VideoFormat::FpsToInterval(codec.framerate) /
90 rtc::kNumNanosecsPerMillisec);
91 }
92
93 // Fake video engine that makes it possible to test enabling and disabling
94 // capturer (checking that the engine state is updated and that the capturer
95 // is indeed capturing) without having to create a channel. It also makes it
96 // possible to test that the media processors are indeed being called when
97 // registered.
98 template<class T>
99 class VideoEngineOverride : public T {
100 public:
101 VideoEngineOverride() : T() {
102 }
103 virtual ~VideoEngineOverride() {
104 }
105 bool is_camera_on() const { return T::GetVideoCapturer()->IsRunning(); }
106 void set_has_senders(bool has_senders) {
107 cricket::VideoCapturer* video_capturer = T::GetVideoCapturer();
108 if (has_senders) {
109 video_capturer->SignalVideoFrame.connect(this,
110 &VideoEngineOverride<T>::OnLocalFrame);
111 } else {
112 video_capturer->SignalVideoFrame.disconnect(this);
113 }
114 }
115 void OnLocalFrame(cricket::VideoCapturer*,
116 const cricket::VideoFrame*) {
117 }
118 void OnLocalFrameFormat(cricket::VideoCapturer*,
119 const cricket::VideoFormat*) {
120 }
121
122 void TriggerMediaFrame(uint32_t ssrc,
123 cricket::VideoFrame* frame,
124 bool* drop_frame) {
125 T::SignalMediaFrame(ssrc, frame, drop_frame);
126 }
127 };
128
129 template<class E, class C>
130 class VideoMediaChannelTest : public testing::Test,
131 public sigslot::has_slots<> {
132 protected:
133 VideoMediaChannelTest<E, C>()
134 : call_(webrtc::Call::Create(webrtc::Call::Config())) {}
135
136 virtual cricket::VideoCodec DefaultCodec() = 0;
137
138 virtual cricket::StreamParams DefaultSendStreamParams() {
139 return cricket::StreamParams::CreateLegacy(kSsrc);
140 }
141
142 virtual void SetUp() {
143 cricket::Device device("test", "device");
144 engine_.Init();
145 channel_.reset(
146 engine_.CreateChannel(call_.get(), cricket::VideoOptions()));
147 EXPECT_TRUE(channel_.get() != NULL);
148 network_interface_.SetDestination(channel_.get());
149 channel_->SetInterface(&network_interface_);
150 media_error_ = cricket::VideoMediaChannel::ERROR_NONE;
151 cricket::VideoRecvParameters parameters;
152 parameters.codecs = engine_.codecs();
153 channel_->SetRecvParameters(parameters);
154 EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams()));
155 video_capturer_.reset(CreateFakeVideoCapturer());
156 cricket::VideoFormat format(640, 480,
157 cricket::VideoFormat::FpsToInterval(30),
158 cricket::FOURCC_I420);
159 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format));
160 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
161 }
162
163 virtual cricket::FakeVideoCapturer* CreateFakeVideoCapturer() {
164 return new cricket::FakeVideoCapturer();
165 }
166
167 // Utility method to setup an additional stream to send and receive video.
168 // Used to test send and recv between two streams.
169 void SetUpSecondStream() {
170 SetUpSecondStreamWithNoRecv();
171 // Setup recv for second stream.
172 EXPECT_TRUE(channel_->AddRecvStream(
173 cricket::StreamParams::CreateLegacy(kSsrc + 2)));
174 // Make the second renderer available for use by a new stream.
175 EXPECT_TRUE(channel_->SetRenderer(kSsrc + 2, &renderer2_));
176 }
177 // Setup an additional stream just to send video. Defer add recv stream.
178 // This is required if you want to test unsignalled recv of video rtp packets.
179 void SetUpSecondStreamWithNoRecv() {
180 // SetUp() already added kSsrc make sure duplicate SSRCs cant be added.
181 EXPECT_TRUE(channel_->AddRecvStream(
182 cricket::StreamParams::CreateLegacy(kSsrc)));
183 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_));
184 EXPECT_FALSE(channel_->AddSendStream(
185 cricket::StreamParams::CreateLegacy(kSsrc)));
186 EXPECT_TRUE(channel_->AddSendStream(
187 cricket::StreamParams::CreateLegacy(kSsrc + 2)));
188 // We dont add recv for the second stream.
189
190 // Setup the receive and renderer for second stream after send.
191 video_capturer_2_.reset(CreateFakeVideoCapturer());
192 cricket::VideoFormat format(640, 480,
193 cricket::VideoFormat::FpsToInterval(30),
194 cricket::FOURCC_I420);
195 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_2_->Start(format));
196
197 EXPECT_TRUE(channel_->SetCapturer(kSsrc + 2, video_capturer_2_.get()));
198 }
199 virtual void TearDown() {
200 channel_.reset();
201 }
202 bool SetDefaultCodec() {
203 return SetOneCodec(DefaultCodec());
204 }
205
206 bool SetOneCodec(int pt, const char* name, int w, int h, int fr) {
207 return SetOneCodec(cricket::VideoCodec(pt, name, w, h, fr, 0));
208 }
209 bool SetOneCodec(const cricket::VideoCodec& codec) {
210 cricket::VideoFormat capture_format(codec.width, codec.height,
211 cricket::VideoFormat::FpsToInterval(codec.framerate),
212 cricket::FOURCC_I420);
213
214 if (video_capturer_) {
215 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format));
216 }
217 if (video_capturer_2_) {
218 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_2_->Start(capture_format));
219 }
220
221 bool sending = channel_->sending();
222 bool success = SetSend(false);
223 if (success) {
224 cricket::VideoSendParameters parameters;
225 parameters.codecs.push_back(codec);
226 success = channel_->SetSendParameters(parameters);
227 }
228 if (success) {
229 success = SetSend(sending);
230 }
231 return success;
232 }
233 bool SetSend(bool send) {
234 return channel_->SetSend(send);
235 }
236 bool SetSendStreamFormat(uint32_t ssrc, const cricket::VideoCodec& codec) {
237 return channel_->SetSendStreamFormat(ssrc, cricket::VideoFormat(
238 codec.width, codec.height,
239 cricket::VideoFormat::FpsToInterval(codec.framerate),
240 cricket::FOURCC_ANY));
241 }
242 int DrainOutgoingPackets() {
243 int packets = 0;
244 do {
245 packets = NumRtpPackets();
246 // 100 ms should be long enough.
247 rtc::Thread::Current()->ProcessMessages(100);
248 } while (NumRtpPackets() > packets);
249 return NumRtpPackets();
250 }
251 bool SendFrame() {
252 if (video_capturer_2_) {
253 video_capturer_2_->CaptureFrame();
254 }
255 return video_capturer_.get() &&
256 video_capturer_->CaptureFrame();
257 }
258 bool WaitAndSendFrame(int wait_ms) {
259 bool ret = rtc::Thread::Current()->ProcessMessages(wait_ms);
260 ret &= SendFrame();
261 return ret;
262 }
263 // Sends frames and waits for the decoder to be fully initialized.
264 // Returns the number of frames that were sent.
265 int WaitForDecoder() {
266 #if defined(HAVE_OPENMAX)
267 // Send enough frames for the OpenMAX decoder to continue processing, and
268 // return the number of frames sent.
269 // Send frames for a full kTimeout's worth of 15fps video.
270 int frame_count = 0;
271 while (frame_count < static_cast<int>(kTimeout) / 66) {
272 EXPECT_TRUE(WaitAndSendFrame(66));
273 ++frame_count;
274 }
275 return frame_count;
276 #else
277 return 0;
278 #endif
279 }
280 bool SendCustomVideoFrame(int w, int h) {
281 if (!video_capturer_.get()) return false;
282 return video_capturer_->CaptureCustomFrame(w, h, cricket::FOURCC_I420);
283 }
284 int NumRtpBytes() {
285 return network_interface_.NumRtpBytes();
286 }
287 int NumRtpBytes(uint32_t ssrc) {
288 return network_interface_.NumRtpBytes(ssrc);
289 }
290 int NumRtpPackets() {
291 return network_interface_.NumRtpPackets();
292 }
293 int NumRtpPackets(uint32_t ssrc) {
294 return network_interface_.NumRtpPackets(ssrc);
295 }
296 int NumSentSsrcs() {
297 return network_interface_.NumSentSsrcs();
298 }
299 const rtc::Buffer* GetRtpPacket(int index) {
300 return network_interface_.GetRtpPacket(index);
301 }
302 int NumRtcpPackets() {
303 return network_interface_.NumRtcpPackets();
304 }
305 const rtc::Buffer* GetRtcpPacket(int index) {
306 return network_interface_.GetRtcpPacket(index);
307 }
308 static int GetPayloadType(const rtc::Buffer* p) {
309 int pt = -1;
310 ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL);
311 return pt;
312 }
313 static bool ParseRtpPacket(const rtc::Buffer* p,
314 bool* x,
315 int* pt,
316 int* seqnum,
317 uint32_t* tstamp,
318 uint32_t* ssrc,
319 std::string* payload) {
320 rtc::ByteBuffer buf(*p);
321 uint8_t u08 = 0;
322 uint16_t u16 = 0;
323 uint32_t u32 = 0;
324
325 // Read X and CC fields.
326 if (!buf.ReadUInt8(&u08)) return false;
327 bool extension = ((u08 & 0x10) != 0);
328 uint8_t cc = (u08 & 0x0F);
329 if (x) *x = extension;
330
331 // Read PT field.
332 if (!buf.ReadUInt8(&u08)) return false;
333 if (pt) *pt = (u08 & 0x7F);
334
335 // Read Sequence Number field.
336 if (!buf.ReadUInt16(&u16)) return false;
337 if (seqnum) *seqnum = u16;
338
339 // Read Timestamp field.
340 if (!buf.ReadUInt32(&u32)) return false;
341 if (tstamp) *tstamp = u32;
342
343 // Read SSRC field.
344 if (!buf.ReadUInt32(&u32)) return false;
345 if (ssrc) *ssrc = u32;
346
347 // Skip CSRCs.
348 for (uint8_t i = 0; i < cc; ++i) {
349 if (!buf.ReadUInt32(&u32)) return false;
350 }
351
352 // Skip extension header.
353 if (extension) {
354 // Read Profile-specific extension header ID
355 if (!buf.ReadUInt16(&u16)) return false;
356
357 // Read Extension header length
358 if (!buf.ReadUInt16(&u16)) return false;
359 uint16_t ext_header_len = u16;
360
361 // Read Extension header
362 for (uint16_t i = 0; i < ext_header_len; ++i) {
363 if (!buf.ReadUInt32(&u32)) return false;
364 }
365 }
366
367 if (payload) {
368 return buf.ReadString(payload, buf.Length());
369 }
370 return true;
371 }
372
373 // Parse all RTCP packet, from start_index to stop_index, and count how many
374 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count
375 // and return true.
376 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) {
377 int count = 0;
378 for (int i = start_index; i < stop_index; ++i) {
379 rtc::scoped_ptr<const rtc::Buffer> p(GetRtcpPacket(i));
380 rtc::ByteBuffer buf(*p);
381 size_t total_len = 0;
382 // The packet may be a compound RTCP packet.
383 while (total_len < p->size()) {
384 // Read FMT, type and length.
385 uint8_t fmt = 0;
386 uint8_t type = 0;
387 uint16_t length = 0;
388 if (!buf.ReadUInt8(&fmt)) return false;
389 fmt &= 0x1F;
390 if (!buf.ReadUInt8(&type)) return false;
391 if (!buf.ReadUInt16(&length)) return false;
392 buf.Consume(length * 4); // Skip RTCP data.
393 total_len += (length + 1) * 4;
394 if ((192 == type) || ((206 == type) && (4 == fmt))) {
395 ++count;
396 }
397 }
398 }
399
400 if (fir_count) {
401 *fir_count = count;
402 }
403 return true;
404 }
405
406 void OnVideoChannelError(uint32_t ssrc,
407 cricket::VideoMediaChannel::Error error) {
408 media_error_ = error;
409 }
410
411 // Test that SetSend works.
412 void SetSend() {
413 EXPECT_FALSE(channel_->sending());
414 EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get()));
415 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
416 EXPECT_FALSE(channel_->sending());
417 EXPECT_TRUE(SetSend(true));
418 EXPECT_TRUE(channel_->sending());
419 EXPECT_TRUE(SendFrame());
420 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
421 EXPECT_TRUE(SetSend(false));
422 EXPECT_FALSE(channel_->sending());
423 }
424 // Test that SetSend fails without codecs being set.
425 void SetSendWithoutCodecs() {
426 EXPECT_FALSE(channel_->sending());
427 EXPECT_FALSE(SetSend(true));
428 EXPECT_FALSE(channel_->sending());
429 }
430 // Test that we properly set the send and recv buffer sizes by the time
431 // SetSend is called.
432 void SetSendSetsTransportBufferSizes() {
433 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
434 EXPECT_TRUE(SetSend(true));
435 EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
436 EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size());
437 }
438 // Tests that we can send frames and the right payload type is used.
439 void Send(const cricket::VideoCodec& codec) {
440 EXPECT_TRUE(SetOneCodec(codec));
441 EXPECT_TRUE(SetSend(true));
442 EXPECT_TRUE(SendFrame());
443 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
444 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
445 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
446 }
447 // Tests that we can send and receive frames.
448 void SendAndReceive(const cricket::VideoCodec& codec) {
449 EXPECT_TRUE(SetOneCodec(codec));
450 EXPECT_TRUE(SetSend(true));
451 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
452 EXPECT_EQ(0, renderer_.num_rendered_frames());
453 EXPECT_TRUE(SendFrame());
454 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
455 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
456 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
457 }
458 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec,
459 int duration_sec, int fps) {
460 EXPECT_TRUE(SetOneCodec(codec));
461 EXPECT_TRUE(SetSend(true));
462 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
463 EXPECT_EQ(0, renderer_.num_rendered_frames());
464 for (int i = 0; i < duration_sec; ++i) {
465 for (int frame = 1; frame <= fps; ++frame) {
466 EXPECT_TRUE(WaitAndSendFrame(1000 / fps));
467 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout);
468 }
469 }
470 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
471 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
472 }
473
474 // Test that stats work properly for a 1-1 call.
475 void GetStats() {
476 const int kDurationSec = 3;
477 const int kFps = 10;
478 SendReceiveManyAndGetStats(DefaultCodec(), kDurationSec, kFps);
479
480 cricket::VideoMediaInfo info;
481 EXPECT_TRUE(channel_->GetStats(&info));
482
483 ASSERT_EQ(1U, info.senders.size());
484 // TODO(whyuan): bytes_sent and bytes_rcvd are different. Are both payload?
485 // For webrtc, bytes_sent does not include the RTP header length.
486 EXPECT_GT(info.senders[0].bytes_sent, 0);
487 EXPECT_EQ(NumRtpPackets(), info.senders[0].packets_sent);
488 EXPECT_EQ(0.0, info.senders[0].fraction_lost);
489 EXPECT_EQ(0, info.senders[0].firs_rcvd);
490 EXPECT_EQ(0, info.senders[0].plis_rcvd);
491 EXPECT_EQ(0, info.senders[0].nacks_rcvd);
492 EXPECT_EQ(DefaultCodec().width, info.senders[0].send_frame_width);
493 EXPECT_EQ(DefaultCodec().height, info.senders[0].send_frame_height);
494 EXPECT_GT(info.senders[0].framerate_input, 0);
495 EXPECT_GT(info.senders[0].framerate_sent, 0);
496
497 ASSERT_EQ(1U, info.receivers.size());
498 EXPECT_EQ(1U, info.senders[0].ssrcs().size());
499 EXPECT_EQ(1U, info.receivers[0].ssrcs().size());
500 EXPECT_EQ(info.senders[0].ssrcs()[0], info.receivers[0].ssrcs()[0]);
501 EXPECT_EQ(NumRtpBytes(), info.receivers[0].bytes_rcvd);
502 EXPECT_EQ(NumRtpPackets(), info.receivers[0].packets_rcvd);
503 EXPECT_EQ(0.0, info.receivers[0].fraction_lost);
504 EXPECT_EQ(0, info.receivers[0].packets_lost);
505 // TODO(asapersson): Not set for webrtc. Handle missing stats.
506 // EXPECT_EQ(0, info.receivers[0].packets_concealed);
507 EXPECT_EQ(0, info.receivers[0].firs_sent);
508 EXPECT_EQ(0, info.receivers[0].plis_sent);
509 EXPECT_EQ(0, info.receivers[0].nacks_sent);
510 EXPECT_EQ(DefaultCodec().width, info.receivers[0].frame_width);
511 EXPECT_EQ(DefaultCodec().height, info.receivers[0].frame_height);
512 EXPECT_GT(info.receivers[0].framerate_rcvd, 0);
513 EXPECT_GT(info.receivers[0].framerate_decoded, 0);
514 EXPECT_GT(info.receivers[0].framerate_output, 0);
515 }
516
517 cricket::VideoSenderInfo GetSenderStats(size_t i) {
518 cricket::VideoMediaInfo info;
519 EXPECT_TRUE(channel_->GetStats(&info));
520 return info.senders[i];
521 }
522
523 cricket::VideoReceiverInfo GetReceiverStats(size_t i) {
524 cricket::VideoMediaInfo info;
525 EXPECT_TRUE(channel_->GetStats(&info));
526 return info.receivers[i];
527 }
528
529 // Test that stats work properly for a conf call with multiple recv streams.
530 void GetStatsMultipleRecvStreams() {
531 cricket::FakeVideoRenderer renderer1, renderer2;
532 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
533 cricket::VideoSendParameters parameters;
534 parameters.codecs.push_back(DefaultCodec());
535 parameters.options.conference_mode = rtc::Optional<bool>(true);
536 EXPECT_TRUE(channel_->SetSendParameters(parameters));
537 EXPECT_TRUE(SetSend(true));
538 EXPECT_TRUE(channel_->AddRecvStream(
539 cricket::StreamParams::CreateLegacy(1)));
540 EXPECT_TRUE(channel_->AddRecvStream(
541 cricket::StreamParams::CreateLegacy(2)));
542 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1));
543 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2));
544 EXPECT_EQ(0, renderer1.num_rendered_frames());
545 EXPECT_EQ(0, renderer2.num_rendered_frames());
546 std::vector<uint32_t> ssrcs;
547 ssrcs.push_back(1);
548 ssrcs.push_back(2);
549 network_interface_.SetConferenceMode(true, ssrcs);
550 EXPECT_TRUE(SendFrame());
551 EXPECT_FRAME_ON_RENDERER_WAIT(
552 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
553 EXPECT_FRAME_ON_RENDERER_WAIT(
554 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
555
556 EXPECT_TRUE(channel_->SetSend(false));
557
558 cricket::VideoMediaInfo info;
559 EXPECT_TRUE(channel_->GetStats(&info));
560 ASSERT_EQ(1U, info.senders.size());
561 // TODO(whyuan): bytes_sent and bytes_rcvd are different. Are both payload?
562 // For webrtc, bytes_sent does not include the RTP header length.
563 EXPECT_GT(GetSenderStats(0).bytes_sent, 0);
564 EXPECT_EQ_WAIT(NumRtpPackets(), GetSenderStats(0).packets_sent, kTimeout);
565 EXPECT_EQ(DefaultCodec().width, GetSenderStats(0).send_frame_width);
566 EXPECT_EQ(DefaultCodec().height, GetSenderStats(0).send_frame_height);
567
568 ASSERT_EQ(2U, info.receivers.size());
569 for (size_t i = 0; i < info.receivers.size(); ++i) {
570 EXPECT_EQ(1U, GetReceiverStats(i).ssrcs().size());
571 EXPECT_EQ(i + 1, GetReceiverStats(i).ssrcs()[0]);
572 EXPECT_EQ_WAIT(NumRtpBytes(), GetReceiverStats(i).bytes_rcvd, kTimeout);
573 EXPECT_EQ_WAIT(NumRtpPackets(), GetReceiverStats(i).packets_rcvd,
574 kTimeout);
575 EXPECT_EQ(DefaultCodec().width, GetReceiverStats(i).frame_width);
576 EXPECT_EQ(DefaultCodec().height, GetReceiverStats(i).frame_height);
577 }
578 }
579 // Test that stats work properly for a conf call with multiple send streams.
580 void GetStatsMultipleSendStreams() {
581 // Normal setup; note that we set the SSRC explicitly to ensure that
582 // it will come first in the senders map.
583 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
584 cricket::VideoSendParameters parameters;
585 parameters.codecs.push_back(DefaultCodec());
586 parameters.options.conference_mode = rtc::Optional<bool>(true);
587 EXPECT_TRUE(channel_->SetSendParameters(parameters));
588 EXPECT_TRUE(channel_->AddRecvStream(
589 cricket::StreamParams::CreateLegacy(kSsrc)));
590 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_));
591 channel_->UpdateAspectRatio(640, 400);
592 EXPECT_TRUE(SetSend(true));
593 EXPECT_TRUE(SendFrame());
594 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
595 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
596
597 // Add an additional capturer, and hook up a renderer to receive it.
598 cricket::FakeVideoRenderer renderer2;
599 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
600 CreateFakeVideoCapturer());
601 capturer->SetScreencast(true);
602 const int kTestWidth = 160;
603 const int kTestHeight = 120;
604 cricket::VideoFormat format(kTestWidth, kTestHeight,
605 cricket::VideoFormat::FpsToInterval(5),
606 cricket::FOURCC_I420);
607 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format));
608 EXPECT_TRUE(channel_->AddSendStream(
609 cricket::StreamParams::CreateLegacy(5678)));
610 EXPECT_TRUE(channel_->SetCapturer(5678, capturer.get()));
611 EXPECT_TRUE(channel_->AddRecvStream(
612 cricket::StreamParams::CreateLegacy(5678)));
613 EXPECT_TRUE(channel_->SetRenderer(5678, &renderer2));
614 EXPECT_TRUE(capturer->CaptureCustomFrame(
615 kTestWidth, kTestHeight, cricket::FOURCC_I420));
616 EXPECT_FRAME_ON_RENDERER_WAIT(
617 renderer2, 1, kTestWidth, kTestHeight, kTimeout);
618
619 // Get stats, and make sure they are correct for two senders. We wait until
620 // the number of expected packets have been sent to avoid races where we
621 // check stats before it has been updated.
622 cricket::VideoMediaInfo info;
623 for (uint32_t i = 0; i < kTimeout; ++i) {
624 rtc::Thread::Current()->ProcessMessages(1);
625 EXPECT_TRUE(channel_->GetStats(&info));
626 ASSERT_EQ(2U, info.senders.size());
627 if (info.senders[0].packets_sent + info.senders[1].packets_sent ==
628 NumRtpPackets()) {
629 // Stats have been updated for both sent frames, expectations can be
630 // checked now.
631 break;
632 }
633 }
634 EXPECT_EQ(NumRtpPackets(),
635 info.senders[0].packets_sent + info.senders[1].packets_sent)
636 << "Timed out while waiting for packet counts for all sent packets.";
637 EXPECT_EQ(1U, info.senders[0].ssrcs().size());
638 EXPECT_EQ(1234U, info.senders[0].ssrcs()[0]);
639 EXPECT_EQ(DefaultCodec().width, info.senders[0].send_frame_width);
640 EXPECT_EQ(DefaultCodec().height, info.senders[0].send_frame_height);
641 EXPECT_EQ(1U, info.senders[1].ssrcs().size());
642 EXPECT_EQ(5678U, info.senders[1].ssrcs()[0]);
643 EXPECT_EQ(kTestWidth, info.senders[1].send_frame_width);
644 EXPECT_EQ(kTestHeight, info.senders[1].send_frame_height);
645 // The capturer must be unregistered here as it runs out of it's scope next.
646 EXPECT_TRUE(channel_->SetCapturer(5678, NULL));
647 }
648
649 // Test that we can set the bandwidth.
650 void SetSendBandwidth() {
651 cricket::VideoSendParameters parameters;
652 parameters.codecs.push_back(DefaultCodec());
653 parameters.max_bandwidth_bps = -1; // <= 0 means unlimited.
654 EXPECT_TRUE(channel_->SetSendParameters(parameters));
655 parameters.max_bandwidth_bps = 128 * 1024;
656 EXPECT_TRUE(channel_->SetSendParameters(parameters));
657 }
658 // Test that we can set the SSRC for the default send source.
659 void SetSendSsrc() {
660 EXPECT_TRUE(SetDefaultCodec());
661 EXPECT_TRUE(SetSendStreamFormat(kSsrc, DefaultCodec()));
662 EXPECT_TRUE(SetSend(true));
663 EXPECT_TRUE(SendFrame());
664 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
665 uint32_t ssrc = 0;
666 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
667 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
668 EXPECT_EQ(kSsrc, ssrc);
669 // Packets are being paced out, so these can mismatch between the first and
670 // second call to NumRtpPackets until pending packets are paced out.
671 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
672 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
673 EXPECT_EQ(1, NumSentSsrcs());
674 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1));
675 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1));
676 }
677 // Test that we can set the SSRC even after codecs are set.
678 void SetSendSsrcAfterSetCodecs() {
679 // Remove stream added in Setup.
680 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
681 EXPECT_TRUE(SetDefaultCodec());
682 EXPECT_TRUE(channel_->AddSendStream(
683 cricket::StreamParams::CreateLegacy(999)));
684 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get()));
685 EXPECT_TRUE(SetSendStreamFormat(999u, DefaultCodec()));
686 EXPECT_TRUE(SetSend(true));
687 EXPECT_TRUE(WaitAndSendFrame(0));
688 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
689 uint32_t ssrc = 0;
690 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
691 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
692 EXPECT_EQ(999u, ssrc);
693 // Packets are being paced out, so these can mismatch between the first and
694 // second call to NumRtpPackets until pending packets are paced out.
695 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
696 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
697 EXPECT_EQ(1, NumSentSsrcs());
698 EXPECT_EQ(0, NumRtpPackets(kSsrc));
699 EXPECT_EQ(0, NumRtpBytes(kSsrc));
700 }
701 // Test that we can set the default video renderer before and after
702 // media is received.
703 void SetRenderer() {
704 uint8_t data1[] = {
705 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
706
707 rtc::Buffer packet1(data1, sizeof(data1));
708 rtc::SetBE32(packet1.data() + 8, kSsrc);
709 channel_->SetRenderer(kDefaultReceiveSsrc, NULL);
710 EXPECT_TRUE(SetDefaultCodec());
711 EXPECT_TRUE(SetSend(true));
712 EXPECT_EQ(0, renderer_.num_rendered_frames());
713 channel_->OnPacketReceived(&packet1, rtc::PacketTime());
714 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
715 EXPECT_TRUE(SendFrame());
716 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
717 }
718
719 // Tests empty StreamParams is rejected.
720 void RejectEmptyStreamParams() {
721 // Remove the send stream that was added during Setup.
722 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
723
724 cricket::StreamParams empty;
725 EXPECT_FALSE(channel_->AddSendStream(empty));
726 EXPECT_TRUE(channel_->AddSendStream(
727 cricket::StreamParams::CreateLegacy(789u)));
728 }
729
730 // Tests setting up and configuring a send stream.
731 void AddRemoveSendStreams() {
732 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
733 EXPECT_TRUE(SetSend(true));
734 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
735 EXPECT_TRUE(SendFrame());
736 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
737 EXPECT_GT(NumRtpPackets(), 0);
738 uint32_t ssrc = 0;
739 size_t last_packet = NumRtpPackets() - 1;
740 rtc::scoped_ptr<const rtc::Buffer>
741 p(GetRtpPacket(static_cast<int>(last_packet)));
742 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
743 EXPECT_EQ(kSsrc, ssrc);
744
745 // Remove the send stream that was added during Setup.
746 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
747 int rtp_packets = NumRtpPackets();
748
749 EXPECT_TRUE(channel_->AddSendStream(
750 cricket::StreamParams::CreateLegacy(789u)));
751 EXPECT_TRUE(channel_->SetCapturer(789u, video_capturer_.get()));
752 EXPECT_EQ(rtp_packets, NumRtpPackets());
753 // Wait 30ms to guarantee the engine does not drop the frame.
754 EXPECT_TRUE(WaitAndSendFrame(30));
755 EXPECT_TRUE_WAIT(NumRtpPackets() > rtp_packets, kTimeout);
756
757 last_packet = NumRtpPackets() - 1;
758 p.reset(GetRtpPacket(static_cast<int>(last_packet)));
759 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
760 EXPECT_EQ(789u, ssrc);
761 }
762
763 // Test that no frames are rendered after the receive stream have been
764 // removed.
765 void AddRemoveRecvStreamAndRender() {
766 cricket::FakeVideoRenderer renderer1;
767 EXPECT_TRUE(SetDefaultCodec());
768 EXPECT_TRUE(SetSend(true));
769 EXPECT_TRUE(channel_->AddRecvStream(
770 cricket::StreamParams::CreateLegacy(kSsrc)));
771 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer1));
772
773 EXPECT_TRUE(SendFrame());
774 EXPECT_FRAME_ON_RENDERER_WAIT(
775 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
776 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc));
777 // Send three more frames. This is to avoid that the test might be flaky
778 // due to frame dropping.
779 for (size_t i = 0; i < 3; ++i)
780 EXPECT_TRUE(WaitAndSendFrame(100));
781
782 // Test that no more frames have been rendered.
783 EXPECT_EQ(1, renderer1.num_rendered_frames());
784
785 // Re-add the stream again and make sure it renders.
786 EXPECT_TRUE(channel_->AddRecvStream(
787 cricket::StreamParams::CreateLegacy(kSsrc)));
788 // Force the next frame to be a key frame to make the receiving
789 // decoder happy.
790 EXPECT_TRUE(channel_->SendIntraFrame());
791
792 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer1));
793 EXPECT_TRUE(SendFrame());
794 // Because the default channel is used, RemoveRecvStream above is not going
795 // to delete the channel. As a result the engine will continue to receive
796 // and decode the 3 frames sent above. So it is possible we will receive
797 // some (e.g. 1) of these 3 frames after the renderer is set again.
798 EXPECT_GT_FRAME_ON_RENDERER_WAIT(
799 renderer1, 2, DefaultCodec().width, DefaultCodec().height, kTimeout);
800 // Detach |renderer1| before exit as there might be frames come late.
801 EXPECT_TRUE(channel_->SetRenderer(kSsrc, NULL));
802 }
803
804 // Tests the behavior of incoming streams in a conference scenario.
805 void SimulateConference() {
806 cricket::FakeVideoRenderer renderer1, renderer2;
807 EXPECT_TRUE(SetDefaultCodec());
808 cricket::VideoSendParameters parameters;
809 parameters.codecs.push_back(DefaultCodec());
810 parameters.options.conference_mode = rtc::Optional<bool>(true);
811 EXPECT_TRUE(channel_->SetSendParameters(parameters));
812 EXPECT_TRUE(SetSend(true));
813 EXPECT_TRUE(channel_->AddRecvStream(
814 cricket::StreamParams::CreateLegacy(1)));
815 EXPECT_TRUE(channel_->AddRecvStream(
816 cricket::StreamParams::CreateLegacy(2)));
817 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1));
818 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2));
819 EXPECT_EQ(0, renderer1.num_rendered_frames());
820 EXPECT_EQ(0, renderer2.num_rendered_frames());
821 std::vector<uint32_t> ssrcs;
822 ssrcs.push_back(1);
823 ssrcs.push_back(2);
824 network_interface_.SetConferenceMode(true, ssrcs);
825 EXPECT_TRUE(SendFrame());
826 EXPECT_FRAME_ON_RENDERER_WAIT(
827 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
828 EXPECT_FRAME_ON_RENDERER_WAIT(
829 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
830
831 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
832 EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get()));
833 EXPECT_EQ(DefaultCodec().width, renderer1.width());
834 EXPECT_EQ(DefaultCodec().height, renderer1.height());
835 EXPECT_EQ(DefaultCodec().width, renderer2.width());
836 EXPECT_EQ(DefaultCodec().height, renderer2.height());
837 EXPECT_TRUE(channel_->RemoveRecvStream(2));
838 EXPECT_TRUE(channel_->RemoveRecvStream(1));
839 }
840
841 // Tests that we can add and remove capturers and frames are sent out properly
842 void AddRemoveCapturer() {
843 cricket::VideoCodec codec = DefaultCodec();
844 codec.width = 320;
845 codec.height = 240;
846 const int time_between_send = TimeBetweenSend(codec);
847 EXPECT_TRUE(SetOneCodec(codec));
848 EXPECT_TRUE(SetSend(true));
849 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
850 EXPECT_EQ(0, renderer_.num_rendered_frames());
851 EXPECT_TRUE(SendFrame());
852 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
853 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
854 CreateFakeVideoCapturer());
855 capturer->SetScreencast(true);
856 cricket::VideoFormat format(480, 360,
857 cricket::VideoFormat::FpsToInterval(30),
858 cricket::FOURCC_I420);
859 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(format));
860 // All capturers start generating frames with the same timestamp. ViE does
861 // not allow the same timestamp to be used. Capture one frame before
862 // associating the capturer with the channel.
863 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
864 cricket::FOURCC_I420));
865
866 int captured_frames = 1;
867 for (int iterations = 0; iterations < 2; ++iterations) {
868 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get()));
869 rtc::Thread::Current()->ProcessMessages(time_between_send);
870 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
871 cricket::FOURCC_I420));
872 ++captured_frames;
873 // Wait until frame of right size is captured.
874 EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= captured_frames &&
875 format.width == renderer_.width() &&
876 format.height == renderer_.height() &&
877 !renderer_.black_frame(), kTimeout);
878 EXPECT_GE(renderer_.num_rendered_frames(), captured_frames);
879 EXPECT_EQ(format.width, renderer_.width());
880 EXPECT_EQ(format.height, renderer_.height());
881 captured_frames = renderer_.num_rendered_frames() + 1;
882 EXPECT_FALSE(renderer_.black_frame());
883 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
884 // Make sure a black frame is generated within the specified timeout.
885 // The black frame should be the resolution of the previous frame to
886 // prevent expensive encoder reconfigurations.
887 EXPECT_TRUE_WAIT(renderer_.num_rendered_frames() >= captured_frames &&
888 format.width == renderer_.width() &&
889 format.height == renderer_.height() &&
890 renderer_.black_frame(), kTimeout);
891 EXPECT_GE(renderer_.num_rendered_frames(), captured_frames);
892 EXPECT_EQ(format.width, renderer_.width());
893 EXPECT_EQ(format.height, renderer_.height());
894 EXPECT_TRUE(renderer_.black_frame());
895
896 // The black frame has the same timestamp as the next frame since it's
897 // timestamp is set to the last frame's timestamp + interval. WebRTC will
898 // not render a frame with the same timestamp so capture another frame
899 // with the frame capturer to increment the next frame's timestamp.
900 EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
901 cricket::FOURCC_I420));
902 }
903 }
904
905 // Tests that if RemoveCapturer is called without a capturer ever being
906 // added, the plugin shouldn't crash (and no black frame should be sent).
907 void RemoveCapturerWithoutAdd() {
908 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
909 EXPECT_TRUE(SetSend(true));
910 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
911 EXPECT_EQ(0, renderer_.num_rendered_frames());
912 EXPECT_TRUE(SendFrame());
913 EXPECT_FRAME_WAIT(1, 640, 400, kTimeout);
914 // Wait for one frame so they don't get dropped because we send frames too
915 // tightly.
916 rtc::Thread::Current()->ProcessMessages(30);
917 // Remove the capturer.
918 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
919 // Wait for one black frame for removing the capturer.
920 EXPECT_FRAME_WAIT(2, 640, 400, kTimeout);
921
922 // No capturer was added, so this RemoveCapturer should
923 // fail.
924 EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL));
925 rtc::Thread::Current()->ProcessMessages(300);
926 // Verify no more frames were sent.
927 EXPECT_EQ(2, renderer_.num_rendered_frames());
928 }
929
930 // Tests that we can add and remove capturer as unique sources.
931 void AddRemoveCapturerMultipleSources() {
932 // WebRTC implementation will drop frames if pushed to quickly. Wait the
933 // interval time to avoid that.
934 // WebRTC implementation will drop frames if pushed to quickly. Wait the
935 // interval time to avoid that.
936 // Set up the stream associated with the engine.
937 EXPECT_TRUE(channel_->AddRecvStream(
938 cricket::StreamParams::CreateLegacy(kSsrc)));
939 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer_));
940 cricket::VideoFormat capture_format; // default format
941 capture_format.interval = cricket::VideoFormat::FpsToInterval(30);
942 // Set up additional stream 1.
943 cricket::FakeVideoRenderer renderer1;
944 EXPECT_FALSE(channel_->SetRenderer(1, &renderer1));
945 EXPECT_TRUE(channel_->AddRecvStream(
946 cricket::StreamParams::CreateLegacy(1)));
947 EXPECT_TRUE(channel_->SetRenderer(1, &renderer1));
948 EXPECT_TRUE(channel_->AddSendStream(
949 cricket::StreamParams::CreateLegacy(1)));
950 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer1(
951 CreateFakeVideoCapturer());
952 capturer1->SetScreencast(true);
953 EXPECT_EQ(cricket::CS_RUNNING, capturer1->Start(capture_format));
954 // Set up additional stream 2.
955 cricket::FakeVideoRenderer renderer2;
956 EXPECT_FALSE(channel_->SetRenderer(2, &renderer2));
957 EXPECT_TRUE(channel_->AddRecvStream(
958 cricket::StreamParams::CreateLegacy(2)));
959 EXPECT_TRUE(channel_->SetRenderer(2, &renderer2));
960 EXPECT_TRUE(channel_->AddSendStream(
961 cricket::StreamParams::CreateLegacy(2)));
962 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer2(
963 CreateFakeVideoCapturer());
964 capturer2->SetScreencast(true);
965 EXPECT_EQ(cricket::CS_RUNNING, capturer2->Start(capture_format));
966 // State for all the streams.
967 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
968 // A limitation in the lmi implementation requires that SetCapturer() is
969 // called after SetOneCodec().
970 // TODO(hellner): this seems like an unnecessary constraint, fix it.
971 EXPECT_TRUE(channel_->SetCapturer(1, capturer1.get()));
972 EXPECT_TRUE(channel_->SetCapturer(2, capturer2.get()));
973 EXPECT_TRUE(SetSend(true));
974 // Test capturer associated with engine.
975 const int kTestWidth = 160;
976 const int kTestHeight = 120;
977 EXPECT_TRUE(capturer1->CaptureCustomFrame(
978 kTestWidth, kTestHeight, cricket::FOURCC_I420));
979 EXPECT_FRAME_ON_RENDERER_WAIT(
980 renderer1, 1, kTestWidth, kTestHeight, kTimeout);
981 // Capture a frame with additional capturer2, frames should be received
982 EXPECT_TRUE(capturer2->CaptureCustomFrame(
983 kTestWidth, kTestHeight, cricket::FOURCC_I420));
984 EXPECT_FRAME_ON_RENDERER_WAIT(
985 renderer2, 1, kTestWidth, kTestHeight, kTimeout);
986 // Successfully remove the capturer.
987 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
988 // Fail to re-remove the capturer.
989 EXPECT_FALSE(channel_->SetCapturer(kSsrc, NULL));
990 // The capturers must be unregistered here as it runs out of it's scope
991 // next.
992 EXPECT_TRUE(channel_->SetCapturer(1, NULL));
993 EXPECT_TRUE(channel_->SetCapturer(2, NULL));
994 }
995
996 void HighAspectHighHeightCapturer() {
997 const int kWidth = 80;
998 const int kHeight = 10000;
999 const int kScaledWidth = 20;
1000 const int kScaledHeight = 2500;
1001
1002 cricket::VideoCodec codec(DefaultCodec());
1003 EXPECT_TRUE(SetOneCodec(codec));
1004 EXPECT_TRUE(SetSend(true));
1005
1006 cricket::FakeVideoRenderer renderer;
1007 EXPECT_TRUE(channel_->AddRecvStream(
1008 cricket::StreamParams::CreateLegacy(kSsrc)));
1009 EXPECT_TRUE(channel_->SetRenderer(kSsrc, &renderer));
1010 EXPECT_EQ(0, renderer.num_rendered_frames());
1011
1012 EXPECT_TRUE(SendFrame());
1013 EXPECT_GT_FRAME_ON_RENDERER_WAIT(
1014 renderer, 1, codec.width, codec.height, kTimeout);
1015
1016 // Registering an external capturer is currently the same as screen casting
1017 // (update the test when this changes).
1018 rtc::scoped_ptr<cricket::FakeVideoCapturer> capturer(
1019 CreateFakeVideoCapturer());
1020 capturer->SetScreencast(true);
1021 const std::vector<cricket::VideoFormat>* formats =
1022 capturer->GetSupportedFormats();
1023 cricket::VideoFormat capture_format = (*formats)[0];
1024 EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format));
1025 // Capture frame to not get same frame timestamps as previous capturer.
1026 capturer->CaptureFrame();
1027 EXPECT_TRUE(channel_->SetCapturer(kSsrc, capturer.get()));
1028 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
1029 EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight,
1030 cricket::FOURCC_ARGB));
1031 EXPECT_GT_FRAME_ON_RENDERER_WAIT(
1032 renderer, 2, kScaledWidth, kScaledHeight, kTimeout);
1033 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
1034 }
1035
1036 // Tests that we can adapt video resolution with 16:10 aspect ratio properly.
1037 void AdaptResolution16x10() {
1038 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1039 cricket::VideoCodec codec(DefaultCodec());
1040 codec.width = 640;
1041 codec.height = 400;
1042 SendAndReceive(codec);
1043 codec.width /= 2;
1044 codec.height /= 2;
1045 // Adapt the resolution.
1046 EXPECT_TRUE(SetOneCodec(codec));
1047 EXPECT_TRUE(WaitAndSendFrame(30));
1048 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout);
1049 }
1050 // Tests that we can adapt video resolution with 4:3 aspect ratio properly.
1051 void AdaptResolution4x3() {
1052 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1053 cricket::VideoCodec codec(DefaultCodec());
1054 codec.width = 640;
1055 codec.height = 400;
1056 SendAndReceive(codec);
1057 codec.width /= 2;
1058 codec.height /= 2;
1059 // Adapt the resolution.
1060 EXPECT_TRUE(SetOneCodec(codec));
1061 EXPECT_TRUE(WaitAndSendFrame(30));
1062 EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout);
1063 }
1064 // Tests that we can drop all frames properly.
1065 void AdaptDropAllFrames() {
1066 // Set the channel codec's resolution to 0, which will require the adapter
1067 // to drop all frames.
1068 cricket::VideoCodec codec(DefaultCodec());
1069 codec.width = codec.height = codec.framerate = 0;
1070 EXPECT_TRUE(SetOneCodec(codec));
1071 EXPECT_TRUE(SetSend(true));
1072 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1073 EXPECT_EQ(0, renderer_.num_rendered_frames());
1074 EXPECT_TRUE(SendFrame());
1075 EXPECT_TRUE(SendFrame());
1076 rtc::Thread::Current()->ProcessMessages(500);
1077 EXPECT_EQ(0, renderer_.num_rendered_frames());
1078 }
1079 // Tests that we can reduce the frame rate on demand properly.
1080 // TODO(fbarchard): This test is flakey on pulse. Fix and re-enable
1081 void AdaptFramerate() {
1082 cricket::VideoCodec codec(DefaultCodec());
1083 int frame_count = 0;
1084 // The capturer runs at 30 fps. The channel requires 30 fps.
1085 EXPECT_TRUE(SetOneCodec(codec));
1086 EXPECT_TRUE(SetSend(true));
1087 EXPECT_EQ(frame_count, renderer_.num_rendered_frames());
1088 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1089 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1090 frame_count += 2;
1091 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout);
1092 rtc::scoped_ptr<const rtc::Buffer> p(GetRtpPacket(0));
1093 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
1094
1095 // The channel requires 15 fps.
1096 codec.framerate = 15;
1097 EXPECT_TRUE(SetOneCodec(codec));
1098 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1099 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1100 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1101 frame_count += 2;
1102 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1103
1104 // The channel requires 10 fps.
1105 codec.framerate = 10;
1106 EXPECT_TRUE(SetOneCodec(codec));
1107 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1108 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1109 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1110 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1111 frame_count += 2;
1112 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1113
1114 // The channel requires 8 fps. The adapter adapts to 10 fps, which is the
1115 // closest factor of 30.
1116 codec.framerate = 8;
1117 EXPECT_TRUE(SetOneCodec(codec));
1118 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1119 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1120 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1121 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1122 frame_count += 2;
1123 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1124 }
1125 // Tests that adapted frames won't be upscaled to a higher resolution.
1126 void SendsLowerResolutionOnSmallerFrames() {
1127 cricket::VideoCodec codec = DefaultCodec();
1128 codec.width = 320;
1129 codec.height = 240;
1130 EXPECT_TRUE(SetOneCodec(codec));
1131 EXPECT_TRUE(SetSend(true));
1132 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1133 EXPECT_EQ(0, renderer_.num_rendered_frames());
1134 EXPECT_TRUE(SendFrame());
1135 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
1136
1137 // Check that we send smaller frames at the new resolution.
1138 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(33));
1139 EXPECT_TRUE(video_capturer_->CaptureCustomFrame(
1140 codec.width / 2, codec.height / 2, cricket::FOURCC_I420));
1141 EXPECT_FRAME_WAIT(2, codec.width / 2, codec.height / 2, kTimeout);
1142 }
1143 // Tests that we can set the send stream format properly.
1144 void SetSendStreamFormat() {
1145 cricket::VideoCodec codec(DefaultCodec());
1146 SendAndReceive(codec);
1147 int frame_count = 1;
1148 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout);
1149
1150 // Adapt the resolution and frame rate to half.
1151 cricket::VideoFormat format(
1152 codec.width / 2,
1153 codec.height / 2,
1154 cricket::VideoFormat::FpsToInterval(codec.framerate / 2),
1155 cricket::FOURCC_I420);
1156 // The SSRC differs from the send SSRC.
1157 EXPECT_FALSE(channel_->SetSendStreamFormat(kSsrc - 1, format));
1158 EXPECT_TRUE(channel_->SetSendStreamFormat(kSsrc, format));
1159
1160 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1161 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1162 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1163 frame_count += 1;
1164 EXPECT_FRAME_WAIT(frame_count, format.width, format.height, kTimeout);
1165
1166 // Adapt the resolution to 0x0, which should drop all frames.
1167 format.width = 0;
1168 format.height = 0;
1169 EXPECT_TRUE(channel_->SetSendStreamFormat(kSsrc, format));
1170 EXPECT_TRUE(SendFrame());
1171 EXPECT_TRUE(SendFrame());
1172 rtc::Thread::Current()->ProcessMessages(500);
1173 EXPECT_EQ(frame_count, renderer_.num_rendered_frames());
1174 }
1175 // Test that setting send stream format to 0x0 resolution will result in
1176 // frames being dropped.
1177 void SetSendStreamFormat0x0() {
1178 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
1179 EXPECT_TRUE(SetSendStreamFormat(kSsrc, DefaultCodec()));
1180 EXPECT_TRUE(SetSend(true));
1181 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1182 EXPECT_EQ(0, renderer_.num_rendered_frames());
1183 // This frame should be received.
1184 EXPECT_TRUE(SendFrame());
1185 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
1186 const int64_t interval =
1187 cricket::VideoFormat::FpsToInterval(DefaultCodec().framerate);
1188 cricket::VideoFormat format(
1189 0,
1190 0,
1191 interval,
1192 cricket::FOURCC_I420);
1193 EXPECT_TRUE(channel_->SetSendStreamFormat(kSsrc, format));
1194 // This frame should not be received.
1195 EXPECT_TRUE(WaitAndSendFrame(
1196 static_cast<int>(interval/rtc::kNumNanosecsPerMillisec)));
1197 rtc::Thread::Current()->ProcessMessages(500);
1198 EXPECT_EQ(1, renderer_.num_rendered_frames());
1199 }
1200
1201 // Tests that we can mute and unmute the channel properly.
1202 void MuteStream() {
1203 EXPECT_TRUE(SetDefaultCodec());
1204 cricket::FakeVideoCapturer video_capturer;
1205 video_capturer.Start(
1206 cricket::VideoFormat(
1207 640, 480,
1208 cricket::VideoFormat::FpsToInterval(30),
1209 cricket::FOURCC_I420));
1210 EXPECT_TRUE(channel_->SetCapturer(kSsrc, &video_capturer));
1211 EXPECT_TRUE(SetSend(true));
1212 EXPECT_TRUE(channel_->SetRenderer(kDefaultReceiveSsrc, &renderer_));
1213 EXPECT_EQ(0, renderer_.num_rendered_frames());
1214 // Mute the channel and expect black output frame.
1215 int frame_count = 0;
1216 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
1217 EXPECT_TRUE(video_capturer.CaptureFrame());
1218 ++frame_count;
1219 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1220 EXPECT_TRUE(renderer_.black_frame());
1221 // Unmute the channel and expect non-black output frame.
1222 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
1223 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
1224 EXPECT_TRUE(video_capturer.CaptureFrame());
1225 ++frame_count;
1226 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1227 EXPECT_FALSE(renderer_.black_frame());
1228 // Test that we can also Mute using the correct send stream SSRC.
1229 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
1230 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
1231 EXPECT_TRUE(video_capturer.CaptureFrame());
1232 ++frame_count;
1233 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1234 EXPECT_TRUE(renderer_.black_frame());
1235 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
1236 EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
1237 EXPECT_TRUE(video_capturer.CaptureFrame());
1238 ++frame_count;
1239 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
1240 EXPECT_FALSE(renderer_.black_frame());
1241 // Test that muting an existing stream succeeds even if it's muted.
1242 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
1243 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, false, nullptr));
1244 // Test that unmuting an existing stream succeeds even if it's not muted.
1245 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
1246 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr));
1247 // Test that muting an invalid stream fails.
1248 EXPECT_FALSE(channel_->SetVideoSend(kSsrc+1, false, nullptr));
1249 EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL));
1250 }
1251
1252 // Test that multiple send streams can be created and deleted properly.
1253 void MultipleSendStreams() {
1254 // Remove stream added in Setup. I.e. remove stream corresponding to default
1255 // channel.
1256 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
1257 const unsigned int kSsrcsSize = sizeof(kSsrcs4)/sizeof(kSsrcs4[0]);
1258 for (unsigned int i = 0; i < kSsrcsSize; ++i) {
1259 EXPECT_TRUE(channel_->AddSendStream(
1260 cricket::StreamParams::CreateLegacy(kSsrcs4[i])));
1261 }
1262 // Delete one of the non default channel streams, let the destructor delete
1263 // the remaining ones.
1264 EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs4[kSsrcsSize - 1]));
1265 // Stream should already be deleted.
1266 EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[kSsrcsSize - 1]));
1267 }
1268
1269 // Two streams one channel tests.
1270
1271 // Tests that we can send and receive frames.
1272 void TwoStreamsSendAndReceive(const cricket::VideoCodec& codec) {
1273 SetUpSecondStream();
1274 // Test sending and receiving on first stream.
1275 SendAndReceive(codec);
1276 // Test sending and receiving on second stream.
1277 EXPECT_EQ_WAIT(1, renderer2_.num_rendered_frames(), kTimeout);
1278 EXPECT_GT(NumRtpPackets(), 0);
1279 EXPECT_EQ(1, renderer2_.num_rendered_frames());
1280 }
1281
1282 // Set up 2 streams where the first stream uses the default channel.
1283 // Then disconnect the first stream and verify default channel becomes
1284 // available.
1285 // Then add a new stream with |new_ssrc|. The new stream should re-use the
1286 // default channel.
1287 void TwoStreamsReUseFirstStream(const cricket::VideoCodec& codec) {
1288 SetUpSecondStream();
1289 // Default channel used by the first stream.
1290 EXPECT_EQ(kSsrc, channel_->GetDefaultSendChannelSsrc());
1291 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc));
1292 EXPECT_FALSE(channel_->RemoveRecvStream(kSsrc));
1293 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
1294 EXPECT_FALSE(channel_->RemoveSendStream(kSsrc));
1295 // Default channel is no longer used by a stream.
1296 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
1297 uint32_t new_ssrc = kSsrc + 100;
1298 EXPECT_TRUE(channel_->AddSendStream(
1299 cricket::StreamParams::CreateLegacy(new_ssrc)));
1300 // Re-use default channel.
1301 EXPECT_EQ(new_ssrc, channel_->GetDefaultSendChannelSsrc());
1302 EXPECT_FALSE(channel_->AddSendStream(
1303 cricket::StreamParams::CreateLegacy(new_ssrc)));
1304 EXPECT_TRUE(channel_->AddRecvStream(
1305 cricket::StreamParams::CreateLegacy(new_ssrc)));
1306 EXPECT_TRUE(channel_->SetRenderer(new_ssrc, &renderer_));
1307 EXPECT_FALSE(channel_->AddRecvStream(
1308 cricket::StreamParams::CreateLegacy(new_ssrc)));
1309
1310 EXPECT_TRUE(channel_->SetCapturer(new_ssrc, video_capturer_.get()));
1311
1312 SendAndReceive(codec);
1313 EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc));
1314 EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
1315 }
1316
1317 // Tests that we can send and receive frames with early receive.
1318 void TwoStreamsSendAndUnsignalledRecv(const cricket::VideoCodec& codec) {
1319 cricket::VideoSendParameters parameters;
1320 parameters.options.conference_mode = rtc::Optional<bool>(true);
1321 parameters.options.unsignalled_recv_stream_limit = rtc::Optional<int>(1);
1322 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1323 SetUpSecondStreamWithNoRecv();
1324 // Test sending and receiving on first stream.
1325 Send(codec);
1326 EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout);
1327 EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
1328 // The first send is not expected to yield frames, because the ssrc
1329 // is not signalled yet. With unsignalled recv enabled, we will drop frames
1330 // instead of packets.
1331 EXPECT_EQ(0, renderer2_.num_rendered_frames());
1332 // Give a chance for the decoder to process before adding the receiver.
1333 rtc::Thread::Current()->ProcessMessages(100);
1334 // Test sending and receiving on second stream.
1335 EXPECT_TRUE(channel_->AddRecvStream(
1336 cricket::StreamParams::CreateLegacy(kSsrc + 2)));
1337 EXPECT_TRUE(channel_->SetRenderer(kSsrc + 2, &renderer2_));
1338 SendFrame();
1339 EXPECT_EQ_WAIT(2, renderer_.num_rendered_frames(), kTimeout);
1340 EXPECT_EQ(4, NumRtpPackets());
1341 // The second send is expected to yield frame as the ssrc is signalled now.
1342 // Decode should succeed here, though we received the key frame earlier.
1343 // Without early recv, we would have dropped it and decoding would have
1344 // failed.
1345 EXPECT_EQ_WAIT(1, renderer2_.num_rendered_frames(), kTimeout);
1346 }
1347
1348 // Tests that we drop key frames when conference mode is enabled and we
1349 // receive rtp packets on unsignalled streams. Removal of a unsignalled recv
1350 // stream is successful.
1351 void TwoStreamsAddAndRemoveUnsignalledRecv(
1352 const cricket::VideoCodec& codec) {
1353 cricket::VideoOptions vmo;
1354 vmo.conference_mode = rtc::Optional<bool>(true);
1355 vmo.unsignalled_recv_stream_limit = rtc::Optional<int>(1);
1356 EXPECT_TRUE(channel_->SetOptions(vmo));
1357 SetUpSecondStreamWithNoRecv();
1358 // Sending and receiving on first stream.
1359 Send(codec);
1360 EXPECT_EQ_WAIT(2, NumRtpPackets(), kTimeout);
1361 EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
1362 // The first send is not expected to yield frames, because the ssrc
1363 // is no signalled yet. With unsignalled recv enabled, we will drop frames
1364 // instead of packets.
1365 EXPECT_EQ(0, renderer2_.num_rendered_frames());
1366 // Give a chance for the decoder to process before adding the receiver.
1367 rtc::Thread::Current()->ProcessMessages(100);
1368 // Ensure that we can remove the unsignalled recv stream that was created
1369 // when the first video packet with unsignalled recv ssrc is received.
1370 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc + 2));
1371 }
1372
1373 const rtc::scoped_ptr<webrtc::Call> call_;
1374 VideoEngineOverride<E> engine_;
1375 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_;
1376 rtc::scoped_ptr<cricket::FakeVideoCapturer> video_capturer_2_;
1377 rtc::scoped_ptr<C> channel_;
1378 cricket::FakeNetworkInterface network_interface_;
1379 cricket::FakeVideoRenderer renderer_;
1380 cricket::VideoMediaChannel::Error media_error_;
1381
1382 // Used by test cases where 2 streams are run on the same channel.
1383 cricket::FakeVideoRenderer renderer2_;
1384 };
1385
1386 #endif // TALK_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698