diff options
Diffstat (limited to 'media/cast')
131 files changed, 1099 insertions, 1132 deletions
diff --git a/media/cast/cast_config.h b/media/cast/cast_config.h index 4ebef67..091ee25 100644 --- a/media/cast/cast_config.h +++ b/media/cast/cast_config.h @@ -7,7 +7,6 @@ #include <string> -#include "base/basictypes.h" #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/shared_memory.h" @@ -60,10 +59,10 @@ struct AudioSenderConfig { ~AudioSenderConfig(); // Identifier referring to the sender, used by the receiver. - uint32 ssrc; + uint32_t ssrc; // The receiver's SSRC identifier. - uint32 receiver_ssrc; + uint32_t receiver_ssrc; // The total amount of time between a frame's capture/recording on the sender // and its playback on the receiver (i.e., shown to a user). This should be @@ -98,10 +97,10 @@ struct VideoSenderConfig { ~VideoSenderConfig(); // Identifier referring to the sender, used by the receiver. - uint32 ssrc; + uint32_t ssrc; // The receiver's SSRC identifier. - uint32 receiver_ssrc; + uint32_t receiver_ssrc; // The total amount of time between a frame's capture/recording on the sender // and its playback on the receiver (i.e., shown to a user). This should be @@ -154,10 +153,10 @@ struct FrameReceiverConfig { ~FrameReceiverConfig(); // The receiver's SSRC identifier. - uint32 receiver_ssrc; + uint32_t receiver_ssrc; // The sender's SSRC identifier. - uint32 sender_ssrc; + uint32_t sender_ssrc; // The total amount of time between a frame's capture/recording on the sender // and its playback on the receiver (i.e., shown to a user). This is fixed as diff --git a/media/cast/cast_defines.h b/media/cast/cast_defines.h index 6860797..d839b59 100644 --- a/media/cast/cast_defines.h +++ b/media/cast/cast_defines.h @@ -13,37 +13,38 @@ namespace cast { // TODO(miu): All remaining functions in this file are to be replaced with // methods in well-defined data types. http://crbug.com/530839 -inline bool IsNewerFrameId(uint32 frame_id, uint32 prev_frame_id) { +inline bool IsNewerFrameId(uint32_t frame_id, uint32_t prev_frame_id) { return (frame_id != prev_frame_id) && - static_cast<uint32>(frame_id - prev_frame_id) < 0x80000000; + static_cast<uint32_t>(frame_id - prev_frame_id) < 0x80000000; } -inline bool IsNewerRtpTimestamp(uint32 timestamp, uint32 prev_timestamp) { +inline bool IsNewerRtpTimestamp(uint32_t timestamp, uint32_t prev_timestamp) { return (timestamp != prev_timestamp) && - static_cast<uint32>(timestamp - prev_timestamp) < 0x80000000; + static_cast<uint32_t>(timestamp - prev_timestamp) < 0x80000000; } -inline bool IsOlderFrameId(uint32 frame_id, uint32 prev_frame_id) { +inline bool IsOlderFrameId(uint32_t frame_id, uint32_t prev_frame_id) { return (frame_id == prev_frame_id) || IsNewerFrameId(prev_frame_id, frame_id); } -inline bool IsNewerPacketId(uint16 packet_id, uint16 prev_packet_id) { +inline bool IsNewerPacketId(uint16_t packet_id, uint16_t prev_packet_id) { return (packet_id != prev_packet_id) && - static_cast<uint16>(packet_id - prev_packet_id) < 0x8000; + static_cast<uint16_t>(packet_id - prev_packet_id) < 0x8000; } -inline bool IsNewerSequenceNumber(uint16 sequence_number, - uint16 prev_sequence_number) { +inline bool IsNewerSequenceNumber(uint16_t sequence_number, + uint16_t prev_sequence_number) { // Same function as IsNewerPacketId just different data and name. return IsNewerPacketId(sequence_number, prev_sequence_number); } -inline base::TimeDelta RtpDeltaToTimeDelta(int64 rtp_delta, int rtp_timebase) { +inline base::TimeDelta RtpDeltaToTimeDelta(int64_t rtp_delta, + int rtp_timebase) { DCHECK_GT(rtp_timebase, 0); return rtp_delta * base::TimeDelta::FromSeconds(1) / rtp_timebase; } -inline int64 TimeDeltaToRtpDelta(base::TimeDelta delta, int rtp_timebase) { +inline int64_t TimeDeltaToRtpDelta(base::TimeDelta delta, int rtp_timebase) { DCHECK_GT(rtp_timebase, 0); return delta * rtp_timebase / base::TimeDelta::FromSeconds(1); } diff --git a/media/cast/cast_environment.h b/media/cast/cast_environment.h index 9b29d4a..39c556b 100644 --- a/media/cast/cast_environment.h +++ b/media/cast/cast_environment.h @@ -5,7 +5,6 @@ #ifndef MEDIA_CAST_CAST_ENVIRONMENT_H_ #define MEDIA_CAST_CAST_ENVIRONMENT_H_ -#include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" #include "base/single_thread_task_runner.h" diff --git a/media/cast/cast_receiver.h b/media/cast/cast_receiver.h index a2668c7..2b827d7 100644 --- a/media/cast/cast_receiver.h +++ b/media/cast/cast_receiver.h @@ -8,7 +8,6 @@ #ifndef MEDIA_CAST_CAST_RECEIVER_H_ #define MEDIA_CAST_CAST_RECEIVER_H_ -#include "base/basictypes.h" #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/media/cast/cast_sender.h b/media/cast/cast_sender.h index 99d3c86..c35664e 100644 --- a/media/cast/cast_sender.h +++ b/media/cast/cast_sender.h @@ -10,7 +10,6 @@ #ifndef MEDIA_CAST_CAST_SENDER_H_ #define MEDIA_CAST_CAST_SENDER_H_ -#include "base/basictypes.h" #include "base/callback.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" diff --git a/media/cast/common/clock_drift_smoother.cc b/media/cast/common/clock_drift_smoother.cc index df3ffdb..01b7d06a 100644 --- a/media/cast/common/clock_drift_smoother.cc +++ b/media/cast/common/clock_drift_smoother.cc @@ -19,8 +19,8 @@ ClockDriftSmoother::~ClockDriftSmoother() {} base::TimeDelta ClockDriftSmoother::Current() const { DCHECK(!last_update_time_.is_null()); - return base::TimeDelta::FromMicroseconds( - static_cast<int64>(estimate_us_ + 0.5)); // Round to nearest microsecond. + return base::TimeDelta::FromMicroseconds(static_cast<int64_t>( + estimate_us_ + 0.5)); // Round to nearest microsecond. } void ClockDriftSmoother::Reset(base::TimeTicks now, diff --git a/media/cast/common/transport_encryption_handler.cc b/media/cast/common/transport_encryption_handler.cc index 360e40c..b0b2f96 100644 --- a/media/cast/common/transport_encryption_handler.cc +++ b/media/cast/common/transport_encryption_handler.cc @@ -15,7 +15,7 @@ namespace { const size_t kAesBlockSize = 16; const size_t kAesKeySize = 16; -std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) { +std::string GetAesNonce(uint32_t frame_id, const std::string& iv_mask) { std::string aes_nonce(kAesBlockSize, 0); // Serializing frame_id in big-endian order (aes_nonce[8] is the most @@ -61,7 +61,7 @@ bool TransportEncryptionHandler::Initialize(const std::string& aes_key, return true; } -bool TransportEncryptionHandler::Encrypt(uint32 frame_id, +bool TransportEncryptionHandler::Encrypt(uint32_t frame_id, const base::StringPiece& data, std::string* encrypted_data) { if (!is_activated_) @@ -77,7 +77,7 @@ bool TransportEncryptionHandler::Encrypt(uint32 frame_id, return true; } -bool TransportEncryptionHandler::Decrypt(uint32 frame_id, +bool TransportEncryptionHandler::Decrypt(uint32_t frame_id, const base::StringPiece& ciphertext, std::string* plaintext) { if (!is_activated_) { diff --git a/media/cast/common/transport_encryption_handler.h b/media/cast/common/transport_encryption_handler.h index d71dc49..d89a1b87 100644 --- a/media/cast/common/transport_encryption_handler.h +++ b/media/cast/common/transport_encryption_handler.h @@ -8,7 +8,6 @@ // Helper class to handle encryption for the Cast Transport library. #include <string> -#include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/strings/string_piece.h" #include "base/threading/non_thread_safe.h" @@ -28,11 +27,11 @@ class TransportEncryptionHandler : public base::NonThreadSafe { bool Initialize(const std::string& aes_key, const std::string& aes_iv_mask); - bool Encrypt(uint32 frame_id, + bool Encrypt(uint32_t frame_id, const base::StringPiece& data, std::string* encrypted_data); - bool Decrypt(uint32 frame_id, + bool Decrypt(uint32_t frame_id, const base::StringPiece& ciphertext, std::string* plaintext); diff --git a/media/cast/logging/encoding_event_subscriber.cc b/media/cast/logging/encoding_event_subscriber.cc index 82ec06f..a393c22 100644 --- a/media/cast/logging/encoding_event_subscriber.cc +++ b/media/cast/logging/encoding_event_subscriber.cc @@ -103,12 +103,13 @@ void EncodingEventSubscriber::OnReceiveFrameEvent( } else if (frame_event.type == FRAME_ENCODED) { event_proto->set_encoded_frame_size(frame_event.size); if (frame_event.encoder_cpu_utilization >= 0.0) { - event_proto->set_encoder_cpu_percent_utilized(base::saturated_cast<int32>( + event_proto->set_encoder_cpu_percent_utilized( + base::saturated_cast<int32_t>( frame_event.encoder_cpu_utilization * 100.0 + 0.5)); } if (frame_event.idealized_bitrate_utilization >= 0.0) { event_proto->set_idealized_bitrate_percent_utilized( - base::saturated_cast<int32>( + base::saturated_cast<int32_t>( frame_event.idealized_bitrate_utilization * 100.0 + 0.5)); } if (frame_event.media_type == VIDEO_EVENT) { diff --git a/media/cast/logging/encoding_event_subscriber_unittest.cc b/media/cast/logging/encoding_event_subscriber_unittest.cc index 123a8fe..cfcbb34 100644 --- a/media/cast/logging/encoding_event_subscriber_unittest.cc +++ b/media/cast/logging/encoding_event_subscriber_unittest.cc @@ -19,7 +19,7 @@ using media::cast::proto::LogMetadata; namespace { -int64 InMilliseconds(base::TimeTicks event_time) { +int64_t InMilliseconds(base::TimeTicks event_time) { return (event_time - base::TimeTicks()).InMilliseconds(); } diff --git a/media/cast/logging/log_deserializer.cc b/media/cast/logging/log_deserializer.cc index 5e5b189..09f74c7 100644 --- a/media/cast/logging/log_deserializer.cc +++ b/media/cast/logging/log_deserializer.cc @@ -72,7 +72,7 @@ bool PopulateDeserializedLog(base::BigEndianReader* reader, int num_frame_events = log->metadata.num_frame_events(); RtpTimestamp relative_rtp_timestamp = 0; - uint16 proto_size = 0; + uint16_t proto_size = 0; for (int i = 0; i < num_frame_events; i++) { if (!reader->ReadU16(&proto_size)) return false; @@ -146,7 +146,7 @@ bool DoDeserializeEvents(const char* data, base::BigEndianReader reader(data, data_bytes); LogMetadata metadata; - uint16 proto_size = 0; + uint16_t proto_size = 0; while (reader.remaining() > 0) { if (!reader.ReadU16(&proto_size)) return false; @@ -186,9 +186,9 @@ bool Uncompress(const char* data, int* uncompressed_bytes) { z_stream stream = {0}; - stream.next_in = reinterpret_cast<uint8*>(const_cast<char*>(data)); + stream.next_in = reinterpret_cast<uint8_t*>(const_cast<char*>(data)); stream.avail_in = data_bytes; - stream.next_out = reinterpret_cast<uint8*>(uncompressed); + stream.next_out = reinterpret_cast<uint8_t*>(uncompressed); stream.avail_out = max_uncompressed_bytes; bool success = false; diff --git a/media/cast/logging/log_serializer.cc b/media/cast/logging/log_serializer.cc index c5cb252..732be17 100644 --- a/media/cast/logging/log_serializer.cc +++ b/media/cast/logging/log_serializer.cc @@ -47,7 +47,7 @@ bool DoSerializeEvents(const LogMetadata& metadata, int proto_size = metadata.ByteSize(); DCHECK(proto_size <= kMaxSerializedProtoBytes); - if (!writer.WriteU16(static_cast<uint16>(proto_size))) + if (!writer.WriteU16(static_cast<uint16_t>(proto_size))) return false; if (!metadata.SerializeToArray(writer.ptr(), writer.remaining())) return false; @@ -73,7 +73,7 @@ bool DoSerializeEvents(const LogMetadata& metadata, DCHECK(proto_size <= kMaxSerializedProtoBytes); // Write size of the proto, then write the proto. - if (!writer.WriteU16(static_cast<uint16>(proto_size))) + if (!writer.WriteU16(static_cast<uint16_t>(proto_size))) return false; if (!frame_event.SerializeToArray(writer.ptr(), writer.remaining())) return false; @@ -97,7 +97,7 @@ bool DoSerializeEvents(const LogMetadata& metadata, DCHECK(proto_size <= kMaxSerializedProtoBytes); // Write size of the proto, then write the proto. - if (!writer.WriteU16(static_cast<uint16>(proto_size))) + if (!writer.WriteU16(static_cast<uint16_t>(proto_size))) return false; if (!packet_event.SerializeToArray(writer.ptr(), writer.remaining())) return false; @@ -124,9 +124,9 @@ bool Compress(char* uncompressed_buffer, Z_DEFAULT_STRATEGY); DCHECK_EQ(Z_OK, result); - stream.next_in = reinterpret_cast<uint8*>(uncompressed_buffer); + stream.next_in = reinterpret_cast<uint8_t*>(uncompressed_buffer); stream.avail_in = uncompressed_bytes; - stream.next_out = reinterpret_cast<uint8*>(output); + stream.next_out = reinterpret_cast<uint8_t*>(output); stream.avail_out = max_output_bytes; // Do a one-shot compression. This will return Z_STREAM_END only if |output| diff --git a/media/cast/logging/logging_defines.h b/media/cast/logging/logging_defines.h index dc29554..607ff0d 100644 --- a/media/cast/logging/logging_defines.h +++ b/media/cast/logging/logging_defines.h @@ -14,9 +14,9 @@ namespace media { namespace cast { -static const uint32 kFrameIdUnknown = 0xFFFFFFFF; +static const uint32_t kFrameIdUnknown = 0xFFFFFFFF; -typedef uint32 RtpTimestamp; +typedef uint32_t RtpTimestamp; enum CastLoggingEvent { UNKNOWN, @@ -53,7 +53,7 @@ struct FrameEvent { ~FrameEvent(); RtpTimestamp rtp_timestamp; - uint32 frame_id; + uint32_t frame_id; // Resolution of the frame. Only set for video FRAME_CAPTURE_END events. int width; @@ -93,9 +93,9 @@ struct PacketEvent { ~PacketEvent(); RtpTimestamp rtp_timestamp; - uint32 frame_id; - uint16 max_packet_id; - uint16 packet_id; + uint32_t frame_id; + uint16_t max_packet_id; + uint16_t packet_id; size_t size; // Time of event logged. diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.cc b/media/cast/logging/receiver_time_offset_estimator_impl.cc index d511654..db80fc4 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl.cc @@ -17,23 +17,23 @@ ReceiverTimeOffsetEstimatorImpl::BoundCalculator::BoundCalculator() ReceiverTimeOffsetEstimatorImpl::BoundCalculator::~BoundCalculator() {} void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::SetSent( - uint32 rtp, - uint32 packet_id, + uint32_t rtp, + uint32_t packet_id, bool audio, base::TimeTicks t) { - uint64 key = (static_cast<uint64>(rtp) << 32) | (packet_id << 1) | - static_cast<uint64>(audio); + uint64_t key = (static_cast<uint64_t>(rtp) << 32) | (packet_id << 1) | + static_cast<uint64_t>(audio); events_[key].first = t; CheckUpdate(key); } void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::SetReceived( - uint32 rtp, - uint16 packet_id, + uint32_t rtp, + uint16_t packet_id, bool audio, base::TimeTicks t) { - uint64 key = (static_cast<uint64>(rtp) << 32) | (packet_id << 1) | - static_cast<uint64>(audio); + uint64_t key = (static_cast<uint64_t>(rtp) << 32) | (packet_id << 1) | + static_cast<uint64_t>(audio); events_[key].second = t; CheckUpdate(key); } @@ -53,8 +53,8 @@ void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::UpdateBound( has_bound_ = true; } -void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::CheckUpdate( - uint64 key) { + void ReceiverTimeOffsetEstimatorImpl::BoundCalculator::CheckUpdate( + uint64_t key) { const TimeTickPair& ticks = events_[key]; if (!ticks.first.is_null() && !ticks.second.is_null()) { UpdateBound(ticks.first, ticks.second); diff --git a/media/cast/logging/receiver_time_offset_estimator_impl.h b/media/cast/logging/receiver_time_offset_estimator_impl.h index c2b6455..77d5275 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl.h +++ b/media/cast/logging/receiver_time_offset_estimator_impl.h @@ -58,26 +58,26 @@ class ReceiverTimeOffsetEstimatorImpl : public ReceiverTimeOffsetEstimator { class BoundCalculator { public: typedef std::pair<base::TimeTicks, base::TimeTicks> TimeTickPair; - typedef std::map<uint64, TimeTickPair> EventMap; + typedef std::map<uint64_t, TimeTickPair> EventMap; BoundCalculator(); ~BoundCalculator(); bool has_bound() const { return has_bound_; } base::TimeDelta bound() const { return bound_; } - void SetSent(uint32 rtp, - uint32 packet_id, + void SetSent(uint32_t rtp, + uint32_t packet_id, bool audio, base::TimeTicks t); - void SetReceived(uint32 rtp, - uint16 packet_id, + void SetReceived(uint32_t rtp, + uint16_t packet_id, bool audio, base::TimeTicks t); private: void UpdateBound(base::TimeTicks a, base::TimeTicks b); - void CheckUpdate(uint64 key); + void CheckUpdate(uint64_t key); private: EventMap events_; diff --git a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc index 2cbaafd..eab8ff3 100644 --- a/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc +++ b/media/cast/logging/receiver_time_offset_estimator_impl_unittest.cc @@ -50,7 +50,7 @@ class ReceiverTimeOffsetEstimatorImplTest : public ::testing::Test { // Event C occurred at sender time 60ms. // Then the bound after all 3 events have arrived is [130-60=70, 130-20=110]. TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { - int64 true_offset_ms = 100; + int64_t true_offset_ms = 100; receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); base::TimeDelta lower_bound; @@ -59,7 +59,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); RtpTimestamp rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t frame_id = 0; AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); @@ -122,8 +122,8 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); - int64 lower_bound_ms = lower_bound.InMilliseconds(); - int64 upper_bound_ms = upper_bound.InMilliseconds(); + int64_t lower_bound_ms = lower_bound.InMilliseconds(); + int64_t upper_bound_ms = upper_bound.InMilliseconds(); EXPECT_EQ(70, lower_bound_ms); EXPECT_EQ(110, upper_bound_ms); EXPECT_GE(true_offset_ms, lower_bound_ms); @@ -133,7 +133,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EstimateOffset) { // Same scenario as above, but event C arrives before event B. It doesn't mean // event C occurred before event B. TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { - int64 true_offset_ms = 100; + int64_t true_offset_ms = 100; receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); base::TimeDelta lower_bound; @@ -142,7 +142,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { EXPECT_FALSE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); RtpTimestamp rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t frame_id = 0; AdvanceClocks(base::TimeDelta::FromMilliseconds(20)); @@ -208,8 +208,8 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); - int64 lower_bound_ms = lower_bound.InMilliseconds(); - int64 upper_bound_ms = upper_bound.InMilliseconds(); + int64_t lower_bound_ms = lower_bound.InMilliseconds(); + int64_t upper_bound_ms = upper_bound.InMilliseconds(); EXPECT_EQ(70, lower_bound_ms); EXPECT_EQ(110, upper_bound_ms); EXPECT_GE(true_offset_ms, lower_bound_ms); @@ -217,7 +217,7 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, EventCArrivesBeforeEventB) { } TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { - int64 true_offset_ms = 100; + int64_t true_offset_ms = 100; receiver_clock_.Advance(base::TimeDelta::FromMilliseconds(true_offset_ms)); base::TimeDelta lower_bound; @@ -387,8 +387,8 @@ TEST_F(ReceiverTimeOffsetEstimatorImplTest, MultipleIterations) { cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); EXPECT_TRUE(estimator_.GetReceiverOffsetBounds(&lower_bound, &upper_bound)); - int64 lower_bound_ms = lower_bound.InMilliseconds(); - int64 upper_bound_ms = upper_bound.InMilliseconds(); + int64_t lower_bound_ms = lower_bound.InMilliseconds(); + int64_t upper_bound_ms = upper_bound.InMilliseconds(); EXPECT_GT(lower_bound_ms, 90); EXPECT_LE(lower_bound_ms, true_offset_ms); EXPECT_LT(upper_bound_ms, 150); diff --git a/media/cast/logging/serialize_deserialize_test.cc b/media/cast/logging/serialize_deserialize_test.cc index f1766d0..aa4ba1d 100644 --- a/media/cast/logging/serialize_deserialize_test.cc +++ b/media/cast/logging/serialize_deserialize_test.cc @@ -31,7 +31,7 @@ const media::cast::CastLoggingEvent kVideoPacketEvents[] = { const int kWidth[] = {1280, 1280, 1280, 1280, 1920, 1920, 1920, 1920}; const int kHeight[] = {720, 720, 720, 720, 1080, 1080, 1080, 1080}; const int kEncodedFrameSize[] = {512, 425, 399, 400, 237}; -const int64 kDelayMillis[] = {15, 4, 8, 42, 23, 16}; +const int64_t kDelayMillis[] = {15, 4, 8, 42, 23, 16}; const int kEncoderCPUPercentUtilized[] = {10, 9, 42, 3, 11, 12, 15, 7}; const int kIdealizedBitratePercentUtilized[] = {9, 9, 9, 15, 36, 38, 35, 40}; @@ -55,12 +55,12 @@ class SerializeDeserializeTest : public ::testing::Test { metadata_.set_num_frame_events(10); metadata_.set_num_packet_events(10); - int64 event_time_ms = 0; + int64_t event_time_ms = 0; // Insert frame and packet events with RTP timestamps 0, 90, 180, ... for (int i = 0; i < metadata_.num_frame_events(); i++) { linked_ptr<AggregatedFrameEvent> frame_event(new AggregatedFrameEvent); frame_event->set_relative_rtp_timestamp(i * 90); - for (uint32 event_index = 0; event_index < arraysize(kVideoFrameEvents); + for (uint32_t event_index = 0; event_index < arraysize(kVideoFrameEvents); ++event_index) { frame_event->add_event_type( ToProtoEventType(kVideoFrameEvents[event_index])); @@ -90,9 +90,8 @@ class SerializeDeserializeTest : public ::testing::Test { BasePacketEvent* base_event = packet_event->add_base_packet_event(); base_event->set_packet_id(packet_id); packet_id++; - for (uint32 event_index = 0; - event_index < arraysize(kVideoPacketEvents); - ++event_index) { + for (uint32_t event_index = 0; + event_index < arraysize(kVideoPacketEvents); ++event_index) { base_event->add_event_type( ToProtoEventType(kVideoPacketEvents[event_index])); base_event->add_event_timestamp_ms(event_time_ms); diff --git a/media/cast/logging/simple_event_subscriber.cc b/media/cast/logging/simple_event_subscriber.cc index cad9956..7146f64 100644 --- a/media/cast/logging/simple_event_subscriber.cc +++ b/media/cast/logging/simple_event_subscriber.cc @@ -4,7 +4,6 @@ #include "media/cast/logging/simple_event_subscriber.h" - #include "base/logging.h" namespace media { diff --git a/media/cast/logging/stats_event_subscriber.cc b/media/cast/logging/stats_event_subscriber.cc index a254e63..ff5e6f8 100644 --- a/media/cast/logging/stats_event_subscriber.cc +++ b/media/cast/logging/stats_event_subscriber.cc @@ -35,9 +35,9 @@ bool IsReceiverEvent(CastLoggingEvent event) { } // namespace -StatsEventSubscriber::SimpleHistogram::SimpleHistogram(int64 min, - int64 max, - int64 width) +StatsEventSubscriber::SimpleHistogram::SimpleHistogram(int64_t min, + int64_t max, + int64_t width) : min_(min), max_(max), width_(width), buckets_((max - min) / width + 2) { CHECK_GT(buckets_.size(), 2u); CHECK_EQ(0, (max_ - min_) % width_); @@ -46,7 +46,7 @@ StatsEventSubscriber::SimpleHistogram::SimpleHistogram(int64 min, StatsEventSubscriber::SimpleHistogram::~SimpleHistogram() { } -void StatsEventSubscriber::SimpleHistogram::Add(int64 sample) { +void StatsEventSubscriber::SimpleHistogram::Add(int64_t sample) { if (sample < min_) { ++buckets_.front(); } else if (sample >= max_) { @@ -78,8 +78,8 @@ StatsEventSubscriber::SimpleHistogram::GetHistogram() const { if (!buckets_[i]) continue; bucket.reset(new base::DictionaryValue); - int64 lower = min_ + (i - 1) * width_; - int64 upper = lower + width_ - 1; + int64_t lower = min_ + (i - 1) * width_; + int64_t upper = lower + width_ - 1; bucket->SetInteger( base::StringPrintf("%" PRId64 "-%" PRId64, lower, upper), buckets_[i]); @@ -596,7 +596,7 @@ void StatsEventSubscriber::UpdateLastResponseTime( void StatsEventSubscriber::ErasePacketSentTime( const PacketEvent& packet_event) { - std::pair<RtpTimestamp, uint16> key( + std::pair<RtpTimestamp, uint16_t> key( std::make_pair(packet_event.rtp_timestamp, packet_event.packet_id)); packet_sent_times_.erase(key); } @@ -622,7 +622,7 @@ void StatsEventSubscriber::RecordPacketRelatedLatencies( if (!GetReceiverOffset(&receiver_offset)) return; - std::pair<RtpTimestamp, uint16> key( + std::pair<RtpTimestamp, uint16_t> key( std::make_pair(packet_event.rtp_timestamp, packet_event.packet_id)); PacketEventTimeMap::iterator it = packet_sent_times_.find(key); if (it == packet_sent_times_.end()) { diff --git a/media/cast/logging/stats_event_subscriber.h b/media/cast/logging/stats_event_subscriber.h index 36d5110..c1a1e19 100644 --- a/media/cast/logging/stats_event_subscriber.h +++ b/media/cast/logging/stats_event_subscriber.h @@ -90,20 +90,20 @@ class StatsEventSubscriber : public RawEventSubscriber { // Overflow bucket: >= max // |min| must be less than |max|. // |width| must divide |max - min| evenly. - SimpleHistogram(int64 min, int64 max, int64 width); + SimpleHistogram(int64_t min, int64_t max, int64_t width); ~SimpleHistogram(); - void Add(int64 sample); + void Add(int64_t sample); void Reset(); scoped_ptr<base::ListValue> GetHistogram() const; private: - int64 min_; - int64 max_; - int64 width_; + int64_t min_; + int64_t max_; + int64_t width_; std::vector<int> buckets_; }; @@ -183,9 +183,8 @@ class StatsEventSubscriber : public RawEventSubscriber { typedef std::map<CastStat, double> StatsMap; typedef std::map<CastStat, linked_ptr<SimpleHistogram> > HistogramMap; typedef std::map<RtpTimestamp, FrameInfo> FrameInfoMap; - typedef std::map< - std::pair<RtpTimestamp, uint16>, - std::pair<base::TimeTicks, CastLoggingEvent> > + typedef std::map<std::pair<RtpTimestamp, uint16_t>, + std::pair<base::TimeTicks, CastLoggingEvent>> PacketEventTimeMap; typedef std::map<CastLoggingEvent, FrameLogStats> FrameStatsMap; typedef std::map<CastLoggingEvent, PacketLogStats> PacketStatsMap; diff --git a/media/cast/logging/stats_event_subscriber_unittest.cc b/media/cast/logging/stats_event_subscriber_unittest.cc index d649c89..0cec20f 100644 --- a/media/cast/logging/stats_event_subscriber_unittest.cc +++ b/media/cast/logging/stats_event_subscriber_unittest.cc @@ -67,8 +67,8 @@ class StatsEventSubscriberTest : public ::testing::Test { TEST_F(StatsEventSubscriberTest, CaptureEncode) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 0; + uint32_t frame_id = 0; int extra_frames = 50; // Only the first |extra_frames| frames logged will be taken into account // when computing dropped frames. @@ -147,8 +147,8 @@ TEST_F(StatsEventSubscriberTest, CaptureEncode) { TEST_F(StatsEventSubscriberTest, Encode) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 0; + uint32_t frame_id = 0; int num_frames = 10; base::TimeTicks start_time = sender_clock_->NowTicks(); AdvanceClocks(base::TimeDelta::FromMicroseconds(35678)); @@ -215,8 +215,8 @@ TEST_F(StatsEventSubscriberTest, Encode) { TEST_F(StatsEventSubscriberTest, Decode) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 0; + uint32_t frame_id = 0; int num_frames = 10; base::TimeTicks start_time = sender_clock_->NowTicks(); for (int i = 0; i < num_frames; i++) { @@ -251,8 +251,8 @@ TEST_F(StatsEventSubscriberTest, Decode) { TEST_F(StatsEventSubscriberTest, PlayoutDelay) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 0; + uint32_t frame_id = 0; int num_frames = 10; int late_frames = 0; for (int i = 0, delay_ms = -50; i < num_frames; i++, delay_ms += 10) { @@ -286,8 +286,8 @@ TEST_F(StatsEventSubscriberTest, PlayoutDelay) { TEST_F(StatsEventSubscriberTest, E2ELatency) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 0; + uint32_t frame_id = 0; int num_frames = 10; base::TimeDelta total_latency; for (int i = 0; i < num_frames; i++) { @@ -333,7 +333,7 @@ TEST_F(StatsEventSubscriberTest, E2ELatency) { TEST_F(StatsEventSubscriberTest, Packets) { Init(VIDEO_EVENT); - uint32 rtp_timestamp = 0; + uint32_t rtp_timestamp = 0; int num_packets = 10; int num_latency_recorded_packets = 0; base::TimeTicks start_time = sender_clock_->NowTicks(); @@ -557,8 +557,8 @@ TEST_F(StatsEventSubscriberTest, Histograms) { Init(VIDEO_EVENT); AdvanceClocks(base::TimeDelta::FromMilliseconds(123)); - uint32 rtp_timestamp = 123; - uint32 frame_id = 0; + uint32_t rtp_timestamp = 123; + uint32_t frame_id = 0; // 10 Frames with capture latency in the bucket of "10-14"ms. // 10 Frames with encode time in the bucket of "15-19"ms. 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_; diff --git a/media/cast/receiver/audio_decoder.cc b/media/cast/receiver/audio_decoder.cc index 1956ace..2f04d5f 100644 --- a/media/cast/receiver/audio_decoder.cc +++ b/media/cast/receiver/audio_decoder.cc @@ -45,7 +45,7 @@ class AudioDecoder::ImplBase "size of frame_id types do not match"); bool is_continuous = true; if (seen_first_frame_) { - const uint32 frames_ahead = encoded_frame->frame_id - last_frame_id_; + const uint32_t frames_ahead = encoded_frame->frame_id - last_frame_id_; if (frames_ahead > 1) { RecoverBecauseFramesWereDropped(); is_continuous = false; @@ -81,7 +81,7 @@ class AudioDecoder::ImplBase virtual void RecoverBecauseFramesWereDropped() {} // Note: Implementation of Decode() is allowed to mutate |data|. - virtual scoped_ptr<AudioBus> Decode(uint8* data, int len) = 0; + virtual scoped_ptr<AudioBus> Decode(uint8_t* data, int len) = 0; const scoped_refptr<CastEnvironment> cast_environment_; const Codec codec_; @@ -92,7 +92,7 @@ class AudioDecoder::ImplBase private: bool seen_first_frame_; - uint32 last_frame_id_; + uint32_t last_frame_id_; DISALLOW_COPY_AND_ASSIGN(ImplBase); }; @@ -106,10 +106,10 @@ class AudioDecoder::OpusImpl : public AudioDecoder::ImplBase { CODEC_AUDIO_OPUS, num_channels, sampling_rate), - decoder_memory_(new uint8[opus_decoder_get_size(num_channels)]), + decoder_memory_(new uint8_t[opus_decoder_get_size(num_channels)]), opus_decoder_(reinterpret_cast<OpusDecoder*>(decoder_memory_.get())), - max_samples_per_frame_( - kOpusMaxFrameDurationMillis * sampling_rate / 1000), + max_samples_per_frame_(kOpusMaxFrameDurationMillis * sampling_rate / + 1000), buffer_(new float[max_samples_per_frame_ * num_channels]) { if (ImplBase::operational_status_ != STATUS_UNINITIALIZED) return; @@ -132,7 +132,7 @@ class AudioDecoder::OpusImpl : public AudioDecoder::ImplBase { DCHECK_GE(result, 0); } - scoped_ptr<AudioBus> Decode(uint8* data, int len) final { + scoped_ptr<AudioBus> Decode(uint8_t* data, int len) final { scoped_ptr<AudioBus> audio_bus; const opus_int32 num_samples_decoded = opus_decode_float( opus_decoder_, data, len, buffer_.get(), max_samples_per_frame_, 0); @@ -153,7 +153,7 @@ class AudioDecoder::OpusImpl : public AudioDecoder::ImplBase { return audio_bus.Pass(); } - const scoped_ptr<uint8[]> decoder_memory_; + const scoped_ptr<uint8_t[]> decoder_memory_; OpusDecoder* const opus_decoder_; const int max_samples_per_frame_; const scoped_ptr<float[]> buffer_; @@ -183,21 +183,21 @@ class AudioDecoder::Pcm16Impl : public AudioDecoder::ImplBase { private: ~Pcm16Impl() final {} - scoped_ptr<AudioBus> Decode(uint8* data, int len) final { + scoped_ptr<AudioBus> Decode(uint8_t* data, int len) final { scoped_ptr<AudioBus> audio_bus; - const int num_samples = len / sizeof(int16) / num_channels_; + const int num_samples = len / sizeof(int16_t) / num_channels_; if (num_samples <= 0) return audio_bus.Pass(); - int16* const pcm_data = reinterpret_cast<int16*>(data); + int16_t* const pcm_data = reinterpret_cast<int16_t*>(data); #if defined(ARCH_CPU_LITTLE_ENDIAN) // Convert endianness. const int num_elements = num_samples * num_channels_; for (int i = 0; i < num_elements; ++i) - pcm_data[i] = static_cast<int16>(base::NetToHost16(pcm_data[i])); + pcm_data[i] = static_cast<int16_t>(base::NetToHost16(pcm_data[i])); #endif audio_bus = AudioBus::Create(num_channels_, num_samples).Pass(); - audio_bus->FromInterleaved(pcm_data, num_samples, sizeof(int16)); + audio_bus->FromInterleaved(pcm_data, num_samples, sizeof(int16_t)); return audio_bus.Pass(); } diff --git a/media/cast/receiver/audio_decoder_unittest.cc b/media/cast/receiver/audio_decoder_unittest.cc index 2e6a1dc..48dfab6 100644 --- a/media/cast/receiver/audio_decoder_unittest.cc +++ b/media/cast/receiver/audio_decoder_unittest.cc @@ -58,7 +58,7 @@ class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { if (GetParam().codec == CODEC_AUDIO_OPUS) { opus_encoder_memory_.reset( - new uint8[opus_encoder_get_size(GetParam().num_channels)]); + new uint8_t[opus_encoder_get_size(GetParam().num_channels)]); OpusEncoder* const opus_encoder = reinterpret_cast<OpusEncoder*>(opus_encoder_memory_.get()); CHECK_EQ(OPUS_OK, opus_encoder_init(opus_encoder, @@ -90,15 +90,15 @@ class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { // Encode |audio_bus| into |encoded_frame->data|. const int num_elements = audio_bus->channels() * audio_bus->frames(); - std::vector<int16> interleaved(num_elements); - audio_bus->ToInterleaved( - audio_bus->frames(), sizeof(int16), &interleaved.front()); + std::vector<int16_t> interleaved(num_elements); + audio_bus->ToInterleaved(audio_bus->frames(), sizeof(int16_t), + &interleaved.front()); if (GetParam().codec == CODEC_AUDIO_PCM16) { - encoded_frame->data.resize(num_elements * sizeof(int16)); - int16* const pcm_data = - reinterpret_cast<int16*>(encoded_frame->mutable_bytes()); + encoded_frame->data.resize(num_elements * sizeof(int16_t)); + int16_t* const pcm_data = + reinterpret_cast<int16_t*>(encoded_frame->mutable_bytes()); for (size_t i = 0; i < interleaved.size(); ++i) - pcm_data[i] = static_cast<int16>(base::HostToNet16(interleaved[i])); + pcm_data[i] = static_cast<int16_t>(base::HostToNet16(interleaved[i])); } else if (GetParam().codec == CODEC_AUDIO_OPUS) { OpusEncoder* const opus_encoder = reinterpret_cast<OpusEncoder*>(opus_encoder_memory_.get()); @@ -183,9 +183,9 @@ class AudioDecoderTest : public ::testing::TestWithParam<TestScenario> { const scoped_refptr<StandaloneCastEnvironment> cast_environment_; scoped_ptr<AudioDecoder> audio_decoder_; scoped_ptr<TestAudioBusFactory> audio_bus_factory_; - uint32 last_frame_id_; + uint32_t last_frame_id_; bool seen_a_decoded_frame_; - scoped_ptr<uint8[]> opus_encoder_memory_; + scoped_ptr<uint8_t[]> opus_encoder_memory_; base::Lock lock_; base::ConditionVariable cond_; diff --git a/media/cast/receiver/cast_receiver_impl.cc b/media/cast/receiver/cast_receiver_impl.cc index 83d8bf7..c9aeefb 100644 --- a/media/cast/receiver/cast_receiver_impl.cc +++ b/media/cast/receiver/cast_receiver_impl.cc @@ -46,7 +46,7 @@ void CastReceiverImpl::ReceivePacket(scoped_ptr<Packet> packet) { const uint8_t* const data = &packet->front(); const size_t length = packet->size(); - uint32 ssrc_of_sender; + uint32_t ssrc_of_sender; if (Rtcp::IsRtcpPacket(data, length)) { ssrc_of_sender = Rtcp::GetSsrcOfSender(data, length); } else if (!RtpParser::ParseSsrc(data, length, &ssrc_of_sender)) { @@ -123,8 +123,8 @@ void CastReceiverImpl::DecodeEncodedAudioFrame( audio_sampling_rate_, audio_codec_)); } - const uint32 frame_id = encoded_frame->frame_id; - const uint32 rtp_timestamp = encoded_frame->rtp_timestamp; + const uint32_t frame_id = encoded_frame->frame_id; + const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; const base::TimeTicks playout_time = encoded_frame->reference_time; audio_decoder_->DecodeFrame( encoded_frame.Pass(), @@ -155,8 +155,8 @@ void CastReceiverImpl::DecodeEncodedVideoFrame( if (!video_decoder_) video_decoder_.reset(new VideoDecoder(cast_environment_, video_codec_)); - const uint32 frame_id = encoded_frame->frame_id; - const uint32 rtp_timestamp = encoded_frame->rtp_timestamp; + const uint32_t frame_id = encoded_frame->frame_id; + const uint32_t rtp_timestamp = encoded_frame->rtp_timestamp; const base::TimeTicks playout_time = encoded_frame->reference_time; video_decoder_->DecodeFrame( encoded_frame.Pass(), @@ -172,8 +172,8 @@ void CastReceiverImpl::DecodeEncodedVideoFrame( void CastReceiverImpl::EmitDecodedAudioFrame( const scoped_refptr<CastEnvironment>& cast_environment, const AudioFrameDecodedCallback& callback, - uint32 frame_id, - uint32 rtp_timestamp, + uint32_t frame_id, + uint32_t rtp_timestamp, const base::TimeTicks& playout_time, scoped_ptr<AudioBus> audio_bus, bool is_continuous) { @@ -199,8 +199,8 @@ void CastReceiverImpl::EmitDecodedAudioFrame( void CastReceiverImpl::EmitDecodedVideoFrame( const scoped_refptr<CastEnvironment>& cast_environment, const VideoFrameDecodedCallback& callback, - uint32 frame_id, - uint32 rtp_timestamp, + uint32_t frame_id, + uint32_t rtp_timestamp, const base::TimeTicks& playout_time, const scoped_refptr<VideoFrame>& video_frame, bool is_continuous) { diff --git a/media/cast/receiver/cast_receiver_impl.h b/media/cast/receiver/cast_receiver_impl.h index 6a6592a..f94735c 100644 --- a/media/cast/receiver/cast_receiver_impl.h +++ b/media/cast/receiver/cast_receiver_impl.h @@ -62,8 +62,8 @@ class CastReceiverImpl : public CastReceiver { static void EmitDecodedAudioFrame( const scoped_refptr<CastEnvironment>& cast_environment, const AudioFrameDecodedCallback& callback, - uint32 frame_id, - uint32 rtp_timestamp, + uint32_t frame_id, + uint32_t rtp_timestamp, const base::TimeTicks& playout_time, scoped_ptr<AudioBus> audio_bus, bool is_continuous); @@ -76,8 +76,8 @@ class CastReceiverImpl : public CastReceiver { static void EmitDecodedVideoFrame( const scoped_refptr<CastEnvironment>& cast_environment, const VideoFrameDecodedCallback& callback, - uint32 frame_id, - uint32 rtp_timestamp, + uint32_t frame_id, + uint32_t rtp_timestamp, const base::TimeTicks& playout_time, const scoped_refptr<VideoFrame>& video_frame, bool is_continuous); @@ -88,8 +88,8 @@ class CastReceiverImpl : public CastReceiver { // Used by DispatchReceivedPacket() to direct packets to the appropriate frame // receiver. - const uint32 ssrc_of_audio_sender_; - const uint32 ssrc_of_video_sender_; + const uint32_t ssrc_of_audio_sender_; + const uint32_t ssrc_of_video_sender_; // Parameters for the decoders that are created on-demand. The values here // might be nonsense if the client of CastReceiverImpl never intends to use diff --git a/media/cast/receiver/frame_receiver.cc b/media/cast/receiver/frame_receiver.cc index b9d5a6e..303a718 100644 --- a/media/cast/receiver/frame_receiver.cc +++ b/media/cast/receiver/frame_receiver.cc @@ -81,7 +81,7 @@ bool FrameReceiver::ProcessPacket(scoped_ptr<Packet> packet) { rtcp_.IncomingRtcpPacket(&packet->front(), packet->size()); } else { RtpCastHeader rtp_header; - const uint8* payload_data; + const uint8_t* payload_data; size_t payload_size; if (!packet_parser_.ParsePacket(&packet->front(), packet->size(), @@ -105,7 +105,7 @@ bool FrameReceiver::ProcessPacket(scoped_ptr<Packet> packet) { } void FrameReceiver::ProcessParsedPacket(const RtpCastHeader& rtp_header, - const uint8* payload_data, + const uint8_t* payload_data, size_t payload_size) { DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); @@ -155,7 +155,7 @@ void FrameReceiver::ProcessParsedPacket(const RtpCastHeader& rtp_header, lip_sync_reference_time_ = fresh_sync_reference; } else { lip_sync_reference_time_ += RtpDeltaToTimeDelta( - static_cast<int32>(fresh_sync_rtp - lip_sync_rtp_timestamp_), + static_cast<int32_t>(fresh_sync_rtp - lip_sync_rtp_timestamp_), rtp_timebase_); } lip_sync_rtp_timestamp_ = fresh_sync_rtp; @@ -302,12 +302,11 @@ base::TimeTicks FrameReceiver::GetPlayoutTime(const EncodedFrame& frame) const { target_playout_delay = base::TimeDelta::FromMilliseconds( frame.new_playout_delay_ms); } - return lip_sync_reference_time_ + - lip_sync_drift_.Current() + - RtpDeltaToTimeDelta( - static_cast<int32>(frame.rtp_timestamp - lip_sync_rtp_timestamp_), - rtp_timebase_) + - target_playout_delay; + return lip_sync_reference_time_ + lip_sync_drift_.Current() + + RtpDeltaToTimeDelta(static_cast<int32_t>(frame.rtp_timestamp - + lip_sync_rtp_timestamp_), + rtp_timebase_) + + target_playout_delay; } void FrameReceiver::ScheduleNextCastMessage() { diff --git a/media/cast/receiver/frame_receiver.h b/media/cast/receiver/frame_receiver.h index ec3175f..6bb96e1 100644 --- a/media/cast/receiver/frame_receiver.h +++ b/media/cast/receiver/frame_receiver.h @@ -69,7 +69,7 @@ class FrameReceiver : public RtpPayloadFeedback, friend class FrameReceiverTest; // Invokes ProcessParsedPacket(). void ProcessParsedPacket(const RtpCastHeader& rtp_header, - const uint8* payload_data, + const uint8_t* payload_data, size_t payload_size); // RtpPayloadFeedback implementation. diff --git a/media/cast/receiver/frame_receiver_unittest.cc b/media/cast/receiver/frame_receiver_unittest.cc index 6e6a3915..6386631 100644 --- a/media/cast/receiver/frame_receiver_unittest.cc +++ b/media/cast/receiver/frame_receiver_unittest.cc @@ -28,7 +28,7 @@ namespace cast { namespace { const int kPacketSize = 1500; -const uint32 kFirstFrameId = 1234; +const uint32_t kFirstFrameId = 1234; const int kPlayoutDelayMillis = 100; class FakeFrameClient { @@ -36,7 +36,7 @@ class FakeFrameClient { FakeFrameClient() : num_called_(0) {} virtual ~FakeFrameClient() {} - void AddExpectedResult(uint32 expected_frame_id, + void AddExpectedResult(uint32_t expected_frame_id, const base::TimeTicks& expected_playout_time) { expected_results_.push_back( std::make_pair(expected_frame_id, expected_playout_time)); @@ -56,7 +56,7 @@ class FakeFrameClient { int number_times_called() const { return num_called_; } private: - std::deque<std::pair<uint32, base::TimeTicks> > expected_results_; + std::deque<std::pair<uint32_t, base::TimeTicks>> expected_results_; int num_called_; DISALLOW_COPY_AND_ASSIGN(FakeFrameClient); @@ -119,21 +119,20 @@ class FrameReceiverTest : public ::testing::Test { void FeedLipSyncInfoIntoReceiver() { const base::TimeTicks now = testing_clock_->NowTicks(); - const int64 rtp_timestamp = (now - start_time_) * - config_.rtp_timebase / base::TimeDelta::FromSeconds(1); + const int64_t rtp_timestamp = (now - start_time_) * config_.rtp_timebase / + base::TimeDelta::FromSeconds(1); CHECK_LE(0, rtp_timestamp); - uint32 ntp_seconds; - uint32 ntp_fraction; + uint32_t ntp_seconds; + uint32_t ntp_fraction; ConvertTimeTicksToNtp(now, &ntp_seconds, &ntp_fraction); TestRtcpPacketBuilder rtcp_packet; - rtcp_packet.AddSrWithNtp(config_.sender_ssrc, - ntp_seconds, ntp_fraction, - static_cast<uint32>(rtp_timestamp)); + rtcp_packet.AddSrWithNtp(config_.sender_ssrc, ntp_seconds, ntp_fraction, + static_cast<uint32_t>(rtp_timestamp)); ASSERT_TRUE(receiver_->ProcessPacket(rtcp_packet.GetPacket().Pass())); } FrameReceiverConfig config_; - std::vector<uint8> payload_; + std::vector<uint8_t> payload_; RtpCastHeader rtp_header_; base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. base::TimeTicks start_time_; @@ -217,7 +216,7 @@ TEST_F(FrameReceiverTest, ReceivesFramesSkippingWhenAppropriate) { EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) .WillRepeatedly(testing::Return()); - const uint32 rtp_advance_per_frame = + const uint32_t rtp_advance_per_frame = config_.rtp_timebase / config_.target_frame_rate; const base::TimeDelta time_advance_per_frame = base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; @@ -320,7 +319,7 @@ TEST_F(FrameReceiverTest, ReceivesFramesRefusingToSkipAny) { EXPECT_CALL(mock_transport_, SendRtcpFromRtpReceiver(_, _, _, _, _, _, _)) .WillRepeatedly(testing::Return()); - const uint32 rtp_advance_per_frame = + const uint32_t rtp_advance_per_frame = config_.rtp_timebase / config_.target_frame_rate; const base::TimeDelta time_advance_per_frame = base::TimeDelta::FromSeconds(1) / config_.target_frame_rate; diff --git a/media/cast/receiver/video_decoder.cc b/media/cast/receiver/video_decoder.cc index e942380..96ec359 100644 --- a/media/cast/receiver/video_decoder.cc +++ b/media/cast/receiver/video_decoder.cc @@ -49,7 +49,7 @@ class VideoDecoder::ImplBase "size of frame_id types do not match"); bool is_continuous = true; if (seen_first_frame_) { - const uint32 frames_ahead = encoded_frame->frame_id - last_frame_id_; + const uint32_t frames_ahead = encoded_frame->frame_id - last_frame_id_; if (frames_ahead > 1) { RecoverBecauseFramesWereDropped(); is_continuous = false; @@ -84,7 +84,7 @@ class VideoDecoder::ImplBase virtual void RecoverBecauseFramesWereDropped() {} // Note: Implementation of Decode() is allowed to mutate |data|. - virtual scoped_refptr<VideoFrame> Decode(uint8* data, int len) = 0; + virtual scoped_refptr<VideoFrame> Decode(uint8_t* data, int len) = 0; const scoped_refptr<CastEnvironment> cast_environment_; const Codec codec_; @@ -97,7 +97,7 @@ class VideoDecoder::ImplBase private: bool seen_first_frame_; - uint32 last_frame_id_; + uint32_t last_frame_id_; DISALLOW_COPY_AND_ASSIGN(ImplBase); }; @@ -131,7 +131,7 @@ class VideoDecoder::Vp8Impl : public VideoDecoder::ImplBase { CHECK_EQ(VPX_CODEC_OK, vpx_codec_destroy(&context_)); } - scoped_refptr<VideoFrame> Decode(uint8* data, int len) final { + scoped_refptr<VideoFrame> Decode(uint8_t* data, int len) final { if (len <= 0 || vpx_codec_decode(&context_, data, static_cast<unsigned int>(len), @@ -193,7 +193,7 @@ class VideoDecoder::FakeImpl : public VideoDecoder::ImplBase { private: ~FakeImpl() final {} - scoped_refptr<VideoFrame> Decode(uint8* data, int len) final { + scoped_refptr<VideoFrame> Decode(uint8_t* data, int len) final { // Make sure this is a JSON string. if (!len || data[0] != '{') return NULL; diff --git a/media/cast/receiver/video_decoder_unittest.cc b/media/cast/receiver/video_decoder_unittest.cc index fad2db5..6cb3d49 100644 --- a/media/cast/receiver/video_decoder_unittest.cc +++ b/media/cast/receiver/video_decoder_unittest.cc @@ -153,7 +153,7 @@ class VideoDecoderTest : public ::testing::TestWithParam<Codec> { scoped_ptr<VideoDecoder> video_decoder_; gfx::Size next_frame_size_; base::TimeDelta next_frame_timestamp_; - uint32 last_frame_id_; + uint32_t last_frame_id_; bool seen_a_decoded_frame_; Vp8Encoder vp8_encoder_; diff --git a/media/cast/sender/audio_encoder.cc b/media/cast/sender/audio_encoder.cc index bf18118..aaf84d1 100644 --- a/media/cast/sender/audio_encoder.cc +++ b/media/cast/sender/audio_encoder.cc @@ -97,13 +97,13 @@ class AudioEncoder::ImplBase if (!frame_capture_time_.is_null()) { const base::TimeDelta amount_ahead_by = recorded_time - (frame_capture_time_ + buffer_fill_duration); - const int64 num_frames_missed = amount_ahead_by / frame_duration_; + const int64_t num_frames_missed = amount_ahead_by / frame_duration_; if (num_frames_missed > kUnderrunSkipThreshold) { samples_dropped_from_buffer_ += buffer_fill_end_; buffer_fill_end_ = 0; buffer_fill_duration = base::TimeDelta(); frame_rtp_timestamp_ += - static_cast<uint32>(num_frames_missed * samples_per_frame_); + static_cast<uint32_t>(num_frames_missed * samples_per_frame_); DVLOG(1) << "Skipping RTP timestamp ahead to account for " << num_frames_missed * samples_per_frame_ << " samples' worth of underrun."; @@ -205,14 +205,14 @@ class AudioEncoder::ImplBase int buffer_fill_end_; // A counter used to label EncodedFrames. - uint32 frame_id_; + uint32_t frame_id_; // The RTP timestamp for the next frame of encoded audio. This is defined as // the number of audio samples encoded so far, plus the estimated number of // samples that were missed due to data underruns. A receiver uses this value // to detect gaps in the audio signal data being provided. Per the spec, RTP // timestamp values are allowed to overflow and roll around past zero. - uint32 frame_rtp_timestamp_; + uint32_t frame_rtp_timestamp_; // The local system time associated with the start of the next frame of // encoded audio. This value is passed on to a receiver as a reference clock @@ -242,7 +242,7 @@ class AudioEncoder::OpusImpl : public AudioEncoder::ImplBase { sampling_rate, sampling_rate / kDefaultFramesPerSecond, /* 10 ms frames */ callback), - encoder_memory_(new uint8[opus_encoder_get_size(num_channels)]), + encoder_memory_(new uint8_t[opus_encoder_get_size(num_channels)]), opus_encoder_(reinterpret_cast<OpusEncoder*>(encoder_memory_.get())), buffer_(new float[num_channels * samples_per_frame_]) { if (ImplBase::operational_status_ != STATUS_UNINITIALIZED || @@ -289,12 +289,9 @@ class AudioEncoder::OpusImpl : public AudioEncoder::ImplBase { bool EncodeFromFilledBuffer(std::string* out) final { out->resize(kOpusMaxPayloadSize); - const opus_int32 result = - opus_encode_float(opus_encoder_, - buffer_.get(), - samples_per_frame_, - reinterpret_cast<uint8*>(string_as_array(out)), - kOpusMaxPayloadSize); + const opus_int32 result = opus_encode_float( + opus_encoder_, buffer_.get(), samples_per_frame_, + reinterpret_cast<uint8_t*>(string_as_array(out)), kOpusMaxPayloadSize); if (result > 1) { out->resize(result); return true; @@ -318,7 +315,7 @@ class AudioEncoder::OpusImpl : public AudioEncoder::ImplBase { duration == base::TimeDelta::FromMilliseconds(60); } - const scoped_ptr<uint8[]> encoder_memory_; + const scoped_ptr<uint8_t[]> encoder_memory_; OpusEncoder* const opus_encoder_; const scoped_ptr<float[]> buffer_; @@ -492,8 +489,8 @@ class AudioEncoder::AppleAacImpl : public AudioEncoder::ImplBase { // Allocate a buffer to store one access unit. This is the only location // where the implementation modifies |access_unit_buffer_|. - const_cast<scoped_ptr<uint8[]>&>(access_unit_buffer_) - .reset(new uint8[max_access_unit_size]); + const_cast<scoped_ptr<uint8_t[]>&>(access_unit_buffer_) + .reset(new uint8_t[max_access_unit_size]); // Initialize the converter ABL. Note that the buffer size has to be set // before every encode operation, since the field is modified to indicate @@ -512,7 +509,7 @@ class AudioEncoder::AppleAacImpl : public AudioEncoder::ImplBase { nullptr) != noErr) { return false; } - scoped_ptr<uint8[]> cookie_data(new uint8[cookie_size]); + scoped_ptr<uint8_t[]> cookie_data(new uint8_t[cookie_size]); if (AudioConverterGetProperty(converter_, kAudioConverterCompressionMagicCookie, &cookie_size, @@ -701,7 +698,7 @@ class AudioEncoder::AppleAacImpl : public AudioEncoder::ImplBase { // A buffer that holds one AAC access unit. Initialized in |Initialize| once // the maximum access unit size is known. - const scoped_ptr<uint8[]> access_unit_buffer_; + const scoped_ptr<uint8_t[]> access_unit_buffer_; // The maximum size of an access unit that the encoder can emit. const uint32_t max_access_unit_size_; @@ -749,7 +746,7 @@ class AudioEncoder::Pcm16Impl : public AudioEncoder::ImplBase { sampling_rate, sampling_rate / kDefaultFramesPerSecond, /* 10 ms frames */ callback), - buffer_(new int16[num_channels * samples_per_frame_]) { + buffer_(new int16_t[num_channels * samples_per_frame_]) { if (ImplBase::operational_status_ != STATUS_UNINITIALIZED) return; operational_status_ = STATUS_INITIALIZED; @@ -763,25 +760,23 @@ class AudioEncoder::Pcm16Impl : public AudioEncoder::ImplBase { int buffer_fill_offset, int num_samples) final { audio_bus->ToInterleavedPartial( - source_offset, - num_samples, - sizeof(int16), + source_offset, num_samples, sizeof(int16_t), buffer_.get() + buffer_fill_offset * num_channels_); } bool EncodeFromFilledBuffer(std::string* out) final { // Output 16-bit PCM integers in big-endian byte order. - out->resize(num_channels_ * samples_per_frame_ * sizeof(int16)); - const int16* src = buffer_.get(); - const int16* const src_end = src + num_channels_ * samples_per_frame_; - uint16* dest = reinterpret_cast<uint16*>(&out->at(0)); + out->resize(num_channels_ * samples_per_frame_ * sizeof(int16_t)); + const int16_t* src = buffer_.get(); + const int16_t* const src_end = src + num_channels_ * samples_per_frame_; + uint16_t* dest = reinterpret_cast<uint16_t*>(&out->at(0)); for (; src < src_end; ++src, ++dest) *dest = base::HostToNet16(*src); return true; } private: - const scoped_ptr<int16[]> buffer_; + const scoped_ptr<int16_t[]> buffer_; DISALLOW_COPY_AND_ASSIGN(Pcm16Impl); }; diff --git a/media/cast/sender/audio_encoder_unittest.cc b/media/cast/sender/audio_encoder_unittest.cc index 48ebdc1..b96a553 100644 --- a/media/cast/sender/audio_encoder_unittest.cc +++ b/media/cast/sender/audio_encoder_unittest.cc @@ -46,7 +46,7 @@ class TestEncodedAudioFrameReceiver { void FrameEncoded(scoped_ptr<SenderEncodedFrame> encoded_frame, int samples_skipped) { EXPECT_EQ(encoded_frame->dependency, EncodedFrame::KEY); - EXPECT_EQ(static_cast<uint8>(frames_received_ & 0xff), + EXPECT_EQ(static_cast<uint8_t>(frames_received_ & 0xff), encoded_frame->frame_id); EXPECT_EQ(encoded_frame->frame_id, encoded_frame->referenced_frame_id); // RTP timestamps should be monotonically increasing and integer multiples @@ -68,7 +68,7 @@ class TestEncodedAudioFrameReceiver { private: int frames_received_; - uint32 rtp_lower_bound_; + uint32_t rtp_lower_bound_; int samples_per_frame_; base::TimeTicks lower_bound_; base::TimeTicks upper_bound_; @@ -77,10 +77,10 @@ class TestEncodedAudioFrameReceiver { }; struct TestScenario { - const int64* durations_in_ms; + const int64_t* durations_in_ms; size_t num_durations; - TestScenario(const int64* d, size_t n) + TestScenario(const int64_t* d, size_t n) : durations_in_ms(d), num_durations(n) {} std::string ToString() const { @@ -191,38 +191,38 @@ TEST_P(AudioEncoderTest, EncodeAac) { } #endif -static const int64 kOneCall_3Millis[] = {3}; -static const int64 kOneCall_10Millis[] = {10}; -static const int64 kOneCall_13Millis[] = {13}; -static const int64 kOneCall_20Millis[] = {20}; - -static const int64 kTwoCalls_3Millis[] = {3, 3}; -static const int64 kTwoCalls_10Millis[] = {10, 10}; -static const int64 kTwoCalls_Mixed1[] = {3, 10}; -static const int64 kTwoCalls_Mixed2[] = {10, 3}; -static const int64 kTwoCalls_Mixed3[] = {3, 17}; -static const int64 kTwoCalls_Mixed4[] = {17, 3}; - -static const int64 kManyCalls_3Millis[] = {3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3}; -static const int64 kManyCalls_10Millis[] = {10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10}; -static const int64 kManyCalls_Mixed1[] = {3, 10, 3, 10, 3, 10, 3, 10, 3, - 10, 3, 10, 3, 10, 3, 10, 3, 10}; -static const int64 kManyCalls_Mixed2[] = {10, 3, 10, 3, 10, 3, 10, 3, 10, 3, - 10, 3, 10, 3, 10, 3, 10, 3, 10, 3}; -static const int64 kManyCalls_Mixed3[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, - 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4}; -static const int64 kManyCalls_Mixed4[] = {31, 4, 15, 9, 26, 53, 5, 8, 9, - 7, 9, 32, 38, 4, 62, 64, 3}; -static const int64 kManyCalls_Mixed5[] = {3, 14, 15, 9, 26, 53, 58, 9, 7, - 9, 3, 23, 8, 4, 6, 2, 6, 43}; - -static const int64 kOneBigUnderrun[] = {10, 10, 10, 10, -1000, 10, 10, 10}; -static const int64 kTwoBigUnderruns[] = {10, 10, 10, 10, -712, 10, 10, 10, - -1311, 10, 10, 10}; -static const int64 kMixedUnderruns[] = {31, -64, 4, 15, 9, 26, -53, 5, 8, -9, - 7, 9, 32, 38, -4, 62, -64, 3}; +static const int64_t kOneCall_3Millis[] = {3}; +static const int64_t kOneCall_10Millis[] = {10}; +static const int64_t kOneCall_13Millis[] = {13}; +static const int64_t kOneCall_20Millis[] = {20}; + +static const int64_t kTwoCalls_3Millis[] = {3, 3}; +static const int64_t kTwoCalls_10Millis[] = {10, 10}; +static const int64_t kTwoCalls_Mixed1[] = {3, 10}; +static const int64_t kTwoCalls_Mixed2[] = {10, 3}; +static const int64_t kTwoCalls_Mixed3[] = {3, 17}; +static const int64_t kTwoCalls_Mixed4[] = {17, 3}; + +static const int64_t kManyCalls_3Millis[] = {3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3}; +static const int64_t kManyCalls_10Millis[] = {10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10}; +static const int64_t kManyCalls_Mixed1[] = {3, 10, 3, 10, 3, 10, 3, 10, 3, + 10, 3, 10, 3, 10, 3, 10, 3, 10}; +static const int64_t kManyCalls_Mixed2[] = {10, 3, 10, 3, 10, 3, 10, 3, 10, 3, + 10, 3, 10, 3, 10, 3, 10, 3, 10, 3}; +static const int64_t kManyCalls_Mixed3[] = {3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, + 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4}; +static const int64_t kManyCalls_Mixed4[] = {31, 4, 15, 9, 26, 53, 5, 8, 9, + 7, 9, 32, 38, 4, 62, 64, 3}; +static const int64_t kManyCalls_Mixed5[] = {3, 14, 15, 9, 26, 53, 58, 9, 7, + 9, 3, 23, 8, 4, 6, 2, 6, 43}; + +static const int64_t kOneBigUnderrun[] = {10, 10, 10, 10, -1000, 10, 10, 10}; +static const int64_t kTwoBigUnderruns[] = {10, 10, 10, 10, -712, 10, + 10, 10, -1311, 10, 10, 10}; +static const int64_t kMixedUnderruns[] = {31, -64, 4, 15, 9, 26, -53, 5, 8, + -9, 7, 9, 32, 38, -4, 62, -64, 3}; INSTANTIATE_TEST_CASE_P( AudioEncoderTestScenarios, diff --git a/media/cast/sender/audio_sender_unittest.cc b/media/cast/sender/audio_sender_unittest.cc index edbee2e..f866b51 100644 --- a/media/cast/sender/audio_sender_unittest.cc +++ b/media/cast/sender/audio_sender_unittest.cc @@ -53,7 +53,7 @@ class TestPacketSender : public PacketSender { return true; } - int64 GetBytesSent() final { return 0; } + int64_t GetBytesSent() final { return 0; } int number_of_rtp_packets() const { return number_of_rtp_packets_; } diff --git a/media/cast/sender/congestion_control.cc b/media/cast/sender/congestion_control.cc index 0c37056..c5b91f5 100644 --- a/media/cast/sender/congestion_control.cc +++ b/media/cast/sender/congestion_control.cc @@ -38,10 +38,10 @@ class AdaptiveCongestionControl : public CongestionControl { // CongestionControl implementation. void UpdateRtt(base::TimeDelta rtt) final; void UpdateTargetPlayoutDelay(base::TimeDelta delay) final; - void SendFrameToTransport(uint32 frame_id, + void SendFrameToTransport(uint32_t frame_id, size_t frame_size_in_bits, base::TimeTicks when) final; - void AckFrame(uint32 frame_id, base::TimeTicks when) final; + void AckFrame(uint32_t frame_id, base::TimeTicks when) final; int GetBitrate(base::TimeTicks playout_time, base::TimeDelta playout_delay, int soft_max_bitrate) final; @@ -61,7 +61,7 @@ class AdaptiveCongestionControl : public CongestionControl { static base::TimeDelta DeadTime(const FrameStats& a, const FrameStats& b); // Get the FrameStats for a given |frame_id|. Never returns nullptr. // Note: Older FrameStats will be removed automatically. - FrameStats* GetFrameStats(uint32 frame_id); + FrameStats* GetFrameStats(uint32_t frame_id); // Discard old FrameStats. void PruneFrameStats(); // Calculate a safe bitrate. This is based on how much we've been @@ -71,7 +71,7 @@ class AdaptiveCongestionControl : public CongestionControl { // Estimate when the transport will start sending the data for a given frame. // |estimated_bitrate| is the current estimated transmit bitrate in bits per // second. - base::TimeTicks EstimatedSendingTime(uint32 frame_id, + base::TimeTicks EstimatedSendingTime(uint32_t frame_id, double estimated_bitrate); base::TickClock* const clock_; // Not owned by this class. @@ -79,9 +79,9 @@ class AdaptiveCongestionControl : public CongestionControl { const int min_bitrate_configured_; const double max_frame_rate_; std::deque<FrameStats> frame_stats_; - uint32 last_frame_stats_; - uint32 last_acked_frame_; - uint32 last_enqueued_frame_; + uint32_t last_frame_stats_; + uint32_t last_acked_frame_; + uint32_t last_enqueued_frame_; base::TimeDelta rtt_; size_t history_size_; size_t acked_bits_in_history_; @@ -98,10 +98,10 @@ class FixedCongestionControl : public CongestionControl { // CongestionControl implementation. void UpdateRtt(base::TimeDelta rtt) final {} void UpdateTargetPlayoutDelay(base::TimeDelta delay) final {} - void SendFrameToTransport(uint32 frame_id, + void SendFrameToTransport(uint32_t frame_id, size_t frame_size_in_bits, base::TimeTicks when) final {} - void AckFrame(uint32 frame_id, base::TimeTicks when) final {} + void AckFrame(uint32_t frame_id, base::TimeTicks when) final {} int GetBitrate(base::TimeTicks playout_time, base::TimeDelta playout_delay, int soft_max_bitrate) final { @@ -143,18 +143,17 @@ static const size_t kHistorySize = 100; AdaptiveCongestionControl::FrameStats::FrameStats() : frame_size_in_bits(0) { } -AdaptiveCongestionControl::AdaptiveCongestionControl( - base::TickClock* clock, - int max_bitrate_configured, - int min_bitrate_configured, - double max_frame_rate) +AdaptiveCongestionControl::AdaptiveCongestionControl(base::TickClock* clock, + int max_bitrate_configured, + int min_bitrate_configured, + double max_frame_rate) : clock_(clock), max_bitrate_configured_(max_bitrate_configured), min_bitrate_configured_(min_bitrate_configured), max_frame_rate_(max_frame_rate), - last_frame_stats_(static_cast<uint32>(-1)), - last_acked_frame_(static_cast<uint32>(-1)), - last_enqueued_frame_(static_cast<uint32>(-1)), + last_frame_stats_(static_cast<uint32_t>(-1)), + last_acked_frame_(static_cast<uint32_t>(-1)), + last_enqueued_frame_(static_cast<uint32_t>(-1)), history_size_(kHistorySize), acked_bits_in_history_(0) { DCHECK_GE(max_bitrate_configured, min_bitrate_configured) << "Invalid config"; @@ -205,10 +204,10 @@ double AdaptiveCongestionControl::CalculateSafeBitrate() { return acked_bits_in_history_ / std::max(transmit_time, 1E-3); } -AdaptiveCongestionControl::FrameStats* -AdaptiveCongestionControl::GetFrameStats(uint32 frame_id) { - int32 offset = static_cast<int32>(frame_id - last_frame_stats_); - DCHECK_LT(offset, static_cast<int32>(kHistorySize)); +AdaptiveCongestionControl::FrameStats* AdaptiveCongestionControl::GetFrameStats( + uint32_t frame_id) { + int32_t offset = static_cast<int32_t>(frame_id - last_frame_stats_); + DCHECK_LT(offset, static_cast<int32_t>(kHistorySize)); if (offset > 0) { frame_stats_.resize(frame_stats_.size() + offset); last_frame_stats_ += offset; @@ -218,7 +217,7 @@ AdaptiveCongestionControl::GetFrameStats(uint32 frame_id) { offset += frame_stats_.size() - 1; // TODO(miu): Change the following to DCHECK once crash fix is confirmed. // http://crbug.com/517145 - CHECK(offset >= 0 && offset < static_cast<int32>(frame_stats_.size())); + CHECK(offset >= 0 && offset < static_cast<int32_t>(frame_stats_.size())); return &frame_stats_[offset]; } @@ -235,7 +234,7 @@ void AdaptiveCongestionControl::PruneFrameStats() { } } -void AdaptiveCongestionControl::AckFrame(uint32 frame_id, +void AdaptiveCongestionControl::AckFrame(uint32_t frame_id, base::TimeTicks when) { FrameStats* frame_stats = GetFrameStats(last_acked_frame_); while (IsNewerFrameId(frame_id, last_acked_frame_)) { @@ -255,7 +254,7 @@ void AdaptiveCongestionControl::AckFrame(uint32 frame_id, } } -void AdaptiveCongestionControl::SendFrameToTransport(uint32 frame_id, +void AdaptiveCongestionControl::SendFrameToTransport(uint32_t frame_id, size_t frame_size_in_bits, base::TimeTicks when) { last_enqueued_frame_ = frame_id; @@ -265,7 +264,7 @@ void AdaptiveCongestionControl::SendFrameToTransport(uint32 frame_id, } base::TimeTicks AdaptiveCongestionControl::EstimatedSendingTime( - uint32 frame_id, + uint32_t frame_id, double estimated_bitrate) { const base::TimeTicks now = clock_->NowTicks(); @@ -277,7 +276,7 @@ base::TimeTicks AdaptiveCongestionControl::EstimatedSendingTime( // be in-flight; and therefore it is common for the |estimated_sending_time| // for those frames to be before |now|. base::TimeTicks estimated_sending_time; - for (uint32 f = last_acked_frame_; IsNewerFrameId(frame_id, f); ++f) { + for (uint32_t f = last_acked_frame_; IsNewerFrameId(frame_id, f); ++f) { FrameStats* const stats = GetFrameStats(f); // |estimated_ack_time| is the local time when the sender receives the ACK, diff --git a/media/cast/sender/congestion_control.h b/media/cast/sender/congestion_control.h index 8e17134..3951f99 100644 --- a/media/cast/sender/congestion_control.h +++ b/media/cast/sender/congestion_control.h @@ -5,7 +5,6 @@ #ifndef MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_ #define MEDIA_CAST_CONGESTION_CONTROL_CONGESTION_CONTROL_H_ -#include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/time/tick_clock.h" #include "base/time/time.h" @@ -24,12 +23,12 @@ class CongestionControl { virtual void UpdateTargetPlayoutDelay(base::TimeDelta delay) = 0; // Called when an encoded frame is enqueued for transport. - virtual void SendFrameToTransport(uint32 frame_id, + virtual void SendFrameToTransport(uint32_t frame_id, size_t frame_size_in_bits, base::TimeTicks when) = 0; // Called when we receive an ACK for a frame. - virtual void AckFrame(uint32 frame_id, base::TimeTicks when) = 0; + virtual void AckFrame(uint32_t frame_id, base::TimeTicks when) = 0; // Returns the bitrate we should use for the next frame. |soft_max_bitrate| // is a soft upper-bound applied to the computed target bitrate before the diff --git a/media/cast/sender/congestion_control_unittest.cc b/media/cast/sender/congestion_control_unittest.cc index b435b9a..e1c0251 100644 --- a/media/cast/sender/congestion_control_unittest.cc +++ b/media/cast/sender/congestion_control_unittest.cc @@ -15,9 +15,9 @@ namespace cast { static const int kMaxBitrateConfigured = 5000000; static const int kMinBitrateConfigured = 500000; -static const int64 kFrameDelayMs = 33; +static const int64_t kFrameDelayMs = 33; static const double kMaxFrameRate = 1000.0 / kFrameDelayMs; -static const int64 kStartMillisecond = INT64_C(12345678900000); +static const int64_t kStartMillisecond = INT64_C(12345678900000); static const double kTargetEmptyBufferFraction = 0.9; class CongestionControlTest : public ::testing::Test { @@ -36,11 +36,11 @@ class CongestionControlTest : public ::testing::Test { congestion_control_->UpdateTargetPlayoutDelay(target_playout_delay); } - void AckFrame(uint32 frame_id) { + void AckFrame(uint32_t frame_id) { congestion_control_->AckFrame(frame_id, testing_clock_.NowTicks()); } - void Run(uint32 frames, + void Run(uint32_t frames, size_t frame_size, base::TimeDelta rtt, base::TimeDelta frame_delay, @@ -61,7 +61,7 @@ class CongestionControlTest : public ::testing::Test { base::SimpleTestTickClock testing_clock_; scoped_ptr<CongestionControl> congestion_control_; scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; - uint32 frame_id_; + uint32_t frame_id_; DISALLOW_COPY_AND_ASSIGN(CongestionControlTest); }; @@ -70,7 +70,7 @@ class CongestionControlTest : public ::testing::Test { // estimations of network bandwidth and how much is in-flight (i.e, using the // "target buffer fill" model). TEST_F(CongestionControlTest, SimpleRun) { - uint32 frame_size = 10000 * 8; + uint32_t frame_size = 10000 * 8; Run(500, frame_size, base::TimeDelta::FromMilliseconds(10), @@ -83,11 +83,10 @@ TEST_F(CongestionControlTest, SimpleRun) { // the underlying computations. const int soft_max_bitrate = std::numeric_limits<int>::max(); - uint32 safe_bitrate = frame_size * 1000 / kFrameDelayMs; - uint32 bitrate = congestion_control_->GetBitrate( + uint32_t safe_bitrate = frame_size * 1000 / kFrameDelayMs; + uint32_t bitrate = congestion_control_->GetBitrate( testing_clock_.NowTicks() + base::TimeDelta::FromMilliseconds(300), - base::TimeDelta::FromMilliseconds(300), - soft_max_bitrate); + base::TimeDelta::FromMilliseconds(300), soft_max_bitrate); EXPECT_NEAR( safe_bitrate / kTargetEmptyBufferFraction, bitrate, safe_bitrate * 0.05); diff --git a/media/cast/sender/external_video_encoder.cc b/media/cast/sender/external_video_encoder.cc index 11484c0..f716a55 100644 --- a/media/cast/sender/external_video_encoder.cc +++ b/media/cast/sender/external_video_encoder.cc @@ -102,7 +102,7 @@ class ExternalVideoEncoder::VEAClientImpl void Initialize(const gfx::Size& frame_size, VideoCodecProfile codec_profile, int start_bit_rate, - uint32 first_frame_id) { + uint32_t first_frame_id) { DCHECK(task_runner_->RunsTasksOnCurrentThread()); requested_bit_rate_ = start_bit_rate; @@ -185,12 +185,12 @@ class ExternalVideoEncoder::VEAClientImpl // Encoder has encoded a frame and it's available in one of the output // buffers. Package the result in a media::cast::EncodedFrame and post it // to the Cast MAIN thread via the supplied callback. - void BitstreamBufferReady(int32 bitstream_buffer_id, + void BitstreamBufferReady(int32_t bitstream_buffer_id, size_t payload_size, bool key_frame) final { DCHECK(task_runner_->RunsTasksOnCurrentThread()); if (bitstream_buffer_id < 0 || - bitstream_buffer_id >= static_cast<int32>(output_buffers_.size())) { + bitstream_buffer_id >= static_cast<int32_t>(output_buffers_.size())) { NOTREACHED(); VLOG(1) << "BitstreamBufferReady(): invalid bitstream_buffer_id=" << bitstream_buffer_id; @@ -263,11 +263,11 @@ class ExternalVideoEncoder::VEAClientImpl if (key_frame || key_frame_quantizer_parsable_) { if (codec_profile_ == media::VP8PROFILE_ANY) { quantizer = ParseVp8HeaderQuantizer( - reinterpret_cast<const uint8*>(encoded_frame->data.data()), + reinterpret_cast<const uint8_t*>(encoded_frame->data.data()), encoded_frame->data.size()); } else if (codec_profile_ == media::H264PROFILE_MAIN) { quantizer = GetH264FrameQuantizer( - reinterpret_cast<const uint8*>(encoded_frame->data.data()), + reinterpret_cast<const uint8_t*>(encoded_frame->data.data()), encoded_frame->data.size()); } else { NOTIMPLEMENTED(); @@ -375,7 +375,7 @@ class ExternalVideoEncoder::VEAClientImpl // Immediately provide all output buffers to the VEA. for (size_t i = 0; i < output_buffers_.size(); ++i) { video_encode_accelerator_->UseOutputBitstreamBuffer( - media::BitstreamBuffer(static_cast<int32>(i), + media::BitstreamBuffer(static_cast<int32_t>(i), output_buffers_[i]->handle(), output_buffers_[i]->mapped_size())); } @@ -383,7 +383,7 @@ class ExternalVideoEncoder::VEAClientImpl // Parse H264 SPS, PPS, and Slice header, and return the averaged frame // quantizer in the range of [0, 51], or -1 on parse error. - double GetH264FrameQuantizer(const uint8* encoded_data, off_t size) { + double GetH264FrameQuantizer(const uint8_t* encoded_data, off_t size) { DCHECK(encoded_data); if (!size) return -1; @@ -447,7 +447,7 @@ class ExternalVideoEncoder::VEAClientImpl const CreateVideoEncodeMemoryCallback create_video_encode_memory_cb_; scoped_ptr<media::VideoEncodeAccelerator> video_encode_accelerator_; bool encoder_active_; - uint32 next_frame_id_; + uint32_t next_frame_id_; bool key_frame_encountered_; std::string stream_header_; VideoCodecProfile codec_profile_; @@ -491,7 +491,7 @@ ExternalVideoEncoder::ExternalVideoEncoder( const scoped_refptr<CastEnvironment>& cast_environment, const VideoSenderConfig& video_config, const gfx::Size& frame_size, - uint32 first_frame_id, + uint32_t first_frame_id, const StatusChangeCallback& status_change_cb, const CreateVideoEncodeAcceleratorCallback& create_vea_cb, const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb) @@ -559,7 +559,7 @@ void ExternalVideoEncoder::GenerateKeyFrame() { void ExternalVideoEncoder::OnCreateVideoEncodeAccelerator( const VideoSenderConfig& video_config, - uint32 first_frame_id, + uint32_t first_frame_id, const StatusChangeCallback& status_change_cb, scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner, scoped_ptr<media::VideoEncodeAccelerator> vea) { @@ -655,7 +655,7 @@ double QuantizerEstimator::EstimateForKeyFrame(const VideoFrame& frame) { const int rows_in_subset = std::max(1, size.height() * FRAME_SAMPLING_PERCENT / 100); if (last_frame_size_ != size || !last_frame_pixel_buffer_) { - last_frame_pixel_buffer_.reset(new uint8[size.width() * rows_in_subset]); + last_frame_pixel_buffer_.reset(new uint8_t[size.width() * rows_in_subset]); last_frame_size_ = size; } @@ -667,11 +667,11 @@ double QuantizerEstimator::EstimateForKeyFrame(const VideoFrame& frame) { const int row_skip = size.height() / rows_in_subset; int y = 0; for (int i = 0; i < rows_in_subset; ++i, y += row_skip) { - const uint8* const row_begin = frame.visible_data(VideoFrame::kYPlane) + - y * frame.stride(VideoFrame::kYPlane); - const uint8* const row_end = row_begin + size.width(); + const uint8_t* const row_begin = frame.visible_data(VideoFrame::kYPlane) + + y * frame.stride(VideoFrame::kYPlane); + const uint8_t* const row_end = row_begin + size.width(); int left_hand_pixel_value = static_cast<int>(*row_begin); - for (const uint8* p = row_begin + 1; p < row_end; ++p) { + for (const uint8_t* p = row_begin + 1; p < row_end; ++p) { const int right_hand_pixel_value = static_cast<int>(*p); const int difference = right_hand_pixel_value - left_hand_pixel_value; const int histogram_index = difference + 255; @@ -714,12 +714,12 @@ double QuantizerEstimator::EstimateForDeltaFrame(const VideoFrame& frame) { const int row_skip = size.height() / rows_in_subset; int y = 0; for (int i = 0; i < rows_in_subset; ++i, y += row_skip) { - const uint8* const row_begin = frame.visible_data(VideoFrame::kYPlane) + - y * frame.stride(VideoFrame::kYPlane); - const uint8* const row_end = row_begin + size.width(); - uint8* const last_frame_row_begin = + const uint8_t* const row_begin = frame.visible_data(VideoFrame::kYPlane) + + y * frame.stride(VideoFrame::kYPlane); + const uint8_t* const row_end = row_begin + size.width(); + uint8_t* const last_frame_row_begin = last_frame_pixel_buffer_.get() + i * size.width(); - for (const uint8* p = row_begin, *q = last_frame_row_begin; p < row_end; + for (const uint8_t *p = row_begin, *q = last_frame_row_begin; p < row_end; ++p, ++q) { const int difference = static_cast<int>(*p) - static_cast<int>(*q); const int histogram_index = difference + 255; diff --git a/media/cast/sender/external_video_encoder.h b/media/cast/sender/external_video_encoder.h index 23e50e5..9ff1c1f 100644 --- a/media/cast/sender/external_video_encoder.h +++ b/media/cast/sender/external_video_encoder.h @@ -29,7 +29,7 @@ class ExternalVideoEncoder : public VideoEncoder { const scoped_refptr<CastEnvironment>& cast_environment, const VideoSenderConfig& video_config, const gfx::Size& frame_size, - uint32 first_frame_id, + uint32_t first_frame_id, const StatusChangeCallback& status_change_cb, const CreateVideoEncodeAcceleratorCallback& create_vea_cb, const CreateVideoEncodeMemoryCallback& create_video_encode_memory_cb); @@ -52,7 +52,7 @@ class ExternalVideoEncoder : public VideoEncoder { // |client_| holds a reference to the new VEAClientImpl. void OnCreateVideoEncodeAccelerator( const VideoSenderConfig& video_config, - uint32 first_frame_id, + uint32_t first_frame_id, const StatusChangeCallback& status_change_cb, scoped_refptr<base::SingleThreadTaskRunner> encoder_task_runner, scoped_ptr<media::VideoEncodeAccelerator> vea); @@ -149,7 +149,7 @@ class QuantizerEstimator { // A cache of a subset of rows of pixels from the last frame examined. This // is used to compute the entropy of the difference between frames, which in // turn is used to compute the entropy and quantizer. - scoped_ptr<uint8[]> last_frame_pixel_buffer_; + scoped_ptr<uint8_t[]> last_frame_pixel_buffer_; gfx::Size last_frame_size_; DISALLOW_COPY_AND_ASSIGN(QuantizerEstimator); diff --git a/media/cast/sender/external_video_encoder_unittest.cc b/media/cast/sender/external_video_encoder_unittest.cc index 78359f3..1004ba5 100644 --- a/media/cast/sender/external_video_encoder_unittest.cc +++ b/media/cast/sender/external_video_encoder_unittest.cc @@ -13,7 +13,7 @@ namespace cast { namespace { -scoped_refptr<VideoFrame> CreateFrame(const uint8* y_plane_data, +scoped_refptr<VideoFrame> CreateFrame(const uint8_t* y_plane_data, const gfx::Size& size) { scoped_refptr<VideoFrame> result = VideoFrame::CreateFrame(PIXEL_FORMAT_I420, size, @@ -35,7 +35,8 @@ TEST(QuantizerEstimator, EstimatesForTrivialFrames) { QuantizerEstimator qe; const gfx::Size frame_size(320, 180); - const scoped_ptr<uint8[]> black_frame_data(new uint8[frame_size.GetArea()]); + const scoped_ptr<uint8_t[]> black_frame_data( + new uint8_t[frame_size.GetArea()]); memset(black_frame_data.get(), 0, frame_size.GetArea()); const scoped_refptr<VideoFrame> black_frame = CreateFrame(black_frame_data.get(), frame_size); @@ -48,8 +49,8 @@ TEST(QuantizerEstimator, EstimatesForTrivialFrames) { for (int i = 0; i < 3; ++i) EXPECT_EQ(4.0, qe.EstimateForDeltaFrame(*black_frame)); - const scoped_ptr<uint8[]> checkerboard_frame_data( - new uint8[frame_size.GetArea()]); + const scoped_ptr<uint8_t[]> checkerboard_frame_data( + new uint8_t[frame_size.GetArea()]); for (int i = 0, end = frame_size.GetArea(); i < end; ++i) checkerboard_frame_data.get()[i] = (((i % 2) == 0) ? 0 : 255); const scoped_refptr<VideoFrame> checkerboard_frame = @@ -65,11 +66,11 @@ TEST(QuantizerEstimator, EstimatesForTrivialFrames) { // results in high quantizer estimates. for (int i = 0; i < 3; ++i) { int rand_seed = 0xdeadbeef + i; - const scoped_ptr<uint8[]> random_frame_data( - new uint8[frame_size.GetArea()]); + const scoped_ptr<uint8_t[]> random_frame_data( + new uint8_t[frame_size.GetArea()]); for (int j = 0, end = frame_size.GetArea(); j < end; ++j) { rand_seed = (1103515245 * rand_seed + 12345) % (1 << 31); - random_frame_data.get()[j] = static_cast<uint8>(rand_seed & 0xff); + random_frame_data.get()[j] = static_cast<uint8_t>(rand_seed & 0xff); } const scoped_refptr<VideoFrame> random_frame = CreateFrame(random_frame_data.get(), frame_size); diff --git a/media/cast/sender/fake_software_video_encoder.cc b/media/cast/sender/fake_software_video_encoder.cc index 3c33152..57fe249 100644 --- a/media/cast/sender/fake_software_video_encoder.cc +++ b/media/cast/sender/fake_software_video_encoder.cc @@ -70,7 +70,7 @@ void FakeSoftwareVideoEncoder::Encode( } } -void FakeSoftwareVideoEncoder::UpdateRates(uint32 new_bitrate) { +void FakeSoftwareVideoEncoder::UpdateRates(uint32_t new_bitrate) { frame_size_ = new_bitrate / video_config_.max_frame_rate / 8; } diff --git a/media/cast/sender/fake_software_video_encoder.h b/media/cast/sender/fake_software_video_encoder.h index 39c0344..d6a6f54 100644 --- a/media/cast/sender/fake_software_video_encoder.h +++ b/media/cast/sender/fake_software_video_encoder.h @@ -22,14 +22,14 @@ class FakeSoftwareVideoEncoder : public SoftwareVideoEncoder { void Encode(const scoped_refptr<media::VideoFrame>& video_frame, const base::TimeTicks& reference_time, SenderEncodedFrame* encoded_frame) final; - void UpdateRates(uint32 new_bitrate) final; + void UpdateRates(uint32_t new_bitrate) final; void GenerateKeyFrame() final; private: VideoSenderConfig video_config_; gfx::Size last_frame_size_; bool next_frame_is_key_; - uint32 frame_id_; + uint32_t frame_id_; int frame_size_; }; diff --git a/media/cast/sender/h264_vt_encoder.cc b/media/cast/sender/h264_vt_encoder.cc index c9f9330..30f968f 100644 --- a/media/cast/sender/h264_vt_encoder.cc +++ b/media/cast/sender/h264_vt_encoder.cc @@ -725,7 +725,7 @@ void H264VideoToolboxEncoder::CompressionCallback(void* encoder_opaque, // Increment the encoder-scoped frame id and assign the new value to this // frame. VideoToolbox calls the output callback serially, so this is safe. - const uint32 frame_id = ++encoder->last_frame_id_; + const uint32_t frame_id = ++encoder->last_frame_id_; scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); encoded_frame->frame_id = frame_id; diff --git a/media/cast/sender/h264_vt_encoder.h b/media/cast/sender/h264_vt_encoder.h index a152b0a..15318bf 100644 --- a/media/cast/sender/h264_vt_encoder.h +++ b/media/cast/sender/h264_vt_encoder.h @@ -112,7 +112,7 @@ class H264VideoToolboxEncoder : public VideoEncoder, scoped_refptr<VideoFrameFactoryImpl> video_frame_factory_; // The ID of the last frame that was emitted. - uint32 last_frame_id_; + uint32_t last_frame_id_; // Force next frame to be a keyframe. bool encode_next_frame_as_keyframe_; diff --git a/media/cast/sender/h264_vt_encoder_unittest.cc b/media/cast/sender/h264_vt_encoder_unittest.cc index 19dd3d1..fac070d 100644 --- a/media/cast/sender/h264_vt_encoder_unittest.cc +++ b/media/cast/sender/h264_vt_encoder_unittest.cc @@ -84,9 +84,9 @@ class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> { int count_frames_delivered() const { return count_frames_delivered_; } - void PushExpectation(uint32 expected_frame_id, - uint32 expected_last_referenced_frame_id, - uint32 expected_rtp_timestamp, + void PushExpectation(uint32_t expected_frame_id, + uint32_t expected_last_referenced_frame_id, + uint32_t expected_rtp_timestamp, const base::TimeTicks& expected_reference_time) { expectations_.push(Expectation{expected_frame_id, expected_last_referenced_frame_id, @@ -120,9 +120,9 @@ class MetadataRecorder : public base::RefCountedThreadSafe<MetadataRecorder> { int count_frames_delivered_; struct Expectation { - uint32 expected_frame_id; - uint32 expected_last_referenced_frame_id; - uint32 expected_rtp_timestamp; + uint32_t expected_frame_id; + uint32_t expected_last_referenced_frame_id; + uint32_t expected_rtp_timestamp; base::TimeTicks expected_reference_time; }; std::queue<Expectation> expectations_; @@ -292,7 +292,7 @@ TEST_F(H264VideoToolboxEncoderTest, CheckFrameMetadataSequence) { EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb)); message_loop_.RunUntilIdle(); - for (uint32 frame_id = 1; frame_id < 10; ++frame_id) { + for (uint32_t frame_id = 1; frame_id < 10; ++frame_id) { AdvanceClockAndVideoFrameTimestamp(); metadata_recorder->PushExpectation( frame_id, frame_id - 1, @@ -317,7 +317,7 @@ TEST_F(H264VideoToolboxEncoderTest, CheckFramesAreDecodable) { VideoEncoder::FrameEncodedCallback cb = base::Bind(&EndToEndFrameChecker::EncodeDone, checker.get()); - for (uint32 frame_id = 0; frame_id < 6; ++frame_id) { + for (uint32_t frame_id = 0; frame_id < 6; ++frame_id) { checker->PushExpectation(frame_); EXPECT_TRUE(encoder_->EncodeVideoFrame(frame_, clock_->NowTicks(), cb)); AdvanceClockAndVideoFrameTimestamp(); diff --git a/media/cast/sender/performance_metrics_overlay.cc b/media/cast/sender/performance_metrics_overlay.cc index 842bdf1..dfa2f21 100644 --- a/media/cast/sender/performance_metrics_overlay.cc +++ b/media/cast/sender/performance_metrics_overlay.cc @@ -29,7 +29,7 @@ const int kPlane = 0; // Y-plane in YUV formats. // different value than it did before. |p_ul| is a pointer to the pixel at // coordinate (0,0) in a single-channel 8bpp bitmap. |stride| is the number of // bytes per row in the output bitmap. -void DivergePixels(const gfx::Rect& rect, uint8* p_ul, int stride) { +void DivergePixels(const gfx::Rect& rect, uint8_t* p_ul, int stride) { DCHECK(p_ul); DCHECK_GT(stride, 0); @@ -52,14 +52,14 @@ void DivergePixels(const gfx::Rect& rect, uint8* p_ul, int stride) { const int left = rect.x() * kScale; const int right = rect.right() * kScale; for (int y = top; y < bottom; ++y) { - uint8* const p_l = p_ul + y * stride; + uint8_t* const p_l = p_ul + y * stride; for (int x = left; x < right; ++x) { int intensity = p_l[x]; if (intensity >= kDivergeDownThreshold) intensity = std::max(kMinIntensity, intensity - kDivergeDownAmount); else intensity += kDivergeUpAmount; - p_l[x] = static_cast<uint8>(intensity); + p_l[x] = static_cast<uint8_t>(intensity); } } } @@ -84,7 +84,7 @@ void RenderLineOfText(const std::string& line, int top, VideoFrame* frame) { // Compute the pointer to the pixel at the upper-left corner of the first // character to be rendered. const int stride = frame->stride(kPlane); - uint8* p_ul = + uint8_t* p_ul = // Start at the first pixel in the first row... frame->visible_data(kPlane) + (stride * top) // ...now move to the right edge of the visible part of the frame... diff --git a/media/cast/sender/size_adaptable_video_encoder_base.h b/media/cast/sender/size_adaptable_video_encoder_base.h index 237e3ab..a450a99 100644 --- a/media/cast/sender/size_adaptable_video_encoder_base.h +++ b/media/cast/sender/size_adaptable_video_encoder_base.h @@ -52,9 +52,7 @@ class SizeAdaptableVideoEncoderBase : public VideoEncoder { const gfx::Size& frame_size() const { return frame_size_; } - uint32 last_frame_id() const { - return last_frame_id_; - } + uint32_t last_frame_id() const { return last_frame_id_; } // Returns a callback that calls OnEncoderStatusChange(). The callback is // canceled by invalidating its bound weak pointer just before a replacement @@ -106,7 +104,7 @@ class SizeAdaptableVideoEncoderBase : public VideoEncoder { int frames_in_encoder_; // The ID of the last frame that was emitted from |encoder_|. - uint32 last_frame_id_; + uint32_t last_frame_id_; // NOTE: Weak pointers must be invalidated before all other member variables. base::WeakPtrFactory<SizeAdaptableVideoEncoderBase> weak_factory_; diff --git a/media/cast/sender/software_video_encoder.h b/media/cast/sender/software_video_encoder.h index 98cdf4b..acf96e3 100644 --- a/media/cast/sender/software_video_encoder.h +++ b/media/cast/sender/software_video_encoder.h @@ -5,7 +5,6 @@ #ifndef MEDIA_CAST_SENDER_SOFTWARE_VIDEO_ENCODER_H_ #define MEDIA_CAST_SENDER_SOFTWARE_VIDEO_ENCODER_H_ -#include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "media/cast/sender/sender_encoded_frame.h" @@ -34,7 +33,7 @@ class SoftwareVideoEncoder { SenderEncodedFrame* encoded_frame) = 0; // Update the encoder with a new target bit rate. - virtual void UpdateRates(uint32 new_bitrate) = 0; + virtual void UpdateRates(uint32_t new_bitrate) = 0; // Set the next frame to be a key frame. virtual void GenerateKeyFrame() = 0; diff --git a/media/cast/sender/video_encoder_unittest.cc b/media/cast/sender/video_encoder_unittest.cc index e308fc4..63f694e 100644 --- a/media/cast/sender/video_encoder_unittest.cc +++ b/media/cast/sender/video_encoder_unittest.cc @@ -165,8 +165,8 @@ class VideoEncoderTest // encoder rejected the request. bool EncodeAndCheckDelivery( const scoped_refptr<media::VideoFrame>& video_frame, - uint32 frame_id, - uint32 reference_frame_id) { + uint32_t frame_id, + uint32_t reference_frame_id) { return video_encoder_->EncodeVideoFrame( video_frame, Now(), @@ -213,12 +213,11 @@ class VideoEncoderTest // Checks that |encoded_frame| matches expected values. This is the method // bound in the callback returned from EncodeAndCheckDelivery(). - void DeliverEncodedVideoFrame( - uint32 expected_frame_id, - uint32 expected_last_referenced_frame_id, - uint32 expected_rtp_timestamp, - const base::TimeTicks& expected_reference_time, - scoped_ptr<SenderEncodedFrame> encoded_frame) { + void DeliverEncodedVideoFrame(uint32_t expected_frame_id, + uint32_t expected_last_referenced_frame_id, + uint32_t expected_rtp_timestamp, + const base::TimeTicks& expected_reference_time, + scoped_ptr<SenderEncodedFrame> encoded_frame) { EXPECT_TRUE(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); EXPECT_EQ(expected_frame_id, encoded_frame->frame_id); @@ -285,8 +284,8 @@ TEST_P(VideoEncoderTest, GeneratesKeyFrameThenOnlyDeltaFrames) { EXPECT_EQ(0, count_frames_delivered()); ExpectVEAResponsesForExternalVideoEncoder(0, 0); - uint32 frame_id = 0; - uint32 reference_frame_id = 0; + uint32_t frame_id = 0; + uint32_t reference_frame_id = 0; const gfx::Size frame_size(1280, 720); // Some encoders drop one or more frames initially while the encoder @@ -337,7 +336,7 @@ TEST_P(VideoEncoderTest, EncodesVariedFrameSizes) { frame_sizes.push_back(gfx::Size(322, 182)); // Grow the other dimension. frame_sizes.push_back(gfx::Size(1920, 1080)); // Grow both dimensions again. - uint32 frame_id = 0; + uint32_t frame_id = 0; // Encode one frame at each size. For encoders with a resize delay, except no // frames to be delivered since each frame size change will sprun diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc index be77ec3..0209962 100644 --- a/media/cast/sender/video_sender.cc +++ b/media/cast/sender/video_sender.cc @@ -288,7 +288,7 @@ int VideoSender::GetNumberOfFramesInEncoder() const { base::TimeDelta VideoSender::GetInFlightMediaDuration() const { if (GetUnacknowledgedFrameCount() > 0) { - const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; + const uint32_t oldest_unacked_frame_id = latest_acked_frame_id_ + 1; return last_enqueued_frame_reference_time_ - GetRecordedReferenceTime(oldest_unacked_frame_id); } else { @@ -328,7 +328,7 @@ int VideoSender::GetMaximumTargetBitrateForFrame( static_cast<int>(sqrt(resolution.GetArea() * 9.0 / 16.0)); // Linearly translate from |lines_of_resolution| to a maximum target bitrate. - int64 result = lines_of_resolution - STANDARD_RESOLUTION_LINES; + int64_t result = lines_of_resolution - STANDARD_RESOLUTION_LINES; result *= BITRATE_FOR_HIGH_RESOLUTION - BITRATE_FOR_STANDARD_RESOLUTION; result /= HIGH_RESOLUTION_LINES - STANDARD_RESOLUTION_LINES; result += BITRATE_FOR_STANDARD_RESOLUTION; diff --git a/media/cast/sender/video_sender_unittest.cc b/media/cast/sender/video_sender_unittest.cc index 60f15a5..af271da 100644 --- a/media/cast/sender/video_sender_unittest.cc +++ b/media/cast/sender/video_sender_unittest.cc @@ -30,7 +30,7 @@ namespace media { namespace cast { namespace { -static const uint8 kPixelValue = 123; +static const uint8_t kPixelValue = 123; static const int kWidth = 320; static const int kHeight = 240; @@ -73,7 +73,7 @@ class TestPacketSender : public PacketSender { return true; } - int64 GetBytesSent() final { return 0; } + int64_t GetBytesSent() final { return 0; } int number_of_rtp_packets() const { return number_of_rtp_packets_; } @@ -126,12 +126,8 @@ class PeerVideoSender : public VideoSender { scoped_refptr<VideoFrame> CreateFakeFrame(const gfx::Size& resolution, bool high_frame_rate_in_metadata) { const scoped_refptr<VideoFrame> frame = VideoFrame::WrapExternalData( - PIXEL_FORMAT_I420, - resolution, - gfx::Rect(resolution), - resolution, - static_cast<uint8*>(nullptr) + 1, - resolution.GetArea() * 3 / 2, + PIXEL_FORMAT_I420, resolution, gfx::Rect(resolution), resolution, + static_cast<uint8_t*>(nullptr) + 1, resolution.GetArea() * 3 / 2, base::TimeDelta()); const double frame_rate = high_frame_rate_in_metadata ? 60.0 : 30.0; frame->metadata()->SetTimeDelta( diff --git a/media/cast/sender/vp8_encoder.cc b/media/cast/sender/vp8_encoder.cc index a7298e7..bcb1378 100644 --- a/media/cast/sender/vp8_encoder.cc +++ b/media/cast/sender/vp8_encoder.cc @@ -229,8 +229,8 @@ void Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, TimeDeltaToRtpDelta(video_frame->timestamp(), kVideoFrequency); encoded_frame->reference_time = reference_time; encoded_frame->data.assign( - static_cast<const uint8*>(pkt->data.frame.buf), - static_cast<const uint8*>(pkt->data.frame.buf) + pkt->data.frame.sz); + static_cast<const uint8_t*>(pkt->data.frame.buf), + static_cast<const uint8_t*>(pkt->data.frame.buf) + pkt->data.frame.sz); break; // Done, since all data is provided in one CX_FRAME_PKT packet. } DCHECK(!encoded_frame->data.empty()) @@ -291,13 +291,13 @@ void Vp8Encoder::Encode(const scoped_refptr<media::VideoFrame>& video_frame, } } -void Vp8Encoder::UpdateRates(uint32 new_bitrate) { +void Vp8Encoder::UpdateRates(uint32_t new_bitrate) { DCHECK(thread_checker_.CalledOnValidThread()); if (!is_initialized()) return; - uint32 new_bitrate_kbit = new_bitrate / 1000; + uint32_t new_bitrate_kbit = new_bitrate / 1000; if (config_.rc_target_bitrate == new_bitrate_kbit) return; diff --git a/media/cast/sender/vp8_encoder.h b/media/cast/sender/vp8_encoder.h index c3d985f..ffb95e22 100644 --- a/media/cast/sender/vp8_encoder.h +++ b/media/cast/sender/vp8_encoder.h @@ -5,7 +5,6 @@ #ifndef MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ #define MEDIA_CAST_SENDER_CODECS_VP8_VP8_ENCODER_H_ -#include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/threading/thread_checker.h" #include "media/cast/cast_config.h" @@ -31,7 +30,7 @@ class Vp8Encoder : public SoftwareVideoEncoder { void Encode(const scoped_refptr<media::VideoFrame>& video_frame, const base::TimeTicks& reference_time, SenderEncodedFrame* encoded_frame) final; - void UpdateRates(uint32 new_bitrate) final; + void UpdateRates(uint32_t new_bitrate) final; void GenerateKeyFrame() final; private: @@ -66,7 +65,7 @@ class Vp8Encoder : public SoftwareVideoEncoder { base::TimeDelta last_frame_timestamp_; // The last encoded frame's ID. - uint32 last_encoded_frame_id_; + uint32_t last_encoded_frame_id_; // This is bound to the thread where Initialize() is called. base::ThreadChecker thread_checker_; diff --git a/media/cast/sender/vp8_quantizer_parser.cc b/media/cast/sender/vp8_quantizer_parser.cc index 167e7cc..0646efd 100644 --- a/media/cast/sender/vp8_quantizer_parser.cc +++ b/media/cast/sender/vp8_quantizer_parser.cc @@ -19,7 +19,7 @@ namespace { // necessary parts being exported. class Vp8BitReader { public: - Vp8BitReader(const uint8* data, size_t size) + Vp8BitReader(const uint8_t* data, size_t size) : encoded_data_(data), encoded_data_end_(data + size) { Vp8DecoderReadBytes(); } @@ -34,8 +34,8 @@ class Vp8BitReader { // Read new bytes frome the encoded data buffer until |bit_count_| > 0. void Vp8DecoderReadBytes(); - const uint8* encoded_data_; // Current byte to decode. - const uint8* const encoded_data_end_; // The end of the byte to decode. + const uint8_t* encoded_data_; // Current byte to decode. + const uint8_t* const encoded_data_end_; // The end of the byte to decode. // The following two variables are maintained by the decoder. // General decoding rule: // If |value_| is in the range of 0 to half of |range_|, output 0. @@ -53,7 +53,7 @@ class Vp8BitReader { }; // The number of bits to be left-shifted to make the variable range_ over 128. -const uint8 vp8_shift[128] = { +const uint8_t vp8_shift[128] = { 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, @@ -62,7 +62,7 @@ const uint8 vp8_shift[128] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // Mapping from the q_index(0-127) to the quantizer value(0-63). -const uint8 vp8_quantizer_lookup[128] = { +const uint8_t vp8_quantizer_lookup[128] = { 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 12, 13, 13, 14, 15, 16, 17, 18, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, @@ -167,7 +167,7 @@ void ParseFilterHeader(Vp8BitReader* bit_reader) { } } // unnamed namespace -int ParseVp8HeaderQuantizer(const uint8* encoded_data, size_t size) { +int ParseVp8HeaderQuantizer(const uint8_t* encoded_data, size_t size) { DCHECK(encoded_data); if (size <= 3) { return -1; @@ -198,7 +198,7 @@ int ParseVp8HeaderQuantizer(const uint8* encoded_data, size_t size) { // Parse the number of coefficient data partitions. bit_reader.DecodeValue(2); // Parse the base q_index. - uint8 q_index = static_cast<uint8>(bit_reader.DecodeValue(7)); + uint8_t q_index = static_cast<uint8_t>(bit_reader.DecodeValue(7)); if (q_index > 127) { return 63; } diff --git a/media/cast/sender/vp8_quantizer_parser.h b/media/cast/sender/vp8_quantizer_parser.h index abd0d5e..09b222b 100644 --- a/media/cast/sender/vp8_quantizer_parser.h +++ b/media/cast/sender/vp8_quantizer_parser.h @@ -12,7 +12,7 @@ namespace cast { // Partially parse / skip data in the header and the first partition, // and return the base quantizer in the range [0,63], or -1 on parse error. -int ParseVp8HeaderQuantizer(const uint8* data, size_t size); +int ParseVp8HeaderQuantizer(const uint8_t* data, size_t size); } // namespace cast } // namespace media diff --git a/media/cast/sender/vp8_quantizer_parser_unittest.cc b/media/cast/sender/vp8_quantizer_parser_unittest.cc index f028264..1c83cb1 100644 --- a/media/cast/sender/vp8_quantizer_parser_unittest.cc +++ b/media/cast/sender/vp8_quantizer_parser_unittest.cc @@ -84,14 +84,14 @@ class Vp8QuantizerParserTest : public ::testing::Test { TEST_F(Vp8QuantizerParserTest, InsufficientData) { for (int i = 0; i < 3; ++i) { scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); - const uint8* encoded_data = - reinterpret_cast<const uint8*>(encoded_frame->data.data()); + const uint8_t* encoded_data = + reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); // Null input. int decoded_quantizer = ParseVp8HeaderQuantizer(encoded_data, encoded_frame->data.size()); EXPECT_EQ(-1, decoded_quantizer); EncodeOneFrame(encoded_frame.get()); - encoded_data = reinterpret_cast<const uint8*>(encoded_frame->data.data()); + encoded_data = reinterpret_cast<const uint8_t*>(encoded_frame->data.data()); // Zero bytes should not be enough to decode the quantizer value. decoded_quantizer = ParseVp8HeaderQuantizer(encoded_data, 0); EXPECT_EQ(-1, decoded_quantizer); @@ -136,7 +136,7 @@ TEST_F(Vp8QuantizerParserTest, VariedQuantizer) { scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); EncodeOneFrame(encoded_frame.get()); decoded_quantizer = ParseVp8HeaderQuantizer( - reinterpret_cast<const uint8*>(encoded_frame->data.data()), + reinterpret_cast<const uint8_t*>(encoded_frame->data.data()), encoded_frame->data.size()); EXPECT_EQ(qp, decoded_quantizer); } diff --git a/media/cast/test/cast_benchmarks.cc b/media/cast/test/cast_benchmarks.cc index 19d5edf..81d0263 100644 --- a/media/cast/test/cast_benchmarks.cc +++ b/media/cast/test/cast_benchmarks.cc @@ -67,7 +67,7 @@ namespace cast { namespace { -static const int64 kStartMillisecond = INT64_C(1245); +static const int64_t kStartMillisecond = INT64_C(1245); static const int kTargetPlayoutDelayMs = 400; void UpdateCastTransportStatus(CastTransportStatus status) { @@ -95,8 +95,8 @@ class CastTransportSenderWrapper : public CastTransportSender { public: // Takes ownership of |transport|. void Init(CastTransportSender* transport, - uint64* encoded_video_bytes, - uint64* encoded_audio_bytes) { + uint64_t* encoded_video_bytes, + uint64_t* encoded_audio_bytes) { transport_.reset(transport); encoded_video_bytes_ = encoded_video_bytes; encoded_audio_bytes_ = encoded_audio_bytes; @@ -116,7 +116,7 @@ class CastTransportSenderWrapper : public CastTransportSender { transport_->InitializeVideo(config, cast_message_cb, rtt_cb); } - void InsertFrame(uint32 ssrc, const EncodedFrame& frame) final { + void InsertFrame(uint32_t ssrc, const EncodedFrame& frame) final { if (ssrc == audio_ssrc_) { *encoded_audio_bytes_ += frame.data.size(); } else if (ssrc == video_ssrc_) { @@ -125,20 +125,20 @@ class CastTransportSenderWrapper : public CastTransportSender { transport_->InsertFrame(ssrc, frame); } - 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 { transport_->SendSenderReport(ssrc, current_time, current_time_as_rtp_timestamp); } - void CancelSendingFrames(uint32 ssrc, - const std::vector<uint32>& frame_ids) final { + void CancelSendingFrames(uint32_t ssrc, + const std::vector<uint32_t>& frame_ids) final { transport_->CancelSendingFrames(ssrc, frame_ids); } - void ResendFrameForKickstart(uint32 ssrc, uint32 frame_id) final { + void ResendFrameForKickstart(uint32_t ssrc, uint32_t frame_id) final { transport_->ResendFrameForKickstart(ssrc, frame_id); } @@ -146,13 +146,13 @@ class CastTransportSenderWrapper : public CastTransportSender { return transport_->PacketReceiverForTesting(); } - void AddValidSsrc(uint32 ssrc) final { + void AddValidSsrc(uint32_t ssrc) final { return transport_->AddValidSsrc(ssrc); } 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, @@ -169,9 +169,9 @@ class CastTransportSenderWrapper : public CastTransportSender { private: scoped_ptr<CastTransportSender> transport_; - uint32 audio_ssrc_, video_ssrc_; - uint64* encoded_video_bytes_; - uint64* encoded_audio_bytes_; + uint32_t audio_ssrc_, video_ssrc_; + uint64_t* encoded_video_bytes_; + uint64_t* encoded_audio_bytes_; }; struct MeasuringPoint { @@ -490,8 +490,8 @@ class RunOneBenchmark { LoopBackTransport sender_to_receiver_; CastTransportSenderWrapper transport_sender_; scoped_ptr<CastTransportSender> transport_receiver_; - uint64 video_bytes_encoded_; - uint64 audio_bytes_encoded_; + uint64_t video_bytes_encoded_; + uint64_t audio_bytes_encoded_; scoped_ptr<CastReceiver> cast_receiver_; scoped_ptr<CastSender> cast_sender_; diff --git a/media/cast/test/end2end_unittest.cc b/media/cast/test/end2end_unittest.cc index 3228075..015833d 100644 --- a/media/cast/test/end2end_unittest.cc +++ b/media/cast/test/end2end_unittest.cc @@ -47,7 +47,7 @@ namespace cast { namespace { -static const int64 kStartMillisecond = INT64_C(1245); +static const int64_t kStartMillisecond = INT64_C(1245); static const int kAudioChannels = 2; static const double kSoundFrequency = 314.15926535897; // Freq of sine wave. static const float kSoundVolume = 0.5f; @@ -87,7 +87,7 @@ std::string ConvertFromBase16String(const std::string& base_16) { DCHECK_EQ(base_16.size() % 2, 0u) << "Must be a multiple of 2"; compressed.reserve(base_16.size() / 2); - std::vector<uint8> v; + std::vector<uint8_t> v; if (!base::HexStringToBytes(base_16, &v)) { NOTREACHED(); } @@ -135,13 +135,13 @@ std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( // Constructs a map from each packet (Packet ID) to counts of each event // type logged for that packet. -std::map<uint16, LoggingEventCounts> GetEventCountForPacketEvents( +std::map<uint16_t, LoggingEventCounts> GetEventCountForPacketEvents( const std::vector<PacketEvent>& packet_events) { - std::map<uint16, LoggingEventCounts> event_counter_for_packet; + std::map<uint16_t, LoggingEventCounts> event_counter_for_packet; for (std::vector<PacketEvent>::const_iterator it = packet_events.begin(); it != packet_events.end(); ++it) { - std::map<uint16, LoggingEventCounts>::iterator map_it = + std::map<uint16_t, LoggingEventCounts>::iterator map_it = event_counter_for_packet.find(it->packet_id); if (map_it == event_counter_for_packet.end()) { LoggingEventCounts new_counter; @@ -210,7 +210,7 @@ class LoopBackTransport : public PacketSender { bytes_sent_ += packet->data.size(); if (drop_packets_belonging_to_odd_frames_) { - uint32 frame_id = packet->data[13]; + uint32_t frame_id = packet->data[13]; if (frame_id % 2 == 1) return true; } @@ -220,7 +220,7 @@ class LoopBackTransport : public PacketSender { return true; } - int64 GetBytesSent() final { return bytes_sent_; } + int64_t GetBytesSent() final { return bytes_sent_; } void SetSendPackets(bool send_packets) { send_packets_ = send_packets; } @@ -239,7 +239,7 @@ class LoopBackTransport : public PacketSender { bool drop_packets_belonging_to_odd_frames_; scoped_refptr<CastEnvironment> cast_environment_; scoped_ptr<test::PacketPipe> packet_pipe_; - int64 bytes_sent_; + int64_t bytes_sent_; }; // Class that verifies the audio frames coming out of the receiver. @@ -316,20 +316,20 @@ class TestReceiverAudioCallback // Note: Just peeking here. Will delegate to CheckAudioFrame() to pop. // We need to "decode" the encoded audio frame. The codec is simply to - // swizzle the bytes of each int16 from host-->network-->host order to get - // interleaved int16 PCM. Then, make an AudioBus out of that. - const int num_elements = audio_frame->data.size() / sizeof(int16); + // swizzle the bytes of each int16_t from host-->network-->host order to get + // interleaved int16_t PCM. Then, make an AudioBus out of that. + const int num_elements = audio_frame->data.size() / sizeof(int16_t); ASSERT_EQ(expected_audio_frame.audio_bus->channels() * expected_audio_frame.audio_bus->frames(), num_elements); - int16* const pcm_data = - reinterpret_cast<int16*>(audio_frame->mutable_bytes()); + int16_t* const pcm_data = + reinterpret_cast<int16_t*>(audio_frame->mutable_bytes()); for (int i = 0; i < num_elements; ++i) - pcm_data[i] = static_cast<int16>(base::NetToHost16(pcm_data[i])); + pcm_data[i] = static_cast<int16_t>(base::NetToHost16(pcm_data[i])); scoped_ptr<AudioBus> audio_bus( AudioBus::Create(expected_audio_frame.audio_bus->channels(), expected_audio_frame.audio_bus->frames())); - audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16)); + audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16_t)); // Delegate the checking from here... CheckAudioFrame(audio_bus.Pass(), audio_frame->reference_time, true); @@ -1129,14 +1129,13 @@ TEST_F(End2EndTest, VideoLogging) { // Packet logging. // Verify that all packet related events were logged. event_subscriber_sender_.GetPacketEventsAndReset(&packet_events_); - std::map<uint16, LoggingEventCounts> event_count_for_packet = + std::map<uint16_t, LoggingEventCounts> event_count_for_packet = GetEventCountForPacketEvents(packet_events_); // Verify that each packet have the expected types of events logged. - for (std::map<uint16, LoggingEventCounts>::iterator map_it = + for (std::map<uint16_t, LoggingEventCounts>::iterator map_it = event_count_for_packet.begin(); - map_it != event_count_for_packet.end(); - ++map_it) { + map_it != event_count_for_packet.end(); ++map_it) { int total_event_count_for_packet = 0; for (int i = 0; i <= kNumOfLoggingEvents; ++i) { total_event_count_for_packet += map_it->second.counter[i]; @@ -1432,8 +1431,8 @@ TEST_F(End2EndTest, TestSetPlayoutDelay) { RunTasks(100 * kFrameTimerMs + 1); // Empty the pipeline. size_t jump = 0; for (size_t i = 1; i < video_ticks_.size(); i++) { - int64 delta = (video_ticks_[i].second - - video_ticks_[i-1].second).InMilliseconds(); + int64_t delta = + (video_ticks_[i].second - video_ticks_[i - 1].second).InMilliseconds(); if (delta > 100) { EXPECT_EQ(kNewDelay - kTargetPlayoutDelayMs + kFrameTimerMs, delta); EXPECT_EQ(0u, jump); diff --git a/media/cast/test/fake_media_source.cc b/media/cast/test/fake_media_source.cc index 24327d0..3c7a8e0 100644 --- a/media/cast/test/fake_media_source.cc +++ b/media/cast/test/fake_media_source.cc @@ -45,14 +45,13 @@ void AVFreeFrame(AVFrame* frame) { av_frame_free(&frame); } -base::TimeDelta PtsToTimeDelta(int64 pts, const AVRational& time_base) { +base::TimeDelta PtsToTimeDelta(int64_t pts, const AVRational& time_base) { return pts * base::TimeDelta::FromSeconds(1) * time_base.num / time_base.den; } -int64 TimeDeltaToPts(base::TimeDelta delta, const AVRational& time_base) { - return static_cast<int64>( - delta.InSecondsF() * time_base.den / time_base.num + - 0.5 /* rounding */); +int64_t TimeDeltaToPts(base::TimeDelta delta, const AVRational& time_base) { + return static_cast<int64_t>( + delta.InSecondsF() * time_base.den / time_base.num + 0.5 /* rounding */); } } // namespace @@ -542,7 +541,7 @@ void FakeMediaSource::DecodeVideo(ScopedAVPacket packet) { const AVRational& frame_rate = av_video_stream()->r_frame_rate; timestamp = last_video_frame_timestamp_ + (base::TimeDelta::FromSeconds(1) * frame_rate.den / frame_rate.num); - const int64 adjustment_pts = TimeDeltaToPts(timestamp, time_base); + const int64_t adjustment_pts = TimeDeltaToPts(timestamp, time_base); video_first_pts_ = avframe->pkt_pts - adjustment_pts; } diff --git a/media/cast/test/fake_media_source.h b/media/cast/test/fake_media_source.h index 3ca55a0..af100aa 100644 --- a/media/cast/test/fake_media_source.h +++ b/media/cast/test/fake_media_source.h @@ -121,7 +121,7 @@ class FakeMediaSource : public media::AudioConverter::InputCallback { base::TimeTicks next_frame_size_change_time_; scoped_refptr<AudioFrameInput> audio_frame_input_; scoped_refptr<VideoFrameInput> video_frame_input_; - uint8 synthetic_count_; + uint8_t synthetic_count_; base::TickClock* const clock_; // Not owned by this class. // Time when the stream starts. @@ -156,7 +156,7 @@ class FakeMediaSource : public media::AudioConverter::InputCallback { std::queue<scoped_refptr<VideoFrame> > video_frame_queue_; std::queue<scoped_refptr<VideoFrame> > inserted_video_frame_queue_; - int64 video_first_pts_; + int64_t video_first_pts_; bool video_first_pts_set_; base::TimeDelta last_video_frame_timestamp_; diff --git a/media/cast/test/fake_single_thread_task_runner.h b/media/cast/test/fake_single_thread_task_runner.h index c6fb02e..bae0507 100644 --- a/media/cast/test/fake_single_thread_task_runner.h +++ b/media/cast/test/fake_single_thread_task_runner.h @@ -7,7 +7,6 @@ #include <map> -#include "base/basictypes.h" #include "base/single_thread_task_runner.h" #include "base/test/simple_test_tick_clock.h" #include "base/test/test_pending_task.h" diff --git a/media/cast/test/loopback_transport.cc b/media/cast/test/loopback_transport.cc index 7c71d58..fe1b78a8 100644 --- a/media/cast/test/loopback_transport.cc +++ b/media/cast/test/loopback_transport.cc @@ -53,7 +53,7 @@ bool LoopBackTransport::SendPacket(PacketRef packet, return true; } -int64 LoopBackTransport::GetBytesSent() { +int64_t LoopBackTransport::GetBytesSent() { return bytes_sent_; } diff --git a/media/cast/test/loopback_transport.h b/media/cast/test/loopback_transport.h index 478004c..52eeb47 100644 --- a/media/cast/test/loopback_transport.h +++ b/media/cast/test/loopback_transport.h @@ -31,7 +31,7 @@ class LoopBackTransport : public PacketSender { bool SendPacket(PacketRef packet, const base::Closure& cb) final; - int64 GetBytesSent() final; + int64_t GetBytesSent() final; // Initiailize this loopback transport. // Establish a flow of packets from |pipe| to |packet_receiver|. @@ -50,7 +50,7 @@ class LoopBackTransport : public PacketSender { private: const scoped_refptr<CastEnvironment> cast_environment_; scoped_ptr<test::PacketPipe> packet_pipe_; - int64 bytes_sent_; + int64_t bytes_sent_; DISALLOW_COPY_AND_ASSIGN(LoopBackTransport); }; diff --git a/media/cast/test/receiver.cc b/media/cast/test/receiver.cc index ed069b6..94eb86c 100644 --- a/media/cast/test/receiver.cc +++ b/media/cast/test/receiver.cc @@ -65,14 +65,14 @@ const char* kVideoWindowWidth = "1280"; const char* kVideoWindowHeight = "720"; #endif // defined(USE_X11) -void GetPorts(uint16* tx_port, uint16* rx_port) { +void GetPorts(uint16_t* tx_port, uint16_t* rx_port) { test::InputBuilder tx_input( "Enter send port.", DEFAULT_SEND_PORT, 1, 65535); - *tx_port = static_cast<uint16>(tx_input.GetIntInput()); + *tx_port = static_cast<uint16_t>(tx_input.GetIntInput()); test::InputBuilder rx_input( "Enter receive port.", DEFAULT_RECEIVE_PORT, 1, 65535); - *rx_port = static_cast<uint16>(rx_input.GetIntInput()); + *rx_port = static_cast<uint16_t>(rx_input.GetIntInput()); } std::string GetIpAddress(const std::string& display_text) { @@ -273,10 +273,10 @@ class NaivePlayer : public InProcessReceiver, << "Video: Discontinuity in received frames."; video_playout_queue_.push_back(std::make_pair(playout_time, video_frame)); ScheduleVideoPlayout(); - uint16 frame_no; + uint16_t frame_no; if (media::cast::test::DecodeBarcode(video_frame, &frame_no)) { video_play_times_.insert( - std::pair<uint16, base::TimeTicks>(frame_no, playout_time)); + std::pair<uint16_t, base::TimeTicks>(frame_no, playout_time)); } else { VLOG(2) << "Barcode decode failed!"; } @@ -289,7 +289,7 @@ class NaivePlayer : public InProcessReceiver, LOG_IF(WARNING, !is_continuous) << "Audio: Discontinuity in received frames."; base::AutoLock auto_lock(audio_lock_); - uint16 frame_no; + uint16_t frame_no; if (media::cast::DecodeTimestamp(audio_frame->channel(0), audio_frame->frames(), &frame_no)) { @@ -299,7 +299,7 @@ class NaivePlayer : public InProcessReceiver, // that we already missed the first one. if (is_continuous && frame_no == last_audio_frame_no_ + 1) { audio_play_times_.insert( - std::pair<uint16, base::TimeTicks>(frame_no, playout_time)); + std::pair<uint16_t, base::TimeTicks>(frame_no, playout_time)); } last_audio_frame_no_ = frame_no; } else { @@ -476,7 +476,7 @@ class NaivePlayer : public InProcessReceiver, audio_play_times_.size() > 30) { size_t num_events = 0; base::TimeDelta delta; - std::map<uint16, base::TimeTicks>::iterator audio_iter, video_iter; + std::map<uint16_t, base::TimeTicks>::iterator audio_iter, video_iter; for (video_iter = video_play_times_.begin(); video_iter != video_play_times_.end(); ++video_iter) { @@ -517,7 +517,7 @@ class NaivePlayer : public InProcessReceiver, VideoQueueEntry; std::deque<VideoQueueEntry> video_playout_queue_; base::TimeTicks last_popped_video_playout_time_; - int64 num_video_frames_processed_; + int64_t num_video_frames_processed_; base::OneShotTimer video_playout_timer_; @@ -526,15 +526,15 @@ class NaivePlayer : public InProcessReceiver, typedef std::pair<base::TimeTicks, AudioBus*> AudioQueueEntry; std::deque<AudioQueueEntry> audio_playout_queue_; base::TimeTicks last_popped_audio_playout_time_; - int64 num_audio_frames_processed_; + int64_t num_audio_frames_processed_; // These must only be used on the audio thread calling OnMoreData(). scoped_ptr<AudioBus> currently_playing_audio_frame_; int currently_playing_audio_frame_start_; - std::map<uint16, base::TimeTicks> audio_play_times_; - std::map<uint16, base::TimeTicks> video_play_times_; - int32 last_audio_frame_no_; + std::map<uint16_t, base::TimeTicks> audio_play_times_; + std::map<uint16_t, base::TimeTicks> video_play_times_; + int32_t last_audio_frame_no_; }; } // namespace cast @@ -560,7 +560,7 @@ int main(int argc, char** argv) { media::cast::GetVideoReceiverConfig(); // Determine local and remote endpoints. - uint16 remote_port, local_port; + uint16_t remote_port, local_port; media::cast::GetPorts(&remote_port, &local_port); if (!local_port) { LOG(ERROR) << "Invalid local port."; diff --git a/media/cast/test/sender.cc b/media/cast/test/sender.cc index 5791ffe..6f46222 100644 --- a/media/cast/test/sender.cc +++ b/media/cast/test/sender.cc @@ -76,7 +76,7 @@ void QuitLoopOnInitializationResult(media::cast::OperationalStatus result) { base::MessageLoop::current()->QuitWhenIdle(); } -net::IPEndPoint CreateUDPAddress(const std::string& ip_str, uint16 port) { +net::IPEndPoint CreateUDPAddress(const std::string& ip_str, uint16_t port) { net::IPAddressNumber ip_number; CHECK(net::ParseIPLiteralToNumber(ip_str, &ip_number)); return net::IPEndPoint(ip_number, port); @@ -202,7 +202,7 @@ int main(int argc, char** argv) { // Running transport on the main thread. // Setting up transport config. net::IPEndPoint remote_endpoint = - CreateUDPAddress(remote_ip_address, static_cast<uint16>(remote_port)); + CreateUDPAddress(remote_ip_address, static_cast<uint16_t>(remote_port)); // Enable raw event and stats logging. // Running transport on the main thread. diff --git a/media/cast/test/simulator.cc b/media/cast/test/simulator.cc index f63a797..b486648 100644 --- a/media/cast/test/simulator.cc +++ b/media/cast/test/simulator.cc @@ -528,9 +528,9 @@ void RunSimulation(const base::FilePath& source_path, int encoded_video_frames = 0; int dropped_video_frames = 0; int late_video_frames = 0; - int64 total_delay_of_late_frames_ms = 0; - int64 encoded_size = 0; - int64 target_bitrate = 0; + int64_t total_delay_of_late_frames_ms = 0; + int64_t encoded_size = 0; + int64_t target_bitrate = 0; for (size_t i = 0; i < video_frame_events.size(); ++i) { const media::cast::proto::AggregatedFrameEvent& event = *video_frame_events[i]; diff --git a/media/cast/test/skewed_single_thread_task_runner.h b/media/cast/test/skewed_single_thread_task_runner.h index 666a348..b3b0c92 100644 --- a/media/cast/test/skewed_single_thread_task_runner.h +++ b/media/cast/test/skewed_single_thread_task_runner.h @@ -7,7 +7,6 @@ #include <map> -#include "base/basictypes.h" #include "base/single_thread_task_runner.h" #include "base/test/simple_test_tick_clock.h" #include "base/test/test_pending_task.h" diff --git a/media/cast/test/utility/audio_utility.cc b/media/cast/test/utility/audio_utility.cc index 41ecd15..348b692 100644 --- a/media/cast/test/utility/audio_utility.cc +++ b/media/cast/test/utility/audio_utility.cc @@ -4,7 +4,6 @@ #include <cmath> -#include "base/basictypes.h" #include "base/logging.h" #include "base/time/time.h" #include "media/base/audio_bus.h" @@ -93,7 +92,7 @@ const size_t kSamplesToAnalyze = kSamplingFrequency / kBaseFrequency; const double kSenseFrequency = kBaseFrequency * (kNumBits + 1); const double kMinSense = 1.5; -bool EncodeTimestamp(uint16 timestamp, +bool EncodeTimestamp(uint16_t timestamp, size_t sample_offset, size_t length, float* samples) { @@ -147,7 +146,7 @@ double DecodeOneFrequency(const float* samples, // each of the bits. Each frequency must have a strength that is similar to // the sense frequency or to zero, or the decoding fails. If it fails, we // move head by 60 samples and try again until we run out of samples. -bool DecodeTimestamp(const float* samples, size_t length, uint16* timestamp) { +bool DecodeTimestamp(const float* samples, size_t length, uint16_t* timestamp) { for (size_t start = 0; start + kSamplesToAnalyze <= length; start += kSamplesToAnalyze / 4) { @@ -156,7 +155,7 @@ bool DecodeTimestamp(const float* samples, size_t length, uint16* timestamp) { kSenseFrequency); if (sense < kMinSense) continue; bool success = true; - uint16 gray_coded = 0; + uint16_t gray_coded = 0; for (size_t bit = 0; success && bit < kNumBits; bit++) { double signal_strength = DecodeOneFrequency( &samples[start], @@ -174,7 +173,7 @@ bool DecodeTimestamp(const float* samples, size_t length, uint16* timestamp) { } if (success) { // Convert from gray-coded number to binary. - uint16 mask; + uint16_t mask; for (mask = gray_coded >> 1; mask != 0; mask = mask >> 1) { gray_coded = gray_coded ^ mask; } diff --git a/media/cast/test/utility/audio_utility.h b/media/cast/test/utility/audio_utility.h index 36ef858..f2362e6 100644 --- a/media/cast/test/utility/audio_utility.h +++ b/media/cast/test/utility/audio_utility.h @@ -67,14 +67,14 @@ int CountZeroCrossings(const float* samples, int length); // contain how many samples has been encoded so far, so that we can make smooth // transitions between encoded chunks. // See audio_utility.cc for details on how the encoding is done. -bool EncodeTimestamp(uint16 timestamp, +bool EncodeTimestamp(uint16_t timestamp, size_t sample_offset, size_t length, float* samples); // Decode a timestamp encoded with EncodeTimestamp. Returns true if a // timestamp was found in |samples|. -bool DecodeTimestamp(const float* samples, size_t length, uint16* timestamp); +bool DecodeTimestamp(const float* samples, size_t length, uint16_t* timestamp); } // namespace cast } // namespace media diff --git a/media/cast/test/utility/audio_utility_unittest.cc b/media/cast/test/utility/audio_utility_unittest.cc index 951d676..47d1ad0 100644 --- a/media/cast/test/utility/audio_utility_unittest.cc +++ b/media/cast/test/utility/audio_utility_unittest.cc @@ -13,9 +13,9 @@ namespace { TEST(AudioTimestampTest, Small) { std::vector<float> samples(480); - for (int32 in_timestamp = 0; in_timestamp < 65536; in_timestamp += 177) { + for (int32_t in_timestamp = 0; in_timestamp < 65536; in_timestamp += 177) { EncodeTimestamp(in_timestamp, 0, samples.size(), &samples.front()); - uint16 out_timestamp; + uint16_t out_timestamp; EXPECT_TRUE( DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); ASSERT_EQ(in_timestamp, out_timestamp); @@ -24,7 +24,7 @@ TEST(AudioTimestampTest, Small) { TEST(AudioTimestampTest, Negative) { std::vector<float> samples(480); - uint16 out_timestamp; + uint16_t out_timestamp; EXPECT_FALSE( DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); } @@ -33,7 +33,7 @@ TEST(AudioTimestampTest, CheckPhase) { std::vector<float> samples(4800); EncodeTimestamp(4711, 0, samples.size(), &samples.front()); while (samples.size() > 240) { - uint16 out_timestamp; + uint16_t out_timestamp; EXPECT_TRUE( DecodeTimestamp(&samples.front(), samples.size(), &out_timestamp)); ASSERT_EQ(4711, out_timestamp); diff --git a/media/cast/test/utility/generate_barcode_video.cc b/media/cast/test/utility/generate_barcode_video.cc index e917ecd..774706d 100644 --- a/media/cast/test/utility/generate_barcode_video.cc +++ b/media/cast/test/utility/generate_barcode_video.cc @@ -29,11 +29,11 @@ int main(int argc, char **argv) { int width = atoi(argv[1]); int height = atoi(argv[2]); int fps = atoi(argv[3]); - uint16 wanted_frames = atoi(argv[4]); + uint16_t wanted_frames = atoi(argv[4]); scoped_refptr<media::VideoFrame> frame = media::VideoFrame::CreateBlackFrame(gfx::Size(width, height)); printf("YUV4MPEG2 W%d H%d F%d:1 Ip C420mpeg2\n", width, height, fps); - for (uint16 frame_id = 1; frame_id <= wanted_frames; frame_id++) { + for (uint16_t frame_id = 1; frame_id <= wanted_frames; frame_id++) { CHECK(media::cast::test::EncodeBarcode(frame_id, frame)); printf("FRAME\n"); DumpPlane(frame, media::VideoFrame::kYPlane); diff --git a/media/cast/test/utility/net_utility.cc b/media/cast/test/utility/net_utility.cc index c146d9a..9515f1d 100644 --- a/media/cast/test/utility/net_utility.cc +++ b/media/cast/test/utility/net_utility.cc @@ -4,7 +4,6 @@ #include "media/cast/test/utility/net_utility.h" -#include "base/basictypes.h" #include "net/base/net_errors.h" #include "net/udp/udp_server_socket.h" diff --git a/media/cast/test/utility/tap_proxy.cc b/media/cast/test/utility/tap_proxy.cc index 7bd696b..43125f5 100644 --- a/media/cast/test/utility/tap_proxy.cc +++ b/media/cast/test/utility/tap_proxy.cc @@ -151,16 +151,16 @@ class ByteCounter { return packets / time_range().InSecondsF(); } - void Increment(uint64 x) { + void Increment(uint64_t x) { bytes_ += x; packets_ ++; } private: - uint64 bytes_; - uint64 packets_; - std::deque<uint64> byte_data_; - std::deque<uint64> packet_data_; + uint64_t bytes_; + uint64_t packets_; + std::deque<uint64_t> byte_data_; + std::deque<uint64_t> packet_data_; std::deque<base::TimeTicks> time_data_; }; diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc index 19191ed..088ebc9 100644 --- a/media/cast/test/utility/udp_proxy.cc +++ b/media/cast/test/utility/udp_proxy.cc @@ -72,7 +72,7 @@ class Buffer : public PacketPipe { last_schedule_ = clock_->NowTicks(); double megabits = buffer_.front()->size() * 8 / 1000000.0; double seconds = megabits / max_megabits_per_second_; - int64 microseconds = static_cast<int64>(seconds * 1E6); + int64_t microseconds = static_cast<int64_t>(seconds * 1E6); task_runner_->PostDelayedTask( FROM_HERE, base::Bind(&Buffer::ProcessBuffer, weak_factory_.GetWeakPtr()), @@ -80,14 +80,14 @@ class Buffer : public PacketPipe { } void ProcessBuffer() { - int64 bytes_to_send = static_cast<int64>( + int64_t bytes_to_send = static_cast<int64_t>( (clock_->NowTicks() - last_schedule_).InSecondsF() * max_megabits_per_second_ * 1E6 / 8); - if (bytes_to_send < static_cast<int64>(buffer_.front()->size())) { + if (bytes_to_send < static_cast<int64_t>(buffer_.front()->size())) { bytes_to_send = buffer_.front()->size(); } while (!buffer_.empty() && - static_cast<int64>(buffer_.front()->size()) <= bytes_to_send) { + static_cast<int64_t>(buffer_.front()->size()) <= bytes_to_send) { CHECK(!buffer_.empty()); scoped_ptr<Packet> packet(buffer_.front().release()); bytes_to_send -= packet->size(); @@ -140,10 +140,9 @@ class SimpleDelayBase : public PacketPipe { double seconds = GetDelay(); task_runner_->PostDelayedTask( FROM_HERE, - base::Bind(&SimpleDelayBase::SendInternal, - weak_factory_.GetWeakPtr(), + base::Bind(&SimpleDelayBase::SendInternal, weak_factory_.GetWeakPtr(), base::Passed(&packet)), - base::TimeDelta::FromMicroseconds(static_cast<int64>(seconds * 1E6))); + base::TimeDelta::FromMicroseconds(static_cast<int64_t>(seconds * 1E6))); } protected: virtual double GetDelay() = 0; @@ -239,7 +238,7 @@ class RandomSortedDelay : public PacketPipe { private: void ScheduleExtraDelay(double mult) { double seconds = seconds_between_extra_delay_ * mult * base::RandDouble(); - int64 microseconds = static_cast<int64>(seconds * 1E6); + int64_t microseconds = static_cast<int64_t>(seconds * 1E6); task_runner_->PostDelayedTask( FROM_HERE, base::Bind(&RandomSortedDelay::CauseExtraDelay, @@ -249,9 +248,8 @@ class RandomSortedDelay : public PacketPipe { void CauseExtraDelay() { next_send_ = std::max<base::TimeTicks>( - clock_->NowTicks() + - base::TimeDelta::FromMicroseconds( - static_cast<int64>(extra_delay_ * 1E6)), + clock_->NowTicks() + base::TimeDelta::FromMicroseconds( + static_cast<int64_t>(extra_delay_ * 1E6)), next_send_); // An extra delay just happened, wait up to seconds_between_extra_delay_*2 // before scheduling another one to make the average equal to @@ -324,7 +322,7 @@ class NetworkGlitchPipe : public PacketPipe { works_ = !works_; double seconds = base::RandDouble() * (works_ ? max_work_time_ : max_outage_time_); - int64 microseconds = static_cast<int64>(seconds * 1E6); + int64_t microseconds = static_cast<int64_t>(seconds * 1E6); task_runner_->PostDelayedTask( FROM_HERE, base::Bind(&NetworkGlitchPipe::Flip, weak_factory_.GetWeakPtr()), @@ -415,7 +413,7 @@ InterruptedPoissonProcess::InterruptedPoissonProcess( const std::vector<double>& average_rates, double coef_burstiness, double coef_variance, - uint32 rand_seed) + uint32_t rand_seed) : clock_(NULL), average_rates_(average_rates), coef_burstiness_(coef_burstiness), @@ -462,7 +460,7 @@ base::TimeDelta InterruptedPoissonProcess::NextEvent(double rate) { double InterruptedPoissonProcess::RandDouble() { // Generate a 64-bits random number from MT19937 and then convert // it to double. - uint64 rand = mt_rand_.genrand_int32(); + uint64_t rand = mt_rand_.genrand_int32(); rand <<= 32; rand |= mt_rand_.genrand_int32(); return base::BitsToOpenEndedUnitInterval(rand); diff --git a/media/cast/test/utility/udp_proxy.h b/media/cast/test/utility/udp_proxy.h index bf95341..7fda438 100644 --- a/media/cast/test/utility/udp_proxy.h +++ b/media/cast/test/utility/udp_proxy.h @@ -7,7 +7,6 @@ #include <vector> -#include "base/basictypes.h" #include "base/memory/linked_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" @@ -54,11 +53,10 @@ class PacketPipe { // The rate above is the average rate of a poisson distribution. class InterruptedPoissonProcess { public: - InterruptedPoissonProcess( - const std::vector<double>& average_rates, - double coef_burstiness, - double coef_variance, - uint32 rand_seed); + InterruptedPoissonProcess(const std::vector<double>& average_rates, + double coef_burstiness, + double coef_variance, + uint32_t rand_seed); ~InterruptedPoissonProcess(); scoped_ptr<PacketPipe> NewBuffer(size_t size); diff --git a/media/cast/test/utility/udp_proxy_main.cc b/media/cast/test/utility/udp_proxy_main.cc index 439b079..8c2e7cf4 100644 --- a/media/cast/test/utility/udp_proxy_main.cc +++ b/media/cast/test/utility/udp_proxy_main.cc @@ -48,16 +48,16 @@ class ByteCounter { return packets / time_range().InSecondsF(); } - void Increment(uint64 x) { + void Increment(uint64_t x) { bytes_ += x; packets_ ++; } private: - uint64 bytes_; - uint64 packets_; - std::deque<uint64> byte_data_; - std::deque<uint64> packet_data_; + uint64_t bytes_; + uint64_t packets_; + std::deque<uint64_t> byte_data_; + std::deque<uint64_t> packet_data_; std::deque<base::TimeTicks> time_data_; }; @@ -161,9 +161,9 @@ int main(int argc, char** argv) { exit(1); } net::IPEndPoint remote_endpoint(remote_ip_number, - static_cast<uint16>(remote_port)); + static_cast<uint16_t>(remote_port)); net::IPEndPoint local_endpoint(local_ip_number, - static_cast<uint16>(local_port)); + static_cast<uint16_t>(local_port)); scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; scoped_ptr<media::cast::test::InterruptedPoissonProcess> ipp( media::cast::test::DefaultInterruptedPoissonProcess()); diff --git a/media/cast/test/utility/video_utility.cc b/media/cast/test/utility/video_utility.cc index a11de5f..a63d7cf 100644 --- a/media/cast/test/utility/video_utility.cc +++ b/media/cast/test/utility/video_utility.cc @@ -66,12 +66,12 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { // Set Y. const int height = frame_size.height(); const int stride_y = frame->stride(VideoFrame::kYPlane); - uint8* y_plane = frame->data(VideoFrame::kYPlane); + uint8_t* y_plane = frame->data(VideoFrame::kYPlane); for (int j = 0; j < height; ++j) { const int stripe_j = (j / stripe_size) * stripe_size; for (int i = 0; i < stride_y; ++i) { const int stripe_i = (i / stripe_size) * stripe_size; - *y_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); + *y_plane = static_cast<uint8_t>(start_value + stripe_i + stripe_j); ++y_plane; } } @@ -79,7 +79,7 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { const int half_height = (height + 1) / 2; if (frame->format() == PIXEL_FORMAT_NV12) { const int stride_uv = frame->stride(VideoFrame::kUVPlane); - uint8* uv_plane = frame->data(VideoFrame::kUVPlane); + uint8_t* uv_plane = frame->data(VideoFrame::kUVPlane); // Set U and V. for (int j = 0; j < half_height; ++j) { @@ -87,7 +87,7 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { for (int i = 0; i < stride_uv; i += 2) { const int stripe_i = (i / stripe_size) * stripe_size; *uv_plane = *(uv_plane + 1) = - static_cast<uint8>(start_value + stripe_i + stripe_j); + static_cast<uint8_t>(start_value + stripe_i + stripe_j); uv_plane += 2; } } @@ -96,15 +96,15 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { frame->format() == PIXEL_FORMAT_YV12); const int stride_u = frame->stride(VideoFrame::kUPlane); const int stride_v = frame->stride(VideoFrame::kVPlane); - uint8* u_plane = frame->data(VideoFrame::kUPlane); - uint8* v_plane = frame->data(VideoFrame::kVPlane); + uint8_t* u_plane = frame->data(VideoFrame::kUPlane); + uint8_t* v_plane = frame->data(VideoFrame::kVPlane); // Set U. for (int j = 0; j < half_height; ++j) { const int stripe_j = (j / stripe_size) * stripe_size; for (int i = 0; i < stride_u; ++i) { const int stripe_i = (i / stripe_size) * stripe_size; - *u_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); + *u_plane = static_cast<uint8_t>(start_value + stripe_i + stripe_j); ++u_plane; } } @@ -114,7 +114,7 @@ void PopulateVideoFrame(VideoFrame* frame, int start_value) { const int stripe_j = (j / stripe_size) * stripe_size; for (int i = 0; i < stride_v; ++i) { const int stripe_i = (i / stripe_size) * stripe_size; - *v_plane = static_cast<uint8>(start_value + stripe_i + stripe_j); + *v_plane = static_cast<uint8_t>(start_value + stripe_i + stripe_j); ++v_plane; } } @@ -127,9 +127,9 @@ void PopulateVideoFrameWithNoise(VideoFrame* frame) { const int stride_u = frame->stride(VideoFrame::kUPlane); const int stride_v = frame->stride(VideoFrame::kVPlane); const int half_height = (height + 1) / 2; - uint8* const y_plane = frame->data(VideoFrame::kYPlane); - uint8* const u_plane = frame->data(VideoFrame::kUPlane); - uint8* const v_plane = frame->data(VideoFrame::kVPlane); + uint8_t* const y_plane = frame->data(VideoFrame::kYPlane); + uint8_t* const u_plane = frame->data(VideoFrame::kUPlane); + uint8_t* const v_plane = frame->data(VideoFrame::kVPlane); base::RandBytes(y_plane, height * stride_y); base::RandBytes(u_plane, half_height * stride_u); @@ -142,11 +142,11 @@ bool PopulateVideoFrameFromFile(VideoFrame* frame, FILE* video_file) { const int half_width = (width + 1) / 2; const int half_height = (height + 1) / 2; const size_t frame_size = width * height + 2 * half_width * half_height; - uint8* const y_plane = frame->data(VideoFrame::kYPlane); - uint8* const u_plane = frame->data(VideoFrame::kUPlane); - uint8* const v_plane = frame->data(VideoFrame::kVPlane); + uint8_t* const y_plane = frame->data(VideoFrame::kYPlane); + uint8_t* const u_plane = frame->data(VideoFrame::kUPlane); + uint8_t* const v_plane = frame->data(VideoFrame::kVPlane); - uint8* const raw_data = new uint8[frame_size]; + uint8_t* const raw_data = new uint8_t[frame_size]; const size_t count = fread(raw_data, 1, frame_size, video_file); if (count != frame_size) return false; |