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

Side by Side Diff: talk/session/media/channel.cc

Issue 1219663008: Remove media sinks from Channel. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 5 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 | « talk/session/media/channel.h ('k') | talk/session/media/channel_unittest.cc » ('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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 496
497 // Protect ourselves against crazy data. 497 // Protect ourselves against crazy data.
498 if (!ValidPacket(rtcp, packet)) { 498 if (!ValidPacket(rtcp, packet)) {
499 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " " 499 LOG(LS_ERROR) << "Dropping outgoing " << content_name_ << " "
500 << PacketType(rtcp) 500 << PacketType(rtcp)
501 << " packet: wrong size=" << packet->size(); 501 << " packet: wrong size=" << packet->size();
502 return false; 502 return false;
503 } 503 }
504 504
505 // Signal to the media sink before protecting the packet.
506 {
507 rtc::CritScope cs(&signal_send_packet_cs_);
508 SignalSendPacketPreCrypto(packet->data(), packet->size(), rtcp);
509 }
510
511 rtc::PacketOptions options(dscp); 505 rtc::PacketOptions options(dscp);
512 // Protect if needed. 506 // Protect if needed.
513 if (srtp_filter_.IsActive()) { 507 if (srtp_filter_.IsActive()) {
514 bool res; 508 bool res;
515 uint8_t* data = packet->data(); 509 uint8_t* data = packet->data();
516 int len = static_cast<int>(packet->size()); 510 int len = static_cast<int>(packet->size());
517 if (!rtcp) { 511 if (!rtcp) {
518 // If ENABLE_EXTERNAL_AUTH flag is on then packet authentication is not done 512 // If ENABLE_EXTERNAL_AUTH flag is on then packet authentication is not done
519 // inside libsrtp for a RTP packet. A external HMAC module will be writing 513 // inside libsrtp for a RTP packet. A external HMAC module will be writing
520 // a fake HMAC value. This is ONLY done for a RTP packet. 514 // a fake HMAC value. This is ONLY done for a RTP packet.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 packet->SetSize(len); 563 packet->SetSize(len);
570 } else if (secure_required_) { 564 } else if (secure_required_) {
571 // This is a double check for something that supposedly can't happen. 565 // This is a double check for something that supposedly can't happen.
572 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp) 566 LOG(LS_ERROR) << "Can't send outgoing " << PacketType(rtcp)
573 << " packet when SRTP is inactive and crypto is required"; 567 << " packet when SRTP is inactive and crypto is required";
574 568
575 ASSERT(false); 569 ASSERT(false);
576 return false; 570 return false;
577 } 571 }
578 572
579 // Signal to the media sink after protecting the packet.
580 {
581 rtc::CritScope cs(&signal_send_packet_cs_);
582 SignalSendPacketPostCrypto(packet->data(), packet->size(), rtcp);
583 }
584
585 // Bon voyage. 573 // Bon voyage.
586 int ret = 574 int ret =
587 channel->SendPacket(packet->data<char>(), packet->size(), options, 575 channel->SendPacket(packet->data<char>(), packet->size(), options,
588 (secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0); 576 (secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0);
589 if (ret != static_cast<int>(packet->size())) { 577 if (ret != static_cast<int>(packet->size())) {
590 if (channel->GetError() == EWOULDBLOCK) { 578 if (channel->GetError() == EWOULDBLOCK) {
591 LOG(LS_WARNING) << "Got EWOULDBLOCK from socket."; 579 LOG(LS_WARNING) << "Got EWOULDBLOCK from socket.";
592 SetReadyToSend(channel, false); 580 SetReadyToSend(channel, false);
593 } 581 }
594 return false; 582 return false;
(...skipping 20 matching lines...) Expand all
615 return; 603 return;
616 } 604 }
617 605
618 // We are only interested in the first rtp packet because that 606 // We are only interested in the first rtp packet because that
619 // indicates the media has started flowing. 607 // indicates the media has started flowing.
620 if (!has_received_packet_ && !rtcp) { 608 if (!has_received_packet_ && !rtcp) {
621 has_received_packet_ = true; 609 has_received_packet_ = true;
622 signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED); 610 signaling_thread()->Post(this, MSG_FIRSTPACKETRECEIVED);
623 } 611 }
624 612
625 // Signal to the media sink before unprotecting the packet.
626 {
627 rtc::CritScope cs(&signal_recv_packet_cs_);
628 SignalRecvPacketPostCrypto(packet->data(), packet->size(), rtcp);
629 }
630
631 // Unprotect the packet, if needed. 613 // Unprotect the packet, if needed.
632 if (srtp_filter_.IsActive()) { 614 if (srtp_filter_.IsActive()) {
633 char* data = packet->data<char>(); 615 char* data = packet->data<char>();
634 int len = static_cast<int>(packet->size()); 616 int len = static_cast<int>(packet->size());
635 bool res; 617 bool res;
636 if (!rtcp) { 618 if (!rtcp) {
637 res = srtp_filter_.UnprotectRtp(data, len, &len); 619 res = srtp_filter_.UnprotectRtp(data, len, &len);
638 if (!res) { 620 if (!res) {
639 int seq_num = -1; 621 int seq_num = -1;
640 uint32 ssrc = 0; 622 uint32 ssrc = 0;
(...skipping 25 matching lines...) Expand all
666 // channels, so we haven't yet extracted keys, even if DTLS did complete 648 // channels, so we haven't yet extracted keys, even if DTLS did complete
667 // on the channel that the packets are being sent on. It's really good 649 // on the channel that the packets are being sent on. It's really good
668 // practice to wait for both RTP and RTCP to be good to go before sending 650 // practice to wait for both RTP and RTCP to be good to go before sending
669 // media, to prevent weird failure modes, so it's fine for us to just eat 651 // media, to prevent weird failure modes, so it's fine for us to just eat
670 // packets here. This is all sidestepped if RTCP mux is used anyway. 652 // packets here. This is all sidestepped if RTCP mux is used anyway.
671 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp) 653 LOG(LS_WARNING) << "Can't process incoming " << PacketType(rtcp)
672 << " packet when SRTP is inactive and crypto is required"; 654 << " packet when SRTP is inactive and crypto is required";
673 return; 655 return;
674 } 656 }
675 657
676 // Signal to the media sink after unprotecting the packet.
677 {
678 rtc::CritScope cs(&signal_recv_packet_cs_);
679 SignalRecvPacketPreCrypto(packet->data(), packet->size(), rtcp);
680 }
681
682 // Push it down to the media channel. 658 // Push it down to the media channel.
683 if (!rtcp) { 659 if (!rtcp) {
684 media_channel_->OnPacketReceived(packet, packet_time); 660 media_channel_->OnPacketReceived(packet, packet_time);
685 } else { 661 } else {
686 media_channel_->OnRtcpReceived(packet, packet_time); 662 media_channel_->OnRtcpReceived(packet, packet_time);
687 } 663 }
688 } 664 }
689 665
690 void BaseChannel::OnNewLocalDescription( 666 void BaseChannel::OnNewLocalDescription(
691 BaseSession* session, ContentAction action) { 667 BaseSession* session, ContentAction action) {
(...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2526 return (data_channel_type_ == DCT_RTP); 2502 return (data_channel_type_ == DCT_RTP);
2527 } 2503 }
2528 2504
2529 void DataChannel::OnStreamClosedRemotely(uint32 sid) { 2505 void DataChannel::OnStreamClosedRemotely(uint32 sid) {
2530 rtc::TypedMessageData<uint32>* message = 2506 rtc::TypedMessageData<uint32>* message =
2531 new rtc::TypedMessageData<uint32>(sid); 2507 new rtc::TypedMessageData<uint32>(sid);
2532 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); 2508 signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message);
2533 } 2509 }
2534 2510
2535 } // namespace cricket 2511 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/session/media/channel.h ('k') | talk/session/media/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698