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