| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright 2004 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 101   } else if (answer_enable) { | 101   } else if (answer_enable) { | 
| 102     // If the offer didn't specify RTCP mux, the answer shouldn't either. | 102     // If the offer didn't specify RTCP mux, the answer shouldn't either. | 
| 103     LOG(LS_WARNING) << "Invalid parameters in RTCP mux answer"; | 103     LOG(LS_WARNING) << "Invalid parameters in RTCP mux answer"; | 
| 104     return false; | 104     return false; | 
| 105   } else { | 105   } else { | 
| 106     state_ = ST_INIT; | 106     state_ = ST_INIT; | 
| 107   } | 107   } | 
| 108   return true; | 108   return true; | 
| 109 } | 109 } | 
| 110 | 110 | 
| 111 // Check the RTP payload type.  If 63 < payload type < 96, it's RTCP. |  | 
| 112 // For additional details, see http://tools.ietf.org/html/rfc5761. |  | 
| 113 bool IsRtcp(const char* data, int len) { |  | 
| 114   if (len < 2) { |  | 
| 115     return false; |  | 
| 116   } |  | 
| 117   char pt = data[1] & 0x7F; |  | 
| 118   return (63 < pt) && (pt < 96); |  | 
| 119 } |  | 
| 120 |  | 
| 121 bool RtcpMuxFilter::DemuxRtcp(const char* data, int len) { |  | 
| 122   // If we're muxing RTP/RTCP, we must inspect each packet delivered |  | 
| 123   // and determine whether it is RTP or RTCP. We do so by looking at |  | 
| 124   // the RTP payload type (see IsRtcp).  Note that if we offer RTCP |  | 
| 125   // mux, we may receive muxed RTCP before we receive the answer, so |  | 
| 126   // we operate in that state too. |  | 
| 127   bool offered_mux = ((state_ == ST_SENTOFFER) && offer_enable_); |  | 
| 128   return (IsActive() || offered_mux) && IsRtcp(data, len); |  | 
| 129 } |  | 
| 130 |  | 
| 131 bool RtcpMuxFilter::ExpectOffer(bool offer_enable, ContentSource source) { | 111 bool RtcpMuxFilter::ExpectOffer(bool offer_enable, ContentSource source) { | 
| 132   return ((state_ == ST_INIT) || | 112   return ((state_ == ST_INIT) || | 
| 133           (state_ == ST_ACTIVE && offer_enable == offer_enable_) || | 113           (state_ == ST_ACTIVE && offer_enable == offer_enable_) || | 
| 134           (state_ == ST_SENTOFFER && source == CS_LOCAL) || | 114           (state_ == ST_SENTOFFER && source == CS_LOCAL) || | 
| 135           (state_ == ST_RECEIVEDOFFER && source == CS_REMOTE)); | 115           (state_ == ST_RECEIVEDOFFER && source == CS_REMOTE)); | 
| 136 } | 116 } | 
| 137 | 117 | 
| 138 bool RtcpMuxFilter::ExpectAnswer(ContentSource source) { | 118 bool RtcpMuxFilter::ExpectAnswer(ContentSource source) { | 
| 139   return ((state_ == ST_SENTOFFER && source == CS_REMOTE) || | 119   return ((state_ == ST_SENTOFFER && source == CS_REMOTE) || | 
| 140           (state_ == ST_RECEIVEDOFFER && source == CS_LOCAL) || | 120           (state_ == ST_RECEIVEDOFFER && source == CS_LOCAL) || | 
| 141           (state_ == ST_SENTPRANSWER && source == CS_LOCAL) || | 121           (state_ == ST_SENTPRANSWER && source == CS_LOCAL) || | 
| 142           (state_ == ST_RECEIVEDPRANSWER && source == CS_REMOTE)); | 122           (state_ == ST_RECEIVEDPRANSWER && source == CS_REMOTE)); | 
| 143 } | 123 } | 
| 144 | 124 | 
| 145 }  // namespace cricket | 125 }  // namespace cricket | 
| OLD | NEW | 
|---|