Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / renderer_host / p2p / socket_host.cc
index 007ab77..fd26298 100644 (file)
 #include "content/browser/renderer_host/render_process_host_impl.h"
 #include "content/public/browser/browser_thread.h"
 #include "crypto/hmac.h"
-#include "third_party/libjingle/source/talk/base/asyncpacketsocket.h"
-#include "third_party/libjingle/source/talk/base/byteorder.h"
-#include "third_party/libjingle/source/talk/base/messagedigest.h"
 #include "third_party/libjingle/source/talk/p2p/base/stun.h"
+#include "third_party/webrtc/base/asyncpacketsocket.h"
+#include "third_party/webrtc/base/byteorder.h"
+#include "third_party/webrtc/base/messagedigest.h"
 
 namespace {
 
@@ -48,7 +48,7 @@ bool IsRtcpPacket(const char* data) {
 }
 
 bool IsTurnSendIndicationPacket(const char* data) {
-  uint16 type = talk_base::GetBE16(data);
+  uint16 type = rtc::GetBE16(data);
   return (type == cricket::TURN_SEND_INDICATION);
 }
 
@@ -80,7 +80,7 @@ bool ValidateRtpHeader(const char* rtp, int length, size_t* header_length) {
 
   // Getting extension profile length.
   // Length is in 32 bit words.
-  uint16 extn_length = talk_base::GetBE16(rtp + 2) * 4;
+  uint16 extn_length = rtc::GetBE16(rtp + 2) * 4;
 
   // Verify input length against total header size.
   if (rtp_hdr_len_without_extn + kRtpExtnHdrLen + extn_length > length) {
@@ -129,7 +129,7 @@ void UpdateAbsSendTimeExtnValue(char* extn_data, int len,
 // Assumes |len| is actual packet length + tag length. Updates HMAC at end of
 // the RTP packet.
 void UpdateRtpAuthTag(char* rtp, int len,
-                      const talk_base::PacketOptions& options) {
+                      const rtc::PacketOptions& options) {
   // If there is no key, return.
   if (options.packet_time_params.srtp_auth_key.empty())
     return;
@@ -176,7 +176,7 @@ namespace content {
 namespace packet_processing_helpers {
 
 bool ApplyPacketOptions(char* data, int length,
-                        const talk_base::PacketOptions& options,
+                        const rtc::PacketOptions& options,
                         uint32 abs_send_time) {
   DCHECK(data != NULL);
   DCHECK(length > 0);
@@ -221,7 +221,8 @@ bool GetRtpPacketStartPositionAndLength(const char* packet,
                                         int length,
                                         int* rtp_start_pos,
                                         int* rtp_packet_length) {
-  int rtp_begin, rtp_length;
+  int rtp_begin;
+  int rtp_length = 0;
   if (IsTurnChannelData(packet)) {
     // Turn Channel Message header format.
     //   0                   1                   2                   3
@@ -238,7 +239,7 @@ bool GetRtpPacketStartPositionAndLength(const char* packet,
     }
 
     rtp_begin = kTurnChannelHdrLen;
-    rtp_length = talk_base::GetBE16(&packet[2]);
+    rtp_length = rtc::GetBE16(&packet[2]);
     if (length < rtp_length + kTurnChannelHdrLen) {
       return false;
     }
@@ -248,7 +249,7 @@ bool GetRtpPacketStartPositionAndLength(const char* packet,
       return false;
     }
     // Validate STUN message length.
-    int stun_msg_len = talk_base::GetBE16(&packet[2]);
+    int stun_msg_len = rtc::GetBE16(&packet[2]);
     if (stun_msg_len + P2PSocketHost::kStunHeaderSize != length) {
       return false;
     }
@@ -274,8 +275,8 @@ bool GetRtpPacketStartPositionAndLength(const char* packet,
       // padding bits are ignored, and may be any value.
       uint16 attr_type, attr_length;
       // Getting attribute type and length.
-      attr_type = talk_base::GetBE16(&packet[rtp_begin]);
-      attr_length = talk_base::GetBE16(
+      attr_type = rtc::GetBE16(&packet[rtp_begin]);
+      attr_length = rtc::GetBE16(
           &packet[rtp_begin + sizeof(attr_type)]);
       // Checking for bogus attribute length.
       if (length < attr_length + rtp_begin) {
@@ -314,7 +315,7 @@ bool GetRtpPacketStartPositionAndLength(const char* packet,
   }
 
   // Making sure we have a valid RTP packet at the end.
-  if (!(rtp_length < kMinRtpHdrLen) &&
+  if ((rtp_length >= kMinRtpHdrLen) &&
       IsRtpPacket(packet + rtp_begin, rtp_length) &&
       ValidateRtpHeader(packet + rtp_begin, rtp_length, NULL)) {
     *rtp_start_pos = rtp_begin;
@@ -352,9 +353,9 @@ bool UpdateRtpAbsSendTimeExtn(char* rtp, int length,
   rtp += rtp_hdr_len_without_extn;
 
   // Getting extension profile ID and length.
-  uint16 profile_id = talk_base::GetBE16(rtp);
+  uint16 profile_id = rtc::GetBE16(rtp);
   // Length is in 32 bit words.
-  uint16 extn_length = talk_base::GetBE16(rtp + 2) * 4;
+  uint16 extn_length = rtc::GetBE16(rtp + 2) * 4;
 
   rtp += kRtpExtnHdrLen;  // Moving past extn header.