| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 sendbuf_size_(-1), | 54 sendbuf_size_(-1), |
| 55 recvbuf_size_(-1), | 55 recvbuf_size_(-1), |
| 56 dscp_(rtc::DSCP_NO_CHANGE) { | 56 dscp_(rtc::DSCP_NO_CHANGE) { |
| 57 } | 57 } |
| 58 | 58 |
| 59 void SetDestination(MediaChannel* dest) { dest_ = dest; } | 59 void SetDestination(MediaChannel* dest) { dest_ = dest; } |
| 60 | 60 |
| 61 // Conference mode is a mode where instead of simply forwarding the packets, | 61 // Conference mode is a mode where instead of simply forwarding the packets, |
| 62 // the transport will send multiple copies of the packet with the specified | 62 // the transport will send multiple copies of the packet with the specified |
| 63 // SSRCs. This allows us to simulate receiving media from multiple sources. | 63 // SSRCs. This allows us to simulate receiving media from multiple sources. |
| 64 void SetConferenceMode(bool conf, const std::vector<uint32>& ssrcs) { | 64 void SetConferenceMode(bool conf, const std::vector<uint32_t>& ssrcs) { |
| 65 rtc::CritScope cs(&crit_); | 65 rtc::CritScope cs(&crit_); |
| 66 conf_ = conf; | 66 conf_ = conf; |
| 67 conf_sent_ssrcs_ = ssrcs; | 67 conf_sent_ssrcs_ = ssrcs; |
| 68 } | 68 } |
| 69 | 69 |
| 70 int NumRtpBytes() { | 70 int NumRtpBytes() { |
| 71 rtc::CritScope cs(&crit_); | 71 rtc::CritScope cs(&crit_); |
| 72 int bytes = 0; | 72 int bytes = 0; |
| 73 for (size_t i = 0; i < rtp_packets_.size(); ++i) { | 73 for (size_t i = 0; i < rtp_packets_.size(); ++i) { |
| 74 bytes += static_cast<int>(rtp_packets_[i].size()); | 74 bytes += static_cast<int>(rtp_packets_[i].size()); |
| 75 } | 75 } |
| 76 return bytes; | 76 return bytes; |
| 77 } | 77 } |
| 78 | 78 |
| 79 int NumRtpBytes(uint32 ssrc) { | 79 int NumRtpBytes(uint32_t ssrc) { |
| 80 rtc::CritScope cs(&crit_); | 80 rtc::CritScope cs(&crit_); |
| 81 int bytes = 0; | 81 int bytes = 0; |
| 82 GetNumRtpBytesAndPackets(ssrc, &bytes, NULL); | 82 GetNumRtpBytesAndPackets(ssrc, &bytes, NULL); |
| 83 return bytes; | 83 return bytes; |
| 84 } | 84 } |
| 85 | 85 |
| 86 int NumRtpPackets() { | 86 int NumRtpPackets() { |
| 87 rtc::CritScope cs(&crit_); | 87 rtc::CritScope cs(&crit_); |
| 88 return static_cast<int>(rtp_packets_.size()); | 88 return static_cast<int>(rtp_packets_.size()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 int NumRtpPackets(uint32 ssrc) { | 91 int NumRtpPackets(uint32_t ssrc) { |
| 92 rtc::CritScope cs(&crit_); | 92 rtc::CritScope cs(&crit_); |
| 93 int packets = 0; | 93 int packets = 0; |
| 94 GetNumRtpBytesAndPackets(ssrc, NULL, &packets); | 94 GetNumRtpBytesAndPackets(ssrc, NULL, &packets); |
| 95 return packets; | 95 return packets; |
| 96 } | 96 } |
| 97 | 97 |
| 98 int NumSentSsrcs() { | 98 int NumSentSsrcs() { |
| 99 rtc::CritScope cs(&crit_); | 99 rtc::CritScope cs(&crit_); |
| 100 return static_cast<int>(sent_ssrcs_.size()); | 100 return static_cast<int>(sent_ssrcs_.size()); |
| 101 } | 101 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 125 | 125 |
| 126 int sendbuf_size() const { return sendbuf_size_; } | 126 int sendbuf_size() const { return sendbuf_size_; } |
| 127 int recvbuf_size() const { return recvbuf_size_; } | 127 int recvbuf_size() const { return recvbuf_size_; } |
| 128 rtc::DiffServCodePoint dscp() const { return dscp_; } | 128 rtc::DiffServCodePoint dscp() const { return dscp_; } |
| 129 | 129 |
| 130 protected: | 130 protected: |
| 131 virtual bool SendPacket(rtc::Buffer* packet, | 131 virtual bool SendPacket(rtc::Buffer* packet, |
| 132 rtc::DiffServCodePoint dscp) { | 132 rtc::DiffServCodePoint dscp) { |
| 133 rtc::CritScope cs(&crit_); | 133 rtc::CritScope cs(&crit_); |
| 134 | 134 |
| 135 uint32 cur_ssrc = 0; | 135 uint32_t cur_ssrc = 0; |
| 136 if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) { | 136 if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) { |
| 137 return false; | 137 return false; |
| 138 } | 138 } |
| 139 sent_ssrcs_[cur_ssrc]++; | 139 sent_ssrcs_[cur_ssrc]++; |
| 140 | 140 |
| 141 rtp_packets_.push_back(*packet); | 141 rtp_packets_.push_back(*packet); |
| 142 if (conf_) { | 142 if (conf_) { |
| 143 rtc::Buffer buffer_copy(*packet); | 143 rtc::Buffer buffer_copy(*packet); |
| 144 for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) { | 144 for (size_t i = 0; i < conf_sent_ssrcs_.size(); ++i) { |
| 145 if (!SetRtpSsrc(buffer_copy.data(), buffer_copy.size(), | 145 if (!SetRtpSsrc(buffer_copy.data(), buffer_copy.size(), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 rtc::CreatePacketTime(0)); | 191 rtc::CreatePacketTime(0)); |
| 192 } else { | 192 } else { |
| 193 dest_->OnRtcpReceived(&msg_data->data(), | 193 dest_->OnRtcpReceived(&msg_data->data(), |
| 194 rtc::CreatePacketTime(0)); | 194 rtc::CreatePacketTime(0)); |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 delete msg_data; | 197 delete msg_data; |
| 198 } | 198 } |
| 199 | 199 |
| 200 private: | 200 private: |
| 201 void GetNumRtpBytesAndPackets(uint32 ssrc, int* bytes, int* packets) { | 201 void GetNumRtpBytesAndPackets(uint32_t ssrc, int* bytes, int* packets) { |
| 202 if (bytes) { | 202 if (bytes) { |
| 203 *bytes = 0; | 203 *bytes = 0; |
| 204 } | 204 } |
| 205 if (packets) { | 205 if (packets) { |
| 206 *packets = 0; | 206 *packets = 0; |
| 207 } | 207 } |
| 208 uint32 cur_ssrc = 0; | 208 uint32_t cur_ssrc = 0; |
| 209 for (size_t i = 0; i < rtp_packets_.size(); ++i) { | 209 for (size_t i = 0; i < rtp_packets_.size(); ++i) { |
| 210 if (!GetRtpSsrc(rtp_packets_[i].data(), rtp_packets_[i].size(), | 210 if (!GetRtpSsrc(rtp_packets_[i].data(), rtp_packets_[i].size(), |
| 211 &cur_ssrc)) { | 211 &cur_ssrc)) { |
| 212 return; | 212 return; |
| 213 } | 213 } |
| 214 if (ssrc == cur_ssrc) { | 214 if (ssrc == cur_ssrc) { |
| 215 if (bytes) { | 215 if (bytes) { |
| 216 *bytes += static_cast<int>(rtp_packets_[i].size()); | 216 *bytes += static_cast<int>(rtp_packets_[i].size()); |
| 217 } | 217 } |
| 218 if (packets) { | 218 if (packets) { |
| 219 ++(*packets); | 219 ++(*packets); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 rtc::Thread* thread_; | 225 rtc::Thread* thread_; |
| 226 MediaChannel* dest_; | 226 MediaChannel* dest_; |
| 227 bool conf_; | 227 bool conf_; |
| 228 // The ssrcs used in sending out packets in conference mode. | 228 // The ssrcs used in sending out packets in conference mode. |
| 229 std::vector<uint32> conf_sent_ssrcs_; | 229 std::vector<uint32_t> conf_sent_ssrcs_; |
| 230 // Map to track counts of packets that have been sent per ssrc. | 230 // Map to track counts of packets that have been sent per ssrc. |
| 231 // This includes packets that are dropped. | 231 // This includes packets that are dropped. |
| 232 std::map<uint32, uint32> sent_ssrcs_; | 232 std::map<uint32_t, uint32_t> sent_ssrcs_; |
| 233 // Map to track packet-number that needs to be dropped per ssrc. | 233 // Map to track packet-number that needs to be dropped per ssrc. |
| 234 std::map<uint32, std::set<uint32> > drop_map_; | 234 std::map<uint32_t, std::set<uint32_t> > drop_map_; |
| 235 rtc::CriticalSection crit_; | 235 rtc::CriticalSection crit_; |
| 236 std::vector<rtc::Buffer> rtp_packets_; | 236 std::vector<rtc::Buffer> rtp_packets_; |
| 237 std::vector<rtc::Buffer> rtcp_packets_; | 237 std::vector<rtc::Buffer> rtcp_packets_; |
| 238 int sendbuf_size_; | 238 int sendbuf_size_; |
| 239 int recvbuf_size_; | 239 int recvbuf_size_; |
| 240 rtc::DiffServCodePoint dscp_; | 240 rtc::DiffServCodePoint dscp_; |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 } // namespace cricket | 243 } // namespace cricket |
| 244 | 244 |
| 245 #endif // TALK_MEDIA_BASE_FAKENETWORKINTERFACE_H_ | 245 #endif // TALK_MEDIA_BASE_FAKENETWORKINTERFACE_H_ |
| OLD | NEW |