OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_test_utils.h" |
6 | 6 |
7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 } | 192 } |
193 | 193 |
194 void CreateStunRequest(std::vector<char>* packet) { | 194 void CreateStunRequest(std::vector<char>* packet) { |
195 CreateStunPacket(packet, kStunBindingRequest); | 195 CreateStunPacket(packet, kStunBindingRequest); |
196 } | 196 } |
197 | 197 |
198 void CreateStunResponse(std::vector<char>* packet) { | 198 void CreateStunResponse(std::vector<char>* packet) { |
199 CreateStunPacket(packet, kStunBindingResponse); | 199 CreateStunPacket(packet, kStunBindingResponse); |
200 } | 200 } |
201 | 201 |
202 | |
202 void CreateStunError(std::vector<char>* packet) { | 203 void CreateStunError(std::vector<char>* packet) { |
203 CreateStunPacket(packet, kStunBindingError); | 204 CreateStunPacket(packet, kStunBindingError); |
204 } | 205 } |
205 | 206 |
207 void CreateRtpPacket(std::vector<char>* packet) { | |
208 CreateRandomPacket(packet); // Minimum length is 20 bytes. | |
209 *reinterpret_cast<uint8*>(&*packet->begin()) = 0x80; | |
210 // Extension bit not set. | |
211 } | |
212 | |
213 void CreateRtpPacketWithSendtimeExtension(std::vector<char>* packet, | |
214 int extension_id) { | |
215 CreateRandomPacket(packet); | |
216 *reinterpret_cast<uint8*>(&*packet->begin()) = 0x81; | |
217 *reinterpret_cast<uint16*>(&*packet->begin() + kRtpHeaderSize) = 0xBEDE; | |
juberti2
2014/02/22 01:16:05
Need to use SetBE16 to get the right endianness
| |
218 *reinterpret_cast<uint16*>(&*packet->begin() + kRtpHeaderSize + 2) = 1; | |
219 *reinterpret_cast<uint8*>(&*packet->begin() + kRtpHeaderSize + 4) = | |
220 (extension_id << 4) + 2; | |
221 } | |
222 | |
223 void CreateTurn | |
224 | |
206 net::IPEndPoint ParseAddress(const std::string ip_str, int port) { | 225 net::IPEndPoint ParseAddress(const std::string ip_str, int port) { |
207 net::IPAddressNumber ip; | 226 net::IPAddressNumber ip; |
208 EXPECT_TRUE(net::ParseIPLiteralToNumber(ip_str, &ip)); | 227 EXPECT_TRUE(net::ParseIPLiteralToNumber(ip_str, &ip)); |
209 return net::IPEndPoint(ip, port); | 228 return net::IPEndPoint(ip, port); |
210 } | 229 } |
OLD | NEW |