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