Use WebRTC API to convert byteorder in srtpfilter.
This CL uses WebRTC API to convert 64bit from big-endian to host-endian,
so the internal "be64_to_cpu" of libsrtp is not used. The code path of
"be64_to_cpu" in newer versions of libsrtp depends on compile-time
defines that are not available in WebRTC.
BUG=https://code.google.com/p/chromium/issues/detail?id=328475
R=juberti@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/46749004
Cr-Commit-Position: refs/heads/master@{#8904}
diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc
index 8beec10..a49b037 100644
--- a/talk/session/media/srtpfilter.cc
+++ b/talk/session/media/srtpfilter.cc
@@ -35,6 +35,7 @@
#include "talk/media/base/rtputils.h"
#include "webrtc/base/base64.h"
+#include "webrtc/base/byteorder.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/timeutils.h"
@@ -628,7 +629,8 @@
return false;
// Shift packet index, put into network byte order
- *index = be64_to_cpu(rdbx_get_packet_index(&stream->rtp_rdbx) << 16);
+ *index = static_cast<int64>(
+ rtc::NetworkToHost64(rdbx_get_packet_index(&stream->rtp_rdbx) << 16));
return true;
}
diff --git a/talk/session/media/srtpfilter_unittest.cc b/talk/session/media/srtpfilter_unittest.cc
index f3b7625..d8174a9 100644
--- a/talk/session/media/srtpfilter_unittest.cc
+++ b/talk/session/media/srtpfilter_unittest.cc
@@ -35,10 +35,8 @@
extern "C" {
#ifdef SRTP_RELATIVE_PATH
#include "crypto/include/err.h"
-#include "crypto/include/datatypes.h"
#else
#include "third_party/libsrtp/srtp/crypto/include/err.h"
-#include "third_party/libsrtp/srtp/crypto/include/datatypes.h"
#endif
}
@@ -676,7 +674,7 @@
EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_,
sizeof(rtp_packet_), &out_len, &index));
// |index| will be shifted by 16.
- int64 be64_index = be64_to_cpu(1 << 16);
+ int64 be64_index = static_cast<int64>(rtc::NetworkToHost64(1 << 16));
EXPECT_EQ(be64_index, index);
}