| OLD | NEW |
| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Note: callers are responsible for deleting the returned buffer. | 117 // Note: callers are responsible for deleting the returned buffer. |
| 118 const rtc::Buffer* GetRtcpPacket(int index) { | 118 const rtc::Buffer* GetRtcpPacket(int index) { |
| 119 rtc::CritScope cs(&crit_); | 119 rtc::CritScope cs(&crit_); |
| 120 if (index >= NumRtcpPackets()) { | 120 if (index >= NumRtcpPackets()) { |
| 121 return NULL; | 121 return NULL; |
| 122 } | 122 } |
| 123 return new rtc::Buffer(rtcp_packets_[index]); | 123 return new rtc::Buffer(rtcp_packets_[index]); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // Indicate that |n|'th packet for |ssrc| should be dropped. | |
| 127 void AddPacketDrop(uint32 ssrc, uint32 n) { | |
| 128 drop_map_[ssrc].insert(n); | |
| 129 } | |
| 130 | |
| 131 int sendbuf_size() const { return sendbuf_size_; } | 126 int sendbuf_size() const { return sendbuf_size_; } |
| 132 int recvbuf_size() const { return recvbuf_size_; } | 127 int recvbuf_size() const { return recvbuf_size_; } |
| 133 rtc::DiffServCodePoint dscp() const { return dscp_; } | 128 rtc::DiffServCodePoint dscp() const { return dscp_; } |
| 134 | 129 |
| 135 protected: | 130 protected: |
| 136 virtual bool SendPacket(rtc::Buffer* packet, | 131 virtual bool SendPacket(rtc::Buffer* packet, |
| 137 rtc::DiffServCodePoint dscp) { | 132 rtc::DiffServCodePoint dscp) { |
| 138 rtc::CritScope cs(&crit_); | 133 rtc::CritScope cs(&crit_); |
| 139 | 134 |
| 140 uint32 cur_ssrc = 0; | 135 uint32 cur_ssrc = 0; |
| 141 if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) { | 136 if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) { |
| 142 return false; | 137 return false; |
| 143 } | 138 } |
| 144 sent_ssrcs_[cur_ssrc]++; | 139 sent_ssrcs_[cur_ssrc]++; |
| 145 | 140 |
| 146 // Check if we need to drop this packet. | |
| 147 std::map<uint32, std::set<uint32> >::iterator itr = | |
| 148 drop_map_.find(cur_ssrc); | |
| 149 if (itr != drop_map_.end() && | |
| 150 itr->second.count(sent_ssrcs_[cur_ssrc]) > 0) { | |
| 151 // "Drop" the packet. | |
| 152 return true; | |
| 153 } | |
| 154 | |
| 155 rtp_packets_.push_back(*packet); | 141 rtp_packets_.push_back(*packet); |
| 156 if (conf_) { | 142 if (conf_) { |
| 157 rtc::Buffer buffer_copy(*packet); | 143 rtc::Buffer buffer_copy(*packet); |
| 158 for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) { | 144 for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) { |
| 159 if (!SetRtpSsrc(buffer_copy.data(), buffer_copy.size(), | 145 if (!SetRtpSsrc(buffer_copy.data(), buffer_copy.size(), |
| 160 conf_sent_ssrcs_[i])) { | 146 conf_sent_ssrcs_[i])) { |
| 161 return false; | 147 return false; |
| 162 } | 148 } |
| 163 PostMessage(ST_RTP, buffer_copy); | 149 PostMessage(ST_RTP, buffer_copy); |
| 164 } | 150 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 std::vector<rtc::Buffer> rtp_packets_; | 236 std::vector<rtc::Buffer> rtp_packets_; |
| 251 std::vector<rtc::Buffer> rtcp_packets_; | 237 std::vector<rtc::Buffer> rtcp_packets_; |
| 252 int sendbuf_size_; | 238 int sendbuf_size_; |
| 253 int recvbuf_size_; | 239 int recvbuf_size_; |
| 254 rtc::DiffServCodePoint dscp_; | 240 rtc::DiffServCodePoint dscp_; |
| 255 }; | 241 }; |
| 256 | 242 |
| 257 } // namespace cricket | 243 } // namespace cricket |
| 258 | 244 |
| 259 #endif // TALK_MEDIA_BASE_FAKENETWORKINTERFACE_H_ | 245 #endif // TALK_MEDIA_BASE_FAKENETWORKINTERFACE_H_ |
| OLD | NEW |