diff options
author | Avi Drissman <avi@chromium.org> | 2015-12-18 20:11:31 -0500 |
---|---|---|
committer | Avi Drissman <avi@chromium.org> | 2015-12-19 01:13:36 +0000 |
commit | 97785eaf0f3b8f017a38fe738ade818754492483 (patch) | |
tree | 6663166eaeaefbc78833bf48e89e6544e5d8d1cd /media/cast/net | |
parent | a388b145dee01a807b80517d57c7229e34e23883 (diff) | |
download | chromium_src-97785eaf0f3b8f017a38fe738ade818754492483.zip chromium_src-97785eaf0f3b8f017a38fe738ade818754492483.tar.gz chromium_src-97785eaf0f3b8f017a38fe738ade818754492483.tar.bz2 |
Switch to standard integer types in media/.
BUG=138542
TBR=dalecurtis@chromium.org
Review URL: https://codereview.chromium.org/1534273002 .
Cr-Commit-Position: refs/heads/master@{#366242}
Diffstat (limited to 'media/cast/net')
55 files changed, 631 insertions, 630 deletions
diff --git a/media/cast/net/cast_transport_config.h b/media/cast/net/cast_transport_config.h index 7cdeec9..eb3cac6 100644 --- a/media/cast/net/cast_transport_config.h +++ b/media/cast/net/cast_transport_config.h @@ -7,7 +7,6 @@ #include <string> -#include "base/basictypes.h" #include "base/callback.h" #include "base/stl_util.h" #include "media/cast/net/cast_transport_defines.h" @@ -31,10 +30,10 @@ struct CastTransportRtpConfig { ~CastTransportRtpConfig(); // Identifier refering to this sender. - uint32 ssrc; + uint32_t ssrc; // Identifier for incoming RTCP traffic. - uint32 feedback_ssrc; + uint32_t feedback_ssrc; // RTP payload type enum: Specifies the type/encoding of frame data. int rtp_payload_type; @@ -70,13 +69,13 @@ struct EncodedFrame { EncodedFrame(); virtual ~EncodedFrame(); - // Convenience accessors to data as an array of uint8 elements. - const uint8* bytes() const { - return reinterpret_cast<uint8*>(string_as_array( - const_cast<std::string*>(&data))); + // Convenience accessors to data as an array of uint8_t elements. + const uint8_t* bytes() const { + return reinterpret_cast<uint8_t*>( + string_as_array(const_cast<std::string*>(&data))); } - uint8* mutable_bytes() { - return reinterpret_cast<uint8*>(string_as_array(&data)); + uint8_t* mutable_bytes() { + return reinterpret_cast<uint8_t*>(string_as_array(&data)); } // Copies all data members except |data| to |dest|. @@ -88,19 +87,19 @@ struct EncodedFrame { // The label associated with this frame. Implies an ordering relative to // other frames in the same stream. - uint32 frame_id; + uint32_t frame_id; // The label associated with the frame upon which this frame depends. If // this frame does not require any other frame in order to become decodable // (e.g., key frames), |referenced_frame_id| must equal |frame_id|. - uint32 referenced_frame_id; + uint32_t referenced_frame_id; // The stream timestamp, on the timeline of the signal data. For example, RTP // timestamps for audio are usually defined as the total number of audio // samples encoded in all prior frames. A playback system uses this value to // detect gaps in the stream, and otherwise stretch the signal to match // playout targets. - uint32 rtp_timestamp; + uint32_t rtp_timestamp; // The common reference clock timestamp for this frame. This value originates // from a sender and is used to provide lip synchronization between streams in @@ -113,7 +112,7 @@ struct EncodedFrame { // Playout delay for this and all future frames. Used by the Adaptive // Playout delay extension. Zero means no change. - uint16 new_playout_delay_ms; + uint16_t new_playout_delay_ms; // The encoded signal data. std::string data; @@ -133,7 +132,7 @@ class PacketSender { virtual bool SendPacket(PacketRef packet, const base::Closure& cb) = 0; // Returns the number of bytes ever sent. - virtual int64 GetBytesSent() = 0; + virtual int64_t GetBytesSent() = 0; virtual ~PacketSender() {} }; @@ -143,31 +142,31 @@ struct RtcpSenderInfo { ~RtcpSenderInfo(); // First three members are used for lipsync. // First two members are used for rtt. - uint32 ntp_seconds; - uint32 ntp_fraction; - uint32 rtp_timestamp; - uint32 send_packet_count; + uint32_t ntp_seconds; + uint32_t ntp_fraction; + uint32_t rtp_timestamp; + uint32_t send_packet_count; size_t send_octet_count; }; struct RtcpReportBlock { RtcpReportBlock(); ~RtcpReportBlock(); - uint32 remote_ssrc; // SSRC of sender of this report. - uint32 media_ssrc; // SSRC of the RTP packet sender. - uint8 fraction_lost; - uint32 cumulative_lost; // 24 bits valid. - uint32 extended_high_sequence_number; - uint32 jitter; - uint32 last_sr; - uint32 delay_since_last_sr; + uint32_t remote_ssrc; // SSRC of sender of this report. + uint32_t media_ssrc; // SSRC of the RTP packet sender. + uint8_t fraction_lost; + uint32_t cumulative_lost; // 24 bits valid. + uint32_t extended_high_sequence_number; + uint32_t jitter; + uint32_t last_sr; + uint32_t delay_since_last_sr; }; struct RtcpDlrrReportBlock { RtcpDlrrReportBlock(); ~RtcpDlrrReportBlock(); - uint32 last_rr; - uint32 delay_since_last_rr; + uint32_t last_rr; + uint32_t delay_since_last_rr; }; inline bool operator==(RtcpSenderInfo lhs, RtcpSenderInfo rhs) { diff --git a/media/cast/net/cast_transport_defines.h b/media/cast/net/cast_transport_defines.h index bdd5494..cddd055 100644 --- a/media/cast/net/cast_transport_defines.h +++ b/media/cast/net/cast_transport_defines.h @@ -12,7 +12,6 @@ #include <string> #include <vector> -#include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/time/time.h" @@ -41,10 +40,10 @@ const uint16_t kRtcpCastLastPacket = 0xfffe; const size_t kMaxIpPacketSize = 1500; -// Each uint16 represents one packet id within a cast frame. +// Each uint16_t represents one packet id within a cast frame. // Can also contain kRtcpCastAllPacketsLost and kRtcpCastLastPacket. using PacketIdSet = std::set<uint16_t>; -// Each uint8 represents one cast frame. +// Each uint8_t represents one cast frame. using MissingFramesAndPacketsMap = std::map<uint8_t, PacketIdSet>; using Packet = std::vector<uint8_t>; @@ -60,8 +59,8 @@ class FrameIdWrapHelper { explicit FrameIdWrapHelper(uint32_t start_frame_id) : largest_frame_id_seen_(start_frame_id) {} - uint32 MapTo32bitsFrameId(const uint8 over_the_wire_frame_id) { - uint32 ret = (largest_frame_id_seen_ & ~0xff) | over_the_wire_frame_id; + uint32_t MapTo32bitsFrameId(const uint8_t over_the_wire_frame_id) { + uint32_t ret = (largest_frame_id_seen_ & ~0xff) | over_the_wire_frame_id; // Add 1000 to both sides to avoid underflows. if (1000 + ret - largest_frame_id_seen_ > 1000 + 127) { ret -= 0x100; @@ -77,7 +76,7 @@ class FrameIdWrapHelper { private: friend class FrameIdWrapHelperTest; - uint32 largest_frame_id_seen_; + uint32_t largest_frame_id_seen_; DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelper); }; diff --git a/media/cast/net/cast_transport_sender.h b/media/cast/net/cast_transport_sender.h index b20c9df..5988928 100644 --- a/media/cast/net/cast_transport_sender.h +++ b/media/cast/net/cast_transport_sender.h @@ -18,7 +18,6 @@ #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ #define MEDIA_CAST_NET_CAST_TRANSPORT_SENDER_H_ -#include "base/basictypes.h" #include "base/callback.h" #include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" @@ -82,26 +81,25 @@ class CastTransportSender : public base::NonThreadSafe { // Encrypt, packetize and transmit |frame|. |ssrc| must refer to a // a channel already established with InitializeAudio / InitializeVideo. - virtual void InsertFrame(uint32 ssrc, const EncodedFrame& frame) = 0; + virtual void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) = 0; // Sends a RTCP sender report to the receiver. // |ssrc| is the SSRC for this report. // |current_time| is the current time reported by a tick clock. // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. - virtual void SendSenderReport( - uint32 ssrc, - base::TimeTicks current_time, - uint32 current_time_as_rtp_timestamp) = 0; + virtual void SendSenderReport(uint32_t ssrc, + base::TimeTicks current_time, + uint32_t current_time_as_rtp_timestamp) = 0; // Cancels sending packets for the frames in the set. // |ssrc| is the SSRC for the stream. // |frame_ids| contains the IDs of the frames that will be cancelled. - virtual void CancelSendingFrames(uint32 ssrc, - const std::vector<uint32>& frame_ids) = 0; + virtual void CancelSendingFrames(uint32_t ssrc, + const std::vector<uint32_t>& frame_ids) = 0; // Resends a frame or part of a frame to kickstart. This is used when the // stream appears to be stalled. - virtual void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) = 0; + virtual void ResendFrameForKickstart(uint32_t ssrc, uint32_t frame_id) = 0; // Returns a callback for receiving packets for testing purposes. virtual PacketReceiverCallback PacketReceiverForTesting(); @@ -111,12 +109,12 @@ class CastTransportSender : public base::NonThreadSafe { // Add a valid SSRC. This is used to verify that incoming packets // come from the right sender. Without valid SSRCs, the return address cannot // be automatically established. - virtual void AddValidSsrc(uint32 ssrc) = 0; + virtual void AddValidSsrc(uint32_t ssrc) = 0; // Send an RTCP message from receiver to sender. virtual void SendRtcpFromRtpReceiver( - uint32 ssrc, - uint32 sender_ssrc, + uint32_t ssrc, + uint32_t sender_ssrc, const RtcpTimeData& time_data, const RtcpCastMessage* cast_message, base::TimeDelta target_delay, diff --git a/media/cast/net/cast_transport_sender_impl.cc b/media/cast/net/cast_transport_sender_impl.cc index f473219..10646ee 100644 --- a/media/cast/net/cast_transport_sender_impl.cc +++ b/media/cast/net/cast_transport_sender_impl.cc @@ -38,13 +38,14 @@ int LookupOptionWithDefault(const base::DictionaryValue& options, } }; -int32 GetTransportSendBufferSize(const base::DictionaryValue& options) { +int32_t GetTransportSendBufferSize(const base::DictionaryValue& options) { // Socket send buffer size needs to be at least greater than one burst // size. - int32 max_burst_size = + int32_t max_burst_size = LookupOptionWithDefault(options, kOptionPacerMaxBurstSize, - kMaxBurstSize) * kMaxIpPacketSize; - int32 min_send_buffer_size = + kMaxBurstSize) * + kMaxIpPacketSize; + int32_t min_send_buffer_size = LookupOptionWithDefault(options, kOptionSendBufferMinSize, 0); return std::max(max_burst_size, min_send_buffer_size); } @@ -254,7 +255,7 @@ void EncryptAndSendFrame(const EncodedFrame& frame, } } // namespace -void CastTransportSenderImpl::InsertFrame(uint32 ssrc, +void CastTransportSenderImpl::InsertFrame(uint32_t ssrc, const EncodedFrame& frame) { if (audio_sender_ && ssrc == audio_sender_->ssrc()) { EncryptAndSendFrame(frame, &audio_encryptor_, audio_sender_.get()); @@ -266,9 +267,9 @@ void CastTransportSenderImpl::InsertFrame(uint32 ssrc, } void CastTransportSenderImpl::SendSenderReport( - uint32 ssrc, + uint32_t ssrc, base::TimeTicks current_time, - uint32 current_time_as_rtp_timestamp) { + uint32_t current_time_as_rtp_timestamp) { if (audio_sender_ && ssrc == audio_sender_->ssrc()) { audio_rtcp_session_->SendRtcpFromRtpSender( current_time, current_time_as_rtp_timestamp, @@ -283,8 +284,8 @@ void CastTransportSenderImpl::SendSenderReport( } void CastTransportSenderImpl::CancelSendingFrames( - uint32 ssrc, - const std::vector<uint32>& frame_ids) { + uint32_t ssrc, + const std::vector<uint32_t>& frame_ids) { if (audio_sender_ && ssrc == audio_sender_->ssrc()) { audio_sender_->CancelSendingFrames(frame_ids); } else if (video_sender_ && ssrc == video_sender_->ssrc()) { @@ -294,8 +295,8 @@ void CastTransportSenderImpl::CancelSendingFrames( } } -void CastTransportSenderImpl::ResendFrameForKickstart(uint32 ssrc, - uint32 frame_id) { +void CastTransportSenderImpl::ResendFrameForKickstart(uint32_t ssrc, + uint32_t frame_id) { if (audio_sender_ && ssrc == audio_sender_->ssrc()) { DCHECK(audio_rtcp_session_); audio_sender_->ResendFrameForKickstart( @@ -312,7 +313,7 @@ void CastTransportSenderImpl::ResendFrameForKickstart(uint32 ssrc, } void CastTransportSenderImpl::ResendPackets( - uint32 ssrc, + uint32_t ssrc, const MissingFramesAndPacketsMap& missing_packets, bool cancel_rtx_if_not_in_list, const DedupInfo& dedup_info) { @@ -358,7 +359,7 @@ void CastTransportSenderImpl::SendRawEvents() { bool CastTransportSenderImpl::OnReceivedPacket(scoped_ptr<Packet> packet) { const uint8_t* const data = &packet->front(); const size_t length = packet->size(); - uint32 ssrc; + uint32_t ssrc; if (Rtcp::IsRtcpPacket(data, length)) { ssrc = Rtcp::GetSsrcOfSender(data, length); } else if (!RtpParser::ParseSsrc(data, length, &ssrc)) { @@ -430,7 +431,7 @@ void CastTransportSenderImpl::OnReceivedLogMessage( } void CastTransportSenderImpl::OnReceivedCastMessage( - uint32 ssrc, + uint32_t ssrc, const RtcpCastMessageCallback& cast_message_cb, const RtcpCastMessage& cast_message) { if (!cast_message_cb.is_null()) @@ -438,7 +439,7 @@ void CastTransportSenderImpl::OnReceivedCastMessage( DedupInfo dedup_info; if (audio_sender_ && audio_sender_->ssrc() == ssrc) { - const int64 acked_bytes = + const int64_t acked_bytes = audio_sender_->GetLastByteSentForFrame(cast_message.ack_frame_id); last_byte_acked_for_audio_ = std::max(acked_bytes, last_byte_acked_for_audio_); @@ -465,13 +466,13 @@ void CastTransportSenderImpl::OnReceivedCastMessage( dedup_info); } -void CastTransportSenderImpl::AddValidSsrc(uint32 ssrc) { +void CastTransportSenderImpl::AddValidSsrc(uint32_t ssrc) { valid_ssrcs_.insert(ssrc); } void CastTransportSenderImpl::SendRtcpFromRtpReceiver( - uint32 ssrc, - uint32 sender_ssrc, + uint32_t ssrc, + uint32_t sender_ssrc, const RtcpTimeData& time_data, const RtcpCastMessage* cast_message, base::TimeDelta target_delay, diff --git a/media/cast/net/cast_transport_sender_impl.h b/media/cast/net/cast_transport_sender_impl.h index 09b4299..2e32ac2 100644 --- a/media/cast/net/cast_transport_sender_impl.h +++ b/media/cast/net/cast_transport_sender_impl.h @@ -99,25 +99,25 @@ class CastTransportSenderImpl : public CastTransportSender { void InitializeVideo(const CastTransportRtpConfig& config, const RtcpCastMessageCallback& cast_message_cb, const RtcpRttCallback& rtt_cb) final; - void InsertFrame(uint32 ssrc, const EncodedFrame& frame) final; + void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final; - void SendSenderReport(uint32 ssrc, + void SendSenderReport(uint32_t ssrc, base::TimeTicks current_time, - uint32 current_time_as_rtp_timestamp) final; + uint32_t current_time_as_rtp_timestamp) final; - void CancelSendingFrames(uint32 ssrc, - const std::vector<uint32>& frame_ids) final; + void CancelSendingFrames(uint32_t ssrc, + const std::vector<uint32_t>& frame_ids) final; - void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) final; + void ResendFrameForKickstart(uint32_t ssrc, uint32_t frame_id) final; PacketReceiverCallback PacketReceiverForTesting() final; // CastTransportReceiver implementation. - void AddValidSsrc(uint32 ssrc) final; + void AddValidSsrc(uint32_t ssrc) final; void SendRtcpFromRtpReceiver( - uint32 ssrc, - uint32 sender_ssrc, + uint32_t ssrc, + uint32_t sender_ssrc, const RtcpTimeData& time_data, const RtcpCastMessage* cast_message, base::TimeDelta target_delay, @@ -135,7 +135,7 @@ class CastTransportSenderImpl : public CastTransportSender { // If |cancel_rtx_if_not_in_list| is true then transmission of packets for the // frames but not in the list will be dropped. // See PacedSender::ResendPackets() to see how |dedup_info| works. - void ResendPackets(uint32 ssrc, + void ResendPackets(uint32_t ssrc, const MissingFramesAndPacketsMap& missing_packets, bool cancel_rtx_if_not_in_list, const DedupInfo& dedup_info); @@ -152,7 +152,7 @@ class CastTransportSenderImpl : public CastTransportSender { const RtcpReceiverLogMessage& log); // Called when a RTCP Cast message is received. - void OnReceivedCastMessage(uint32 ssrc, + void OnReceivedCastMessage(uint32_t ssrc, const RtcpCastMessageCallback& cast_message_cb, const RtcpCastMessage& cast_message); @@ -192,10 +192,10 @@ class CastTransportSenderImpl : public CastTransportSender { // Right after a frame is sent we record the number of bytes sent to the // socket. We record the corresponding bytes sent for the most recent ACKed // audio packet. - int64 last_byte_acked_for_audio_; + int64_t last_byte_acked_for_audio_; // Packets that don't match these ssrcs are ignored. - std::set<uint32> valid_ssrcs_; + std::set<uint32_t> valid_ssrcs_; // Called with incoming packets. (Unless they match the // channels created by Initialize{Audio,Video}. diff --git a/media/cast/net/cast_transport_sender_impl_unittest.cc b/media/cast/net/cast_transport_sender_impl_unittest.cc index fecf820..bd795be 100644 --- a/media/cast/net/cast_transport_sender_impl_unittest.cc +++ b/media/cast/net/cast_transport_sender_impl_unittest.cc @@ -20,9 +20,9 @@ namespace media { namespace cast { namespace { -const int64 kStartMillisecond = INT64_C(12345678900000); -const uint32 kVideoSsrc = 1; -const uint32 kAudioSsrc = 2; +const int64_t kStartMillisecond = INT64_C(12345678900000); +const uint32_t kVideoSsrc = 1; +const uint32_t kAudioSsrc = 2; } // namespace class FakePacketSender : public PacketSender { @@ -41,7 +41,7 @@ class FakePacketSender : public PacketSender { return true; } - int64 GetBytesSent() final { return bytes_sent_; } + int64_t GetBytesSent() final { return bytes_sent_; } void SetPaused(bool paused) { paused_ = paused; @@ -58,7 +58,7 @@ class FakePacketSender : public PacketSender { base::Closure callback_; PacketRef stored_packet_; int packets_sent_; - int64 bytes_sent_; + int64_t bytes_sent_; DISALLOW_COPY_AND_ASSIGN(FakePacketSender); }; @@ -256,7 +256,7 @@ TEST_F(CastTransportSenderImplTest, CancelRetransmits) { task_runner_->Sleep(base::TimeDelta::FromMilliseconds(10)); EXPECT_EQ(2, num_times_logging_callback_called_); - std::vector<uint32> cancel_sending_frames; + std::vector<uint32_t> cancel_sending_frames; cancel_sending_frames.push_back(1); transport_sender_->CancelSendingFrames(kVideoSsrc, cancel_sending_frames); diff --git a/media/cast/net/frame_id_wrap_helper_test.cc b/media/cast/net/frame_id_wrap_helper_test.cc index 9be52bd..5ffeb22 100644 --- a/media/cast/net/frame_id_wrap_helper_test.cc +++ b/media/cast/net/frame_id_wrap_helper_test.cc @@ -14,16 +14,16 @@ class FrameIdWrapHelperTest : public ::testing::Test { FrameIdWrapHelperTest() : frame_id_wrap_helper_(kFirstFrameId - 1) {} ~FrameIdWrapHelperTest() override {} - void RunOneTest(uint32 starting_point, int iterations) { + void RunOneTest(uint32_t starting_point, int iterations) { const int window_size = 127; - uint32 window_base = starting_point; + uint32_t window_base = starting_point; frame_id_wrap_helper_.largest_frame_id_seen_ = starting_point; for (int i = 0; i < iterations; i++) { - uint32 largest_frame_id_seen = + uint32_t largest_frame_id_seen = frame_id_wrap_helper_.largest_frame_id_seen_; int offset = rand() % window_size; - uint32 frame_id = window_base + offset; - uint32 mapped_frame_id = + uint32_t frame_id = window_base + offset; + uint32_t mapped_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(frame_id & 0xff); EXPECT_EQ(frame_id, mapped_frame_id) << " Largest ID seen: " << largest_frame_id_seen @@ -46,19 +46,19 @@ TEST_F(FrameIdWrapHelperTest, FirstFrame) { } TEST_F(FrameIdWrapHelperTest, Rollover) { - uint32 new_frame_id = 0u; + uint32_t new_frame_id = 0u; for (int i = 0; i <= 256; ++i) { new_frame_id = - frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8>(i)); + frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8_t>(i)); } EXPECT_EQ(256u, new_frame_id); } TEST_F(FrameIdWrapHelperTest, OutOfOrder) { - uint32 new_frame_id = 0u; + uint32_t new_frame_id = 0u; for (int i = 0; i < 255; ++i) { new_frame_id = - frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8>(i)); + frame_id_wrap_helper_.MapTo32bitsFrameId(static_cast<uint8_t>(i)); } EXPECT_EQ(254u, new_frame_id); new_frame_id = frame_id_wrap_helper_.MapTo32bitsFrameId(0u); diff --git a/media/cast/net/mock_cast_transport_sender.h b/media/cast/net/mock_cast_transport_sender.h index 0827e1f..5eee66c 100644 --- a/media/cast/net/mock_cast_transport_sender.h +++ b/media/cast/net/mock_cast_transport_sender.h @@ -24,25 +24,24 @@ class MockCastTransportSender : public CastTransportSender { const CastTransportRtpConfig& config, const RtcpCastMessageCallback& cast_message_cb, const RtcpRttCallback& rtt_cb)); - MOCK_METHOD2(InsertFrame, void(uint32 ssrc, const EncodedFrame& frame)); - MOCK_METHOD3(SendSenderReport, void( - uint32 ssrc, - base::TimeTicks current_time, - uint32 current_time_as_rtp_timestamp)); - MOCK_METHOD2(CancelSendingFrames, void( - uint32 ssrc, - const std::vector<uint32>& frame_ids)); - MOCK_METHOD2(ResendFrameForKickstart, void(uint32 ssrc, uint32 frame_id)); + MOCK_METHOD2(InsertFrame, void(uint32_t ssrc, const EncodedFrame& frame)); + MOCK_METHOD3(SendSenderReport, + void(uint32_t ssrc, + base::TimeTicks current_time, + uint32_t current_time_as_rtp_timestamp)); + MOCK_METHOD2(CancelSendingFrames, + void(uint32_t ssrc, const std::vector<uint32_t>& frame_ids)); + MOCK_METHOD2(ResendFrameForKickstart, void(uint32_t ssrc, uint32_t frame_id)); MOCK_METHOD0(PacketReceiverForTesting, PacketReceiverCallback()); - MOCK_METHOD1(AddValidSsrc, void(uint32 ssrc)); - MOCK_METHOD7(SendRtcpFromRtpReceiver, void( - uint32 ssrc, - uint32 sender_ssrc, - const RtcpTimeData& time_data, - const RtcpCastMessage* cast_message, - base::TimeDelta target_delay, - const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, - const RtpReceiverStatistics* rtp_receiver_statistics)); + MOCK_METHOD1(AddValidSsrc, void(uint32_t ssrc)); + MOCK_METHOD7(SendRtcpFromRtpReceiver, + void(uint32_t ssrc, + uint32_t sender_ssrc, + const RtcpTimeData& time_data, + const RtcpCastMessage* cast_message, + base::TimeDelta target_delay, + const ReceiverRtcpEventSubscriber::RtcpEvents* rtcp_events, + const RtpReceiverStatistics* rtp_receiver_statistics)); }; } // namespace cast diff --git a/media/cast/net/pacing/paced_sender.cc b/media/cast/net/pacing/paced_sender.cc index 61166da..f70fc40 100644 --- a/media/cast/net/pacing/paced_sender.cc +++ b/media/cast/net/pacing/paced_sender.cc @@ -14,7 +14,7 @@ namespace cast { namespace { -static const int64 kPacingIntervalMs = 10; +static const int64_t kPacingIntervalMs = 10; // Each frame will be split into no more than kPacingMaxBurstsPerFrame // bursts of packets. static const size_t kPacingMaxBurstsPerFrame = 3; @@ -32,9 +32,9 @@ DedupInfo::DedupInfo() : last_byte_acked_for_audio(0) {} // static PacketKey PacedPacketSender::MakePacketKey(PacketKey::PacketType packet_type, - uint32 frame_id, - uint32 ssrc, - uint16 packet_id) { + uint32_t frame_id, + uint32_t ssrc, + uint16_t packet_id) { PacketKey key{packet_type, frame_id, ssrc, packet_id}; return key; } @@ -67,27 +67,27 @@ PacedSender::PacedSender( PacedSender::~PacedSender() {} -void PacedSender::RegisterAudioSsrc(uint32 audio_ssrc) { +void PacedSender::RegisterAudioSsrc(uint32_t audio_ssrc) { audio_ssrc_ = audio_ssrc; } -void PacedSender::RegisterVideoSsrc(uint32 video_ssrc) { +void PacedSender::RegisterVideoSsrc(uint32_t video_ssrc) { video_ssrc_ = video_ssrc; } -void PacedSender::RegisterPrioritySsrc(uint32 ssrc) { +void PacedSender::RegisterPrioritySsrc(uint32_t ssrc) { priority_ssrcs_.push_back(ssrc); } -int64 PacedSender::GetLastByteSentForPacket(const PacketKey& packet_key) { +int64_t PacedSender::GetLastByteSentForPacket(const PacketKey& packet_key) { PacketSendHistory::const_iterator it = send_history_.find(packet_key); if (it == send_history_.end()) return 0; return it->second.last_byte_sent; } -int64 PacedSender::GetLastByteSentForSsrc(uint32 ssrc) { - std::map<uint32, int64>::const_iterator it = last_byte_sent_.find(ssrc); +int64_t PacedSender::GetLastByteSentForSsrc(uint32_t ssrc) { + std::map<uint32_t, int64_t>::const_iterator it = last_byte_sent_.find(ssrc); if (it == last_byte_sent_.end()) return 0; return it->second; @@ -169,7 +169,7 @@ bool PacedSender::ResendPackets(const SendPacketVector& packets, return true; } -bool PacedSender::SendRtcpPacket(uint32 ssrc, PacketRef packet) { +bool PacedSender::SendRtcpPacket(uint32_t ssrc, PacketRef packet) { if (state_ == State_TransportBlocked) { PacketKey key = PacedPacketSender::MakePacketKey(PacketKey::RTCP, 0, ssrc, 0); @@ -336,7 +336,7 @@ void PacedSender::LogPacketEvent(const Packet& packet, CastLoggingEvent type) { packet.size()); bool success = reader.Skip(4); success &= reader.ReadU32(&event.rtp_timestamp); - uint32 ssrc; + uint32_t ssrc; success &= reader.ReadU32(&ssrc); if (ssrc == audio_ssrc_) { event.media_type = AUDIO_EVENT; diff --git a/media/cast/net/pacing/paced_sender.h b/media/cast/net/pacing/paced_sender.h index f37ebe7..c2a32d2 100644 --- a/media/cast/net/pacing/paced_sender.h +++ b/media/cast/net/pacing/paced_sender.h @@ -9,7 +9,6 @@ #include <tuple> #include <vector> -#include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/single_thread_task_runner.h" @@ -37,9 +36,9 @@ struct PacketKey { enum PacketType { RTCP = 0, RTP = 1 }; PacketType packet_type; - uint32 frame_id; - uint32 ssrc; - uint16 packet_id; + uint32_t frame_id; + uint32_t ssrc; + uint16_t packet_id; bool operator<(const PacketKey& key) const { return std::tie(packet_type, frame_id, ssrc, packet_id) < @@ -66,7 +65,7 @@ typedef std::vector<std::pair<PacketKey, PacketRef> > SendPacketVector; struct DedupInfo { DedupInfo(); base::TimeDelta resend_interval; - int64 last_byte_acked_for_audio; + int64_t last_byte_acked_for_audio; }; // We have this pure virtual class to enable mocking. @@ -75,15 +74,15 @@ class PacedPacketSender { virtual bool SendPackets(const SendPacketVector& packets) = 0; virtual bool ResendPackets(const SendPacketVector& packets, const DedupInfo& dedup_info) = 0; - virtual bool SendRtcpPacket(uint32 ssrc, PacketRef packet) = 0; + virtual bool SendRtcpPacket(uint32_t ssrc, PacketRef packet) = 0; virtual void CancelSendingPacket(const PacketKey& packet_key) = 0; virtual ~PacedPacketSender() {} static PacketKey MakePacketKey(PacketKey::PacketType, - uint32 frame_id, - uint32 ssrc, - uint16 packet_id); + uint32_t frame_id, + uint32_t ssrc, + uint16_t packet_id); }; class PacedSender : public PacedPacketSender, @@ -105,29 +104,29 @@ class PacedSender : public PacedPacketSender, ~PacedSender() final; // These must be called before non-RTCP packets are sent. - void RegisterAudioSsrc(uint32 audio_ssrc); - void RegisterVideoSsrc(uint32 video_ssrc); + void RegisterAudioSsrc(uint32_t audio_ssrc); + void RegisterVideoSsrc(uint32_t video_ssrc); // Register SSRC that has a higher priority for sending. Multiple SSRCs can // be registered. // Note that it is not expected to register many SSRCs with this method. // Because IsHigherPriority() is determined in linear time. - void RegisterPrioritySsrc(uint32 ssrc); + void RegisterPrioritySsrc(uint32_t ssrc); // Returns the total number of bytes sent to the socket when the specified // packet was just sent. // Returns 0 if the packet cannot be found or not yet sent. - int64 GetLastByteSentForPacket(const PacketKey& packet_key); + int64_t GetLastByteSentForPacket(const PacketKey& packet_key); // Returns the total number of bytes sent to the socket when the last payload // identified by SSRC is just sent. - int64 GetLastByteSentForSsrc(uint32 ssrc); + int64_t GetLastByteSentForSsrc(uint32_t ssrc); // PacedPacketSender implementation. bool SendPackets(const SendPacketVector& packets) final; bool ResendPackets(const SendPacketVector& packets, const DedupInfo& dedup_info) final; - bool SendRtcpPacket(uint32 ssrc, PacketRef packet) final; + bool SendRtcpPacket(uint32_t ssrc, PacketRef packet) final; void CancelSendingPacket(const PacketKey& packet_key) final; private: @@ -185,12 +184,12 @@ class PacedSender : public PacedPacketSender, PacketSender* const transport_; scoped_refptr<base::SingleThreadTaskRunner> transport_task_runner_; - uint32 audio_ssrc_; - uint32 video_ssrc_; + uint32_t audio_ssrc_; + uint32_t video_ssrc_; // Set of SSRCs that have higher priority. This is a vector instead of a // set because there's only very few in it (most likely 1). - std::vector<uint32> priority_ssrcs_; + std::vector<uint32_t> priority_ssrcs_; typedef std::map<PacketKey, std::pair<PacketType, PacketRef> > PacketList; PacketList packet_list_; PacketList priority_packet_list_; @@ -198,16 +197,16 @@ class PacedSender : public PacedPacketSender, struct PacketSendRecord { PacketSendRecord(); base::TimeTicks time; // Time when the packet was sent. - int64 last_byte_sent; // Number of bytes sent to network just after this - // packet was sent. - int64 last_byte_sent_for_audio; // Number of bytes sent to network from - // audio stream just before this packet. + int64_t last_byte_sent; // Number of bytes sent to network just after this + // packet was sent. + int64_t last_byte_sent_for_audio; // Number of bytes sent to network from + // audio stream just before this packet. }; typedef std::map<PacketKey, PacketSendRecord> PacketSendHistory; PacketSendHistory send_history_; PacketSendHistory send_history_buffer_; // Records the last byte sent for payload with a specific SSRC. - std::map<uint32, int64> last_byte_sent_; + std::map<uint32_t, int64_t> last_byte_sent_; size_t target_burst_size_; size_t max_burst_size_; diff --git a/media/cast/net/pacing/paced_sender_unittest.cc b/media/cast/net/pacing/paced_sender_unittest.cc index 1df7415..b11625d 100644 --- a/media/cast/net/pacing/paced_sender_unittest.cc +++ b/media/cast/net/pacing/paced_sender_unittest.cc @@ -16,16 +16,16 @@ namespace media { namespace cast { namespace { -static const uint8 kValue = 123; +static const uint8_t kValue = 123; static const size_t kSize1 = 101; static const size_t kSize2 = 102; static const size_t kSize3 = 103; static const size_t kSize4 = 104; static const size_t kNackSize = 105; -static const int64 kStartMillisecond = INT64_C(12345678900000); -static const uint32 kVideoSsrc = 0x1234; -static const uint32 kAudioSsrc = 0x5678; -static const uint32 kFrameRtpTimestamp = 12345; +static const int64_t kStartMillisecond = INT64_C(12345678900000); +static const uint32_t kVideoSsrc = 0x1234; +static const uint32_t kAudioSsrc = 0x5678; +static const uint32_t kFrameRtpTimestamp = 12345; class TestPacketSender : public PacketSender { public: @@ -40,7 +40,7 @@ class TestPacketSender : public PacketSender { return true; } - int64 GetBytesSent() final { return bytes_sent_; } + int64_t GetBytesSent() final { return bytes_sent_; } void AddExpectedSize(int expected_packet_size, int repeat_count) { for (int i = 0; i < repeat_count; ++i) { @@ -50,7 +50,7 @@ class TestPacketSender : public PacketSender { public: std::list<int> expected_packet_size_; - int64 bytes_sent_; + int64_t bytes_sent_; DISALLOW_COPY_AND_ASSIGN(TestPacketSender); }; @@ -123,7 +123,7 @@ class PacedSenderTest : public ::testing::Test { TestPacketSender mock_transport_; scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; scoped_ptr<PacedSender> paced_sender_; - uint32 frame_id_; + uint32_t frame_id_; DISALLOW_COPY_AND_ASSIGN(PacedSenderTest); }; @@ -177,7 +177,7 @@ TEST_F(PacedSenderTest, BasicPace) { // Check that packet logging events match expected values. EXPECT_EQ(num_of_packets, static_cast<int>(packet_events_.size())); - uint16 expected_packet_id = 0; + uint16_t expected_packet_id = 0; for (const PacketEvent& e : packet_events_) { ASSERT_LE(earliest_event_timestamp, e.timestamp); ASSERT_GE(latest_event_timestamp, e.timestamp); @@ -407,34 +407,34 @@ TEST_F(PacedSenderTest, GetLastByteSent) { SendPacketVector packets2 = CreateSendPacketVector(kSize1, 1, false); EXPECT_TRUE(paced_sender_->SendPackets(packets1)); - EXPECT_EQ(static_cast<int64>(kSize1), + EXPECT_EQ(static_cast<int64_t>(kSize1), paced_sender_->GetLastByteSentForPacket(packets1[0].first)); - EXPECT_EQ(static_cast<int64>(kSize1), + EXPECT_EQ(static_cast<int64_t>(kSize1), paced_sender_->GetLastByteSentForSsrc(kAudioSsrc)); EXPECT_EQ(0, paced_sender_->GetLastByteSentForSsrc(kVideoSsrc)); EXPECT_TRUE(paced_sender_->SendPackets(packets2)); - EXPECT_EQ(static_cast<int64>(2 * kSize1), + EXPECT_EQ(static_cast<int64_t>(2 * kSize1), paced_sender_->GetLastByteSentForPacket(packets2[0].first)); - EXPECT_EQ(static_cast<int64>(kSize1), + EXPECT_EQ(static_cast<int64_t>(kSize1), paced_sender_->GetLastByteSentForSsrc(kAudioSsrc)); - EXPECT_EQ(static_cast<int64>(2 * kSize1), + EXPECT_EQ(static_cast<int64_t>(2 * kSize1), paced_sender_->GetLastByteSentForSsrc(kVideoSsrc)); EXPECT_TRUE(paced_sender_->ResendPackets(packets1, DedupInfo())); - EXPECT_EQ(static_cast<int64>(3 * kSize1), + EXPECT_EQ(static_cast<int64_t>(3 * kSize1), paced_sender_->GetLastByteSentForPacket(packets1[0].first)); - EXPECT_EQ(static_cast<int64>(3 * kSize1), + EXPECT_EQ(static_cast<int64_t>(3 * kSize1), paced_sender_->GetLastByteSentForSsrc(kAudioSsrc)); - EXPECT_EQ(static_cast<int64>(2 * kSize1), + EXPECT_EQ(static_cast<int64_t>(2 * kSize1), paced_sender_->GetLastByteSentForSsrc(kVideoSsrc)); EXPECT_TRUE(paced_sender_->ResendPackets(packets2, DedupInfo())); - EXPECT_EQ(static_cast<int64>(4 * kSize1), + EXPECT_EQ(static_cast<int64_t>(4 * kSize1), paced_sender_->GetLastByteSentForPacket(packets2[0].first)); - EXPECT_EQ(static_cast<int64>(3 * kSize1), + EXPECT_EQ(static_cast<int64_t>(3 * kSize1), paced_sender_->GetLastByteSentForSsrc(kAudioSsrc)); - EXPECT_EQ(static_cast<int64>(4 * kSize1), + EXPECT_EQ(static_cast<int64_t>(4 * kSize1), paced_sender_->GetLastByteSentForSsrc(kVideoSsrc)); } @@ -450,11 +450,11 @@ TEST_F(PacedSenderTest, DedupWithResendInterval) { // This packet will not be sent. EXPECT_TRUE(paced_sender_->ResendPackets(packets, dedup_info)); - EXPECT_EQ(static_cast<int64>(kSize1), mock_transport_.GetBytesSent()); + EXPECT_EQ(static_cast<int64_t>(kSize1), mock_transport_.GetBytesSent()); dedup_info.resend_interval = base::TimeDelta::FromMilliseconds(5); EXPECT_TRUE(paced_sender_->ResendPackets(packets, dedup_info)); - EXPECT_EQ(static_cast<int64>(2 * kSize1), mock_transport_.GetBytesSent()); + EXPECT_EQ(static_cast<int64_t>(2 * kSize1), mock_transport_.GetBytesSent()); } } // namespace cast diff --git a/media/cast/net/rtcp/receiver_rtcp_event_subscriber.cc b/media/cast/net/rtcp/receiver_rtcp_event_subscriber.cc index 6ada1e4..7935e67 100644 --- a/media/cast/net/rtcp/receiver_rtcp_event_subscriber.cc +++ b/media/cast/net/rtcp/receiver_rtcp_event_subscriber.cc @@ -81,7 +81,7 @@ void ReceiverRtcpEventSubscriber::GetRtcpEventsWithRedundancy( DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(rtcp_events); - uint64 event_level = rtcp_events_.size() + popped_events_; + uint64_t event_level = rtcp_events_.size() + popped_events_; event_levels_for_past_frames_.push_back(event_level); for (size_t i = 0; i < kNumResends; i++) { @@ -89,8 +89,9 @@ void ReceiverRtcpEventSubscriber::GetRtcpEventsWithRedundancy( if (event_levels_for_past_frames_.size() < resend_delay + 1) break; - uint64 send_limit = event_levels_for_past_frames_[ - event_levels_for_past_frames_.size() - 1 - resend_delay]; + uint64_t send_limit = + event_levels_for_past_frames_[event_levels_for_past_frames_.size() - 1 - + resend_delay]; if (send_ptrs_[i] < popped_events_) { send_ptrs_[i] = popped_events_; diff --git a/media/cast/net/rtcp/receiver_rtcp_event_subscriber.h b/media/cast/net/rtcp/receiver_rtcp_event_subscriber.h index 248f07a..54ee477 100644 --- a/media/cast/net/rtcp/receiver_rtcp_event_subscriber.h +++ b/media/cast/net/rtcp/receiver_rtcp_event_subscriber.h @@ -74,21 +74,21 @@ class ReceiverRtcpEventSubscriber : public RawEventSubscriber { std::deque<RtcpEventPair> rtcp_events_; // Counts how many events have been removed from rtcp_events_. - uint64 popped_events_; + uint64_t popped_events_; // Events greater than send_ptrs_[0] have not been sent yet. // Events greater than send_ptrs_[1] have been transmit once. // Note that these counters use absolute numbers, so you need // to subtract popped_events_ before looking up the events in // rtcp_events_. - uint64 send_ptrs_[kNumResends]; + uint64_t send_ptrs_[kNumResends]; // For each frame, we push how many events have been added to // rtcp_events_ so far. We use this to make sure that // send_ptrs_[N+1] is always at least kResendDelay frames behind // send_ptrs_[N]. Old information is removed so that information // for (kNumResends + 1) * kResendDelay frames remain. - std::deque<uint64> event_levels_for_past_frames_; + std::deque<uint64_t> event_levels_for_past_frames_; // Ensures methods are only called on the main thread. base::ThreadChecker thread_checker_; diff --git a/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc b/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc index 4980494..7797da3 100644 --- a/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc +++ b/media/cast/net/rtcp/receiver_rtcp_event_subscriber_unittest.cc @@ -18,7 +18,7 @@ namespace cast { namespace { const size_t kMaxEventEntries = 10u; -const int64 kDelayMs = 20L; +const int64_t kDelayMs = 20L; } // namespace @@ -152,7 +152,7 @@ TEST_F(ReceiverRtcpEventSubscriberTest, LogAudioEvents) { TEST_F(ReceiverRtcpEventSubscriberTest, DropEventsWhenSizeExceeded) { Init(VIDEO_EVENT); - for (uint32 i = 1u; i <= 10u; ++i) { + for (uint32_t i = 1u; i <= 10u; ++i) { scoped_ptr<FrameEvent> decode_event(new FrameEvent()); decode_event->timestamp = testing_clock_->NowTicks(); decode_event->type = FRAME_DECODED; diff --git a/media/cast/net/rtcp/rtcp.h b/media/cast/net/rtcp/rtcp.h index 48c6f0d..4780a9f 100644 --- a/media/cast/net/rtcp/rtcp.h +++ b/media/cast/net/rtcp/rtcp.h @@ -85,7 +85,7 @@ class Rtcp { // and used to maintain a RTCP session. // Returns false if this is not a RTCP packet or it is not directed to // this session, e.g. SSRC doesn't match. - bool IncomingRtcpPacket(const uint8* data, size_t length); + bool IncomingRtcpPacket(const uint8_t* data, size_t length); // If available, returns true and sets the output arguments to the latest // lip-sync timestamps gleaned from the sender reports. While the sender @@ -102,8 +102,8 @@ class Rtcp { return current_round_trip_time_; } - static bool IsRtcpPacket(const uint8* packet, size_t length); - static uint32_t GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); + static bool IsRtcpPacket(const uint8_t* packet, size_t length); + static uint32_t GetSsrcOfSender(const uint8_t* rtcp_buffer, size_t length); uint32_t GetLocalSsrc() const { return local_ssrc_; } uint32_t GetRemoteSsrc() const { return remote_ssrc_; } diff --git a/media/cast/net/rtcp/rtcp_builder.cc b/media/cast/net/rtcp/rtcp_builder.cc index 07006fc..1f81520 100644 --- a/media/cast/net/rtcp/rtcp_builder.cc +++ b/media/cast/net/rtcp/rtcp_builder.cc @@ -18,20 +18,20 @@ namespace { // Max delta is 4095 milliseconds because we need to be able to encode it in // 12 bits. -const int64 kMaxWireFormatTimeDeltaMs = INT64_C(0xfff); +const int64_t kMaxWireFormatTimeDeltaMs = INT64_C(0xfff); -uint16 MergeEventTypeAndTimestampForWireFormat( +uint16_t MergeEventTypeAndTimestampForWireFormat( const CastLoggingEvent& event, const base::TimeDelta& time_delta) { - int64 time_delta_ms = time_delta.InMilliseconds(); + int64_t time_delta_ms = time_delta.InMilliseconds(); DCHECK_GE(time_delta_ms, 0); DCHECK_LE(time_delta_ms, kMaxWireFormatTimeDeltaMs); - uint16 time_delta_12_bits = - static_cast<uint16>(time_delta_ms & kMaxWireFormatTimeDeltaMs); + uint16_t time_delta_12_bits = + static_cast<uint16_t>(time_delta_ms & kMaxWireFormatTimeDeltaMs); - uint16 event_type_4_bits = ConvertEventTypeToWireFormat(event); + uint16_t event_type_4_bits = ConvertEventTypeToWireFormat(event); DCHECK(event_type_4_bits); DCHECK(~(event_type_4_bits & 0xfff0)); return (event_type_4_bits << 12) | time_delta_12_bits; @@ -114,11 +114,8 @@ class NackStringBuilder { }; } // namespace -RtcpBuilder::RtcpBuilder(uint32 sending_ssrc) - : writer_(NULL, 0), - ssrc_(sending_ssrc), - ptr_of_length_(NULL) { -} +RtcpBuilder::RtcpBuilder(uint32_t sending_ssrc) + : writer_(NULL, 0), ssrc_(sending_ssrc), ptr_of_length_(NULL) {} RtcpBuilder::~RtcpBuilder() {} @@ -237,8 +234,8 @@ void RtcpBuilder::AddCast(const RtcpCastMessage* cast, writer_.WriteU32(ssrc_); // Add our own SSRC. writer_.WriteU32(cast->media_ssrc); // Remote SSRC. writer_.WriteU32(kCast); - writer_.WriteU8(static_cast<uint8>(cast->ack_frame_id)); - uint8* cast_loss_field_pos = reinterpret_cast<uint8*>(writer_.ptr()); + writer_.WriteU8(static_cast<uint8_t>(cast->ack_frame_id)); + uint8_t* cast_loss_field_pos = reinterpret_cast<uint8_t*>(writer_.ptr()); writer_.WriteU8(0); // Overwritten with number_of_loss_fields. DCHECK_LE(target_delay.InMilliseconds(), std::numeric_limits<uint16_t>::max()); @@ -259,7 +256,7 @@ void RtcpBuilder::AddCast(const RtcpCastMessage* cast, // Iterate through all frames with missing packets. if (frame_it->second.empty()) { // Special case all packets in a frame is missing. - writer_.WriteU8(static_cast<uint8>(frame_it->first)); + writer_.WriteU8(static_cast<uint8_t>(frame_it->first)); writer_.WriteU16(kRtcpCastAllPacketsLost); writer_.WriteU8(0); nack_string_builder.PushPacket(kRtcpCastAllPacketsLost); @@ -267,16 +264,16 @@ void RtcpBuilder::AddCast(const RtcpCastMessage* cast, } else { PacketIdSet::const_iterator packet_it = frame_it->second.begin(); while (packet_it != frame_it->second.end()) { - uint16 packet_id = *packet_it; + uint16_t packet_id = *packet_it; // Write frame and packet id to buffer before calculating bitmask. - writer_.WriteU8(static_cast<uint8>(frame_it->first)); + writer_.WriteU8(static_cast<uint8_t>(frame_it->first)); writer_.WriteU16(packet_id); nack_string_builder.PushPacket(packet_id); - uint8 bitmask = 0; + uint8_t bitmask = 0; ++packet_it; while (packet_it != frame_it->second.end()) { - int shift = static_cast<uint8>(*packet_it - packet_id) - 1; + int shift = static_cast<uint8_t>(*packet_it - packet_id) - 1; if (shift >= 0 && shift <= 7) { nack_string_builder.PushPacket(*packet_it); bitmask |= (1 << shift); @@ -295,7 +292,7 @@ void RtcpBuilder::AddCast(const RtcpCastMessage* cast, << ", ACK: " << cast->ack_frame_id << ", NACK: " << nack_string_builder.GetString(); DCHECK_LE(number_of_loss_fields, kRtcpMaxCastLossFields); - *cast_loss_field_pos = static_cast<uint8>(number_of_loss_fields); + *cast_loss_field_pos = static_cast<uint8_t>(number_of_loss_fields); } void RtcpBuilder::AddSR(const RtcpSenderInfo& sender_info) { @@ -305,7 +302,7 @@ void RtcpBuilder::AddSR(const RtcpSenderInfo& sender_info) { writer_.WriteU32(sender_info.ntp_fraction); writer_.WriteU32(sender_info.rtp_timestamp); writer_.WriteU32(sender_info.send_packet_count); - writer_.WriteU32(static_cast<uint32>(sender_info.send_octet_count)); + writer_.WriteU32(static_cast<uint32_t>(sender_info.send_octet_count)); } /* @@ -367,21 +364,21 @@ void RtcpBuilder::AddReceiverLog( total_number_of_messages_to_send -= messages_in_frame; // On the wire format is number of messages - 1. - writer_.WriteU8(static_cast<uint8>(messages_in_frame - 1)); + writer_.WriteU8(static_cast<uint8_t>(messages_in_frame - 1)); base::TimeTicks event_timestamp_base = frame_log_messages.event_log_messages_.front().event_timestamp; - uint32 base_timestamp_ms = + uint32_t base_timestamp_ms = (event_timestamp_base - base::TimeTicks()).InMilliseconds(); - writer_.WriteU8(static_cast<uint8>(base_timestamp_ms >> 16)); - writer_.WriteU8(static_cast<uint8>(base_timestamp_ms >> 8)); - writer_.WriteU8(static_cast<uint8>(base_timestamp_ms)); + writer_.WriteU8(static_cast<uint8_t>(base_timestamp_ms >> 16)); + writer_.WriteU8(static_cast<uint8_t>(base_timestamp_ms >> 8)); + writer_.WriteU8(static_cast<uint8_t>(base_timestamp_ms)); while (!frame_log_messages.event_log_messages_.empty() && messages_in_frame > 0) { const RtcpReceiverEventLogMessage& event_message = frame_log_messages.event_log_messages_.front(); - uint16 event_type_and_timestamp_delta = + uint16_t event_type_and_timestamp_delta = MergeEventTypeAndTimestampForWireFormat( event_message.type, event_message.event_timestamp - event_timestamp_base); @@ -389,8 +386,8 @@ void RtcpBuilder::AddReceiverLog( case FRAME_ACK_SENT: case FRAME_PLAYOUT: case FRAME_DECODED: - writer_.WriteU16( - static_cast<uint16>(event_message.delay_delta.InMilliseconds())); + writer_.WriteU16(static_cast<uint16_t>( + event_message.delay_delta.InMilliseconds())); writer_.WriteU16(event_type_and_timestamp_delta); break; case PACKET_RECEIVED: diff --git a/media/cast/net/rtcp/rtcp_builder.h b/media/cast/net/rtcp/rtcp_builder.h index e6890d2..c7470a3 100644 --- a/media/cast/net/rtcp/rtcp_builder.h +++ b/media/cast/net/rtcp/rtcp_builder.h @@ -20,7 +20,7 @@ namespace cast { class RtcpBuilder { public: - explicit RtcpBuilder(uint32 sending_ssrc); + explicit RtcpBuilder(uint32_t sending_ssrc); ~RtcpBuilder(); PacketRef BuildRtcpFromReceiver( @@ -54,7 +54,7 @@ class RtcpBuilder { PacketRef Finish(); base::BigEndianWriter writer_; - const uint32 ssrc_; + const uint32_t ssrc_; char* ptr_of_length_; PacketRef packet_; diff --git a/media/cast/net/rtcp/rtcp_builder_unittest.cc b/media/cast/net/rtcp/rtcp_builder_unittest.cc index f39c82d..3ed5294 100644 --- a/media/cast/net/rtcp/rtcp_builder_unittest.cc +++ b/media/cast/net/rtcp/rtcp_builder_unittest.cc @@ -18,8 +18,8 @@ namespace media { namespace cast { namespace { -static const uint32 kSendingSsrc = 0x12345678; -static const uint32 kMediaSsrc = 0x87654321; +static const uint32_t kSendingSsrc = 0x12345678; +static const uint32_t kMediaSsrc = 0x87654321; static const base::TimeDelta kDefaultDelay = base::TimeDelta::FromMilliseconds(100); @@ -167,8 +167,8 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtraAndCastMessage) { } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtrCastMessageAndLog) { - static const uint32 kTimeBaseMs = 12345678; - static const uint32 kTimeDelayMs = 10; + static const uint32_t kTimeBaseMs = 12345678; + static const uint32_t kTimeDelayMs = 10; TestRtcpPacketBuilder p; p.AddRr(kSendingSsrc, 1); @@ -242,8 +242,8 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithRrtrCastMessageAndLog) { } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOversizedFrameLog) { - static const uint32 kTimeBaseMs = 12345678; - static const uint32 kTimeDelayMs = 10; + static const uint32_t kTimeBaseMs = 12345678; + static const uint32_t kTimeDelayMs = 10; TestRtcpPacketBuilder p; p.AddRr(kSendingSsrc, 1); @@ -264,10 +264,8 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOversizedFrameLog) { num_events, kTimeBaseMs); for (int i = 0; i < num_events; i++) { - p.AddReceiverEventLog( - kLostPacketId1, - PACKET_RECEIVED, - static_cast<uint16>(kTimeDelayMs * i)); + p.AddReceiverEventLog(kLostPacketId1, PACKET_RECEIVED, + static_cast<uint16_t>(kTimeDelayMs * i)); } @@ -297,8 +295,8 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOversizedFrameLog) { } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithTooManyLogFrames) { - static const uint32 kTimeBaseMs = 12345678; - static const uint32 kTimeDelayMs = 10; + static const uint32_t kTimeBaseMs = 12345678; + static const uint32_t kTimeDelayMs = 10; TestRtcpPacketBuilder p; p.AddRr(kSendingSsrc, 1); @@ -343,7 +341,7 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithTooManyLogFrames) { } TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOldLogFrames) { - static const uint32 kTimeBaseMs = 12345678; + static const uint32_t kTimeBaseMs = 12345678; TestRtcpPacketBuilder p; p.AddRr(kSendingSsrc, 1); @@ -390,7 +388,7 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportWithOldLogFrames) { } TEST_F(RtcpBuilderTest, RtcpReceiverReportRedundancy) { - uint32 time_base_ms = 12345678; + uint32_t time_base_ms = 12345678; int kTimeBetweenEventsMs = 10; RtcpReportBlock report_block = GetReportBlock(); @@ -413,9 +411,9 @@ TEST_F(RtcpBuilderTest, RtcpReceiverReportRedundancy) { time_base_ms - (num_events - 1) * kResendDelay * kTimeBetweenEventsMs); for (int i = 0; i < num_events; i++) { - p.AddReceiverEventLog( - 0, FRAME_ACK_SENT, - base::checked_cast<uint16>(i * kResendDelay * kTimeBetweenEventsMs)); + p.AddReceiverEventLog(0, FRAME_ACK_SENT, + base::checked_cast<uint16_t>(i * kResendDelay * + kTimeBetweenEventsMs)); } FrameEvent frame_event; diff --git a/media/cast/net/rtcp/rtcp_defines.cc b/media/cast/net/rtcp/rtcp_defines.cc index 128682b..2648a04 100644 --- a/media/cast/net/rtcp/rtcp_defines.cc +++ b/media/cast/net/rtcp/rtcp_defines.cc @@ -9,7 +9,7 @@ namespace media { namespace cast { -RtcpCastMessage::RtcpCastMessage(uint32 ssrc) +RtcpCastMessage::RtcpCastMessage(uint32_t ssrc) : media_ssrc(ssrc), ack_frame_id(0u), target_delay_ms(0) {} RtcpCastMessage::RtcpCastMessage() : media_ssrc(0), ack_frame_id(0u), target_delay_ms(0) {} @@ -19,7 +19,7 @@ RtcpReceiverEventLogMessage::RtcpReceiverEventLogMessage() : type(UNKNOWN), packet_id(0u) {} RtcpReceiverEventLogMessage::~RtcpReceiverEventLogMessage() {} -RtcpReceiverFrameLogMessage::RtcpReceiverFrameLogMessage(uint32 timestamp) +RtcpReceiverFrameLogMessage::RtcpReceiverFrameLogMessage(uint32_t timestamp) : rtp_timestamp_(timestamp) {} RtcpReceiverFrameLogMessage::~RtcpReceiverFrameLogMessage() {} diff --git a/media/cast/net/rtcp/rtcp_defines.h b/media/cast/net/rtcp/rtcp_defines.h index 72fdc31..032383a 100644 --- a/media/cast/net/rtcp/rtcp_defines.h +++ b/media/cast/net/rtcp/rtcp_defines.h @@ -38,13 +38,13 @@ enum RtcpPacketFields { // Handle the per frame ACK and NACK messages. struct RtcpCastMessage { - explicit RtcpCastMessage(uint32 ssrc); + explicit RtcpCastMessage(uint32_t ssrc); RtcpCastMessage(); ~RtcpCastMessage(); - uint32 media_ssrc; - uint32 ack_frame_id; - uint16 target_delay_ms; + uint32_t media_ssrc; + uint32_t ack_frame_id; + uint16_t target_delay_ms; MissingFramesAndPacketsMap missing_frames_and_packets; }; @@ -56,16 +56,16 @@ struct RtcpReceiverEventLogMessage { CastLoggingEvent type; base::TimeTicks event_timestamp; base::TimeDelta delay_delta; - uint16 packet_id; + uint16_t packet_id; }; typedef std::list<RtcpReceiverEventLogMessage> RtcpReceiverEventLogMessages; struct RtcpReceiverFrameLogMessage { - explicit RtcpReceiverFrameLogMessage(uint32 rtp_timestamp); + explicit RtcpReceiverFrameLogMessage(uint32_t rtp_timestamp); ~RtcpReceiverFrameLogMessage(); - uint32 rtp_timestamp_; + uint32_t rtp_timestamp_; RtcpReceiverEventLogMessages event_log_messages_; // TODO(mikhal): Investigate what's the best way to allow adding @@ -79,9 +79,9 @@ struct RtcpReceiverReferenceTimeReport { RtcpReceiverReferenceTimeReport(); ~RtcpReceiverReferenceTimeReport(); - uint32 remote_ssrc; - uint32 ntp_seconds; - uint32 ntp_fraction; + uint32_t remote_ssrc; + uint32_t ntp_seconds; + uint32_t ntp_fraction; }; inline bool operator==(RtcpReceiverReferenceTimeReport lhs, @@ -107,7 +107,7 @@ struct RtcpEvent { base::TimeDelta delay_delta; // Only set for packet events. - uint16 packet_id; + uint16_t packet_id; }; typedef base::Callback<void(const RtcpCastMessage&)> RtcpCastMessageCallback; @@ -118,16 +118,16 @@ base::Callback<void(const RtcpReceiverLogMessage&)> RtcpLogMessageCallback; // TODO(hubbe): Document members of this struct. struct RtpReceiverStatistics { RtpReceiverStatistics(); - uint8 fraction_lost; - uint32 cumulative_lost; // 24 bits valid. - uint32 extended_high_sequence_number; - uint32 jitter; + uint8_t fraction_lost; + uint32_t cumulative_lost; // 24 bits valid. + uint32_t extended_high_sequence_number; + uint32_t jitter; }; // These are intended to only be created using Rtcp::ConvertToNTPAndSave. struct RtcpTimeData { - uint32 ntp_seconds; - uint32 ntp_fraction; + uint32_t ntp_seconds; + uint32_t ntp_fraction; base::TimeTicks timestamp; }; @@ -136,8 +136,8 @@ struct RtcpTimeData { struct SendRtcpFromRtpReceiver_Params { SendRtcpFromRtpReceiver_Params(); ~SendRtcpFromRtpReceiver_Params(); - uint32 ssrc; - uint32 sender_ssrc; + uint32_t ssrc; + uint32_t sender_ssrc; RtcpTimeData time_data; scoped_ptr<RtcpCastMessage> cast_message; base::TimeDelta target_delay; diff --git a/media/cast/net/rtcp/rtcp_unittest.cc b/media/cast/net/rtcp/rtcp_unittest.cc index 88b7d45..7b85391 100644 --- a/media/cast/net/rtcp/rtcp_unittest.cc +++ b/media/cast/net/rtcp/rtcp_unittest.cc @@ -19,8 +19,8 @@ namespace cast { using testing::_; -static const uint32 kSenderSsrc = 0x10203; -static const uint32 kReceiverSsrc = 0x40506; +static const uint32_t kSenderSsrc = 0x10203; +static const uint32_t kReceiverSsrc = 0x40506; static const int kInitialReceiverClockOffsetSeconds = -5; class FakeRtcpTransport : public PacedPacketSender { @@ -35,7 +35,7 @@ class FakeRtcpTransport : public PacedPacketSender { base::TimeDelta packet_delay() const { return packet_delay_; } void set_packet_delay(base::TimeDelta delay) { packet_delay_ = delay; } - bool SendRtcpPacket(uint32 ssrc, PacketRef packet) final { + bool SendRtcpPacket(uint32_t ssrc, PacketRef packet) final { clock_->Advance(packet_delay_); if (paused_) { packet_queue_.push_back(packet); @@ -143,13 +143,13 @@ TEST_F(RtcpTest, LipSyncGleanedFromSenderReport) { // Initially, expect no lip-sync info receiver-side without having first // received a RTCP packet. base::TimeTicks reference_time; - uint32 rtp_timestamp; + uint32_t rtp_timestamp; ASSERT_FALSE(rtcp_for_receiver_.GetLatestLipSyncTimes(&rtp_timestamp, &reference_time)); // Send a Sender Report to the receiver. const base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); - const uint32 rtp_timestamp_sent = 0xbee5; + const uint32_t rtp_timestamp_sent = 0xbee5; rtcp_for_sender_.SendRtcpFromRtpSender( reference_time_sent, rtp_timestamp_sent, 1, 1); @@ -193,7 +193,7 @@ TEST_F(RtcpTest, RoundTripTimesDeterminedFromReportPingPong) { // Sender --> Receiver base::TimeTicks reference_time_sent = sender_clock_->NowTicks(); - uint32 rtp_timestamp_sent = 0xbee5 + i; + uint32_t rtp_timestamp_sent = 0xbee5 + i; rtcp_for_sender_.SendRtcpFromRtpSender( reference_time_sent, rtp_timestamp_sent, 1, 1); EXPECT_EQ(expected_rtt_according_to_sender, @@ -267,11 +267,11 @@ TEST_F(RtcpTest, NegativeTimeTicks) { // TODO(miu): Find a better home for this test. TEST(MisplacedCastTest, NtpAndTime) { - const int64 kSecondsbetweenYear1900and2010 = INT64_C(40176 * 24 * 60 * 60); - const int64 kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60); + const int64_t kSecondsbetweenYear1900and2010 = INT64_C(40176 * 24 * 60 * 60); + const int64_t kSecondsbetweenYear1900and2030 = INT64_C(47481 * 24 * 60 * 60); - uint32 ntp_seconds_1 = 0; - uint32 ntp_fraction_1 = 0; + uint32_t ntp_seconds_1 = 0; + uint32_t ntp_fraction_1 = 0; base::TimeTicks input_time = base::TimeTicks::Now(); ConvertTimeTicksToNtp(input_time, &ntp_seconds_1, &ntp_fraction_1); @@ -285,8 +285,8 @@ TEST(MisplacedCastTest, NtpAndTime) { base::TimeDelta time_delta = base::TimeDelta::FromMilliseconds(1000); input_time += time_delta; - uint32 ntp_seconds_2 = 0; - uint32 ntp_fraction_2 = 0; + uint32_t ntp_seconds_2 = 0; + uint32_t ntp_fraction_2 = 0; ConvertTimeTicksToNtp(input_time, &ntp_seconds_2, &ntp_fraction_2); base::TimeTicks out_2 = ConvertNtpToTimeTicks(ntp_seconds_2, ntp_fraction_2); @@ -300,8 +300,8 @@ TEST(MisplacedCastTest, NtpAndTime) { time_delta = base::TimeDelta::FromMilliseconds(500); input_time += time_delta; - uint32 ntp_seconds_3 = 0; - uint32 ntp_fraction_3 = 0; + uint32_t ntp_seconds_3 = 0; + uint32_t ntp_fraction_3 = 0; ConvertTimeTicksToNtp(input_time, &ntp_seconds_3, &ntp_fraction_3); base::TimeTicks out_3 = ConvertNtpToTimeTicks(ntp_seconds_3, ntp_fraction_3); diff --git a/media/cast/net/rtcp/rtcp_utility.cc b/media/cast/net/rtcp/rtcp_utility.cc index f299258..1ad69eb 100644 --- a/media/cast/net/rtcp/rtcp_utility.cc +++ b/media/cast/net/rtcp/rtcp_utility.cc @@ -24,14 +24,13 @@ const int64_t kUnixEpochInNtpSeconds = INT64_C(2208988800); const double kMagicFractionalUnit = 4.294967296E3; } -RtcpParser::RtcpParser(uint32 local_ssrc, uint32 remote_ssrc) : - local_ssrc_(local_ssrc), - remote_ssrc_(remote_ssrc), - has_sender_report_(false), - has_last_report_(false), - has_cast_message_(false), - has_receiver_reference_time_report_(false) { -} +RtcpParser::RtcpParser(uint32_t local_ssrc, uint32_t remote_ssrc) + : local_ssrc_(local_ssrc), + remote_ssrc_(remote_ssrc), + has_sender_report_(false), + has_last_report_(false), + has_cast_message_(false), + has_receiver_reference_time_report_(false) {} RtcpParser::~RtcpParser() {} @@ -86,7 +85,7 @@ bool RtcpParser::ParseCommonHeader(base::BigEndianReader* reader, // // Common header for all Rtcp packets, 4 octets. - uint8 byte; + uint8_t byte; if (!reader->ReadU8(&byte)) return false; parsed_header->V = byte >> 6; @@ -100,7 +99,7 @@ bool RtcpParser::ParseCommonHeader(base::BigEndianReader* reader, if (!reader->ReadU8(&parsed_header->PT)) return false; - uint16 bytes; + uint16_t bytes; if (!reader->ReadU16(&bytes)) return false; @@ -114,14 +113,14 @@ bool RtcpParser::ParseCommonHeader(base::BigEndianReader* reader, bool RtcpParser::ParseSR(base::BigEndianReader* reader, const RtcpCommonHeader& header) { - uint32 sender_ssrc; + uint32_t sender_ssrc; if (!reader->ReadU32(&sender_ssrc)) return false; if (sender_ssrc != remote_ssrc_) return true; - uint32 tmp; + uint32_t tmp; if (!reader->ReadU32(&sender_report_.ntp_seconds) || !reader->ReadU32(&sender_report_.ntp_fraction) || !reader->ReadU32(&sender_report_.rtp_timestamp) || @@ -140,7 +139,7 @@ bool RtcpParser::ParseSR(base::BigEndianReader* reader, bool RtcpParser::ParseRR(base::BigEndianReader* reader, const RtcpCommonHeader& header) { - uint32 receiver_ssrc; + uint32_t receiver_ssrc; if (!reader->ReadU32(&receiver_ssrc)) return false; @@ -155,7 +154,7 @@ bool RtcpParser::ParseRR(base::BigEndianReader* reader, } bool RtcpParser::ParseReportBlock(base::BigEndianReader* reader) { - uint32 ssrc, last_report, delay; + uint32_t ssrc, last_report, delay; if (!reader->ReadU32(&ssrc) || !reader->Skip(12) || !reader->ReadU32(&last_report) || @@ -173,8 +172,8 @@ bool RtcpParser::ParseReportBlock(base::BigEndianReader* reader) { bool RtcpParser::ParseApplicationDefined(base::BigEndianReader* reader, const RtcpCommonHeader& header) { - uint32 sender_ssrc; - uint32 name; + uint32_t sender_ssrc; + uint32_t name; if (!reader->ReadU32(&sender_ssrc) || !reader->ReadU32(&name)) return false; @@ -198,8 +197,8 @@ bool RtcpParser::ParseCastReceiverLogFrameItem( base::BigEndianReader* reader) { while (reader->remaining()) { - uint32 rtp_timestamp; - uint32 data; + uint32_t rtp_timestamp; + uint32_t data; if (!reader->ReadU32(&rtp_timestamp) || !reader->ReadU32(&data)) return false; @@ -208,19 +207,19 @@ bool RtcpParser::ParseCastReceiverLogFrameItem( base::TimeTicks event_timestamp_base = base::TimeTicks() + base::TimeDelta::FromMilliseconds(data & 0xffffff); - size_t num_events = 1 + static_cast<uint8>(data >> 24); + size_t num_events = 1 + static_cast<uint8_t>(data >> 24); RtcpReceiverFrameLogMessage frame_log(rtp_timestamp); for (size_t event = 0; event < num_events; event++) { - uint16 delay_delta_or_packet_id; - uint16 event_type_and_timestamp_delta; + uint16_t delay_delta_or_packet_id; + uint16_t event_type_and_timestamp_delta; if (!reader->ReadU16(&delay_delta_or_packet_id) || !reader->ReadU16(&event_type_and_timestamp_delta)) return false; RtcpReceiverEventLogMessage event_log; event_log.type = TranslateToLogEventFromWireFormat( - static_cast<uint8>(event_type_and_timestamp_delta >> 12)); + static_cast<uint8_t>(event_type_and_timestamp_delta >> 12)); event_log.event_timestamp = event_timestamp_base + base::TimeDelta::FromMilliseconds( @@ -229,7 +228,7 @@ bool RtcpParser::ParseCastReceiverLogFrameItem( event_log.packet_id = delay_delta_or_packet_id; } else { event_log.delay_delta = base::TimeDelta::FromMilliseconds( - static_cast<int16>(delay_delta_or_packet_id)); + static_cast<int16_t>(delay_delta_or_packet_id)); } frame_log.event_log_messages_.push_back(event_log); } @@ -247,8 +246,8 @@ bool RtcpParser::ParseFeedbackCommon(base::BigEndianReader* reader, if (header.IC != 15) { return true; } - uint32 remote_ssrc; - uint32 media_ssrc; + uint32_t remote_ssrc; + uint32_t media_ssrc; if (!reader->ReadU32(&remote_ssrc) || !reader->ReadU32(&media_ssrc)) return false; @@ -256,7 +255,7 @@ bool RtcpParser::ParseFeedbackCommon(base::BigEndianReader* reader, if (remote_ssrc != remote_ssrc_) return true; - uint32 name; + uint32_t name; if (!reader->ReadU32(&name)) return false; @@ -266,8 +265,8 @@ bool RtcpParser::ParseFeedbackCommon(base::BigEndianReader* reader, cast_message_.media_ssrc = remote_ssrc; - uint8 last_frame_id; - uint8 number_of_lost_fields; + uint8_t last_frame_id; + uint8_t number_of_lost_fields; if (!reader->ReadU8(&last_frame_id) || !reader->ReadU8(&number_of_lost_fields) || !reader->ReadU16(&cast_message_.target_delay_ms)) @@ -277,9 +276,9 @@ bool RtcpParser::ParseFeedbackCommon(base::BigEndianReader* reader, cast_message_.ack_frame_id = last_frame_id; for (size_t i = 0; i < number_of_lost_fields; i++) { - uint8 frame_id; - uint16 packet_id; - uint8 bitmask; + uint8_t frame_id; + uint16_t packet_id; + uint8_t bitmask; if (!reader->ReadU8(&frame_id) || !reader->ReadU16(&packet_id) || !reader->ReadU8(&bitmask)) @@ -301,7 +300,7 @@ bool RtcpParser::ParseFeedbackCommon(base::BigEndianReader* reader, bool RtcpParser::ParseExtendedReport(base::BigEndianReader* reader, const RtcpCommonHeader& header) { - uint32 remote_ssrc; + uint32_t remote_ssrc; if (!reader->ReadU32(&remote_ssrc)) return false; @@ -310,8 +309,8 @@ bool RtcpParser::ParseExtendedReport(base::BigEndianReader* reader, return true; while (reader->remaining()) { - uint8 block_type; - uint16 block_length; + uint8_t block_type; + uint16_t block_length; if (!reader->ReadU8(&block_type) || !reader->Skip(1) || !reader->ReadU16(&block_length)) @@ -338,7 +337,7 @@ bool RtcpParser::ParseExtendedReport(base::BigEndianReader* reader, bool RtcpParser::ParseExtendedReportReceiverReferenceTimeReport( base::BigEndianReader* reader, - uint32 remote_ssrc) { + uint32_t remote_ssrc) { receiver_reference_time_report_.remote_ssrc = remote_ssrc; if(!reader->ReadU32(&receiver_reference_time_report_.ntp_seconds) || !reader->ReadU32(&receiver_reference_time_report_.ntp_fraction)) @@ -351,7 +350,7 @@ bool RtcpParser::ParseExtendedReportReceiverReferenceTimeReport( // Converts a log event type to an integer value. // NOTE: We have only allocated 4 bits to represent the type of event over the // wire. Therefore, this function can only return values from 0 to 15. -uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event) { +uint8_t ConvertEventTypeToWireFormat(CastLoggingEvent event) { switch (event) { case FRAME_ACK_SENT: return 11; @@ -366,7 +365,7 @@ uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event) { } } -CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event) { +CastLoggingEvent TranslateToLogEventFromWireFormat(uint8_t event) { // TODO(imcheng): Remove the old mappings once they are no longer used. switch (event) { case 1: // AudioAckSent @@ -407,10 +406,10 @@ void ConvertTimeToFractions(int64_t ntp_time_us, // off the entire system. DCHECK_LT(seconds_component, INT64_C(4263431296)) << "One year left to fix the NTP year 2036 wrap-around issue!"; - *seconds = static_cast<uint32>(seconds_component); + *seconds = static_cast<uint32_t>(seconds_component); *fractions = - static_cast<uint32>((ntp_time_us % base::Time::kMicrosecondsPerSecond) * - kMagicFractionalUnit); + static_cast<uint32_t>((ntp_time_us % base::Time::kMicrosecondsPerSecond) * + kMagicFractionalUnit); } void ConvertTimeTicksToNtp(const base::TimeTicks& time, diff --git a/media/cast/net/rtcp/rtcp_utility.h b/media/cast/net/rtcp/rtcp_utility.h index a0a2abff..4092951 100644 --- a/media/cast/net/rtcp/rtcp_utility.h +++ b/media/cast/net/rtcp/rtcp_utility.h @@ -16,24 +16,24 @@ namespace cast { // RFC 3550 page 44, including end null. static const size_t kRtcpCnameSize = 256; -static const uint32 kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T'; +static const uint32_t kCast = ('C' << 24) + ('A' << 16) + ('S' << 8) + 'T'; -static const uint8 kReceiverLogSubtype = 2; +static const uint8_t kReceiverLogSubtype = 2; static const size_t kRtcpMaxReceiverLogMessages = 256; static const size_t kRtcpMaxCastLossFields = 100; struct RtcpCommonHeader { - uint8 V; // Version. + uint8_t V; // Version. bool P; // Padding. - uint8 IC; // Item count / subtype. - uint8 PT; // Packet Type. + uint8_t IC; // Item count / subtype. + uint8_t PT; // Packet Type. size_t length_in_octets; }; class RtcpParser { public: - RtcpParser(uint32 local_ssrc, uint32 remote_ssrc); + RtcpParser(uint32_t local_ssrc, uint32_t remote_ssrc); ~RtcpParser(); bool Parse(base::BigEndianReader* reader); @@ -44,8 +44,8 @@ class RtcpParser { } bool has_last_report() const { return has_last_report_; } - uint32 last_report() const { return last_report_; } - uint32 delay_since_last_report() const { return delay_since_last_report_; } + uint32_t last_report() const { return last_report_; } + uint32_t delay_since_last_report() const { return delay_since_last_report_; } bool has_receiver_log() const { return !receiver_log_.empty(); } const RtcpReceiverLogMessage& receiver_log() const { return receiver_log_; } @@ -80,18 +80,18 @@ class RtcpParser { const RtcpCommonHeader& header); bool ParseExtendedReportReceiverReferenceTimeReport( base::BigEndianReader* reader, - uint32 remote_ssrc); + uint32_t remote_ssrc); bool ParseExtendedReportDelaySinceLastReceiverReport( base::BigEndianReader* reader); - uint32 local_ssrc_; - uint32 remote_ssrc_; + uint32_t local_ssrc_; + uint32_t remote_ssrc_; bool has_sender_report_; RtcpSenderInfo sender_report_; - uint32 last_report_; - uint32 delay_since_last_report_; + uint32_t last_report_; + uint32_t delay_since_last_report_; bool has_last_report_; // |receiver_log_| is a vector vector, no need for has_*. @@ -109,10 +109,10 @@ class RtcpParser { // Converts a log event type to an integer value. // NOTE: We have only allocated 4 bits to represent the type of event over the // wire. Therefore, this function can only return values from 0 to 15. -uint8 ConvertEventTypeToWireFormat(CastLoggingEvent event); +uint8_t ConvertEventTypeToWireFormat(CastLoggingEvent event); // The inverse of |ConvertEventTypeToWireFormat()|. -CastLoggingEvent TranslateToLogEventFromWireFormat(uint8 event); +CastLoggingEvent TranslateToLogEventFromWireFormat(uint8_t event); // Splits an NTP timestamp having a microsecond timebase into the standard two // 32-bit integer wire format. diff --git a/media/cast/net/rtcp/rtcp_utility_unittest.cc b/media/cast/net/rtcp/rtcp_utility_unittest.cc index ec38755..ca68176 100644 --- a/media/cast/net/rtcp/rtcp_utility_unittest.cc +++ b/media/cast/net/rtcp/rtcp_utility_unittest.cc @@ -14,9 +14,9 @@ namespace media { namespace cast { -static const uint32 kSenderSsrc = 0x10203; -static const uint32 kSourceSsrc = 0x40506; -static const uint32 kUnknownSsrc = 0xDEAD; +static const uint32_t kSenderSsrc = 0x10203; +static const uint32_t kSourceSsrc = 0x40506; +static const uint32_t kUnknownSsrc = 0xDEAD; static const base::TimeDelta kTargetDelay = base::TimeDelta::FromMilliseconds(100); @@ -322,9 +322,9 @@ TEST_F(RtcpParserTest, InjectReceiverReportPacketWithCastFeedback) { } TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationBase) { - static const uint32 kTimeBaseMs = 12345678; - static const uint32 kTimeDelayMs = 10; - static const uint32 kDelayDeltaMs = 123; + static const uint32_t kTimeBaseMs = 12345678; + static const uint32_t kTimeDelayMs = 10; + static const uint32_t kDelayDeltaMs = 123; base::SimpleTestTickClock testing_clock; testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs)); @@ -365,8 +365,8 @@ TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationBase) { } TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationMulti) { - static const uint32 kTimeBaseMs = 12345678; - static const uint32 kTimeDelayMs = 10; + static const uint32_t kTimeBaseMs = 12345678; + static const uint32_t kTimeDelayMs = 10; static const int kDelayDeltaMs = 123; // To be varied for every frame. base::SimpleTestTickClock testing_clock; testing_clock.Advance(base::TimeDelta::FromMilliseconds(kTimeBaseMs)); @@ -392,7 +392,7 @@ TEST_F(RtcpParserTest, InjectReceiverReportWithReceiverLogVerificationMulti) { for (int i = 0; i < 100; ++i) { p.AddReceiverFrameLog(kRtpTimestamp, 1, kTimeBaseMs + i * kTimeDelayMs); const int delay = (i - 50) * kDelayDeltaMs; - p.AddReceiverEventLog(static_cast<uint16>(delay), FRAME_ACK_SENT, 0); + p.AddReceiverEventLog(static_cast<uint16_t>(delay), FRAME_ACK_SENT, 0); } RtcpParser parser(kSourceSsrc, kSenderSsrc); diff --git a/media/cast/net/rtcp/test_rtcp_packet_builder.cc b/media/cast/net/rtcp/test_rtcp_packet_builder.cc index 32e1883..382cde4 100644 --- a/media/cast/net/rtcp/test_rtcp_packet_builder.cc +++ b/media/cast/net/rtcp/test_rtcp_packet_builder.cc @@ -15,7 +15,7 @@ TestRtcpPacketBuilder::TestRtcpPacketBuilder() big_endian_writer_(reinterpret_cast<char*>(buffer_), kMaxIpPacketSize), big_endian_reader_(NULL, 0) {} -void TestRtcpPacketBuilder::AddSr(uint32 sender_ssrc, +void TestRtcpPacketBuilder::AddSr(uint32_t sender_ssrc, int number_of_report_blocks) { AddRtcpHeader(200, number_of_report_blocks); big_endian_writer_.WriteU32(sender_ssrc); @@ -26,10 +26,10 @@ void TestRtcpPacketBuilder::AddSr(uint32 sender_ssrc, big_endian_writer_.WriteU32(kSendOctetCount); } -void TestRtcpPacketBuilder::AddSrWithNtp(uint32 sender_ssrc, - uint32 ntp_high, - uint32 ntp_low, - uint32 rtp_timestamp) { +void TestRtcpPacketBuilder::AddSrWithNtp(uint32_t sender_ssrc, + uint32_t ntp_high, + uint32_t ntp_low, + uint32_t rtp_timestamp) { AddRtcpHeader(200, 0); big_endian_writer_.WriteU32(sender_ssrc); big_endian_writer_.WriteU32(ntp_high); @@ -39,13 +39,13 @@ void TestRtcpPacketBuilder::AddSrWithNtp(uint32 sender_ssrc, big_endian_writer_.WriteU32(kSendOctetCount); } -void TestRtcpPacketBuilder::AddRr(uint32 sender_ssrc, +void TestRtcpPacketBuilder::AddRr(uint32_t sender_ssrc, int number_of_report_blocks) { AddRtcpHeader(201, number_of_report_blocks); big_endian_writer_.WriteU32(sender_ssrc); } -void TestRtcpPacketBuilder::AddRb(uint32 rtp_ssrc) { +void TestRtcpPacketBuilder::AddRb(uint32_t rtp_ssrc) { big_endian_writer_.WriteU32(rtp_ssrc); big_endian_writer_.WriteU32(kLoss); big_endian_writer_.WriteU32(kExtendedMax); @@ -54,7 +54,7 @@ void TestRtcpPacketBuilder::AddRb(uint32 rtp_ssrc) { big_endian_writer_.WriteU32(kDelayLastSr); } -void TestRtcpPacketBuilder::AddXrHeader(uint32 sender_ssrc) { +void TestRtcpPacketBuilder::AddXrHeader(uint32_t sender_ssrc) { AddRtcpHeader(207, 0); big_endian_writer_.WriteU32(sender_ssrc); } @@ -77,7 +77,7 @@ void TestRtcpPacketBuilder::AddUnknownBlock() { big_endian_writer_.WriteU32(42); } -void TestRtcpPacketBuilder::AddXrDlrrBlock(uint32 sender_ssrc) { +void TestRtcpPacketBuilder::AddXrDlrrBlock(uint32_t sender_ssrc) { big_endian_writer_.WriteU8(5); // Block type. big_endian_writer_.WriteU8(0); // Reserved. big_endian_writer_.WriteU16(3); // Block length. @@ -88,7 +88,7 @@ void TestRtcpPacketBuilder::AddXrDlrrBlock(uint32 sender_ssrc) { big_endian_writer_.WriteU32(kDelayLastRr); } -void TestRtcpPacketBuilder::AddXrExtendedDlrrBlock(uint32 sender_ssrc) { +void TestRtcpPacketBuilder::AddXrExtendedDlrrBlock(uint32_t sender_ssrc) { big_endian_writer_.WriteU8(5); // Block type. big_endian_writer_.WriteU8(0); // Reserved. big_endian_writer_.WriteU16(9); // Block length. @@ -113,7 +113,7 @@ void TestRtcpPacketBuilder::AddXrRrtrBlock() { big_endian_writer_.WriteU32(kNtpLow); } -void TestRtcpPacketBuilder::AddNack(uint32 sender_ssrc, uint32 media_ssrc) { +void TestRtcpPacketBuilder::AddNack(uint32_t sender_ssrc, uint32_t media_ssrc) { AddRtcpHeader(205, 1); big_endian_writer_.WriteU32(sender_ssrc); big_endian_writer_.WriteU32(media_ssrc); @@ -121,15 +121,15 @@ void TestRtcpPacketBuilder::AddNack(uint32 sender_ssrc, uint32 media_ssrc) { big_endian_writer_.WriteU16(0); } -void TestRtcpPacketBuilder::AddSendReportRequest(uint32 sender_ssrc, - uint32 media_ssrc) { +void TestRtcpPacketBuilder::AddSendReportRequest(uint32_t sender_ssrc, + uint32_t media_ssrc) { AddRtcpHeader(205, 5); big_endian_writer_.WriteU32(sender_ssrc); big_endian_writer_.WriteU32(media_ssrc); } -void TestRtcpPacketBuilder::AddCast(uint32 sender_ssrc, - uint32 media_ssrc, +void TestRtcpPacketBuilder::AddCast(uint32_t sender_ssrc, + uint32_t media_ssrc, base::TimeDelta target_delay) { AddRtcpHeader(206, 15); big_endian_writer_.WriteU32(sender_ssrc); @@ -152,7 +152,7 @@ void TestRtcpPacketBuilder::AddCast(uint32 sender_ssrc, big_endian_writer_.WriteU8(0); // Lost packet id mask. } -void TestRtcpPacketBuilder::AddReceiverLog(uint32 sender_ssrc) { +void TestRtcpPacketBuilder::AddReceiverLog(uint32_t sender_ssrc) { AddRtcpHeader(204, 2); big_endian_writer_.WriteU32(sender_ssrc); big_endian_writer_.WriteU8('C'); @@ -161,22 +161,22 @@ void TestRtcpPacketBuilder::AddReceiverLog(uint32 sender_ssrc) { big_endian_writer_.WriteU8('T'); } -void TestRtcpPacketBuilder::AddReceiverFrameLog(uint32 rtp_timestamp, +void TestRtcpPacketBuilder::AddReceiverFrameLog(uint32_t rtp_timestamp, int num_events, - uint32 event_timesamp_base) { + uint32_t event_timesamp_base) { big_endian_writer_.WriteU32(rtp_timestamp); - big_endian_writer_.WriteU8(static_cast<uint8>(num_events - 1)); - big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base >> 16)); - big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base >> 8)); - big_endian_writer_.WriteU8(static_cast<uint8>(event_timesamp_base)); + big_endian_writer_.WriteU8(static_cast<uint8_t>(num_events - 1)); + big_endian_writer_.WriteU8(static_cast<uint8_t>(event_timesamp_base >> 16)); + big_endian_writer_.WriteU8(static_cast<uint8_t>(event_timesamp_base >> 8)); + big_endian_writer_.WriteU8(static_cast<uint8_t>(event_timesamp_base)); } -void TestRtcpPacketBuilder::AddReceiverEventLog(uint16 event_data, +void TestRtcpPacketBuilder::AddReceiverEventLog(uint16_t event_data, CastLoggingEvent event, - uint16 event_timesamp_delta) { + uint16_t event_timesamp_delta) { big_endian_writer_.WriteU16(event_data); - uint8 event_id = ConvertEventTypeToWireFormat(event); - uint16 type_and_delta = static_cast<uint16>(event_id) << 12; + uint8_t event_id = ConvertEventTypeToWireFormat(event); + uint16_t type_and_delta = static_cast<uint16_t>(event_id) << 12; type_and_delta += event_timesamp_delta & 0x0fff; big_endian_writer_.WriteU16(type_and_delta); } @@ -187,7 +187,7 @@ scoped_ptr<media::cast::Packet> TestRtcpPacketBuilder::GetPacket() { new media::cast::Packet(buffer_, buffer_ + Length())); } -const uint8* TestRtcpPacketBuilder::Data() { +const uint8_t* TestRtcpPacketBuilder::Data() { PatchLengthField(); return buffer_; } diff --git a/media/cast/net/rtcp/test_rtcp_packet_builder.h b/media/cast/net/rtcp/test_rtcp_packet_builder.h index 948f7a0..04ceb05 100644 --- a/media/cast/net/rtcp/test_rtcp_packet_builder.h +++ b/media/cast/net/rtcp/test_rtcp_packet_builder.h @@ -18,18 +18,18 @@ namespace cast { namespace { // Sender report. -static const uint32 kNtpHigh = 0x01020304; -static const uint32 kNtpLow = 0x05060708; -static const uint32 kRtpTimestamp = 0x10203040; -static const uint32 kSendPacketCount = 987; -static const uint32 kSendOctetCount = 87654; +static const uint32_t kNtpHigh = 0x01020304; +static const uint32_t kNtpLow = 0x05060708; +static const uint32_t kRtpTimestamp = 0x10203040; +static const uint32_t kSendPacketCount = 987; +static const uint32_t kSendOctetCount = 87654; // Report block. static const int kLoss = 0x01000123; static const int kExtendedMax = 0x15678; static const int kTestJitter = 0x10203; -static const uint32 kLastSr = 0x34561234; -static const uint32 kDelayLastSr = 1000; +static const uint32_t kLastSr = 0x34561234; +static const uint32_t kDelayLastSr = 1000; // DLRR block. static const int kLastRr = 0x34561234; @@ -39,9 +39,9 @@ static const int kDelayLastRr = 1000; static const int kMissingPacket = 34567; // CAST. -static const uint32 kAckFrameId = 17; -static const uint32 kLostFrameId = 18; -static const uint32 kFrameIdWithLostPackets = 19; +static const uint32_t kAckFrameId = 17; +static const uint32_t kLostFrameId = 18; +static const uint32_t kFrameIdWithLostPackets = 19; static const int kLostPacketId1 = 3; static const int kLostPacketId2 = 5; static const int kLostPacketId3 = 12; @@ -51,37 +51,37 @@ class TestRtcpPacketBuilder { public: TestRtcpPacketBuilder(); - void AddSr(uint32 sender_ssrc, int number_of_report_blocks); - void AddSrWithNtp(uint32 sender_ssrc, - uint32 ntp_high, - uint32 ntp_low, - uint32 rtp_timestamp); - void AddRr(uint32 sender_ssrc, int number_of_report_blocks); - void AddRb(uint32 rtp_ssrc); - - void AddXrHeader(uint32 sender_ssrc); - void AddXrDlrrBlock(uint32 sender_ssrc); - void AddXrExtendedDlrrBlock(uint32 sender_ssrc); + void AddSr(uint32_t sender_ssrc, int number_of_report_blocks); + void AddSrWithNtp(uint32_t sender_ssrc, + uint32_t ntp_high, + uint32_t ntp_low, + uint32_t rtp_timestamp); + void AddRr(uint32_t sender_ssrc, int number_of_report_blocks); + void AddRb(uint32_t rtp_ssrc); + + void AddXrHeader(uint32_t sender_ssrc); + void AddXrDlrrBlock(uint32_t sender_ssrc); + void AddXrExtendedDlrrBlock(uint32_t sender_ssrc); void AddXrRrtrBlock(); void AddXrUnknownBlock(); void AddUnknownBlock(); - void AddNack(uint32 sender_ssrc, uint32 media_ssrc); - void AddSendReportRequest(uint32 sender_ssrc, uint32 media_ssrc); + void AddNack(uint32_t sender_ssrc, uint32_t media_ssrc); + void AddSendReportRequest(uint32_t sender_ssrc, uint32_t media_ssrc); - void AddCast(uint32 sender_ssrc, - uint32 media_ssrc, + void AddCast(uint32_t sender_ssrc, + uint32_t media_ssrc, base::TimeDelta target_delay); - void AddReceiverLog(uint32 sender_ssrc); - void AddReceiverFrameLog(uint32 rtp_timestamp, + void AddReceiverLog(uint32_t sender_ssrc); + void AddReceiverFrameLog(uint32_t rtp_timestamp, int num_events, - uint32 event_timesamp_base); - void AddReceiverEventLog(uint16 event_data, + uint32_t event_timesamp_base); + void AddReceiverEventLog(uint16_t event_data, CastLoggingEvent event, - uint16 event_timesamp_delta); + uint16_t event_timesamp_delta); scoped_ptr<Packet> GetPacket(); - const uint8* Data(); + const uint8_t* Data(); int Length() { return kMaxIpPacketSize - big_endian_writer_.remaining(); } base::BigEndianReader* Reader(); @@ -91,7 +91,7 @@ class TestRtcpPacketBuilder { // Where the length field of the current packet is. // Note: 0 is not a legal value, it is used for "uninitialized". - uint8 buffer_[kMaxIpPacketSize]; + uint8_t buffer_[kMaxIpPacketSize]; char* ptr_of_length_; base::BigEndianWriter big_endian_writer_; base::BigEndianReader big_endian_reader_; diff --git a/media/cast/net/rtp/cast_message_builder.cc b/media/cast/net/rtp/cast_message_builder.cc index da851ee..0a47887 100644 --- a/media/cast/net/rtp/cast_message_builder.cc +++ b/media/cast/net/rtp/cast_message_builder.cc @@ -31,7 +31,7 @@ CastMessageBuilder::CastMessageBuilder( base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, const Framer* framer, - uint32 media_ssrc, + uint32_t media_ssrc, bool decoder_faster_than_max_frame_rate, int max_unacked_frames) : clock_(clock), @@ -49,8 +49,8 @@ CastMessageBuilder::CastMessageBuilder( CastMessageBuilder::~CastMessageBuilder() {} -void CastMessageBuilder::CompleteFrameReceived(uint32 frame_id) { - DCHECK_GE(static_cast<int32>(frame_id - last_acked_frame_id_), 0); +void CastMessageBuilder::CompleteFrameReceived(uint32_t frame_id) { + DCHECK_GE(static_cast<int32_t>(frame_id - last_acked_frame_id_), 0); VLOG(2) << "CompleteFrameReceived: " << frame_id; if (last_update_time_.is_null()) { // Our first update. @@ -67,7 +67,7 @@ void CastMessageBuilder::CompleteFrameReceived(uint32 frame_id) { cast_feedback_->CastFeedback(cast_msg_); } -bool CastMessageBuilder::UpdateAckMessage(uint32 frame_id) { +bool CastMessageBuilder::UpdateAckMessage(uint32_t frame_id) { if (!decoder_faster_than_max_frame_rate_) { int complete_frame_count = framer_->NumberOfCompleteFrames(); if (complete_frame_count > max_unacked_frames_) { @@ -169,8 +169,8 @@ void CastMessageBuilder::BuildPacketList() { if (framer_->Empty()) return; - uint32 newest_frame_id = framer_->NewestFrameId(); - uint32 next_expected_frame_id = cast_msg_.ack_frame_id + 1; + uint32_t newest_frame_id = framer_->NewestFrameId(); + uint32_t next_expected_frame_id = cast_msg_.ack_frame_id + 1; // Iterate over all frames. for (; !IsNewerFrameId(next_expected_frame_id, newest_frame_id); diff --git a/media/cast/net/rtp/cast_message_builder.h b/media/cast/net/rtp/cast_message_builder.h index ab9b72f..3b956b8 100644 --- a/media/cast/net/rtp/cast_message_builder.h +++ b/media/cast/net/rtp/cast_message_builder.h @@ -19,25 +19,25 @@ namespace cast { class Framer; class RtpPayloadFeedback; -typedef std::map<uint32, base::TimeTicks> TimeLastNackMap; +typedef std::map<uint32_t, base::TimeTicks> TimeLastNackMap; class CastMessageBuilder { public: CastMessageBuilder(base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, const Framer* framer, - uint32 media_ssrc, + uint32_t media_ssrc, bool decoder_faster_than_max_frame_rate, int max_unacked_frames); ~CastMessageBuilder(); - void CompleteFrameReceived(uint32 frame_id); + void CompleteFrameReceived(uint32_t frame_id); bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send); void UpdateCastMessage(); void Reset(); private: - bool UpdateAckMessage(uint32 frame_id); + bool UpdateAckMessage(uint32_t frame_id); void BuildPacketList(); bool UpdateCastMessageInternal(RtcpCastMessage* message); @@ -46,7 +46,7 @@ class CastMessageBuilder { // CastMessageBuilder has only const access to the framer. const Framer* const framer_; - const uint32 media_ssrc_; + const uint32_t media_ssrc_; const bool decoder_faster_than_max_frame_rate_; const int max_unacked_frames_; @@ -57,8 +57,8 @@ class CastMessageBuilder { bool slowing_down_ack_; bool acked_last_frame_; - uint32 last_acked_frame_id_; - std::deque<uint32> ack_queue_; + uint32_t last_acked_frame_id_; + std::deque<uint32_t> ack_queue_; DISALLOW_COPY_AND_ASSIGN(CastMessageBuilder); }; diff --git a/media/cast/net/rtp/cast_message_builder_unittest.cc b/media/cast/net/rtp/cast_message_builder_unittest.cc index 166834e..730ecf8 100644 --- a/media/cast/net/rtp/cast_message_builder_unittest.cc +++ b/media/cast/net/rtp/cast_message_builder_unittest.cc @@ -16,12 +16,12 @@ namespace media { namespace cast { namespace { -static const uint32 kSsrc = 0x1234; -static const uint32 kShortTimeIncrementMs = 10; -static const uint32 kLongTimeIncrementMs = 40; -static const int64 kStartMillisecond = INT64_C(12345678900000); +static const uint32_t kSsrc = 0x1234; +static const uint32_t kShortTimeIncrementMs = 10; +static const uint32_t kLongTimeIncrementMs = 40; +static const int64_t kStartMillisecond = INT64_C(12345678900000); -typedef std::map<uint32, size_t> MissingPacketsMap; +typedef std::map<uint32_t, size_t> MissingPacketsMap; class NackFeedbackVerification : public RtpPayloadFeedback { public: @@ -53,7 +53,7 @@ class NackFeedbackVerification : public RtpPayloadFeedback { triggered_ = true; } - size_t num_missing_packets(uint32 frame_id) { + size_t num_missing_packets(uint32_t frame_id) { MissingPacketsMap::iterator it; it = missing_packets_.find(frame_id); if (it == missing_packets_.end()) @@ -69,12 +69,12 @@ class NackFeedbackVerification : public RtpPayloadFeedback { return ret_val; } - uint32 last_frame_acked() { return last_frame_acked_; } + uint32_t last_frame_acked() { return last_frame_acked_; } private: bool triggered_; MissingPacketsMap missing_packets_; // Missing packets per frame. - uint32 last_frame_acked_; + uint32_t last_frame_acked_; DISALLOW_COPY_AND_ASSIGN(NackFeedbackVerification); }; @@ -102,14 +102,14 @@ class CastMessageBuilderTest : public ::testing::Test { ~CastMessageBuilderTest() override {} - void SetFrameIds(uint32 frame_id, uint32 reference_frame_id) { + void SetFrameIds(uint32_t frame_id, uint32_t reference_frame_id) { rtp_header_.frame_id = frame_id; rtp_header_.reference_frame_id = reference_frame_id; } - void SetPacketId(uint16 packet_id) { rtp_header_.packet_id = packet_id; } + void SetPacketId(uint16_t packet_id) { rtp_header_.packet_id = packet_id; } - void SetMaxPacketId(uint16 max_packet_id) { + void SetMaxPacketId(uint16_t max_packet_id) { rtp_header_.max_packet_id = max_packet_id; } @@ -117,7 +117,7 @@ class CastMessageBuilderTest : public ::testing::Test { void InsertPacket() { bool duplicate; - uint8 payload = 0; + uint8_t payload = 0; if (framer_.InsertPacket(&payload, 1, rtp_header_, &duplicate)) { cast_msg_builder_->CompleteFrameReceived(rtp_header_.frame_id); } @@ -391,7 +391,7 @@ TEST_F(CastMessageBuilderTest, SlowDownAck) { SetKeyFrame(true); InsertPacket(); - uint32 frame_id; + uint32_t frame_id; testing_clock_.Advance( base::TimeDelta::FromMilliseconds(kShortTimeIncrementMs)); SetKeyFrame(false); @@ -404,7 +404,7 @@ TEST_F(CastMessageBuilderTest, SlowDownAck) { base::TimeDelta::FromMilliseconds(kShortTimeIncrementMs)); } // We should now have entered the slowdown ACK state. - uint32 expected_frame_id = 1; + uint32_t expected_frame_id = 1; for (; frame_id < 10; ++frame_id) { if (frame_id % 2) { ++expected_frame_id; diff --git a/media/cast/net/rtp/frame_buffer.cc b/media/cast/net/rtp/frame_buffer.cc index 319aad2..facccaa 100644 --- a/media/cast/net/rtp/frame_buffer.cc +++ b/media/cast/net/rtp/frame_buffer.cc @@ -22,7 +22,7 @@ FrameBuffer::FrameBuffer() FrameBuffer::~FrameBuffer() {} -bool FrameBuffer::InsertPacket(const uint8* payload_data, +bool FrameBuffer::InsertPacket(const uint8_t* payload_data, size_t payload_size, const RtpCastHeader& rtp_header) { // Is this the first packet in the frame? @@ -45,7 +45,7 @@ bool FrameBuffer::InsertPacket(const uint8* payload_data, return false; } - std::vector<uint8> data; + std::vector<uint8_t> data; std::pair<PacketMap::iterator, bool> retval = packets_.insert(make_pair(rtp_header.packet_id, data)); diff --git a/media/cast/net/rtp/frame_buffer.h b/media/cast/net/rtp/frame_buffer.h index dedd82e..a558ae8 100644 --- a/media/cast/net/rtp/frame_buffer.h +++ b/media/cast/net/rtp/frame_buffer.h @@ -14,13 +14,13 @@ namespace media { namespace cast { -typedef std::map<uint16, std::vector<uint8> > PacketMap; +typedef std::map<uint16_t, std::vector<uint8_t>> PacketMap; class FrameBuffer { public: FrameBuffer(); ~FrameBuffer(); - bool InsertPacket(const uint8* payload_data, + bool InsertPacket(const uint8_t* payload_data, size_t payload_size, const RtpCastHeader& rtp_header); bool Complete() const; @@ -34,19 +34,21 @@ class FrameBuffer { bool AssembleEncodedFrame(EncodedFrame* frame) const; bool is_key_frame() const { return is_key_frame_; } - uint32 last_referenced_frame_id() const { return last_referenced_frame_id_; } - uint32 frame_id() const { return frame_id_; } + uint32_t last_referenced_frame_id() const { + return last_referenced_frame_id_; + } + uint32_t frame_id() const { return frame_id_; } private: - uint32 frame_id_; - uint16 max_packet_id_; - uint16 num_packets_received_; - uint16 max_seen_packet_id_; - uint16 new_playout_delay_ms_; + uint32_t frame_id_; + uint16_t max_packet_id_; + uint16_t num_packets_received_; + uint16_t max_seen_packet_id_; + uint16_t new_playout_delay_ms_; bool is_key_frame_; size_t total_data_size_; - uint32 last_referenced_frame_id_; - uint32 rtp_timestamp_; + uint32_t last_referenced_frame_id_; + uint32_t rtp_timestamp_; PacketMap packets_; DISALLOW_COPY_AND_ASSIGN(FrameBuffer); diff --git a/media/cast/net/rtp/frame_buffer_unittest.cc b/media/cast/net/rtp/frame_buffer_unittest.cc index f13771a..c910918 100644 --- a/media/cast/net/rtp/frame_buffer_unittest.cc +++ b/media/cast/net/rtp/frame_buffer_unittest.cc @@ -18,7 +18,7 @@ class FrameBufferTest : public ::testing::Test { ~FrameBufferTest() override {} FrameBuffer buffer_; - std::vector<uint8> payload_; + std::vector<uint8_t> payload_; RtpCastHeader rtp_header_; DISALLOW_COPY_AND_ASSIGN(FrameBufferTest); diff --git a/media/cast/net/rtp/framer.cc b/media/cast/net/rtp/framer.cc index a79ce79..2c98ee1 100644 --- a/media/cast/net/rtp/framer.cc +++ b/media/cast/net/rtp/framer.cc @@ -15,7 +15,7 @@ typedef FrameList::const_iterator ConstFrameIterator; Framer::Framer(base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, - uint32 ssrc, + uint32_t ssrc, bool decoder_faster_than_max_frame_rate, int max_unacked_frames) : decoder_faster_than_max_frame_rate_(decoder_faster_than_max_frame_rate), @@ -34,15 +34,15 @@ Framer::Framer(base::TickClock* clock, Framer::~Framer() {} -bool Framer::InsertPacket(const uint8* payload_data, +bool Framer::InsertPacket(const uint8_t* payload_data, size_t payload_size, const RtpCastHeader& rtp_header, bool* duplicate) { *duplicate = false; - uint32 frame_id = rtp_header.frame_id; + uint32_t frame_id = rtp_header.frame_id; if (rtp_header.is_key_frame && waiting_for_key_) { - last_released_frame_ = static_cast<uint32>(frame_id - 1); + last_released_frame_ = static_cast<uint32_t>(frame_id - 1); waiting_for_key_ = false; } @@ -88,7 +88,7 @@ bool Framer::GetEncodedFrame(EncodedFrame* frame, bool* have_multiple_decodable_frames) { *have_multiple_decodable_frames = HaveMultipleDecodableFrames(); - uint32 frame_id; + uint32_t frame_id; // Find frame id. if (NextContinuousFrame(&frame_id)) { // We have our next frame. @@ -112,7 +112,7 @@ bool Framer::GetEncodedFrame(EncodedFrame* frame, return it->second->AssembleEncodedFrame(frame); } -void Framer::AckFrame(uint32 frame_id) { +void Framer::AckFrame(uint32_t frame_id) { VLOG(2) << "ACK frame " << frame_id; cast_msg_builder_->CompleteFrameReceived(frame_id); } @@ -125,7 +125,7 @@ void Framer::Reset() { cast_msg_builder_->Reset(); } -void Framer::ReleaseFrame(uint32 frame_id) { +void Framer::ReleaseFrame(uint32_t frame_id) { RemoveOldFrames(frame_id); frames_.erase(frame_id); @@ -151,7 +151,7 @@ bool Framer::TimeToSendNextCastMessage(base::TimeTicks* time_to_send) { void Framer::SendCastMessage() { cast_msg_builder_->UpdateCastMessage(); } -void Framer::RemoveOldFrames(uint32 frame_id) { +void Framer::RemoveOldFrames(uint32_t frame_id) { FrameList::iterator it = frames_.begin(); while (it != frames_.end()) { @@ -165,9 +165,11 @@ void Framer::RemoveOldFrames(uint32 frame_id) { last_released_frame_ = frame_id; } -uint32 Framer::NewestFrameId() const { return newest_frame_id_; } +uint32_t Framer::NewestFrameId() const { + return newest_frame_id_; +} -bool Framer::NextContinuousFrame(uint32* frame_id) const { +bool Framer::NextContinuousFrame(uint32_t* frame_id) const { FrameList::const_iterator it; for (it = frames_.begin(); it != frames_.end(); ++it) { @@ -195,9 +197,9 @@ bool Framer::HaveMultipleDecodableFrames() const { return false; } -uint32 Framer::LastContinuousFrame() const { - uint32 last_continuous_frame_id = last_released_frame_; - uint32 next_expected_frame = last_released_frame_; +uint32_t Framer::LastContinuousFrame() const { + uint32_t last_continuous_frame_id = last_released_frame_; + uint32_t next_expected_frame = last_released_frame_; FrameList::const_iterator it; @@ -215,7 +217,7 @@ uint32 Framer::LastContinuousFrame() const { return last_continuous_frame_id; } -bool Framer::NextFrameAllowingSkippingFrames(uint32* frame_id) const { +bool Framer::NextFrameAllowingSkippingFrames(uint32_t* frame_id) const { // Find the oldest decodable frame. FrameList::const_iterator it_best_match = frames_.end(); FrameList::const_iterator it; @@ -247,13 +249,13 @@ int Framer::NumberOfCompleteFrames() const { return count; } -bool Framer::FrameExists(uint32 frame_id) const { +bool Framer::FrameExists(uint32_t frame_id) const { return frames_.end() != frames_.find(frame_id); } -void Framer::GetMissingPackets(uint32 frame_id, - bool last_frame, - PacketIdSet* missing_packets) const { +void Framer::GetMissingPackets(uint32_t frame_id, + bool last_frame, + PacketIdSet* missing_packets) const { FrameList::const_iterator it = frames_.find(frame_id); if (it == frames_.end()) return; @@ -265,7 +267,7 @@ bool Framer::ContinuousFrame(FrameBuffer* frame) const { DCHECK(frame); if (waiting_for_key_ && !frame->is_key_frame()) return false; - return static_cast<uint32>(last_released_frame_ + 1) == frame->frame_id(); + return static_cast<uint32_t>(last_released_frame_ + 1) == frame->frame_id(); } bool Framer::DecodableFrame(FrameBuffer* frame) const { diff --git a/media/cast/net/rtp/framer.h b/media/cast/net/rtp/framer.h index e39bafe..b215f7a 100644 --- a/media/cast/net/rtp/framer.h +++ b/media/cast/net/rtp/framer.h @@ -7,7 +7,6 @@ #include <map> -#include "base/basictypes.h" #include "base/memory/linked_ptr.h" #include "base/memory/scoped_ptr.h" #include "base/time/tick_clock.h" @@ -20,13 +19,13 @@ namespace media { namespace cast { -typedef std::map<uint32, linked_ptr<FrameBuffer> > FrameList; +typedef std::map<uint32_t, linked_ptr<FrameBuffer>> FrameList; class Framer { public: Framer(base::TickClock* clock, RtpPayloadFeedback* incoming_payload_feedback, - uint32 ssrc, + uint32_t ssrc, bool decoder_faster_than_max_frame_rate, int max_unacked_frames); ~Framer(); @@ -34,7 +33,7 @@ class Framer { // Return true when receiving the last packet in a frame, creating a // complete frame. If a duplicate packet for an already complete frame is // received, the function returns false but sets |duplicate| to true. - bool InsertPacket(const uint8* payload_data, + bool InsertPacket(const uint8_t* payload_data, size_t payload_size, const RtpCastHeader& rtp_header, bool* duplicate); @@ -49,9 +48,9 @@ class Framer { bool* have_multiple_complete_frames); // TODO(hubbe): Move this elsewhere. - void AckFrame(uint32 frame_id); + void AckFrame(uint32_t frame_id); - void ReleaseFrame(uint32 frame_id); + void ReleaseFrame(uint32_t frame_id); // Reset framer state to original state and flush all pending buffers. void Reset(); @@ -59,20 +58,20 @@ class Framer { void SendCastMessage(); bool Empty() const; - bool FrameExists(uint32 frame_id) const; - uint32 NewestFrameId() const; + bool FrameExists(uint32_t frame_id) const; + uint32_t NewestFrameId() const; - void RemoveOldFrames(uint32 frame_id); + void RemoveOldFrames(uint32_t frame_id); // Identifies the next frame to be released (rendered). - bool NextContinuousFrame(uint32* frame_id) const; - uint32 LastContinuousFrame() const; + bool NextContinuousFrame(uint32_t* frame_id) const; + uint32_t LastContinuousFrame() const; - bool NextFrameAllowingSkippingFrames(uint32* frame_id) const; + bool NextFrameAllowingSkippingFrames(uint32_t* frame_id) const; bool HaveMultipleDecodableFrames() const; int NumberOfCompleteFrames() const; - void GetMissingPackets(uint32 frame_id, + void GetMissingPackets(uint32_t frame_id, bool last_frame, PacketIdSet* missing_packets) const; @@ -84,8 +83,8 @@ class Framer { FrameList frames_; scoped_ptr<CastMessageBuilder> cast_msg_builder_; bool waiting_for_key_; - uint32 last_released_frame_; - uint32 newest_frame_id_; + uint32_t last_released_frame_; + uint32_t newest_frame_id_; DISALLOW_COPY_AND_ASSIGN(Framer); }; diff --git a/media/cast/net/rtp/framer_unittest.cc b/media/cast/net/rtp/framer_unittest.cc index c06b1d9..feed3ab 100644 --- a/media/cast/net/rtp/framer_unittest.cc +++ b/media/cast/net/rtp/framer_unittest.cc @@ -24,7 +24,7 @@ class FramerTest : public ::testing::Test { ~FramerTest() override {} - std::vector<uint8> payload_; + std::vector<uint8_t> payload_; RtpCastHeader rtp_header_; MockRtpPayloadFeedback mock_rtp_payload_feedback_; Framer framer_; diff --git a/media/cast/net/rtp/mock_rtp_feedback.h b/media/cast/net/rtp/mock_rtp_feedback.h index 9542081..b5a3a68 100644 --- a/media/cast/net/rtp/mock_rtp_feedback.h +++ b/media/cast/net/rtp/mock_rtp_feedback.h @@ -14,19 +14,20 @@ namespace cast { class MockRtpFeedback : public RtpFeedback { public: MOCK_METHOD4(OnInitializeDecoder, - int32(const int8 payloadType, - const int frequency, - const uint8 channels, - const uint32 rate)); + int32_t(const int8_t payloadType, + const int frequency, + const uint8_t channels, + const uint32_t rate)); - MOCK_METHOD1(OnPacketTimeout, void(const int32 id)); + MOCK_METHOD1(OnPacketTimeout, void(const int32_t id)); MOCK_METHOD2(OnReceivedPacket, - void(const int32 id, const RtpRtcpPacketField packet_type)); + void(const int32_t id, const RtpRtcpPacketField packet_type)); MOCK_METHOD2(OnPeriodicDeadOrAlive, - void(const int32 id, const RTPAliveType alive)); - MOCK_METHOD2(OnIncomingSSRCChanged, void(const int32 id, const uint32 ssrc)); + void(const int32_t id, const RTPAliveType alive)); + MOCK_METHOD2(OnIncomingSSRCChanged, + void(const int32_t id, const uint32_t ssrc)); MOCK_METHOD3(OnIncomingCSRCChanged, - void(const int32 id, const uint32 csrc, const bool added)); + void(const int32_t id, const uint32_t csrc, const bool added)); }; } // namespace cast diff --git a/media/cast/net/rtp/packet_storage.cc b/media/cast/net/rtp/packet_storage.cc index bd242e6..9b124ac 100644 --- a/media/cast/net/rtp/packet_storage.cc +++ b/media/cast/net/rtp/packet_storage.cc @@ -22,7 +22,7 @@ size_t PacketStorage::GetNumberOfStoredFrames() const { return frames_.size() - zombie_count_; } -void PacketStorage::StoreFrame(uint32 frame_id, +void PacketStorage::StoreFrame(uint32_t frame_id, const SendPacketVector& packets) { if (packets.empty()) { NOTREACHED(); @@ -33,7 +33,7 @@ void PacketStorage::StoreFrame(uint32 frame_id, first_frame_id_in_list_ = frame_id; } else { // Make sure frame IDs are consecutive. - DCHECK_EQ(first_frame_id_in_list_ + static_cast<uint32>(frames_.size()), + DCHECK_EQ(first_frame_id_in_list_ + static_cast<uint32_t>(frames_.size()), frame_id); // Make sure we aren't being asked to store more frames than the system's // design limit. @@ -44,9 +44,9 @@ void PacketStorage::StoreFrame(uint32 frame_id, frames_.push_back(packets); } -void PacketStorage::ReleaseFrame(uint32 frame_id) { - const uint32 offset = frame_id - first_frame_id_in_list_; - if (static_cast<int32>(offset) < 0 || offset >= frames_.size() || +void PacketStorage::ReleaseFrame(uint32_t frame_id) { + const uint32_t offset = frame_id - first_frame_id_in_list_; + if (static_cast<int32_t>(offset) < 0 || offset >= frames_.size() || frames_[offset].empty()) { return; } @@ -62,10 +62,10 @@ void PacketStorage::ReleaseFrame(uint32 frame_id) { } } -const SendPacketVector* PacketStorage::GetFrame8(uint8 frame_id_8bits) const { +const SendPacketVector* PacketStorage::GetFrame8(uint8_t frame_id_8bits) const { // The requested frame ID has only 8-bits so convert the first frame ID // in list to match. - uint8 index_8bits = first_frame_id_in_list_ & 0xFF; + uint8_t index_8bits = first_frame_id_in_list_ & 0xFF; index_8bits = frame_id_8bits - index_8bits; if (index_8bits >= frames_.size()) return NULL; diff --git a/media/cast/net/rtp/packet_storage.h b/media/cast/net/rtp/packet_storage.h index e086f8b..370cf5d 100644 --- a/media/cast/net/rtp/packet_storage.h +++ b/media/cast/net/rtp/packet_storage.h @@ -7,7 +7,6 @@ #include <deque> -#include "base/basictypes.h" #include "media/cast/net/pacing/paced_sender.h" namespace media { @@ -19,22 +18,22 @@ class PacketStorage { virtual ~PacketStorage(); // Store all of the packets for a frame. - void StoreFrame(uint32 frame_id, const SendPacketVector& packets); + void StoreFrame(uint32_t frame_id, const SendPacketVector& packets); // Release all of the packets for a frame. - void ReleaseFrame(uint32 frame_id); + void ReleaseFrame(uint32_t frame_id); // Returns a list of packets for a frame indexed by a 8-bits ID. // It is the lowest 8 bits of a frame ID. // Returns NULL if the frame cannot be found. - const SendPacketVector* GetFrame8(uint8 frame_id_8bits) const; + const SendPacketVector* GetFrame8(uint8_t frame_id_8bits) const; // Get the number of stored frames. size_t GetNumberOfStoredFrames() const; private: std::deque<SendPacketVector> frames_; - uint32 first_frame_id_in_list_; + uint32_t first_frame_id_in_list_; // The number of frames whose packets have been released, but the entry in the // |frames_| queue has not yet been popped. diff --git a/media/cast/net/rtp/packet_storage_unittest.cc b/media/cast/net/rtp/packet_storage_unittest.cc index 699368f..29fc415 100644 --- a/media/cast/net/rtp/packet_storage_unittest.cc +++ b/media/cast/net/rtp/packet_storage_unittest.cc @@ -22,7 +22,7 @@ static const size_t kStoredFrames = 10; // Generate |number_of_frames| and store into |*storage|. // First frame has 1 packet, second frame has 2 packets, etc. static void StoreFrames(size_t number_of_frames, - uint32 first_frame_id, + uint32_t first_frame_id, PacketStorage* storage) { const int kSsrc = 1; for (size_t i = 0; i < number_of_frames; ++i) { @@ -33,7 +33,7 @@ static void StoreFrames(size_t number_of_frames, Packet test_packet(1, 0); packets.push_back(std::make_pair( PacedPacketSender::MakePacketKey(PacketKey::RTP, i, kSsrc, - base::checked_cast<uint16>(j)), + base::checked_cast<uint16_t>(j)), new base::RefCountedData<Packet>(test_packet))); } storage->StoreFrame(first_frame_id, packets); @@ -44,8 +44,8 @@ static void StoreFrames(size_t number_of_frames, TEST(PacketStorageTest, NumberOfStoredFrames) { PacketStorage storage; - uint32 frame_id = 0; - frame_id = ~frame_id; // The maximum value of uint32. + uint32_t frame_id = 0; + frame_id = ~frame_id; // The maximum value of uint32_t. StoreFrames(kMaxUnackedFrames / 2, frame_id, &storage); EXPECT_EQ(static_cast<size_t>(kMaxUnackedFrames / 2), storage.GetNumberOfStoredFrames()); @@ -54,14 +54,14 @@ TEST(PacketStorageTest, NumberOfStoredFrames) { TEST(PacketStorageTest, GetFrameWrapAround8bits) { PacketStorage storage; - const uint32 kFirstFrameId = 250; + const uint32_t kFirstFrameId = 250; StoreFrames(kStoredFrames, kFirstFrameId, &storage); EXPECT_EQ(std::min<size_t>(kMaxUnackedFrames, kStoredFrames), storage.GetNumberOfStoredFrames()); // Expect we get the correct frames by looking at the number of // packets. - uint32 frame_id = kFirstFrameId; + uint32_t frame_id = kFirstFrameId; for (size_t i = 0; i < kStoredFrames; ++i) { ASSERT_TRUE(storage.GetFrame8(frame_id)); EXPECT_EQ(i + 1, storage.GetFrame8(frame_id)->size()); @@ -72,15 +72,15 @@ TEST(PacketStorageTest, GetFrameWrapAround8bits) { TEST(PacketStorageTest, GetFrameWrapAround32bits) { PacketStorage storage; - // First frame ID is close to the maximum value of uint32. - uint32 first_frame_id = 0xffffffff - 5; + // First frame ID is close to the maximum value of uint32_t. + uint32_t first_frame_id = 0xffffffff - 5; StoreFrames(kStoredFrames, first_frame_id, &storage); EXPECT_EQ(std::min<size_t>(kMaxUnackedFrames, kStoredFrames), storage.GetNumberOfStoredFrames()); // Expect we get the correct frames by looking at the number of // packets. - uint32 frame_id = first_frame_id; + uint32_t frame_id = first_frame_id; for (size_t i = 0; i < kStoredFrames; ++i) { ASSERT_TRUE(storage.GetFrame8(frame_id)); EXPECT_EQ(i + 1, storage.GetFrame8(frame_id)->size()); @@ -91,12 +91,12 @@ TEST(PacketStorageTest, GetFrameWrapAround32bits) { TEST(PacketStorageTest, FramesReleased) { PacketStorage storage; - const uint32 kFirstFrameId = 0; + const uint32_t kFirstFrameId = 0; StoreFrames(5, kFirstFrameId, &storage); EXPECT_EQ(std::min<size_t>(kMaxUnackedFrames, 5), storage.GetNumberOfStoredFrames()); - for (uint32 frame_id = kFirstFrameId; frame_id < kFirstFrameId + 5; + for (uint32_t frame_id = kFirstFrameId; frame_id < kFirstFrameId + 5; ++frame_id) { EXPECT_TRUE(storage.GetFrame8(frame_id)); } diff --git a/media/cast/net/rtp/receiver_stats.cc b/media/cast/net/rtp/receiver_stats.cc index bceb8add..2238f6a 100644 --- a/media/cast/net/rtp/receiver_stats.cc +++ b/media/cast/net/rtp/receiver_stats.cc @@ -11,7 +11,7 @@ namespace media { namespace cast { -static const uint32 kMaxSequenceNumber = 65536; +static const uint32_t kMaxSequenceNumber = 65536; ReceiverStats::ReceiverStats(base::TickClock* clock) : clock_(clock), @@ -43,7 +43,7 @@ RtpReceiverStatistics ReceiverStats::GetStatistics() { } else { float tmp_ratio = (1 - static_cast<float>(interval_number_packets_) / abs(diff)); - ret.fraction_lost = static_cast<uint8>(256 * tmp_ratio); + ret.fraction_lost = static_cast<uint8_t>(256 * tmp_ratio); } } @@ -63,7 +63,8 @@ RtpReceiverStatistics ReceiverStats::GetStatistics() { ret.extended_high_sequence_number = (sequence_number_cycles_ << 16) + max_sequence_number_; - ret.jitter = static_cast<uint32>(std::abs(jitter_.InMillisecondsRoundedUp())); + ret.jitter = + static_cast<uint32_t>(std::abs(jitter_.InMillisecondsRoundedUp())); // Reset interval values. interval_min_sequence_number_ = 0; @@ -74,7 +75,7 @@ RtpReceiverStatistics ReceiverStats::GetStatistics() { } void ReceiverStats::UpdateStatistics(const RtpCastHeader& header) { - const uint16 new_seq_num = header.sequence_number; + const uint16_t new_seq_num = header.sequence_number; if (interval_number_packets_ == 0) { // First packet in the interval. diff --git a/media/cast/net/rtp/receiver_stats.h b/media/cast/net/rtp/receiver_stats.h index 5ffbb5f..127e04a 100644 --- a/media/cast/net/rtp/receiver_stats.h +++ b/media/cast/net/rtp/receiver_stats.h @@ -24,10 +24,10 @@ class ReceiverStats { base::TickClock* const clock_; // Not owned by this class. // Global metrics. - uint16 min_sequence_number_; - uint16 max_sequence_number_; - uint32 total_number_packets_; - uint16 sequence_number_cycles_; + uint16_t min_sequence_number_; + uint16_t max_sequence_number_; + uint32_t total_number_packets_; + uint16_t sequence_number_cycles_; base::TimeDelta last_received_timestamp_; base::TimeTicks last_received_packet_time_; base::TimeDelta jitter_; diff --git a/media/cast/net/rtp/receiver_stats_unittest.cc b/media/cast/net/rtp/receiver_stats_unittest.cc index 9784b90..a62d95c 100644 --- a/media/cast/net/rtp/receiver_stats_unittest.cc +++ b/media/cast/net/rtp/receiver_stats_unittest.cc @@ -14,8 +14,8 @@ namespace media { namespace cast { -static const int64 kStartMillisecond = INT64_C(12345678900000); -static const uint32 kStdTimeIncrementMs = 33; +static const int64_t kStartMillisecond = INT64_C(12345678900000); +static const uint32_t kStdTimeIncrementMs = 33; class ReceiverStatsTest : public ::testing::Test { protected: @@ -28,7 +28,7 @@ class ReceiverStatsTest : public ::testing::Test { } ~ReceiverStatsTest() override {} - uint32 ExpectedJitter(uint32 const_interval, int num_packets) { + uint32_t ExpectedJitter(uint32_t const_interval, int num_packets) { float jitter = 0; // Assume timestamps have a constant kStdTimeIncrementMs interval. float float_interval = @@ -36,7 +36,7 @@ class ReceiverStatsTest : public ::testing::Test { for (int i = 0; i < num_packets; ++i) { jitter += (float_interval - jitter) / 16; } - return static_cast<uint32>(jitter + 0.5f); + return static_cast<uint32_t>(jitter + 0.5f); } ReceiverStats stats_; @@ -71,7 +71,7 @@ TEST_F(ReceiverStatsTest, LossCount) { EXPECT_EQ(63u, s.fraction_lost); EXPECT_EQ(74u, s.cumulative_lost); // Build extended sequence number. - const uint32 extended_seq_num = rtp_header_.sequence_number - 1; + const uint32_t extended_seq_num = rtp_header_.sequence_number - 1; EXPECT_EQ(extended_seq_num, s.extended_high_sequence_number); } @@ -89,12 +89,12 @@ TEST_F(ReceiverStatsTest, NoLossWrap) { EXPECT_EQ(0u, s.fraction_lost); EXPECT_EQ(0u, s.cumulative_lost); // Build extended sequence number (one wrap cycle). - const uint32 extended_seq_num = (1 << 16) + rtp_header_.sequence_number - 1; + const uint32_t extended_seq_num = (1 << 16) + rtp_header_.sequence_number - 1; EXPECT_EQ(extended_seq_num, s.extended_high_sequence_number); } TEST_F(ReceiverStatsTest, LossCountWrap) { - const uint32 kStartSequenceNumber = 65500; + const uint32_t kStartSequenceNumber = 65500; rtp_header_.sequence_number = kStartSequenceNumber; for (int i = 0; i < 300; ++i) { if (i % 4) @@ -109,7 +109,7 @@ TEST_F(ReceiverStatsTest, LossCountWrap) { EXPECT_EQ(63u, s.fraction_lost); EXPECT_EQ(74u, s.cumulative_lost); // Build extended sequence number (one wrap cycle). - const uint32 extended_seq_num = (1 << 16) + rtp_header_.sequence_number - 1; + const uint32_t extended_seq_num = (1 << 16) + rtp_header_.sequence_number - 1; EXPECT_EQ(extended_seq_num, s.extended_high_sequence_number); } @@ -124,7 +124,7 @@ TEST_F(ReceiverStatsTest, BasicJitter) { EXPECT_FALSE(s.fraction_lost); EXPECT_FALSE(s.cumulative_lost); // Build extended sequence number (one wrap cycle). - const uint32 extended_seq_num = rtp_header_.sequence_number - 1; + const uint32_t extended_seq_num = rtp_header_.sequence_number - 1; EXPECT_EQ(extended_seq_num, s.extended_high_sequence_number); EXPECT_EQ(ExpectedJitter(kStdTimeIncrementMs, 300), s.jitter); } @@ -143,7 +143,7 @@ TEST_F(ReceiverStatsTest, NonTrivialJitter) { EXPECT_FALSE(s.fraction_lost); EXPECT_FALSE(s.cumulative_lost); // Build extended sequence number (one wrap cycle). - const uint32 extended_seq_num = rtp_header_.sequence_number - 1; + const uint32_t extended_seq_num = rtp_header_.sequence_number - 1; EXPECT_EQ(extended_seq_num, s.extended_high_sequence_number); EXPECT_EQ(ExpectedJitter(kStdTimeIncrementMs + kAdditionalIncrement, 300), s.jitter); diff --git a/media/cast/net/rtp/rtp_defines.h b/media/cast/net/rtp/rtp_defines.h index 2506190..719fdf4 100644 --- a/media/cast/net/rtp/rtp_defines.h +++ b/media/cast/net/rtp/rtp_defines.h @@ -5,47 +5,46 @@ #ifndef MEDIA_CAST_NET_RTP_RTP_DEFINES_H_ #define MEDIA_CAST_NET_RTP_RTP_DEFINES_H_ -#include "base/basictypes.h" #include "media/cast/net/rtcp/rtcp_defines.h" namespace media { namespace cast { -static const uint16 kRtpHeaderLength = 12; -static const uint16 kCastHeaderLength = 7; +static const uint16_t kRtpHeaderLength = 12; +static const uint16_t kCastHeaderLength = 7; // RTP Header -static const uint8 kRtpExtensionBitMask = 0x10; -static const uint8 kRtpMarkerBitMask = 0x80; -static const uint8 kRtpNumCsrcsMask = 0x0f; +static const uint8_t kRtpExtensionBitMask = 0x10; +static const uint8_t kRtpMarkerBitMask = 0x80; +static const uint8_t kRtpNumCsrcsMask = 0x0f; // Cast Header -static const uint8 kCastKeyFrameBitMask = 0x80; -static const uint8 kCastReferenceFrameIdBitMask = 0x40; -static const uint8 kCastExtensionCountmask = 0x3f; +static const uint8_t kCastKeyFrameBitMask = 0x80; +static const uint8_t kCastReferenceFrameIdBitMask = 0x40; +static const uint8_t kCastExtensionCountmask = 0x3f; // Cast RTP extensions. -static const uint8 kCastRtpExtensionAdaptiveLatency = 1; +static const uint8_t kCastRtpExtensionAdaptiveLatency = 1; struct RtpCastHeader { RtpCastHeader(); // Elements from RTP packet header. bool marker; - uint8 payload_type; - uint16 sequence_number; - uint32 rtp_timestamp; - uint32 sender_ssrc; - uint8 num_csrcs; + uint8_t payload_type; + uint16_t sequence_number; + uint32_t rtp_timestamp; + uint32_t sender_ssrc; + uint8_t num_csrcs; // Elements from Cast header (at beginning of RTP payload). bool is_key_frame; bool is_reference; - uint32 frame_id; - uint16 packet_id; - uint16 max_packet_id; - uint32 reference_frame_id; - uint16 new_playout_delay_ms; - uint8 num_extensions; + uint32_t frame_id; + uint16_t packet_id; + uint16_t max_packet_id; + uint32_t reference_frame_id; + uint16_t new_playout_delay_ms; + uint8_t num_extensions; }; class RtpPayloadFeedback { diff --git a/media/cast/net/rtp/rtp_packet_builder.cc b/media/cast/net/rtp/rtp_packet_builder.cc index 4501dbf..dbeeede 100644 --- a/media/cast/net/rtp/rtp_packet_builder.cc +++ b/media/cast/net/rtp/rtp_packet_builder.cc @@ -24,22 +24,25 @@ RtpPacketBuilder::RtpPacketBuilder() void RtpPacketBuilder::SetKeyFrame(bool is_key) { is_key_ = is_key; } -void RtpPacketBuilder::SetFrameIds(uint32 frame_id, uint32 reference_frame_id) { +void RtpPacketBuilder::SetFrameIds(uint32_t frame_id, + uint32_t reference_frame_id) { frame_id_ = frame_id; reference_frame_id_ = reference_frame_id; } -void RtpPacketBuilder::SetPacketId(uint16 packet_id) { packet_id_ = packet_id; } +void RtpPacketBuilder::SetPacketId(uint16_t packet_id) { + packet_id_ = packet_id; +} -void RtpPacketBuilder::SetMaxPacketId(uint16 max_packet_id) { +void RtpPacketBuilder::SetMaxPacketId(uint16_t max_packet_id) { max_packet_id_ = max_packet_id; } -void RtpPacketBuilder::SetTimestamp(uint32 timestamp) { +void RtpPacketBuilder::SetTimestamp(uint32_t timestamp) { timestamp_ = timestamp; } -void RtpPacketBuilder::SetSequenceNumber(uint16 sequence_number) { +void RtpPacketBuilder::SetSequenceNumber(uint16_t sequence_number) { sequence_number_ = sequence_number; } @@ -49,14 +52,16 @@ void RtpPacketBuilder::SetPayloadType(int payload_type) { payload_type_ = payload_type; } -void RtpPacketBuilder::SetSsrc(uint32 ssrc) { ssrc_ = ssrc; } +void RtpPacketBuilder::SetSsrc(uint32_t ssrc) { + ssrc_ = ssrc; +} -void RtpPacketBuilder::BuildHeader(uint8* data, uint32 data_length) { +void RtpPacketBuilder::BuildHeader(uint8_t* data, uint32_t data_length) { BuildCommonHeader(data, data_length); BuildCastHeader(data + kRtpHeaderLength, data_length - kRtpHeaderLength); } -void RtpPacketBuilder::BuildCastHeader(uint8* data, uint32 data_length) { +void RtpPacketBuilder::BuildCastHeader(uint8_t* data, uint32_t data_length) { // Build header. DCHECK_LE(kCastHeaderLength, data_length); // Set the first 7 bytes to 0. @@ -75,7 +80,7 @@ void RtpPacketBuilder::BuildCastHeader(uint8* data, uint32 data_length) { } } -void RtpPacketBuilder::BuildCommonHeader(uint8* data, uint32 data_length) { +void RtpPacketBuilder::BuildCommonHeader(uint8_t* data, uint32_t data_length) { DCHECK_LE(kRtpHeaderLength, data_length); base::BigEndianWriter big_endian_writer(reinterpret_cast<char*>(data), 96); big_endian_writer.WriteU8(0x80); diff --git a/media/cast/net/rtp/rtp_packet_builder.h b/media/cast/net/rtp/rtp_packet_builder.h index da8efc9..bfed1c3 100644 --- a/media/cast/net/rtp/rtp_packet_builder.h +++ b/media/cast/net/rtp/rtp_packet_builder.h @@ -18,30 +18,30 @@ class RtpPacketBuilder { public: RtpPacketBuilder(); void SetKeyFrame(bool is_key); - void SetFrameIds(uint32 frame_id, uint32 reference_frame_id); - void SetPacketId(uint16 packet_id); - void SetMaxPacketId(uint16 max_packet_id); - void SetTimestamp(uint32 timestamp); - void SetSequenceNumber(uint16 sequence_number); + void SetFrameIds(uint32_t frame_id, uint32_t reference_frame_id); + void SetPacketId(uint16_t packet_id); + void SetMaxPacketId(uint16_t max_packet_id); + void SetTimestamp(uint32_t timestamp); + void SetSequenceNumber(uint16_t sequence_number); void SetMarkerBit(bool marker); void SetPayloadType(int payload_type); - void SetSsrc(uint32 ssrc); - void BuildHeader(uint8* data, uint32 data_length); + void SetSsrc(uint32_t ssrc); + void BuildHeader(uint8_t* data, uint32_t data_length); private: bool is_key_; - uint32 frame_id_; - uint16 packet_id_; - uint16 max_packet_id_; - uint32 reference_frame_id_; - uint32 timestamp_; - uint16 sequence_number_; + uint32_t frame_id_; + uint16_t packet_id_; + uint16_t max_packet_id_; + uint32_t reference_frame_id_; + uint32_t timestamp_; + uint16_t sequence_number_; bool marker_; int payload_type_; - uint32 ssrc_; + uint32_t ssrc_; - void BuildCastHeader(uint8* data, uint32 data_length); - void BuildCommonHeader(uint8* data, uint32 data_length); + void BuildCastHeader(uint8_t* data, uint32_t data_length); + void BuildCommonHeader(uint8_t* data, uint32_t data_length); DISALLOW_COPY_AND_ASSIGN(RtpPacketBuilder); }; diff --git a/media/cast/net/rtp/rtp_packetizer.cc b/media/cast/net/rtp/rtp_packetizer.cc index 6eb3230..81bc6dd 100644 --- a/media/cast/net/rtp/rtp_packetizer.cc +++ b/media/cast/net/rtp/rtp_packetizer.cc @@ -38,14 +38,14 @@ RtpPacketizer::RtpPacketizer(PacedSender* const transport, RtpPacketizer::~RtpPacketizer() {} -uint16 RtpPacketizer::NextSequenceNumber() { +uint16_t RtpPacketizer::NextSequenceNumber() { ++sequence_number_; return sequence_number_ - 1; } void RtpPacketizer::SendFrameAsPackets(const EncodedFrame& frame) { - uint16 rtp_header_length = kRtpHeaderLength + kCastHeaderLength; - uint16 max_length = config_.max_payload_length - rtp_header_length - 1; + uint16_t rtp_header_length = kRtpHeaderLength + kCastHeaderLength; + uint16_t max_length = config_.max_payload_length - rtp_header_length - 1; rtp_timestamp_ = frame.rtp_timestamp; // Split the payload evenly (round number up). @@ -58,7 +58,7 @@ void RtpPacketizer::SendFrameAsPackets(const EncodedFrame& frame) { size_t remaining_size = frame.data.size(); std::string::const_iterator data_iter = frame.data.begin(); - uint8 num_extensions = 0; + uint8_t num_extensions = 0; if (frame.new_playout_delay_ms) num_extensions++; DCHECK_LE(num_extensions, kCastExtensionCountmask); @@ -76,29 +76,28 @@ void RtpPacketizer::SendFrameAsPackets(const EncodedFrame& frame) { // Build Cast header. // TODO(miu): Should we always set the ref frame bit and the ref_frame_id? DCHECK_NE(frame.dependency, EncodedFrame::UNKNOWN_DEPENDENCY); - uint8 byte0 = kCastReferenceFrameIdBitMask; + uint8_t byte0 = kCastReferenceFrameIdBitMask; if (frame.dependency == EncodedFrame::KEY) byte0 |= kCastKeyFrameBitMask; // Extensions only go on the first packet of the frame if (packet_id_ == 0) byte0 |= num_extensions; packet->data.push_back(byte0); - packet->data.push_back(static_cast<uint8>(frame.frame_id)); + packet->data.push_back(static_cast<uint8_t>(frame.frame_id)); size_t start_size = packet->data.size(); packet->data.resize(start_size + 4); base::BigEndianWriter big_endian_writer( reinterpret_cast<char*>(&(packet->data[start_size])), 4); big_endian_writer.WriteU16(packet_id_); - big_endian_writer.WriteU16(static_cast<uint16>(num_packets - 1)); - packet->data.push_back(static_cast<uint8>(frame.referenced_frame_id)); + big_endian_writer.WriteU16(static_cast<uint16_t>(num_packets - 1)); + packet->data.push_back(static_cast<uint8_t>(frame.referenced_frame_id)); // Add extension details only on the first packet of the frame if (packet_id_ == 0 && frame.new_playout_delay_ms) { packet->data.push_back(kCastRtpExtensionAdaptiveLatency << 2); packet->data.push_back(2); // 2 bytes packet->data.push_back( - static_cast<uint8>(frame.new_playout_delay_ms >> 8)); - packet->data.push_back( - static_cast<uint8>(frame.new_playout_delay_ms)); + static_cast<uint8_t>(frame.new_playout_delay_ms >> 8)); + packet->data.push_back(static_cast<uint8_t>(frame.new_playout_delay_ms)); } // Copy payload data. @@ -128,9 +127,9 @@ void RtpPacketizer::SendFrameAsPackets(const EncodedFrame& frame) { void RtpPacketizer::BuildCommonRTPheader(Packet* packet, bool marker_bit, - uint32 time_stamp) { + uint32_t time_stamp) { packet->push_back(0x80); - packet->push_back(static_cast<uint8>(config_.payload_type) | + packet->push_back(static_cast<uint8_t>(config_.payload_type) | (marker_bit ? kRtpMarkerBitMask : 0)); size_t start_size = packet->size(); packet->resize(start_size + 10); diff --git a/media/cast/net/rtp/rtp_packetizer.h b/media/cast/net/rtp/rtp_packetizer.h index 034a74a..e69a80c 100644 --- a/media/cast/net/rtp/rtp_packetizer.h +++ b/media/cast/net/rtp/rtp_packetizer.h @@ -27,8 +27,8 @@ struct RtpPacketizerConfig { // General. int payload_type; - uint16 max_payload_length; - uint16 sequence_number; + uint16_t max_payload_length; + uint16_t sequence_number; // SSRC. unsigned int ssrc; @@ -48,21 +48,23 @@ class RtpPacketizer { // Return the next sequence number, and increment by one. Enables unique // incremental sequence numbers for every packet (including retransmissions). - uint16 NextSequenceNumber(); + uint16_t NextSequenceNumber(); size_t send_packet_count() const { return send_packet_count_; } size_t send_octet_count() const { return send_octet_count_; } private: - void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp); + void BuildCommonRTPheader(Packet* packet, + bool marker_bit, + uint32_t time_stamp); RtpPacketizerConfig config_; PacedSender* const transport_; // Not owned by this class. PacketStorage* packet_storage_; - uint16 sequence_number_; - uint32 rtp_timestamp_; - uint16 packet_id_; + uint16_t sequence_number_; + uint32_t rtp_timestamp_; + uint16_t packet_id_; size_t send_packet_count_; size_t send_octet_count_; diff --git a/media/cast/net/rtp/rtp_packetizer_unittest.cc b/media/cast/net/rtp/rtp_packetizer_unittest.cc index 07eb419..29afb09 100644 --- a/media/cast/net/rtp/rtp_packetizer_unittest.cc +++ b/media/cast/net/rtp/rtp_packetizer_unittest.cc @@ -19,8 +19,8 @@ namespace cast { namespace { static const int kPayload = 127; -static const uint32 kTimestampMs = 10; -static const uint16 kSeqNum = 33; +static const uint32_t kTimestampMs = 10; +static const uint16_t kSeqNum = 33; static const int kMaxPacketLength = 1500; static const int kSsrc = 0x12345; static const unsigned int kFrameSize = 5000; @@ -67,7 +67,7 @@ class TestRtpPacketTransport : public PacketSender { ++packets_sent_; RtpParser parser(kSsrc, kPayload); RtpCastHeader rtp_header; - const uint8* payload_data; + const uint8_t* payload_data; size_t payload_size; parser.ParsePacket(&packet->data[0], packet->data.size(), &rtp_header, &payload_data, &payload_size); @@ -77,7 +77,7 @@ class TestRtpPacketTransport : public PacketSender { return true; } - int64 GetBytesSent() final { return 0; } + int64_t GetBytesSent() final { return 0; } size_t number_of_packets_received() const { return packets_sent_; } @@ -85,19 +85,19 @@ class TestRtpPacketTransport : public PacketSender { expected_number_of_packets_ = expected_number_of_packets; } - void set_rtp_timestamp(uint32 rtp_timestamp) { + void set_rtp_timestamp(uint32_t rtp_timestamp) { expected_rtp_timestamp_ = rtp_timestamp; } RtpPacketizerConfig config_; - uint32 sequence_number_; + uint32_t sequence_number_; size_t packets_sent_; size_t number_of_packets_; size_t expected_number_of_packets_; // Assuming packets arrive in sequence. int expected_packet_id_; - uint32 expected_frame_id_; - uint32 expected_rtp_timestamp_; + uint32_t expected_frame_id_; + uint32_t expected_rtp_timestamp_; private: DISALLOW_COPY_AND_ASSIGN(TestRtpPacketTransport); diff --git a/media/cast/net/rtp/rtp_parser.cc b/media/cast/net/rtp/rtp_parser.cc index a59aa99..9dc0243 100644 --- a/media/cast/net/rtp/rtp_parser.cc +++ b/media/cast/net/rtp/rtp_parser.cc @@ -13,25 +13,26 @@ namespace media { namespace cast { // static -bool RtpParser::ParseSsrc(const uint8* packet, +bool RtpParser::ParseSsrc(const uint8_t* packet, size_t length, - uint32* ssrc) { + uint32_t* ssrc) { base::BigEndianReader big_endian_reader( reinterpret_cast<const char*>(packet), length); return big_endian_reader.Skip(8) && big_endian_reader.ReadU32(ssrc); } -RtpParser::RtpParser(uint32 expected_sender_ssrc, uint8 expected_payload_type) +RtpParser::RtpParser(uint32_t expected_sender_ssrc, + uint8_t expected_payload_type) : expected_sender_ssrc_(expected_sender_ssrc), expected_payload_type_(expected_payload_type), frame_id_wrap_helper_(kFirstFrameId - 1) {} RtpParser::~RtpParser() {} -bool RtpParser::ParsePacket(const uint8* packet, +bool RtpParser::ParsePacket(const uint8_t* packet, size_t length, RtpCastHeader* header, - const uint8** payload_data, + const uint8_t** payload_data, size_t* payload_size) { DCHECK(packet); DCHECK(header); @@ -46,10 +47,10 @@ bool RtpParser::ParsePacket(const uint8* packet, // Parse the RTP header. See // http://en.wikipedia.org/wiki/Real-time_Transport_Protocol for an // explanation of the standard RTP packet header. - uint8 bits; + uint8_t bits; if (!reader.ReadU8(&bits)) return false; - const uint8 version = bits >> 6; + const uint8_t version = bits >> 6; if (version != 2) return false; header->num_csrcs = bits & kRtpNumCsrcsMask; @@ -76,7 +77,7 @@ bool RtpParser::ParsePacket(const uint8* packet, return false; header->is_key_frame = !!(bits & kCastKeyFrameBitMask); header->is_reference = !!(bits & kCastReferenceFrameIdBitMask); - uint8 truncated_frame_id; + uint8_t truncated_frame_id; if (!reader.ReadU8(&truncated_frame_id) || !reader.ReadU16(&header->packet_id) || !reader.ReadU16(&header->max_packet_id)) { @@ -85,7 +86,7 @@ bool RtpParser::ParsePacket(const uint8* packet, // Sanity-check: Do the packet ID values make sense w.r.t. each other? if (header->max_packet_id < header->packet_id) return false; - uint8 truncated_reference_frame_id; + uint8_t truncated_reference_frame_id; if (!header->is_reference) { // By default, a key frame only references itself; and non-key frames // reference their direct predecessor. @@ -98,7 +99,7 @@ bool RtpParser::ParsePacket(const uint8* packet, header->num_extensions = bits & kCastExtensionCountmask; for (int i = 0; i < header->num_extensions; i++) { - uint16 type_and_size; + uint16_t type_and_size; if (!reader.ReadU16(&type_and_size)) return false; base::StringPiece tmp; @@ -128,7 +129,7 @@ bool RtpParser::ParsePacket(const uint8* packet, header->reference_frame_id |= truncated_reference_frame_id; // All remaining data in the packet is the payload. - *payload_data = reinterpret_cast<const uint8*>(reader.ptr()); + *payload_data = reinterpret_cast<const uint8_t*>(reader.ptr()); *payload_size = reader.remaining(); return true; diff --git a/media/cast/net/rtp/rtp_parser.h b/media/cast/net/rtp/rtp_parser.h index d9e6ab9..e3f39012 100644 --- a/media/cast/net/rtp/rtp_parser.h +++ b/media/cast/net/rtp/rtp_parser.h @@ -16,7 +16,7 @@ namespace cast { // throughout the media/cast library. class RtpParser { public: - RtpParser(uint32 expected_sender_ssrc, uint8 expected_payload_type); + RtpParser(uint32_t expected_sender_ssrc, uint8_t expected_payload_type); virtual ~RtpParser(); @@ -27,17 +27,17 @@ class RtpParser { // payload data. Returns false if the data appears to be invalid, is not from // the expected sender (as identified by the SSRC field), or is not the // expected payload type. - bool ParsePacket(const uint8* packet, + bool ParsePacket(const uint8_t* packet, size_t length, RtpCastHeader* rtp_header, - const uint8** payload_data, + const uint8_t** payload_data, size_t* payload_size); - static bool ParseSsrc(const uint8* packet, size_t length, uint32* ssrc); + static bool ParseSsrc(const uint8_t* packet, size_t length, uint32_t* ssrc); private: - const uint32 expected_sender_ssrc_; - const uint8 expected_payload_type_; + const uint32_t expected_sender_ssrc_; + const uint8_t expected_payload_type_; FrameIdWrapHelper frame_id_wrap_helper_; DISALLOW_COPY_AND_ASSIGN(RtpParser); diff --git a/media/cast/net/rtp/rtp_parser_unittest.cc b/media/cast/net/rtp/rtp_parser_unittest.cc index 97d0922..4109edf 100644 --- a/media/cast/net/rtp/rtp_parser_unittest.cc +++ b/media/cast/net/rtp/rtp_parser_unittest.cc @@ -14,10 +14,10 @@ namespace cast { static const size_t kPacketLength = 1500; static const int kTestPayloadType = 127; -static const uint32 kTestSsrc = 1234; -static const uint32 kTestTimestamp = 111111; -static const uint16 kTestSeqNum = 4321; -static const uint8 kRefFrameId = 17; +static const uint32_t kTestSsrc = 1234; +static const uint32_t kTestTimestamp = 111111; +static const uint16_t kTestSeqNum = 4321; +static const uint8_t kRefFrameId = 17; class RtpParserTest : public ::testing::Test { protected: @@ -38,7 +38,7 @@ class RtpParserTest : public ::testing::Test { void ExpectParsesPacket() { RtpCastHeader parsed_header; - const uint8* payload = NULL; + const uint8_t* payload = NULL; size_t payload_size = static_cast<size_t>(-1); EXPECT_TRUE(rtp_parser_.ParsePacket( packet_, kPacketLength, &parsed_header, &payload, &payload_size)); @@ -62,14 +62,14 @@ class RtpParserTest : public ::testing::Test { void ExpectDoesNotParsePacket() { RtpCastHeader parsed_header; - const uint8* payload = NULL; + const uint8_t* payload = NULL; size_t payload_size = static_cast<size_t>(-1); EXPECT_FALSE(rtp_parser_.ParsePacket( packet_, kPacketLength, &parsed_header, &payload, &payload_size)); } RtpPacketBuilder packet_builder_; - uint8 packet_[kPacketLength]; + uint8_t packet_[kPacketLength]; RtpParser rtp_parser_; RtpCastHeader cast_header_; }; @@ -164,10 +164,10 @@ TEST_F(RtpParserTest, ParseCastPacketWithSpecificFrameReference) { } TEST_F(RtpParserTest, ParseExpandingFrameIdTo32Bits) { - const uint32 kMaxFrameId = 1000; + const uint32_t kMaxFrameId = 1000; packet_builder_.SetKeyFrame(true); cast_header_.is_key_frame = true; - for (uint32 frame_id = 0; frame_id <= kMaxFrameId; ++frame_id) { + for (uint32_t frame_id = 0; frame_id <= kMaxFrameId; ++frame_id) { packet_builder_.SetFrameIds(frame_id, frame_id); packet_builder_.BuildHeader(packet_, kPacketLength); cast_header_.frame_id = frame_id; @@ -177,13 +177,13 @@ TEST_F(RtpParserTest, ParseExpandingFrameIdTo32Bits) { } TEST_F(RtpParserTest, ParseExpandingReferenceFrameIdTo32Bits) { - const uint32 kMaxFrameId = 1000; - const uint32 kMaxBackReferenceOffset = 10; + const uint32_t kMaxFrameId = 1000; + const uint32_t kMaxBackReferenceOffset = 10; packet_builder_.SetKeyFrame(false); cast_header_.is_key_frame = false; - for (uint32 frame_id = kMaxBackReferenceOffset; - frame_id <= kMaxFrameId; ++frame_id) { - const uint32 reference_frame_id = + for (uint32_t frame_id = kMaxBackReferenceOffset; frame_id <= kMaxFrameId; + ++frame_id) { + const uint32_t reference_frame_id = frame_id - base::RandInt(1, kMaxBackReferenceOffset); packet_builder_.SetFrameIds(frame_id, reference_frame_id); packet_builder_.BuildHeader(packet_, kPacketLength); diff --git a/media/cast/net/rtp/rtp_sender.cc b/media/cast/net/rtp/rtp_sender.cc index bd822e8..22ee314 100644 --- a/media/cast/net/rtp/rtp_sender.cc +++ b/media/cast/net/rtp/rtp_sender.cc @@ -60,7 +60,7 @@ void RtpSender::ResendPackets( it != missing_frames_and_packets.end(); ++it) { SendPacketVector packets_to_resend; - uint8 frame_id = it->first; + uint8_t frame_id = it->first; // Set of packets that the receiver wants us to re-send. // If empty, we need to re-send all packets for this frame. const PacketIdSet& missing_packet_set = it->second; @@ -77,7 +77,7 @@ void RtpSender::ResendPackets( for (SendPacketVector::const_iterator it = stored_packets->begin(); it != stored_packets->end(); ++it) { const PacketKey& packet_key = it->first; - const uint16 packet_id = packet_key.packet_id; + const uint16_t packet_id = packet_key.packet_id; // Should we resend the packet? bool resend = resend_all; @@ -110,8 +110,8 @@ void RtpSender::ResendPackets( } } -void RtpSender::CancelSendingFrames(const std::vector<uint32>& frame_ids) { - for (std::vector<uint32>::const_iterator i = frame_ids.begin(); +void RtpSender::CancelSendingFrames(const std::vector<uint32_t>& frame_ids) { + for (std::vector<uint32_t>::const_iterator i = frame_ids.begin(); i != frame_ids.end(); ++i) { const SendPacketVector* stored_packets = storage_.GetFrame8(*i & 0xFF); if (!stored_packets) @@ -124,7 +124,7 @@ void RtpSender::CancelSendingFrames(const std::vector<uint32>& frame_ids) { } } -void RtpSender::ResendFrameForKickstart(uint32 frame_id, +void RtpSender::ResendFrameForKickstart(uint32_t frame_id, base::TimeDelta dedupe_window) { // Send the last packet of the encoded frame to kick start // retransmission. This gives enough information to the receiver what @@ -147,11 +147,11 @@ void RtpSender::UpdateSequenceNumber(Packet* packet) { static const int kByteOffsetToSequenceNumber = 2; base::BigEndianWriter big_endian_writer( reinterpret_cast<char*>((&packet->front()) + kByteOffsetToSequenceNumber), - sizeof(uint16)); + sizeof(uint16_t)); big_endian_writer.WriteU16(packetizer_->NextSequenceNumber()); } -int64 RtpSender::GetLastByteSentForFrame(uint32 frame_id) { +int64_t RtpSender::GetLastByteSentForFrame(uint32_t frame_id) { const SendPacketVector* stored_packets = storage_.GetFrame8(frame_id & 0xFF); if (!stored_packets) return 0; diff --git a/media/cast/net/rtp/rtp_sender.h b/media/cast/net/rtp/rtp_sender.h index 32083d0..68cb601 100644 --- a/media/cast/net/rtp/rtp_sender.h +++ b/media/cast/net/rtp/rtp_sender.h @@ -49,11 +49,12 @@ class RtpSender { // frame was just sent. // Returns 0 if the frame cannot be found or the frame was only sent // partially. - int64 GetLastByteSentForFrame(uint32 frame_id); + int64_t GetLastByteSentForFrame(uint32_t frame_id); - void CancelSendingFrames(const std::vector<uint32>& frame_ids); + void CancelSendingFrames(const std::vector<uint32_t>& frame_ids); - void ResendFrameForKickstart(uint32 frame_id, base::TimeDelta dedupe_window); + void ResendFrameForKickstart(uint32_t frame_id, + base::TimeDelta dedupe_window); size_t send_packet_count() const { return packetizer_ ? packetizer_->send_packet_count() : 0; @@ -61,7 +62,7 @@ class RtpSender { size_t send_octet_count() const { return packetizer_ ? packetizer_->send_octet_count() : 0; } - uint32 ssrc() const { return config_.ssrc; } + uint32_t ssrc() const { return config_.ssrc; } private: void UpdateSequenceNumber(Packet* packet); diff --git a/media/cast/net/udp_transport.cc b/media/cast/net/udp_transport.cc index 0d77a69..89d2927 100644 --- a/media/cast/net/udp_transport.cc +++ b/media/cast/net/udp_transport.cc @@ -40,7 +40,7 @@ UdpTransport::UdpTransport( const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, const net::IPEndPoint& local_end_point, const net::IPEndPoint& remote_end_point, - int32 send_buffer_size, + int32_t send_buffer_size, const CastTransportStatusCallback& status_callback) : io_thread_proxy_(io_thread_proxy), local_addr_(local_end_point), @@ -257,7 +257,7 @@ bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) { return true; } -int64 UdpTransport::GetBytesSent() { +int64_t UdpTransport::GetBytesSent() { return bytes_sent_; } diff --git a/media/cast/net/udp_transport.h b/media/cast/net/udp_transport.h index c845c5a..a942236 100644 --- a/media/cast/net/udp_transport.h +++ b/media/cast/net/udp_transport.h @@ -40,7 +40,7 @@ class UdpTransport : public PacketSender { const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_proxy, const net::IPEndPoint& local_end_point, const net::IPEndPoint& remote_end_point, - int32 send_buffer_size, + int32_t send_buffer_size, const CastTransportStatusCallback& status_callback); ~UdpTransport() final; @@ -59,7 +59,7 @@ class UdpTransport : public PacketSender { // PacketSender implementations. bool SendPacket(PacketRef packet, const base::Closure& cb) final; - int64 GetBytesSent() final; + int64_t GetBytesSent() final; private: // Requests and processes packets from |udp_socket_|. This method is called @@ -88,7 +88,7 @@ class UdpTransport : public PacketSender { scoped_refptr<net::WrappedIOBuffer> recv_buf_; net::IPEndPoint recv_addr_; PacketReceiverCallbackWithStatus packet_receiver_; - int32 send_buffer_size_; + int32_t send_buffer_size_; const CastTransportStatusCallback status_callback_; int bytes_sent_; |