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

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

Issue 1817753003: Revert of Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « webrtc/media/base/rtpdataengine_unittest.cc ('k') | webrtc/media/engine/webrtcvideoengine2.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 252 }
253 int NumRtpPackets() { 253 int NumRtpPackets() {
254 return network_interface_.NumRtpPackets(); 254 return network_interface_.NumRtpPackets();
255 } 255 }
256 int NumRtpPackets(uint32_t ssrc) { 256 int NumRtpPackets(uint32_t ssrc) {
257 return network_interface_.NumRtpPackets(ssrc); 257 return network_interface_.NumRtpPackets(ssrc);
258 } 258 }
259 int NumSentSsrcs() { 259 int NumSentSsrcs() {
260 return network_interface_.NumSentSsrcs(); 260 return network_interface_.NumSentSsrcs();
261 } 261 }
262 const rtc::CopyOnWriteBuffer* GetRtpPacket(int index) { 262 const rtc::Buffer* GetRtpPacket(int index) {
263 return network_interface_.GetRtpPacket(index); 263 return network_interface_.GetRtpPacket(index);
264 } 264 }
265 int NumRtcpPackets() { 265 int NumRtcpPackets() {
266 return network_interface_.NumRtcpPackets(); 266 return network_interface_.NumRtcpPackets();
267 } 267 }
268 const rtc::CopyOnWriteBuffer* GetRtcpPacket(int index) { 268 const rtc::Buffer* GetRtcpPacket(int index) {
269 return network_interface_.GetRtcpPacket(index); 269 return network_interface_.GetRtcpPacket(index);
270 } 270 }
271 static int GetPayloadType(const rtc::CopyOnWriteBuffer* p) { 271 static int GetPayloadType(const rtc::Buffer* p) {
272 int pt = -1; 272 int pt = -1;
273 ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL); 273 ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL);
274 return pt; 274 return pt;
275 } 275 }
276 static bool ParseRtpPacket(const rtc::CopyOnWriteBuffer* p, 276 static bool ParseRtpPacket(const rtc::Buffer* p,
277 bool* x, 277 bool* x,
278 int* pt, 278 int* pt,
279 int* seqnum, 279 int* seqnum,
280 uint32_t* tstamp, 280 uint32_t* tstamp,
281 uint32_t* ssrc, 281 uint32_t* ssrc,
282 std::string* payload) { 282 std::string* payload) {
283 // TODO(jbauch): avoid copying the buffer data into the ByteBuffer 283 rtc::ByteBuffer buf(*p);
284 rtc::ByteBuffer buf(p->data<char>(), p->size());
285 uint8_t u08 = 0; 284 uint8_t u08 = 0;
286 uint16_t u16 = 0; 285 uint16_t u16 = 0;
287 uint32_t u32 = 0; 286 uint32_t u32 = 0;
288 287
289 // Read X and CC fields. 288 // Read X and CC fields.
290 if (!buf.ReadUInt8(&u08)) return false; 289 if (!buf.ReadUInt8(&u08)) return false;
291 bool extension = ((u08 & 0x10) != 0); 290 bool extension = ((u08 & 0x10) != 0);
292 uint8_t cc = (u08 & 0x0F); 291 uint8_t cc = (u08 & 0x0F);
293 if (x) *x = extension; 292 if (x) *x = extension;
294 293
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 332 }
334 return true; 333 return true;
335 } 334 }
336 335
337 // Parse all RTCP packet, from start_index to stop_index, and count how many 336 // Parse all RTCP packet, from start_index to stop_index, and count how many
338 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count 337 // FIR (PT=206 and FMT=4 according to RFC 5104). If successful, set the count
339 // and return true. 338 // and return true.
340 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) { 339 bool CountRtcpFir(int start_index, int stop_index, int* fir_count) {
341 int count = 0; 340 int count = 0;
342 for (int i = start_index; i < stop_index; ++i) { 341 for (int i = start_index; i < stop_index; ++i) {
343 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtcpPacket(i)); 342 std::unique_ptr<const rtc::Buffer> p(GetRtcpPacket(i));
344 // TODO(jbauch): avoid copying the buffer data into the ByteBuffer 343 rtc::ByteBuffer buf(*p);
345 rtc::ByteBuffer buf(p->data<char>(), p->size());
346 size_t total_len = 0; 344 size_t total_len = 0;
347 // The packet may be a compound RTCP packet. 345 // The packet may be a compound RTCP packet.
348 while (total_len < p->size()) { 346 while (total_len < p->size()) {
349 // Read FMT, type and length. 347 // Read FMT, type and length.
350 uint8_t fmt = 0; 348 uint8_t fmt = 0;
351 uint8_t type = 0; 349 uint8_t type = 0;
352 uint16_t length = 0; 350 uint16_t length = 0;
353 if (!buf.ReadUInt8(&fmt)) return false; 351 if (!buf.ReadUInt8(&fmt)) return false;
354 fmt &= 0x1F; 352 fmt &= 0x1F;
355 if (!buf.ReadUInt8(&type)) return false; 353 if (!buf.ReadUInt8(&type)) return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 EXPECT_TRUE(SetSend(true)); 397 EXPECT_TRUE(SetSend(true));
400 EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size()); 398 EXPECT_EQ(64 * 1024, network_interface_.sendbuf_size());
401 EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size()); 399 EXPECT_EQ(64 * 1024, network_interface_.recvbuf_size());
402 } 400 }
403 // Tests that we can send frames and the right payload type is used. 401 // Tests that we can send frames and the right payload type is used.
404 void Send(const cricket::VideoCodec& codec) { 402 void Send(const cricket::VideoCodec& codec) {
405 EXPECT_TRUE(SetOneCodec(codec)); 403 EXPECT_TRUE(SetOneCodec(codec));
406 EXPECT_TRUE(SetSend(true)); 404 EXPECT_TRUE(SetSend(true));
407 EXPECT_TRUE(SendFrame()); 405 EXPECT_TRUE(SendFrame());
408 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 406 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
409 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 407 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
410 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 408 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
411 } 409 }
412 // Tests that we can send and receive frames. 410 // Tests that we can send and receive frames.
413 void SendAndReceive(const cricket::VideoCodec& codec) { 411 void SendAndReceive(const cricket::VideoCodec& codec) {
414 EXPECT_TRUE(SetOneCodec(codec)); 412 EXPECT_TRUE(SetOneCodec(codec));
415 EXPECT_TRUE(SetSend(true)); 413 EXPECT_TRUE(SetSend(true));
416 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 414 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
417 EXPECT_EQ(0, renderer_.num_rendered_frames()); 415 EXPECT_EQ(0, renderer_.num_rendered_frames());
418 EXPECT_TRUE(SendFrame()); 416 EXPECT_TRUE(SendFrame());
419 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); 417 EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
420 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 418 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
421 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 419 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
422 } 420 }
423 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec, 421 void SendReceiveManyAndGetStats(const cricket::VideoCodec& codec,
424 int duration_sec, int fps) { 422 int duration_sec, int fps) {
425 EXPECT_TRUE(SetOneCodec(codec)); 423 EXPECT_TRUE(SetOneCodec(codec));
426 EXPECT_TRUE(SetSend(true)); 424 EXPECT_TRUE(SetSend(true));
427 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 425 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
428 EXPECT_EQ(0, renderer_.num_rendered_frames()); 426 EXPECT_EQ(0, renderer_.num_rendered_frames());
429 for (int i = 0; i < duration_sec; ++i) { 427 for (int i = 0; i < duration_sec; ++i) {
430 for (int frame = 1; frame <= fps; ++frame) { 428 for (int frame = 1; frame <= fps; ++frame) {
431 EXPECT_TRUE(WaitAndSendFrame(1000 / fps)); 429 EXPECT_TRUE(WaitAndSendFrame(1000 / fps));
432 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout); 430 EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout);
433 } 431 }
434 } 432 }
435 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 433 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
436 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 434 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
437 } 435 }
438 436
439 // Test that stats work properly for a 1-1 call. 437 // Test that stats work properly for a 1-1 call.
440 void GetStats() { 438 void GetStats() {
441 const int kDurationSec = 3; 439 const int kDurationSec = 3;
442 const int kFps = 10; 440 const int kFps = 10;
443 SendReceiveManyAndGetStats(DefaultCodec(), kDurationSec, kFps); 441 SendReceiveManyAndGetStats(DefaultCodec(), kDurationSec, kFps);
444 442
445 cricket::VideoMediaInfo info; 443 cricket::VideoMediaInfo info;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 parameters.max_bandwidth_bps = 128 * 1024; 616 parameters.max_bandwidth_bps = 128 * 1024;
619 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 617 EXPECT_TRUE(channel_->SetSendParameters(parameters));
620 } 618 }
621 // Test that we can set the SSRC for the default send source. 619 // Test that we can set the SSRC for the default send source.
622 void SetSendSsrc() { 620 void SetSendSsrc() {
623 EXPECT_TRUE(SetDefaultCodec()); 621 EXPECT_TRUE(SetDefaultCodec());
624 EXPECT_TRUE(SetSend(true)); 622 EXPECT_TRUE(SetSend(true));
625 EXPECT_TRUE(SendFrame()); 623 EXPECT_TRUE(SendFrame());
626 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 624 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
627 uint32_t ssrc = 0; 625 uint32_t ssrc = 0;
628 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 626 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
629 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 627 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
630 EXPECT_EQ(kSsrc, ssrc); 628 EXPECT_EQ(kSsrc, ssrc);
631 // Packets are being paced out, so these can mismatch between the first and 629 // Packets are being paced out, so these can mismatch between the first and
632 // second call to NumRtpPackets until pending packets are paced out. 630 // second call to NumRtpPackets until pending packets are paced out.
633 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); 631 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
634 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); 632 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
635 EXPECT_EQ(1, NumSentSsrcs()); 633 EXPECT_EQ(1, NumSentSsrcs());
636 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1)); 634 EXPECT_EQ(0, NumRtpPackets(kSsrc - 1));
637 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1)); 635 EXPECT_EQ(0, NumRtpBytes(kSsrc - 1));
638 } 636 }
639 // Test that we can set the SSRC even after codecs are set. 637 // Test that we can set the SSRC even after codecs are set.
640 void SetSendSsrcAfterSetCodecs() { 638 void SetSendSsrcAfterSetCodecs() {
641 // Remove stream added in Setup. 639 // Remove stream added in Setup.
642 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); 640 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
643 EXPECT_TRUE(SetDefaultCodec()); 641 EXPECT_TRUE(SetDefaultCodec());
644 EXPECT_TRUE(channel_->AddSendStream( 642 EXPECT_TRUE(channel_->AddSendStream(
645 cricket::StreamParams::CreateLegacy(999))); 643 cricket::StreamParams::CreateLegacy(999)));
646 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get())); 644 EXPECT_TRUE(channel_->SetCapturer(999u, video_capturer_.get()));
647 EXPECT_TRUE(SetSend(true)); 645 EXPECT_TRUE(SetSend(true));
648 EXPECT_TRUE(WaitAndSendFrame(0)); 646 EXPECT_TRUE(WaitAndSendFrame(0));
649 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); 647 EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
650 uint32_t ssrc = 0; 648 uint32_t ssrc = 0;
651 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 649 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
652 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 650 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
653 EXPECT_EQ(999u, ssrc); 651 EXPECT_EQ(999u, ssrc);
654 // Packets are being paced out, so these can mismatch between the first and 652 // Packets are being paced out, so these can mismatch between the first and
655 // second call to NumRtpPackets until pending packets are paced out. 653 // second call to NumRtpPackets until pending packets are paced out.
656 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout); 654 EXPECT_EQ_WAIT(NumRtpPackets(), NumRtpPackets(ssrc), kTimeout);
657 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout); 655 EXPECT_EQ_WAIT(NumRtpBytes(), NumRtpBytes(ssrc), kTimeout);
658 EXPECT_EQ(1, NumSentSsrcs()); 656 EXPECT_EQ(1, NumSentSsrcs());
659 EXPECT_EQ(0, NumRtpPackets(kSsrc)); 657 EXPECT_EQ(0, NumRtpPackets(kSsrc));
660 EXPECT_EQ(0, NumRtpBytes(kSsrc)); 658 EXPECT_EQ(0, NumRtpBytes(kSsrc));
661 } 659 }
662 // Test that we can set the default video renderer before and after 660 // Test that we can set the default video renderer before and after
663 // media is received. 661 // media is received.
664 void SetSink() { 662 void SetSink() {
665 uint8_t data1[] = { 663 uint8_t data1[] = {
666 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 664 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
667 665
668 rtc::CopyOnWriteBuffer packet1(data1, sizeof(data1)); 666 rtc::Buffer packet1(data1, sizeof(data1));
669 rtc::SetBE32(packet1.data() + 8, kSsrc); 667 rtc::SetBE32(packet1.data() + 8, kSsrc);
670 channel_->SetSink(kDefaultReceiveSsrc, NULL); 668 channel_->SetSink(kDefaultReceiveSsrc, NULL);
671 EXPECT_TRUE(SetDefaultCodec()); 669 EXPECT_TRUE(SetDefaultCodec());
672 EXPECT_TRUE(SetSend(true)); 670 EXPECT_TRUE(SetSend(true));
673 EXPECT_EQ(0, renderer_.num_rendered_frames()); 671 EXPECT_EQ(0, renderer_.num_rendered_frames());
674 channel_->OnPacketReceived(&packet1, rtc::PacketTime()); 672 channel_->OnPacketReceived(&packet1, rtc::PacketTime());
675 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 673 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
676 EXPECT_TRUE(SendFrame()); 674 EXPECT_TRUE(SendFrame());
677 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); 675 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
678 } 676 }
(...skipping 12 matching lines...) Expand all
691 // Tests setting up and configuring a send stream. 689 // Tests setting up and configuring a send stream.
692 void AddRemoveSendStreams() { 690 void AddRemoveSendStreams() {
693 EXPECT_TRUE(SetOneCodec(DefaultCodec())); 691 EXPECT_TRUE(SetOneCodec(DefaultCodec()));
694 EXPECT_TRUE(SetSend(true)); 692 EXPECT_TRUE(SetSend(true));
695 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_)); 693 EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
696 EXPECT_TRUE(SendFrame()); 694 EXPECT_TRUE(SendFrame());
697 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); 695 EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
698 EXPECT_GT(NumRtpPackets(), 0); 696 EXPECT_GT(NumRtpPackets(), 0);
699 uint32_t ssrc = 0; 697 uint32_t ssrc = 0;
700 size_t last_packet = NumRtpPackets() - 1; 698 size_t last_packet = NumRtpPackets() - 1;
701 std::unique_ptr<const rtc::CopyOnWriteBuffer> 699 std::unique_ptr<const rtc::Buffer>
702 p(GetRtpPacket(static_cast<int>(last_packet))); 700 p(GetRtpPacket(static_cast<int>(last_packet)));
703 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); 701 ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL);
704 EXPECT_EQ(kSsrc, ssrc); 702 EXPECT_EQ(kSsrc, ssrc);
705 703
706 // Remove the send stream that was added during Setup. 704 // Remove the send stream that was added during Setup.
707 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); 705 EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
708 int rtp_packets = NumRtpPackets(); 706 int rtp_packets = NumRtpPackets();
709 707
710 EXPECT_TRUE(channel_->AddSendStream( 708 EXPECT_TRUE(channel_->AddSendStream(
711 cricket::StreamParams::CreateLegacy(789u))); 709 cricket::StreamParams::CreateLegacy(789u)));
(...skipping 29 matching lines...) Expand all
741 std::vector<uint32_t> ssrcs; 739 std::vector<uint32_t> ssrcs;
742 ssrcs.push_back(1); 740 ssrcs.push_back(1);
743 ssrcs.push_back(2); 741 ssrcs.push_back(2);
744 network_interface_.SetConferenceMode(true, ssrcs); 742 network_interface_.SetConferenceMode(true, ssrcs);
745 EXPECT_TRUE(SendFrame()); 743 EXPECT_TRUE(SendFrame());
746 EXPECT_FRAME_ON_RENDERER_WAIT( 744 EXPECT_FRAME_ON_RENDERER_WAIT(
747 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); 745 renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
748 EXPECT_FRAME_ON_RENDERER_WAIT( 746 EXPECT_FRAME_ON_RENDERER_WAIT(
749 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout); 747 renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
750 748
751 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 749 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
752 EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get())); 750 EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get()));
753 EXPECT_EQ(DefaultCodec().width, renderer1.width()); 751 EXPECT_EQ(DefaultCodec().width, renderer1.width());
754 EXPECT_EQ(DefaultCodec().height, renderer1.height()); 752 EXPECT_EQ(DefaultCodec().height, renderer1.height());
755 EXPECT_EQ(DefaultCodec().width, renderer2.width()); 753 EXPECT_EQ(DefaultCodec().width, renderer2.width());
756 EXPECT_EQ(DefaultCodec().height, renderer2.height()); 754 EXPECT_EQ(DefaultCodec().height, renderer2.height());
757 EXPECT_TRUE(channel_->RemoveRecvStream(2)); 755 EXPECT_TRUE(channel_->RemoveRecvStream(2));
758 EXPECT_TRUE(channel_->RemoveRecvStream(1)); 756 EXPECT_TRUE(channel_->RemoveRecvStream(1));
759 } 757 }
760 758
761 // Tests that we can add and remove capturers and frames are sent out properly 759 // Tests that we can add and remove capturers and frames are sent out properly
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 cricket::VideoCodec codec(DefaultCodec()); 1004 cricket::VideoCodec codec(DefaultCodec());
1007 int frame_count = 0; 1005 int frame_count = 0;
1008 // The capturer runs at 30 fps. The channel requires 30 fps. 1006 // The capturer runs at 30 fps. The channel requires 30 fps.
1009 EXPECT_TRUE(SetOneCodec(codec)); 1007 EXPECT_TRUE(SetOneCodec(codec));
1010 EXPECT_TRUE(SetSend(true)); 1008 EXPECT_TRUE(SetSend(true));
1011 EXPECT_EQ(frame_count, renderer_.num_rendered_frames()); 1009 EXPECT_EQ(frame_count, renderer_.num_rendered_frames());
1012 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered. 1010 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1013 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered. 1011 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1014 frame_count += 2; 1012 frame_count += 2;
1015 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout); 1013 EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout);
1016 std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0)); 1014 std::unique_ptr<const rtc::Buffer> p(GetRtpPacket(0));
1017 EXPECT_EQ(codec.id, GetPayloadType(p.get())); 1015 EXPECT_EQ(codec.id, GetPayloadType(p.get()));
1018 1016
1019 // The channel requires 15 fps. 1017 // The channel requires 15 fps.
1020 codec.framerate = 15; 1018 codec.framerate = 15;
1021 EXPECT_TRUE(SetOneCodec(codec)); 1019 EXPECT_TRUE(SetOneCodec(codec));
1022 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered. 1020 EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
1023 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped. 1021 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
1024 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered. 1022 EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
1025 frame_count += 2; 1023 frame_count += 2;
1026 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout); 1024 EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 std::unique_ptr<C> channel_; 1186 std::unique_ptr<C> channel_;
1189 cricket::FakeNetworkInterface network_interface_; 1187 cricket::FakeNetworkInterface network_interface_;
1190 cricket::FakeVideoRenderer renderer_; 1188 cricket::FakeVideoRenderer renderer_;
1191 cricket::VideoMediaChannel::Error media_error_; 1189 cricket::VideoMediaChannel::Error media_error_;
1192 1190
1193 // Used by test cases where 2 streams are run on the same channel. 1191 // Used by test cases where 2 streams are run on the same channel.
1194 cricket::FakeVideoRenderer renderer2_; 1192 cricket::FakeVideoRenderer renderer2_;
1195 }; 1193 };
1196 1194
1197 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT 1195 #endif // WEBRTC_MEDIA_BASE_VIDEOENGINE_UNITTEST_H_ NOLINT
OLDNEW
« no previous file with comments | « webrtc/media/base/rtpdataengine_unittest.cc ('k') | webrtc/media/engine/webrtcvideoengine2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698