| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. and Robin Seggelmann | 3 * Copyright 2012 Google Inc. and Robin Seggelmann |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (!first) result << " | "; | 81 if (!first) result << " | "; |
| 82 result << flaginfo[i].name; | 82 result << flaginfo[i].name; |
| 83 first = false; | 83 first = false; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 return result.str(); | 86 return result.str(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Returns a comma-separated, human-readable list of the integers in 'array'. | 89 // Returns a comma-separated, human-readable list of the integers in 'array'. |
| 90 // All 'num_elems' of them. | 90 // All 'num_elems' of them. |
| 91 std::string ListArray(const uint16* array, int num_elems) { | 91 std::string ListArray(const uint16_t* array, int num_elems) { |
| 92 std::stringstream result; | 92 std::stringstream result; |
| 93 for (int i = 0; i < num_elems; ++i) { | 93 for (int i = 0; i < num_elems; ++i) { |
| 94 if (i) { | 94 if (i) { |
| 95 result << ", " << array[i]; | 95 result << ", " << array[i]; |
| 96 } else { | 96 } else { |
| 97 result << array[i]; | 97 result << array[i]; |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 return result.str(); | 100 return result.str(); |
| 101 } | 101 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 568 } |
| 569 | 569 |
| 570 bool SctpDataMediaChannel::SetRecvParameters(const DataRecvParameters& params) { | 570 bool SctpDataMediaChannel::SetRecvParameters(const DataRecvParameters& params) { |
| 571 return SetRecvCodecs(params.codecs); | 571 return SetRecvCodecs(params.codecs); |
| 572 } | 572 } |
| 573 | 573 |
| 574 bool SctpDataMediaChannel::AddSendStream(const StreamParams& stream) { | 574 bool SctpDataMediaChannel::AddSendStream(const StreamParams& stream) { |
| 575 return AddStream(stream); | 575 return AddStream(stream); |
| 576 } | 576 } |
| 577 | 577 |
| 578 bool SctpDataMediaChannel::RemoveSendStream(uint32 ssrc) { | 578 bool SctpDataMediaChannel::RemoveSendStream(uint32_t ssrc) { |
| 579 return ResetStream(ssrc); | 579 return ResetStream(ssrc); |
| 580 } | 580 } |
| 581 | 581 |
| 582 bool SctpDataMediaChannel::AddRecvStream(const StreamParams& stream) { | 582 bool SctpDataMediaChannel::AddRecvStream(const StreamParams& stream) { |
| 583 // SCTP DataChannels are always bi-directional and calling AddSendStream will | 583 // SCTP DataChannels are always bi-directional and calling AddSendStream will |
| 584 // enable both sending and receiving on the stream. So AddRecvStream is a | 584 // enable both sending and receiving on the stream. So AddRecvStream is a |
| 585 // no-op. | 585 // no-op. |
| 586 return true; | 586 return true; |
| 587 } | 587 } |
| 588 | 588 |
| 589 bool SctpDataMediaChannel::RemoveRecvStream(uint32 ssrc) { | 589 bool SctpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) { |
| 590 // SCTP DataChannels are always bi-directional and calling RemoveSendStream | 590 // SCTP DataChannels are always bi-directional and calling RemoveSendStream |
| 591 // will disable both sending and receiving on the stream. So RemoveRecvStream | 591 // will disable both sending and receiving on the stream. So RemoveRecvStream |
| 592 // is a no-op. | 592 // is a no-op. |
| 593 return true; | 593 return true; |
| 594 } | 594 } |
| 595 | 595 |
| 596 bool SctpDataMediaChannel::SendData( | 596 bool SctpDataMediaChannel::SendData( |
| 597 const SendDataParams& params, | 597 const SendDataParams& params, |
| 598 const rtc::Buffer& payload, | 598 const rtc::Buffer& payload, |
| 599 SendDataResult* result) { | 599 SendDataResult* result) { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 << "Not receiving packet with sid=" << params.ssrc | 720 << "Not receiving packet with sid=" << params.ssrc |
| 721 << " len=" << buffer->size() << " before SetReceive(true)."; | 721 << " len=" << buffer->size() << " before SetReceive(true)."; |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 | 724 |
| 725 bool SctpDataMediaChannel::AddStream(const StreamParams& stream) { | 725 bool SctpDataMediaChannel::AddStream(const StreamParams& stream) { |
| 726 if (!stream.has_ssrcs()) { | 726 if (!stream.has_ssrcs()) { |
| 727 return false; | 727 return false; |
| 728 } | 728 } |
| 729 | 729 |
| 730 const uint32 ssrc = stream.first_ssrc(); | 730 const uint32_t ssrc = stream.first_ssrc(); |
| 731 if (open_streams_.find(ssrc) != open_streams_.end()) { | 731 if (open_streams_.find(ssrc) != open_streams_.end()) { |
| 732 LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): " | 732 LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): " |
| 733 << "Not adding data stream '" << stream.id | 733 << "Not adding data stream '" << stream.id |
| 734 << "' with ssrc=" << ssrc | 734 << "' with ssrc=" << ssrc |
| 735 << " because stream is already open."; | 735 << " because stream is already open."; |
| 736 return false; | 736 return false; |
| 737 } else if (queued_reset_streams_.find(ssrc) != queued_reset_streams_.end() | 737 } else if (queued_reset_streams_.find(ssrc) != queued_reset_streams_.end() |
| 738 || sent_reset_streams_.find(ssrc) != sent_reset_streams_.end()) { | 738 || sent_reset_streams_.find(ssrc) != sent_reset_streams_.end()) { |
| 739 LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): " | 739 LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): " |
| 740 << "Not adding data stream '" << stream.id | 740 << "Not adding data stream '" << stream.id |
| 741 << "' with ssrc=" << ssrc | 741 << "' with ssrc=" << ssrc |
| 742 << " because stream is still closing."; | 742 << " because stream is still closing."; |
| 743 return false; | 743 return false; |
| 744 } | 744 } |
| 745 | 745 |
| 746 open_streams_.insert(ssrc); | 746 open_streams_.insert(ssrc); |
| 747 return true; | 747 return true; |
| 748 } | 748 } |
| 749 | 749 |
| 750 bool SctpDataMediaChannel::ResetStream(uint32 ssrc) { | 750 bool SctpDataMediaChannel::ResetStream(uint32_t ssrc) { |
| 751 // We typically get this called twice for the same stream, once each for | 751 // We typically get this called twice for the same stream, once each for |
| 752 // Send and Recv. | 752 // Send and Recv. |
| 753 StreamSet::iterator found = open_streams_.find(ssrc); | 753 StreamSet::iterator found = open_streams_.find(ssrc); |
| 754 | 754 |
| 755 if (found == open_streams_.end()) { | 755 if (found == open_streams_.end()) { |
| 756 LOG(LS_VERBOSE) << debug_name_ << "->ResetStream(" << ssrc << "): " | 756 LOG(LS_VERBOSE) << debug_name_ << "->ResetStream(" << ssrc << "): " |
| 757 << "stream not found."; | 757 << "stream not found."; |
| 758 return false; | 758 return false; |
| 759 } else { | 759 } else { |
| 760 LOG(LS_VERBOSE) << debug_name_ << "->ResetStream(" << ssrc << "): " | 760 LOG(LS_VERBOSE) << debug_name_ << "->ResetStream(" << ssrc << "): " |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 bool SctpDataMediaChannel::SendQueuedStreamResets() { | 990 bool SctpDataMediaChannel::SendQueuedStreamResets() { |
| 991 if (!sent_reset_streams_.empty() || queued_reset_streams_.empty()) | 991 if (!sent_reset_streams_.empty() || queued_reset_streams_.empty()) |
| 992 return true; | 992 return true; |
| 993 | 993 |
| 994 LOG(LS_VERBOSE) << "SendQueuedStreamResets[" << debug_name_ << "]: Sending [" | 994 LOG(LS_VERBOSE) << "SendQueuedStreamResets[" << debug_name_ << "]: Sending [" |
| 995 << ListStreams(queued_reset_streams_) << "], Open: [" | 995 << ListStreams(queued_reset_streams_) << "], Open: [" |
| 996 << ListStreams(open_streams_) << "], Sent: [" | 996 << ListStreams(open_streams_) << "], Sent: [" |
| 997 << ListStreams(sent_reset_streams_) << "]"; | 997 << ListStreams(sent_reset_streams_) << "]"; |
| 998 | 998 |
| 999 const size_t num_streams = queued_reset_streams_.size(); | 999 const size_t num_streams = queued_reset_streams_.size(); |
| 1000 const size_t num_bytes = sizeof(struct sctp_reset_streams) | 1000 const size_t num_bytes = |
| 1001 + (num_streams * sizeof(uint16)); | 1001 sizeof(struct sctp_reset_streams) + (num_streams * sizeof(uint16_t)); |
| 1002 | 1002 |
| 1003 std::vector<uint8> reset_stream_buf(num_bytes, 0); | 1003 std::vector<uint8_t> reset_stream_buf(num_bytes, 0); |
| 1004 struct sctp_reset_streams* resetp = reinterpret_cast<sctp_reset_streams*>( | 1004 struct sctp_reset_streams* resetp = reinterpret_cast<sctp_reset_streams*>( |
| 1005 &reset_stream_buf[0]); | 1005 &reset_stream_buf[0]); |
| 1006 resetp->srs_assoc_id = SCTP_ALL_ASSOC; | 1006 resetp->srs_assoc_id = SCTP_ALL_ASSOC; |
| 1007 resetp->srs_flags = SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_OUTGOING; | 1007 resetp->srs_flags = SCTP_STREAM_RESET_INCOMING | SCTP_STREAM_RESET_OUTGOING; |
| 1008 resetp->srs_number_streams = rtc::checked_cast<uint16_t>(num_streams); | 1008 resetp->srs_number_streams = rtc::checked_cast<uint16_t>(num_streams); |
| 1009 int result_idx = 0; | 1009 int result_idx = 0; |
| 1010 for (StreamSet::iterator it = queued_reset_streams_.begin(); | 1010 for (StreamSet::iterator it = queued_reset_streams_.begin(); |
| 1011 it != queued_reset_streams_.end(); ++it) { | 1011 it != queued_reset_streams_.end(); ++it) { |
| 1012 resetp->srs_stream_list[result_idx++] = *it; | 1012 resetp->srs_stream_list[result_idx++] = *it; |
| 1013 } | 1013 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1037 } | 1037 } |
| 1038 case MSG_SCTPOUTBOUNDPACKET: { | 1038 case MSG_SCTPOUTBOUNDPACKET: { |
| 1039 rtc::scoped_ptr<OutboundPacketMessage> pdata( | 1039 rtc::scoped_ptr<OutboundPacketMessage> pdata( |
| 1040 static_cast<OutboundPacketMessage*>(msg->pdata)); | 1040 static_cast<OutboundPacketMessage*>(msg->pdata)); |
| 1041 OnPacketFromSctpToNetwork(pdata->data().get()); | 1041 OnPacketFromSctpToNetwork(pdata->data().get()); |
| 1042 break; | 1042 break; |
| 1043 } | 1043 } |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 } // namespace cricket | 1046 } // namespace cricket |
| OLD | NEW |