Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: content/browser/renderer_host/p2p/socket_host_test_utils.cc

Issue 159353002: This CL adds methods to manipulate RTP header extension, particularly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/p2p/socket_host_test_utils.cc
diff --git a/content/browser/renderer_host/p2p/socket_host_test_utils.cc b/content/browser/renderer_host/p2p/socket_host_test_utils.cc
index 67c461a6b97c64a225ee47521d1ee01f5c366f99..ca749457b59e70c508bc90fad5b3d86f07af658a 100644
--- a/content/browser/renderer_host/p2p/socket_host_test_utils.cc
+++ b/content/browser/renderer_host/p2p/socket_host_test_utils.cc
@@ -14,6 +14,8 @@ const uint16 kStunBindingRequest = 0x0001;
const uint16 kStunBindingResponse = 0x0102;
const uint16 kStunBindingError = 0x0111;
const uint32 kStunMagicCookie = 0x2112A442;
+const int kRtpHeaderSize = 12;
+const int kTurnChannelDataHdr = 4;
MockIPCSender::MockIPCSender() { }
MockIPCSender::~MockIPCSender() { }
@@ -199,10 +201,39 @@ void CreateStunResponse(std::vector<char>* packet) {
CreateStunPacket(packet, kStunBindingResponse);
}
+
void CreateStunError(std::vector<char>* packet) {
CreateStunPacket(packet, kStunBindingError);
}
+void CreateRtpPacket(std::vector<char>* packet) {
+ CreateRandomPacket(packet); // Minimum length is 20 bytes.
+ *reinterpret_cast<uint8*>(&*packet->begin()) = 0x80;
+ // Extension bit not set.
+}
+
+void CreateRtpPacketWithSendtimeExtension(std::vector<char>* packet,
juberti2 2014/02/25 00:48:24 SendTime->SendTime
Mallinath (Gone from Chromium) 2014/02/25 22:56:44 Done.
+ int extension_id) {
+ CreateRandomPacket(packet);
+ *reinterpret_cast<uint8*>(&*packet->begin()) = 0x90;
+ *reinterpret_cast<uint16*>(&*packet->begin() + kRtpHeaderSize) =
+ base::HostToNet16(0xBEDE);
+ *reinterpret_cast<uint16*>(&*packet->begin() + kRtpHeaderSize + 2) =
+ base::HostToNet16(2);
+ *reinterpret_cast<uint8*>(&*packet->begin() + kRtpHeaderSize + 4) =
+ (extension_id << 4) + 2;
+}
+
+void CreateTurnChannelData(std::vector<char>* packet) {
+ size_t size = kRtpHeaderSize + kTurnChannelDataHdr + rand() % 1000;
juberti2 2014/02/25 00:48:24 instead of checking random sizes, i think we shoul
Mallinath (Gone from Chromium) 2014/02/25 22:56:44 Yea, removing these methods and adding test vector
+ packet->resize(size);
+ *reinterpret_cast<uint16*>(&*packet->begin()) = base::HostToNet16(0x4000);
+ *reinterpret_cast<uint16*>(&*packet->begin() + 2) =
+ base::HostToNet16(size - 4);
+ // Write RTP header
+ *reinterpret_cast<uint8*>(&*packet->begin() + 4) = 0x80;
juberti2 2014/02/25 00:48:24 this should call CreateRtpPacketWithSendTimeExtens
Mallinath (Gone from Chromium) 2014/02/25 22:56:44 As above. On 2014/02/25 00:48:24, juberti2 wrote:
+}
+
net::IPEndPoint ParseAddress(const std::string ip_str, int port) {
net::IPAddressNumber ip;
EXPECT_TRUE(net::ParseIPLiteralToNumber(ip_str, &ip));

Powered by Google App Engine
This is Rietveld 408576698