From 4b3c0d6f34c379c2a06f654b62403876b20180c6 Mon Sep 17 00:00:00 2001 From: Jiayang Liu Date: Tue, 31 Mar 2015 15:02:42 -0700 Subject: 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} --- talk/session/media/srtpfilter.cc | 4 +++- talk/session/media/srtpfilter_unittest.cc | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'talk/session') diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc index 8beec10459..a49b037734 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 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p, int in_len, int64* index) { 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( + 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 f3b7625c22..d8174a978a 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 @@ TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) { 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(rtc::NetworkToHost64(1 << 16)); EXPECT_EQ(be64_index, index); } -- cgit v1.2.3