diff --git a/talk/app/webrtc/androidvideocapturer.cc b/talk/app/webrtc/androidvideocapturer.cc index 618fcb30ce..0ee60c2cf7 100644 --- a/talk/app/webrtc/androidvideocapturer.cc +++ b/talk/app/webrtc/androidvideocapturer.cc @@ -50,13 +50,13 @@ class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory { captured_frame_.pixel_width = 1; captured_frame_.data = nullptr; captured_frame_.data_size = cricket::CapturedFrame::kUnknownDataSize; - captured_frame_.fourcc = static_cast(cricket::FOURCC_ANY); + captured_frame_.fourcc = static_cast(cricket::FOURCC_ANY); } void UpdateCapturedFrame( const rtc::scoped_refptr& buffer, int rotation, - int64 time_stamp_in_ns) { + int64_t time_stamp_in_ns) { buffer_ = buffer; captured_frame_.width = buffer->width(); captured_frame_.height = buffer->height(); @@ -169,7 +169,7 @@ bool AndroidVideoCapturer::IsRunning() { return running_; } -bool AndroidVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { +bool AndroidVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { RTC_CHECK(thread_checker_.CalledOnValidThread()); fourccs->push_back(cricket::FOURCC_YV12); return true; @@ -192,7 +192,7 @@ void AndroidVideoCapturer::OnCapturerStarted(bool success) { void AndroidVideoCapturer::OnIncomingFrame( rtc::scoped_refptr buffer, int rotation, - int64 time_stamp) { + int64_t time_stamp) { RTC_CHECK(thread_checker_.CalledOnValidThread()); frame_factory_->UpdateCapturedFrame(buffer, rotation, time_stamp); SignalFrameCaptured(this, frame_factory_->GetCapturedFrame()); diff --git a/talk/app/webrtc/androidvideocapturer.h b/talk/app/webrtc/androidvideocapturer.h index ad45004eeb..fdc86290bb 100644 --- a/talk/app/webrtc/androidvideocapturer.h +++ b/talk/app/webrtc/androidvideocapturer.h @@ -69,7 +69,7 @@ class AndroidVideoCapturer : public cricket::VideoCapturer { // Argument |buffer| is intentionally by value, for use with rtc::Bind. void OnIncomingFrame(rtc::scoped_refptr buffer, int rotation, - int64 time_stamp); + int64_t time_stamp); // Called from JNI to request a new video format. void OnOutputFormatRequest(int width, int height, int fps); @@ -89,7 +89,7 @@ class AndroidVideoCapturer : public cricket::VideoCapturer { void Stop() override; bool IsRunning() override; bool IsScreencast() const override { return false; } - bool GetPreferredFourccs(std::vector* fourccs) override; + bool GetPreferredFourccs(std::vector* fourccs) override; bool running_; rtc::scoped_refptr delegate_; diff --git a/talk/app/webrtc/datachannel.cc b/talk/app/webrtc/datachannel.cc index 690ee65d3b..2028dc9f03 100644 --- a/talk/app/webrtc/datachannel.cc +++ b/talk/app/webrtc/datachannel.cc @@ -193,7 +193,7 @@ bool DataChannel::reliable() const { } } -uint64 DataChannel::buffered_amount() const { +uint64_t DataChannel::buffered_amount() const { return queued_send_data_.byte_count(); } @@ -239,7 +239,7 @@ bool DataChannel::Send(const DataBuffer& buffer) { return true; } -void DataChannel::SetReceiveSsrc(uint32 receive_ssrc) { +void DataChannel::SetReceiveSsrc(uint32_t receive_ssrc) { ASSERT(data_channel_type_ == cricket::DCT_RTP); if (receive_ssrc_set_) { @@ -276,7 +276,7 @@ void DataChannel::OnTransportChannelCreated() { } } -void DataChannel::SetSendSsrc(uint32 send_ssrc) { +void DataChannel::SetSendSsrc(uint32_t send_ssrc) { ASSERT(data_channel_type_ == cricket::DCT_RTP); if (send_ssrc_set_) { return; @@ -304,7 +304,7 @@ void DataChannel::OnDataEngineClose() { void DataChannel::OnDataReceived(cricket::DataChannel* channel, const cricket::ReceiveDataParams& params, const rtc::Buffer& payload) { - uint32 expected_ssrc = + uint32_t expected_ssrc = (data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id; if (params.ssrc != expected_ssrc) { return; @@ -476,7 +476,7 @@ void DataChannel::SendQueuedDataMessages() { ASSERT(state_ == kOpen || state_ == kClosing); - uint64 start_buffered_amount = buffered_amount(); + uint64_t start_buffered_amount = buffered_amount(); while (!queued_send_data_.Empty()) { DataBuffer* buffer = queued_send_data_.Front(); if (!SendDataMessage(*buffer, false)) { diff --git a/talk/app/webrtc/datachannel.h b/talk/app/webrtc/datachannel.h index 8e58d0664b..4506f71b14 100644 --- a/talk/app/webrtc/datachannel.h +++ b/talk/app/webrtc/datachannel.h @@ -114,16 +114,14 @@ class DataChannel : public DataChannelInterface, virtual std::string label() const { return label_; } virtual bool reliable() const; virtual bool ordered() const { return config_.ordered; } - virtual uint16 maxRetransmitTime() const { + virtual uint16_t maxRetransmitTime() const { return config_.maxRetransmitTime; } - virtual uint16 maxRetransmits() const { - return config_.maxRetransmits; - } + virtual uint16_t maxRetransmits() const { return config_.maxRetransmits; } virtual std::string protocol() const { return config_.protocol; } virtual bool negotiated() const { return config_.negotiated; } virtual int id() const { return config_.id; } - virtual uint64 buffered_amount() const; + virtual uint64_t buffered_amount() const; virtual void Close(); virtual DataState state() const { return state_; } virtual bool Send(const DataBuffer& buffer); @@ -160,10 +158,10 @@ class DataChannel : public DataChannelInterface, // Set the SSRC this channel should use to send data on the // underlying data engine. |send_ssrc| == 0 means that the channel is no // longer part of the session negotiation. - void SetSendSsrc(uint32 send_ssrc); + void SetSendSsrc(uint32_t send_ssrc); // Set the SSRC this channel should use to receive data from the // underlying data engine. - void SetReceiveSsrc(uint32 receive_ssrc); + void SetReceiveSsrc(uint32_t receive_ssrc); cricket::DataChannelType data_channel_type() const { return data_channel_type_; @@ -240,8 +238,8 @@ class DataChannel : public DataChannelInterface, bool send_ssrc_set_; bool receive_ssrc_set_; bool writable_; - uint32 send_ssrc_; - uint32 receive_ssrc_; + uint32_t send_ssrc_; + uint32_t receive_ssrc_; // Control messages that always have to get sent out before any queued // data. PacketQueue queued_control_data_; @@ -266,13 +264,13 @@ BEGIN_PROXY_MAP(DataChannel) PROXY_CONSTMETHOD0(std::string, label) PROXY_CONSTMETHOD0(bool, reliable) PROXY_CONSTMETHOD0(bool, ordered) - PROXY_CONSTMETHOD0(uint16, maxRetransmitTime) - PROXY_CONSTMETHOD0(uint16, maxRetransmits) + PROXY_CONSTMETHOD0(uint16_t, maxRetransmitTime) + PROXY_CONSTMETHOD0(uint16_t, maxRetransmits) PROXY_CONSTMETHOD0(std::string, protocol) PROXY_CONSTMETHOD0(bool, negotiated) PROXY_CONSTMETHOD0(int, id) PROXY_CONSTMETHOD0(DataState, state) - PROXY_CONSTMETHOD0(uint64, buffered_amount) + PROXY_CONSTMETHOD0(uint64_t, buffered_amount) PROXY_METHOD0(void, Close) PROXY_METHOD1(bool, Send, const DataBuffer&) END_PROXY() diff --git a/talk/app/webrtc/datachannel_unittest.cc b/talk/app/webrtc/datachannel_unittest.cc index e3c290bd9b..b4f611e215 100644 --- a/talk/app/webrtc/datachannel_unittest.cc +++ b/talk/app/webrtc/datachannel_unittest.cc @@ -43,7 +43,7 @@ class FakeDataChannelObserver : public webrtc::DataChannelObserver { ++on_state_change_count_; } - void OnBufferedAmountChange(uint64 previous_amount) { + void OnBufferedAmountChange(uint64_t previous_amount) { ++on_buffered_amount_change_count_; } @@ -215,7 +215,7 @@ TEST_F(SctpDataChannelTest, OpenMessageSent) { EXPECT_GE(webrtc_data_channel_->id(), 0); EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); EXPECT_EQ(provider_.last_send_data_params().ssrc, - static_cast(webrtc_data_channel_->id())); + static_cast(webrtc_data_channel_->id())); } TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) { @@ -225,7 +225,7 @@ TEST_F(SctpDataChannelTest, QueuedOpenMessageSent) { EXPECT_EQ(cricket::DMT_CONTROL, provider_.last_send_data_params().type); EXPECT_EQ(provider_.last_send_data_params().ssrc, - static_cast(webrtc_data_channel_->id())); + static_cast(webrtc_data_channel_->id())); } // Tests that the DataChannel created after transport gets ready can enter OPEN diff --git a/talk/app/webrtc/datachannelinterface.h b/talk/app/webrtc/datachannelinterface.h index 9d2cd44d3c..d70972f05a 100644 --- a/talk/app/webrtc/datachannelinterface.h +++ b/talk/app/webrtc/datachannelinterface.h @@ -92,7 +92,7 @@ class DataChannelObserver { // A data buffer was successfully received. virtual void OnMessage(const DataBuffer& buffer) = 0; // The data channel's buffered_amount has changed. - virtual void OnBufferedAmountChange(uint64 previous_amount){}; + virtual void OnBufferedAmountChange(uint64_t previous_amount){}; protected: virtual ~DataChannelObserver() {} @@ -135,8 +135,8 @@ class DataChannelInterface : public rtc::RefCountInterface { // implemented these APIs. They should all just return the values the // DataChannel was created with. virtual bool ordered() const { return false; } - virtual uint16 maxRetransmitTime() const { return 0; } - virtual uint16 maxRetransmits() const { return 0; } + virtual uint16_t maxRetransmitTime() const { return 0; } + virtual uint16_t maxRetransmits() const { return 0; } virtual std::string protocol() const { return std::string(); } virtual bool negotiated() const { return false; } @@ -145,7 +145,7 @@ class DataChannelInterface : public rtc::RefCountInterface { // The buffered_amount returns the number of bytes of application data // (UTF-8 text and binary data) that have been queued using SendBuffer but // have not yet been transmitted to the network. - virtual uint64 buffered_amount() const = 0; + virtual uint64_t buffered_amount() const = 0; virtual void Close() = 0; // Sends |data| to the remote peer. virtual bool Send(const DataBuffer& buffer) = 0; diff --git a/talk/app/webrtc/dtmfsender_unittest.cc b/talk/app/webrtc/dtmfsender_unittest.cc index 64f43e412c..f686aa2ccc 100644 --- a/talk/app/webrtc/dtmfsender_unittest.cc +++ b/talk/app/webrtc/dtmfsender_unittest.cc @@ -132,7 +132,7 @@ class FakeDtmfProvider : public DtmfProviderInterface { private: std::set can_insert_dtmf_tracks_; std::vector dtmf_info_queue_; - int64 last_insert_dtmf_call_; + int64_t last_insert_dtmf_call_; sigslot::signal0<> SignalDestroyed; }; diff --git a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc index f859410acb..1f6313119e 100644 --- a/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc +++ b/talk/app/webrtc/java/jni/androidmediadecoder_jni.cc @@ -519,10 +519,10 @@ int32_t MediaCodecVideoDecoder::DecodeOnCodecThread( // Copy encoded data to Java ByteBuffer. jobject j_input_buffer = input_buffers_[j_input_buffer_index]; - uint8* buffer = - reinterpret_cast(jni->GetDirectBufferAddress(j_input_buffer)); + uint8_t* buffer = + reinterpret_cast(jni->GetDirectBufferAddress(j_input_buffer)); RTC_CHECK(buffer) << "Indirect buffer??"; - int64 buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer); + int64_t buffer_capacity = jni->GetDirectBufferCapacity(j_input_buffer); if (CheckException(jni) || buffer_capacity < inputImage._length) { ALOGE("Input frame size %d is bigger than buffer size %d.", inputImage._length, buffer_capacity); diff --git a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc index a25a3cc0ef..8817df42df 100644 --- a/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc +++ b/talk/app/webrtc/java/jni/androidmediaencoder_jni.cc @@ -487,7 +487,7 @@ int32_t MediaCodecVideoEncoder::InitEncodeOnCodecThread( for (size_t i = 0; i < num_input_buffers; ++i) { input_buffers_[i] = jni->NewGlobalRef(jni->GetObjectArrayElement(input_buffers, i)); - int64 yuv_buffer_capacity = + int64_t yuv_buffer_capacity = jni->GetDirectBufferCapacity(input_buffers_[i]); CHECK_EXCEPTION(jni); RTC_CHECK(yuv_buffer_capacity >= yuv_size_) << "Insufficient capacity"; @@ -572,8 +572,8 @@ int32_t MediaCodecVideoEncoder::EncodeOnCodecThread( frames_received_ - 1, current_timestamp_us_ / 1000, frames_in_queue_); jobject j_input_buffer = input_buffers_[j_input_buffer_index]; - uint8* yuv_buffer = - reinterpret_cast(jni->GetDirectBufferAddress(j_input_buffer)); + uint8_t* yuv_buffer = + reinterpret_cast(jni->GetDirectBufferAddress(j_input_buffer)); CHECK_EXCEPTION(jni); RTC_CHECK(yuv_buffer) << "Indirect buffer??"; RTC_CHECK(!libyuv::ConvertFromI420( @@ -726,7 +726,7 @@ bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) { // Extract payload. size_t payload_size = jni->GetDirectBufferCapacity(j_output_buffer); - uint8* payload = reinterpret_cast( + uint8_t* payload = reinterpret_cast( jni->GetDirectBufferAddress(j_output_buffer)); CHECK_EXCEPTION(jni); diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc index 93b169526c..9ac64063a6 100644 --- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc +++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.cc @@ -126,7 +126,7 @@ void AndroidVideoCapturerJni::AsyncCapturerInvoke( invoker_->AsyncInvoke(rtc::Bind(method, capturer_, args...)); } -void AndroidVideoCapturerJni::ReturnBuffer(int64 time_stamp) { +void AndroidVideoCapturerJni::ReturnBuffer(int64_t time_stamp) { jmethodID m = GetMethodID(jni(), *j_video_capturer_class_, "returnBuffer", "(J)V"); jni()->CallVoidMethod(*j_capturer_global_, m, time_stamp); @@ -155,7 +155,7 @@ void AndroidVideoCapturerJni::OnIncomingFrame(void* video_frame, int width, int height, int rotation, - int64 time_stamp) { + int64_t time_stamp) { const uint8_t* y_plane = static_cast(video_frame); // Android guarantees that the stride is a multiple of 16. // http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29 diff --git a/talk/app/webrtc/java/jni/androidvideocapturer_jni.h b/talk/app/webrtc/java/jni/androidvideocapturer_jni.h index 9a356d8c62..cd3dd9af64 100644 --- a/talk/app/webrtc/java/jni/androidvideocapturer_jni.h +++ b/talk/app/webrtc/java/jni/androidvideocapturer_jni.h @@ -61,14 +61,14 @@ class AndroidVideoCapturerJni : public webrtc::AndroidVideoCapturerDelegate { int width, int height, int rotation, - int64 time_stamp); + int64_t time_stamp); void OnOutputFormatRequest(int width, int height, int fps); protected: ~AndroidVideoCapturerJni(); private: - void ReturnBuffer(int64 time_stamp); + void ReturnBuffer(int64_t time_stamp); JNIEnv* jni(); // Helper function to make safe asynchronous calls to |capturer_|. The calls diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index 33b08907be..fc6ce50c51 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -606,7 +606,7 @@ class DataChannelObserverWrapper : public DataChannelObserver { virtual ~DataChannelObserverWrapper() {} - void OnBufferedAmountChange(uint64 previous_amount) override { + void OnBufferedAmountChange(uint64_t previous_amount) override { ScopedLocalRefFrame local_ref_frame(jni()); jni()->CallVoidMethod(*j_observer_global_, j_on_buffered_amount_change_mid_, previous_amount); @@ -806,13 +806,13 @@ class JavaVideoRendererWrapper : public VideoRendererInterface { strides_array[2] = frame->GetVPitch(); jni()->ReleaseIntArrayElements(strides, strides_array, 0); jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); - jobject y_buffer = jni()->NewDirectByteBuffer( - const_cast(frame->GetYPlane()), - frame->GetYPitch() * frame->GetHeight()); + jobject y_buffer = + jni()->NewDirectByteBuffer(const_cast(frame->GetYPlane()), + frame->GetYPitch() * frame->GetHeight()); jobject u_buffer = jni()->NewDirectByteBuffer( - const_cast(frame->GetUPlane()), frame->GetChromaSize()); + const_cast(frame->GetUPlane()), frame->GetChromaSize()); jobject v_buffer = jni()->NewDirectByteBuffer( - const_cast(frame->GetVPlane()), frame->GetChromaSize()); + const_cast(frame->GetVPlane()), frame->GetChromaSize()); jni()->SetObjectArrayElement(planes, 0, y_buffer); jni()->SetObjectArrayElement(planes, 1, u_buffer); jni()->SetObjectArrayElement(planes, 2, v_buffer); @@ -880,8 +880,8 @@ JOW(jobject, DataChannel_state)(JNIEnv* jni, jobject j_dc) { } JOW(jlong, DataChannel_bufferedAmount)(JNIEnv* jni, jobject j_dc) { - uint64 buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount(); - RTC_CHECK_LE(buffered_amount, std::numeric_limits::max()) + uint64_t buffered_amount = ExtractNativeDC(jni, j_dc)->buffered_amount(); + RTC_CHECK_LE(buffered_amount, std::numeric_limits::max()) << "buffered_amount overflowed jlong!"; return static_cast(buffered_amount); } diff --git a/talk/app/webrtc/mediastreamprovider.h b/talk/app/webrtc/mediastreamprovider.h index 7e25b66a3c..b80f6b2bd4 100644 --- a/talk/app/webrtc/mediastreamprovider.h +++ b/talk/app/webrtc/mediastreamprovider.h @@ -55,17 +55,19 @@ namespace webrtc { class AudioProviderInterface { public: // Enable/disable the audio playout of a remote audio track with |ssrc|. - virtual void SetAudioPlayout(uint32 ssrc, bool enable, + virtual void SetAudioPlayout(uint32_t ssrc, + bool enable, cricket::AudioRenderer* renderer) = 0; // Enable/disable sending audio on the local audio track with |ssrc|. // When |enable| is true |options| should be applied to the audio track. - virtual void SetAudioSend(uint32 ssrc, bool enable, + virtual void SetAudioSend(uint32_t ssrc, + bool enable, const cricket::AudioOptions& options, cricket::AudioRenderer* renderer) = 0; // Sets the audio playout volume of a remote audio track with |ssrc|. // |volume| is in the range of [0, 10]. - virtual void SetAudioPlayoutVolume(uint32 ssrc, double volume) = 0; + virtual void SetAudioPlayoutVolume(uint32_t ssrc, double volume) = 0; protected: virtual ~AudioProviderInterface() {} @@ -76,13 +78,15 @@ class AudioProviderInterface { // PeerConnection. class VideoProviderInterface { public: - virtual bool SetCaptureDevice(uint32 ssrc, + virtual bool SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) = 0; // Enable/disable the video playout of a remote video track with |ssrc|. - virtual void SetVideoPlayout(uint32 ssrc, bool enable, + virtual void SetVideoPlayout(uint32_t ssrc, + bool enable, cricket::VideoRenderer* renderer) = 0; // Enable sending video on the local video track with |ssrc|. - virtual void SetVideoSend(uint32 ssrc, bool enable, + virtual void SetVideoSend(uint32_t ssrc, + bool enable, const cricket::VideoOptions* options) = 0; protected: diff --git a/talk/app/webrtc/mediastreamsignaling.cc b/talk/app/webrtc/mediastreamsignaling.cc index 4f2615f1d0..c12471c778 100644 --- a/talk/app/webrtc/mediastreamsignaling.cc +++ b/talk/app/webrtc/mediastreamsignaling.cc @@ -612,7 +612,7 @@ void MediaStreamSignaling::UpdateRemoteStreamsList( // track id. const std::string& stream_label = it->sync_label; const std::string& track_id = it->id; - uint32 ssrc = it->first_ssrc(); + uint32_t ssrc = it->first_ssrc(); rtc::scoped_refptr stream = remote_streams_->find(stream_label); @@ -634,7 +634,7 @@ void MediaStreamSignaling::UpdateRemoteStreamsList( void MediaStreamSignaling::OnRemoteTrackSeen(const std::string& stream_label, const std::string& track_id, - uint32 ssrc, + uint32_t ssrc, cricket::MediaType media_type) { MediaStreamInterface* stream = remote_streams_->find(stream_label); @@ -801,7 +801,7 @@ void MediaStreamSignaling::UpdateLocalTracks( // track id. const std::string& stream_label = it->sync_label; const std::string& track_id = it->id; - uint32 ssrc = it->first_ssrc(); + uint32_t ssrc = it->first_ssrc(); const TrackInfo* track_info = FindTrackInfo(*current_tracks, stream_label, track_id); @@ -814,7 +814,7 @@ void MediaStreamSignaling::UpdateLocalTracks( void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label, const std::string& track_id, - uint32 ssrc, + uint32_t ssrc, cricket::MediaType media_type) { MediaStreamInterface* stream = local_streams_->find(stream_label); if (!stream) { @@ -844,11 +844,10 @@ void MediaStreamSignaling::OnLocalTrackSeen(const std::string& stream_label, } } -void MediaStreamSignaling::OnLocalTrackRemoved( - const std::string& stream_label, - const std::string& track_id, - uint32 ssrc, - cricket::MediaType media_type) { +void MediaStreamSignaling::OnLocalTrackRemoved(const std::string& stream_label, + const std::string& track_id, + uint32_t ssrc, + cricket::MediaType media_type) { MediaStreamInterface* stream = local_streams_->find(stream_label); if (!stream) { // This is the normal case. Ie RemoveLocalStream has been called and the @@ -953,7 +952,7 @@ void MediaStreamSignaling::UpdateClosingDataChannels( } void MediaStreamSignaling::CreateRemoteDataChannel(const std::string& label, - uint32 remote_ssrc) { + uint32_t remote_ssrc) { if (!data_channel_factory_) { LOG(LS_WARNING) << "Remote peer requested a DataChannel but DataChannels " << "are not supported."; @@ -991,8 +990,7 @@ void MediaStreamSignaling::OnDtlsRoleReadyForSctp(rtc::SSLRole role) { } } - -void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32 sid) { +void MediaStreamSignaling::OnRemoteSctpDataChannelClosed(uint32_t sid) { int index = FindDataChannelBySid(sid); if (index < 0) { LOG(LS_WARNING) << "Unexpected sid " << sid diff --git a/talk/app/webrtc/mediastreamsignaling.h b/talk/app/webrtc/mediastreamsignaling.h index 08f9cba3fa..b858b5b5a0 100644 --- a/talk/app/webrtc/mediastreamsignaling.h +++ b/talk/app/webrtc/mediastreamsignaling.h @@ -66,12 +66,12 @@ class MediaStreamSignalingObserver { // Triggered when the remote SessionDescription has a new audio track. virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) = 0; + uint32_t ssrc) = 0; // Triggered when the remote SessionDescription has a new video track. virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) = 0; + uint32_t ssrc) = 0; // Triggered when the remote SessionDescription has removed an audio track. virtual void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, @@ -84,17 +84,17 @@ class MediaStreamSignalingObserver { // Triggered when the local SessionDescription has a new audio track. virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) = 0; + uint32_t ssrc) = 0; // Triggered when the local SessionDescription has a new video track. virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) = 0; + uint32_t ssrc) = 0; // Triggered when the local SessionDescription has removed an audio track. virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) = 0; + uint32_t ssrc) = 0; // Triggered when the local SessionDescription has removed a video track. virtual void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, @@ -254,7 +254,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> { } void OnDataTransportCreatedForSctp(); void OnDtlsRoleReadyForSctp(rtc::SSLRole role); - void OnRemoteSctpDataChannelClosed(uint32 sid); + void OnRemoteSctpDataChannelClosed(uint32_t sid); const SctpDataChannels& sctp_data_channels() const { return sctp_data_channels_; @@ -286,11 +286,11 @@ class MediaStreamSignaling : public sigslot::has_slots<> { TrackInfo() : ssrc(0) {} TrackInfo(const std::string& stream_label, const std::string track_id, - uint32 ssrc) + uint32_t ssrc) : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} std::string stream_label; std::string track_id; - uint32 ssrc; + uint32_t ssrc; }; typedef std::vector TrackInfos; @@ -309,7 +309,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> { // MediaStreamSignaling::OnAddRemoteVideoTrack. void OnRemoteTrackSeen(const std::string& stream_label, const std::string& track_id, - uint32 ssrc, + uint32_t ssrc, cricket::MediaType media_type); // Triggered when a remote track has been removed from a remote session @@ -350,7 +350,7 @@ class MediaStreamSignaling : public sigslot::has_slots<> { // |local_streams_| void OnLocalTrackSeen(const std::string& stream_label, const std::string& track_id, - uint32 ssrc, + uint32_t ssrc, cricket::MediaType media_type); // Triggered when a local track has been removed from a local session @@ -361,14 +361,14 @@ class MediaStreamSignaling : public sigslot::has_slots<> { // MediaStreamTrack in a MediaStream in |local_streams_|. void OnLocalTrackRemoved(const std::string& stream_label, const std::string& track_id, - uint32 ssrc, + uint32_t ssrc, cricket::MediaType media_type); void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams); void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams); void UpdateClosingDataChannels( const std::vector& active_channels, bool is_local_update); - void CreateRemoteDataChannel(const std::string& label, uint32 remote_ssrc); + void CreateRemoteDataChannel(const std::string& label, uint32_t remote_ssrc); const TrackInfo* FindTrackInfo(const TrackInfos& infos, const std::string& stream_label, diff --git a/talk/app/webrtc/mediastreamsignaling_unittest.cc b/talk/app/webrtc/mediastreamsignaling_unittest.cc index 4f54df49b4..23337058d1 100644 --- a/talk/app/webrtc/mediastreamsignaling_unittest.cc +++ b/talk/app/webrtc/mediastreamsignaling_unittest.cc @@ -311,19 +311,19 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { virtual void OnAddLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { AddTrack(&local_audio_tracks_, stream, audio_track, ssrc); } virtual void OnAddLocalVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) { + uint32_t ssrc) { AddTrack(&local_video_tracks_, stream, video_track, ssrc); } virtual void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { RemoveTrack(&local_audio_tracks_, stream, audio_track); } @@ -334,13 +334,13 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { virtual void OnAddRemoteAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { AddTrack(&remote_audio_tracks_, stream, audio_track, ssrc); } virtual void OnAddRemoteVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) { + uint32_t ssrc) { AddTrack(&remote_video_tracks_, stream, video_track, ssrc); } @@ -369,7 +369,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { void VerifyRemoteAudioTrack(const std::string& stream_label, const std::string& track_id, - uint32 ssrc) { + uint32_t ssrc) { VerifyTrack(remote_audio_tracks_, stream_label, track_id, ssrc); } @@ -377,14 +377,14 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { void VerifyRemoteVideoTrack(const std::string& stream_label, const std::string& track_id, - uint32 ssrc) { + uint32_t ssrc) { VerifyTrack(remote_video_tracks_, stream_label, track_id, ssrc); } size_t NumberOfLocalAudioTracks() { return local_audio_tracks_.size(); } void VerifyLocalAudioTrack(const std::string& stream_label, const std::string& track_id, - uint32 ssrc) { + uint32_t ssrc) { VerifyTrack(local_audio_tracks_, stream_label, track_id, ssrc); } @@ -392,7 +392,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { void VerifyLocalVideoTrack(const std::string& stream_label, const std::string& track_id, - uint32 ssrc) { + uint32_t ssrc) { VerifyTrack(local_video_tracks_, stream_label, track_id, ssrc); } @@ -401,18 +401,18 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { TrackInfo() {} TrackInfo(const std::string& stream_label, const std::string track_id, - uint32 ssrc) + uint32_t ssrc) : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} std::string stream_label; std::string track_id; - uint32 ssrc; + uint32_t ssrc; }; typedef std::vector TrackInfos; void AddTrack(TrackInfos* track_infos, MediaStreamInterface* stream, MediaStreamTrackInterface* track, - uint32 ssrc) { + uint32_t ssrc) { (*track_infos).push_back(TrackInfo(stream->label(), track->id(), ssrc)); } @@ -442,7 +442,7 @@ class MockSignalingObserver : public webrtc::MediaStreamSignalingObserver { void VerifyTrack(const TrackInfos& track_infos, const std::string& stream_label, const std::string& track_id, - uint32 ssrc) { + uint32_t ssrc) { const TrackInfo* track_info = FindTrackInfo(track_infos, stream_label, track_id); diff --git a/talk/app/webrtc/objc/RTCDataChannel.mm b/talk/app/webrtc/objc/RTCDataChannel.mm index 8a9b6b6095..fdb5c99a83 100644 --- a/talk/app/webrtc/objc/RTCDataChannel.mm +++ b/talk/app/webrtc/objc/RTCDataChannel.mm @@ -43,7 +43,7 @@ class RTCDataChannelObserver : public DataChannelObserver { [_channel.delegate channelDidChangeState:_channel]; } - void OnBufferedAmountChange(uint64 previousAmount) override { + void OnBufferedAmountChange(uint64_t previousAmount) override { RTCDataChannel* channel = _channel; id delegate = channel.delegate; if ([delegate diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.h b/talk/app/webrtc/objc/avfoundationvideocapturer.h index dd3290903f..ded80f6647 100644 --- a/talk/app/webrtc/objc/avfoundationvideocapturer.h +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.h @@ -49,7 +49,7 @@ class AVFoundationVideoCapturer : public cricket::VideoCapturer { bool IsScreencast() const override { return false; } - bool GetPreferredFourccs(std::vector* fourccs) override { + bool GetPreferredFourccs(std::vector* fourccs) override { fourccs->push_back(cricket::FOURCC_NV12); return true; } diff --git a/talk/app/webrtc/objc/avfoundationvideocapturer.mm b/talk/app/webrtc/objc/avfoundationvideocapturer.mm index b4d7ee2443..e1b0f88fb6 100644 --- a/talk/app/webrtc/objc/avfoundationvideocapturer.mm +++ b/talk/app/webrtc/objc/avfoundationvideocapturer.mm @@ -415,13 +415,13 @@ void AVFoundationVideoCapturer::CaptureSampleBuffer( uvPlaneAddress == yPlaneAddress + yPlaneHeight * yPlaneBytesPerRow); // Stuff data into a cricket::CapturedFrame. - int64 currentTime = rtc::TimeNanos(); + int64_t currentTime = rtc::TimeNanos(); cricket::CapturedFrame frame; frame.width = yPlaneWidth; frame.height = yPlaneHeight; frame.pixel_width = 1; frame.pixel_height = 1; - frame.fourcc = static_cast(cricket::FOURCC_NV12); + frame.fourcc = static_cast(cricket::FOURCC_NV12); frame.time_stamp = currentTime; frame.data = yPlaneAddress; frame.data_size = frameSize; diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc index bf9a80d9b7..86902b0359 100644 --- a/talk/app/webrtc/peerconnection.cc +++ b/talk/app/webrtc/peerconnection.cc @@ -862,13 +862,13 @@ void PeerConnection::OnAddDataChannel(DataChannelInterface* data_channel) { void PeerConnection::OnAddRemoteAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { receivers_.push_back(new AudioRtpReceiver(audio_track, ssrc, session_.get())); } void PeerConnection::OnAddRemoteVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) { + uint32_t ssrc) { receivers_.push_back(new VideoRtpReceiver(video_track, ssrc, session_.get())); } @@ -902,14 +902,14 @@ void PeerConnection::OnRemoveRemoteVideoTrack( void PeerConnection::OnAddLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { senders_.push_back(new AudioRtpSender(audio_track, ssrc, session_.get())); stats_->AddLocalAudioTrack(audio_track, ssrc); } void PeerConnection::OnAddLocalVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) { + uint32_t ssrc) { senders_.push_back(new VideoRtpSender(video_track, ssrc, session_.get())); } @@ -917,7 +917,7 @@ void PeerConnection::OnAddLocalVideoTrack(MediaStreamInterface* stream, // description. void PeerConnection::OnRemoveLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { auto it = FindSenderForTrack(audio_track); if (it == senders_.end()) { LOG(LS_WARNING) << "RtpSender for track with id " << audio_track->id() diff --git a/talk/app/webrtc/peerconnection.h b/talk/app/webrtc/peerconnection.h index 8a8701931a..3d6ce1ba6d 100644 --- a/talk/app/webrtc/peerconnection.h +++ b/talk/app/webrtc/peerconnection.h @@ -133,23 +133,23 @@ class PeerConnection : public PeerConnectionInterface, void OnAddDataChannel(DataChannelInterface* data_channel) override; void OnAddRemoteAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) override; + uint32_t ssrc) override; void OnAddRemoteVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) override; + uint32_t ssrc) override; void OnRemoveRemoteAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track) override; void OnRemoveRemoteVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track) override; void OnAddLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) override; + uint32_t ssrc) override; void OnAddLocalVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track, - uint32 ssrc) override; + uint32_t ssrc) override; void OnRemoveLocalAudioTrack(MediaStreamInterface* stream, AudioTrackInterface* audio_track, - uint32 ssrc) override; + uint32_t ssrc) override; void OnRemoveLocalVideoTrack(MediaStreamInterface* stream, VideoTrackInterface* video_track) override; void OnRemoveLocalStream(MediaStreamInterface* stream) override; diff --git a/talk/app/webrtc/peerconnectioninterface_unittest.cc b/talk/app/webrtc/peerconnectioninterface_unittest.cc index 5e135df647..8b7c9cf382 100644 --- a/talk/app/webrtc/peerconnectioninterface_unittest.cc +++ b/talk/app/webrtc/peerconnectioninterface_unittest.cc @@ -58,7 +58,7 @@ static const char kTurnIceServerUri[] = "turn:user@turn.example.org"; static const char kTurnUsername[] = "user"; static const char kTurnPassword[] = "password"; static const char kTurnHostname[] = "turn.example.org"; -static const uint32 kTimeout = 10000U; +static const uint32_t kTimeout = 10000U; #define MAYBE_SKIP_TEST(feature) \ if (!(feature())) { \ diff --git a/talk/app/webrtc/remotevideocapturer.cc b/talk/app/webrtc/remotevideocapturer.cc index 439e52c5d5..b0c9f9fc08 100644 --- a/talk/app/webrtc/remotevideocapturer.cc +++ b/talk/app/webrtc/remotevideocapturer.cc @@ -65,7 +65,7 @@ bool RemoteVideoCapturer::IsRunning() { return capture_state() == cricket::CS_RUNNING; } -bool RemoteVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { +bool RemoteVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { if (!fourccs) return false; fourccs->push_back(cricket::FOURCC_I420); diff --git a/talk/app/webrtc/remotevideocapturer.h b/talk/app/webrtc/remotevideocapturer.h index 1429ffb9cc..b5298d94ee 100644 --- a/talk/app/webrtc/remotevideocapturer.h +++ b/talk/app/webrtc/remotevideocapturer.h @@ -51,7 +51,7 @@ class RemoteVideoCapturer : public cricket::VideoCapturer { const cricket::VideoFormat& capture_format) override; void Stop() override; bool IsRunning() override; - bool GetPreferredFourccs(std::vector* fourccs) override; + bool GetPreferredFourccs(std::vector* fourccs) override; bool GetBestCaptureFormat(const cricket::VideoFormat& desired, cricket::VideoFormat* best_format) override; bool IsScreencast() const override; diff --git a/talk/app/webrtc/remotevideocapturer_unittest.cc b/talk/app/webrtc/remotevideocapturer_unittest.cc index 2ba4a1a237..88277b61fc 100644 --- a/talk/app/webrtc/remotevideocapturer_unittest.cc +++ b/talk/app/webrtc/remotevideocapturer_unittest.cc @@ -104,7 +104,7 @@ TEST_F(RemoteVideoCapturerTest, StartStop) { TEST_F(RemoteVideoCapturerTest, GetPreferredFourccs) { EXPECT_FALSE(capturer_.GetPreferredFourccs(NULL)); - std::vector fourccs; + std::vector fourccs; EXPECT_TRUE(capturer_.GetPreferredFourccs(&fourccs)); EXPECT_EQ(1u, fourccs.size()); EXPECT_EQ(cricket::FOURCC_I420, fourccs.at(0)); diff --git a/talk/app/webrtc/rtpreceiver.cc b/talk/app/webrtc/rtpreceiver.cc index b8eca30c84..faf3de3033 100644 --- a/talk/app/webrtc/rtpreceiver.cc +++ b/talk/app/webrtc/rtpreceiver.cc @@ -32,7 +32,7 @@ namespace webrtc { AudioRtpReceiver::AudioRtpReceiver(AudioTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, AudioProviderInterface* provider) : id_(track->id()), track_(track), @@ -82,7 +82,7 @@ void AudioRtpReceiver::Reconfigure() { } VideoRtpReceiver::VideoRtpReceiver(VideoTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, VideoProviderInterface* provider) : id_(track->id()), track_(track), ssrc_(ssrc), provider_(provider) { provider_->SetVideoPlayout(ssrc_, true, track_->GetSource()->FrameInput()); diff --git a/talk/app/webrtc/rtpreceiver.h b/talk/app/webrtc/rtpreceiver.h index f5bcb2e286..a93ccbcbfe 100644 --- a/talk/app/webrtc/rtpreceiver.h +++ b/talk/app/webrtc/rtpreceiver.h @@ -45,7 +45,7 @@ class AudioRtpReceiver : public ObserverInterface, public rtc::RefCountedObject { public: AudioRtpReceiver(AudioTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, AudioProviderInterface* provider); virtual ~AudioRtpReceiver(); @@ -70,7 +70,7 @@ class AudioRtpReceiver : public ObserverInterface, std::string id_; rtc::scoped_refptr track_; - uint32 ssrc_; + uint32_t ssrc_; AudioProviderInterface* provider_; bool cached_track_enabled_; }; @@ -78,7 +78,7 @@ class AudioRtpReceiver : public ObserverInterface, class VideoRtpReceiver : public rtc::RefCountedObject { public: VideoRtpReceiver(VideoTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, VideoProviderInterface* provider); virtual ~VideoRtpReceiver(); @@ -95,7 +95,7 @@ class VideoRtpReceiver : public rtc::RefCountedObject { private: std::string id_; rtc::scoped_refptr track_; - uint32 ssrc_; + uint32_t ssrc_; VideoProviderInterface* provider_; }; diff --git a/talk/app/webrtc/rtpsender.cc b/talk/app/webrtc/rtpsender.cc index 28ba073fc5..3a78f4598a 100644 --- a/talk/app/webrtc/rtpsender.cc +++ b/talk/app/webrtc/rtpsender.cc @@ -59,7 +59,7 @@ void LocalAudioSinkAdapter::SetSink(cricket::AudioRenderer::Sink* sink) { } AudioRtpSender::AudioRtpSender(AudioTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, AudioProviderInterface* provider) : id_(track->id()), track_(track), @@ -136,7 +136,7 @@ void AudioRtpSender::Reconfigure() { } VideoRtpSender::VideoRtpSender(VideoTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, VideoProviderInterface* provider) : id_(track->id()), track_(track), diff --git a/talk/app/webrtc/rtpsender.h b/talk/app/webrtc/rtpsender.h index a0eae5dd6a..3741909323 100644 --- a/talk/app/webrtc/rtpsender.h +++ b/talk/app/webrtc/rtpsender.h @@ -71,7 +71,7 @@ class AudioRtpSender : public ObserverInterface, public rtc::RefCountedObject { public: AudioRtpSender(AudioTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, AudioProviderInterface* provider); virtual ~AudioRtpSender(); @@ -94,7 +94,7 @@ class AudioRtpSender : public ObserverInterface, std::string id_; rtc::scoped_refptr track_; - uint32 ssrc_; + uint32_t ssrc_; AudioProviderInterface* provider_; bool cached_track_enabled_; @@ -107,7 +107,7 @@ class VideoRtpSender : public ObserverInterface, public rtc::RefCountedObject { public: VideoRtpSender(VideoTrackInterface* track, - uint32 ssrc, + uint32_t ssrc, VideoProviderInterface* provider); virtual ~VideoRtpSender(); @@ -130,7 +130,7 @@ class VideoRtpSender : public ObserverInterface, std::string id_; rtc::scoped_refptr track_; - uint32 ssrc_; + uint32_t ssrc_; VideoProviderInterface* provider_; bool cached_track_enabled_; }; diff --git a/talk/app/webrtc/rtpsenderreceiver_unittest.cc b/talk/app/webrtc/rtpsenderreceiver_unittest.cc index 973b854171..b69221bfb6 100644 --- a/talk/app/webrtc/rtpsenderreceiver_unittest.cc +++ b/talk/app/webrtc/rtpsenderreceiver_unittest.cc @@ -47,8 +47,8 @@ using ::testing::Exactly; static const char kStreamLabel1[] = "local_stream_1"; static const char kVideoTrackId[] = "video_1"; static const char kAudioTrackId[] = "audio_1"; -static const uint32 kVideoSsrc = 98; -static const uint32 kAudioSsrc = 99; +static const uint32_t kVideoSsrc = 98; +static const uint32_t kAudioSsrc = 99; namespace webrtc { @@ -57,15 +57,15 @@ class MockAudioProvider : public AudioProviderInterface { public: virtual ~MockAudioProvider() {} MOCK_METHOD3(SetAudioPlayout, - void(uint32 ssrc, + void(uint32_t ssrc, bool enable, cricket::AudioRenderer* renderer)); MOCK_METHOD4(SetAudioSend, - void(uint32 ssrc, + void(uint32_t ssrc, bool enable, const cricket::AudioOptions& options, cricket::AudioRenderer* renderer)); - MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32 ssrc, double volume)); + MOCK_METHOD2(SetAudioPlayoutVolume, void(uint32_t ssrc, double volume)); }; // Helper class to test RtpSender/RtpReceiver. @@ -73,13 +73,13 @@ class MockVideoProvider : public VideoProviderInterface { public: virtual ~MockVideoProvider() {} MOCK_METHOD2(SetCaptureDevice, - bool(uint32 ssrc, cricket::VideoCapturer* camera)); + bool(uint32_t ssrc, cricket::VideoCapturer* camera)); MOCK_METHOD3(SetVideoPlayout, - void(uint32 ssrc, + void(uint32_t ssrc, bool enable, cricket::VideoRenderer* renderer)); MOCK_METHOD3(SetVideoSend, - void(uint32 ssrc, + void(uint32_t ssrc, bool enable, const cricket::VideoOptions* options)); }; diff --git a/talk/app/webrtc/sctputils.cc b/talk/app/webrtc/sctputils.cc index 21174c3e48..a64383720f 100644 --- a/talk/app/webrtc/sctputils.cc +++ b/talk/app/webrtc/sctputils.cc @@ -36,8 +36,8 @@ namespace webrtc { // Format defined at // http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-01#section -static const uint8 DATA_CHANNEL_OPEN_MESSAGE_TYPE = 0x03; -static const uint8 DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE = 0x02; +static const uint8_t DATA_CHANNEL_OPEN_MESSAGE_TYPE = 0x03; +static const uint8_t DATA_CHANNEL_OPEN_ACK_MESSAGE_TYPE = 0x02; enum DataChannelOpenMessageChannelType { DCOMCT_ORDERED_RELIABLE = 0x00, @@ -55,7 +55,7 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04 rtc::ByteBuffer buffer(payload); - uint8 message_type; + uint8_t message_type; if (!buffer.ReadUInt8(&message_type)) { LOG(LS_WARNING) << "Could not read OPEN message type."; return false; @@ -66,28 +66,28 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, return false; } - uint8 channel_type; + uint8_t channel_type; if (!buffer.ReadUInt8(&channel_type)) { LOG(LS_WARNING) << "Could not read OPEN message channel type."; return false; } - uint16 priority; + uint16_t priority; if (!buffer.ReadUInt16(&priority)) { LOG(LS_WARNING) << "Could not read OPEN message reliabilility prioirty."; return false; } - uint32 reliability_param; + uint32_t reliability_param; if (!buffer.ReadUInt32(&reliability_param)) { LOG(LS_WARNING) << "Could not read OPEN message reliabilility param."; return false; } - uint16 label_length; + uint16_t label_length; if (!buffer.ReadUInt16(&label_length)) { LOG(LS_WARNING) << "Could not read OPEN message label length."; return false; } - uint16 protocol_length; + uint16_t protocol_length; if (!buffer.ReadUInt16(&protocol_length)) { LOG(LS_WARNING) << "Could not read OPEN message protocol length."; return false; @@ -126,7 +126,7 @@ bool ParseDataChannelOpenMessage(const rtc::Buffer& payload, bool ParseDataChannelOpenAckMessage(const rtc::Buffer& payload) { rtc::ByteBuffer buffer(payload); - uint8 message_type; + uint8_t message_type; if (!buffer.ReadUInt8(&message_type)) { LOG(LS_WARNING) << "Could not read OPEN_ACK message type."; return false; @@ -144,9 +144,9 @@ bool WriteDataChannelOpenMessage(const std::string& label, rtc::Buffer* payload) { // Format defined at // http://tools.ietf.org/html/draft-ietf-rtcweb-data-protocol-00#section-6.1 - uint8 channel_type = 0; - uint32 reliability_param = 0; - uint16 priority = 0; + uint8_t channel_type = 0; + uint32_t reliability_param = 0; + uint16_t priority = 0; if (config.ordered) { if (config.maxRetransmits > -1) { channel_type = DCOMCT_ORDERED_PARTIAL_RTXS; @@ -176,8 +176,8 @@ bool WriteDataChannelOpenMessage(const std::string& label, buffer.WriteUInt8(channel_type); buffer.WriteUInt16(priority); buffer.WriteUInt32(reliability_param); - buffer.WriteUInt16(static_cast(label.length())); - buffer.WriteUInt16(static_cast(config.protocol.length())); + buffer.WriteUInt16(static_cast(label.length())); + buffer.WriteUInt16(static_cast(config.protocol.length())); buffer.WriteString(label); buffer.WriteString(config.protocol); payload->SetData(buffer.Data(), buffer.Length()); diff --git a/talk/app/webrtc/sctputils_unittest.cc b/talk/app/webrtc/sctputils_unittest.cc index 164f6dd23b..e5f323aa22 100644 --- a/talk/app/webrtc/sctputils_unittest.cc +++ b/talk/app/webrtc/sctputils_unittest.cc @@ -34,12 +34,12 @@ class SctpUtilsTest : public testing::Test { void VerifyOpenMessageFormat(const rtc::Buffer& packet, const std::string& label, const webrtc::DataChannelInit& config) { - uint8 message_type; - uint8 channel_type; - uint32 reliability; - uint16 priority; - uint16 label_length; - uint16 protocol_length; + uint8_t message_type; + uint8_t channel_type; + uint32_t reliability; + uint16_t priority; + uint16_t label_length; + uint16_t protocol_length; rtc::ByteBuffer buffer(packet.data(), packet.length()); ASSERT_TRUE(buffer.ReadUInt8(&message_type)); @@ -152,7 +152,7 @@ TEST_F(SctpUtilsTest, WriteParseAckMessage) { rtc::Buffer packet; webrtc::WriteDataChannelOpenAckMessage(&packet); - uint8 message_type; + uint8_t message_type; rtc::ByteBuffer buffer(packet.data(), packet.length()); ASSERT_TRUE(buffer.ReadUInt8(&message_type)); EXPECT_EQ(0x02, message_type); diff --git a/talk/app/webrtc/statscollector.cc b/talk/app/webrtc/statscollector.cc index 70cc44db0e..5b527ecc73 100644 --- a/talk/app/webrtc/statscollector.cc +++ b/talk/app/webrtc/statscollector.cc @@ -66,7 +66,7 @@ struct TypeForAdd { typedef TypeForAdd BoolForAdd; typedef TypeForAdd FloatForAdd; -typedef TypeForAdd Int64ForAdd; +typedef TypeForAdd Int64ForAdd; typedef TypeForAdd IntForAdd; StatsReport::Id GetTransportIdFromProxy(const cricket::ProxyTransportMap& map, @@ -301,7 +301,7 @@ void ExtractStatsFromList(const std::vector& data, StatsCollector* collector, StatsReport::Direction direction) { for (const auto& d : data) { - uint32 ssrc = d.ssrc(); + uint32_t ssrc = d.ssrc(); // Each track can have stats for both local and remote objects. // TODO(hta): Handle the case of multiple SSRCs per object. StatsReport* report = collector->PrepareReport(true, ssrc, transport_id, @@ -383,7 +383,7 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) { } void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { RTC_DCHECK(session_->signaling_thread()->IsCurrent()); RTC_DCHECK(audio_track != NULL); #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) @@ -405,7 +405,7 @@ void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track, } void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track, - uint32 ssrc) { + uint32_t ssrc) { RTC_DCHECK(audio_track != NULL); local_audio_tracks_.erase(std::remove_if(local_audio_tracks_.begin(), local_audio_tracks_.end(), @@ -482,16 +482,15 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) { } } -StatsReport* StatsCollector::PrepareReport( - bool local, - uint32 ssrc, - const StatsReport::Id& transport_id, - StatsReport::Direction direction) { +StatsReport* StatsCollector::PrepareReport(bool local, + uint32_t ssrc, + const StatsReport::Id& transport_id, + StatsReport::Direction direction) { RTC_DCHECK(session_->signaling_thread()->IsCurrent()); StatsReport::Id id(StatsReport::NewIdWithDirection( - local ? StatsReport::kStatsReportTypeSsrc : - StatsReport::kStatsReportTypeRemoteSsrc, - rtc::ToString(ssrc), direction)); + local ? StatsReport::kStatsReportTypeSsrc + : StatsReport::kStatsReportTypeRemoteSsrc, + rtc::ToString(ssrc), direction)); StatsReport* report = reports_.Find(id); // Use the ID of the track that is currently mapped to the SSRC, if any. @@ -861,10 +860,10 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() { // Loop through the existing local audio tracks. for (const auto& it : local_audio_tracks_) { AudioTrackInterface* track = it.first; - uint32 ssrc = it.second; - StatsReport* report = GetReport(StatsReport::kStatsReportTypeSsrc, - rtc::ToString(ssrc), - StatsReport::kSend); + uint32_t ssrc = it.second; + StatsReport* report = + GetReport(StatsReport::kStatsReportTypeSsrc, + rtc::ToString(ssrc), StatsReport::kSend); if (report == NULL) { // This can happen if a local audio track is added to a stream on the // fly and the report has not been set up yet. Do nothing in this case. @@ -905,7 +904,8 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track, stats.echo_delay_std_ms); } -bool StatsCollector::GetTrackIdBySsrc(uint32 ssrc, std::string* track_id, +bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc, + std::string* track_id, StatsReport::Direction direction) { RTC_DCHECK(session_->signaling_thread()->IsCurrent()); if (direction == StatsReport::kSend) { diff --git a/talk/app/webrtc/statscollector.h b/talk/app/webrtc/statscollector.h index 99130a3f01..add26c6465 100644 --- a/talk/app/webrtc/statscollector.h +++ b/talk/app/webrtc/statscollector.h @@ -67,11 +67,11 @@ class StatsCollector { void AddStream(MediaStreamInterface* stream); // Adds a local audio track that is used for getting some voice statistics. - void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc); + void AddLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc); // Removes a local audio tracks that is used for getting some voice // statistics. - void RemoveLocalAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc); + void RemoveLocalAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc); // Gather statistics from the session and store them for future use. void UpdateStats(PeerConnectionInterface::StatsOutputLevel level); @@ -89,8 +89,10 @@ class StatsCollector { // Prepare a local or remote SSRC report for the given ssrc. Used internally // in the ExtractStatsFromList template. - StatsReport* PrepareReport(bool local, uint32 ssrc, - const StatsReport::Id& transport_id, StatsReport::Direction direction); + StatsReport* PrepareReport(bool local, + uint32_t ssrc, + const StatsReport::Id& transport_id, + StatsReport::Direction direction); // Method used by the unittest to force a update of stats since UpdateStats() // that occur less than kMinGatherStatsPeriod number of ms apart will be @@ -139,7 +141,8 @@ class StatsCollector { // Helper method to get the id for the track identified by ssrc. // |direction| tells if the track is for sending or receiving. - bool GetTrackIdBySsrc(uint32 ssrc, std::string* track_id, + bool GetTrackIdBySsrc(uint32_t ssrc, + std::string* track_id, StatsReport::Direction direction); // Helper method to update the timestamp of track records. @@ -155,7 +158,7 @@ class StatsCollector { // TODO(tommi): We appear to be holding on to raw pointers to reference // counted objects? We should be using scoped_refptr here. - typedef std::vector > + typedef std::vector > LocalAudioTrackVector; LocalAudioTrackVector local_audio_tracks_; }; diff --git a/talk/app/webrtc/statscollector_unittest.cc b/talk/app/webrtc/statscollector_unittest.cc index 34a1c90cfb..21f9df8e8f 100644 --- a/talk/app/webrtc/statscollector_unittest.cc +++ b/talk/app/webrtc/statscollector_unittest.cc @@ -78,7 +78,7 @@ const char kNotFound[] = "NOT FOUND"; // Constant names for track identification. const char kLocalTrackId[] = "local_track_id"; const char kRemoteTrackId[] = "remote_track_id"; -const uint32 kSsrcOfTrack = 1234; +const uint32_t kSsrcOfTrack = 1234; class MockWebRtcSession : public webrtc::WebRtcSession { public: @@ -91,8 +91,8 @@ class MockWebRtcSession : public webrtc::WebRtcSession { MOCK_CONST_METHOD0(mediastream_signaling, const MediaStreamSignaling*()); // Libjingle uses "local" for a outgoing track, and "remote" for a incoming // track. - MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32, std::string*)); - MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32, std::string*)); + MOCK_METHOD2(GetLocalTrackIdBySsrc, bool(uint32_t, std::string*)); + MOCK_METHOD2(GetRemoteTrackIdBySsrc, bool(uint32_t, std::string*)); MOCK_METHOD1(GetTransportStats, bool(cricket::SessionStats*)); MOCK_METHOD2(GetLocalCertificate, bool(const std::string& transport_name, @@ -301,7 +301,7 @@ void VerifyVoiceReceiverInfoReport( EXPECT_EQ(rtc::ToString(info.audio_level), value_in_report); EXPECT_TRUE(GetValue( report, StatsReport::kStatsValueNameBytesReceived, &value_in_report)); - EXPECT_EQ(rtc::ToString(info.bytes_rcvd), value_in_report); + EXPECT_EQ(rtc::ToString(info.bytes_rcvd), value_in_report); EXPECT_TRUE(GetValue( report, StatsReport::kStatsValueNameJitterReceived, &value_in_report)); EXPECT_EQ(rtc::ToString(info.jitter_ms), value_in_report); @@ -367,7 +367,7 @@ void VerifyVoiceSenderInfoReport(const StatsReport* report, EXPECT_EQ(sinfo.codec_name, value_in_report); EXPECT_TRUE(GetValue( report, StatsReport::kStatsValueNameBytesSent, &value_in_report)); - EXPECT_EQ(rtc::ToString(sinfo.bytes_sent), value_in_report); + EXPECT_EQ(rtc::ToString(sinfo.bytes_sent), value_in_report); EXPECT_TRUE(GetValue( report, StatsReport::kStatsValueNamePacketsSent, &value_in_report)); EXPECT_EQ(rtc::ToString(sinfo.packets_sent), value_in_report); @@ -610,7 +610,7 @@ class StatsCollectorTest : public testing::Test { EXPECT_EQ(audio_track->id(), track_id); std::string ssrc_id = ExtractSsrcStatsValue( *reports, StatsReport::kStatsValueNameSsrc); - EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); + EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); // Verifies the values in the track report. if (voice_sender_info) { @@ -633,7 +633,7 @@ class StatsCollectorTest : public testing::Test { EXPECT_EQ(audio_track->id(), track_id); ssrc_id = ExtractSsrcStatsValue(track_reports, StatsReport::kStatsValueNameSsrc); - EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); + EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); if (voice_sender_info) VerifyVoiceSenderInfoReport(track_report, *voice_sender_info); if (voice_receiver_info) @@ -775,9 +775,8 @@ TEST_F(StatsCollectorTest, ExtractDataInfo) { EXPECT_EQ(label, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports, StatsReport::kStatsValueNameLabel)); - EXPECT_EQ(rtc::ToString(id), - ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, - reports, + EXPECT_EQ(rtc::ToString(id), + ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports, StatsReport::kStatsValueNameDataChannelId)); EXPECT_EQ(state, ExtractStatsValue(StatsReport::kStatsReportTypeDataChannel, reports, @@ -810,7 +809,7 @@ TEST_F(StatsCollectorTest, BytesCounterHandles64Bits) { cricket::VideoSenderInfo video_sender_info; cricket::VideoMediaInfo stats_read; // The number of bytes must be larger than 0xFFFFFFFF for this test. - const int64 kBytesSent = 12345678901234LL; + const int64_t kBytesSent = 12345678901234LL; const std::string kBytesSentString("12345678901234"); AddOutgoingVideoTrackStats(); @@ -858,7 +857,7 @@ TEST_F(StatsCollectorTest, BandwidthEstimationInfoIsReported) { cricket::VideoMediaInfo stats_read; // Set up an SSRC just to test that we get both kinds of stats back: SSRC and // BWE. - const int64 kBytesSent = 12345678901234LL; + const int64_t kBytesSent = 12345678901234LL; const std::string kBytesSentString("12345678901234"); AddOutgoingVideoTrackStats(); @@ -973,7 +972,7 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { // Constructs an ssrc stats update. cricket::VideoSenderInfo video_sender_info; cricket::VideoMediaInfo stats_read; - const int64 kBytesSent = 12345678901234LL; + const int64_t kBytesSent = 12345678901234LL; // Construct a stats value to read. video_sender_info.add_ssrc(1234); @@ -1009,7 +1008,7 @@ TEST_F(StatsCollectorTest, TrackAndSsrcObjectExistAfterUpdateSsrcStats) { std::string ssrc_id = ExtractSsrcStatsValue( reports, StatsReport::kStatsValueNameSsrc); - EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); + EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); std::string track_id = ExtractSsrcStatsValue( reports, StatsReport::kStatsValueNameTrackId); @@ -1037,7 +1036,7 @@ TEST_F(StatsCollectorTest, TransportObjectLinkedFromSsrcObject) { // Constructs an ssrc stats update. cricket::VideoSenderInfo video_sender_info; cricket::VideoMediaInfo stats_read; - const int64 kBytesSent = 12345678901234LL; + const int64_t kBytesSent = 12345678901234LL; // Construct a stats value to read. video_sender_info.add_ssrc(1234); @@ -1179,7 +1178,7 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { // Constructs an ssrc stats update. cricket::VideoReceiverInfo video_receiver_info; cricket::VideoMediaInfo stats_read; - const int64 kNumOfPacketsConcealed = 54321; + const int64_t kNumOfPacketsConcealed = 54321; // Construct a stats value to read. video_receiver_info.add_ssrc(1234); @@ -1205,7 +1204,7 @@ TEST_F(StatsCollectorTest, ReportsFromRemoteTrack) { std::string ssrc_id = ExtractSsrcStatsValue( reports, StatsReport::kStatsValueNameSsrc); - EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); + EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); std::string track_id = ExtractSsrcStatsValue( reports, StatsReport::kStatsValueNameTrackId); @@ -1227,7 +1226,7 @@ TEST_F(StatsCollectorTest, IceCandidateReport) { rtc::SocketAddress local_address(local_ip, local_port); rtc::SocketAddress remote_address(remote_ip, remote_port); rtc::AdapterType network_type = rtc::ADAPTER_TYPE_ETHERNET; - uint32 priority = 1000; + uint32_t priority = 1000; cricket::Candidate c; ASSERT(c.id().length() > 0); @@ -1590,7 +1589,7 @@ TEST_F(StatsCollectorTest, GetStatsAfterRemoveAudioStream) { EXPECT_EQ(kLocalTrackId, track_id); std::string ssrc_id = ExtractSsrcStatsValue( reports, StatsReport::kStatsValueNameSsrc); - EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); + EXPECT_EQ(rtc::ToString(kSsrcOfTrack), ssrc_id); // Verifies the values in the track report, no value will be changed by the // AudioTrackInterface::GetSignalValue() and diff --git a/talk/app/webrtc/statstypes.cc b/talk/app/webrtc/statstypes.cc index 51ec7fd8a3..e45833c668 100644 --- a/talk/app/webrtc/statstypes.cc +++ b/talk/app/webrtc/statstypes.cc @@ -229,7 +229,7 @@ bool StatsReport::IdBase::Equals(const IdBase& other) const { return other.type_ == type_; } -StatsReport::Value::Value(StatsValueName name, int64 value, Type int_type) +StatsReport::Value::Value(StatsValueName name, int64_t value, Type int_type) : name(name), type_(int_type) { RTC_DCHECK(type_ == kInt || type_ == kInt64); type_ == kInt ? value_.int_ = static_cast(value) : value_.int64_ = value; @@ -331,7 +331,7 @@ bool StatsReport::Value::operator==(const char* value) const { return value == value_.static_string_; } -bool StatsReport::Value::operator==(int64 value) const { +bool StatsReport::Value::operator==(int64_t value) const { return type_ == kInt ? value_.int_ == static_cast(value) : (type_ == kInt64 ? value_.int64_ == value : false); } @@ -353,7 +353,7 @@ int StatsReport::Value::int_val() const { return value_.int_; } -int64 StatsReport::Value::int64_val() const { +int64_t StatsReport::Value::int64_val() const { RTC_DCHECK(type_ == kInt64); return value_.int64_; } @@ -682,7 +682,7 @@ void StatsReport::AddString(StatsReport::StatsValueName name, values_[name] = ValuePtr(new Value(name, value)); } -void StatsReport::AddInt64(StatsReport::StatsValueName name, int64 value) { +void StatsReport::AddInt64(StatsReport::StatsValueName name, int64_t value) { const Value* found = FindValue(name); if (!found || !(*found == value)) values_[name] = ValuePtr(new Value(name, value, Value::kInt64)); @@ -690,7 +690,7 @@ void StatsReport::AddInt64(StatsReport::StatsValueName name, int64 value) { void StatsReport::AddInt(StatsReport::StatsValueName name, int value) { const Value* found = FindValue(name); - if (!found || !(*found == static_cast(value))) + if (!found || !(*found == static_cast(value))) values_[name] = ValuePtr(new Value(name, value, Value::kInt)); } diff --git a/talk/app/webrtc/statstypes.h b/talk/app/webrtc/statstypes.h index 33b2fa7410..7fa9f3212d 100644 --- a/talk/app/webrtc/statstypes.h +++ b/talk/app/webrtc/statstypes.h @@ -250,16 +250,16 @@ class StatsReport { struct Value { enum Type { - kInt, // int. - kInt64, // int64. - kFloat, // float. - kString, // std::string + kInt, // int. + kInt64, // int64_t. + kFloat, // float. + kString, // std::string kStaticString, // const char*. - kBool, // bool. - kId, // Id. + kBool, // bool. + kId, // Id. }; - Value(StatsValueName name, int64 value, Type int_type); + Value(StatsValueName name, int64_t value, Type int_type); Value(StatsValueName name, float f); Value(StatsValueName name, const std::string& value); Value(StatsValueName name, const char* value); @@ -281,7 +281,7 @@ class StatsReport { // kString and kStaticString too. bool operator==(const std::string& value) const; bool operator==(const char* value) const; - bool operator==(int64 value) const; + bool operator==(int64_t value) const; bool operator==(bool value) const; bool operator==(float value) const; bool operator==(const Id& value) const; @@ -289,7 +289,7 @@ class StatsReport { // Getters that allow getting the native value directly. // The caller must know the type beforehand or else hit a check. int int_val() const; - int64 int64_val() const; + int64_t int64_val() const; float float_val() const; const char* static_string_val() const; const std::string& string_val() const; @@ -312,7 +312,7 @@ class StatsReport { // TODO(tommi): Use C++ 11 union and make value_ const. union InternalType { int int_; - int64 int64_; + int64_t int64_; float float_; bool bool_; std::string* string_; @@ -355,7 +355,7 @@ class StatsReport { void AddString(StatsValueName name, const std::string& value); void AddString(StatsValueName name, const char* value); - void AddInt64(StatsValueName name, int64 value); + void AddInt64(StatsValueName name, int64_t value); void AddInt(StatsValueName name, int value); void AddFloat(StatsValueName name, float value); void AddBoolean(StatsValueName name, bool value); diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.cc b/talk/app/webrtc/test/fakeaudiocapturemodule.cc index 32f9c840be..3564d28d25 100644 --- a/talk/app/webrtc/test/fakeaudiocapturemodule.cc +++ b/talk/app/webrtc/test/fakeaudiocapturemodule.cc @@ -40,7 +40,7 @@ static const int kHighSampleValue = 10000; // Same value as src/modules/audio_device/main/source/audio_device_config.h in // https://code.google.com/p/webrtc/ -static const uint32 kAdmMaxIdleTimeProcess = 1000; +static const uint32_t kAdmMaxIdleTimeProcess = 1000; // Constants here are derived by running VoE using a real ADM. // The constants correspond to 10ms of mono audio at 44kHz. @@ -90,12 +90,12 @@ int FakeAudioCaptureModule::frames_received() const { } int64_t FakeAudioCaptureModule::TimeUntilNextProcess() { - const uint32 current_time = rtc::Time(); + const uint32_t current_time = rtc::Time(); if (current_time < last_process_time_ms_) { // TODO: wraparound could be handled more gracefully. return 0; } - const uint32 elapsed_time = current_time - last_process_time_ms_; + const uint32_t elapsed_time = current_time - last_process_time_ms_; if (kAdmMaxIdleTimeProcess < elapsed_time) { return 0; } @@ -684,9 +684,9 @@ void FakeAudioCaptureModule::ProcessFrameP() { } next_frame_time_ += kTimePerFrameMs; - const uint32 current_time = rtc::Time(); - const uint32 wait_time = (next_frame_time_ > current_time) ? - next_frame_time_ - current_time : 0; + const uint32_t current_time = rtc::Time(); + const uint32_t wait_time = + (next_frame_time_ > current_time) ? next_frame_time_ - current_time : 0; process_thread_->PostDelayed(wait_time, this, MSG_RUN_PROCESS); } diff --git a/talk/app/webrtc/test/fakeaudiocapturemodule.h b/talk/app/webrtc/test/fakeaudiocapturemodule.h index 65a03c8404..4284b9ed51 100644 --- a/talk/app/webrtc/test/fakeaudiocapturemodule.h +++ b/talk/app/webrtc/test/fakeaudiocapturemodule.h @@ -53,7 +53,7 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, public rtc::MessageHandler { public: - typedef uint16 Sample; + typedef uint16_t Sample; // The value for the following constants have been derived by running VoE // using a real ADM. The constants correspond to 10ms of mono audio at 44kHz. @@ -242,7 +242,7 @@ class FakeAudioCaptureModule // The time in milliseconds when Process() was last called or 0 if no call // has been made. - uint32 last_process_time_ms_; + uint32_t last_process_time_ms_; // Callback for playout and recording. webrtc::AudioTransport* audio_callback_; @@ -262,7 +262,7 @@ class FakeAudioCaptureModule // wall clock time the next frame should be generated and received. started_ // ensures that next_frame_time_ can be initialized properly on first call. bool started_; - uint32 next_frame_time_; + uint32_t next_frame_time_; rtc::scoped_ptr process_thread_; diff --git a/talk/app/webrtc/test/fakedatachannelprovider.h b/talk/app/webrtc/test/fakedatachannelprovider.h index eb86873c90..9a8352e1cd 100644 --- a/talk/app/webrtc/test/fakedatachannelprovider.h +++ b/talk/app/webrtc/test/fakedatachannelprovider.h @@ -137,11 +137,11 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { return connected_channels_.find(data_channel) != connected_channels_.end(); } - bool IsSendStreamAdded(uint32 stream) const { + bool IsSendStreamAdded(uint32_t stream) const { return send_ssrcs_.find(stream) != send_ssrcs_.end(); } - bool IsRecvStreamAdded(uint32 stream) const { + bool IsRecvStreamAdded(uint32_t stream) const { return recv_ssrcs_.find(stream) != recv_ssrcs_.end(); } @@ -152,6 +152,6 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface { bool ready_to_send_; bool transport_error_; std::set connected_channels_; - std::set send_ssrcs_; - std::set recv_ssrcs_; + std::set send_ssrcs_; + std::set recv_ssrcs_; }; diff --git a/talk/app/webrtc/test/fakemediastreamsignaling.h b/talk/app/webrtc/test/fakemediastreamsignaling.h index c98a24d7ab..562c4ad306 100644 --- a/talk/app/webrtc/test/fakemediastreamsignaling.h +++ b/talk/app/webrtc/test/fakemediastreamsignaling.h @@ -90,16 +90,16 @@ class FakeMediaStreamSignaling : public webrtc::MediaStreamSignaling, virtual void OnAddDataChannel(webrtc::DataChannelInterface* data_channel) {} virtual void OnAddLocalAudioTrack(webrtc::MediaStreamInterface* stream, webrtc::AudioTrackInterface* audio_track, - uint32 ssrc) {} + uint32_t ssrc) {} virtual void OnAddLocalVideoTrack(webrtc::MediaStreamInterface* stream, webrtc::VideoTrackInterface* video_track, - uint32 ssrc) {} + uint32_t ssrc) {} virtual void OnAddRemoteAudioTrack(webrtc::MediaStreamInterface* stream, webrtc::AudioTrackInterface* audio_track, - uint32 ssrc) {} + uint32_t ssrc) {} virtual void OnAddRemoteVideoTrack(webrtc::MediaStreamInterface* stream, webrtc::VideoTrackInterface* video_track, - uint32 ssrc) {} + uint32_t ssrc) {} virtual void OnRemoveRemoteAudioTrack( webrtc::MediaStreamInterface* stream, webrtc::AudioTrackInterface* audio_track) {} @@ -108,7 +108,7 @@ class FakeMediaStreamSignaling : public webrtc::MediaStreamSignaling, webrtc::VideoTrackInterface* video_track) {} virtual void OnRemoveLocalAudioTrack(webrtc::MediaStreamInterface* stream, webrtc::AudioTrackInterface* audio_track, - uint32 ssrc) {} + uint32_t ssrc) {} virtual void OnRemoveLocalVideoTrack( webrtc::MediaStreamInterface* stream, webrtc::VideoTrackInterface* video_track) {} diff --git a/talk/app/webrtc/test/mockpeerconnectionobservers.h b/talk/app/webrtc/test/mockpeerconnectionobservers.h index d2697b4364..f1bdbee9f5 100644 --- a/talk/app/webrtc/test/mockpeerconnectionobservers.h +++ b/talk/app/webrtc/test/mockpeerconnectionobservers.h @@ -98,7 +98,7 @@ class MockDataChannelObserver : public webrtc::DataChannelObserver { channel_->UnregisterObserver(); } - void OnBufferedAmountChange(uint64 previous_amount) override {} + void OnBufferedAmountChange(uint64_t previous_amount) override {} void OnStateChange() override { state_ = channel_->state(); } void OnMessage(const DataBuffer& buffer) override { diff --git a/talk/app/webrtc/videosource.cc b/talk/app/webrtc/videosource.cc index af5f628490..b33f5f9e13 100644 --- a/talk/app/webrtc/videosource.cc +++ b/talk/app/webrtc/videosource.cc @@ -250,10 +250,10 @@ const cricket::VideoFormat& GetBestCaptureFormat( std::vector::const_iterator it = formats.begin(); std::vector::const_iterator best_it = formats.begin(); int best_diff_area = std::abs(default_area - it->width * it->height); - int64 best_diff_interval = kDefaultFormat.interval; + int64_t best_diff_interval = kDefaultFormat.interval; for (; it != formats.end(); ++it) { int diff_area = std::abs(default_area - it->width * it->height); - int64 diff_interval = std::abs(kDefaultFormat.interval - it->interval); + int64_t diff_interval = std::abs(kDefaultFormat.interval - it->interval); if (diff_area < best_diff_area || (diff_area == best_diff_area && diff_interval < best_diff_interval)) { best_diff_area = diff_area; diff --git a/talk/app/webrtc/webrtcsdp.cc b/talk/app/webrtc/webrtcsdp.cc index 28d4e9e8b1..961833501d 100644 --- a/talk/app/webrtc/webrtcsdp.cc +++ b/talk/app/webrtc/webrtcsdp.cc @@ -231,7 +231,7 @@ struct SsrcInfo { // Create random string (which will be used as track label later)? msid_appdata(rtc::CreateRandomString(8)) { } - uint32 ssrc_id; + uint32_t ssrc_id; std::string cname; std::string msid_identifier; std::string msid_appdata; @@ -525,8 +525,10 @@ static bool HasAttribute(const std::string& line, return (line.compare(kLinePrefixLength, attribute.size(), attribute) == 0); } -static bool AddSsrcLine(uint32 ssrc_id, const std::string& attribute, - const std::string& value, std::string* message) { +static bool AddSsrcLine(uint32_t ssrc_id, + const std::string& attribute, + const std::string& value, + std::string* message) { // RFC 5576 // a=ssrc: : std::ostringstream os; @@ -1004,7 +1006,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate, return false; } const std::string& transport = fields[2]; - uint32 priority = 0; + uint32_t priority = 0; if (!GetValueFromString(first_line, fields[3], &priority, error)) { return false; } @@ -1078,7 +1080,7 @@ bool ParseCandidate(const std::string& message, Candidate* candidate, // kept for backwards compatibility. std::string username; std::string password; - uint32 generation = 0; + uint32_t generation = 0; for (size_t i = current_position; i + 1 < fields.size(); ++i) { // RFC 5245 // *(SP extension-att-name SP extension-att-value) @@ -1441,16 +1443,16 @@ void BuildRtpContentAttributes( std::ostringstream os; InitAttrLine(kAttributeSsrcGroup, &os); os << kSdpDelimiterColon << track->ssrc_groups[i].semantics; - std::vector::const_iterator ssrc = + std::vector::const_iterator ssrc = track->ssrc_groups[i].ssrcs.begin(); for (; ssrc != track->ssrc_groups[i].ssrcs.end(); ++ssrc) { - os << kSdpDelimiterSpace << rtc::ToString(*ssrc); + os << kSdpDelimiterSpace << rtc::ToString(*ssrc); } AddLine(os.str(), message); } // Build the ssrc lines for each ssrc. for (size_t i = 0; i < track->ssrcs.size(); ++i) { - uint32 ssrc = track->ssrcs[i]; + uint32_t ssrc = track->ssrcs[i]; // RFC 5576 // a=ssrc: cname: AddSsrcLine(ssrc, kSsrcAttributeCname, @@ -2634,7 +2636,7 @@ bool ParseContent(const std::string& message, if (ssrc_group->ssrcs.empty()) { continue; } - uint32 ssrc = ssrc_group->ssrcs.front(); + uint32_t ssrc = ssrc_group->ssrcs.front(); for (StreamParamsVec::iterator track = tracks.begin(); track != tracks.end(); ++track) { if (track->has_ssrc(ssrc)) { @@ -2706,7 +2708,7 @@ bool ParseSsrcAttribute(const std::string& line, SsrcInfoVec* ssrc_infos, if (!GetValue(field1, kAttributeSsrc, &ssrc_id_s, error)) { return false; } - uint32 ssrc_id = 0; + uint32_t ssrc_id = 0; if (!GetValueFromString(line, ssrc_id_s, &ssrc_id, error)) { return false; } @@ -2783,9 +2785,9 @@ bool ParseSsrcGroupAttribute(const std::string& line, if (!GetValue(fields[0], kAttributeSsrcGroup, &semantics, error)) { return false; } - std::vector ssrcs; + std::vector ssrcs; for (size_t i = 1; i < fields.size(); ++i) { - uint32 ssrc = 0; + uint32_t ssrc = 0; if (!GetValueFromString(line, fields[i], &ssrc, error)) { return false; } diff --git a/talk/app/webrtc/webrtcsdp_unittest.cc b/talk/app/webrtc/webrtcsdp_unittest.cc index a534c23920..a972daa62d 100644 --- a/talk/app/webrtc/webrtcsdp_unittest.cc +++ b/talk/app/webrtc/webrtcsdp_unittest.cc @@ -75,9 +75,9 @@ using webrtc::SessionDescriptionInterface; typedef std::vector AudioCodecs; typedef std::vector Candidates; -static const uint32 kDefaultSctpPort = 5000; +static const uint32_t kDefaultSctpPort = 5000; static const char kSessionTime[] = "t=0 0\r\n"; -static const uint32 kCandidatePriority = 2130706432U; // pref = 1.0 +static const uint32_t kCandidatePriority = 2130706432U; // pref = 1.0 static const char kCandidateUfragVoice[] = "ufrag_voice"; static const char kCandidatePwdVoice[] = "pwd_voice"; static const char kAttributeIcePwdVoice[] = "a=ice-pwd:pwd_voice\r\n"; @@ -86,7 +86,7 @@ static const char kCandidatePwdVideo[] = "pwd_video"; static const char kCandidateUfragData[] = "ufrag_data"; static const char kCandidatePwdData[] = "pwd_data"; static const char kAttributeIcePwdVideo[] = "a=ice-pwd:pwd_video\r\n"; -static const uint32 kCandidateGeneration = 2; +static const uint32_t kCandidateGeneration = 2; static const char kCandidateFoundation1[] = "a0+B/1"; static const char kCandidateFoundation2[] = "a0+B/2"; static const char kCandidateFoundation3[] = "a0+B/3"; @@ -107,11 +107,9 @@ static const char kExtmap[] = static const char kExtmapWithDirectionAndAttribute[] = "a=extmap:1/sendrecv http://example.com/082005/ext.htm#ttime a1 a2\r\n"; -static const uint8 kIdentityDigest[] = {0x4A, 0xAD, 0xB9, 0xB1, - 0x3F, 0x82, 0x18, 0x3B, - 0x54, 0x02, 0x12, 0xDF, - 0x3E, 0x5D, 0x49, 0x6B, - 0x19, 0xE5, 0x7C, 0xAB}; +static const uint8_t kIdentityDigest[] = { + 0x4A, 0xAD, 0xB9, 0xB1, 0x3F, 0x82, 0x18, 0x3B, 0x54, 0x02, + 0x12, 0xDF, 0x3E, 0x5D, 0x49, 0x6B, 0x19, 0xE5, 0x7C, 0xAB}; static const char kDtlsSctp[] = "DTLS/SCTP"; static const char kUdpDtlsSctp[] = "UDP/DTLS/SCTP"; @@ -409,26 +407,26 @@ static const char kDataContentName[] = "data_content_name"; static const char kStreamLabel1[] = "local_stream_1"; static const char kStream1Cname[] = "stream_1_cname"; static const char kAudioTrackId1[] = "audio_track_id_1"; -static const uint32 kAudioTrack1Ssrc = 1; +static const uint32_t kAudioTrack1Ssrc = 1; static const char kVideoTrackId1[] = "video_track_id_1"; -static const uint32 kVideoTrack1Ssrc = 2; +static const uint32_t kVideoTrack1Ssrc = 2; static const char kVideoTrackId2[] = "video_track_id_2"; -static const uint32 kVideoTrack2Ssrc = 3; +static const uint32_t kVideoTrack2Ssrc = 3; // MediaStream 2 static const char kStreamLabel2[] = "local_stream_2"; static const char kStream2Cname[] = "stream_2_cname"; static const char kAudioTrackId2[] = "audio_track_id_2"; -static const uint32 kAudioTrack2Ssrc = 4; +static const uint32_t kAudioTrack2Ssrc = 4; static const char kVideoTrackId3[] = "video_track_id_3"; -static const uint32 kVideoTrack3Ssrc = 5; -static const uint32 kVideoTrack4Ssrc = 6; +static const uint32_t kVideoTrack3Ssrc = 5; +static const uint32_t kVideoTrack4Ssrc = 6; // DataChannel static const char kDataChannelLabel[] = "data_channel"; static const char kDataChannelMsid[] = "data_channeld0"; static const char kDataChannelCname[] = "data_channel_cname"; -static const uint32 kDataChannelSsrc = 10; +static const uint32_t kDataChannelSsrc = 10; // Candidate static const char kDummyMid[] = "dummy_mid"; @@ -2157,7 +2155,7 @@ TEST_F(WebRtcSdpTest, DeserializeSdpWithCorruptedSctpDataChannels) { TEST_F(WebRtcSdpTest, DeserializeSdpWithSctpDataChannelAndNewPort) { AddSctpDataChannel(); - const uint16 kUnusualSctpPort = 9556; + const uint16_t kUnusualSctpPort = 9556; char default_portstr[16]; char unusual_portstr[16]; rtc::sprintfn(default_portstr, sizeof(default_portstr), "%d", diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc index 15ddc28c7f..2ab9a1e696 100644 --- a/talk/app/webrtc/webrtcsession.cc +++ b/talk/app/webrtc/webrtcsession.cc @@ -265,9 +265,9 @@ static void UpdateSessionDescriptionSecurePolicy(cricket::CryptoType type, } } -static bool GetAudioSsrcByTrackId( - const SessionDescription* session_description, - const std::string& track_id, uint32 *ssrc) { +static bool GetAudioSsrcByTrackId(const SessionDescription* session_description, + const std::string& track_id, + uint32_t* ssrc) { const cricket::ContentInfo* audio_info = cricket::GetFirstAudioContent(session_description); if (!audio_info) { @@ -289,7 +289,8 @@ static bool GetAudioSsrcByTrackId( } static bool GetTrackIdBySsrc(const SessionDescription* session_description, - uint32 ssrc, std::string* track_id) { + uint32_t ssrc, + std::string* track_id) { ASSERT(track_id != NULL); const cricket::ContentInfo* audio_info = @@ -461,7 +462,7 @@ static void SetOptionFromOptionalConstraint( } } -uint32 ConvertIceTransportTypeToCandidateFilter( +uint32_t ConvertIceTransportTypeToCandidateFilter( PeerConnectionInterface::IceTransportsType type) { switch (type) { case PeerConnectionInterface::kNone: @@ -1212,13 +1213,15 @@ bool WebRtcSession::SetIceTransports( ConvertIceTransportTypeToCandidateFilter(type)); } -bool WebRtcSession::GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id) { +bool WebRtcSession::GetLocalTrackIdBySsrc(uint32_t ssrc, + std::string* track_id) { if (!base_local_description()) return false; return webrtc::GetTrackIdBySsrc(base_local_description(), ssrc, track_id); } -bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id) { +bool WebRtcSession::GetRemoteTrackIdBySsrc(uint32_t ssrc, + std::string* track_id) { if (!base_remote_description()) return false; return webrtc::GetTrackIdBySsrc(base_remote_description(), ssrc, track_id); @@ -1230,7 +1233,8 @@ std::string WebRtcSession::BadStateErrMsg(State state) { return desc.str(); } -void WebRtcSession::SetAudioPlayout(uint32 ssrc, bool enable, +void WebRtcSession::SetAudioPlayout(uint32_t ssrc, + bool enable, cricket::AudioRenderer* renderer) { ASSERT(signaling_thread()->IsCurrent()); if (!voice_channel_) { @@ -1250,7 +1254,8 @@ void WebRtcSession::SetAudioPlayout(uint32 ssrc, bool enable, } } -void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable, +void WebRtcSession::SetAudioSend(uint32_t ssrc, + bool enable, const cricket::AudioOptions& options, cricket::AudioRenderer* renderer) { ASSERT(signaling_thread()->IsCurrent()); @@ -1263,7 +1268,7 @@ void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable, } } -void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) { +void WebRtcSession::SetAudioPlayoutVolume(uint32_t ssrc, double volume) { ASSERT(signaling_thread()->IsCurrent()); ASSERT(volume >= 0 && volume <= 10); if (!voice_channel_) { @@ -1276,7 +1281,7 @@ void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) { } } -bool WebRtcSession::SetCaptureDevice(uint32 ssrc, +bool WebRtcSession::SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) { ASSERT(signaling_thread()->IsCurrent()); @@ -1296,7 +1301,7 @@ bool WebRtcSession::SetCaptureDevice(uint32 ssrc, return true; } -void WebRtcSession::SetVideoPlayout(uint32 ssrc, +void WebRtcSession::SetVideoPlayout(uint32_t ssrc, bool enable, cricket::VideoRenderer* renderer) { ASSERT(signaling_thread()->IsCurrent()); @@ -1312,7 +1317,8 @@ void WebRtcSession::SetVideoPlayout(uint32 ssrc, } } -void WebRtcSession::SetVideoSend(uint32 ssrc, bool enable, +void WebRtcSession::SetVideoSend(uint32_t ssrc, + bool enable, const cricket::VideoOptions* options) { ASSERT(signaling_thread()->IsCurrent()); if (!video_channel_) { @@ -1333,7 +1339,7 @@ bool WebRtcSession::CanInsertDtmf(const std::string& track_id) { LOG(LS_ERROR) << "CanInsertDtmf: No audio channel exists."; return false; } - uint32 send_ssrc = 0; + uint32_t send_ssrc = 0; // The Dtmf is negotiated per channel not ssrc, so we only check if the ssrc // exists. if (!GetAudioSsrcByTrackId(base_local_description(), track_id, @@ -1351,7 +1357,7 @@ bool WebRtcSession::InsertDtmf(const std::string& track_id, LOG(LS_ERROR) << "InsertDtmf: No audio channel exists."; return false; } - uint32 send_ssrc = 0; + uint32_t send_ssrc = 0; if (!VERIFY(GetAudioSsrcByTrackId(base_local_description(), track_id, &send_ssrc))) { LOG(LS_ERROR) << "InsertDtmf: Track does not exist: " << track_id; diff --git a/talk/app/webrtc/webrtcsession.h b/talk/app/webrtc/webrtcsession.h index b3d76bf6b4..6e4a9e92b4 100644 --- a/talk/app/webrtc/webrtcsession.h +++ b/talk/app/webrtc/webrtcsession.h @@ -198,25 +198,25 @@ class WebRtcSession : public cricket::BaseSession, } // Get the id used as a media stream track's "id" field from ssrc. - virtual bool GetLocalTrackIdBySsrc(uint32 ssrc, std::string* track_id); - virtual bool GetRemoteTrackIdBySsrc(uint32 ssrc, std::string* track_id); + virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id); + virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id); // AudioMediaProviderInterface implementation. - void SetAudioPlayout(uint32 ssrc, + void SetAudioPlayout(uint32_t ssrc, bool enable, cricket::AudioRenderer* renderer) override; - void SetAudioSend(uint32 ssrc, + void SetAudioSend(uint32_t ssrc, bool enable, const cricket::AudioOptions& options, cricket::AudioRenderer* renderer) override; - void SetAudioPlayoutVolume(uint32 ssrc, double volume) override; + void SetAudioPlayoutVolume(uint32_t ssrc, double volume) override; // Implements VideoMediaProviderInterface. - bool SetCaptureDevice(uint32 ssrc, cricket::VideoCapturer* camera) override; - void SetVideoPlayout(uint32 ssrc, + bool SetCaptureDevice(uint32_t ssrc, cricket::VideoCapturer* camera) override; + void SetVideoPlayout(uint32_t ssrc, bool enable, cricket::VideoRenderer* renderer) override; - void SetVideoSend(uint32 ssrc, + void SetVideoSend(uint32_t ssrc, bool enable, const cricket::VideoOptions* options) override; diff --git a/talk/app/webrtc/webrtcsession_unittest.cc b/talk/app/webrtc/webrtcsession_unittest.cc index dbe485cdbf..2853ca43a7 100644 --- a/talk/app/webrtc/webrtcsession_unittest.cc +++ b/talk/app/webrtc/webrtcsession_unittest.cc @@ -1465,8 +1465,8 @@ TEST_F(WebRtcSessionTest, TestCreateSdesOfferReceiveSdesAnswer) { // Verify the session id is the same and the session version is // increased. EXPECT_EQ(session_id_orig, offer->session_id()); - EXPECT_LT(rtc::FromString(session_version_orig), - rtc::FromString(offer->session_version())); + EXPECT_LT(rtc::FromString(session_version_orig), + rtc::FromString(offer->session_version())); SetLocalDescriptionWithoutError(offer); EXPECT_EQ(0u, video_channel_->send_streams().size()); @@ -1525,8 +1525,8 @@ TEST_F(WebRtcSessionTest, TestReceiveSdesOfferCreateSdesAnswer) { // Verify the session id is the same and the session version is // increased. EXPECT_EQ(session_id_orig, answer->session_id()); - EXPECT_LT(rtc::FromString(session_version_orig), - rtc::FromString(answer->session_version())); + EXPECT_LT(rtc::FromString(session_version_orig), + rtc::FromString(answer->session_version())); SetLocalDescriptionWithoutError(answer); ASSERT_EQ(2u, video_channel_->recv_streams().size()); @@ -3107,7 +3107,7 @@ TEST_F(WebRtcSessionTest, SetAudioPlayout) { cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); ASSERT_TRUE(channel != NULL); ASSERT_EQ(1u, channel->recv_streams().size()); - uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); + uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); double left_vol, right_vol; EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); EXPECT_EQ(1, left_vol); @@ -3132,7 +3132,7 @@ TEST_F(WebRtcSessionTest, SetAudioSend) { cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); ASSERT_TRUE(channel != NULL); ASSERT_EQ(1u, channel->send_streams().size()); - uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); + uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); cricket::AudioOptions options; @@ -3162,7 +3162,7 @@ TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); ASSERT_TRUE(channel != NULL); ASSERT_EQ(1u, channel->send_streams().size()); - uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); + uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); rtc::scoped_ptr renderer(new FakeAudioRenderer()); cricket::AudioOptions options; @@ -3187,7 +3187,7 @@ TEST_F(WebRtcSessionTest, SetVideoPlayout) { ASSERT_LT(0u, channel->renderers().size()); EXPECT_TRUE(channel->renderers().begin()->second == NULL); ASSERT_EQ(1u, channel->recv_streams().size()); - uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); + uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); cricket::FakeVideoRenderer renderer; session_->SetVideoPlayout(receive_ssrc, true, &renderer); EXPECT_TRUE(channel->renderers().begin()->second == &renderer); @@ -3202,7 +3202,7 @@ TEST_F(WebRtcSessionTest, SetVideoSend) { cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); ASSERT_TRUE(channel != NULL); ASSERT_EQ(1u, channel->send_streams().size()); - uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); + uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); cricket::VideoOptions* options = NULL; session_->SetVideoSend(send_ssrc, false, options); @@ -3236,7 +3236,7 @@ TEST_F(WebRtcSessionTest, InsertDtmf) { // Verify ASSERT_EQ(3U, channel->dtmf_info_queue().size()); - const uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); + const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, expected_duration, expected_flags)); EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc index f6414d314e..876931539a 100644 --- a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc +++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc @@ -44,7 +44,7 @@ static const char kFailedDueToIdentityFailed[] = static const char kFailedDueToSessionShutdown[] = " failed because the session was shut down"; -static const uint64 kInitSessionVersion = 2; +static const uint64_t kInitSessionVersion = 2; static bool CompareStream(const MediaSessionOptions::Stream& stream1, const MediaSessionOptions::Stream& stream2) { @@ -415,7 +415,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer( // Just increase the version number by one each time when a new offer // is created regardless if it's identical to the previous one or not. - // The |session_version_| is a uint64, the wrap around should not happen. + // The |session_version_| is a uint64_t, the wrap around should not happen. ASSERT(session_version_ + 1 > session_version_); JsepSessionDescription* offer(new JsepSessionDescription( JsepSessionDescription::kOffer)); @@ -459,7 +459,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer( // In that case, the version number in the "o=" line of the answer is // unrelated to the version number in the o line of the offer. // Get a new version number by increasing the |session_version_answer_|. - // The |session_version_| is a uint64, the wrap around should not happen. + // The |session_version_| is a uint64_t, the wrap around should not happen. ASSERT(session_version_ + 1 > session_version_); JsepSessionDescription* answer(new JsepSessionDescription( JsepSessionDescription::kAnswer)); diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.h b/talk/app/webrtc/webrtcsessiondescriptionfactory.h index 52b8da5d01..95fab63a3d 100644 --- a/talk/app/webrtc/webrtcsessiondescriptionfactory.h +++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.h @@ -186,7 +186,7 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler, MediaStreamSignaling* const mediastream_signaling_; cricket::TransportDescriptionFactory transport_desc_factory_; cricket::MediaSessionDescriptionFactory session_desc_factory_; - uint64 session_version_; + uint64_t session_version_; const rtc::scoped_ptr dtls_identity_store_; const rtc::scoped_refptr identity_request_observer_; diff --git a/talk/media/base/audioframe.h b/talk/media/base/audioframe.h old mode 100755 new mode 100644 index b0c8b047d4..157d0f1148 --- a/talk/media/base/audioframe.h +++ b/talk/media/base/audioframe.h @@ -38,14 +38,13 @@ class AudioFrame { sampling_frequency_(8000), stereo_(false) { } - AudioFrame(int16* audio, size_t audio_length, int sample_freq, bool stereo) + AudioFrame(int16_t* audio, size_t audio_length, int sample_freq, bool stereo) : audio10ms_(audio), length_(audio_length), sampling_frequency_(sample_freq), - stereo_(stereo) { - } + stereo_(stereo) {} - int16* GetData() { return audio10ms_; } + int16_t* GetData() { return audio10ms_; } size_t GetSize() const { return length_; } int GetSamplingFrequency() const { return sampling_frequency_; } bool GetStereo() const { return stereo_; } @@ -53,7 +52,7 @@ class AudioFrame { private: // TODO(janahan): currently the data is not owned by this class. // add ownership when we come up with the first use case that requires it. - int16* audio10ms_; + int16_t* audio10ms_; size_t length_; int sampling_frequency_; bool stereo_; diff --git a/talk/media/base/cpuid.cc b/talk/media/base/cpuid.cc index 8cf912ffba..daaf94e12f 100644 --- a/talk/media/base/cpuid.cc +++ b/talk/media/base/cpuid.cc @@ -43,7 +43,7 @@ void CpuInfo::MaskCpuFlagsForTest(int enable_flags) { bool IsCoreIOrBetter() { #if defined(__i386__) || defined(__x86_64__) || \ defined(_M_IX86) || defined(_M_X64) - uint32 cpu_info[4]; + uint32_t cpu_info[4]; libyuv::CpuId(0, 0, &cpu_info[0]); // Function 0: Vendor ID if (cpu_info[1] == 0x756e6547 && cpu_info[3] == 0x49656e69 && cpu_info[2] == 0x6c65746e) { // GenuineIntel diff --git a/talk/media/base/executablehelpers.h b/talk/media/base/executablehelpers.h index 2dde01084a..401890f4e8 100644 --- a/talk/media/base/executablehelpers.h +++ b/talk/media/base/executablehelpers.h @@ -42,7 +42,7 @@ namespace rtc { // Returns the path to the running executable or an empty path. // TODO(thorcarpenter): Consolidate with FluteClient::get_executable_dir. inline Pathname GetExecutablePath() { - const int32 kMaxExePathSize = 255; + const int32_t kMaxExePathSize = 255; #ifdef WIN32 TCHAR exe_path_buffer[kMaxExePathSize]; DWORD copied_length = GetModuleFileName(NULL, // NULL = Current process @@ -71,7 +71,7 @@ inline Pathname GetExecutablePath() { return rtc::Pathname(); } #elif defined LINUX - int32 copied_length = kMaxExePathSize - 1; + int32_t copied_length = kMaxExePathSize - 1; const char* kProcExeFmt = "/proc/%d/exe"; char proc_exe_link[40]; snprintf(proc_exe_link, sizeof(proc_exe_link), kProcExeFmt, getpid()); diff --git a/talk/media/base/fakemediaengine.h b/talk/media/base/fakemediaengine.h index 13ab8fa894..7325667aa5 100644 --- a/talk/media/base/fakemediaengine.h +++ b/talk/media/base/fakemediaengine.h @@ -113,7 +113,7 @@ template class RtpHelper : public Base { send_streams_.push_back(sp); return true; } - virtual bool RemoveSendStream(uint32 ssrc) { + virtual bool RemoveSendStream(uint32_t ssrc) { return RemoveStreamBySsrc(&send_streams_, ssrc); } virtual bool AddRecvStream(const StreamParams& sp) { @@ -124,10 +124,10 @@ template class RtpHelper : public Base { receive_streams_.push_back(sp); return true; } - virtual bool RemoveRecvStream(uint32 ssrc) { + virtual bool RemoveRecvStream(uint32_t ssrc) { return RemoveStreamBySsrc(&receive_streams_, ssrc); } - bool IsStreamMuted(uint32 ssrc) const { + bool IsStreamMuted(uint32_t ssrc) const { bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); // If |ssrc = 0| check if the first send stream is muted. if (!ret && ssrc == 0 && !send_streams_.empty()) { @@ -142,15 +142,15 @@ template class RtpHelper : public Base { const std::vector& recv_streams() const { return receive_streams_; } - bool HasRecvStream(uint32 ssrc) const { + bool HasRecvStream(uint32_t ssrc) const { return GetStreamBySsrc(receive_streams_, ssrc) != nullptr; } - bool HasSendStream(uint32 ssrc) const { + bool HasSendStream(uint32_t ssrc) const { return GetStreamBySsrc(send_streams_, ssrc) != nullptr; } // TODO(perkj): This is to support legacy unit test that only check one // sending stream. - uint32 send_ssrc() const { + uint32_t send_ssrc() const { if (send_streams_.empty()) return 0; return send_streams_[0].first_ssrc(); @@ -169,7 +169,7 @@ template class RtpHelper : public Base { } protected: - bool MuteStream(uint32 ssrc, bool mute) { + bool MuteStream(uint32_t ssrc, bool mute) { if (!HasSendStream(ssrc) && ssrc != 0) { return false; } @@ -218,10 +218,10 @@ template class RtpHelper : public Base { std::list rtcp_packets_; std::vector send_streams_; std::vector receive_streams_; - std::set muted_streams_; + std::set muted_streams_; bool fail_set_send_codecs_; bool fail_set_recv_codecs_; - uint32 send_ssrc_; + uint32_t send_ssrc_; std::string rtcp_cname_; bool ready_to_send_; }; @@ -229,10 +229,12 @@ template class RtpHelper : public Base { class FakeVoiceMediaChannel : public RtpHelper { public: struct DtmfInfo { - DtmfInfo(uint32 ssrc, int event_code, int duration, int flags) - : ssrc(ssrc), event_code(event_code), duration(duration), flags(flags) { - } - uint32 ssrc; + DtmfInfo(uint32_t ssrc, int event_code, int duration, int flags) + : ssrc(ssrc), + event_code(event_code), + duration(duration), + flags(flags) {} + uint32_t ssrc; int event_code; int duration; int flags; @@ -271,7 +273,8 @@ class FakeVoiceMediaChannel : public RtpHelper { virtual bool SetSend(SendFlags flag) { return set_sending(flag != SEND_NOTHING); } - virtual bool SetAudioSend(uint32 ssrc, bool enable, + virtual bool SetAudioSend(uint32_t ssrc, + bool enable, const AudioOptions* options, AudioRenderer* renderer) { if (!SetLocalRenderer(ssrc, renderer)) { @@ -291,14 +294,14 @@ class FakeVoiceMediaChannel : public RtpHelper { output_scalings_[sp.first_ssrc()] = OutputScaling(); return true; } - virtual bool RemoveRecvStream(uint32 ssrc) { + virtual bool RemoveRecvStream(uint32_t ssrc) { if (!RtpHelper::RemoveRecvStream(ssrc)) return false; output_scalings_.erase(ssrc); return true; } - virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { - std::map::iterator it = + virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) { + std::map::iterator it = remote_renderers_.find(ssrc); if (renderer) { if (it != remote_renderers_.end()) { @@ -336,15 +339,17 @@ class FakeVoiceMediaChannel : public RtpHelper { } return false; } - virtual bool InsertDtmf(uint32 ssrc, int event_code, int duration, + virtual bool InsertDtmf(uint32_t ssrc, + int event_code, + int duration, int flags) { dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags)); return true; } - virtual bool SetOutputScaling(uint32 ssrc, double left, double right) { + virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) { if (0 == ssrc) { - std::map::iterator it; + std::map::iterator it; for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) { it->second.left = left; it->second.right = right; @@ -357,7 +362,7 @@ class FakeVoiceMediaChannel : public RtpHelper { } return false; } - bool GetOutputScaling(uint32 ssrc, double* left, double* right) { + bool GetOutputScaling(uint32_t ssrc, double* left, double* right) { if (output_scalings_.find(ssrc) == output_scalings_.end()) return false; *left = output_scalings_[ssrc].left; @@ -420,7 +425,7 @@ class FakeVoiceMediaChannel : public RtpHelper { options_.SetAll(options); return true; } - bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) { + bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) { auto it = local_renderers_.find(ssrc); if (renderer) { if (it != local_renderers_.end()) { @@ -441,17 +446,19 @@ class FakeVoiceMediaChannel : public RtpHelper { FakeVoiceEngine* engine_; std::vector recv_codecs_; std::vector send_codecs_; - std::map output_scalings_; + std::map output_scalings_; std::vector dtmf_info_queue_; int time_since_last_typing_; AudioOptions options_; - std::map local_renderers_; - std::map remote_renderers_; + std::map local_renderers_; + std::map remote_renderers_; }; // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, - uint32 ssrc, int event_code, int duration, + uint32_t ssrc, + int event_code, + int duration, int flags) { return (info.duration == duration && info.event_code == event_code && info.flags == flags && info.ssrc == ssrc); @@ -475,18 +482,18 @@ class FakeVideoMediaChannel : public RtpHelper { const std::vector& codecs() const { return send_codecs(); } bool rendering() const { return playout(); } const VideoOptions& options() const { return options_; } - const std::map& renderers() const { + const std::map& renderers() const { return renderers_; } int max_bps() const { return max_bps_; } - bool GetSendStreamFormat(uint32 ssrc, VideoFormat* format) { + bool GetSendStreamFormat(uint32_t ssrc, VideoFormat* format) { if (send_formats_.find(ssrc) == send_formats_.end()) { return false; } *format = send_formats_[ssrc]; return true; } - virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) { + virtual bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) { if (send_formats_.find(ssrc) == send_formats_.end()) { return false; } @@ -511,7 +518,7 @@ class FakeVideoMediaChannel : public RtpHelper { SetSendStreamDefaultFormat(sp.first_ssrc()); return true; } - virtual bool RemoveSendStream(uint32 ssrc) { + virtual bool RemoveSendStream(uint32_t ssrc) { send_formats_.erase(ssrc); return RtpHelper::RemoveSendStream(ssrc); } @@ -523,7 +530,7 @@ class FakeVideoMediaChannel : public RtpHelper { *send_codec = send_codecs_[0]; return true; } - virtual bool SetRenderer(uint32 ssrc, VideoRenderer* r) { + virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* r) { if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { return false; } @@ -534,7 +541,7 @@ class FakeVideoMediaChannel : public RtpHelper { } virtual bool SetSend(bool send) { return set_sending(send); } - virtual bool SetVideoSend(uint32 ssrc, bool enable, + virtual bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options) { if (!RtpHelper::MuteStream(ssrc, !enable)) { return false; @@ -544,11 +551,11 @@ class FakeVideoMediaChannel : public RtpHelper { } return true; } - virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { + virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { capturers_[ssrc] = capturer; return true; } - bool HasCapturer(uint32 ssrc) const { + bool HasCapturer(uint32_t ssrc) const { return capturers_.find(ssrc) != capturers_.end(); } virtual bool AddRecvStream(const StreamParams& sp) { @@ -557,7 +564,7 @@ class FakeVideoMediaChannel : public RtpHelper { renderers_[sp.first_ssrc()] = NULL; return true; } - virtual bool RemoveRecvStream(uint32 ssrc) { + virtual bool RemoveRecvStream(uint32_t ssrc) { if (!RtpHelper::RemoveRecvStream(ssrc)) return false; renderers_.erase(ssrc); @@ -611,7 +618,7 @@ class FakeVideoMediaChannel : public RtpHelper { } // Be default, each send stream uses the first send codec format. - void SetSendStreamDefaultFormat(uint32 ssrc) { + void SetSendStreamDefaultFormat(uint32_t ssrc) { if (!send_codecs_.empty()) { send_formats_[ssrc] = VideoFormat( send_codecs_[0].width, send_codecs_[0].height, @@ -623,9 +630,9 @@ class FakeVideoMediaChannel : public RtpHelper { FakeVideoEngine* engine_; std::vector recv_codecs_; std::vector send_codecs_; - std::map renderers_; - std::map send_formats_; - std::map capturers_; + std::map renderers_; + std::map send_formats_; + std::map capturers_; bool sent_intra_frame_; bool requested_intra_frame_; VideoOptions options_; @@ -659,7 +666,7 @@ class FakeDataMediaChannel : public RtpHelper { return false; return true; } - virtual bool RemoveRecvStream(uint32 ssrc) { + virtual bool RemoveRecvStream(uint32_t ssrc) { if (!RtpHelper::RemoveRecvStream(ssrc)) return false; return true; diff --git a/talk/media/base/fakenetworkinterface.h b/talk/media/base/fakenetworkinterface.h index 5178e67eeb..275f5981ce 100644 --- a/talk/media/base/fakenetworkinterface.h +++ b/talk/media/base/fakenetworkinterface.h @@ -61,7 +61,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, // Conference mode is a mode where instead of simply forwarding the packets, // the transport will send multiple copies of the packet with the specified // SSRCs. This allows us to simulate receiving media from multiple sources. - void SetConferenceMode(bool conf, const std::vector& ssrcs) { + void SetConferenceMode(bool conf, const std::vector& ssrcs) { rtc::CritScope cs(&crit_); conf_ = conf; conf_sent_ssrcs_ = ssrcs; @@ -76,7 +76,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, return bytes; } - int NumRtpBytes(uint32 ssrc) { + int NumRtpBytes(uint32_t ssrc) { rtc::CritScope cs(&crit_); int bytes = 0; GetNumRtpBytesAndPackets(ssrc, &bytes, NULL); @@ -88,7 +88,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, return static_cast(rtp_packets_.size()); } - int NumRtpPackets(uint32 ssrc) { + int NumRtpPackets(uint32_t ssrc) { rtc::CritScope cs(&crit_); int packets = 0; GetNumRtpBytesAndPackets(ssrc, NULL, &packets); @@ -132,7 +132,7 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, rtc::DiffServCodePoint dscp) { rtc::CritScope cs(&crit_); - uint32 cur_ssrc = 0; + uint32_t cur_ssrc = 0; if (!GetRtpSsrc(packet->data(), packet->size(), &cur_ssrc)) { return false; } @@ -198,14 +198,14 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, } private: - void GetNumRtpBytesAndPackets(uint32 ssrc, int* bytes, int* packets) { + void GetNumRtpBytesAndPackets(uint32_t ssrc, int* bytes, int* packets) { if (bytes) { *bytes = 0; } if (packets) { *packets = 0; } - uint32 cur_ssrc = 0; + uint32_t cur_ssrc = 0; for (size_t i = 0; i < rtp_packets_.size(); ++i) { if (!GetRtpSsrc(rtp_packets_[i].data(), rtp_packets_[i].size(), &cur_ssrc)) { @@ -226,12 +226,12 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface, MediaChannel* dest_; bool conf_; // The ssrcs used in sending out packets in conference mode. - std::vector conf_sent_ssrcs_; + std::vector conf_sent_ssrcs_; // Map to track counts of packets that have been sent per ssrc. // This includes packets that are dropped. - std::map sent_ssrcs_; + std::map sent_ssrcs_; // Map to track packet-number that needs to be dropped per ssrc. - std::map > drop_map_; + std::map > drop_map_; rtc::CriticalSection crit_; std::vector rtp_packets_; std::vector rtcp_packets_; diff --git a/talk/media/base/fakevideocapturer.h b/talk/media/base/fakevideocapturer.h index 7bf8952e91..a668ea7d0c 100644 --- a/talk/media/base/fakevideocapturer.h +++ b/talk/media/base/fakevideocapturer.h @@ -84,24 +84,24 @@ class FakeVideoCapturer : public cricket::VideoCapturer { GetCaptureFormat()->interval, GetCaptureFormat()->fourcc); } - bool CaptureCustomFrame(int width, int height, uint32 fourcc) { + bool CaptureCustomFrame(int width, int height, uint32_t fourcc) { // default to 30fps return CaptureCustomFrame(width, height, 33333333, fourcc); } bool CaptureCustomFrame(int width, int height, int64_t timestamp_interval, - uint32 fourcc) { + uint32_t fourcc) { if (!running_) { return false; } // Currently, |fourcc| is always I420 or ARGB. // TODO(fbarchard): Extend SizeOf to take fourcc. - uint32 size = 0u; + uint32_t size = 0u; if (fourcc == cricket::FOURCC_ARGB) { size = width * 4 * height; } else if (fourcc == cricket::FOURCC_I420) { - size = static_cast(cricket::VideoFrame::SizeOf(width, height)); + size = static_cast(cricket::VideoFrame::SizeOf(width, height)); } else { return false; // Unsupported FOURCC. } @@ -122,9 +122,9 @@ class FakeVideoCapturer : public cricket::VideoCapturer { // Copy something non-zero into the buffer so Validate wont complain that // the frame is all duplicate. memset(frame.data, 1, size / 2); - memset(reinterpret_cast(frame.data) + (size / 2), 2, - size - (size / 2)); - memcpy(frame.data, reinterpret_cast(&fourcc), 4); + memset(reinterpret_cast(frame.data) + (size / 2), 2, + size - (size / 2)); + memcpy(frame.data, reinterpret_cast(&fourcc), 4); frame.rotation = rotation_; // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to // capture results from downstream. @@ -157,7 +157,7 @@ class FakeVideoCapturer : public cricket::VideoCapturer { is_screencast_ = is_screencast; } virtual bool IsScreencast() const { return is_screencast_; } - bool GetPreferredFourccs(std::vector* fourccs) { + bool GetPreferredFourccs(std::vector* fourccs) { fourccs->push_back(cricket::FOURCC_I420); fourccs->push_back(cricket::FOURCC_MJPG); return true; @@ -171,8 +171,8 @@ class FakeVideoCapturer : public cricket::VideoCapturer { private: bool running_; - int64 initial_unix_timestamp_; - int64 next_timestamp_; + int64_t initial_unix_timestamp_; + int64_t next_timestamp_; bool is_screencast_; webrtc::VideoRotation rotation_; }; diff --git a/talk/media/base/fakevideorenderer.h b/talk/media/base/fakevideorenderer.h index 9ceaac8b1f..c6a1c2468d 100644 --- a/talk/media/base/fakevideorenderer.h +++ b/talk/media/base/fakevideorenderer.h @@ -106,9 +106,12 @@ class FakeVideoRenderer : public VideoRenderer { sigslot::signal1 SignalRenderFrame; private: - static bool CheckFrameColorYuv(uint8 y_min, uint8 y_max, - uint8 u_min, uint8 u_max, - uint8 v_min, uint8 v_max, + static bool CheckFrameColorYuv(uint8_t y_min, + uint8_t y_max, + uint8_t u_min, + uint8_t u_max, + uint8_t v_min, + uint8_t v_max, const cricket::VideoFrame* frame) { if (!frame) { return false; @@ -116,12 +119,12 @@ class FakeVideoRenderer : public VideoRenderer { // Y size_t y_width = frame->GetWidth(); size_t y_height = frame->GetHeight(); - const uint8* y_plane = frame->GetYPlane(); - const uint8* y_pos = y_plane; - int32 y_pitch = frame->GetYPitch(); + const uint8_t* y_plane = frame->GetYPlane(); + const uint8_t* y_pos = y_plane; + int32_t y_pitch = frame->GetYPitch(); for (size_t i = 0; i < y_height; ++i) { for (size_t j = 0; j < y_width; ++j) { - uint8 y_value = *(y_pos + j); + uint8_t y_value = *(y_pos + j); if (y_value < y_min || y_value > y_max) { return false; } @@ -131,19 +134,19 @@ class FakeVideoRenderer : public VideoRenderer { // U and V size_t chroma_width = frame->GetChromaWidth(); size_t chroma_height = frame->GetChromaHeight(); - const uint8* u_plane = frame->GetUPlane(); - const uint8* v_plane = frame->GetVPlane(); - const uint8* u_pos = u_plane; - const uint8* v_pos = v_plane; - int32 u_pitch = frame->GetUPitch(); - int32 v_pitch = frame->GetVPitch(); + const uint8_t* u_plane = frame->GetUPlane(); + const uint8_t* v_plane = frame->GetVPlane(); + const uint8_t* u_pos = u_plane; + const uint8_t* v_pos = v_plane; + int32_t u_pitch = frame->GetUPitch(); + int32_t v_pitch = frame->GetVPitch(); for (size_t i = 0; i < chroma_height; ++i) { for (size_t j = 0; j < chroma_width; ++j) { - uint8 u_value = *(u_pos + j); + uint8_t u_value = *(u_pos + j); if (u_value < u_min || u_value > u_max) { return false; } - uint8 v_value = *(v_pos + j); + uint8_t v_value = *(v_pos + j); if (v_value < v_min || v_value > v_max) { return false; } diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h index dd46a2ff1a..bf06e23686 100644 --- a/talk/media/base/mediachannel.h +++ b/talk/media/base/mediachannel.h @@ -288,14 +288,14 @@ struct AudioOptions { Settable experimental_ns; Settable aec_dump; // Note that tx_agc_* only applies to non-experimental AGC. - Settable tx_agc_target_dbov; - Settable tx_agc_digital_compression_gain; + Settable tx_agc_target_dbov; + Settable tx_agc_digital_compression_gain; Settable tx_agc_limiter; - Settable rx_agc_target_dbov; - Settable rx_agc_digital_compression_gain; + Settable rx_agc_target_dbov; + Settable rx_agc_digital_compression_gain; Settable rx_agc_limiter; - Settable recording_sample_rate; - Settable playout_sample_rate; + Settable recording_sample_rate; + Settable playout_sample_rate; // Set DSCP value for packet sent from audio channel. Settable dscp; // Enable combined audio+bandwidth BWE. @@ -557,14 +557,14 @@ class MediaChannel : public sigslot::has_slots<> { // Removes an outgoing media stream. // ssrc must be the first SSRC of the media stream if the stream uses // multiple SSRCs. - virtual bool RemoveSendStream(uint32 ssrc) = 0; + virtual bool RemoveSendStream(uint32_t ssrc) = 0; // Creates a new incoming media stream with SSRCs and CNAME as described // by sp. virtual bool AddRecvStream(const StreamParams& sp) = 0; // Removes an incoming media stream. // ssrc must be the first SSRC of the media stream if the stream uses // multiple SSRCs. - virtual bool RemoveRecvStream(uint32 ssrc) = 0; + virtual bool RemoveRecvStream(uint32_t ssrc) = 0; // Returns the absoulte sendtime extension id value from media channel. virtual int GetRtpSendTimeExtnId() const { @@ -640,7 +640,7 @@ struct SsrcSenderInfo { : ssrc(0), timestamp(0) { } - uint32 ssrc; + uint32_t ssrc; double timestamp; // NTP timestamp, represented as seconds since epoch. }; @@ -649,7 +649,7 @@ struct SsrcReceiverInfo { : ssrc(0), timestamp(0) { } - uint32 ssrc; + uint32_t ssrc; double timestamp; }; @@ -666,14 +666,14 @@ struct MediaSenderInfo { } // Temporary utility function for call sites that only provide SSRC. // As more info is added into SsrcSenderInfo, this function should go away. - void add_ssrc(uint32 ssrc) { + void add_ssrc(uint32_t ssrc) { SsrcSenderInfo stat; stat.ssrc = ssrc; add_ssrc(stat); } // Utility accessor for clients that are only interested in ssrc numbers. - std::vector ssrcs() const { - std::vector retval; + std::vector ssrcs() const { + std::vector retval; for (std::vector::const_iterator it = local_stats.begin(); it != local_stats.end(); ++it) { retval.push_back(it->ssrc); @@ -683,14 +683,14 @@ struct MediaSenderInfo { // Utility accessor for clients that make the assumption only one ssrc // exists per media. // This will eventually go away. - uint32 ssrc() const { + uint32_t ssrc() const { if (local_stats.size() > 0) { return local_stats[0].ssrc; } else { return 0; } } - int64 bytes_sent; + int64_t bytes_sent; int packets_sent; int packets_lost; float fraction_lost; @@ -726,13 +726,13 @@ struct MediaReceiverInfo { } // Temporary utility function for call sites that only provide SSRC. // As more info is added into SsrcSenderInfo, this function should go away. - void add_ssrc(uint32 ssrc) { + void add_ssrc(uint32_t ssrc) { SsrcReceiverInfo stat; stat.ssrc = ssrc; add_ssrc(stat); } - std::vector ssrcs() const { - std::vector retval; + std::vector ssrcs() const { + std::vector retval; for (std::vector::const_iterator it = local_stats.begin(); it != local_stats.end(); ++it) { retval.push_back(it->ssrc); @@ -742,7 +742,7 @@ struct MediaReceiverInfo { // Utility accessor for clients that make the assumption only one ssrc // exists per media. // This will eventually go away. - uint32 ssrc() const { + uint32_t ssrc() const { if (local_stats.size() > 0) { return local_stats[0].ssrc; } else { @@ -750,7 +750,7 @@ struct MediaReceiverInfo { } } - int64 bytes_rcvd; + int64_t bytes_rcvd; int packets_rcvd; int packets_lost; float fraction_lost; @@ -827,7 +827,7 @@ struct VoiceReceiverInfo : public MediaReceiverInfo { int decoding_cng; int decoding_plc_cng; // Estimated capture start time in NTP time in ms. - int64 capture_start_ntp_time_ms; + int64_t capture_start_ntp_time_ms; }; struct VideoSenderInfo : public MediaSenderInfo { @@ -931,7 +931,7 @@ struct VideoReceiverInfo : public MediaReceiverInfo { int current_delay_ms; // Estimated capture start time in NTP time in ms. - int64 capture_start_ntp_time_ms; + int64_t capture_start_ntp_time_ms; }; struct DataSenderInfo : public MediaSenderInfo { @@ -939,7 +939,7 @@ struct DataSenderInfo : public MediaSenderInfo { : ssrc(0) { } - uint32 ssrc; + uint32_t ssrc; }; struct DataReceiverInfo : public MediaReceiverInfo { @@ -947,7 +947,7 @@ struct DataReceiverInfo : public MediaReceiverInfo { : ssrc(0) { } - uint32 ssrc; + uint32_t ssrc; }; struct BandwidthEstimationInfo { @@ -1070,11 +1070,12 @@ class VoiceMediaChannel : public MediaChannel { // Starts or stops sending (and potentially capture) of local audio. virtual bool SetSend(SendFlags flag) = 0; // Configure stream for sending. - virtual bool SetAudioSend(uint32 ssrc, bool enable, + virtual bool SetAudioSend(uint32_t ssrc, + bool enable, const AudioOptions* options, AudioRenderer* renderer) = 0; // Sets the renderer object to be used for the specified remote audio stream. - virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) = 0; + virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) = 0; // Gets current energy levels for all incoming streams. virtual bool GetActiveStreams(AudioInfo::StreamList* actives) = 0; // Get the current energy level of the stream sent to the speaker. @@ -1086,7 +1087,7 @@ class VoiceMediaChannel : public MediaChannel { int cost_per_typing, int reporting_threshold, int penalty_decay, int type_event_delay) = 0; // Set left and right scale for speaker output volume of the specified ssrc. - virtual bool SetOutputScaling(uint32 ssrc, double left, double right) = 0; + virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) = 0; // Returns if the telephone-event has been negotiated. virtual bool CanInsertDtmf() { return false; } // Send and/or play a DTMF |event| according to the |flags|. @@ -1094,7 +1095,10 @@ class VoiceMediaChannel : public MediaChannel { // The |ssrc| should be either 0 or a valid send stream ssrc. // The valid value for the |event| are 0 to 15 which corresponding to // DTMF event 0-9, *, #, A-D. - virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) = 0; + virtual bool InsertDtmf(uint32_t ssrc, + int event, + int duration, + int flags) = 0; // Gets quality stats for the channel. virtual bool GetStats(VoiceMediaInfo* info) = 0; }; @@ -1130,18 +1134,20 @@ class VideoMediaChannel : public MediaChannel { // Gets the currently set codecs/payload types to be used for outgoing media. virtual bool GetSendCodec(VideoCodec* send_codec) = 0; // Sets the format of a specified outgoing stream. - virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) = 0; + virtual bool SetSendStreamFormat(uint32_t ssrc, + const VideoFormat& format) = 0; // Starts or stops transmission (and potentially capture) of local video. virtual bool SetSend(bool send) = 0; // Configure stream for sending. - virtual bool SetVideoSend(uint32 ssrc, bool enable, + virtual bool SetVideoSend(uint32_t ssrc, + bool enable, const VideoOptions* options) = 0; // Sets the renderer object to be used for the specified stream. // If SSRC is 0, the renderer is used for the 'default' stream. - virtual bool SetRenderer(uint32 ssrc, VideoRenderer* renderer) = 0; + virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* renderer) = 0; // If |ssrc| is 0, replace the default capturer (engine capturer) with // |capturer|. If |ssrc| is non zero create a new stream with |ssrc| as SSRC. - virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) = 0; + virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) = 0; // Gets quality stats for the channel. virtual bool GetStats(VideoMediaInfo* info) = 0; // Send an intra frame to the receivers. @@ -1169,7 +1175,7 @@ enum DataMessageType { struct ReceiveDataParams { // The in-packet stream indentifier. // For SCTP, this is really SID, not SSRC. - uint32 ssrc; + uint32_t ssrc; // The type of message (binary, text, or control). DataMessageType type; // A per-stream value incremented per packet in the stream. @@ -1188,7 +1194,7 @@ struct ReceiveDataParams { struct SendDataParams { // The in-packet stream indentifier. // For SCTP, this is really SID, not SSRC. - uint32 ssrc; + uint32_t ssrc; // The type of message (binary, text, or control). DataMessageType type; @@ -1276,7 +1282,7 @@ class DataMediaChannel : public MediaChannel { // writable(bool) sigslot::signal1 SignalReadyToSend; // Signal for notifying that the remote side has closed the DataChannel. - sigslot::signal1 SignalStreamClosedRemotely; + sigslot::signal1 SignalStreamClosedRemotely; }; } // namespace cricket diff --git a/talk/media/base/rtpdataengine.cc b/talk/media/base/rtpdataengine.cc index 02e4b7c06f..b2b84b965f 100644 --- a/talk/media/base/rtpdataengine.cc +++ b/talk/media/base/rtpdataengine.cc @@ -95,7 +95,7 @@ void RtpDataMediaChannel::Construct(rtc::Timing* timing) { RtpDataMediaChannel::~RtpDataMediaChannel() { - std::map::const_iterator iter; + std::map::const_iterator iter; for (iter = rtp_clock_by_send_ssrc_.begin(); iter != rtp_clock_by_send_ssrc_.end(); ++iter) { @@ -103,10 +103,9 @@ RtpDataMediaChannel::~RtpDataMediaChannel() { } } -void RtpClock::Tick( - double now, int* seq_num, uint32* timestamp) { +void RtpClock::Tick(double now, int* seq_num, uint32_t* timestamp) { *seq_num = ++last_seq_num_; - *timestamp = timestamp_offset_ + static_cast(now * clockrate_); + *timestamp = timestamp_offset_ + static_cast(now * clockrate_); } const DataCodec* FindUnknownCodec(const std::vector& codecs) { @@ -188,7 +187,7 @@ bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) { return true; } -bool RtpDataMediaChannel::RemoveSendStream(uint32 ssrc) { +bool RtpDataMediaChannel::RemoveSendStream(uint32_t ssrc) { if (!GetStreamBySsrc(send_streams_, ssrc)) { return false; } @@ -217,7 +216,7 @@ bool RtpDataMediaChannel::AddRecvStream(const StreamParams& stream) { return true; } -bool RtpDataMediaChannel::RemoveRecvStream(uint32 ssrc) { +bool RtpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) { RemoveStreamBySsrc(&recv_streams_, ssrc); return true; } diff --git a/talk/media/base/rtpdataengine.h b/talk/media/base/rtpdataengine.h index 211b0dc91d..c0449c9f79 100644 --- a/talk/media/base/rtpdataengine.h +++ b/talk/media/base/rtpdataengine.h @@ -66,21 +66,20 @@ class RtpDataEngine : public DataEngineInterface { // according to the clockrate. class RtpClock { public: - RtpClock(int clockrate, uint16 first_seq_num, uint32 timestamp_offset) + RtpClock(int clockrate, uint16_t first_seq_num, uint32_t timestamp_offset) : clockrate_(clockrate), last_seq_num_(first_seq_num), - timestamp_offset_(timestamp_offset) { - } + timestamp_offset_(timestamp_offset) {} // Given the current time (in number of seconds which must be // monotonically increasing), Return the next sequence number and // timestamp. - void Tick(double now, int* seq_num, uint32* timestamp); + void Tick(double now, int* seq_num, uint32_t* timestamp); private: int clockrate_; - uint16 last_seq_num_; - uint32 timestamp_offset_; + uint16_t last_seq_num_; + uint32_t timestamp_offset_; }; class RtpDataMediaChannel : public DataMediaChannel { @@ -99,9 +98,9 @@ class RtpDataMediaChannel : public DataMediaChannel { virtual bool SetSendParameters(const DataSendParameters& params); virtual bool SetRecvParameters(const DataRecvParameters& params); virtual bool AddSendStream(const StreamParams& sp); - virtual bool RemoveSendStream(uint32 ssrc); + virtual bool RemoveSendStream(uint32_t ssrc); virtual bool AddRecvStream(const StreamParams& sp); - virtual bool RemoveRecvStream(uint32 ssrc); + virtual bool RemoveRecvStream(uint32_t ssrc); virtual bool SetSend(bool send) { sending_ = send; return true; @@ -133,7 +132,7 @@ class RtpDataMediaChannel : public DataMediaChannel { std::vector recv_codecs_; std::vector send_streams_; std::vector recv_streams_; - std::map rtp_clock_by_send_ssrc_; + std::map rtp_clock_by_send_ssrc_; rtc::scoped_ptr send_limiter_; }; diff --git a/talk/media/base/rtpdataengine_unittest.cc b/talk/media/base/rtpdataengine_unittest.cc index 53648df3fa..38cc2c67e5 100644 --- a/talk/media/base/rtpdataengine_unittest.cc +++ b/talk/media/base/rtpdataengine_unittest.cc @@ -302,8 +302,8 @@ TEST_F(RtpDataMediaChannelTest, SendData) { cricket::RtpHeader header1 = GetSentDataHeader(1); EXPECT_EQ(header1.ssrc, 42U); EXPECT_EQ(header1.payload_type, 103); - EXPECT_EQ(static_cast(header0.seq_num + 1), - static_cast(header1.seq_num)); + EXPECT_EQ(static_cast(header0.seq_num + 1), + static_cast(header1.seq_num)); EXPECT_EQ(header0.timestamp + 180000, header1.timestamp); } @@ -362,11 +362,11 @@ TEST_F(RtpDataMediaChannelTest, SendDataMultipleClocks) { cricket::RtpHeader header1b = GetSentDataHeader(2); cricket::RtpHeader header2b = GetSentDataHeader(3); - EXPECT_EQ(static_cast(header1a.seq_num + 1), - static_cast(header1b.seq_num)); + EXPECT_EQ(static_cast(header1a.seq_num + 1), + static_cast(header1b.seq_num)); EXPECT_EQ(header1a.timestamp + 90000, header1b.timestamp); - EXPECT_EQ(static_cast(header2a.seq_num + 1), - static_cast(header2b.seq_num)); + EXPECT_EQ(static_cast(header2a.seq_num + 1), + static_cast(header2b.seq_num)); EXPECT_EQ(header2a.timestamp + 180000, header2b.timestamp); } diff --git a/talk/media/base/rtpdump.cc b/talk/media/base/rtpdump.cc index 61001a8233..6861636c41 100644 --- a/talk/media/base/rtpdump.cc +++ b/talk/media/base/rtpdump.cc @@ -45,7 +45,7 @@ namespace cricket { const char RtpDumpFileHeader::kFirstLine[] = "#!rtpplay1.0 0.0.0.0/0\n"; -RtpDumpFileHeader::RtpDumpFileHeader(uint32 start_ms, uint32 s, uint16 p) +RtpDumpFileHeader::RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p) : start_sec(start_ms / 1000), start_usec(start_ms % 1000 * 1000), source(s), @@ -61,7 +61,7 @@ void RtpDumpFileHeader::WriteToByteBuffer(rtc::ByteBuffer* buf) { buf->WriteUInt16(padding); } -static const uint32 kDefaultTimeIncrease = 30; +static const uint32_t kDefaultTimeIncrease = 30; bool RtpDumpPacket::IsValidRtpPacket() const { return original_data_len >= data.size() && @@ -83,12 +83,12 @@ bool RtpDumpPacket::GetRtpSeqNum(int* seq_num) const { cricket::GetRtpSeqNum(&data[0], data.size(), seq_num); } -bool RtpDumpPacket::GetRtpTimestamp(uint32* ts) const { +bool RtpDumpPacket::GetRtpTimestamp(uint32_t* ts) const { return IsValidRtpPacket() && cricket::GetRtpTimestamp(&data[0], data.size(), ts); } -bool RtpDumpPacket::GetRtpSsrc(uint32* ssrc) const { +bool RtpDumpPacket::GetRtpSsrc(uint32_t* ssrc) const { return IsValidRtpPacket() && cricket::GetRtpSsrc(&data[0], data.size(), ssrc); } @@ -107,7 +107,7 @@ bool RtpDumpPacket::GetRtcpType(int* type) const { // Implementation of RtpDumpReader. /////////////////////////////////////////////////////////////////////////// -void RtpDumpReader::SetSsrc(uint32 ssrc) { +void RtpDumpReader::SetSsrc(uint32_t ssrc) { ssrc_override_ = ssrc; } @@ -131,8 +131,8 @@ rtc::StreamResult RtpDumpReader::ReadPacket(RtpDumpPacket* packet) { return res; } rtc::ByteBuffer buf(header, sizeof(header)); - uint16 dump_packet_len; - uint16 data_len; + uint16_t dump_packet_len; + uint16_t data_len; // Read the full length of the rtpdump packet, including the rtpdump header. buf.ReadUInt16(&dump_packet_len); packet->data.resize(dump_packet_len - sizeof(header)); @@ -175,8 +175,8 @@ rtc::StreamResult RtpDumpReader::ReadFileHeader() { res = stream_->ReadAll(header, sizeof(header), NULL, NULL); if (res == rtc::SR_SUCCESS) { rtc::ByteBuffer buf(header, sizeof(header)); - uint32 start_sec; - uint32 start_usec; + uint32_t start_sec; + uint32_t start_usec; buf.ReadUInt32(&start_sec); buf.ReadUInt32(&start_usec); start_time_ms_ = start_sec * 1000 + start_usec / 1000; @@ -258,7 +258,7 @@ void RtpDumpLoopReader::UpdateStreamStatistics(const RtpDumpPacket& packet) { // Get the RTP sequence number and timestamp of the dump packet. int rtp_seq_num = 0; packet.GetRtpSeqNum(&rtp_seq_num); - uint32 rtp_timestamp = 0; + uint32_t rtp_timestamp = 0; packet.GetRtpTimestamp(&rtp_timestamp); // Set the timestamps and sequence number for the first dump packet. @@ -301,7 +301,7 @@ void RtpDumpLoopReader::UpdateDumpPacket(RtpDumpPacket* packet) { // Get the old RTP sequence number and timestamp. int sequence = 0; packet->GetRtpSeqNum(&sequence); - uint32 timestamp = 0; + uint32_t timestamp = 0; packet->GetRtpTimestamp(×tamp); // Increase the RTP sequence number and timestamp. sequence += loop_count_ * rtp_seq_num_increase_; @@ -331,7 +331,7 @@ void RtpDumpWriter::set_packet_filter(int filter) { LOG(LS_INFO) << "RtpDumpWriter set_packet_filter to " << packet_filter_; } -uint32 RtpDumpWriter::GetElapsedTime() const { +uint32_t RtpDumpWriter::GetElapsedTime() const { return rtc::TimeSince(start_time_ms_); } @@ -349,8 +349,10 @@ rtc::StreamResult RtpDumpWriter::WriteFileHeader() { return WriteToStream(buf.Data(), buf.Length()); } -rtc::StreamResult RtpDumpWriter::WritePacket( - const void* data, size_t data_len, uint32 elapsed, bool rtcp) { +rtc::StreamResult RtpDumpWriter::WritePacket(const void* data, + size_t data_len, + uint32_t elapsed, + bool rtcp) { if (!stream_ || !data || 0 == data_len) return rtc::SR_ERROR; rtc::StreamResult res = rtc::SR_SUCCESS; @@ -371,9 +373,9 @@ rtc::StreamResult RtpDumpWriter::WritePacket( // Write the dump packet header. rtc::ByteBuffer buf; - buf.WriteUInt16(static_cast( - RtpDumpPacket::kHeaderLength + write_len)); - buf.WriteUInt16(static_cast(rtcp ? 0 : data_len)); + buf.WriteUInt16( + static_cast(RtpDumpPacket::kHeaderLength + write_len)); + buf.WriteUInt16(static_cast(rtcp ? 0 : data_len)); buf.WriteUInt32(elapsed); res = WriteToStream(buf.Data(), buf.Length()); if (res != rtc::SR_SUCCESS) { @@ -410,10 +412,10 @@ size_t RtpDumpWriter::FilterPacket(const void* data, size_t data_len, rtc::StreamResult RtpDumpWriter::WriteToStream( const void* data, size_t data_len) { - uint32 before = rtc::Time(); + uint32_t before = rtc::Time(); rtc::StreamResult result = stream_->WriteAll(data, data_len, NULL, NULL); - uint32 delay = rtc::TimeSince(before); + uint32_t delay = rtc::TimeSince(before); if (delay >= warn_slow_writes_delay_) { LOG(LS_WARNING) << "Slow RtpDump: took " << delay << "ms to write " << data_len << " bytes."; diff --git a/talk/media/base/rtpdump.h b/talk/media/base/rtpdump.h index ce85db1e06..0f3091a59e 100644 --- a/talk/media/base/rtpdump.h +++ b/talk/media/base/rtpdump.h @@ -56,24 +56,23 @@ enum RtpDumpPacketFilter { }; struct RtpDumpFileHeader { - RtpDumpFileHeader(uint32 start_ms, uint32 s, uint16 p); + RtpDumpFileHeader(uint32_t start_ms, uint32_t s, uint16_t p); void WriteToByteBuffer(rtc::ByteBuffer* buf); static const char kFirstLine[]; static const size_t kHeaderLength = 16; - uint32 start_sec; // start of recording, the seconds part. - uint32 start_usec; // start of recording, the microseconds part. - uint32 source; // network source (multicast address). - uint16 port; // UDP port. - uint16 padding; // 2 bytes padding. + uint32_t start_sec; // start of recording, the seconds part. + uint32_t start_usec; // start of recording, the microseconds part. + uint32_t source; // network source (multicast address). + uint16_t port; // UDP port. + uint16_t padding; // 2 bytes padding. }; struct RtpDumpPacket { RtpDumpPacket() {} - RtpDumpPacket(const void* d, size_t s, uint32 elapsed, bool rtcp) - : elapsed_time(elapsed), - original_data_len((rtcp) ? 0 : s) { + RtpDumpPacket(const void* d, size_t s, uint32_t elapsed, bool rtcp) + : elapsed_time(elapsed), original_data_len((rtcp) ? 0 : s) { data.resize(s); memcpy(&data[0], d, s); } @@ -87,16 +86,16 @@ struct RtpDumpPacket { // packet. Return true and set the output parameter if successful. bool GetRtpPayloadType(int* pt) const; bool GetRtpSeqNum(int* seq_num) const; - bool GetRtpTimestamp(uint32* ts) const; - bool GetRtpSsrc(uint32* ssrc) const; + bool GetRtpTimestamp(uint32_t* ts) const; + bool GetRtpSsrc(uint32_t* ssrc) const; bool GetRtpHeaderLen(size_t* len) const; // Get the type of the RTCP packet. Return true and set the output parameter // if successful. bool GetRtcpType(int* type) const; static const size_t kHeaderLength = 8; - uint32 elapsed_time; // Milliseconds since the start of recording. - std::vector data; // The actual RTP or RTCP packet. + uint32_t elapsed_time; // Milliseconds since the start of recording. + std::vector data; // The actual RTP or RTCP packet. size_t original_data_len; // The original length of the packet; may be // greater than data.size() if only part of the // packet was recorded. @@ -114,7 +113,7 @@ class RtpDumpReader { virtual ~RtpDumpReader() {} // Use the specified ssrc, rather than the ssrc from dump, for RTP packets. - void SetSsrc(uint32 ssrc); + void SetSsrc(uint32_t ssrc); virtual rtc::StreamResult ReadPacket(RtpDumpPacket* packet); protected: @@ -130,8 +129,8 @@ class RtpDumpReader { rtc::StreamInterface* stream_; bool file_header_read_; size_t first_line_and_file_header_len_; - uint32 start_time_ms_; - uint32 ssrc_override_; + uint32_t start_time_ms_; + uint32_t ssrc_override_; RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpReader); }; @@ -164,22 +163,22 @@ class RtpDumpLoopReader : public RtpDumpReader { // How much to increase the elapsed time, RTP sequence number, RTP timestampe // for each loop. They are calcualted with the variables below during the // first loop. - uint32 elapsed_time_increases_; + uint32_t elapsed_time_increases_; int rtp_seq_num_increase_; - uint32 rtp_timestamp_increase_; + uint32_t rtp_timestamp_increase_; // How many RTP packets and how many payload frames in the input stream. RTP // packets belong to the same frame have the same RTP timestamp, different // dump timestamp, and different RTP sequence number. - uint32 packet_count_; - uint32 frame_count_; + uint32_t packet_count_; + uint32_t frame_count_; // The elapsed time, RTP sequence number, and RTP timestamp of the first and // the previous dump packets in the input stream. - uint32 first_elapsed_time_; + uint32_t first_elapsed_time_; int first_rtp_seq_num_; - uint32 first_rtp_timestamp_; - uint32 prev_elapsed_time_; + uint32_t first_rtp_timestamp_; + uint32_t prev_elapsed_time_; int prev_rtp_seq_num_; - uint32 prev_rtp_timestamp_; + uint32_t prev_rtp_timestamp_; RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpLoopReader); }; @@ -202,7 +201,7 @@ class RtpDumpWriter { return WritePacket(&packet.data[0], packet.data.size(), packet.elapsed_time, packet.is_rtcp()); } - uint32 GetElapsedTime() const; + uint32_t GetElapsedTime() const; bool GetDumpSize(size_t* size) { // Note that we use GetPosition(), rather than GetSize(), to avoid flush the @@ -214,17 +213,19 @@ class RtpDumpWriter { rtc::StreamResult WriteFileHeader(); private: - rtc::StreamResult WritePacket(const void* data, size_t data_len, - uint32 elapsed, bool rtcp); + rtc::StreamResult WritePacket(const void* data, + size_t data_len, + uint32_t elapsed, + bool rtcp); size_t FilterPacket(const void* data, size_t data_len, bool rtcp); rtc::StreamResult WriteToStream(const void* data, size_t data_len); rtc::StreamInterface* stream_; int packet_filter_; bool file_header_written_; - uint32 start_time_ms_; // Time when the record starts. + uint32_t start_time_ms_; // Time when the record starts. // If writing to the stream takes longer than this many ms, log a warning. - uint32 warn_slow_writes_delay_; + uint32_t warn_slow_writes_delay_; RTC_DISALLOW_COPY_AND_ASSIGN(RtpDumpWriter); }; diff --git a/talk/media/base/rtpdump_unittest.cc b/talk/media/base/rtpdump_unittest.cc index 04caf0c0e0..63662436d6 100644 --- a/talk/media/base/rtpdump_unittest.cc +++ b/talk/media/base/rtpdump_unittest.cc @@ -36,7 +36,7 @@ namespace cricket { -static const uint32 kTestSsrc = 1; +static const uint32_t kTestSsrc = 1; // Test that we read the correct header fields from the RTP/RTCP packet. TEST(RtpDumpTest, ReadRtpDumpPacket) { @@ -46,8 +46,8 @@ TEST(RtpDumpTest, ReadRtpDumpPacket) { int payload_type; int seq_num; - uint32 ts; - uint32 ssrc; + uint32_t ts; + uint32_t ssrc; int rtcp_type; EXPECT_FALSE(rtp_packet.is_rtcp()); EXPECT_TRUE(rtp_packet.IsValidRtpPacket()); @@ -129,7 +129,7 @@ TEST(RtpDumpTest, WriteReadSameRtp) { RtpDumpReader reader(&stream); for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) { EXPECT_EQ(rtc::SR_SUCCESS, reader.ReadPacket(&packet)); - uint32 ssrc; + uint32_t ssrc; EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc)); EXPECT_EQ(kTestSsrc, ssrc); } @@ -139,13 +139,13 @@ TEST(RtpDumpTest, WriteReadSameRtp) { // Rewind the stream and read again with a specified ssrc. stream.Rewind(); RtpDumpReader reader_w_ssrc(&stream); - const uint32 send_ssrc = kTestSsrc + 1; + const uint32_t send_ssrc = kTestSsrc + 1; reader_w_ssrc.SetSsrc(send_ssrc); for (size_t i = 0; i < RtpTestUtility::GetTestPacketCount(); ++i) { EXPECT_EQ(rtc::SR_SUCCESS, reader_w_ssrc.ReadPacket(&packet)); EXPECT_FALSE(packet.is_rtcp()); EXPECT_EQ(packet.original_data_len, packet.data.size()); - uint32 ssrc; + uint32_t ssrc; EXPECT_TRUE(GetRtpSsrc(&packet.data[0], packet.data.size(), &ssrc)); EXPECT_EQ(send_ssrc, ssrc); } diff --git a/talk/media/base/rtputils.cc b/talk/media/base/rtputils.cc index 7252cada05..400cc1d69b 100644 --- a/talk/media/base/rtputils.cc +++ b/talk/media/base/rtputils.cc @@ -41,7 +41,7 @@ bool GetUint8(const void* data, size_t offset, int* value) { if (!data || !value) { return false; } - *value = *(static_cast(data) + offset); + *value = *(static_cast(data) + offset); return true; } @@ -50,15 +50,15 @@ bool GetUint16(const void* data, size_t offset, int* value) { return false; } *value = static_cast( - rtc::GetBE16(static_cast(data) + offset)); + rtc::GetBE16(static_cast(data) + offset)); return true; } -bool GetUint32(const void* data, size_t offset, uint32* value) { +bool GetUint32(const void* data, size_t offset, uint32_t* value) { if (!data || !value) { return false; } - *value = rtc::GetBE32(static_cast(data) + offset); + *value = rtc::GetBE32(static_cast(data) + offset); return true; } @@ -74,15 +74,15 @@ bool SetUint16(void* data, size_t offset, uint16_t value) { if (!data) { return false; } - rtc::SetBE16(static_cast(data) + offset, value); + rtc::SetBE16(static_cast(data) + offset, value); return true; } -bool SetUint32(void* data, size_t offset, uint32 value) { +bool SetUint32(void* data, size_t offset, uint32_t value) { if (!data) { return false; } - rtc::SetBE32(static_cast(data) + offset, value); + rtc::SetBE32(static_cast(data) + offset, value); return true; } @@ -111,14 +111,14 @@ bool GetRtpSeqNum(const void* data, size_t len, int* value) { return GetUint16(data, kRtpSeqNumOffset, value); } -bool GetRtpTimestamp(const void* data, size_t len, uint32* value) { +bool GetRtpTimestamp(const void* data, size_t len, uint32_t* value) { if (len < kMinRtpPacketLen) { return false; } return GetUint32(data, kRtpTimestampOffset, value); } -bool GetRtpSsrc(const void* data, size_t len, uint32* value) { +bool GetRtpSsrc(const void* data, size_t len, uint32_t* value) { if (len < kMinRtpPacketLen) { return false; } @@ -127,15 +127,16 @@ bool GetRtpSsrc(const void* data, size_t len, uint32* value) { bool GetRtpHeaderLen(const void* data, size_t len, size_t* value) { if (!data || len < kMinRtpPacketLen || !value) return false; - const uint8* header = static_cast(data); + const uint8_t* header = static_cast(data); // Get base header size + length of CSRCs (not counting extension yet). - size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32); + size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32_t); if (len < header_size) return false; // If there's an extension, read and add in the extension size. if (header[0] & 0x10) { - if (len < header_size + sizeof(uint32)) return false; - header_size += ((rtc::GetBE16(header + header_size + 2) + 1) * - sizeof(uint32)); + if (len < header_size + sizeof(uint32_t)) + return false; + header_size += + ((rtc::GetBE16(header + header_size + 2) + 1) * sizeof(uint32_t)); if (len < header_size) return false; } *value = header_size; @@ -159,18 +160,18 @@ bool GetRtcpType(const void* data, size_t len, int* value) { // This method returns SSRC first of RTCP packet, except if packet is SDES. // TODO(mallinath) - Fully implement RFC 5506. This standard doesn't restrict // to send non-compound packets only to feedback messages. -bool GetRtcpSsrc(const void* data, size_t len, uint32* value) { +bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value) { // Packet should be at least of 8 bytes, to get SSRC from a RTCP packet. if (!data || len < kMinRtcpPacketLen + 4 || !value) return false; int pl_type; if (!GetRtcpType(data, len, &pl_type)) return false; // SDES packet parsing is not supported. if (pl_type == kRtcpTypeSDES) return false; - *value = rtc::GetBE32(static_cast(data) + 4); + *value = rtc::GetBE32(static_cast(data) + 4); return true; } -bool SetRtpSsrc(void* data, size_t len, uint32 value) { +bool SetRtpSsrc(void* data, size_t len, uint32_t value) { return SetUint32(data, kRtpSsrcOffset, value); } @@ -192,7 +193,7 @@ bool IsRtpPacket(const void* data, size_t len) { if (len < kMinRtpPacketLen) return false; - return (static_cast(data)[0] >> 6) == kRtpVersion; + return (static_cast(data)[0] >> 6) == kRtpVersion; } bool IsValidRtpPayloadType(int payload_type) { diff --git a/talk/media/base/rtputils.h b/talk/media/base/rtputils.h index d6e1b4d874..bf8238f302 100644 --- a/talk/media/base/rtputils.h +++ b/talk/media/base/rtputils.h @@ -39,8 +39,8 @@ const size_t kMinRtcpPacketLen = 4; struct RtpHeader { int payload_type; int seq_num; - uint32 timestamp; - uint32 ssrc; + uint32_t timestamp; + uint32_t ssrc; }; enum RtcpTypes { @@ -55,14 +55,14 @@ enum RtcpTypes { bool GetRtpPayloadType(const void* data, size_t len, int* value); bool GetRtpSeqNum(const void* data, size_t len, int* value); -bool GetRtpTimestamp(const void* data, size_t len, uint32* value); -bool GetRtpSsrc(const void* data, size_t len, uint32* value); +bool GetRtpTimestamp(const void* data, size_t len, uint32_t* value); +bool GetRtpSsrc(const void* data, size_t len, uint32_t* value); bool GetRtpHeaderLen(const void* data, size_t len, size_t* value); bool GetRtcpType(const void* data, size_t len, int* value); -bool GetRtcpSsrc(const void* data, size_t len, uint32* value); +bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value); bool GetRtpHeader(const void* data, size_t len, RtpHeader* header); -bool SetRtpSsrc(void* data, size_t len, uint32 value); +bool SetRtpSsrc(void* data, size_t len, uint32_t value); // Assumes version 2, no padding, no extensions, no csrcs. bool SetRtpHeader(void* data, size_t len, const RtpHeader& header); diff --git a/talk/media/base/rtputils_unittest.cc b/talk/media/base/rtputils_unittest.cc index 027f395d09..1a0444b548 100644 --- a/talk/media/base/rtputils_unittest.cc +++ b/talk/media/base/rtputils_unittest.cc @@ -88,11 +88,11 @@ TEST(RtpUtilsTest, GetRtp) { EXPECT_TRUE(GetRtpSeqNum(kPcmuFrame, sizeof(kPcmuFrame), &seq_num)); EXPECT_EQ(1, seq_num); - uint32 ts; + uint32_t ts; EXPECT_TRUE(GetRtpTimestamp(kPcmuFrame, sizeof(kPcmuFrame), &ts)); EXPECT_EQ(0u, ts); - uint32 ssrc; + uint32_t ssrc; EXPECT_TRUE(GetRtpSsrc(kPcmuFrame, sizeof(kPcmuFrame), &ssrc)); EXPECT_EQ(1u, ssrc); @@ -157,7 +157,7 @@ TEST(RtpUtilsTest, GetRtcp) { EXPECT_FALSE(GetRtcpType(kInvalidPacket, sizeof(kInvalidPacket), &pt)); - uint32 ssrc; + uint32_t ssrc; EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket, sizeof(kNonCompoundRtcpPliFeedbackPacket), &ssrc)); diff --git a/talk/media/base/streamparams.cc b/talk/media/base/streamparams.cc index 782c31e28d..2a1e7636ba 100644 --- a/talk/media/base/streamparams.cc +++ b/talk/media/base/streamparams.cc @@ -100,10 +100,10 @@ bool MediaStreams::RemoveDataStream( return RemoveStream(&data_, selector); } -static std::string SsrcsToString(const std::vector& ssrcs) { +static std::string SsrcsToString(const std::vector& ssrcs) { std::ostringstream ost; ost << "ssrcs:["; - for (std::vector::const_iterator it = ssrcs.begin(); + for (std::vector::const_iterator it = ssrcs.begin(); it != ssrcs.end(); ++it) { if (it != ssrcs.begin()) { ost << ","; @@ -161,7 +161,7 @@ std::string StreamParams::ToString() const { ost << "}"; return ost.str(); } -void StreamParams::GetPrimarySsrcs(std::vector* ssrcs) const { +void StreamParams::GetPrimarySsrcs(std::vector* ssrcs) const { const SsrcGroup* sim_group = get_ssrc_group(kSimSsrcGroupSemantics); if (sim_group == NULL) { ssrcs->push_back(first_ssrc()); @@ -172,10 +172,10 @@ void StreamParams::GetPrimarySsrcs(std::vector* ssrcs) const { } } -void StreamParams::GetFidSsrcs(const std::vector& primary_ssrcs, - std::vector* fid_ssrcs) const { +void StreamParams::GetFidSsrcs(const std::vector& primary_ssrcs, + std::vector* fid_ssrcs) const { for (size_t i = 0; i < primary_ssrcs.size(); ++i) { - uint32 fid_ssrc; + uint32_t fid_ssrc; if (GetFidSsrc(primary_ssrcs[i], &fid_ssrc)) { fid_ssrcs->push_back(fid_ssrc); } @@ -183,14 +183,14 @@ void StreamParams::GetFidSsrcs(const std::vector& primary_ssrcs, } bool StreamParams::AddSecondarySsrc(const std::string& semantics, - uint32 primary_ssrc, - uint32 secondary_ssrc) { + uint32_t primary_ssrc, + uint32_t secondary_ssrc) { if (!has_ssrc(primary_ssrc)) { return false; } ssrcs.push_back(secondary_ssrc); - std::vector ssrc_vector; + std::vector ssrc_vector; ssrc_vector.push_back(primary_ssrc); ssrc_vector.push_back(secondary_ssrc); SsrcGroup ssrc_group = SsrcGroup(semantics, ssrc_vector); @@ -199,8 +199,8 @@ bool StreamParams::AddSecondarySsrc(const std::string& semantics, } bool StreamParams::GetSecondarySsrc(const std::string& semantics, - uint32 primary_ssrc, - uint32* secondary_ssrc) const { + uint32_t primary_ssrc, + uint32_t* secondary_ssrc) const { for (std::vector::const_iterator it = ssrc_groups.begin(); it != ssrc_groups.end(); ++it) { if (it->has_semantics(semantics) && @@ -226,8 +226,8 @@ bool IsOneSsrcStream(const StreamParams& sp) { return false; } -static void RemoveFirst(std::list* ssrcs, uint32 value) { - std::list::iterator it = +static void RemoveFirst(std::list* ssrcs, uint32_t value) { + std::list::iterator it = std::find(ssrcs->begin(), ssrcs->end(), value); if (it != ssrcs->end()) { ssrcs->erase(it); @@ -242,7 +242,7 @@ bool IsSimulcastStream(const StreamParams& sp) { // Start with all StreamParams SSRCs. Remove simulcast SSRCs (from sg) and // RTX SSRCs. If we still have SSRCs left, we don't know what they're for. // Also we remove first-found SSRCs only. So duplicates should lead to errors. - std::list sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end()); + std::list sp_ssrcs(sp.ssrcs.begin(), sp.ssrcs.end()); for (size_t i = 0; i < sg->ssrcs.size(); ++i) { RemoveFirst(&sp_ssrcs, sg->ssrcs[i]); } diff --git a/talk/media/base/streamparams.h b/talk/media/base/streamparams.h index 3c683db385..d082bee95a 100644 --- a/talk/media/base/streamparams.h +++ b/talk/media/base/streamparams.h @@ -58,9 +58,8 @@ extern const char kFidSsrcGroupSemantics[]; extern const char kSimSsrcGroupSemantics[]; struct SsrcGroup { - SsrcGroup(const std::string& usage, const std::vector& ssrcs) - : semantics(usage), ssrcs(ssrcs) { - } + SsrcGroup(const std::string& usage, const std::vector& ssrcs) + : semantics(usage), ssrcs(ssrcs) {} bool operator==(const SsrcGroup& other) const { return (semantics == other.semantics && ssrcs == other.ssrcs); @@ -74,11 +73,11 @@ struct SsrcGroup { std::string ToString() const; std::string semantics; // e.g FIX, FEC, SIM. - std::vector ssrcs; // SSRCs of this type. + std::vector ssrcs; // SSRCs of this type. }; struct StreamParams { - static StreamParams CreateLegacy(uint32 ssrc) { + static StreamParams CreateLegacy(uint32_t ssrc) { StreamParams stream; stream.ssrcs.push_back(ssrc); return stream; @@ -98,7 +97,7 @@ struct StreamParams { return !(*this == other); } - uint32 first_ssrc() const { + uint32_t first_ssrc() const { if (ssrcs.empty()) { return 0; } @@ -108,12 +107,10 @@ struct StreamParams { bool has_ssrcs() const { return !ssrcs.empty(); } - bool has_ssrc(uint32 ssrc) const { + bool has_ssrc(uint32_t ssrc) const { return std::find(ssrcs.begin(), ssrcs.end(), ssrc) != ssrcs.end(); } - void add_ssrc(uint32 ssrc) { - ssrcs.push_back(ssrc); - } + void add_ssrc(uint32_t ssrc) { ssrcs.push_back(ssrc); } bool has_ssrc_groups() const { return !ssrc_groups.empty(); } @@ -132,25 +129,25 @@ struct StreamParams { // Convenience function to add an FID ssrc for a primary_ssrc // that's already been added. - inline bool AddFidSsrc(uint32 primary_ssrc, uint32 fid_ssrc) { + inline bool AddFidSsrc(uint32_t primary_ssrc, uint32_t fid_ssrc) { return AddSecondarySsrc(kFidSsrcGroupSemantics, primary_ssrc, fid_ssrc); } // Convenience function to lookup the FID ssrc for a primary_ssrc. // Returns false if primary_ssrc not found or FID not defined for it. - inline bool GetFidSsrc(uint32 primary_ssrc, uint32* fid_ssrc) const { + inline bool GetFidSsrc(uint32_t primary_ssrc, uint32_t* fid_ssrc) const { return GetSecondarySsrc(kFidSsrcGroupSemantics, primary_ssrc, fid_ssrc); } // Convenience to get all the SIM SSRCs if there are SIM ssrcs, or // the first SSRC otherwise. - void GetPrimarySsrcs(std::vector* ssrcs) const; + void GetPrimarySsrcs(std::vector* ssrcs) const; // Convenience to get all the FID SSRCs for the given primary ssrcs. // If a given primary SSRC does not have a FID SSRC, the list of FID // SSRCS will be smaller than the list of primary SSRCs. - void GetFidSsrcs(const std::vector& primary_ssrcs, - std::vector* fid_ssrcs) const; + void GetFidSsrcs(const std::vector& primary_ssrcs, + std::vector* fid_ssrcs) const; std::string ToString() const; @@ -160,7 +157,7 @@ struct StreamParams { std::string groupid; // Unique per-groupid, not across all groupids std::string id; - std::vector ssrcs; // All SSRCs for this source + std::vector ssrcs; // All SSRCs for this source std::vector ssrc_groups; // e.g. FID, FEC, SIM // Examples: "camera", "screencast" std::string type; @@ -170,17 +167,17 @@ struct StreamParams { std::string sync_label; // Friendly name of cname. private: - bool AddSecondarySsrc(const std::string& semantics, uint32 primary_ssrc, - uint32 secondary_ssrc); - bool GetSecondarySsrc(const std::string& semantics, uint32 primary_ssrc, - uint32* secondary_ssrc) const; + bool AddSecondarySsrc(const std::string& semantics, + uint32_t primary_ssrc, + uint32_t secondary_ssrc); + bool GetSecondarySsrc(const std::string& semantics, + uint32_t primary_ssrc, + uint32_t* secondary_ssrc) const; }; // A Stream can be selected by either groupid+id or ssrc. struct StreamSelector { - explicit StreamSelector(uint32 ssrc) : - ssrc(ssrc) { - } + explicit StreamSelector(uint32_t ssrc) : ssrc(ssrc) {} StreamSelector(const std::string& groupid, const std::string& streamid) : @@ -197,7 +194,7 @@ struct StreamSelector { } } - uint32 ssrc; + uint32_t ssrc; std::string groupid; std::string streamid; }; @@ -284,7 +281,7 @@ const StreamParams* GetStream(const StreamParamsVec& streams, } inline const StreamParams* GetStreamBySsrc(const StreamParamsVec& streams, - uint32 ssrc) { + uint32_t ssrc) { return GetStream(streams, [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); } @@ -320,7 +317,7 @@ inline bool RemoveStream(StreamParamsVec* streams, return RemoveStream(streams, [&selector](const StreamParams& sp) { return selector.Matches(sp); }); } -inline bool RemoveStreamBySsrc(StreamParamsVec* streams, uint32 ssrc) { +inline bool RemoveStreamBySsrc(StreamParamsVec* streams, uint32_t ssrc) { return RemoveStream(streams, [&ssrc](const StreamParams& sp) { return sp.has_ssrc(ssrc); }); } diff --git a/talk/media/base/streamparams_unittest.cc b/talk/media/base/streamparams_unittest.cc index c24403baa7..a9e1ce3531 100644 --- a/talk/media/base/streamparams_unittest.cc +++ b/talk/media/base/streamparams_unittest.cc @@ -29,15 +29,17 @@ #include "talk/media/base/testutils.h" #include "webrtc/base/gunit.h" -static const uint32 kSsrcs1[] = {1}; -static const uint32 kSsrcs2[] = {1, 2}; -static const uint32 kSsrcs3[] = {1, 2, 3}; -static const uint32 kRtxSsrcs3[] = {4, 5, 6}; +static const uint32_t kSsrcs1[] = {1}; +static const uint32_t kSsrcs2[] = {1, 2}; +static const uint32_t kSsrcs3[] = {1, 2, 3}; +static const uint32_t kRtxSsrcs3[] = {4, 5, 6}; static cricket::StreamParams CreateStreamParamsWithSsrcGroup( - const std::string& semantics, const uint32 ssrcs_in[], size_t len) { + const std::string& semantics, + const uint32_t ssrcs_in[], + size_t len) { cricket::StreamParams stream; - std::vector ssrcs(ssrcs_in, ssrcs_in + len); + std::vector ssrcs(ssrcs_in, ssrcs_in + len); cricket::SsrcGroup sg(semantics, ssrcs); stream.ssrcs = ssrcs; stream.ssrc_groups.push_back(sg); @@ -77,7 +79,7 @@ TEST(SsrcGroup, ToString) { } TEST(StreamParams, CreateLegacy) { - const uint32 ssrc = 7; + const uint32_t ssrc = 7; cricket::StreamParams one_sp = cricket::StreamParams::CreateLegacy(ssrc); EXPECT_EQ(1U, one_sp.ssrcs.size()); EXPECT_EQ(ssrc, one_sp.first_ssrc()); @@ -132,7 +134,7 @@ TEST(StreamParams, EqualNotEqual) { } TEST(StreamParams, FidFunctions) { - uint32 fid_ssrc; + uint32_t fid_ssrc; cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(1); EXPECT_FALSE(sp.AddFidSsrc(10, 20)); @@ -149,7 +151,7 @@ TEST(StreamParams, FidFunctions) { // Manually create SsrcGroup to test bounds-checking // in GetSecondarySsrc. We construct an invalid StreamParams // for this. - std::vector fid_vector; + std::vector fid_vector; fid_vector.push_back(13); cricket::SsrcGroup invalid_fid_group(cricket::kFidSsrcGroupSemantics, fid_vector); @@ -165,9 +167,9 @@ TEST(StreamParams, GetPrimaryAndFidSsrcs) { sp.ssrcs.push_back(2); sp.ssrcs.push_back(3); - std::vector primary_ssrcs; + std::vector primary_ssrcs; sp.GetPrimarySsrcs(&primary_ssrcs); - std::vector fid_ssrcs; + std::vector fid_ssrcs; sp.GetFidSsrcs(primary_ssrcs, &fid_ssrcs); ASSERT_EQ(1u, primary_ssrcs.size()); EXPECT_EQ(1u, primary_ssrcs[0]); @@ -272,7 +274,7 @@ TEST(StreamParams, TestIsSimulcastStream_InvalidStreams) { // stream3 has two SIM groups. cricket::StreamParams stream3 = cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs2)); - std::vector sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3); + std::vector sim_ssrcs = MAKE_VECTOR(kRtxSsrcs3); cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, sim_ssrcs); for (size_t i = 0; i < sim_ssrcs.size(); i++) { stream3.add_ssrc(sim_ssrcs[i]); diff --git a/talk/media/base/testutils.cc b/talk/media/base/testutils.cc index 2c812420eb..3b1fcf0513 100644 --- a/talk/media/base/testutils.cc +++ b/talk/media/base/testutils.cc @@ -47,8 +47,8 @@ namespace cricket { ///////////////////////////////////////////////////////////////////////// // Implementation of RawRtpPacket ///////////////////////////////////////////////////////////////////////// -void RawRtpPacket::WriteToByteBuffer( - uint32 in_ssrc, rtc::ByteBuffer *buf) const { +void RawRtpPacket::WriteToByteBuffer(uint32_t in_ssrc, + rtc::ByteBuffer* buf) const { if (!buf) return; buf->WriteUInt8(ver_to_cc); @@ -72,8 +72,10 @@ bool RawRtpPacket::ReadFromByteBuffer(rtc::ByteBuffer* buf) { return ret; } -bool RawRtpPacket::SameExceptSeqNumTimestampSsrc( - const RawRtpPacket& packet, uint16 seq, uint32 ts, uint32 ssc) const { +bool RawRtpPacket::SameExceptSeqNumTimestampSsrc(const RawRtpPacket& packet, + uint16_t seq, + uint32_t ts, + uint32_t ssc) const { return sequence_number == seq && timestamp == ts && ver_to_cc == packet.ver_to_cc && @@ -134,12 +136,14 @@ size_t RtpTestUtility::GetTestPacketCount() { ARRAY_SIZE(kTestRawRtcpPackets)); } -bool RtpTestUtility::WriteTestPackets( - size_t count, bool rtcp, uint32 rtp_ssrc, RtpDumpWriter* writer) { +bool RtpTestUtility::WriteTestPackets(size_t count, + bool rtcp, + uint32_t rtp_ssrc, + RtpDumpWriter* writer) { if (!writer || count > GetTestPacketCount()) return false; bool result = true; - uint32 elapsed_time_ms = 0; + uint32_t elapsed_time_ms = 0; for (size_t i = 0; i < count && result; ++i) { rtc::ByteBuffer buf; if (rtcp) { @@ -155,11 +159,12 @@ bool RtpTestUtility::WriteTestPackets( return result; } -bool RtpTestUtility::VerifyTestPacketsFromStream( - size_t count, rtc::StreamInterface* stream, uint32 ssrc) { +bool RtpTestUtility::VerifyTestPacketsFromStream(size_t count, + rtc::StreamInterface* stream, + uint32_t ssrc) { if (!stream) return false; - uint32 prev_elapsed_time = 0; + uint32_t prev_elapsed_time = 0; bool result = true; stream->Rewind(); RtpDumpLoopReader reader(stream); @@ -188,10 +193,10 @@ bool RtpTestUtility::VerifyTestPacketsFromStream( result &= rtp_packet.ReadFromByteBuffer(&buf); result &= rtp_packet.SameExceptSeqNumTimestampSsrc( kTestRawRtpPackets[index], - static_cast(kTestRawRtpPackets[index].sequence_number + - loop * GetTestPacketCount()), - static_cast(kTestRawRtpPackets[index].timestamp + - loop * kRtpTimestampIncrease), + static_cast(kTestRawRtpPackets[index].sequence_number + + loop * GetTestPacketCount()), + static_cast(kTestRawRtpPackets[index].timestamp + + loop * kRtpTimestampIncrease), ssrc); } } @@ -271,7 +276,9 @@ std::string GetTestFilePath(const std::string& filename) { // Loads the image with the specified prefix and size into |out|. bool LoadPlanarYuvTestImage(const std::string& prefix, - int width, int height, uint8* out) { + int width, + int height, + uint8_t* out) { std::stringstream ss; ss << prefix << "." << width << "x" << height << "_P420.yuv"; @@ -289,8 +296,10 @@ bool LoadPlanarYuvTestImage(const std::string& prefix, // Dumps the YUV image out to a file, for visual inspection. // PYUV tool can be used to view dump files. -void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img, - int w, int h) { +void DumpPlanarYuvTestImage(const std::string& prefix, + const uint8_t* img, + int w, + int h) { rtc::FileStream fs; char filename[256]; rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_P420.yuv", @@ -301,8 +310,10 @@ void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img, // Dumps the ARGB image out to a file, for visual inspection. // ffplay tool can be used to view dump files. -void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img, - int w, int h) { +void DumpPlanarArgbTestImage(const std::string& prefix, + const uint8_t* img, + int w, + int h) { rtc::FileStream fs; char filename[256]; rtc::sprintfn(filename, sizeof(filename), "%s.%dx%d_ARGB.raw", @@ -312,12 +323,12 @@ void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img, } bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1) { - const uint8* y0 = frame0->GetYPlane(); - const uint8* u0 = frame0->GetUPlane(); - const uint8* v0 = frame0->GetVPlane(); - const uint8* y1 = frame1->GetYPlane(); - const uint8* u1 = frame1->GetUPlane(); - const uint8* v1 = frame1->GetVPlane(); + const uint8_t* y0 = frame0->GetYPlane(); + const uint8_t* u0 = frame0->GetUPlane(); + const uint8_t* v0 = frame0->GetVPlane(); + const uint8_t* y1 = frame1->GetYPlane(); + const uint8_t* u1 = frame1->GetUPlane(); + const uint8_t* v1 = frame1->GetVPlane(); for (size_t i = 0; i < frame0->GetHeight(); ++i) { if (0 != memcmp(y0, y1, frame0->GetWidth())) { @@ -344,7 +355,8 @@ bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1) { } cricket::StreamParams CreateSimStreamParams( - const std::string& cname, const std::vector& ssrcs) { + const std::string& cname, + const std::vector& ssrcs) { cricket::StreamParams sp; cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, ssrcs); sp.ssrcs = ssrcs; @@ -355,12 +367,13 @@ cricket::StreamParams CreateSimStreamParams( // There should be an rtx_ssrc per ssrc. cricket::StreamParams CreateSimWithRtxStreamParams( - const std::string& cname, const std::vector& ssrcs, - const std::vector& rtx_ssrcs) { + const std::string& cname, + const std::vector& ssrcs, + const std::vector& rtx_ssrcs) { cricket::StreamParams sp = CreateSimStreamParams(cname, ssrcs); for (size_t i = 0; i < ssrcs.size(); ++i) { sp.ssrcs.push_back(rtx_ssrcs[i]); - std::vector fid_ssrcs; + std::vector fid_ssrcs; fid_ssrcs.push_back(ssrcs[i]); fid_ssrcs.push_back(rtx_ssrcs[i]); cricket::SsrcGroup fid_group(cricket::kFidSsrcGroupSemantics, fid_ssrcs); diff --git a/talk/media/base/testutils.h b/talk/media/base/testutils.h index 1b6f2bacc3..cb4146d707 100644 --- a/talk/media/base/testutils.h +++ b/talk/media/base/testutils.h @@ -61,20 +61,22 @@ class RtpDumpWriter; class VideoFrame; struct RawRtpPacket { - void WriteToByteBuffer(uint32 in_ssrc, rtc::ByteBuffer* buf) const; + void WriteToByteBuffer(uint32_t in_ssrc, rtc::ByteBuffer* buf) const; bool ReadFromByteBuffer(rtc::ByteBuffer* buf); // Check if this packet is the same as the specified packet except the // sequence number and timestamp, which should be the same as the specified // parameters. - bool SameExceptSeqNumTimestampSsrc( - const RawRtpPacket& packet, uint16 seq, uint32 ts, uint32 ssc) const; + bool SameExceptSeqNumTimestampSsrc(const RawRtpPacket& packet, + uint16_t seq, + uint32_t ts, + uint32_t ssc) const; int size() const { return 28; } - uint8 ver_to_cc; - uint8 m_to_pt; - uint16 sequence_number; - uint32 timestamp; - uint32 ssrc; + uint8_t ver_to_cc; + uint8_t m_to_pt; + uint16_t sequence_number; + uint32_t timestamp; + uint32_t ssrc; char payload[16]; }; @@ -83,9 +85,9 @@ struct RawRtcpPacket { bool ReadFromByteBuffer(rtc::ByteBuffer* buf); bool EqualsTo(const RawRtcpPacket& packet) const; - uint8 ver_to_count; - uint8 type; - uint16 length; + uint8_t ver_to_count; + uint8_t type; + uint16_t length; char payload[16]; }; @@ -96,26 +98,29 @@ class RtpTestUtility { // Write the first count number of kTestRawRtcpPackets or kTestRawRtpPackets, // depending on the flag rtcp. If it is RTP, use the specified SSRC. Return // true if successful. - static bool WriteTestPackets( - size_t count, bool rtcp, uint32 rtp_ssrc, RtpDumpWriter* writer); + static bool WriteTestPackets(size_t count, + bool rtcp, + uint32_t rtp_ssrc, + RtpDumpWriter* writer); // Loop read the first count number of packets from the specified stream. // Verify the elapsed time of the dump packets increase monotonically. If the // stream is a RTP stream, verify the RTP sequence number, timestamp, and // payload. If the stream is a RTCP stream, verify the RTCP header and // payload. - static bool VerifyTestPacketsFromStream( - size_t count, rtc::StreamInterface* stream, uint32 ssrc); + static bool VerifyTestPacketsFromStream(size_t count, + rtc::StreamInterface* stream, + uint32_t ssrc); // Verify the dump packet is the same as the raw RTP packet. static bool VerifyPacket(const RtpDumpPacket* dump, const RawRtpPacket* raw, bool header_only); - static const uint32 kDefaultSsrc = 1; - static const uint32 kRtpTimestampIncrease = 90; - static const uint32 kDefaultTimeIncrease = 30; - static const uint32 kElapsedTimeInterval = 10; + static const uint32_t kDefaultSsrc = 1; + static const uint32_t kRtpTimestampIncrease = 90; + static const uint32_t kDefaultTimeIncrease = 30; + static const uint32_t kElapsedTimeInterval = 10; static const RawRtpPacket kTestRawRtpPackets[]; static const RawRtcpPacket kTestRawRtcpPackets[]; @@ -130,10 +135,10 @@ class VideoCapturerListener : public sigslot::has_slots<> { CaptureState last_capture_state() const { return last_capture_state_; } int frame_count() const { return frame_count_; } - uint32 frame_fourcc() const { return frame_fourcc_; } + uint32_t frame_fourcc() const { return frame_fourcc_; } int frame_width() const { return frame_width_; } int frame_height() const { return frame_height_; } - uint32 frame_size() const { return frame_size_; } + uint32_t frame_size() const { return frame_size_; } bool resolution_changed() const { return resolution_changed_; } void OnStateChange(VideoCapturer* capturer, CaptureState state); @@ -142,38 +147,38 @@ class VideoCapturerListener : public sigslot::has_slots<> { private: CaptureState last_capture_state_; int frame_count_; - uint32 frame_fourcc_; + uint32_t frame_fourcc_; int frame_width_; int frame_height_; - uint32 frame_size_; + uint32_t frame_size_; bool resolution_changed_; }; class ScreencastEventCatcher : public sigslot::has_slots<> { public: ScreencastEventCatcher() : ssrc_(0), ev_(rtc::WE_RESIZE) { } - uint32 ssrc() const { return ssrc_; } + uint32_t ssrc() const { return ssrc_; } rtc::WindowEvent event() const { return ev_; } - void OnEvent(uint32 ssrc, rtc::WindowEvent ev) { + void OnEvent(uint32_t ssrc, rtc::WindowEvent ev) { ssrc_ = ssrc; ev_ = ev; } private: - uint32 ssrc_; + uint32_t ssrc_; rtc::WindowEvent ev_; }; class VideoMediaErrorCatcher : public sigslot::has_slots<> { public: VideoMediaErrorCatcher() : ssrc_(0), error_(VideoMediaChannel::ERROR_NONE) { } - uint32 ssrc() const { return ssrc_; } + uint32_t ssrc() const { return ssrc_; } VideoMediaChannel::Error error() const { return error_; } - void OnError(uint32 ssrc, VideoMediaChannel::Error error) { + void OnError(uint32_t ssrc, VideoMediaChannel::Error error) { ssrc_ = ssrc; error_ = error; } private: - uint32 ssrc_; + uint32_t ssrc_; VideoMediaChannel::Error error_; }; @@ -183,28 +188,35 @@ std::string GetTestFilePath(const std::string& filename); // PSNR formula: psnr = 10 * log10 (Peak Signal^2 / mse) // sse is set to a small number for identical frames or sse == 0 static inline double ComputePSNR(double sse, double count) { - return libyuv::SumSquareErrorToPsnr(static_cast(sse), - static_cast(count)); + return libyuv::SumSquareErrorToPsnr(static_cast(sse), + static_cast(count)); } -static inline double ComputeSumSquareError(const uint8 *org, const uint8 *rec, +static inline double ComputeSumSquareError(const uint8_t* org, + const uint8_t* rec, int size) { return static_cast(libyuv::ComputeSumSquareError(org, rec, size)); } // Loads the image with the specified prefix and size into |out|. bool LoadPlanarYuvTestImage(const std::string& prefix, - int width, int height, uint8* out); + int width, + int height, + uint8_t* out); // Dumps the YUV image out to a file, for visual inspection. // PYUV tool can be used to view dump files. -void DumpPlanarYuvTestImage(const std::string& prefix, const uint8* img, - int w, int h); +void DumpPlanarYuvTestImage(const std::string& prefix, + const uint8_t* img, + int w, + int h); // Dumps the ARGB image out to a file, for visual inspection. // ffplay tool can be used to view dump files. -void DumpPlanarArgbTestImage(const std::string& prefix, const uint8* img, - int w, int h); +void DumpPlanarArgbTestImage(const std::string& prefix, + const uint8_t* img, + int w, + int h); // Compare two I420 frames. bool VideoFrameEqual(const VideoFrame* frame0, const VideoFrame* frame1); @@ -222,13 +234,14 @@ bool ContainsMatchingCodec(const std::vector& codecs, const C& codec) { } // Create Simulcast StreamParams with given |ssrcs| and |cname|. -cricket::StreamParams CreateSimStreamParams( - const std::string& cname, const std::vector& ssrcs); +cricket::StreamParams CreateSimStreamParams(const std::string& cname, + const std::vector& ssrcs); // Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|. // The number of |rtx_ssrcs| must match number of |ssrcs|. cricket::StreamParams CreateSimWithRtxStreamParams( - const std::string& cname, const std::vector& ssrcs, - const std::vector& rtx_ssrcs); + const std::string& cname, + const std::vector& ssrcs, + const std::vector& rtx_ssrcs); } // namespace cricket diff --git a/talk/media/base/videoadapter.cc b/talk/media/base/videoadapter.cc index 5a2d7b4bce..edeed63722 100644 --- a/talk/media/base/videoadapter.cc +++ b/talk/media/base/videoadapter.cc @@ -182,7 +182,7 @@ VideoAdapter::~VideoAdapter() { void VideoAdapter::SetInputFormat(const VideoFormat& format) { rtc::CritScope cs(&critical_section_); - int64 old_input_interval = input_format_.interval; + int64_t old_input_interval = input_format_.interval; input_format_ = format; output_format_.interval = std::max(output_format_.interval, input_format_.interval); @@ -223,7 +223,7 @@ void CoordinatedVideoAdapter::set_cpu_smoothing(bool enable) { void VideoAdapter::SetOutputFormat(const VideoFormat& format) { rtc::CritScope cs(&critical_section_); - int64 old_output_interval = output_format_.interval; + int64_t old_output_interval = output_format_.interval; output_format_ = format; output_num_pixels_ = output_format_.width * output_format_.height; output_format_.interval = diff --git a/talk/media/base/videoadapter.h b/talk/media/base/videoadapter.h index 4c863b33f6..212f250cf3 100644 --- a/talk/media/base/videoadapter.h +++ b/talk/media/base/videoadapter.h @@ -88,7 +88,7 @@ class VideoAdapter { int adaption_changes_; // Number of changes in scale factor. size_t previous_width_; // Previous adapter output width. size_t previous_height_; // Previous adapter output height. - int64 interval_next_frame_; + int64_t interval_next_frame_; // The critical section to protect the above variables. rtc::CriticalSection critical_section_; @@ -190,7 +190,7 @@ class CoordinatedVideoAdapter // Video formats that the server view requests, the CPU wants, and the encoder // wants respectively. The adapted output format is the minimum of these. int view_desired_num_pixels_; - int64 view_desired_interval_; + int64_t view_desired_interval_; int encoder_desired_num_pixels_; int cpu_desired_num_pixels_; CoordinatedVideoAdapter::AdaptReason adapt_reason_; diff --git a/talk/media/base/videoadapter_unittest.cc b/talk/media/base/videoadapter_unittest.cc old mode 100755 new mode 100644 index 7163c42395..a8d243ecde --- a/talk/media/base/videoadapter_unittest.cc +++ b/talk/media/base/videoadapter_unittest.cc @@ -42,8 +42,8 @@ namespace cricket { namespace { - static const uint32 kWaitTimeout = 3000U; // 3 seconds. - static const uint32 kShortWaitTimeout = 1000U; // 1 second. +static const uint32_t kWaitTimeout = 3000U; // 3 seconds. +static const uint32_t kShortWaitTimeout = 1000U; // 1 second. void UpdateCpuLoad(CoordinatedVideoAdapter* adapter, int current_cpus, int max_cpus, float process_load, float system_load) { adapter->set_cpu_load_min_samples(1); diff --git a/talk/media/base/videocapturer.cc b/talk/media/base/videocapturer.cc index 33cab71893..ca4b9069f1 100644 --- a/talk/media/base/videocapturer.cc +++ b/talk/media/base/videocapturer.cc @@ -58,7 +58,7 @@ enum { MSG_STATE_CHANGE }; -static const int64 kMaxDistance = ~(static_cast(1) << 63); +static const int64_t kMaxDistance = ~(static_cast(1) << 63); #ifdef LINUX static const int kYU12Penalty = 16; // Needs to be higher than MJPG index. #endif @@ -86,7 +86,7 @@ CapturedFrame::CapturedFrame() data(NULL) {} // TODO(fbarchard): Remove this function once lmimediaengine stops using it. -bool CapturedFrame::GetDataSize(uint32* size) const { +bool CapturedFrame::GetDataSize(uint32_t* size) const { if (!size || data_size == CapturedFrame::kUnknownDataSize) { return false; } @@ -275,11 +275,11 @@ bool VideoCapturer::GetBestCaptureFormat(const VideoFormat& format, return false; } LOG(LS_INFO) << " Capture Requested " << format.ToString(); - int64 best_distance = kMaxDistance; + int64_t best_distance = kMaxDistance; std::vector::const_iterator best = supported_formats->end(); std::vector::const_iterator i; for (i = supported_formats->begin(); i != supported_formats->end(); ++i) { - int64 distance = GetFormatDistance(format, *i); + int64_t distance = GetFormatDistance(format, *i); // TODO(fbarchard): Reduce to LS_VERBOSE if/when camera capture is // relatively bug free. LOG(LS_INFO) << " Supported " << i->ToString() << " distance " << distance; @@ -361,7 +361,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, } // Use a temporary buffer to scale - rtc::scoped_ptr scale_buffer; + rtc::scoped_ptr scale_buffer; if (IsScreencast()) { int scaled_width, scaled_height; @@ -390,16 +390,15 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, CapturedFrame* modified_frame = const_cast(captured_frame); const int modified_frame_size = scaled_width * scaled_height * 4; - scale_buffer.reset(new uint8[modified_frame_size]); + scale_buffer.reset(new uint8_t[modified_frame_size]); // Compute new width such that width * height is less than maximum but // maintains original captured frame aspect ratio. // Round down width to multiple of 4 so odd width won't round up beyond // maximum, and so chroma channel is even width to simplify spatial // resampling. - libyuv::ARGBScale(reinterpret_cast(captured_frame->data), + libyuv::ARGBScale(reinterpret_cast(captured_frame->data), captured_frame->width * 4, captured_frame->width, - captured_frame->height, - scale_buffer.get(), + captured_frame->height, scale_buffer.get(), scaled_width * 4, scaled_width, scaled_height, libyuv::kFilterBilinear); modified_frame->width = scaled_width; @@ -416,7 +415,7 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, // TODO(fbarchard): Avoid scale and convert if muted. // Temporary buffer is scoped here so it will persist until i420_frame.Init() // makes a copy of the frame, converting to I420. - rtc::scoped_ptr temp_buffer; + rtc::scoped_ptr temp_buffer; // YUY2 can be scaled vertically using an ARGB scaler. Aspect ratio is only // a problem on OSX. OSX always converts webcams to YUY2 or UYVY. bool can_scale = @@ -450,26 +449,26 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, scaled_height_ = scaled_height; } const int modified_frame_size = scaled_width * scaled_height * kYuy2Bpp; - uint8* temp_buffer_data; + uint8_t* temp_buffer_data; // Pixels are wide and short; Increasing height. Requires temporary buffer. if (scaled_height > captured_frame->height) { - temp_buffer.reset(new uint8[modified_frame_size]); + temp_buffer.reset(new uint8_t[modified_frame_size]); temp_buffer_data = temp_buffer.get(); } else { // Pixels are narrow and tall; Decreasing height. Scale will be done // in place. - temp_buffer_data = reinterpret_cast(captured_frame->data); + temp_buffer_data = reinterpret_cast(captured_frame->data); } // Use ARGBScaler to vertically scale the YUY2 image, adjusting for 16 bpp. - libyuv::ARGBScale(reinterpret_cast(captured_frame->data), + libyuv::ARGBScale(reinterpret_cast(captured_frame->data), captured_frame->width * kYuy2Bpp, // Stride for YUY2. captured_frame->width * kYuy2Bpp / kArgbBpp, // Width. - abs(captured_frame->height), // Height. + abs(captured_frame->height), // Height. temp_buffer_data, - scaled_width * kYuy2Bpp, // Stride for YUY2. + scaled_width * kYuy2Bpp, // Stride for YUY2. scaled_width * kYuy2Bpp / kArgbBpp, // Width. - abs(scaled_height), // New height. + abs(scaled_height), // New height. libyuv::kFilterBilinear); modified_frame->width = scaled_width; modified_frame->height = scaled_height; @@ -589,16 +588,16 @@ void VideoCapturer::OnMessage(rtc::Message* message) { // 3) Framerate closeness. If not same, we prefer faster. // 4) Compression. If desired format has a specific fourcc, we need exact match; // otherwise, we use preference. -int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired, - const VideoFormat& supported) { - int64 distance = kMaxDistance; +int64_t VideoCapturer::GetFormatDistance(const VideoFormat& desired, + const VideoFormat& supported) { + int64_t distance = kMaxDistance; // Check fourcc. - uint32 supported_fourcc = CanonicalFourCC(supported.fourcc); - int64 delta_fourcc = kMaxDistance; + uint32_t supported_fourcc = CanonicalFourCC(supported.fourcc); + int64_t delta_fourcc = kMaxDistance; if (FOURCC_ANY == desired.fourcc) { // Any fourcc is OK for the desired. Use preference to find best fourcc. - std::vector preferred_fourccs; + std::vector preferred_fourccs; if (!GetPreferredFourccs(&preferred_fourccs)) { return distance; } @@ -629,15 +628,15 @@ int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired, // Check resolution and fps. int desired_width = desired.width; int desired_height = desired.height; - int64 delta_w = supported.width - desired_width; + int64_t delta_w = supported.width - desired_width; float supported_fps = VideoFormat::IntervalToFpsFloat(supported.interval); float delta_fps = supported_fps - VideoFormat::IntervalToFpsFloat(desired.interval); // Check height of supported height compared to height we would like it to be. - int64 aspect_h = - desired_width ? supported.width * desired_height / desired_width - : desired_height; - int64 delta_h = supported.height - aspect_h; + int64_t aspect_h = desired_width + ? supported.width * desired_height / desired_width + : desired_height; + int64_t delta_h = supported.height - aspect_h; distance = 0; // Set high penalty if the supported format is lower than the desired format. @@ -664,12 +663,12 @@ int64 VideoCapturer::GetFormatDistance(const VideoFormat& desired, VideoFormat::IntervalToFpsFloat(desired.interval) * 23.f / 30.f; delta_fps = -delta_fps; if (supported_fps < min_desirable_fps) { - distance |= static_cast(1) << 62; + distance |= static_cast(1) << 62; } else { - distance |= static_cast(1) << 15; + distance |= static_cast(1) << 15; } } - int64 idelta_fps = static_cast(delta_fps); + int64_t idelta_fps = static_cast(delta_fps); // 12 bits for width and height and 8 bits for fps and fourcc. distance |= diff --git a/talk/media/base/videocapturer.h b/talk/media/base/videocapturer.h index dd89c441eb..0a11ed09c1 100644 --- a/talk/media/base/videocapturer.h +++ b/talk/media/base/videocapturer.h @@ -68,15 +68,15 @@ enum CaptureState { class VideoFrame; struct CapturedFrame { - static const uint32 kFrameHeaderSize = 40; // Size from width to data_size. - static const uint32 kUnknownDataSize = 0xFFFFFFFF; + static const uint32_t kFrameHeaderSize = 40; // Size from width to data_size. + static const uint32_t kUnknownDataSize = 0xFFFFFFFF; CapturedFrame(); // Get the number of bytes of the frame data. If data_size is known, return // it directly. Otherwise, calculate the size based on width, height, and // fourcc. Return true if succeeded. - bool GetDataSize(uint32* size) const; + bool GetDataSize(uint32_t* size) const; // TODO(guoweis): Change the type of |rotation| from int to // webrtc::VideoRotation once chromium gets the code. @@ -85,16 +85,16 @@ struct CapturedFrame { // The width and height of the captured frame could be different from those // of VideoFormat. Once the first frame is captured, the width, height, // fourcc, pixel_width, and pixel_height should keep the same over frames. - int width; // in number of pixels - int height; // in number of pixels - uint32 fourcc; // compression - uint32 pixel_width; // width of a pixel, default is 1 - uint32 pixel_height; // height of a pixel, default is 1 + int width; // in number of pixels + int height; // in number of pixels + uint32_t fourcc; // compression + uint32_t pixel_width; // width of a pixel, default is 1 + uint32_t pixel_height; // height of a pixel, default is 1 // TODO(magjed): |elapsed_time| is deprecated - remove once not used anymore. - int64 elapsed_time; - int64 time_stamp; // timestamp of when the frame was captured, in unix - // time with nanosecond units. - uint32 data_size; // number of bytes of the frame data + int64_t elapsed_time; + int64_t time_stamp; // timestamp of when the frame was captured, in unix + // time with nanosecond units. + uint32_t data_size; // number of bytes of the frame data // TODO(guoweis): This can't be converted to VideoRotation yet as it's // used by chrome now. @@ -316,7 +316,7 @@ class VideoCapturer // subclasses override this virtual method to provide a vector of fourccs, in // order of preference, that are expected by the media engine. - virtual bool GetPreferredFourccs(std::vector* fourccs) = 0; + virtual bool GetPreferredFourccs(std::vector* fourccs) = 0; // mutators to set private attributes void SetId(const std::string& id) { @@ -341,8 +341,8 @@ class VideoCapturer // Get the distance between the desired format and the supported format. // Return the max distance if they mismatch. See the implementation for // details. - int64 GetFormatDistance(const VideoFormat& desired, - const VideoFormat& supported); + int64_t GetFormatDistance(const VideoFormat& desired, + const VideoFormat& supported); // Convert captured frame to readable string for LOG messages. std::string ToString(const CapturedFrame* frame) const; diff --git a/talk/media/base/videocapturer_unittest.cc b/talk/media/base/videocapturer_unittest.cc index 8f529d238d..359fe9552a 100644 --- a/talk/media/base/videocapturer_unittest.cc +++ b/talk/media/base/videocapturer_unittest.cc @@ -43,7 +43,7 @@ namespace { const int kMsCallbackWait = 500; // For HD only the height matters. const int kMinHdHeight = 720; -const uint32 kTimeout = 5000U; +const uint32_t kTimeout = 5000U; } // namespace diff --git a/talk/media/base/videocommon.cc b/talk/media/base/videocommon.cc index 262551b297..7b6aac206b 100644 --- a/talk/media/base/videocommon.cc +++ b/talk/media/base/videocommon.cc @@ -36,8 +36,8 @@ namespace cricket { struct FourCCAliasEntry { - uint32 alias; - uint32 canonical; + uint32_t alias; + uint32_t canonical; }; static const FourCCAliasEntry kFourCCAliases[] = { @@ -57,7 +57,7 @@ static const FourCCAliasEntry kFourCCAliases[] = { {FOURCC_CM24, FOURCC_RAW}, }; -uint32 CanonicalFourCC(uint32 fourcc) { +uint32_t CanonicalFourCC(uint32_t fourcc) { for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) { if (kFourCCAliases[i].alias == fourcc) { return kFourCCAliases[i].canonical; @@ -223,7 +223,7 @@ void ComputeScaleToSquarePixels(int in_width, int in_height, // as a multiply defined symbol error. See Also: // http://msdn.microsoft.com/en-us/library/34h23df8.aspx #ifndef _MSC_EXTENSIONS -const int64 VideoFormat::kMinimumInterval; // Initialized in header. +const int64_t VideoFormat::kMinimumInterval; // Initialized in header. #endif std::string VideoFormat::ToString() const { diff --git a/talk/media/base/videocommon.h b/talk/media/base/videocommon.h index 56e5f14095..c28a07b70c 100644 --- a/talk/media/base/videocommon.h +++ b/talk/media/base/videocommon.h @@ -42,7 +42,7 @@ namespace cricket { // processing, it doesn't have the correct ssrc. Since currently only Tx // Video processing is supported, this is ok. When we switch over to trigger // from capturer, this should be fixed and this const removed. -const uint32 kDummyVideoSsrc = 0xFFFFFFFF; +const uint32_t kDummyVideoSsrc = 0xFFFFFFFF; // Minimum interval is 10k fps. #define FPS_TO_INTERVAL(fps) \ @@ -55,9 +55,9 @@ const uint32 kDummyVideoSsrc = 0xFFFFFFFF; // Convert four characters to a FourCC code. // Needs to be a macro otherwise the OS X compiler complains when the kFormat* // constants are used in a switch. -#define FOURCC(a, b, c, d) ( \ - (static_cast(a)) | (static_cast(b) << 8) | \ - (static_cast(c) << 16) | (static_cast(d) << 24)) +#define FOURCC(a, b, c, d) \ + ((static_cast(a)) | (static_cast(b) << 8) | \ + (static_cast(c) << 16) | (static_cast(d) << 24)) // Some pages discussing FourCC codes: // http://www.fourcc.org/yuv.php // http://v4l2spec.bytesex.org/spec/book1.htm @@ -137,13 +137,13 @@ enum FourCC { // We move this out of the enum because using it in many places caused // the compiler to get grumpy, presumably since the above enum is // backed by an int. -static const uint32 FOURCC_ANY = 0xFFFFFFFF; +static const uint32_t FOURCC_ANY = 0xFFFFFFFF; // Converts fourcc aliases into canonical ones. -uint32 CanonicalFourCC(uint32 fourcc); +uint32_t CanonicalFourCC(uint32_t fourcc); // Get FourCC code as a string. -inline std::string GetFourccName(uint32 fourcc) { +inline std::string GetFourccName(uint32_t fourcc) { std::string name; name.push_back(static_cast(fourcc & 0xFF)); name.push_back(static_cast((fourcc >> 8) & 0xFF)); @@ -185,19 +185,19 @@ void ComputeScaleToSquarePixels(int in_width, int in_height, struct VideoFormatPod { int width; // Number of pixels. int height; // Number of pixels. - int64 interval; // Nanoseconds. - uint32 fourcc; // Color space. FOURCC_ANY means that any color space is OK. + int64_t interval; // Nanoseconds. + uint32_t fourcc; // Color space. FOURCC_ANY means that any color space is OK. }; struct VideoFormat : VideoFormatPod { - static const int64 kMinimumInterval = + static const int64_t kMinimumInterval = rtc::kNumNanosecsPerSec / 10000; // 10k fps. VideoFormat() { Construct(0, 0, 0, 0); } - VideoFormat(int w, int h, int64 interval_ns, uint32 cc) { + VideoFormat(int w, int h, int64_t interval_ns, uint32_t cc) { Construct(w, h, interval_ns, cc); } @@ -205,25 +205,25 @@ struct VideoFormat : VideoFormatPod { Construct(format.width, format.height, format.interval, format.fourcc); } - void Construct(int w, int h, int64 interval_ns, uint32 cc) { + void Construct(int w, int h, int64_t interval_ns, uint32_t cc) { width = w; height = h; interval = interval_ns; fourcc = cc; } - static int64 FpsToInterval(int fps) { + static int64_t FpsToInterval(int fps) { return fps ? rtc::kNumNanosecsPerSec / fps : kMinimumInterval; } - static int IntervalToFps(int64 interval) { + static int IntervalToFps(int64_t interval) { if (!interval) { return 0; } return static_cast(rtc::kNumNanosecsPerSec / interval); } - static float IntervalToFpsFloat(int64 interval) { + static float IntervalToFpsFloat(int64_t interval) { if (!interval) { return 0.f; } diff --git a/talk/media/base/videoengine_unittest.h b/talk/media/base/videoengine_unittest.h index 74f6294f42..d89b3e6f43 100644 --- a/talk/media/base/videoengine_unittest.h +++ b/talk/media/base/videoengine_unittest.h @@ -58,13 +58,13 @@ EXPECT_TRUE_WAIT((r).num_rendered_frames() >= (c) && \ (w) == (r).width() && \ (h) == (r).height(), (t)); \ - EXPECT_EQ(0, (r).errors()); \ + EXPECT_EQ(0, (r).errors()); -static const uint32 kTimeout = 5000U; -static const uint32 kDefaultReceiveSsrc = 0; -static const uint32 kSsrc = 1234u; -static const uint32 kRtxSsrc = 4321u; -static const uint32 kSsrcs4[] = {1, 2, 3, 4}; +static const uint32_t kTimeout = 5000U; +static const uint32_t kDefaultReceiveSsrc = 0; +static const uint32_t kSsrc = 1234u; +static const uint32_t kRtxSsrc = 4321u; +static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; inline bool IsEqualRes(const cricket::VideoCodec& a, int w, int h, int fps) { return a.width == w && a.height == h && a.framerate == fps; @@ -119,8 +119,9 @@ class VideoEngineOverride : public T { const cricket::VideoFormat*) { } - void TriggerMediaFrame( - uint32 ssrc, cricket::VideoFrame* frame, bool* drop_frame) { + void TriggerMediaFrame(uint32_t ssrc, + cricket::VideoFrame* frame, + bool* drop_frame) { T::SignalMediaFrame(ssrc, frame, drop_frame); } }; @@ -553,7 +554,7 @@ class VideoMediaChannelTest : public testing::Test, bool SetSend(bool send) { return channel_->SetSend(send); } - bool SetSendStreamFormat(uint32 ssrc, const cricket::VideoCodec& codec) { + bool SetSendStreamFormat(uint32_t ssrc, const cricket::VideoCodec& codec) { return channel_->SetSendStreamFormat(ssrc, cricket::VideoFormat( codec.width, codec.height, cricket::VideoFormat::FpsToInterval(codec.framerate), @@ -604,13 +605,13 @@ class VideoMediaChannelTest : public testing::Test, int NumRtpBytes() { return network_interface_.NumRtpBytes(); } - int NumRtpBytes(uint32 ssrc) { + int NumRtpBytes(uint32_t ssrc) { return network_interface_.NumRtpBytes(ssrc); } int NumRtpPackets() { return network_interface_.NumRtpPackets(); } - int NumRtpPackets(uint32 ssrc) { + int NumRtpPackets(uint32_t ssrc) { return network_interface_.NumRtpPackets(ssrc); } int NumSentSsrcs() { @@ -630,18 +631,22 @@ class VideoMediaChannelTest : public testing::Test, ParseRtpPacket(p, NULL, &pt, NULL, NULL, NULL, NULL); return pt; } - static bool ParseRtpPacket(const rtc::Buffer* p, bool* x, int* pt, - int* seqnum, uint32* tstamp, uint32* ssrc, + static bool ParseRtpPacket(const rtc::Buffer* p, + bool* x, + int* pt, + int* seqnum, + uint32_t* tstamp, + uint32_t* ssrc, std::string* payload) { rtc::ByteBuffer buf(*p); - uint8 u08 = 0; - uint16 u16 = 0; - uint32 u32 = 0; + uint8_t u08 = 0; + uint16_t u16 = 0; + uint32_t u32 = 0; // Read X and CC fields. if (!buf.ReadUInt8(&u08)) return false; bool extension = ((u08 & 0x10) != 0); - uint8 cc = (u08 & 0x0F); + uint8_t cc = (u08 & 0x0F); if (x) *x = extension; // Read PT field. @@ -661,7 +666,7 @@ class VideoMediaChannelTest : public testing::Test, if (ssrc) *ssrc = u32; // Skip CSRCs. - for (uint8 i = 0; i < cc; ++i) { + for (uint8_t i = 0; i < cc; ++i) { if (!buf.ReadUInt32(&u32)) return false; } @@ -672,10 +677,10 @@ class VideoMediaChannelTest : public testing::Test, // Read Extension header length if (!buf.ReadUInt16(&u16)) return false; - uint16 ext_header_len = u16; + uint16_t ext_header_len = u16; // Read Extension header - for (uint16 i = 0; i < ext_header_len; ++i) { + for (uint16_t i = 0; i < ext_header_len; ++i) { if (!buf.ReadUInt32(&u32)) return false; } } @@ -698,9 +703,9 @@ class VideoMediaChannelTest : public testing::Test, // The packet may be a compound RTCP packet. while (total_len < p->size()) { // Read FMT, type and length. - uint8 fmt = 0; - uint8 type = 0; - uint16 length = 0; + uint8_t fmt = 0; + uint8_t type = 0; + uint16_t length = 0; if (!buf.ReadUInt8(&fmt)) return false; fmt &= 0x1F; if (!buf.ReadUInt8(&type)) return false; @@ -719,7 +724,7 @@ class VideoMediaChannelTest : public testing::Test, return true; } - void OnVideoChannelError(uint32 ssrc, + void OnVideoChannelError(uint32_t ssrc, cricket::VideoMediaChannel::Error error) { media_error_ = error; } @@ -881,7 +886,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(channel_->SetRenderer(2, &renderer2)); EXPECT_EQ(0, renderer1.num_rendered_frames()); EXPECT_EQ(0, renderer2.num_rendered_frames()); - std::vector ssrcs; + std::vector ssrcs; ssrcs.push_back(1); ssrcs.push_back(2); network_interface_.SetConferenceMode(true, ssrcs); @@ -958,7 +963,7 @@ class VideoMediaChannelTest : public testing::Test, // the number of expected packets have been sent to avoid races where we // check stats before it has been updated. cricket::VideoMediaInfo info; - for (uint32 i = 0; i < kTimeout; ++i) { + for (uint32_t i = 0; i < kTimeout; ++i) { rtc::Thread::Current()->ProcessMessages(1); EXPECT_TRUE(channel_->GetStats(&info)); ASSERT_EQ(2U, info.senders.size()); @@ -1000,7 +1005,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(SendFrame()); EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); - uint32 ssrc = 0; + uint32_t ssrc = 0; rtc::scoped_ptr p(GetRtpPacket(0)); ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); EXPECT_EQ(kSsrc, ssrc); @@ -1022,7 +1027,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(SetSend(true)); EXPECT_TRUE(WaitAndSendFrame(0)); EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout); - uint32 ssrc = 0; + uint32_t ssrc = 0; rtc::scoped_ptr p(GetRtpPacket(0)); ParseRtpPacket(p.get(), NULL, NULL, NULL, NULL, &ssrc, NULL); EXPECT_EQ(999u, ssrc); @@ -1035,9 +1040,8 @@ class VideoMediaChannelTest : public testing::Test, // Test that we can set the default video renderer before and after // media is received. void SetRenderer() { - uint8 data1[] = { - 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + uint8_t data1[] = { + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; rtc::Buffer packet1(data1, sizeof(data1)); rtc::SetBE32(packet1.data() + 8, kSsrc); @@ -1070,7 +1074,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(SendFrame()); EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); EXPECT_GT(NumRtpPackets(), 0); - uint32 ssrc = 0; + uint32_t ssrc = 0; size_t last_packet = NumRtpPackets() - 1; rtc::scoped_ptr p(GetRtpPacket(static_cast(last_packet))); @@ -1243,7 +1247,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_TRUE(channel_->SetRenderer(2, &renderer2)); EXPECT_EQ(0, renderer1.num_rendered_frames()); EXPECT_EQ(0, renderer2.num_rendered_frames()); - std::vector ssrcs; + std::vector ssrcs; ssrcs.push_back(1); ssrcs.push_back(2); network_interface_.SetConferenceMode(true, ssrcs); @@ -1608,8 +1612,8 @@ class VideoMediaChannelTest : public testing::Test, // This frame should be received. EXPECT_TRUE(SendFrame()); EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout); - const int64 interval = cricket::VideoFormat::FpsToInterval( - DefaultCodec().framerate); + const int64_t interval = + cricket::VideoFormat::FpsToInterval(DefaultCodec().framerate); cricket::VideoFormat format( 0, 0, @@ -1719,7 +1723,7 @@ class VideoMediaChannelTest : public testing::Test, EXPECT_FALSE(channel_->RemoveSendStream(kSsrc)); // Default channel is no longer used by a stream. EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc()); - uint32 new_ssrc = kSsrc + 100; + uint32_t new_ssrc = kSsrc + 100; EXPECT_TRUE(channel_->AddSendStream( cricket::StreamParams::CreateLegacy(new_ssrc))); // Re-use default channel. diff --git a/talk/media/base/videoframe.cc b/talk/media/base/videoframe.cc index 5994b072e4..2b604b085b 100644 --- a/talk/media/base/videoframe.cc +++ b/talk/media/base/videoframe.cc @@ -44,15 +44,15 @@ namespace cricket { rtc::StreamResult VideoFrame::Write(rtc::StreamInterface* stream, int* error) const { rtc::StreamResult result = rtc::SR_SUCCESS; - const uint8* src_y = GetYPlane(); - const uint8* src_u = GetUPlane(); - const uint8* src_v = GetVPlane(); + const uint8_t* src_y = GetYPlane(); + const uint8_t* src_u = GetUPlane(); + const uint8_t* src_v = GetVPlane(); if (!src_y || !src_u || !src_v) { return result; // Nothing to write. } - const int32 y_pitch = GetYPitch(); - const int32 u_pitch = GetUPitch(); - const int32 v_pitch = GetVPitch(); + const int32_t y_pitch = GetYPitch(); + const int32_t u_pitch = GetUPitch(); + const int32_t v_pitch = GetVPitch(); const size_t width = GetWidth(); const size_t height = GetHeight(); const size_t half_width = (width + 1) >> 1; @@ -81,7 +81,7 @@ rtc::StreamResult VideoFrame::Write(rtc::StreamInterface* stream, return result; } -size_t VideoFrame::CopyToBuffer(uint8* buffer, size_t size) const { +size_t VideoFrame::CopyToBuffer(uint8_t* buffer, size_t size) const { const size_t y_size = GetHeight() * GetYPitch(); const size_t u_size = GetUPitch() * GetChromaHeight(); const size_t v_size = GetVPitch() * GetChromaHeight(); @@ -93,15 +93,18 @@ size_t VideoFrame::CopyToBuffer(uint8* buffer, size_t size) const { return needed; } -bool VideoFrame::CopyToPlanes( - uint8* dst_y, uint8* dst_u, uint8* dst_v, - int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v) const { +bool VideoFrame::CopyToPlanes(uint8_t* dst_y, + uint8_t* dst_u, + uint8_t* dst_v, + int32_t dst_pitch_y, + int32_t dst_pitch_u, + int32_t dst_pitch_v) const { if (!GetYPlane() || !GetUPlane() || !GetVPlane()) { LOG(LS_ERROR) << "NULL plane pointer."; return false; } - int32 src_width = static_cast(GetWidth()); - int32 src_height = static_cast(GetHeight()); + int32_t src_width = static_cast(GetWidth()); + int32_t src_height = static_cast(GetHeight()); return libyuv::I420Copy(GetYPlane(), GetYPitch(), GetUPlane(), GetUPitch(), GetVPlane(), GetVPitch(), @@ -121,8 +124,8 @@ void VideoFrame::CopyToFrame(VideoFrame* dst) const { dst->GetYPitch(), dst->GetUPitch(), dst->GetVPitch()); } -size_t VideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, - uint8* buffer, +size_t VideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, + uint8_t* buffer, size_t size, int stride_rgb) const { const size_t needed = std::abs(stride_rgb) * GetHeight(); @@ -142,10 +145,16 @@ size_t VideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, } // TODO(fbarchard): Handle odd width/height with rounding. -void VideoFrame::StretchToPlanes( - uint8* dst_y, uint8* dst_u, uint8* dst_v, - int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v, - size_t width, size_t height, bool interpolate, bool vert_crop) const { +void VideoFrame::StretchToPlanes(uint8_t* dst_y, + uint8_t* dst_u, + uint8_t* dst_v, + int32_t dst_pitch_y, + int32_t dst_pitch_u, + int32_t dst_pitch_v, + size_t width, + size_t height, + bool interpolate, + bool vert_crop) const { if (!GetYPlane() || !GetUPlane() || !GetVPlane()) { LOG(LS_ERROR) << "NULL plane pointer."; return; @@ -157,24 +166,24 @@ void VideoFrame::StretchToPlanes( CopyToPlanes(dst_y, dst_u, dst_v, dst_pitch_y, dst_pitch_u, dst_pitch_v); return; } - const uint8* src_y = GetYPlane(); - const uint8* src_u = GetUPlane(); - const uint8* src_v = GetVPlane(); + const uint8_t* src_y = GetYPlane(); + const uint8_t* src_u = GetUPlane(); + const uint8_t* src_v = GetVPlane(); if (vert_crop) { // Adjust the input width:height ratio to be the same as the output ratio. if (src_width * height > src_height * width) { // Reduce the input width, but keep size/position aligned for YuvScaler src_width = ROUNDTO2(src_height * width / height); - int32 iwidth_offset = ROUNDTO2((GetWidth() - src_width) / 2); + int32_t iwidth_offset = ROUNDTO2((GetWidth() - src_width) / 2); src_y += iwidth_offset; src_u += iwidth_offset / 2; src_v += iwidth_offset / 2; } else if (src_width * height < src_height * width) { // Reduce the input height. src_height = src_width * height / width; - int32 iheight_offset = static_cast( - (GetHeight() - src_height) >> 2); + int32_t iheight_offset = + static_cast((GetHeight() - src_height) >> 2); iheight_offset <<= 1; // Ensure that iheight_offset is even. src_y += iheight_offset * GetYPitch(); src_u += iheight_offset / 2 * GetUPitch(); @@ -230,8 +239,11 @@ bool VideoFrame::SetToBlack() { static const size_t kMaxSampleSize = 1000000000u; // Returns whether a sample is valid. -bool VideoFrame::Validate(uint32 fourcc, int w, int h, - const uint8 *sample, size_t sample_size) { +bool VideoFrame::Validate(uint32_t fourcc, + int w, + int h, + const uint8_t* sample, + size_t sample_size) { if (h < 0) { h = -h; } @@ -240,7 +252,7 @@ bool VideoFrame::Validate(uint32 fourcc, int w, int h, LOG(LS_ERROR) << "Invalid dimensions: " << w << "x" << h; return false; } - uint32 format = CanonicalFourCC(fourcc); + uint32_t format = CanonicalFourCC(fourcc); int expected_bpp = 8; switch (format) { case FOURCC_I400: @@ -305,7 +317,7 @@ bool VideoFrame::Validate(uint32 fourcc, int w, int h, return false; } // TODO(fbarchard): Make function to dump information about frames. - uint8 four_samples[4] = { 0, 0, 0, 0 }; + uint8_t four_samples[4] = {0, 0, 0, 0}; for (size_t i = 0; i < ARRAY_SIZE(four_samples) && i < sample_size; ++i) { four_samples[i] = sample[i]; } diff --git a/talk/media/base/videoframe.h b/talk/media/base/videoframe.h index 7199dccf6d..68367200bb 100644 --- a/talk/media/base/videoframe.h +++ b/talk/media/base/videoframe.h @@ -49,12 +49,12 @@ class VideoFrame { // |dh| is destination height, like |dw|, but must be a positive number. // Returns whether the function succeeded or failed. - virtual bool Reset(uint32 fourcc, + virtual bool Reset(uint32_t fourcc, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, @@ -63,12 +63,12 @@ class VideoFrame { bool apply_rotation) = 0; // TODO(guoweis): Remove this once all external implementations are updated. - virtual bool Reset(uint32 fourcc, + virtual bool Reset(uint32_t fourcc, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, @@ -88,16 +88,16 @@ class VideoFrame { size_t GetChromaHeight() const { return (GetHeight() + 1) / 2; } size_t GetChromaSize() const { return GetUPitch() * GetChromaHeight(); } // These can return NULL if the object is not backed by a buffer. - virtual const uint8 *GetYPlane() const = 0; - virtual const uint8 *GetUPlane() const = 0; - virtual const uint8 *GetVPlane() const = 0; - virtual uint8 *GetYPlane() = 0; - virtual uint8 *GetUPlane() = 0; - virtual uint8 *GetVPlane() = 0; + virtual const uint8_t* GetYPlane() const = 0; + virtual const uint8_t* GetUPlane() const = 0; + virtual const uint8_t* GetVPlane() const = 0; + virtual uint8_t* GetYPlane() = 0; + virtual uint8_t* GetUPlane() = 0; + virtual uint8_t* GetVPlane() = 0; - virtual int32 GetYPitch() const = 0; - virtual int32 GetUPitch() const = 0; - virtual int32 GetVPitch() const = 0; + virtual int32_t GetYPitch() const = 0; + virtual int32_t GetUPitch() const = 0; + virtual int32_t GetVPitch() const = 0; // Returns the handle of the underlying video frame. This is used when the // frame is backed by a texture. The object should be destroyed when it is no @@ -144,15 +144,18 @@ class VideoFrame { // sufficient size. Returns the frame's actual size, regardless of whether // it was written or not (like snprintf). If there is insufficient space, // nothing is written. - virtual size_t CopyToBuffer(uint8 *buffer, size_t size) const; + virtual size_t CopyToBuffer(uint8_t* buffer, size_t size) const; // Writes the frame into the given planes, stretched to the given width and // height. The parameter "interpolate" controls whether to interpolate or just // take the nearest-point. The parameter "crop" controls whether to crop this // frame to the aspect ratio of the given dimensions before stretching. - virtual bool CopyToPlanes( - uint8* dst_y, uint8* dst_u, uint8* dst_v, - int32 dst_pitch_y, int32 dst_pitch_u, int32 dst_pitch_v) const; + virtual bool CopyToPlanes(uint8_t* dst_y, + uint8_t* dst_u, + uint8_t* dst_v, + int32_t dst_pitch_y, + int32_t dst_pitch_u, + int32_t dst_pitch_v) const; // Writes the frame into the target VideoFrame. virtual void CopyToFrame(VideoFrame* target) const; @@ -172,16 +175,25 @@ class VideoFrame { // Returns the frame's actual size, regardless of whether it was written or // not (like snprintf). Parameters size and stride_rgb are in units of bytes. // If there is insufficient space, nothing is written. - virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8 *buffer, - size_t size, int stride_rgb) const; + virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, + uint8_t* buffer, + size_t size, + int stride_rgb) const; // Writes the frame into the given planes, stretched to the given width and // height. The parameter "interpolate" controls whether to interpolate or just // take the nearest-point. The parameter "crop" controls whether to crop this // frame to the aspect ratio of the given dimensions before stretching. - virtual void StretchToPlanes( - uint8 *y, uint8 *u, uint8 *v, int32 pitchY, int32 pitchU, int32 pitchV, - size_t width, size_t height, bool interpolate, bool crop) const; + virtual void StretchToPlanes(uint8_t* y, + uint8_t* u, + uint8_t* v, + int32_t pitchY, + int32_t pitchU, + int32_t pitchV, + size_t width, + size_t height, + bool interpolate, + bool crop) const; // Writes the frame into the target VideoFrame, stretched to the size of that // frame. The parameter "interpolate" controls whether to interpolate or just @@ -201,7 +213,10 @@ class VideoFrame { virtual bool SetToBlack(); // Tests if sample is valid. Returns true if valid. - static bool Validate(uint32 fourcc, int w, int h, const uint8 *sample, + static bool Validate(uint32_t fourcc, + int w, + int h, + const uint8_t* sample, size_t sample_size); // Size of an I420 image of given dimensions when stored as a frame buffer. diff --git a/talk/media/base/videoframe_unittest.h b/talk/media/base/videoframe_unittest.h index 92a278be3e..2f72935acd 100644 --- a/talk/media/base/videoframe_unittest.h +++ b/talk/media/base/videoframe_unittest.h @@ -82,15 +82,18 @@ class VideoFrameTest : public testing::Test { return success; } - bool LoadFrame(const std::string& filename, uint32 format, - int32 width, int32 height, T* frame) { + bool LoadFrame(const std::string& filename, + uint32_t format, + int32_t width, + int32_t height, + T* frame) { return LoadFrame(filename, format, width, height, width, abs(height), webrtc::kVideoRotation_0, frame); } bool LoadFrame(const std::string& filename, - uint32 format, - int32 width, - int32 height, + uint32_t format, + int32_t width, + int32_t height, int dw, int dh, webrtc::VideoRotation rotation, @@ -99,15 +102,18 @@ class VideoFrameTest : public testing::Test { return LoadFrame(ms.get(), format, width, height, dw, dh, rotation, frame); } // Load a video frame from a memory stream. - bool LoadFrame(rtc::MemoryStream* ms, uint32 format, - int32 width, int32 height, T* frame) { + bool LoadFrame(rtc::MemoryStream* ms, + uint32_t format, + int32_t width, + int32_t height, + T* frame) { return LoadFrame(ms, format, width, height, width, abs(height), webrtc::kVideoRotation_0, frame); } bool LoadFrame(rtc::MemoryStream* ms, - uint32 format, - int32 width, - int32 height, + uint32_t format, + int32_t width, + int32_t height, int dw, int dh, webrtc::VideoRotation rotation, @@ -119,22 +125,26 @@ class VideoFrameTest : public testing::Test { bool ret = ms->GetSize(&data_size); EXPECT_TRUE(ret); if (ret) { - ret = LoadFrame(reinterpret_cast(ms->GetBuffer()), data_size, + ret = LoadFrame(reinterpret_cast(ms->GetBuffer()), data_size, format, width, height, dw, dh, rotation, frame); } return ret; } // Load a frame from a raw buffer. - bool LoadFrame(uint8* sample, size_t sample_size, uint32 format, - int32 width, int32 height, T* frame) { + bool LoadFrame(uint8_t* sample, + size_t sample_size, + uint32_t format, + int32_t width, + int32_t height, + T* frame) { return LoadFrame(sample, sample_size, format, width, height, width, abs(height), webrtc::kVideoRotation_0, frame); } - bool LoadFrame(uint8* sample, + bool LoadFrame(uint8_t* sample, size_t sample_size, - uint32 format, - int32 width, - int32 height, + uint32_t format, + int32_t width, + int32_t height, int dw, int dh, webrtc::VideoRotation rotation, @@ -178,7 +188,7 @@ class VideoFrameTest : public testing::Test { prefix.c_str(), frame.GetWidth(), frame.GetHeight()); size_t out_size = cricket::VideoFrame::SizeOf(frame.GetWidth(), frame.GetHeight()); - rtc::scoped_ptr out(new uint8[out_size]); + rtc::scoped_ptr out(new uint8_t[out_size]); frame.CopyToBuffer(out.get(), out_size); return DumpSample(filename, out.get(), out_size); } @@ -200,8 +210,9 @@ class VideoFrameTest : public testing::Test { // The pattern is { { green, orange }, { blue, purple } } // There is also a gradient within each square to ensure that the luma // values are handled properly. - rtc::MemoryStream* CreateYuv422Sample(uint32 fourcc, - uint32 width, uint32 height) { + rtc::MemoryStream* CreateYuv422Sample(uint32_t fourcc, + uint32_t width, + uint32_t height) { int y1_pos, y2_pos, u_pos, v_pos; if (!GetYuv422Packing(fourcc, &y1_pos, &y2_pos, &u_pos, &v_pos)) { return NULL; @@ -214,9 +225,9 @@ class VideoFrameTest : public testing::Test { if (!ms->ReserveSize(size)) { return NULL; } - for (uint32 y = 0; y < height; ++y) { + for (uint32_t y = 0; y < height; ++y) { for (int x = 0; x < awidth; x += 2) { - uint8 quad[4]; + uint8_t quad[4]; quad[y1_pos] = (x % 63 + y % 63) + 64; quad[y2_pos] = ((x + 1) % 63 + y % 63) + 64; quad[u_pos] = ((x / 63) & 1) ? 192 : 64; @@ -228,23 +239,25 @@ class VideoFrameTest : public testing::Test { } // Create a test image for YUV 420 formats with 12 bits per pixel. - rtc::MemoryStream* CreateYuvSample(uint32 width, uint32 height, - uint32 bpp) { + rtc::MemoryStream* CreateYuvSample(uint32_t width, + uint32_t height, + uint32_t bpp) { rtc::scoped_ptr ms( new rtc::MemoryStream); if (!ms->ReserveSize(width * height * bpp / 8)) { return NULL; } - for (uint32 i = 0; i < width * height * bpp / 8; ++i) { + for (uint32_t i = 0; i < width * height * bpp / 8; ++i) { char value = ((i / 63) & 1) ? 192 : 64; ms->Write(&value, sizeof(value), NULL, NULL); } return ms.release(); } - rtc::MemoryStream* CreateRgbSample(uint32 fourcc, - uint32 width, uint32 height) { + rtc::MemoryStream* CreateRgbSample(uint32_t fourcc, + uint32_t width, + uint32_t height) { int r_pos, g_pos, b_pos, bytes; if (!GetRgbPacking(fourcc, &r_pos, &g_pos, &b_pos, &bytes)) { return NULL; @@ -256,9 +269,9 @@ class VideoFrameTest : public testing::Test { return NULL; } - for (uint32 y = 0; y < height; ++y) { - for (uint32 x = 0; x < width; ++x) { - uint8 rgb[4] = { 255, 255, 255, 255 }; + for (uint32_t y = 0; y < height; ++y) { + for (uint32_t x = 0; x < width; ++x) { + uint8_t rgb[4] = {255, 255, 255, 255}; rgb[r_pos] = ((x / 63) & 1) ? 224 : 32; rgb[g_pos] = (x % 63 + y % 63) + 96; rgb[b_pos] = ((y / 63) & 1) ? 224 : 32; @@ -271,28 +284,30 @@ class VideoFrameTest : public testing::Test { // Simple conversion routines to verify the optimized VideoFrame routines. // Converts from the specified colorspace to I420. bool ConvertYuv422(const rtc::MemoryStream* ms, - uint32 fourcc, uint32 width, uint32 height, + uint32_t fourcc, + uint32_t width, + uint32_t height, T* frame) { int y1_pos, y2_pos, u_pos, v_pos; if (!GetYuv422Packing(fourcc, &y1_pos, &y2_pos, &u_pos, &v_pos)) { return false; } - const uint8* start = reinterpret_cast(ms->GetBuffer()); + const uint8_t* start = reinterpret_cast(ms->GetBuffer()); int awidth = (width + 1) & ~1; frame->InitToBlack(width, height, 1, 1, 0); int stride_y = frame->GetYPitch(); int stride_u = frame->GetUPitch(); int stride_v = frame->GetVPitch(); - for (uint32 y = 0; y < height; ++y) { - for (uint32 x = 0; x < width; x += 2) { - const uint8* quad1 = start + (y * awidth + x) * 2; + for (uint32_t y = 0; y < height; ++y) { + for (uint32_t x = 0; x < width; x += 2) { + const uint8_t* quad1 = start + (y * awidth + x) * 2; frame->GetYPlane()[stride_y * y + x] = quad1[y1_pos]; if ((x + 1) < width) { frame->GetYPlane()[stride_y * y + x + 1] = quad1[y2_pos]; } if ((y & 1) == 0) { - const uint8* quad2 = quad1 + awidth * 2; + const uint8_t* quad2 = quad1 + awidth * 2; if ((y + 1) >= height) { quad2 = quad1; } @@ -309,14 +324,16 @@ class VideoFrameTest : public testing::Test { // Convert RGB to 420. // A negative height inverts the image. bool ConvertRgb(const rtc::MemoryStream* ms, - uint32 fourcc, int32 width, int32 height, + uint32_t fourcc, + int32_t width, + int32_t height, T* frame) { int r_pos, g_pos, b_pos, bytes; if (!GetRgbPacking(fourcc, &r_pos, &g_pos, &b_pos, &bytes)) { return false; } int pitch = width * bytes; - const uint8* start = reinterpret_cast(ms->GetBuffer()); + const uint8_t* start = reinterpret_cast(ms->GetBuffer()); if (height < 0) { height = -height; start = start + pitch * (height - 1); @@ -326,10 +343,10 @@ class VideoFrameTest : public testing::Test { int stride_y = frame->GetYPitch(); int stride_u = frame->GetUPitch(); int stride_v = frame->GetVPitch(); - for (int32 y = 0; y < height; y += 2) { - for (int32 x = 0; x < width; x += 2) { - const uint8* rgb[4]; - uint8 yuv[4][3]; + for (int32_t y = 0; y < height; y += 2) { + for (int32_t x = 0; x < width; x += 2) { + const uint8_t* rgb[4]; + uint8_t yuv[4][3]; rgb[0] = start + y * pitch + x * bytes; rgb[1] = rgb[0] + ((x + 1) < width ? bytes : 0); rgb[2] = rgb[0] + ((y + 1) < height ? pitch : 0); @@ -358,15 +375,22 @@ class VideoFrameTest : public testing::Test { } // Simple and slow RGB->YUV conversion. From NTSC standard, c/o Wikipedia. - void ConvertRgbPixel(uint8 r, uint8 g, uint8 b, - uint8* y, uint8* u, uint8* v) { + void ConvertRgbPixel(uint8_t r, + uint8_t g, + uint8_t b, + uint8_t* y, + uint8_t* u, + uint8_t* v) { *y = static_cast(.257 * r + .504 * g + .098 * b) + 16; *u = static_cast(-.148 * r - .291 * g + .439 * b) + 128; *v = static_cast(.439 * r - .368 * g - .071 * b) + 128; } - bool GetYuv422Packing(uint32 fourcc, - int* y1_pos, int* y2_pos, int* u_pos, int* v_pos) { + bool GetYuv422Packing(uint32_t fourcc, + int* y1_pos, + int* y2_pos, + int* u_pos, + int* v_pos) { if (fourcc == cricket::FOURCC_YUY2) { *y1_pos = 0; *u_pos = 1; *y2_pos = 2; *v_pos = 3; } else if (fourcc == cricket::FOURCC_UYVY) { @@ -377,8 +401,11 @@ class VideoFrameTest : public testing::Test { return true; } - bool GetRgbPacking(uint32 fourcc, - int* r_pos, int* g_pos, int* b_pos, int* bytes) { + bool GetRgbPacking(uint32_t fourcc, + int* r_pos, + int* g_pos, + int* b_pos, + int* bytes) { if (fourcc == cricket::FOURCC_RAW) { *r_pos = 0; *g_pos = 1; *b_pos = 2; *bytes = 3; // RGB in memory. } else if (fourcc == cricket::FOURCC_24BG) { @@ -401,23 +428,26 @@ class VideoFrameTest : public testing::Test { } static bool IsSize(const cricket::VideoFrame& frame, - uint32 width, uint32 height) { - return !IsNull(frame) && - frame.GetYPitch() >= static_cast(width) && - frame.GetUPitch() >= static_cast(width) / 2 && - frame.GetVPitch() >= static_cast(width) / 2 && - frame.GetWidth() == width && frame.GetHeight() == height; + uint32_t width, + uint32_t height) { + return !IsNull(frame) && frame.GetYPitch() >= static_cast(width) && + frame.GetUPitch() >= static_cast(width) / 2 && + frame.GetVPitch() >= static_cast(width) / 2 && + frame.GetWidth() == width && frame.GetHeight() == height; } static bool IsPlaneEqual(const std::string& name, - const uint8* plane1, uint32 pitch1, - const uint8* plane2, uint32 pitch2, - uint32 width, uint32 height, + const uint8_t* plane1, + uint32_t pitch1, + const uint8_t* plane2, + uint32_t pitch2, + uint32_t width, + uint32_t height, int max_error) { - const uint8* r1 = plane1; - const uint8* r2 = plane2; - for (uint32 y = 0; y < height; ++y) { - for (uint32 x = 0; x < width; ++x) { + const uint8_t* r1 = plane1; + const uint8_t* r2 = plane2; + for (uint32_t y = 0; y < height; ++y) { + for (uint32_t x = 0; x < width; ++x) { if (abs(static_cast(r1[x] - r2[x])) > max_error) { LOG(LS_INFO) << "IsPlaneEqual(" << name << "): pixel[" << x << "," << y << "] differs: " @@ -433,28 +463,32 @@ class VideoFrameTest : public testing::Test { } static bool IsEqual(const cricket::VideoFrame& frame, - size_t width, size_t height, - size_t pixel_width, size_t pixel_height, - int64 time_stamp, - const uint8* y, uint32 ypitch, - const uint8* u, uint32 upitch, - const uint8* v, uint32 vpitch, + size_t width, + size_t height, + size_t pixel_width, + size_t pixel_height, + int64_t time_stamp, + const uint8_t* y, + uint32_t ypitch, + const uint8_t* u, + uint32_t upitch, + const uint8_t* v, + uint32_t vpitch, int max_error) { - return IsSize(frame, - static_cast(width), - static_cast(height)) && - frame.GetPixelWidth() == pixel_width && - frame.GetPixelHeight() == pixel_height && - frame.GetTimeStamp() == time_stamp && - IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch, - static_cast(width), - static_cast(height), max_error) && - IsPlaneEqual("u", frame.GetUPlane(), frame.GetUPitch(), u, upitch, - static_cast((width + 1) / 2), - static_cast((height + 1) / 2), max_error) && - IsPlaneEqual("v", frame.GetVPlane(), frame.GetVPitch(), v, vpitch, - static_cast((width + 1) / 2), - static_cast((height + 1) / 2), max_error); + return IsSize(frame, static_cast(width), + static_cast(height)) && + frame.GetPixelWidth() == pixel_width && + frame.GetPixelHeight() == pixel_height && + frame.GetTimeStamp() == time_stamp && + IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch, + static_cast(width), + static_cast(height), max_error) && + IsPlaneEqual("u", frame.GetUPlane(), frame.GetUPitch(), u, upitch, + static_cast((width + 1) / 2), + static_cast((height + 1) / 2), max_error) && + IsPlaneEqual("v", frame.GetVPlane(), frame.GetVPitch(), v, vpitch, + static_cast((width + 1) / 2), + static_cast((height + 1) / 2), max_error); } static bool IsEqual(const cricket::VideoFrame& frame1, @@ -512,11 +546,11 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, &frame)); - const uint8* y = reinterpret_cast(ms.get()->GetBuffer()); - const uint8* u = y + kWidth * kHeight; - const uint8* v = u + kWidth * kHeight / 4; - EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, - y, kWidth, u, kWidth / 2, v, kWidth / 2, 0)); + const uint8_t* y = reinterpret_cast(ms.get()->GetBuffer()); + const uint8_t* u = y + kWidth * kHeight; + const uint8_t* v = u + kWidth * kHeight / 4; + EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u, + kWidth / 2, v, kWidth / 2, 0)); } // Test constructing an image from a YV12 buffer. @@ -527,11 +561,11 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YV12, kWidth, kHeight, &frame)); - const uint8* y = reinterpret_cast(ms.get()->GetBuffer()); - const uint8* v = y + kWidth * kHeight; - const uint8* u = v + kWidth * kHeight / 4; - EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, - y, kWidth, u, kWidth / 2, v, kWidth / 2, 0)); + const uint8_t* y = reinterpret_cast(ms.get()->GetBuffer()); + const uint8_t* v = y + kWidth * kHeight; + const uint8_t* u = v + kWidth * kHeight / 4; + EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u, + kWidth / 2, v, kWidth / 2, 0)); } // Test constructing an image from a I422 buffer. @@ -539,10 +573,10 @@ class VideoFrameTest : public testing::Test { T frame1, frame2; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); size_t buf_size = kWidth * kHeight * 2; - rtc::scoped_ptr buf(new uint8[buf_size + kAlignment]); - uint8* y = ALIGNP(buf.get(), kAlignment); - uint8* u = y + kWidth * kHeight; - uint8* v = u + (kWidth / 2) * kHeight; + rtc::scoped_ptr buf(new uint8_t[buf_size + kAlignment]); + uint8_t* y = ALIGNP(buf.get(), kAlignment); + uint8_t* u = y + kWidth * kHeight; + uint8_t* v = u + (kWidth / 2) * kHeight; EXPECT_EQ(0, libyuv::I420ToI422(frame1.GetYPlane(), frame1.GetYPitch(), frame1.GetUPlane(), frame1.GetUPitch(), frame1.GetVPlane(), frame1.GetVPitch(), @@ -560,8 +594,8 @@ class VideoFrameTest : public testing::Test { T frame1, frame2; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); size_t buf_size = kWidth * kHeight * 2; - rtc::scoped_ptr buf(new uint8[buf_size + kAlignment]); - uint8* yuy2 = ALIGNP(buf.get(), kAlignment); + rtc::scoped_ptr buf(new uint8_t[buf_size + kAlignment]); + uint8_t* yuy2 = ALIGNP(buf.get(), kAlignment); EXPECT_EQ(0, libyuv::I420ToYUY2(frame1.GetYPlane(), frame1.GetYPitch(), frame1.GetUPlane(), frame1.GetUPitch(), frame1.GetVPlane(), frame1.GetVPitch(), @@ -577,8 +611,8 @@ class VideoFrameTest : public testing::Test { T frame1, frame2; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); size_t buf_size = kWidth * kHeight * 2; - rtc::scoped_ptr buf(new uint8[buf_size + kAlignment + 1]); - uint8* yuy2 = ALIGNP(buf.get(), kAlignment) + 1; + rtc::scoped_ptr buf(new uint8_t[buf_size + kAlignment + 1]); + uint8_t* yuy2 = ALIGNP(buf.get(), kAlignment) + 1; EXPECT_EQ(0, libyuv::I420ToYUY2(frame1.GetYPlane(), frame1.GetYPitch(), frame1.GetUPlane(), frame1.GetUPitch(), frame1.GetVPlane(), frame1.GetVPitch(), @@ -734,8 +768,8 @@ class VideoFrameTest : public testing::Test { void ConstructRGB565() { T frame1, frame2; size_t out_size = kWidth * kHeight * 2; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment]); - uint8* out = ALIGNP(outbuf.get(), kAlignment); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment]); + uint8_t* out = ALIGNP(outbuf.get(), kAlignment); T frame; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_RGBP, @@ -750,8 +784,8 @@ class VideoFrameTest : public testing::Test { void ConstructARGB1555() { T frame1, frame2; size_t out_size = kWidth * kHeight * 2; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment]); - uint8* out = ALIGNP(outbuf.get(), kAlignment); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment]); + uint8_t* out = ALIGNP(outbuf.get(), kAlignment); T frame; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_RGBO, @@ -766,8 +800,8 @@ class VideoFrameTest : public testing::Test { void ConstructARGB4444() { T frame1, frame2; size_t out_size = kWidth * kHeight * 2; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment]); - uint8* out = ALIGNP(outbuf.get(), kAlignment); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment]); + uint8_t* out = ALIGNP(outbuf.get(), kAlignment); T frame; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); EXPECT_EQ(out_size, frame1.ConvertToRgbBuffer(cricket::FOURCC_R444, @@ -793,7 +827,7 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(ret); \ EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \ kHeight, \ - reinterpret_cast(ms->GetBuffer()), \ + reinterpret_cast(ms->GetBuffer()), \ data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \ int width_rotate = static_cast(frame1.GetWidth()); \ int height_rotate = static_cast(frame1.GetHeight()); \ @@ -824,7 +858,7 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(ret); \ EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \ kHeight, \ - reinterpret_cast(ms->GetBuffer()), \ + reinterpret_cast(ms->GetBuffer()), \ data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \ int width_rotate = static_cast(frame1.GetWidth()); \ int height_rotate = static_cast(frame1.GetHeight()); \ @@ -931,22 +965,21 @@ class VideoFrameTest : public testing::Test { // Test 1 pixel edge case image I420 buffer. void ConstructI4201Pixel() { T frame; - uint8 pixel[3] = { 1, 2, 3 }; + uint8_t pixel[3] = {1, 2, 3}; for (int i = 0; i < repeat_; ++i) { EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel, sizeof(pixel), 1, 1, 0, webrtc::kVideoRotation_0)); } - const uint8* y = pixel; - const uint8* u = y + 1; - const uint8* v = u + 1; - EXPECT_TRUE(IsEqual(frame, 1, 1, 1, 1, 0, - y, 1, u, 1, v, 1, 0)); + const uint8_t* y = pixel; + const uint8_t* u = y + 1; + const uint8_t* v = u + 1; + EXPECT_TRUE(IsEqual(frame, 1, 1, 1, 1, 0, y, 1, u, 1, v, 1, 0)); } // Test 5 pixel edge case image. void ConstructI4205Pixel() { T frame; - uint8 pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2]; + uint8_t pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2]; memset(pixels5x5, 1, 5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2); for (int i = 0; i < repeat_; ++i) { EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5, @@ -963,7 +996,7 @@ class VideoFrameTest : public testing::Test { // Test 1 pixel edge case image ARGB buffer. void ConstructARGB1Pixel() { T frame; - uint8 pixel[4] = { 64, 128, 192, 255 }; + uint8_t pixel[4] = {64, 128, 192, 255}; for (int i = 0; i < repeat_; ++i) { EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel, sizeof(pixel), 1, 1, 0, @@ -971,8 +1004,8 @@ class VideoFrameTest : public testing::Test { } // Convert back to ARGB. size_t out_size = 4; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment]); - uint8* out = ALIGNP(outbuf.get(), kAlignment); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment]); + uint8_t* out = ALIGNP(outbuf.get(), kAlignment); EXPECT_EQ(out_size, frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB, out, @@ -990,16 +1023,16 @@ class VideoFrameTest : public testing::Test { // Test Black, White and Grey pixels. void ConstructARGBBlackWhitePixel() { T frame; - uint8 pixel[10 * 4] = { 0, 0, 0, 255, // Black. - 0, 0, 0, 255, - 64, 64, 64, 255, // Dark Grey. - 64, 64, 64, 255, - 128, 128, 128, 255, // Grey. - 128, 128, 128, 255, - 196, 196, 196, 255, // Light Grey. - 196, 196, 196, 255, - 255, 255, 255, 255, // White. - 255, 255, 255, 255 }; + uint8_t pixel[10 * 4] = {0, 0, 0, 255, // Black. + 0, 0, 0, 255, // Black. + 64, 64, 64, 255, // Dark Grey. + 64, 64, 64, 255, // Dark Grey. + 128, 128, 128, 255, // Grey. + 128, 128, 128, 255, // Grey. + 196, 196, 196, 255, // Light Grey. + 196, 196, 196, 255, // Light Grey. + 255, 255, 255, 255, // White. + 255, 255, 255, 255}; // White. for (int i = 0; i < repeat_; ++i) { EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 10, 1, 10, 1, pixel, @@ -1008,8 +1041,8 @@ class VideoFrameTest : public testing::Test { } // Convert back to ARGB size_t out_size = 10 * 4; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment]); - uint8* out = ALIGNP(outbuf.get(), kAlignment); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment]); + uint8_t* out = ALIGNP(outbuf.get(), kAlignment); EXPECT_EQ(out_size, frame.ConvertToRgbBuffer(cricket::FOURCC_ARGB, out, @@ -1131,12 +1164,16 @@ class VideoFrameTest : public testing::Test { } // Test constructing an image from an I420 MJPG buffer. - void ValidateFrame(const char* name, uint32 fourcc, int data_adjust, - int size_adjust, bool expected_result) { + void ValidateFrame(const char* name, + uint32_t fourcc, + int data_adjust, + int size_adjust, + bool expected_result) { T frame; rtc::scoped_ptr ms(LoadSample(name)); ASSERT_TRUE(ms.get() != NULL); - const uint8* sample = reinterpret_cast(ms.get()->GetBuffer()); + const uint8_t* sample = + reinterpret_cast(ms.get()->GetBuffer()); size_t sample_size; ms->GetSize(&sample_size); // Optional adjust size to test invalid size. @@ -1144,9 +1181,9 @@ class VideoFrameTest : public testing::Test { // Allocate a buffer with end page aligned. const int kPadToHeapSized = 16 * 1024 * 1024; - rtc::scoped_ptr page_buffer( - new uint8[((data_size + kPadToHeapSized + 4095) & ~4095)]); - uint8* data_ptr = page_buffer.get(); + rtc::scoped_ptr page_buffer( + new uint8_t[((data_size + kPadToHeapSized + 4095) & ~4095)]); + uint8_t* data_ptr = page_buffer.get(); if (!data_ptr) { LOG(LS_WARNING) << "Failed to allocate memory for ValidateFrame test."; EXPECT_FALSE(expected_result); // NULL is okay if failure was expected. @@ -1383,9 +1420,9 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(IsBlack(frame1)); EXPECT_TRUE(IsEqual(frame1, frame2, 0)); EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth, - kHeight, reinterpret_cast(ms->GetBuffer()), - data_size, 1, 1, 0, rotation, - apply_rotation)); + kHeight, + reinterpret_cast(ms->GetBuffer()), + data_size, 1, 1, 0, rotation, apply_rotation)); if (apply_rotation) EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation()); else @@ -1419,23 +1456,32 @@ class VideoFrameTest : public testing::Test { enum ToFrom { TO, FROM }; // Helper function for test converting from I420 to packed formats. - inline void ConvertToBuffer(int bpp, int rowpad, bool invert, ToFrom to_from, - int error, uint32 fourcc, - int (*RGBToI420)(const uint8* src_frame, int src_stride_frame, - uint8* dst_y, int dst_stride_y, - uint8* dst_u, int dst_stride_u, - uint8* dst_v, int dst_stride_v, - int width, int height)) { + inline void ConvertToBuffer(int bpp, + int rowpad, + bool invert, + ToFrom to_from, + int error, + uint32_t fourcc, + int (*RGBToI420)(const uint8_t* src_frame, + int src_stride_frame, + uint8_t* dst_y, + int dst_stride_y, + uint8_t* dst_u, + int dst_stride_u, + uint8_t* dst_v, + int dst_stride_v, + int width, + int height)) { T frame1, frame2; int repeat_to = (to_from == TO) ? repeat_ : 1; int repeat_from = (to_from == FROM) ? repeat_ : 1; int astride = kWidth * bpp + rowpad; size_t out_size = astride * kHeight; - rtc::scoped_ptr outbuf(new uint8[out_size + kAlignment + 1]); + rtc::scoped_ptr outbuf(new uint8_t[out_size + kAlignment + 1]); memset(outbuf.get(), 0, out_size + kAlignment + 1); - uint8* outtop = ALIGNP(outbuf.get(), kAlignment); - uint8* out = outtop; + uint8_t* outtop = ALIGNP(outbuf.get(), kAlignment); + uint8_t* out = outtop; int stride = astride; if (invert) { out += (kHeight - 1) * stride; // Point to last row. @@ -1750,10 +1796,10 @@ class VideoFrameTest : public testing::Test { void ConvertToI422Buffer() { T frame1, frame2; size_t out_size = kWidth * kHeight * 2; - rtc::scoped_ptr buf(new uint8[out_size + kAlignment]); - uint8* y = ALIGNP(buf.get(), kAlignment); - uint8* u = y + kWidth * kHeight; - uint8* v = u + (kWidth / 2) * kHeight; + rtc::scoped_ptr buf(new uint8_t[out_size + kAlignment]); + uint8_t* y = ALIGNP(buf.get(), kAlignment); + uint8_t* u = y + kWidth * kHeight; + uint8_t* v = u + (kWidth / 2) * kHeight; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); for (int i = 0; i < repeat_; ++i) { EXPECT_EQ(0, libyuv::I420ToI422(frame1.GetYPlane(), frame1.GetYPitch(), @@ -1816,7 +1862,7 @@ class VideoFrameTest : public testing::Test { ASSERT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_I420, kWidth, kHeight, &frame)); size_t out_size = kWidth * kHeight * 3 / 2; - rtc::scoped_ptr out(new uint8[out_size]); + rtc::scoped_ptr out(new uint8_t[out_size]); for (int i = 0; i < repeat_; ++i) { EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size)); } @@ -1864,9 +1910,9 @@ class VideoFrameTest : public testing::Test { void CopyToBuffer1Pixel() { size_t out_size = 3; - rtc::scoped_ptr out(new uint8[out_size + 1]); + rtc::scoped_ptr out(new uint8_t[out_size + 1]); memset(out.get(), 0xfb, out_size + 1); // Fill buffer - uint8 pixel[3] = { 1, 2, 3 }; + uint8_t pixel[3] = {1, 2, 3}; T frame; EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel, sizeof(pixel), 1, 1, 0, diff --git a/talk/media/base/yuvframegenerator.cc b/talk/media/base/yuvframegenerator.cc index 1673ef8a17..2bec4e4231 100644 --- a/talk/media/base/yuvframegenerator.cc +++ b/talk/media/base/yuvframegenerator.cc @@ -55,9 +55,9 @@ YuvFrameGenerator::YuvFrameGenerator(int width, int height, int size = width_ * height_; int qsize = size / 4; frame_data_size_ = size + 2 * qsize; - y_data_ = new uint8[size]; - u_data_ = new uint8[qsize]; - v_data_ = new uint8[qsize]; + y_data_ = new uint8_t[size]; + u_data_ = new uint8_t[qsize]; + v_data_ = new uint8_t[qsize]; if (enable_barcode) { ASSERT(width_ >= kBarcodeBackgroundWidth); ASSERT(height_>= kBarcodeBackgroundHeight); @@ -75,8 +75,8 @@ YuvFrameGenerator::~YuvFrameGenerator() { delete v_data_; } -void YuvFrameGenerator::GenerateNextFrame(uint8* frame_buffer, - int32 barcode_value) { +void YuvFrameGenerator::GenerateNextFrame(uint8_t* frame_buffer, + int32_t barcode_value) { int size = width_ * height_; int qsize = size / 4; memset(y_data_, 0, size); @@ -104,7 +104,7 @@ void YuvFrameGenerator::GenerateNextFrame(uint8* frame_buffer, frame_index_ = (frame_index_ + 1) & 0x0000FFFF; } -void YuvFrameGenerator::DrawLandscape(uint8 *p, int w, int h) { +void YuvFrameGenerator::DrawLandscape(uint8_t* p, int w, int h) { int x, y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { @@ -117,7 +117,7 @@ void YuvFrameGenerator::DrawLandscape(uint8 *p, int w, int h) { } } -void YuvFrameGenerator::DrawGradientX(uint8 *p, int w, int h) { +void YuvFrameGenerator::DrawGradientX(uint8_t* p, int w, int h) { int x, y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { @@ -126,7 +126,7 @@ void YuvFrameGenerator::DrawGradientX(uint8 *p, int w, int h) { } } -void YuvFrameGenerator::DrawGradientY(uint8 *p, int w, int h) { +void YuvFrameGenerator::DrawGradientY(uint8_t* p, int w, int h) { int x, y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { @@ -135,7 +135,7 @@ void YuvFrameGenerator::DrawGradientY(uint8 *p, int w, int h) { } } -void YuvFrameGenerator::DrawMovingLineX(uint8 *p, int w, int h, int n) { +void YuvFrameGenerator::DrawMovingLineX(uint8_t* p, int w, int h, int n) { int x, y; x = n % (w * 2); if (x >= w) x = w + w - x - 1; @@ -144,7 +144,7 @@ void YuvFrameGenerator::DrawMovingLineX(uint8 *p, int w, int h, int n) { } } -void YuvFrameGenerator::DrawMovingLineY(uint8 *p, int w, int h, int n) { +void YuvFrameGenerator::DrawMovingLineY(uint8_t* p, int w, int h, int n) { int x, y; y = n % (h * 2); if (y >= h) y = h + h - y - 1; @@ -153,7 +153,7 @@ void YuvFrameGenerator::DrawMovingLineY(uint8 *p, int w, int h, int n) { } } -void YuvFrameGenerator::DrawBouncingCube(uint8 *p, int w, int h, int n) { +void YuvFrameGenerator::DrawBouncingCube(uint8_t* p, int w, int h, int n) { int x, y, pw, ph, px, py; pw = w / 16; ph = h / 16; @@ -181,7 +181,7 @@ void YuvFrameGenerator::GetBarcodeBounds(int* top, int* left, *height = kBarcodeBackgroundHeight; } -static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) { +static void ComputeBarcodeDigits(uint32_t value, std::stringstream* result) { // Serialize |value| as 7-char string, padded with 0's to the left. result->width(kBarcodeMaxEncodableDigits); result->fill('0'); @@ -193,10 +193,10 @@ static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) { for (int pos = 1; pos <= kBarcodeMaxEncodableDigits; pos++) { char next_char; result->get(next_char); - uint8 digit = next_char - '0'; + uint8_t digit = next_char - '0'; sum += digit * (pos % 2 ? 3 : 1); } - uint8 check_digit = sum % 10; + uint8_t check_digit = sum % 10; if (check_digit != 0) { check_digit = 10 - check_digit; } @@ -205,7 +205,7 @@ static void ComputeBarcodeDigits(uint32 value, std::stringstream* result) { result->seekg(0); } -void YuvFrameGenerator::DrawBarcode(uint32 value) { +void YuvFrameGenerator::DrawBarcode(uint32_t value) { std::stringstream value_str_stream; ComputeBarcodeDigits(value, &value_str_stream); @@ -234,7 +234,7 @@ void YuvFrameGenerator::DrawBarcode(uint32 value) { if (pos++ == 4) { x = DrawMiddleGuardBars(x, y, kBarcodeGuardBarHeight); } - uint8 digit = next_char - '0'; + uint8_t digit = next_char - '0'; x = DrawEanEncodedDigit(digit, x, y, kBarcodeNormalBarHeight, pos > 4); } x = DrawSideGuardBars(x, y, kBarcodeGuardBarHeight); @@ -259,15 +259,15 @@ int YuvFrameGenerator::DrawSideGuardBars(int x, int y, int height) { // which bars are black (1) and which are blank (0). These are for the L-code // only. R-code values are bitwise negation of these. Reference: // http://en.wikipedia.org/wiki/European_Article_Number#Binary_encoding_of_data_digits_into_EAN-13_barcode // NOLINT -const uint8 kEanEncodings[] = { 13, 25, 19, 61, 35, 49, 47, 59, 55, 11 }; +const uint8_t kEanEncodings[] = {13, 25, 19, 61, 35, 49, 47, 59, 55, 11}; int YuvFrameGenerator::DrawEanEncodedDigit(int digit, int x, int y, int height, bool flip) { - uint8 ean_encoding = kEanEncodings[digit]; + uint8_t ean_encoding = kEanEncodings[digit]; if (flip) { ean_encoding = ~ean_encoding; } - uint8 mask = 0x40; + uint8_t mask = 0x40; for (int i = 6; i >= 0; i--, mask >>= 1) { if (ean_encoding & mask) { DrawBlockRectangle(y_data_, x, y, kUnitBarSize, height, width_, 0); @@ -277,8 +277,13 @@ int YuvFrameGenerator::DrawEanEncodedDigit(int digit, int x, int y, return x; } -void YuvFrameGenerator::DrawBlockRectangle(uint8* p, - int x_start, int y_start, int width, int height, int pitch, uint8 value) { +void YuvFrameGenerator::DrawBlockRectangle(uint8_t* p, + int x_start, + int y_start, + int width, + int height, + int pitch, + uint8_t value) { for (int x = x_start; x < x_start + width; x++) { for (int y = y_start; y < y_start + height; y++) { p[x + y * pitch] = value; diff --git a/talk/media/base/yuvframegenerator.h b/talk/media/base/yuvframegenerator.h index 8ae5b5d0a2..9091362f23 100644 --- a/talk/media/base/yuvframegenerator.h +++ b/talk/media/base/yuvframegenerator.h @@ -48,8 +48,8 @@ class YuvFrameGenerator { public: // Constructs a frame-generator that produces frames of size |width|x|height|. // If |enable_barcode| is specified, barcodes can be included in the frames - // when calling |GenerateNextFrame(uint8*, uint32)|. If |enable_barcode| is - // |true| then |width|x|height| should be at least 160x100; otherwise this + // when calling |GenerateNextFrame(uint8_t*, uint32_t)|. If |enable_barcode| + // is |true| then |width|x|height| should be at least 160x100; otherwise this // constructor will abort. YuvFrameGenerator(int width, int height, bool enable_barcode); ~YuvFrameGenerator(); @@ -61,7 +61,7 @@ class YuvFrameGenerator { // into a barcode in the frame. The value should in the range: // [0..9,999,999]. If the value exceeds this range or barcodes were not // requested in the constructor, this function will abort. - void GenerateNextFrame(uint8* frame_buffer, int32 barcode_value); + void GenerateNextFrame(uint8_t* frame_buffer, int32_t barcode_value); int GetHeight() { return height_; } int GetWidth() { return width_; } @@ -72,28 +72,33 @@ class YuvFrameGenerator { void GetBarcodeBounds(int* top, int* left, int* width, int* height); private: - void DrawLandscape(uint8 *p, int w, int h); - void DrawGradientX(uint8 *p, int w, int h); - void DrawGradientY(uint8 *p, int w, int h); - void DrawMovingLineX(uint8 *p, int w, int h, int n); - void DrawMovingLineY(uint8 *p, int w, int h, int n); - void DrawBouncingCube(uint8 *p, int w, int h, int n); + void DrawLandscape(uint8_t* p, int w, int h); + void DrawGradientX(uint8_t* p, int w, int h); + void DrawGradientY(uint8_t* p, int w, int h); + void DrawMovingLineX(uint8_t* p, int w, int h, int n); + void DrawMovingLineY(uint8_t* p, int w, int h, int n); + void DrawBouncingCube(uint8_t* p, int w, int h, int n); - void DrawBarcode(uint32 value); + void DrawBarcode(uint32_t value); int DrawSideGuardBars(int x, int y, int height); int DrawMiddleGuardBars(int x, int y, int height); int DrawEanEncodedDigit(int digit, int x, int y, int height, bool r_code); - void DrawBlockRectangle(uint8* p, int x_start, int y_start, - int width, int height, int pitch, uint8 value); + void DrawBlockRectangle(uint8_t* p, + int x_start, + int y_start, + int width, + int height, + int pitch, + uint8_t value); private: int width_; int height_; int frame_index_; int frame_data_size_; - uint8* y_data_; - uint8* u_data_; - uint8* v_data_; + uint8_t* y_data_; + uint8_t* u_data_; + uint8_t* v_data_; int barcode_start_x_; int barcode_start_y_; diff --git a/talk/media/devices/carbonvideorenderer.cc b/talk/media/devices/carbonvideorenderer.cc index f96dfacad8..846135d925 100644 --- a/talk/media/devices/carbonvideorenderer.cc +++ b/talk/media/devices/carbonvideorenderer.cc @@ -116,7 +116,7 @@ bool CarbonVideoRenderer::SetSize(int width, int height, int reserved) { rtc::CritScope cs(&image_crit_); image_width_ = width; image_height_ = height; - image_.reset(new uint8[width * height * 4]); + image_.reset(new uint8_t[width * height * 4]); memset(image_.get(), 255, width * height * 4); } return true; diff --git a/talk/media/devices/carbonvideorenderer.h b/talk/media/devices/carbonvideorenderer.h index 046c735e9d..52c974060c 100644 --- a/talk/media/devices/carbonvideorenderer.h +++ b/talk/media/devices/carbonvideorenderer.h @@ -59,7 +59,7 @@ class CarbonVideoRenderer : public VideoRenderer { static OSStatus DrawEventHandler(EventHandlerCallRef handler, EventRef event, void* data); - rtc::scoped_ptr image_; + rtc::scoped_ptr image_; rtc::CriticalSection image_crit_; int image_width_; int image_height_; diff --git a/talk/media/devices/filevideocapturer.cc b/talk/media/devices/filevideocapturer.cc index 489be53ccc..72398e0b88 100644 --- a/talk/media/devices/filevideocapturer.cc +++ b/talk/media/devices/filevideocapturer.cc @@ -60,7 +60,7 @@ bool VideoRecorder::RecordFrame(const CapturedFrame& frame) { return false; } - uint32 size = 0; + uint32_t size = 0; if (!frame.GetDataSize(&size)) { LOG(LS_ERROR) << "Unable to calculate the data size of the frame"; return false; @@ -158,7 +158,7 @@ class FileVideoCapturer::FileReadThread ///////////////////////////////////////////////////////////////////// // Implementation of class FileVideoCapturer ///////////////////////////////////////////////////////////////////// -static const int64 kNumNanoSecsPerMilliSec = 1000000; +static const int64_t kNumNanoSecsPerMilliSec = 1000000; const char* FileVideoCapturer::kVideoFileDevicePrefix = "video-file:"; FileVideoCapturer::FileVideoCapturer() @@ -267,7 +267,7 @@ void FileVideoCapturer::Stop() { SetCaptureFormat(NULL); } -bool FileVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { +bool FileVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { if (!fourccs) { return false; } @@ -296,15 +296,15 @@ rtc::StreamResult FileVideoCapturer::ReadFrameHeader( return rtc::SR_EOS; } rtc::ByteBuffer buffer(header, CapturedFrame::kFrameHeaderSize); - buffer.ReadUInt32(reinterpret_cast(&frame->width)); - buffer.ReadUInt32(reinterpret_cast(&frame->height)); + buffer.ReadUInt32(reinterpret_cast(&frame->width)); + buffer.ReadUInt32(reinterpret_cast(&frame->height)); buffer.ReadUInt32(&frame->fourcc); buffer.ReadUInt32(&frame->pixel_width); buffer.ReadUInt32(&frame->pixel_height); // Elapsed time is deprecated. - uint64 dummy_elapsed_time; + uint64_t dummy_elapsed_time; buffer.ReadUInt64(&dummy_elapsed_time); - buffer.ReadUInt64(reinterpret_cast(&frame->time_stamp)); + buffer.ReadUInt64(reinterpret_cast(&frame->time_stamp)); buffer.ReadUInt32(&frame->data_size); } @@ -313,12 +313,12 @@ rtc::StreamResult FileVideoCapturer::ReadFrameHeader( // Executed in the context of FileReadThread. bool FileVideoCapturer::ReadFrame(bool first_frame, int* wait_time_ms) { - uint32 start_read_time_ms = rtc::Time(); + uint32_t start_read_time_ms = rtc::Time(); // 1. Signal the previously read frame to downstream. if (!first_frame) { - captured_frame_.time_stamp = kNumNanoSecsPerMilliSec * - static_cast(start_read_time_ms); + captured_frame_.time_stamp = + kNumNanoSecsPerMilliSec * static_cast(start_read_time_ms); SignalFrameCaptured(this, &captured_frame_); } @@ -367,10 +367,10 @@ bool FileVideoCapturer::ReadFrame(bool first_frame, int* wait_time_ms) { // control the rate; otherwise, we use the timestamp in the file to control // the rate. if (!first_frame && !ignore_framerate_) { - int64 interval_ns = - GetCaptureFormat()->interval > VideoFormat::kMinimumInterval ? - GetCaptureFormat()->interval : - captured_frame_.time_stamp - last_frame_timestamp_ns_; + int64_t interval_ns = + GetCaptureFormat()->interval > VideoFormat::kMinimumInterval + ? GetCaptureFormat()->interval + : captured_frame_.time_stamp - last_frame_timestamp_ns_; int interval_ms = static_cast(interval_ns / kNumNanoSecsPerMilliSec); interval_ms -= rtc::Time() - start_read_time_ms; if (interval_ms > 0) { diff --git a/talk/media/devices/filevideocapturer.h b/talk/media/devices/filevideocapturer.h index f72c638df1..cc41c39b5d 100644 --- a/talk/media/devices/filevideocapturer.h +++ b/talk/media/devices/filevideocapturer.h @@ -122,7 +122,7 @@ class FileVideoCapturer : public VideoCapturer { protected: // Override virtual methods of parent class VideoCapturer. - virtual bool GetPreferredFourccs(std::vector* fourccs); + virtual bool GetPreferredFourccs(std::vector* fourccs); // Read the frame header from the file stream, video_file_. rtc::StreamResult ReadFrameHeader(CapturedFrame* frame); @@ -146,10 +146,10 @@ class FileVideoCapturer : public VideoCapturer { rtc::FileStream video_file_; CapturedFrame captured_frame_; // The number of bytes allocated buffer for captured_frame_.data. - uint32 frame_buffer_size_; + uint32_t frame_buffer_size_; FileReadThread* file_read_thread_; int repeat_; // How many times to repeat the file. - int64 last_frame_timestamp_ns_; // Timestamp of last read frame. + int64_t last_frame_timestamp_ns_; // Timestamp of last read frame. bool ignore_framerate_; RTC_DISALLOW_COPY_AND_ASSIGN(FileVideoCapturer); diff --git a/talk/media/devices/gdivideorenderer.cc b/talk/media/devices/gdivideorenderer.cc index f6fee1ccc8..69453067e2 100644 --- a/talk/media/devices/gdivideorenderer.cc +++ b/talk/media/devices/gdivideorenderer.cc @@ -100,7 +100,7 @@ class GdiVideoRenderer::VideoWindow : public rtc::Win32Window { void OnRenderFrame(const VideoFrame* frame); BITMAPINFO bmi_; - rtc::scoped_ptr image_; + rtc::scoped_ptr image_; rtc::scoped_ptr window_thread_; // The initial position of the window. int initial_x_; @@ -123,7 +123,7 @@ GdiVideoRenderer::VideoWindow::VideoWindow( bmi_.bmiHeader.biHeight = -height; bmi_.bmiHeader.biSizeImage = width * height * 4; - image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]); + image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); } GdiVideoRenderer::VideoWindow::~VideoWindow() { @@ -237,7 +237,7 @@ void GdiVideoRenderer::VideoWindow::OnSize(int width, int height, bmi_.bmiHeader.biWidth = width; bmi_.bmiHeader.biHeight = -height; bmi_.bmiHeader.biSizeImage = width * height * 4; - image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]); + image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); } } diff --git a/talk/media/devices/gtkvideorenderer.cc b/talk/media/devices/gtkvideorenderer.cc index b44b22cdab..d389960e3d 100755 --- a/talk/media/devices/gtkvideorenderer.cc +++ b/talk/media/devices/gtkvideorenderer.cc @@ -89,7 +89,7 @@ bool GtkVideoRenderer::SetSize(int width, int height, int reserved) { return false; } - image_.reset(new uint8[width * height * 4]); + image_.reset(new uint8_t[width * height * 4]); gtk_widget_set_size_request(draw_area_, width, height); width_ = width; @@ -153,7 +153,7 @@ bool GtkVideoRenderer::Initialize(int width, int height) { gtk_widget_show_all(window_); gtk_window_move(GTK_WINDOW(window_), initial_x_, initial_y_); - image_.reset(new uint8[width * height * 4]); + image_.reset(new uint8_t[width * height * 4]); return true; } diff --git a/talk/media/devices/gtkvideorenderer.h b/talk/media/devices/gtkvideorenderer.h index 48e13640c6..0270a7a2c9 100755 --- a/talk/media/devices/gtkvideorenderer.h +++ b/talk/media/devices/gtkvideorenderer.h @@ -58,7 +58,7 @@ class GtkVideoRenderer : public VideoRenderer { // Check if the window has been closed. bool IsClosed() const; - rtc::scoped_ptr image_; + rtc::scoped_ptr image_; GtkWidget* window_; GtkWidget* draw_area_; // The initial position of the window. diff --git a/talk/media/devices/linuxdevicemanager.cc b/talk/media/devices/linuxdevicemanager.cc index d122169ad6..25be321c5e 100644 --- a/talk/media/devices/linuxdevicemanager.cc +++ b/talk/media/devices/linuxdevicemanager.cc @@ -60,9 +60,9 @@ class LinuxDeviceWatcher virtual void Stop(); private: - virtual uint32 GetRequestedEvents(); - virtual void OnPreEvent(uint32 ff); - virtual void OnEvent(uint32 ff, int err); + virtual uint32_t GetRequestedEvents(); + virtual void OnPreEvent(uint32_t ff); + virtual void OnEvent(uint32_t ff, int err); virtual int GetDescriptor(); virtual bool IsDescriptorClosed(); @@ -368,15 +368,15 @@ void LinuxDeviceWatcher::Stop() { libudev_.Unload(); } -uint32 LinuxDeviceWatcher::GetRequestedEvents() { +uint32_t LinuxDeviceWatcher::GetRequestedEvents() { return rtc::DE_READ; } -void LinuxDeviceWatcher::OnPreEvent(uint32 ff) { +void LinuxDeviceWatcher::OnPreEvent(uint32_t ff) { // Nothing to do. } -void LinuxDeviceWatcher::OnEvent(uint32 ff, int err) { +void LinuxDeviceWatcher::OnEvent(uint32_t ff, int err) { udev_device* device = libudev_.udev_monitor_receive_device()(udev_monitor_); if (!device) { // Probably the socket connection to the udev daemon was terminated (perhaps diff --git a/talk/media/devices/mobiledevicemanager.cc b/talk/media/devices/mobiledevicemanager.cc index 39860edf9d..2a886a36d4 100644 --- a/talk/media/devices/mobiledevicemanager.cc +++ b/talk/media/devices/mobiledevicemanager.cc @@ -53,10 +53,10 @@ bool MobileDeviceManager::GetVideoCaptureDevices(std::vector* devs) { if (!info) return false; - uint32 num_cams = info->NumberOfDevices(); + uint32_t num_cams = info->NumberOfDevices(); char id[256]; char name[256]; - for (uint32 i = 0; i < num_cams; ++i) { + for (uint32_t i = 0; i < num_cams; ++i) { if (info->GetDeviceName(i, name, arraysize(name), id, arraysize(id))) continue; devs->push_back(Device(name, id)); diff --git a/talk/media/devices/yuvframescapturer.cc b/talk/media/devices/yuvframescapturer.cc index 7579df170a..dc91cc8411 100644 --- a/talk/media/devices/yuvframescapturer.cc +++ b/talk/media/devices/yuvframescapturer.cc @@ -140,7 +140,7 @@ CaptureState YuvFramesCapturer::Start(const VideoFormat& capture_format) { SetCaptureFormat(&capture_format); barcode_reference_timestamp_millis_ = - static_cast(rtc::Time()) * 1000; + static_cast(rtc::Time()) * 1000; // Create a thread to generate frames. frames_generator_thread = new YuvFramesThread(this); bool ret = frames_generator_thread->Start(); @@ -166,7 +166,7 @@ void YuvFramesCapturer::Stop() { SetCaptureFormat(NULL); } -bool YuvFramesCapturer::GetPreferredFourccs(std::vector* fourccs) { +bool YuvFramesCapturer::GetPreferredFourccs(std::vector* fourccs) { if (!fourccs) { return false; } @@ -180,21 +180,20 @@ void YuvFramesCapturer::ReadFrame(bool first_frame) { if (!first_frame) { SignalFrameCaptured(this, &captured_frame_); } - uint8* buffer = new uint8[frame_data_size_]; + uint8_t* buffer = new uint8_t[frame_data_size_]; frame_generator_->GenerateNextFrame(buffer, GetBarcodeValue()); frame_index_++; memmove(captured_frame_.data, buffer, frame_data_size_); delete[] buffer; } - -int32 YuvFramesCapturer::GetBarcodeValue() { +int32_t YuvFramesCapturer::GetBarcodeValue() { if (barcode_reference_timestamp_millis_ == -1 || frame_index_ % barcode_interval_ != 0) { return -1; } - int64 now_millis = static_cast(rtc::Time()) * 1000; - return static_cast(now_millis - barcode_reference_timestamp_millis_); + int64_t now_millis = static_cast(rtc::Time()) * 1000; + return static_cast(now_millis - barcode_reference_timestamp_millis_); } } // namespace cricket diff --git a/talk/media/devices/yuvframescapturer.h b/talk/media/devices/yuvframescapturer.h index 08c8470861..850a8dfb1d 100644 --- a/talk/media/devices/yuvframescapturer.h +++ b/talk/media/devices/yuvframescapturer.h @@ -70,7 +70,7 @@ class YuvFramesCapturer : public VideoCapturer { protected: // Override virtual methods of parent class VideoCapturer. - virtual bool GetPreferredFourccs(std::vector* fourccs); + virtual bool GetPreferredFourccs(std::vector* fourccs); // Read a frame and determine how long to wait for the next frame. void ReadFrame(bool first_frame); @@ -83,12 +83,12 @@ class YuvFramesCapturer : public VideoCapturer { YuvFramesThread* frames_generator_thread; int width_; int height_; - uint32 frame_data_size_; - uint32 frame_index_; + uint32_t frame_data_size_; + uint32_t frame_index_; - int64 barcode_reference_timestamp_millis_; - int32 barcode_interval_; - int32 GetBarcodeValue(); + int64_t barcode_reference_timestamp_millis_; + int32_t barcode_interval_; + int32_t GetBarcodeValue(); RTC_DISALLOW_COPY_AND_ASSIGN(YuvFramesCapturer); }; diff --git a/talk/media/sctp/sctpdataengine.cc b/talk/media/sctp/sctpdataengine.cc index 1ead8e0f2e..739383d379 100644 --- a/talk/media/sctp/sctpdataengine.cc +++ b/talk/media/sctp/sctpdataengine.cc @@ -88,7 +88,7 @@ std::string ListFlags(int flags) { // Returns a comma-separated, human-readable list of the integers in 'array'. // All 'num_elems' of them. -std::string ListArray(const uint16* array, int num_elems) { +std::string ListArray(const uint16_t* array, int num_elems) { std::stringstream result; for (int i = 0; i < num_elems; ++i) { if (i) { @@ -575,7 +575,7 @@ bool SctpDataMediaChannel::AddSendStream(const StreamParams& stream) { return AddStream(stream); } -bool SctpDataMediaChannel::RemoveSendStream(uint32 ssrc) { +bool SctpDataMediaChannel::RemoveSendStream(uint32_t ssrc) { return ResetStream(ssrc); } @@ -586,7 +586,7 @@ bool SctpDataMediaChannel::AddRecvStream(const StreamParams& stream) { return true; } -bool SctpDataMediaChannel::RemoveRecvStream(uint32 ssrc) { +bool SctpDataMediaChannel::RemoveRecvStream(uint32_t ssrc) { // SCTP DataChannels are always bi-directional and calling RemoveSendStream // will disable both sending and receiving on the stream. So RemoveRecvStream // is a no-op. @@ -727,7 +727,7 @@ bool SctpDataMediaChannel::AddStream(const StreamParams& stream) { return false; } - const uint32 ssrc = stream.first_ssrc(); + const uint32_t ssrc = stream.first_ssrc(); if (open_streams_.find(ssrc) != open_streams_.end()) { LOG(LS_WARNING) << debug_name_ << "->Add(Send|Recv)Stream(...): " << "Not adding data stream '" << stream.id @@ -747,7 +747,7 @@ bool SctpDataMediaChannel::AddStream(const StreamParams& stream) { return true; } -bool SctpDataMediaChannel::ResetStream(uint32 ssrc) { +bool SctpDataMediaChannel::ResetStream(uint32_t ssrc) { // We typically get this called twice for the same stream, once each for // Send and Recv. StreamSet::iterator found = open_streams_.find(ssrc); @@ -997,10 +997,10 @@ bool SctpDataMediaChannel::SendQueuedStreamResets() { << ListStreams(sent_reset_streams_) << "]"; const size_t num_streams = queued_reset_streams_.size(); - const size_t num_bytes = sizeof(struct sctp_reset_streams) - + (num_streams * sizeof(uint16)); + const size_t num_bytes = + sizeof(struct sctp_reset_streams) + (num_streams * sizeof(uint16_t)); - std::vector reset_stream_buf(num_bytes, 0); + std::vector reset_stream_buf(num_bytes, 0); struct sctp_reset_streams* resetp = reinterpret_cast( &reset_stream_buf[0]); resetp->srs_assoc_id = SCTP_ALL_ASSOC; diff --git a/talk/media/sctp/sctpdataengine.h b/talk/media/sctp/sctpdataengine.h index 451c00d5ba..4bc5f0b6fb 100644 --- a/talk/media/sctp/sctpdataengine.h +++ b/talk/media/sctp/sctpdataengine.h @@ -56,7 +56,7 @@ struct socket; namespace cricket { // The highest stream ID (Sid) that SCTP allows, and the number of streams we // tell SCTP we're going to use. -const uint32 kMaxSctpSid = 1023; +const uint32_t kMaxSctpSid = 1023; // This is the default SCTP port to use. It is passed along the wire and the // connectee and connector must be using the same port. It is not related to the @@ -134,7 +134,7 @@ class SctpDataMediaChannel : public DataMediaChannel, PPID_TEXT_LAST = 51 }; - typedef std::set StreamSet; + typedef std::set StreamSet; // Given a thread which will be used to post messages (received data) to this // SctpDataMediaChannel instance. @@ -151,9 +151,9 @@ class SctpDataMediaChannel : public DataMediaChannel, virtual bool SetSendParameters(const DataSendParameters& params); virtual bool SetRecvParameters(const DataRecvParameters& params); virtual bool AddSendStream(const StreamParams& sp); - virtual bool RemoveSendStream(uint32 ssrc); + virtual bool RemoveSendStream(uint32_t ssrc); virtual bool AddRecvStream(const StreamParams& sp); - virtual bool RemoveRecvStream(uint32 ssrc); + virtual bool RemoveRecvStream(uint32_t ssrc); // Called when Sctp gets data. The data may be a notification or data for // OnSctpInboundData. Called from the worker thread. @@ -207,7 +207,7 @@ class SctpDataMediaChannel : public DataMediaChannel, // Adds a stream. bool AddStream(const StreamParams &sp); // Queues a stream for reset. - bool ResetStream(uint32 ssrc); + bool ResetStream(uint32_t ssrc); // Called by OnMessage to send packet on the network. void OnPacketFromSctpToNetwork(rtc::Buffer* buffer); diff --git a/talk/media/sctp/sctpdataengine_unittest.cc b/talk/media/sctp/sctpdataengine_unittest.cc index c540e7c810..2cd0302f56 100644 --- a/talk/media/sctp/sctpdataengine_unittest.cc +++ b/talk/media/sctp/sctpdataengine_unittest.cc @@ -169,21 +169,19 @@ class SignalChannelClosedObserver : public sigslot::has_slots<> { channel->SignalStreamClosedRemotely.connect( this, &SignalChannelClosedObserver::OnStreamClosed); } - void OnStreamClosed(uint32 stream) { - streams_.push_back(stream); - } + void OnStreamClosed(uint32_t stream) { streams_.push_back(stream); } - int StreamCloseCount(uint32 stream) { + int StreamCloseCount(uint32_t stream) { return std::count(streams_.begin(), streams_.end(), stream); } - bool WasStreamClosed(uint32 stream) { + bool WasStreamClosed(uint32_t stream) { return std::find(streams_.begin(), streams_.end(), stream) != streams_.end(); } private: - std::vector streams_; + std::vector streams_; }; class SignalChannelClosedReopener : public sigslot::has_slots<> { @@ -292,7 +290,8 @@ class SctpDataMediaChannelTest : public testing::Test, return channel; } - bool SendData(cricket::SctpDataMediaChannel* chan, uint32 ssrc, + bool SendData(cricket::SctpDataMediaChannel* chan, + uint32_t ssrc, const std::string& msg, cricket::SendDataResult* result) { cricket::SendDataParams params; @@ -302,8 +301,9 @@ class SctpDataMediaChannelTest : public testing::Test, &msg[0], msg.length()), result); } - bool ReceivedData(const SctpFakeDataReceiver* recv, uint32 ssrc, - const std::string& msg ) { + bool ReceivedData(const SctpFakeDataReceiver* recv, + uint32_t ssrc, + const std::string& msg) { return (recv->received() && recv->last_params().ssrc == ssrc && recv->last_data() == msg); diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h index 755a3def14..d205839f3e 100644 --- a/talk/media/webrtc/fakewebrtcvideoengine.h +++ b/talk/media/webrtc/fakewebrtcvideoengine.h @@ -64,29 +64,27 @@ class FakeWebRtcVideoDecoder : public webrtc::VideoDecoder { : num_frames_received_(0) { } - virtual int32 InitDecode(const webrtc::VideoCodec*, int32) { + virtual int32_t InitDecode(const webrtc::VideoCodec*, int32_t) { return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 Decode( - const webrtc::EncodedImage&, bool, const webrtc::RTPFragmentationHeader*, - const webrtc::CodecSpecificInfo*, int64_t) { + virtual int32_t Decode(const webrtc::EncodedImage&, + bool, + const webrtc::RTPFragmentationHeader*, + const webrtc::CodecSpecificInfo*, + int64_t) { num_frames_received_++; return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 RegisterDecodeCompleteCallback( + virtual int32_t RegisterDecodeCompleteCallback( webrtc::DecodedImageCallback*) { return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 Release() { - return WEBRTC_VIDEO_CODEC_OK; - } + virtual int32_t Release() { return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 Reset() { - return WEBRTC_VIDEO_CODEC_OK; - } + virtual int32_t Reset() { return WEBRTC_VIDEO_CODEC_OK; } int GetNumFramesReceived() const { return num_frames_received_; @@ -144,9 +142,9 @@ class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { public: FakeWebRtcVideoEncoder() : num_frames_encoded_(0) {} - virtual int32 InitEncode(const webrtc::VideoCodec* codecSettings, - int32 numberOfCores, - size_t maxPayloadSize) { + virtual int32_t InitEncode(const webrtc::VideoCodec* codecSettings, + int32_t numberOfCores, + size_t maxPayloadSize) { rtc::CritScope lock(&crit_); codec_settings_ = *codecSettings; return WEBRTC_VIDEO_CODEC_OK; @@ -157,30 +155,27 @@ class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { return codec_settings_; } - virtual int32 Encode(const webrtc::VideoFrame& inputImage, - const webrtc::CodecSpecificInfo* codecSpecificInfo, - const std::vector* frame_types) { + virtual int32_t Encode( + const webrtc::VideoFrame& inputImage, + const webrtc::CodecSpecificInfo* codecSpecificInfo, + const std::vector* frame_types) { rtc::CritScope lock(&crit_); ++num_frames_encoded_; return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 RegisterEncodeCompleteCallback( + virtual int32_t RegisterEncodeCompleteCallback( webrtc::EncodedImageCallback* callback) { return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 Release() { + virtual int32_t Release() { return WEBRTC_VIDEO_CODEC_OK; } + + virtual int32_t SetChannelParameters(uint32_t packetLoss, int64_t rtt) { return WEBRTC_VIDEO_CODEC_OK; } - virtual int32 SetChannelParameters(uint32 packetLoss, - int64_t rtt) { - return WEBRTC_VIDEO_CODEC_OK; - } - - virtual int32 SetRates(uint32 newBitRate, - uint32 frameRate) { + virtual int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) { return WEBRTC_VIDEO_CODEC_OK; } diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h index abe6e6db83..672c5626f9 100644 --- a/talk/media/webrtc/fakewebrtcvoiceengine.h +++ b/talk/media/webrtc/fakewebrtcvoiceengine.h @@ -246,7 +246,7 @@ class FakeWebRtcVoiceEngine int dtmf_type; int red_type; int nack_max_packets; - uint32 send_ssrc; + uint32_t send_ssrc; int send_audio_level_ext_; int receive_audio_level_ext_; int send_absolute_sender_time_ext_; @@ -299,7 +299,7 @@ class FakeWebRtcVoiceEngine bool IsInited() const { return inited_; } int GetLastChannel() const { return last_channel_; } - int GetChannelFromLocalSsrc(uint32 local_ssrc) const { + int GetChannelFromLocalSsrc(uint32_t local_ssrc) const { for (std::map::const_iterator iter = channels_.begin(); iter != channels_.end(); ++iter) { if (local_ssrc == iter->second->send_ssrc) @@ -857,7 +857,7 @@ class FakeWebRtcVoiceEngine unsigned int& discardedPackets)); WEBRTC_FUNC(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats)) { WEBRTC_CHECK_CHANNEL(channel); - stats.fractionLost = static_cast(kIntStatValue); + stats.fractionLost = static_cast(kIntStatValue); stats.cumulativeLost = kIntStatValue; stats.extendedMax = kIntStatValue; stats.jitterSamples = kIntStatValue; diff --git a/talk/media/webrtc/simulcast.cc b/talk/media/webrtc/simulcast.cc index 759cfef93b..3f0820fef9 100755 --- a/talk/media/webrtc/simulcast.cc +++ b/talk/media/webrtc/simulcast.cc @@ -74,7 +74,7 @@ static const int kDefaultConferenceNumberOfTemporalLayers[webrtc::kMaxSimulcastStreams] = {3, 3, 3, 3}; -void GetSimulcastSsrcs(const StreamParams& sp, std::vector* ssrcs) { +void GetSimulcastSsrcs(const StreamParams& sp, std::vector* ssrcs) { const SsrcGroup* sim_group = sp.get_ssrc_group(kSimSsrcGroupSemantics); if (sim_group) { ssrcs->insert( @@ -339,7 +339,7 @@ bool ConfigureSimulcastCodec( const StreamParams& sp, const VideoOptions& options, webrtc::VideoCodec* codec) { - std::vector ssrcs; + std::vector ssrcs; GetSimulcastSsrcs(sp, &ssrcs); SimulcastBitrateMode bitrate_mode = GetSimulcastBitrateMode(options); return ConfigureSimulcastCodec(static_cast(ssrcs.size()), bitrate_mode, diff --git a/talk/media/webrtc/simulcast.h b/talk/media/webrtc/simulcast.h index d96ccd07dd..0f238733da 100755 --- a/talk/media/webrtc/simulcast.h +++ b/talk/media/webrtc/simulcast.h @@ -74,7 +74,7 @@ SimulcastBitrateMode GetSimulcastBitrateMode( const VideoOptions& options); // Get the ssrcs of the SIM group from the stream params. -void GetSimulcastSsrcs(const StreamParams& sp, std::vector* ssrcs); +void GetSimulcastSsrcs(const StreamParams& sp, std::vector* ssrcs); // Get simulcast settings. std::vector GetSimulcastConfig( diff --git a/talk/media/webrtc/webrtcvideocapturer.cc b/talk/media/webrtc/webrtcvideocapturer.cc index f64786f098..9f1f32af4f 100644 --- a/talk/media/webrtc/webrtcvideocapturer.cc +++ b/talk/media/webrtc/webrtcvideocapturer.cc @@ -49,7 +49,7 @@ namespace cricket { struct kVideoFourCCEntry { - uint32 fourcc; + uint32_t fourcc; webrtc::RawVideoType webrtc_type; }; @@ -82,7 +82,7 @@ class WebRtcVcmFactory : public WebRtcVcmFactoryInterface { static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap, VideoFormat* format) { - uint32 fourcc = 0; + uint32_t fourcc = 0; for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) { if (kSupportedFourCCs[i].webrtc_type == cap.rawType) { fourcc = kSupportedFourCCs[i].fourcc; @@ -303,7 +303,7 @@ CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) { return CS_FAILED; } - uint32 start = rtc::Time(); + uint32_t start = rtc::Time(); module_->RegisterCaptureDataCallback(*this); if (module_->StartCapture(cap) != 0) { LOG(LS_ERROR) << "Camera '" << GetId() << "' failed to start"; @@ -355,8 +355,7 @@ bool WebRtcVideoCapturer::IsRunning() { return (module_ != NULL && module_->CaptureStarted()); } -bool WebRtcVideoCapturer::GetPreferredFourccs( - std::vector* fourccs) { +bool WebRtcVideoCapturer::GetPreferredFourccs(std::vector* fourccs) { if (!fourccs) { return false; } @@ -435,7 +434,7 @@ WebRtcCapturedFrame::WebRtcCapturedFrame(const webrtc::VideoFrame& sample, pixel_height = 1; // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds). time_stamp = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec; - data_size = rtc::checked_cast(length); + data_size = rtc::checked_cast(length); data = buffer; rotation = sample.rotation(); } diff --git a/talk/media/webrtc/webrtcvideocapturer.h b/talk/media/webrtc/webrtcvideocapturer.h index fe545ad747..66991e097f 100644 --- a/talk/media/webrtc/webrtcvideocapturer.h +++ b/talk/media/webrtc/webrtcvideocapturer.h @@ -77,7 +77,7 @@ class WebRtcVideoCapturer : public VideoCapturer, protected: // Override virtual methods of the parent class VideoCapturer. - virtual bool GetPreferredFourccs(std::vector* fourccs); + virtual bool GetPreferredFourccs(std::vector* fourccs); private: // Callback when a frame is captured by camera. diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index c53dac8561..5ee0119dcf 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -214,9 +214,9 @@ static bool ValidateStreamParams(const StreamParams& sp) { return false; } - std::vector primary_ssrcs; + std::vector primary_ssrcs; sp.GetPrimarySsrcs(&primary_ssrcs); - std::vector rtx_ssrcs; + std::vector rtx_ssrcs; sp.GetFidSsrcs(primary_ssrcs, &rtx_ssrcs); for (uint32_t rtx_ssrc : rtx_ssrcs) { bool rtx_ssrc_present = false; @@ -916,10 +916,9 @@ bool WebRtcVideoChannel2::SetRecvCodecs(const std::vector& codecs) { recv_codecs_ = supported_codecs; rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = receive_streams_.begin(); - it != receive_streams_.end(); - ++it) { + it != receive_streams_.end(); ++it) { it->second->SetRecvCodecs(recv_codecs_); } @@ -1006,7 +1005,7 @@ bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { return true; } -bool WebRtcVideoChannel2::SetSendStreamFormat(uint32 ssrc, +bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) { LOG(LS_VERBOSE) << "SetSendStreamFormat:" << ssrc << " -> " << format.ToString(); @@ -1032,7 +1031,7 @@ bool WebRtcVideoChannel2::SetSend(bool send) { return true; } -bool WebRtcVideoChannel2::SetVideoSend(uint32 ssrc, bool enable, +bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options) { // TODO(solenberg): The state change should be fully rolled back if any one of // these calls fail. @@ -1079,7 +1078,7 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) { if (!ValidateSendSsrcAvailability(sp)) return false; - for (uint32 used_ssrc : sp.ssrcs) + for (uint32_t used_ssrc : sp.ssrcs) send_ssrcs_.insert(used_ssrc); webrtc::VideoSendStream::Config config(this); @@ -1095,7 +1094,7 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) { send_codec_, send_rtp_extensions_); - uint32 ssrc = sp.first_ssrc(); + uint32_t ssrc = sp.first_ssrc(); RTC_DCHECK(ssrc != 0); send_streams_[ssrc] = stream; @@ -1116,7 +1115,7 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) { return true; } -bool WebRtcVideoChannel2::RemoveSendStream(uint32 ssrc) { +bool WebRtcVideoChannel2::RemoveSendStream(uint32_t ssrc) { LOG(LS_INFO) << "RemoveSendStream: " << ssrc; if (ssrc == 0) { @@ -1132,13 +1131,13 @@ bool WebRtcVideoChannel2::RemoveSendStream(uint32 ssrc) { WebRtcVideoSendStream* removed_stream; { rtc::CritScope stream_lock(&stream_crit_); - std::map::iterator it = + std::map::iterator it = send_streams_.find(ssrc); if (it == send_streams_.end()) { return false; } - for (uint32 old_ssrc : it->second->GetSsrcs()) + for (uint32_t old_ssrc : it->second->GetSsrcs()) send_ssrcs_.erase(old_ssrc); removed_stream = it->second; @@ -1156,7 +1155,7 @@ bool WebRtcVideoChannel2::RemoveSendStream(uint32 ssrc) { void WebRtcVideoChannel2::DeleteReceiveStream( WebRtcVideoChannel2::WebRtcVideoReceiveStream* stream) { - for (uint32 old_ssrc : stream->GetSsrcs()) + for (uint32_t old_ssrc : stream->GetSsrcs()) receive_ssrcs_.erase(old_ssrc); delete stream; } @@ -1174,7 +1173,7 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp, if (!ValidateStreamParams(sp)) return false; - uint32 ssrc = sp.first_ssrc(); + uint32_t ssrc = sp.first_ssrc(); RTC_DCHECK(ssrc != 0); // TODO(pbos): Is this ever valid? rtc::CritScope stream_lock(&stream_crit_); @@ -1193,7 +1192,7 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp, if (!ValidateReceiveSsrcAvailability(sp)) return false; - for (uint32 used_ssrc : sp.ssrcs) + for (uint32_t used_ssrc : sp.ssrcs) receive_ssrcs_.insert(used_ssrc); webrtc::VideoReceiveStream::Config config(this); @@ -1218,7 +1217,7 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp, void WebRtcVideoChannel2::ConfigureReceiverRtp( webrtc::VideoReceiveStream::Config* config, const StreamParams& sp) const { - uint32 ssrc = sp.first_ssrc(); + uint32_t ssrc = sp.first_ssrc(); config->rtp.remote_ssrc = ssrc; config->rtp.local_ssrc = rtcp_receiver_report_ssrc_; @@ -1242,7 +1241,7 @@ void WebRtcVideoChannel2::ConfigureReceiverRtp( } for (size_t i = 0; i < recv_codecs_.size(); ++i) { - uint32 rtx_ssrc; + uint32_t rtx_ssrc; if (recv_codecs_[i].rtx_payload_type != -1 && sp.GetFidSsrc(ssrc, &rtx_ssrc)) { webrtc::VideoReceiveStream::Config::Rtp::Rtx& rtx = @@ -1253,7 +1252,7 @@ void WebRtcVideoChannel2::ConfigureReceiverRtp( } } -bool WebRtcVideoChannel2::RemoveRecvStream(uint32 ssrc) { +bool WebRtcVideoChannel2::RemoveRecvStream(uint32_t ssrc) { LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; if (ssrc == 0) { LOG(LS_ERROR) << "RemoveRecvStream with 0 ssrc is not supported."; @@ -1261,7 +1260,7 @@ bool WebRtcVideoChannel2::RemoveRecvStream(uint32 ssrc) { } rtc::CritScope stream_lock(&stream_crit_); - std::map::iterator stream = + std::map::iterator stream = receive_streams_.find(ssrc); if (stream == receive_streams_.end()) { LOG(LS_ERROR) << "Stream not found for ssrc: " << ssrc; @@ -1273,7 +1272,7 @@ bool WebRtcVideoChannel2::RemoveRecvStream(uint32 ssrc) { return true; } -bool WebRtcVideoChannel2::SetRenderer(uint32 ssrc, VideoRenderer* renderer) { +bool WebRtcVideoChannel2::SetRenderer(uint32_t ssrc, VideoRenderer* renderer) { LOG(LS_INFO) << "SetRenderer: ssrc:" << ssrc << " " << (renderer ? "(ptr)" : "NULL"); if (ssrc == 0) { @@ -1282,7 +1281,7 @@ bool WebRtcVideoChannel2::SetRenderer(uint32 ssrc, VideoRenderer* renderer) { } rtc::CritScope stream_lock(&stream_crit_); - std::map::iterator it = + std::map::iterator it = receive_streams_.find(ssrc); if (it == receive_streams_.end()) { return false; @@ -1292,14 +1291,14 @@ bool WebRtcVideoChannel2::SetRenderer(uint32 ssrc, VideoRenderer* renderer) { return true; } -bool WebRtcVideoChannel2::GetRenderer(uint32 ssrc, VideoRenderer** renderer) { +bool WebRtcVideoChannel2::GetRenderer(uint32_t ssrc, VideoRenderer** renderer) { if (ssrc == 0) { *renderer = default_unsignalled_ssrc_handler_.GetDefaultRenderer(); return *renderer != NULL; } rtc::CritScope stream_lock(&stream_crit_); - std::map::iterator it = + std::map::iterator it = receive_streams_.find(ssrc); if (it == receive_streams_.end()) { return false; @@ -1324,20 +1323,18 @@ bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info) { rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = send_streams_.begin(); - it != send_streams_.end(); - ++it) { + it != send_streams_.end(); ++it) { video_media_info->senders.push_back(it->second->GetVideoSenderInfo()); } } void WebRtcVideoChannel2::FillReceiverStats(VideoMediaInfo* video_media_info) { rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = receive_streams_.begin(); - it != receive_streams_.end(); - ++it) { + it != receive_streams_.end(); ++it) { video_media_info->receivers.push_back(it->second->GetVideoReceiverInfo()); } } @@ -1352,16 +1349,15 @@ void WebRtcVideoChannel2::FillBandwidthEstimationStats( // Get send stream bitrate stats. rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator stream = + for (std::map::iterator stream = send_streams_.begin(); - stream != send_streams_.end(); - ++stream) { + stream != send_streams_.end(); ++stream) { stream->second->FillBandwidthEstimationInfo(&bwe_info); } video_media_info->bw_estimations.push_back(bwe_info); } -bool WebRtcVideoChannel2::SetCapturer(uint32 ssrc, VideoCapturer* capturer) { +bool WebRtcVideoChannel2::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { LOG(LS_INFO) << "SetCapturer: " << ssrc << " -> " << (capturer != NULL ? "(capturer)" : "NULL"); RTC_DCHECK(ssrc != 0); @@ -1419,7 +1415,7 @@ void WebRtcVideoChannel2::OnPacketReceived( break; } - uint32 ssrc = 0; + uint32_t ssrc = 0; if (!GetRtpSsrc(packet->data(), packet->size(), &ssrc)) { return; } @@ -1476,7 +1472,7 @@ void WebRtcVideoChannel2::OnReadyToSend(bool ready) { call_->SignalNetworkState(ready ? webrtc::kNetworkUp : webrtc::kNetworkDown); } -bool WebRtcVideoChannel2::MuteStream(uint32 ssrc, bool mute) { +bool WebRtcVideoChannel2::MuteStream(uint32_t ssrc, bool mute) { LOG(LS_VERBOSE) << "MuteStream: " << ssrc << " -> " << (mute ? "mute" : "unmute"); RTC_DCHECK(ssrc != 0); @@ -1509,10 +1505,9 @@ bool WebRtcVideoChannel2::SetRecvRtpHeaderExtensions( recv_rtp_extensions_ = filtered_extensions; rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = receive_streams_.begin(); - it != receive_streams_.end(); - ++it) { + it != receive_streams_.end(); ++it) { it->second->SetRtpExtensions(recv_rtp_extensions_); } return true; @@ -1540,10 +1535,9 @@ bool WebRtcVideoChannel2::SetSendRtpHeaderExtensions( send_rtp_extensions_, kRtpVideoRotationHeaderExtension); rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = send_streams_.begin(); - it != send_streams_.end(); - ++it) { + it != send_streams_.end(); ++it) { it->second->SetRtpExtensions(send_rtp_extensions_); it->second->SetApplyRotation(!cvo_extension); } @@ -1601,10 +1595,9 @@ bool WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { : rtc::DSCP_DEFAULT; MediaChannel::SetDscp(dscp); rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = send_streams_.begin(); - it != send_streams_.end(); - ++it) { + it != send_streams_.end(); ++it) { it->second->SetOptions(options_); } return true; @@ -1668,20 +1661,18 @@ bool WebRtcVideoChannel2::SendRtcp(const uint8_t* data, size_t len) { void WebRtcVideoChannel2::StartAllSendStreams() { rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = send_streams_.begin(); - it != send_streams_.end(); - ++it) { + it != send_streams_.end(); ++it) { it->second->Start(); } } void WebRtcVideoChannel2::StopAllSendStreams() { rtc::CritScope stream_lock(&stream_crit_); - for (std::map::iterator it = + for (std::map::iterator it = send_streams_.begin(); - it != send_streams_.end(); - ++it) { + it != send_streams_.end(); ++it) { it->second->Stop(); } } @@ -1906,7 +1897,7 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::DisconnectCapturer() { return true; } -const std::vector& +const std::vector& WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { return ssrcs_; } @@ -2369,7 +2360,7 @@ WebRtcVideoChannel2::WebRtcVideoReceiveStream::~WebRtcVideoReceiveStream() { ClearDecoders(&allocated_decoders_); } -const std::vector& +const std::vector& WebRtcVideoChannel2::WebRtcVideoReceiveStream::GetSsrcs() const { return ssrcs_; } diff --git a/talk/media/webrtc/webrtcvideoengine2.h b/talk/media/webrtc/webrtcvideoengine2.h index 0fc28d16c8..7096135cdd 100644 --- a/talk/media/webrtc/webrtcvideoengine2.h +++ b/talk/media/webrtc/webrtcvideoengine2.h @@ -169,18 +169,19 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, bool SetSendParameters(const VideoSendParameters& params) override; bool SetRecvParameters(const VideoRecvParameters& params) override; bool GetSendCodec(VideoCodec* send_codec) override; - bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) override; + bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) override; bool SetSend(bool send) override; - bool SetVideoSend(uint32 ssrc, bool mute, + bool SetVideoSend(uint32_t ssrc, + bool mute, const VideoOptions* options) override; bool AddSendStream(const StreamParams& sp) override; - bool RemoveSendStream(uint32 ssrc) override; + bool RemoveSendStream(uint32_t ssrc) override; bool AddRecvStream(const StreamParams& sp) override; bool AddRecvStream(const StreamParams& sp, bool default_stream); - bool RemoveRecvStream(uint32 ssrc) override; - bool SetRenderer(uint32 ssrc, VideoRenderer* renderer) override; + bool RemoveRecvStream(uint32_t ssrc) override; + bool SetRenderer(uint32_t ssrc, VideoRenderer* renderer) override; bool GetStats(VideoMediaInfo* info) override; - bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) override; + bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) override; bool SendIntraFrame() override; bool RequestIntraFrame() override; @@ -198,11 +199,11 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, // Implemented for VideoMediaChannelTest. bool sending() const { return sending_; } - uint32 GetDefaultSendChannelSsrc() { return default_send_ssrc_; } - bool GetRenderer(uint32 ssrc, VideoRenderer** renderer); + uint32_t GetDefaultSendChannelSsrc() { return default_send_ssrc_; } + bool GetRenderer(uint32_t ssrc, VideoRenderer** renderer); private: - bool MuteStream(uint32 ssrc, bool mute); + bool MuteStream(uint32_t ssrc, bool mute); class WebRtcVideoReceiveStream; bool SetSendCodecs(const std::vector& codecs); @@ -269,7 +270,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, void Start(); void Stop(); - const std::vector& GetSsrcs() const; + const std::vector& GetSsrcs() const; VideoSenderInfo GetVideoSenderInfo(); void FillBandwidthEstimationInfo(BandwidthEstimationInfo* bwe_info); @@ -355,7 +356,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, void SetDimensions(int width, int height, bool is_screencast) EXCLUSIVE_LOCKS_REQUIRED(lock_); - const std::vector ssrcs_; + const std::vector ssrcs_; const std::vector ssrc_groups_; webrtc::Call* const call_; WebRtcVideoEncoderFactory* const external_encoder_factory_ @@ -397,7 +398,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, const std::vector& recv_codecs); ~WebRtcVideoReceiveStream(); - const std::vector& GetSsrcs() const; + const std::vector& GetSsrcs() const; void SetLocalSsrc(uint32_t local_ssrc); void SetNackAndRemb(bool nack_enabled, bool remb_enabled); @@ -437,7 +438,7 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, std::string GetCodecNameFromPayloadType(int payload_type); webrtc::Call* const call_; - const std::vector ssrcs_; + const std::vector ssrcs_; const std::vector ssrc_groups_; webrtc::VideoReceiveStream* stream_; @@ -500,16 +501,16 @@ class WebRtcVideoChannel2 : public rtc::MessageHandler, // lock-order inversions. rtc::CriticalSection capturer_crit_; bool signal_cpu_adaptation_ GUARDED_BY(capturer_crit_); - std::map capturers_ GUARDED_BY(capturer_crit_); + std::map capturers_ GUARDED_BY(capturer_crit_); rtc::CriticalSection stream_crit_; // Using primary-ssrc (first ssrc) as key. - std::map send_streams_ + std::map send_streams_ GUARDED_BY(stream_crit_); - std::map receive_streams_ + std::map receive_streams_ GUARDED_BY(stream_crit_); - std::set send_ssrcs_ GUARDED_BY(stream_crit_); - std::set receive_ssrcs_ GUARDED_BY(stream_crit_); + std::set send_ssrcs_ GUARDED_BY(stream_crit_); + std::set receive_ssrcs_ GUARDED_BY(stream_crit_); Settable send_codec_; std::vector send_rtp_extensions_; diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc index 63130b023e..5dab1d6f15 100644 --- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc +++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc @@ -59,10 +59,10 @@ static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0, 0); static const uint8_t kRedRtxPayloadType = 125; -static const uint32 kSsrcs1[] = {1}; -static const uint32 kSsrcs3[] = {1, 2, 3}; -static const uint32 kRtxSsrcs1[] = {4}; -static const uint32 kIncomingUnsignalledSsrc = 0xC0FFEE; +static const uint32_t kSsrcs1[] = {1}; +static const uint32_t kSsrcs3[] = {1, 2, 3}; +static const uint32_t kRtxSsrcs1[] = {4}; +static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; static const char kUnsupportedExtensionName[] = "urn:ietf:params:rtp-hdrext:unsupported"; @@ -487,7 +487,7 @@ TEST_F(WebRtcVideoEngine2Test, frame.width = 1280; frame.height = 720; frame.fourcc = cricket::FOURCC_I420; - frame.data_size = static_cast( + frame.data_size = static_cast( cricket::VideoFrame::SizeOf(frame.width, frame.height)); rtc::scoped_ptr data(new char[frame.data_size]); frame.data = data.get(); @@ -559,7 +559,7 @@ TEST_F(WebRtcVideoEngine2Test, UsesSimulcastAdapterForVp8Factories) { rtc::scoped_ptr channel( SetUpForExternalEncoderFactory(&encoder_factory, codecs)); - std::vector ssrcs = MAKE_VECTOR(kSsrcs3); + std::vector ssrcs = MAKE_VECTOR(kSsrcs3); EXPECT_TRUE( channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); @@ -637,7 +637,7 @@ TEST_F(WebRtcVideoEngine2Test, rtc::scoped_ptr channel( SetUpForExternalEncoderFactory(&encoder_factory, codecs)); - std::vector ssrcs = MAKE_VECTOR(kSsrcs3); + std::vector ssrcs = MAKE_VECTOR(kSsrcs3); EXPECT_TRUE( channel->AddSendStream(CreateSimStreamParams("cname", ssrcs))); @@ -693,7 +693,7 @@ TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) { rtc::scoped_ptr channel( SetUpForExternalEncoderFactory(&encoder_factory, codecs)); - const std::vector ssrcs = MAKE_VECTOR(kSsrcs3); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs3); EXPECT_TRUE( channel->AddSendStream(cricket::CreateSimStreamParams("cname", ssrcs))); // Set the stream to 720p. This should trigger a "real" encoder @@ -1075,11 +1075,11 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test { rtc::scoped_ptr channel_; cricket::VideoSendParameters send_parameters_; cricket::VideoRecvParameters recv_parameters_; - uint32 last_ssrc_; + uint32_t last_ssrc_; }; TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { - const uint32 kVideoSsrc = 123; + const uint32_t kVideoSsrc = 123; const std::string kSyncLabel = "AvSyncLabel"; cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kVideoSsrc); @@ -1101,8 +1101,8 @@ TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { EXPECT_TRUE(channel_->SetSendParameters(parameters)); // Send side. - const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); - const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); + const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); FakeVideoSendStream* send_stream = AddSendStream( cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); @@ -1849,8 +1849,8 @@ TEST_F(WebRtcVideoChannel2Test, SetDefaultSendCodecs) { EXPECT_TRUE(codec.Matches(engine_.codecs()[0])); // Using a RTX setup to verify that the default RTX payload type is good. - const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); - const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); + const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); FakeVideoSendStream* stream = AddSendStream( cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); webrtc::VideoSendStream::Config config = stream->GetConfig(); @@ -2571,8 +2571,8 @@ TEST_F(WebRtcVideoChannel2Test, TranslatesSenderBitrateStatsCorrectly) { TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); - const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); - const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); + const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); ASSERT_EQ(0u, fake_call_->GetVideoReceiveStreams().size()); const size_t kDataLength = 12; @@ -2602,8 +2602,8 @@ TEST_F(WebRtcVideoChannel2Test, DefaultReceiveStreamReconfiguresToUseRtx) { TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); - const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); - const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); + const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); StreamParams sp = cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); @@ -2616,8 +2616,8 @@ TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithMissingSsrcsForRtx) { TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); - const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); - const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); + const std::vector ssrcs = MAKE_VECTOR(kSsrcs1); + const std::vector rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); StreamParams sp = cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs); @@ -2640,8 +2640,8 @@ TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingRtxSsrcs) { TEST_F(WebRtcVideoChannel2Test, RejectsAddingStreamsWithOverlappingSimulcastSsrcs) { - static const uint32 kFirstStreamSsrcs[] = {1, 2, 3}; - static const uint32 kOverlappingStreamSsrcs[] = {4, 3, 5}; + static const uint32_t kFirstStreamSsrcs[] = {1, 2, 3}; + static const uint32_t kOverlappingStreamSsrcs[] = {4, 3, 5}; EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); StreamParams sp = @@ -2967,7 +2967,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { parameters.codecs.push_back(codec); ASSERT_TRUE(channel_->SetSendParameters(parameters)); - std::vector ssrcs = MAKE_VECTOR(kSsrcs3); + std::vector ssrcs = MAKE_VECTOR(kSsrcs3); RTC_DCHECK(num_configured_streams <= ssrcs.size()); ssrcs.resize(num_configured_streams); @@ -3076,7 +3076,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test { FakeCall fake_call_; WebRtcVideoEngine2 engine_; rtc::scoped_ptr channel_; - uint32 last_ssrc_; + uint32_t last_ssrc_; }; TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { diff --git a/talk/media/webrtc/webrtcvideoframe.cc b/talk/media/webrtc/webrtcvideoframe.cc index 2bc97d9500..7da7e3b7fb 100644 --- a/talk/media/webrtc/webrtcvideoframe.cc +++ b/talk/media/webrtc/webrtcvideoframe.cc @@ -69,12 +69,12 @@ WebRtcVideoFrame::WebRtcVideoFrame( WebRtcVideoFrame::~WebRtcVideoFrame() {} -bool WebRtcVideoFrame::Init(uint32 format, +bool WebRtcVideoFrame::Init(uint32_t format, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, @@ -88,11 +88,9 @@ bool WebRtcVideoFrame::Init(uint32 format, bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation) { return Reset(frame->fourcc, frame->width, frame->height, dw, dh, - static_cast(frame->data), frame->data_size, - frame->pixel_width, frame->pixel_height, - frame->time_stamp, - frame->GetRotation(), - apply_rotation); + static_cast(frame->data), frame->data_size, + frame->pixel_width, frame->pixel_height, frame->time_stamp, + frame->GetRotation(), apply_rotation); } bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, @@ -115,42 +113,42 @@ size_t WebRtcVideoFrame::GetHeight() const { return video_frame_buffer_ ? video_frame_buffer_->height() : 0; } -const uint8* WebRtcVideoFrame::GetYPlane() const { +const uint8_t* WebRtcVideoFrame::GetYPlane() const { return video_frame_buffer_ ? video_frame_buffer_->data(kYPlane) : nullptr; } -const uint8* WebRtcVideoFrame::GetUPlane() const { +const uint8_t* WebRtcVideoFrame::GetUPlane() const { return video_frame_buffer_ ? video_frame_buffer_->data(kUPlane) : nullptr; } -const uint8* WebRtcVideoFrame::GetVPlane() const { +const uint8_t* WebRtcVideoFrame::GetVPlane() const { return video_frame_buffer_ ? video_frame_buffer_->data(kVPlane) : nullptr; } -uint8* WebRtcVideoFrame::GetYPlane() { +uint8_t* WebRtcVideoFrame::GetYPlane() { return video_frame_buffer_ ? video_frame_buffer_->MutableData(kYPlane) : nullptr; } -uint8* WebRtcVideoFrame::GetUPlane() { +uint8_t* WebRtcVideoFrame::GetUPlane() { return video_frame_buffer_ ? video_frame_buffer_->MutableData(kUPlane) : nullptr; } -uint8* WebRtcVideoFrame::GetVPlane() { +uint8_t* WebRtcVideoFrame::GetVPlane() { return video_frame_buffer_ ? video_frame_buffer_->MutableData(kVPlane) : nullptr; } -int32 WebRtcVideoFrame::GetYPitch() const { +int32_t WebRtcVideoFrame::GetYPitch() const { return video_frame_buffer_ ? video_frame_buffer_->stride(kYPlane) : 0; } -int32 WebRtcVideoFrame::GetUPitch() const { +int32_t WebRtcVideoFrame::GetUPitch() const { return video_frame_buffer_ ? video_frame_buffer_->stride(kUPlane) : 0; } -int32 WebRtcVideoFrame::GetVPitch() const { +int32_t WebRtcVideoFrame::GetVPitch() const { return video_frame_buffer_ ? video_frame_buffer_->stride(kVPlane) : 0; } @@ -199,19 +197,21 @@ bool WebRtcVideoFrame::MakeExclusive() { return true; } -size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, - size_t size, int stride_rgb) const { +size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, + uint8_t* buffer, + size_t size, + int stride_rgb) const { RTC_CHECK(video_frame_buffer_); RTC_CHECK(video_frame_buffer_->native_handle() == nullptr); return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); } -bool WebRtcVideoFrame::Reset(uint32 format, +bool WebRtcVideoFrame::Reset(uint32_t format, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, diff --git a/talk/media/webrtc/webrtcvideoframe.h b/talk/media/webrtc/webrtcvideoframe.h index f173c96908..abc238f1fc 100644 --- a/talk/media/webrtc/webrtcvideoframe.h +++ b/talk/media/webrtc/webrtcvideoframe.h @@ -57,12 +57,12 @@ class WebRtcVideoFrame : public VideoFrame { // "h" can be negative indicating a vertically flipped image. // "dh" is destination height if cropping is desired and is always positive. // Returns "true" if successful. - bool Init(uint32 format, + bool Init(uint32_t format, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, @@ -82,12 +82,12 @@ class WebRtcVideoFrame : public VideoFrame { int64_t time_stamp_ns); // From base class VideoFrame. - virtual bool Reset(uint32 format, + virtual bool Reset(uint32_t format, int w, int h, int dw, int dh, - uint8* sample, + uint8_t* sample, size_t sample_size, size_t pixel_width, size_t pixel_height, @@ -97,15 +97,15 @@ class WebRtcVideoFrame : public VideoFrame { virtual size_t GetWidth() const; virtual size_t GetHeight() const; - virtual const uint8* GetYPlane() const; - virtual const uint8* GetUPlane() const; - virtual const uint8* GetVPlane() const; - virtual uint8* GetYPlane(); - virtual uint8* GetUPlane(); - virtual uint8* GetVPlane(); - virtual int32 GetYPitch() const; - virtual int32 GetUPitch() const; - virtual int32 GetVPitch() const; + virtual const uint8_t* GetYPlane() const; + virtual const uint8_t* GetUPlane() const; + virtual const uint8_t* GetVPlane() const; + virtual uint8_t* GetYPlane(); + virtual uint8_t* GetUPlane(); + virtual uint8_t* GetVPlane(); + virtual int32_t GetYPitch() const; + virtual int32_t GetUPitch() const; + virtual int32_t GetVPitch() const; virtual void* GetNativeHandle() const; virtual rtc::scoped_refptr GetVideoFrameBuffer() const; @@ -122,8 +122,10 @@ class WebRtcVideoFrame : public VideoFrame { virtual VideoFrame* Copy() const; virtual bool IsExclusive() const; virtual bool MakeExclusive(); - virtual size_t ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, - size_t size, int stride_rgb) const; + virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, + uint8_t* buffer, + size_t size, + int stride_rgb) const; const VideoFrame* GetCopyWithRotationApplied() const override; diff --git a/talk/media/webrtc/webrtcvideoframe_unittest.cc b/talk/media/webrtc/webrtcvideoframe_unittest.cc index 6868c2c4b3..8388f07ba0 100644 --- a/talk/media/webrtc/webrtcvideoframe_unittest.cc +++ b/talk/media/webrtc/webrtcvideoframe_unittest.cc @@ -72,8 +72,8 @@ class WebRtcVideoFrameTest : public VideoFrameTest { captured_frame.height = frame_height; captured_frame.data_size = (frame_width * frame_height) + ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; - rtc::scoped_ptr captured_frame_buffer( - new uint8[captured_frame.data_size]); + rtc::scoped_ptr captured_frame_buffer( + new uint8_t[captured_frame.data_size]); // Initialize memory to satisfy DrMemory tests. memset(captured_frame_buffer.get(), 0, captured_frame.data_size); captured_frame.data = captured_frame_buffer.get(); diff --git a/talk/media/webrtc/webrtcvideoframefactory_unittest.cc b/talk/media/webrtc/webrtcvideoframefactory_unittest.cc index 00c13b5a1d..a9c102264f 100644 --- a/talk/media/webrtc/webrtcvideoframefactory_unittest.cc +++ b/talk/media/webrtc/webrtcvideoframefactory_unittest.cc @@ -51,7 +51,7 @@ class WebRtcVideoFrameFactoryTest captured_frame_.data_size = (frame_width * frame_height) + ((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2; - captured_frame_buffer_.reset(new uint8[captured_frame_.data_size]); + captured_frame_buffer_.reset(new uint8_t[captured_frame_.data_size]); // Initialize memory to satisfy DrMemory tests. memset(captured_frame_buffer_.get(), 0, captured_frame_.data_size); captured_frame_.data = captured_frame_buffer_.get(); @@ -111,7 +111,7 @@ class WebRtcVideoFrameFactoryTest private: cricket::CapturedFrame captured_frame_; - rtc::scoped_ptr captured_frame_buffer_; + rtc::scoped_ptr captured_frame_buffer_; cricket::WebRtcVideoFrameFactory factory_; }; diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index 05b98ec154..54fac221d8 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -845,7 +845,7 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { audioproc->SetExtraOptions(config); } - uint32 recording_sample_rate; + uint32_t recording_sample_rate; if (options.recording_sample_rate.Get(&recording_sample_rate)) { LOG(LS_INFO) << "Recording sample rate is " << recording_sample_rate; if (voe_wrapper_->hw()->SetRecordingSampleRate(recording_sample_rate)) { @@ -853,7 +853,7 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { } } - uint32 playout_sample_rate; + uint32_t playout_sample_rate; if (options.playout_sample_rate.Get(&playout_sample_rate)) { LOG(LS_INFO) << "Playout sample rate is " << playout_sample_rate; if (voe_wrapper_->hw()->SetPlayoutSampleRate(playout_sample_rate)) { @@ -2066,7 +2066,8 @@ bool WebRtcVoiceMediaChannel::ChangeSend(int channel, SendFlags send) { return true; } -bool WebRtcVoiceMediaChannel::SetAudioSend(uint32 ssrc, bool enable, +bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, + bool enable, const AudioOptions* options, AudioRenderer* renderer) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); @@ -2190,7 +2191,7 @@ bool WebRtcVoiceMediaChannel::AddSendStream(const StreamParams& sp) { return ChangeSend(channel, desired_send_); } -bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32 ssrc) { +bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { ChannelMap::iterator it = send_channels_.find(ssrc); if (it == send_channels_.end()) { LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc @@ -2232,7 +2233,7 @@ bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { if (!VERIFY(sp.ssrcs.size() == 1)) return false; - uint32 ssrc = sp.first_ssrc(); + uint32_t ssrc = sp.first_ssrc(); if (ssrc == 0) { LOG(LS_WARNING) << "AddRecvStream with 0 ssrc is not supported."; @@ -2357,7 +2358,7 @@ bool WebRtcVoiceMediaChannel::ConfigureRecvChannel(int channel) { return SetPlayout(channel, playout_); } -bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { +bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; @@ -2417,7 +2418,7 @@ bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32 ssrc) { return true; } -bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32 ssrc, +bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); ChannelMap::iterator it = receive_channels_.find(ssrc); @@ -2440,7 +2441,7 @@ bool WebRtcVoiceMediaChannel::SetRemoteRenderer(uint32 ssrc, return true; } -bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32 ssrc, +bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) { ChannelMap::iterator it = send_channels_.find(ssrc); if (it == send_channels_.end()) { @@ -2513,8 +2514,9 @@ void WebRtcVoiceMediaChannel::SetTypingDetectionParameters(int time_window, } } -bool WebRtcVoiceMediaChannel::SetOutputScaling( - uint32 ssrc, double left, double right) { +bool WebRtcVoiceMediaChannel::SetOutputScaling(uint32_t ssrc, + double left, + double right) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); rtc::CritScope lock(&receive_channels_cs_); // Collect the channels to scale the output volume. @@ -2566,8 +2568,10 @@ bool WebRtcVoiceMediaChannel::CanInsertDtmf() { return dtmf_allowed_; } -bool WebRtcVoiceMediaChannel::InsertDtmf(uint32 ssrc, int event, - int duration, int flags) { +bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, + int event, + int duration, + int flags) { if (!dtmf_allowed_) { return false; } @@ -2691,7 +2695,7 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived( } } -bool WebRtcVoiceMediaChannel::MuteStream(uint32 ssrc, bool muted) { +bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { int channel = (ssrc == 0) ? voe_channel() : GetSendChannelId(ssrc); if (channel == -1) { LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; @@ -2981,7 +2985,7 @@ int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) { return (ret == 0) ? static_cast(ulevel) : -1; } -int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32 ssrc) const { +int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { RTC_DCHECK(thread_checker_.CalledOnValidThread()); ChannelMap::const_iterator it = receive_channels_.find(ssrc); if (it != receive_channels_.end()) @@ -2989,7 +2993,7 @@ int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32 ssrc) const { return (ssrc == default_receive_ssrc_) ? voe_channel() : -1; } -int WebRtcVoiceMediaChannel::GetSendChannelId(uint32 ssrc) const { +int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { RTC_DCHECK(thread_checker_.CalledOnValidThread()); ChannelMap::const_iterator it = send_channels_.find(ssrc); if (it != send_channels_.end()) @@ -3084,10 +3088,11 @@ bool WebRtcVoiceMediaChannel::SetPlayout(int channel, bool playout) { return true; } -uint32 WebRtcVoiceMediaChannel::ParseSsrc(const void* data, size_t len, - bool rtcp) { +uint32_t WebRtcVoiceMediaChannel::ParseSsrc(const void* data, + size_t len, + bool rtcp) { size_t ssrc_pos = (!rtcp) ? 8 : 4; - uint32 ssrc = 0; + uint32_t ssrc = 0; if (len >= (ssrc_pos + sizeof(ssrc))) { ssrc = rtc::GetBE32(static_cast(data) + ssrc_pos); } @@ -3154,7 +3159,7 @@ void WebRtcVoiceMediaChannel::RecreateAudioReceiveStreams() { } } -void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { +void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32_t ssrc) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); WebRtcVoiceChannelRenderer* channel = receive_channels_[ssrc]; RTC_DCHECK(channel != nullptr); @@ -3171,7 +3176,7 @@ void WebRtcVoiceMediaChannel::AddAudioReceiveStream(uint32 ssrc) { receive_streams_.insert(std::make_pair(ssrc, s)); } -void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32 ssrc) { +void WebRtcVoiceMediaChannel::RemoveAudioReceiveStream(uint32_t ssrc) { RTC_DCHECK(thread_checker_.CalledOnValidThread()); auto stream_it = receive_streams_.find(ssrc); if (stream_it != receive_streams_.end()) { diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h index 61dc7b16e1..269920523f 100644 --- a/talk/media/webrtc/webrtcvoiceengine.h +++ b/talk/media/webrtc/webrtcvoiceengine.h @@ -192,13 +192,15 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, bool SetSend(SendFlags send) override; bool PauseSend(); bool ResumeSend(); - bool SetAudioSend(uint32 ssrc, bool enable, const AudioOptions* options, + bool SetAudioSend(uint32_t ssrc, + bool enable, + const AudioOptions* options, AudioRenderer* renderer) override; bool AddSendStream(const StreamParams& sp) override; - bool RemoveSendStream(uint32 ssrc) override; + bool RemoveSendStream(uint32_t ssrc) override; bool AddRecvStream(const StreamParams& sp) override; - bool RemoveRecvStream(uint32 ssrc) override; - bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) override; + bool RemoveRecvStream(uint32_t ssrc) override; + bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) override; bool GetActiveStreams(AudioInfo::StreamList* actives) override; int GetOutputLevel() override; int GetTimeSinceLastTyping() override; @@ -207,10 +209,10 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, int reporting_threshold, int penalty_decay, int type_event_delay) override; - bool SetOutputScaling(uint32 ssrc, double left, double right) override; + bool SetOutputScaling(uint32_t ssrc, double left, double right) override; bool CanInsertDtmf() override; - bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override; + bool InsertDtmf(uint32_t ssrc, int event, int duration, int flags) override; void OnPacketReceived(rtc::Buffer* packet, const rtc::PacketTime& packet_time) override; @@ -236,8 +238,8 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, void OnError(int error); - int GetReceiveChannelId(uint32 ssrc) const; - int GetSendChannelId(uint32 ssrc) const; + int GetReceiveChannelId(uint32_t ssrc) const; + int GetSendChannelId(uint32_t ssrc) const; private: bool SetSendCodecs(const std::vector& codecs); @@ -248,8 +250,8 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, bool SetRecvCodecs(const std::vector& codecs); bool SetRecvRtpHeaderExtensions( const std::vector& extensions); - bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer); - bool MuteStream(uint32 ssrc, bool mute); + bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer); + bool MuteStream(uint32_t ssrc, bool mute); WebRtcVoiceEngine* engine() { return engine_; } int GetLastEngineError() { return engine()->GetLastEngineError(); } @@ -260,14 +262,14 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, bool EnableRtcp(int channel); bool ResetRecvCodecs(int channel); bool SetPlayout(int channel, bool playout); - static uint32 ParseSsrc(const void* data, size_t len, bool rtcp); + static uint32_t ParseSsrc(const void* data, size_t len, bool rtcp); static Error WebRtcErrorToChannelError(int err_code); class WebRtcVoiceChannelRenderer; // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of // WebRtcVoiceChannelRenderer will be created for every new stream and // will be destroyed when the stream goes away. - typedef std::map ChannelMap; + typedef std::map ChannelMap; typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool, unsigned char); @@ -293,8 +295,8 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id, const RtpHeaderExtension* extension); void RecreateAudioReceiveStreams(); - void AddAudioReceiveStream(uint32 ssrc); - void RemoveAudioReceiveStream(uint32 ssrc); + void AddAudioReceiveStream(uint32_t ssrc); + void RemoveAudioReceiveStream(uint32_t ssrc); bool SetRecvCodecsInternal(const std::vector& new_codecs); bool SetChannelRecvRtpHeaderExtensions( @@ -328,13 +330,13 @@ class WebRtcVoiceMediaChannel : public VoiceMediaChannel, // contained in send_channels_, otherwise not. ChannelMap send_channels_; std::vector send_extensions_; - uint32 default_receive_ssrc_; + uint32_t default_receive_ssrc_; // Note the default channel (voe_channel()) can reside in both // receive_channels_ and send_channels_ in non-conference mode and in that // case it will only be there if a non-zero default_receive_ssrc_ is set. ChannelMap receive_channels_; // for multiple sources - std::map receive_streams_; - std::map receive_stream_params_; + std::map receive_streams_; + std::map receive_stream_params_; // receive_channels_ can be read from WebRtc callback thread. Access from // the WebRtc thread must be synchronized with edits on the worker thread. // Reads on the worker thread are ok. diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc index 8a03b24209..70318d14f7 100644 --- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc +++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc @@ -57,8 +57,8 @@ static const cricket::AudioCodec* const kAudioCodecs[] = { &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, }; -static uint32 kSsrc1 = 0x99; -static uint32 kSsrc2 = 0x98; +static uint32_t kSsrc1 = 0x99; +static uint32_t kSsrc2 = 0x98; class FakeVoEWrapper : public cricket::VoEWrapper { public: @@ -118,7 +118,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { EXPECT_TRUE(SetupEngine()); // Remove stream added in Setup, which is corresponding to default channel. int default_channel_num = voe_.GetLastChannel(); - uint32 default_send_ssrc = 0u; + uint32_t default_send_ssrc = 0u; EXPECT_EQ(0, voe_.GetLocalSSRC(default_channel_num, default_send_ssrc)); EXPECT_EQ(kSsrc1, default_send_ssrc); EXPECT_TRUE(channel_->RemoveSendStream(default_send_ssrc)); @@ -135,7 +135,7 @@ class WebRtcVoiceEngineTestFake : public testing::Test { engine_.Terminate(); } - void TestInsertDtmf(uint32 ssrc, bool caller) { + void TestInsertDtmf(uint32_t ssrc, bool caller) { EXPECT_TRUE(engine_.Init(rtc::Thread::Current())); channel_ = engine_.CreateChannel(&call_, cricket::AudioOptions()); EXPECT_TRUE(channel_ != nullptr); @@ -1863,7 +1863,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SendAndPlayout) { TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { SetupForMultiSendStream(); - static const uint32 kSsrcs4[] = {1, 2, 3, 4}; + static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; // Set the global state for sending. EXPECT_TRUE(channel_->SetSend(cricket::SEND_MICROPHONE)); @@ -1898,7 +1898,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CreateAndDeleteMultipleSendStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { SetupForMultiSendStream(); - static const uint32 kSsrcs4[] = {1, 2, 3, 4}; + static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; // Create send streams. for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { EXPECT_TRUE(channel_->AddSendStream( @@ -1937,7 +1937,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendCodecsWithMultipleSendStreams) { TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { SetupForMultiSendStream(); - static const uint32 kSsrcs4[] = {1, 2, 3, 4}; + static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; // Create the send channels and they should be a SEND_NOTHING date. for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { EXPECT_TRUE(channel_->AddSendStream( @@ -1967,7 +1967,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetSendWithMultipleSendStreams) { TEST_F(WebRtcVoiceEngineTestFake, GetStatsWithMultipleSendStreams) { SetupForMultiSendStream(); - static const uint32 kSsrcs4[] = {1, 2, 3, 4}; + static const uint32_t kSsrcs4[] = {1, 2, 3, 4}; // Create send streams. for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { EXPECT_TRUE(channel_->AddSendStream( @@ -2391,7 +2391,7 @@ TEST_F(WebRtcVoiceEngineTestFake, RecvWithMultipleStreams) { char packets[4][sizeof(kPcmuFrame)]; for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) { memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame)); - rtc::SetBE32(packets[i] + 8, static_cast(i)); + rtc::SetBE32(packets[i] + 8, static_cast(i)); } EXPECT_TRUE(voe_.CheckNoPacket(channel_num1)); EXPECT_TRUE(voe_.CheckNoPacket(channel_num2)); @@ -2921,7 +2921,7 @@ TEST_F(WebRtcVoiceEngineTestFake, SetOutputScaling) { } TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { - const uint32 kAudioSsrc = 123; + const uint32_t kAudioSsrc = 123; const std::string kSyncLabel = "AvSyncLabel"; EXPECT_TRUE(SetupEngine()); @@ -2945,21 +2945,21 @@ TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { // Test that changing the combined_audio_video_bwe option results in the // expected state changes on an associated Call. - std::vector ssrcs; + std::vector ssrcs; ssrcs.push_back(223); ssrcs.push_back(224); EXPECT_TRUE(SetupEngine()); cricket::WebRtcVoiceMediaChannel* media_channel = static_cast(channel_); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { EXPECT_TRUE(media_channel->AddRecvStream( cricket::StreamParams::CreateLegacy(ssrc))); } EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); // Combined BWE should be disabled. - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); @@ -2968,7 +2968,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { // Enable combined BWE option - now it should be set up. send_parameters_.options.combined_audio_video_bwe.Set(true); EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); EXPECT_EQ(true, s->GetConfig().combined_audio_video_bwe); @@ -2977,7 +2977,7 @@ TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { // Disable combined BWE option - should be disabled again. send_parameters_.options.combined_audio_video_bwe.Set(false); EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); EXPECT_EQ(false, s->GetConfig().combined_audio_video_bwe); @@ -2995,7 +2995,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { send_parameters_.options.combined_audio_video_bwe.Set(true); EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); - static const uint32 kSsrcs[] = {1, 2, 3, 4}; + static const uint32_t kSsrcs[] = {1, 2, 3, 4}; for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { EXPECT_TRUE(media_channel->AddRecvStream( cricket::StreamParams::CreateLegacy(kSsrcs[i]))); @@ -3007,7 +3007,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { // Test that setting the header extensions results in the expected state // changes on an associated Call. - std::vector ssrcs; + std::vector ssrcs; ssrcs.push_back(223); ssrcs.push_back(224); @@ -3016,14 +3016,14 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { static_cast(channel_); send_parameters_.options.combined_audio_video_bwe.Set(true); EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_)); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { EXPECT_TRUE(media_channel->AddRecvStream( cricket::StreamParams::CreateLegacy(ssrc))); } // Combined BWE should be set up, but with no configured extensions. EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); @@ -3035,7 +3035,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { recv_parameters.extensions = e_exts; channel_->SetRecvParameters(recv_parameters); EXPECT_EQ(2, call_.GetAudioReceiveStreams().size()); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); const auto& s_exts = s->GetConfig().rtp.extensions; @@ -3051,7 +3051,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { // Disable receive extensions. channel_->SetRecvParameters(cricket::AudioRecvParameters()); - for (uint32 ssrc : ssrcs) { + for (uint32_t ssrc : ssrcs) { const auto* s = call_.GetAudioReceiveStream(ssrc); EXPECT_NE(nullptr, s); EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); @@ -3060,7 +3060,7 @@ TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { // Test that packets are forwarded to the Call when configured accordingly. - const uint32 kAudioSsrc = 1; + const uint32_t kAudioSsrc = 1; rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); static const unsigned char kRtcp[] = { 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, diff --git a/talk/session/media/audiomonitor.cc b/talk/session/media/audiomonitor.cc index aa4a87dd31..bdb71cb2f6 100644 --- a/talk/session/media/audiomonitor.cc +++ b/talk/session/media/audiomonitor.cc @@ -31,10 +31,10 @@ namespace cricket { -const uint32 MSG_MONITOR_POLL = 1; -const uint32 MSG_MONITOR_START = 2; -const uint32 MSG_MONITOR_STOP = 3; -const uint32 MSG_MONITOR_SIGNAL = 4; +const uint32_t MSG_MONITOR_POLL = 1; +const uint32_t MSG_MONITOR_START = 2; +const uint32_t MSG_MONITOR_STOP = 3; +const uint32_t MSG_MONITOR_SIGNAL = 4; AudioMonitor::AudioMonitor(VoiceChannel *voice_channel, rtc::Thread *monitor_thread) { diff --git a/talk/session/media/audiomonitor.h b/talk/session/media/audiomonitor.h index 454f0fe013..3723419d6e 100644 --- a/talk/session/media/audiomonitor.h +++ b/talk/session/media/audiomonitor.h @@ -40,7 +40,7 @@ class VoiceChannel; struct AudioInfo { int input_level; int output_level; - typedef std::vector > StreamList; + typedef std::vector > StreamList; StreamList active_streams; // ssrcs contributing to output_level }; @@ -66,7 +66,7 @@ class AudioMonitor : public rtc::MessageHandler, VoiceChannel* voice_channel_; rtc::Thread* monitoring_thread_; rtc::CriticalSection crit_; - uint32 rate_; + uint32_t rate_; bool monitoring_; }; diff --git a/talk/session/media/bundlefilter.cc b/talk/session/media/bundlefilter.cc index cd02a19174..b47d47fb27 100755 --- a/talk/session/media/bundlefilter.cc +++ b/talk/session/media/bundlefilter.cc @@ -32,7 +32,7 @@ namespace cricket { -static const uint32 kSsrc01 = 0x01; +static const uint32_t kSsrc01 = 0x01; BundleFilter::BundleFilter() { } @@ -60,7 +60,7 @@ bool BundleFilter::DemuxPacket(const char* data, size_t len, bool rtcp) { // Rtcp packets using ssrc filter. int pl_type = 0; - uint32 ssrc = 0; + uint32_t ssrc = 0; if (!GetRtcpType(data, len, &pl_type)) return false; if (pl_type == kRtcpTypeSDES) { // SDES packet parsing not supported. @@ -92,7 +92,7 @@ bool BundleFilter::AddStream(const StreamParams& stream) { return true; } -bool BundleFilter::RemoveStream(uint32 ssrc) { +bool BundleFilter::RemoveStream(uint32_t ssrc) { return RemoveStreamBySsrc(&streams_, ssrc); } @@ -100,7 +100,7 @@ bool BundleFilter::HasStreams() const { return !streams_.empty(); } -bool BundleFilter::FindStream(uint32 ssrc) const { +bool BundleFilter::FindStream(uint32_t ssrc) const { return ssrc == 0 ? false : GetStreamBySsrc(streams_, ssrc) != nullptr; } diff --git a/talk/session/media/bundlefilter.h b/talk/session/media/bundlefilter.h index a4980412f0..3717376668 100755 --- a/talk/session/media/bundlefilter.h +++ b/talk/session/media/bundlefilter.h @@ -60,12 +60,12 @@ class BundleFilter { bool AddStream(const StreamParams& stream); // Removes source from the filter. - bool RemoveStream(uint32 ssrc); + bool RemoveStream(uint32_t ssrc); // Utility methods added for unitest. // True if |streams_| is not empty. bool HasStreams() const; - bool FindStream(uint32 ssrc) const; + bool FindStream(uint32_t ssrc) const; bool FindPayloadType(int pl_type) const; void ClearAllPayloadTypes(); diff --git a/talk/session/media/channel.cc b/talk/session/media/channel.cc index fc998c2531..57d09a2d6f 100644 --- a/talk/session/media/channel.cc +++ b/talk/session/media/channel.cc @@ -71,49 +71,41 @@ struct PacketMessageData : public rtc::MessageData { }; struct ScreencastEventMessageData : public rtc::MessageData { - ScreencastEventMessageData(uint32 s, rtc::WindowEvent we) - : ssrc(s), - event(we) { - } - uint32 ssrc; + ScreencastEventMessageData(uint32_t s, rtc::WindowEvent we) + : ssrc(s), event(we) {} + uint32_t ssrc; rtc::WindowEvent event; }; struct VoiceChannelErrorMessageData : public rtc::MessageData { - VoiceChannelErrorMessageData(uint32 in_ssrc, + VoiceChannelErrorMessageData(uint32_t in_ssrc, VoiceMediaChannel::Error in_error) - : ssrc(in_ssrc), - error(in_error) { - } - uint32 ssrc; + : ssrc(in_ssrc), error(in_error) {} + uint32_t ssrc; VoiceMediaChannel::Error error; }; struct VideoChannelErrorMessageData : public rtc::MessageData { - VideoChannelErrorMessageData(uint32 in_ssrc, + VideoChannelErrorMessageData(uint32_t in_ssrc, VideoMediaChannel::Error in_error) - : ssrc(in_ssrc), - error(in_error) { - } - uint32 ssrc; + : ssrc(in_ssrc), error(in_error) {} + uint32_t ssrc; VideoMediaChannel::Error error; }; struct DataChannelErrorMessageData : public rtc::MessageData { - DataChannelErrorMessageData(uint32 in_ssrc, + DataChannelErrorMessageData(uint32_t in_ssrc, DataMediaChannel::Error in_error) - : ssrc(in_ssrc), - error(in_error) {} - uint32 ssrc; + : ssrc(in_ssrc), error(in_error) {} + uint32_t ssrc; DataMediaChannel::Error error; }; struct VideoChannel::ScreencastDetailsData { - explicit ScreencastDetailsData(uint32 s) - : ssrc(s), fps(0), screencast_max_pixels(0) { - } - uint32 ssrc; + explicit ScreencastDetailsData(uint32_t s) + : ssrc(s), fps(0), screencast_max_pixels(0) {} + uint32_t ssrc; int fps; int screencast_max_pixels; }; @@ -365,7 +357,7 @@ bool BaseChannel::AddRecvStream(const StreamParams& sp) { return InvokeOnWorker(Bind(&BaseChannel::AddRecvStream_w, this, sp)); } -bool BaseChannel::RemoveRecvStream(uint32 ssrc) { +bool BaseChannel::RemoveRecvStream(uint32_t ssrc) { return InvokeOnWorker(Bind(&BaseChannel::RemoveRecvStream_w, this, ssrc)); } @@ -374,7 +366,7 @@ bool BaseChannel::AddSendStream(const StreamParams& sp) { Bind(&MediaChannel::AddSendStream, media_channel(), sp)); } -bool BaseChannel::RemoveSendStream(uint32 ssrc) { +bool BaseChannel::RemoveSendStream(uint32_t ssrc) { return InvokeOnWorker( Bind(&MediaChannel::RemoveSendStream, media_channel(), ssrc)); } @@ -566,7 +558,7 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, &options.packet_time_params.srtp_packet_index); // If protection succeeds, let's get auth params from srtp. if (res) { - uint8* auth_key = NULL; + uint8_t* auth_key = NULL; int key_len; res = srtp_filter_.GetRtpAuthParams( &auth_key, &key_len, &options.packet_time_params.srtp_auth_tag_len); @@ -579,7 +571,7 @@ bool BaseChannel::SendPacket(bool rtcp, rtc::Buffer* packet, #endif if (!res) { int seq_num = -1; - uint32 ssrc = 0; + uint32_t ssrc = 0; GetRtpSeqNum(data, len, &seq_num); GetRtpSsrc(data, len, &ssrc); LOG(LS_ERROR) << "Failed to protect " << content_name_ @@ -660,7 +652,7 @@ void BaseChannel::HandlePacket(bool rtcp, rtc::Buffer* packet, res = srtp_filter_.UnprotectRtp(data, len, &len); if (!res) { int seq_num = -1; - uint32 ssrc = 0; + uint32_t ssrc = 0; GetRtpSeqNum(data, len, &seq_num); GetRtpSsrc(data, len, &ssrc); LOG(LS_ERROR) << "Failed to unprotect " << content_name_ @@ -1086,7 +1078,7 @@ bool BaseChannel::AddRecvStream_w(const StreamParams& sp) { return bundle_filter_.AddStream(sp); } -bool BaseChannel::RemoveRecvStream_w(uint32 ssrc) { +bool BaseChannel::RemoveRecvStream_w(uint32_t ssrc) { ASSERT(worker_thread() == rtc::Thread::Current()); bundle_filter_.RemoveStream(ssrc); return media_channel()->RemoveRecvStream(ssrc); @@ -1304,12 +1296,12 @@ bool VoiceChannel::Init() { return true; } -bool VoiceChannel::SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { +bool VoiceChannel::SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) { return InvokeOnWorker(Bind(&VoiceMediaChannel::SetRemoteRenderer, media_channel(), ssrc, renderer)); } -bool VoiceChannel::SetAudioSend(uint32 ssrc, +bool VoiceChannel::SetAudioSend(uint32_t ssrc, bool enable, const AudioOptions* options, AudioRenderer* renderer) { @@ -1347,13 +1339,15 @@ bool VoiceChannel::CanInsertDtmf() { media_channel())); } -bool VoiceChannel::InsertDtmf(uint32 ssrc, int event_code, int duration, +bool VoiceChannel::InsertDtmf(uint32_t ssrc, + int event_code, + int duration, int flags) { return InvokeOnWorker(Bind(&VoiceChannel::InsertDtmf_w, this, ssrc, event_code, duration, flags)); } -bool VoiceChannel::SetOutputScaling(uint32 ssrc, double left, double right) { +bool VoiceChannel::SetOutputScaling(uint32_t ssrc, double left, double right) { return InvokeOnWorker(Bind(&VoiceMediaChannel::SetOutputScaling, media_channel(), ssrc, left, right)); } @@ -1547,7 +1541,9 @@ void VoiceChannel::HandleEarlyMediaTimeout() { } } -bool VoiceChannel::InsertDtmf_w(uint32 ssrc, int event, int duration, +bool VoiceChannel::InsertDtmf_w(uint32_t ssrc, + int event, + int duration, int flags) { if (!enabled()) { return false; @@ -1615,7 +1611,7 @@ bool VideoChannel::Init() { } VideoChannel::~VideoChannel() { - std::vector screencast_ssrcs; + std::vector screencast_ssrcs; ScreencastMap::iterator iter; while (!screencast_capturers_.empty()) { if (!RemoveScreencast(screencast_capturers_.begin()->first)) { @@ -1633,7 +1629,7 @@ VideoChannel::~VideoChannel() { Deinit(); } -bool VideoChannel::SetRenderer(uint32 ssrc, VideoRenderer* renderer) { +bool VideoChannel::SetRenderer(uint32_t ssrc, VideoRenderer* renderer) { worker_thread()->Invoke(Bind( &VideoMediaChannel::SetRenderer, media_channel(), ssrc, renderer)); return true; @@ -1643,17 +1639,17 @@ bool VideoChannel::ApplyViewRequest(const ViewRequest& request) { return InvokeOnWorker(Bind(&VideoChannel::ApplyViewRequest_w, this, request)); } -bool VideoChannel::AddScreencast(uint32 ssrc, VideoCapturer* capturer) { +bool VideoChannel::AddScreencast(uint32_t ssrc, VideoCapturer* capturer) { return worker_thread()->Invoke(Bind( &VideoChannel::AddScreencast_w, this, ssrc, capturer)); } -bool VideoChannel::SetCapturer(uint32 ssrc, VideoCapturer* capturer) { +bool VideoChannel::SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { return InvokeOnWorker(Bind(&VideoMediaChannel::SetCapturer, media_channel(), ssrc, capturer)); } -bool VideoChannel::RemoveScreencast(uint32 ssrc) { +bool VideoChannel::RemoveScreencast(uint32_t ssrc) { return InvokeOnWorker(Bind(&VideoChannel::RemoveScreencast_w, this, ssrc)); } @@ -1661,14 +1657,14 @@ bool VideoChannel::IsScreencasting() { return InvokeOnWorker(Bind(&VideoChannel::IsScreencasting_w, this)); } -int VideoChannel::GetScreencastFps(uint32 ssrc) { +int VideoChannel::GetScreencastFps(uint32_t ssrc) { ScreencastDetailsData data(ssrc); worker_thread()->Invoke(Bind( &VideoChannel::GetScreencastDetails_w, this, &data)); return data.fps; } -int VideoChannel::GetScreencastMaxPixels(uint32 ssrc) { +int VideoChannel::GetScreencastMaxPixels(uint32_t ssrc) { ScreencastDetailsData data(ssrc); worker_thread()->Invoke(Bind( &VideoChannel::GetScreencastDetails_w, this, &data)); @@ -1687,7 +1683,7 @@ bool VideoChannel::RequestIntraFrame() { return true; } -bool VideoChannel::SetVideoSend(uint32 ssrc, +bool VideoChannel::SetVideoSend(uint32_t ssrc, bool mute, const VideoOptions* options) { return InvokeOnWorker(Bind(&VideoMediaChannel::SetVideoSend, media_channel(), @@ -1861,7 +1857,7 @@ bool VideoChannel::ApplyViewRequest_w(const ViewRequest& request) { return ret; } -bool VideoChannel::AddScreencast_w(uint32 ssrc, VideoCapturer* capturer) { +bool VideoChannel::AddScreencast_w(uint32_t ssrc, VideoCapturer* capturer) { if (screencast_capturers_.find(ssrc) != screencast_capturers_.end()) { return false; } @@ -1870,7 +1866,7 @@ bool VideoChannel::AddScreencast_w(uint32 ssrc, VideoCapturer* capturer) { return true; } -bool VideoChannel::RemoveScreencast_w(uint32 ssrc) { +bool VideoChannel::RemoveScreencast_w(uint32_t ssrc) { ScreencastMap::iterator iter = screencast_capturers_.find(ssrc); if (iter == screencast_capturers_.end()) { return false; @@ -1897,7 +1893,7 @@ void VideoChannel::GetScreencastDetails_w( data->screencast_max_pixels = capturer->screencast_max_pixels(); } -void VideoChannel::OnScreencastWindowEvent_s(uint32 ssrc, +void VideoChannel::OnScreencastWindowEvent_s(uint32_t ssrc, rtc::WindowEvent we) { ASSERT(signaling_thread() == rtc::Thread::Current()); SignalScreencastWindowEvent(ssrc, we); @@ -1937,7 +1933,7 @@ void VideoChannel::OnMediaMonitorUpdate( SignalMediaMonitor(this, info); } -void VideoChannel::OnScreencastWindowEvent(uint32 ssrc, +void VideoChannel::OnScreencastWindowEvent(uint32_t ssrc, rtc::WindowEvent event) { ScreencastEventMessageData* pdata = new ScreencastEventMessageData(ssrc, event); @@ -1959,7 +1955,7 @@ void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) { } previous_we_ = we; - uint32 ssrc = 0; + uint32_t ssrc = 0; if (!GetLocalSsrc(capturer, &ssrc)) { return; } @@ -1967,7 +1963,7 @@ void VideoChannel::OnStateChange(VideoCapturer* capturer, CaptureState ev) { OnScreencastWindowEvent(ssrc, we); } -bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32* ssrc) { +bool VideoChannel::GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc) { *ssrc = 0; for (ScreencastMap::iterator iter = screencast_capturers_.begin(); iter != screencast_capturers_.end(); ++iter) { @@ -2226,8 +2222,8 @@ void DataChannel::OnMessage(rtc::Message *pmsg) { break; } case MSG_STREAMCLOSEDREMOTELY: { - rtc::TypedMessageData* data = - static_cast*>(pmsg->pdata); + rtc::TypedMessageData* data = + static_cast*>(pmsg->pdata); SignalStreamClosedRemotely(data->data()); delete data; break; @@ -2272,8 +2268,8 @@ void DataChannel::OnDataReceived( signaling_thread()->Post(this, MSG_DATARECEIVED, msg); } -void DataChannel::OnDataChannelError( - uint32 ssrc, DataMediaChannel::Error err) { +void DataChannel::OnDataChannelError(uint32_t ssrc, + DataMediaChannel::Error err) { DataChannelErrorMessageData* data = new DataChannelErrorMessageData( ssrc, err); signaling_thread()->Post(this, MSG_CHANNEL_ERROR, data); @@ -2296,9 +2292,9 @@ bool DataChannel::ShouldSetupDtlsSrtp() const { return (data_channel_type_ == DCT_RTP); } -void DataChannel::OnStreamClosedRemotely(uint32 sid) { - rtc::TypedMessageData* message = - new rtc::TypedMessageData(sid); +void DataChannel::OnStreamClosedRemotely(uint32_t sid) { + rtc::TypedMessageData* message = + new rtc::TypedMessageData(sid); signaling_thread()->Post(this, MSG_STREAMCLOSEDREMOTELY, message); } diff --git a/talk/session/media/channel.h b/talk/session/media/channel.h index 969f907928..c557ef35b5 100644 --- a/talk/session/media/channel.h +++ b/talk/session/media/channel.h @@ -134,9 +134,9 @@ class BaseChannel // Multiplexing bool AddRecvStream(const StreamParams& sp); - bool RemoveRecvStream(uint32 ssrc); + bool RemoveRecvStream(uint32_t ssrc); bool AddSendStream(const StreamParams& sp); - bool RemoveSendStream(uint32 ssrc); + bool RemoveSendStream(uint32_t ssrc); // Monitoring void StartConnectionMonitor(int cms); @@ -226,9 +226,9 @@ class BaseChannel void ChannelWritable_w(); void ChannelNotWritable_w(); bool AddRecvStream_w(const StreamParams& sp); - bool RemoveRecvStream_w(uint32 ssrc); + bool RemoveRecvStream_w(uint32_t ssrc); bool AddSendStream_w(const StreamParams& sp); - bool RemoveSendStream_w(uint32 ssrc); + bool RemoveSendStream_w(uint32_t ssrc); virtual bool ShouldSetupDtlsSrtp() const; // Do the DTLS key expansion and impose it on the SRTP/SRTCP filters. // |rtcp_channel| indicates whether to set up the RTP or RTCP filter. @@ -335,11 +335,11 @@ class VoiceChannel : public BaseChannel { bool rtcp); ~VoiceChannel(); bool Init(); - bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer); + bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer); // Configure sending media on the stream with SSRC |ssrc| // If there is only one sending stream SSRC 0 can be used. - bool SetAudioSend(uint32 ssrc, + bool SetAudioSend(uint32_t ssrc, bool enable, const AudioOptions* options, AudioRenderer* renderer); @@ -364,8 +364,8 @@ class VoiceChannel : public BaseChannel { // The |ssrc| should be either 0 or a valid send stream ssrc. // The valid value for the |event| are 0 which corresponding to DTMF // event 0-9, *, #, A-D. - bool InsertDtmf(uint32 ssrc, int event_code, int duration, int flags); - bool SetOutputScaling(uint32 ssrc, double left, double right); + bool InsertDtmf(uint32_t ssrc, int event_code, int duration, int flags); + bool SetOutputScaling(uint32_t ssrc, double left, double right); // Get statistics about the current media session. bool GetStats(VoiceMediaInfo* stats); @@ -401,8 +401,8 @@ class VoiceChannel : public BaseChannel { ContentAction action, std::string* error_desc); void HandleEarlyMediaTimeout(); - bool InsertDtmf_w(uint32 ssrc, int event, int duration, int flags); - bool SetOutputScaling_w(uint32 ssrc, double left, double right); + bool InsertDtmf_w(uint32_t ssrc, int event, int duration, int flags); + bool SetOutputScaling_w(uint32_t ssrc, double left, double right); bool GetStats_w(VoiceMediaInfo* stats); virtual void OnMessage(rtc::Message* pmsg); @@ -443,20 +443,20 @@ class VideoChannel : public BaseChannel { return static_cast(BaseChannel::media_channel()); } - bool SetRenderer(uint32 ssrc, VideoRenderer* renderer); + bool SetRenderer(uint32_t ssrc, VideoRenderer* renderer); bool ApplyViewRequest(const ViewRequest& request); // TODO(pthatcher): Refactor to use a "capture id" instead of an // ssrc here as the "key". // Passes ownership of the capturer to the channel. - bool AddScreencast(uint32 ssrc, VideoCapturer* capturer); - bool SetCapturer(uint32 ssrc, VideoCapturer* capturer); - bool RemoveScreencast(uint32 ssrc); + bool AddScreencast(uint32_t ssrc, VideoCapturer* capturer); + bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer); + bool RemoveScreencast(uint32_t ssrc); // True if we've added a screencast. Doesn't matter if the capturer // has been started or not. bool IsScreencasting(); - int GetScreencastFps(uint32 ssrc); - int GetScreencastMaxPixels(uint32 ssrc); + int GetScreencastFps(uint32_t ssrc); + int GetScreencastMaxPixels(uint32_t ssrc); // Get statistics about the current media session. bool GetStats(VideoMediaInfo* stats); @@ -466,17 +466,17 @@ class VideoChannel : public BaseChannel { void StartMediaMonitor(int cms); void StopMediaMonitor(); sigslot::signal2 SignalMediaMonitor; - sigslot::signal2 SignalScreencastWindowEvent; + sigslot::signal2 SignalScreencastWindowEvent; bool SendIntraFrame(); bool RequestIntraFrame(); // Configure sending media on the stream with SSRC |ssrc| // If there is only one sending stream SSRC 0 can be used. - bool SetVideoSend(uint32 ssrc, bool enable, const VideoOptions* options); + bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options); private: - typedef std::map ScreencastMap; + typedef std::map ScreencastMap; struct ScreencastDetailsData; // overrides from BaseChannel @@ -490,9 +490,9 @@ class VideoChannel : public BaseChannel { std::string* error_desc); bool ApplyViewRequest_w(const ViewRequest& request); - bool AddScreencast_w(uint32 ssrc, VideoCapturer* capturer); - bool RemoveScreencast_w(uint32 ssrc); - void OnScreencastWindowEvent_s(uint32 ssrc, rtc::WindowEvent we); + bool AddScreencast_w(uint32_t ssrc, VideoCapturer* capturer); + bool RemoveScreencast_w(uint32_t ssrc); + void OnScreencastWindowEvent_s(uint32_t ssrc, rtc::WindowEvent we); bool IsScreencasting_w() const; void GetScreencastDetails_w(ScreencastDetailsData* d) const; bool GetStats_w(VideoMediaInfo* stats); @@ -503,10 +503,9 @@ class VideoChannel : public BaseChannel { ConnectionMonitor* monitor, const std::vector& infos); virtual void OnMediaMonitorUpdate( VideoMediaChannel* media_channel, const VideoMediaInfo& info); - virtual void OnScreencastWindowEvent(uint32 ssrc, - rtc::WindowEvent event); + virtual void OnScreencastWindowEvent(uint32_t ssrc, rtc::WindowEvent event); virtual void OnStateChange(VideoCapturer* capturer, CaptureState ev); - bool GetLocalSsrc(const VideoCapturer* capturer, uint32* ssrc); + bool GetLocalSsrc(const VideoCapturer* capturer, uint32_t* ssrc); VideoRenderer* renderer_; ScreencastMap screencast_capturers_; @@ -548,16 +547,14 @@ class DataChannel : public BaseChannel { sigslot::signal2 SignalMediaMonitor; sigslot::signal2&> SignalConnectionMonitor; - sigslot::signal3 + sigslot::signal3 SignalDataReceived; // Signal for notifying when the channel becomes ready to send data. // That occurs when the channel is enabled, the transport is writable, // both local and remote descriptions are set, and the channel is unblocked. sigslot::signal1 SignalReadyToSendData; // Signal for notifying that the remote side has closed the DataChannel. - sigslot::signal1 SignalStreamClosedRemotely; + sigslot::signal1 SignalStreamClosedRemotely; protected: // downcasts a MediaChannel. @@ -626,9 +623,9 @@ class DataChannel : public BaseChannel { virtual bool ShouldSetupDtlsSrtp() const; void OnDataReceived( const ReceiveDataParams& params, const char* data, size_t len); - void OnDataChannelError(uint32 ssrc, DataMediaChannel::Error error); + void OnDataChannelError(uint32_t ssrc, DataMediaChannel::Error error); void OnDataChannelReadyToSend(bool writable); - void OnStreamClosedRemotely(uint32 sid); + void OnStreamClosedRemotely(uint32_t sid); rtc::scoped_ptr media_monitor_; // TODO(pthatcher): Make a separate SctpDataChannel and diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc index d6f25922ce..b861d0a4ef 100644 --- a/talk/session/media/channel_unittest.cc +++ b/talk/session/media/channel_unittest.cc @@ -67,9 +67,9 @@ static const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1, 0); static const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30, 0); static const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15, 0); static const cricket::DataCodec kGoogleDataCodec(101, "google-data", 0); -static const uint32 kSsrc1 = 0x1111; -static const uint32 kSsrc2 = 0x2222; -static const uint32 kSsrc3 = 0x3333; +static const uint32_t kSsrc1 = 0x1111; +static const uint32_t kSsrc2 = 0x2222; +static const uint32_t kSsrc3 = 0x3333; static const int kAudioPts[] = {0, 8}; static const int kVideoPts[] = {97, 99}; @@ -127,9 +127,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { DTLS = 0x10 }; ChannelTest(bool verify_playout, - const uint8* rtp_data, + const uint8_t* rtp_data, int rtp_len, - const uint8* rtcp_data, + const uint8_t* rtcp_data, int rtcp_len) : verify_playout_(verify_playout), transport_controller1_(cricket::ICEROLE_CONTROLLING), @@ -309,22 +309,22 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { static_cast(rtcp_packet_.size())); } // Methods to send custom data. - bool SendCustomRtp1(uint32 ssrc, int sequence_number, int pl_type = -1) { + bool SendCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); return media_channel1_->SendRtp(data.c_str(), static_cast(data.size())); } - bool SendCustomRtp2(uint32 ssrc, int sequence_number, int pl_type = -1) { + bool SendCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); return media_channel2_->SendRtp(data.c_str(), static_cast(data.size())); } - bool SendCustomRtcp1(uint32 ssrc) { + bool SendCustomRtcp1(uint32_t ssrc) { std::string data(CreateRtcpData(ssrc)); return media_channel1_->SendRtcp(data.c_str(), static_cast(data.size())); } - bool SendCustomRtcp2(uint32 ssrc) { + bool SendCustomRtcp2(uint32_t ssrc) { std::string data(CreateRtcpData(ssrc)); return media_channel2_->SendRtcp(data.c_str(), static_cast(data.size())); @@ -346,27 +346,27 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { static_cast(rtcp_packet_.size())); } // Methods to check custom data. - bool CheckCustomRtp1(uint32 ssrc, int sequence_number, int pl_type = -1 ) { + bool CheckCustomRtp1(uint32_t ssrc, int sequence_number, int pl_type = -1) { std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); return media_channel1_->CheckRtp(data.c_str(), static_cast(data.size())); } - bool CheckCustomRtp2(uint32 ssrc, int sequence_number, int pl_type = -1) { + bool CheckCustomRtp2(uint32_t ssrc, int sequence_number, int pl_type = -1) { std::string data(CreateRtpData(ssrc, sequence_number, pl_type)); return media_channel2_->CheckRtp(data.c_str(), static_cast(data.size())); } - bool CheckCustomRtcp1(uint32 ssrc) { + bool CheckCustomRtcp1(uint32_t ssrc) { std::string data(CreateRtcpData(ssrc)); return media_channel1_->CheckRtcp(data.c_str(), static_cast(data.size())); } - bool CheckCustomRtcp2(uint32 ssrc) { + bool CheckCustomRtcp2(uint32_t ssrc) { std::string data(CreateRtcpData(ssrc)); return media_channel2_->CheckRtcp(data.c_str(), static_cast(data.size())); } - std::string CreateRtpData(uint32 ssrc, int sequence_number, int pl_type) { + std::string CreateRtpData(uint32_t ssrc, int sequence_number, int pl_type) { std::string data(rtp_packet_); // Set SSRC in the rtp packet copy. rtc::SetBE32(const_cast(data.c_str()) + 8, ssrc); @@ -377,7 +377,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } return data; } - std::string CreateRtcpData(uint32 ssrc) { + std::string CreateRtcpData(uint32_t ssrc) { std::string data(rtcp_packet_); // Set SSRC in the rtcp packet copy. rtc::SetBE32(const_cast(data.c_str()) + 4, ssrc); @@ -410,7 +410,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { // Creates a cricket::SessionDescription with one MediaContent and one stream. // kPcmuCodec is used as audio codec and kH264Codec is used as video codec. - cricket::SessionDescription* CreateSessionDescriptionWithStream(uint32 ssrc) { + cricket::SessionDescription* CreateSessionDescriptionWithStream( + uint32_t ssrc) { typename T::Content content; cricket::SessionDescription* sdesc = new cricket::SessionDescription(); CreateContent(SECURE, kPcmuCodec, kH264Codec, &content); @@ -466,8 +467,9 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { } } - void AddLegacyStreamInContent(uint32 ssrc, int flags, - typename T::Content* content) { + void AddLegacyStreamInContent(uint32_t ssrc, + int flags, + typename T::Content* content) { // Base implementation. } @@ -1450,7 +1452,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> { int pl_type2 = pl_types[1]; int flags = SSRC_MUX | RTCP; if (secure) flags |= SECURE; - uint32 expected_channels = 2U; + uint32_t expected_channels = 2U; if (rtcp_mux) { flags |= RTCP_MUX; expected_channels = 1U; @@ -1834,9 +1836,11 @@ bool ChannelTest::CodecMatches(const cricket::AudioCodec& c1, c1.bitrate == c2.bitrate && c1.channels == c2.channels; } -template<> +template <> void ChannelTest::AddLegacyStreamInContent( - uint32 ssrc, int flags, cricket::AudioContentDescription* audio) { + uint32_t ssrc, + int flags, + cricket::AudioContentDescription* audio) { audio->AddLegacyStream(ssrc); } @@ -1904,9 +1908,11 @@ bool ChannelTest::CodecMatches(const cricket::VideoCodec& c1, c1.framerate == c2.framerate; } -template<> +template <> void ChannelTest::AddLegacyStreamInContent( - uint32 ssrc, int flags, cricket::VideoContentDescription* video) { + uint32_t ssrc, + int flags, + cricket::VideoContentDescription* video) { video->AddLegacyStream(ssrc); } @@ -2651,9 +2657,11 @@ bool ChannelTest::CodecMatches(const cricket::DataCodec& c1, return c1.name == c2.name; } -template<> +template <> void ChannelTest::AddLegacyStreamInContent( - uint32 ssrc, int flags, cricket::DataContentDescription* data) { + uint32_t ssrc, + int flags, + cricket::DataContentDescription* data) { data->AddLegacyStream(ssrc); } diff --git a/talk/session/media/currentspeakermonitor.cc b/talk/session/media/currentspeakermonitor.cc index ebea3bdeb5..5cfab267a0 100644 --- a/talk/session/media/currentspeakermonitor.cc +++ b/talk/session/media/currentspeakermonitor.cc @@ -80,17 +80,17 @@ void CurrentSpeakerMonitor::Stop() { } void CurrentSpeakerMonitor::set_min_time_between_switches( - uint32 min_time_between_switches) { + uint32_t min_time_between_switches) { min_time_between_switches_ = min_time_between_switches; } void CurrentSpeakerMonitor::OnAudioMonitor( AudioSourceContext* audio_source_context, const AudioInfo& info) { - std::map active_ssrc_to_level_map; + std::map active_ssrc_to_level_map; cricket::AudioInfo::StreamList::const_iterator stream_list_it; for (stream_list_it = info.active_streams.begin(); stream_list_it != info.active_streams.end(); ++stream_list_it) { - uint32 ssrc = stream_list_it->first; + uint32_t ssrc = stream_list_it->first; active_ssrc_to_level_map[ssrc] = stream_list_it->second; // It's possible we haven't yet added this source to our map. If so, @@ -102,11 +102,11 @@ void CurrentSpeakerMonitor::OnAudioMonitor( } int max_level = 0; - uint32 loudest_speaker_ssrc = 0; + uint32_t loudest_speaker_ssrc = 0; // Update the speaking states of all participants based on the new audio // level information. Also retain loudest speaker. - std::map::iterator state_it; + std::map::iterator state_it; for (state_it = ssrc_to_speaking_state_map_.begin(); state_it != ssrc_to_speaking_state_map_.end(); ++state_it) { bool is_previous_speaker = current_speaker_ssrc_ == state_it->first; @@ -115,7 +115,7 @@ void CurrentSpeakerMonitor::OnAudioMonitor( // members as having started or stopped speaking. Matches the // algorithm used by the hangouts js code. - std::map::const_iterator level_it = + std::map::const_iterator level_it = active_ssrc_to_level_map.find(state_it->first); // Note that the stream map only contains streams with non-zero audio // levels. @@ -182,7 +182,7 @@ void CurrentSpeakerMonitor::OnAudioMonitor( // We avoid over-switching by disabling switching for a period of time after // a switch is done. - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); if (earliest_permitted_switch_time_ <= now && current_speaker_ssrc_ != loudest_speaker_ssrc) { current_speaker_ssrc_ = loudest_speaker_ssrc; diff --git a/talk/session/media/currentspeakermonitor.h b/talk/session/media/currentspeakermonitor.h index 64beb98247..4dfe6f0997 100644 --- a/talk/session/media/currentspeakermonitor.h +++ b/talk/session/media/currentspeakermonitor.h @@ -76,12 +76,12 @@ class CurrentSpeakerMonitor : public sigslot::has_slots<> { // Used by tests. Note that the actual minimum time between switches // enforced by the monitor will be the given value plus or minus the // resolution of the system clock. - void set_min_time_between_switches(uint32 min_time_between_switches); + void set_min_time_between_switches(uint32_t min_time_between_switches); // This is fired when the current speaker changes, and provides his audio // SSRC. This only fires after the audio monitor on the underlying // AudioSourceContext has been started. - sigslot::signal2 SignalUpdate; + sigslot::signal2 SignalUpdate; private: void OnAudioMonitor(AudioSourceContext* audio_source_context, @@ -107,12 +107,12 @@ class CurrentSpeakerMonitor : public sigslot::has_slots<> { bool started_; AudioSourceContext* audio_source_context_; BaseSession* session_; - std::map ssrc_to_speaking_state_map_; - uint32 current_speaker_ssrc_; + std::map ssrc_to_speaking_state_map_; + uint32_t current_speaker_ssrc_; // To prevent overswitching, switching is disabled for some time after a // switch is made. This gives us the earliest time a switch is permitted. - uint32 earliest_permitted_switch_time_; - uint32 min_time_between_switches_; + uint32_t earliest_permitted_switch_time_; + uint32_t min_time_between_switches_; }; } diff --git a/talk/session/media/currentspeakermonitor_unittest.cc b/talk/session/media/currentspeakermonitor_unittest.cc index 6a99973f96..7970cea18b 100644 --- a/talk/session/media/currentspeakermonitor_unittest.cc +++ b/talk/session/media/currentspeakermonitor_unittest.cc @@ -32,15 +32,15 @@ namespace cricket { -static const uint32 kSsrc1 = 1001; -static const uint32 kSsrc2 = 1002; -static const uint32 kMinTimeBetweenSwitches = 10; +static const uint32_t kSsrc1 = 1001; +static const uint32_t kSsrc2 = 1002; +static const uint32_t kMinTimeBetweenSwitches = 10; // Due to limited system clock resolution, the CurrentSpeakerMonitor may // actually require more or less time between switches than that specified // in the call to set_min_time_between_switches. To be safe, we sleep for // 90 ms more than the min time between switches before checking for a switch. // I am assuming system clocks do not have a coarser resolution than 90 ms. -static const uint32 kSleepTimeBetweenSwitches = 100; +static const uint32_t kSleepTimeBetweenSwitches = 100; class CurrentSpeakerMonitorTest : public testing::Test, public sigslot::has_slots<> { @@ -68,9 +68,9 @@ class CurrentSpeakerMonitorTest : public testing::Test, AudioSourceContext source_; CurrentSpeakerMonitor* monitor_; int num_changes_; - uint32 current_speaker_; + uint32_t current_speaker_; - void OnUpdate(CurrentSpeakerMonitor* monitor, uint32 current_speaker) { + void OnUpdate(CurrentSpeakerMonitor* monitor, uint32_t current_speaker) { current_speaker_ = current_speaker; num_changes_++; } diff --git a/talk/session/media/externalhmac.h b/talk/session/media/externalhmac.h index 22fb36a99b..150a1bbc97 100644 --- a/talk/session/media/externalhmac.h +++ b/talk/session/media/externalhmac.h @@ -62,7 +62,7 @@ extern "C" { // The pointer to the key will be allocated in the external_hmac_init function. // This pointer is owned by srtp_t in a template context. typedef struct { - uint8 key[HMAC_KEY_LENGTH]; + uint8_t key[HMAC_KEY_LENGTH]; int key_length; } ExternalHmacContext; diff --git a/talk/session/media/mediamonitor.cc b/talk/session/media/mediamonitor.cc index 565e1459f7..f717062201 100644 --- a/talk/session/media/mediamonitor.cc +++ b/talk/session/media/mediamonitor.cc @@ -50,7 +50,7 @@ MediaMonitor::~MediaMonitor() { worker_thread_->Clear(this); } -void MediaMonitor::Start(uint32 milliseconds) { +void MediaMonitor::Start(uint32_t milliseconds) { rate_ = milliseconds; if (rate_ < 100) rate_ = 100; diff --git a/talk/session/media/mediamonitor.h b/talk/session/media/mediamonitor.h index 89740a8d4c..445b379477 100644 --- a/talk/session/media/mediamonitor.h +++ b/talk/session/media/mediamonitor.h @@ -46,7 +46,7 @@ class MediaMonitor : public rtc::MessageHandler, rtc::Thread* monitor_thread); ~MediaMonitor(); - void Start(uint32 milliseconds); + void Start(uint32_t milliseconds); void Stop(); protected: @@ -59,7 +59,7 @@ class MediaMonitor : public rtc::MessageHandler, rtc::Thread* worker_thread_; rtc::Thread* monitor_thread_; bool monitoring_; - uint32 rate_; + uint32_t rate_; }; // Templatized MediaMonitor that can deal with different kinds of media. diff --git a/talk/session/media/mediasession.cc b/talk/session/media/mediasession.cc index 99e1ea3936..2cd2d46d9c 100644 --- a/talk/session/media/mediasession.cc +++ b/talk/session/media/mediasession.cc @@ -45,7 +45,7 @@ #ifdef HAVE_SCTP #include "talk/media/sctp/sctpdataengine.h" #else -static const uint32 kMaxSctpSid = 1023; +static const uint32_t kMaxSctpSid = 1023; #endif namespace { @@ -250,9 +250,9 @@ static bool GenerateCname(const StreamParamsVec& params_vec, // |num_ssrcs| is the number of the SSRC will be generated. static void GenerateSsrcs(const StreamParamsVec& params_vec, int num_ssrcs, - std::vector* ssrcs) { + std::vector* ssrcs) { for (int i = 0; i < num_ssrcs; i++) { - uint32 candidate; + uint32_t candidate; do { candidate = rtc::CreateRandomNonZeroId(); } while (GetStreamBySsrc(params_vec, candidate) || @@ -262,15 +262,14 @@ static void GenerateSsrcs(const StreamParamsVec& params_vec, } // Returns false if we exhaust the range of SIDs. -static bool GenerateSctpSid(const StreamParamsVec& params_vec, - uint32* sid) { +static bool GenerateSctpSid(const StreamParamsVec& params_vec, uint32_t* sid) { if (params_vec.size() > kMaxSctpSid) { LOG(LS_WARNING) << "Could not generate an SCTP SID: too many SCTP streams."; return false; } while (true) { - uint32 candidate = rtc::CreateRandomNonZeroId() % kMaxSctpSid; + uint32_t candidate = rtc::CreateRandomNonZeroId() % kMaxSctpSid; if (!GetStreamBySsrc(params_vec, candidate)) { *sid = candidate; return true; @@ -279,8 +278,8 @@ static bool GenerateSctpSid(const StreamParamsVec& params_vec, } static bool GenerateSctpSids(const StreamParamsVec& params_vec, - std::vector* sids) { - uint32 sid; + std::vector* sids) { + uint32_t sid; if (!GenerateSctpSid(params_vec, &sid)) { LOG(LS_WARNING) << "Could not generated an SCTP SID."; return false; @@ -441,7 +440,7 @@ static bool AddStreamParams( if (streams.empty() && add_legacy_stream) { // TODO(perkj): Remove this legacy stream when all apps use StreamParams. - std::vector ssrcs; + std::vector ssrcs; if (IsSctp(content_description)) { GenerateSctpSids(*current_streams, &ssrcs); } else { @@ -476,7 +475,7 @@ static bool AddStreamParams( return false; } - std::vector ssrcs; + std::vector ssrcs; if (IsSctp(content_description)) { GenerateSctpSids(*current_streams, &ssrcs); } else { @@ -495,7 +494,7 @@ static bool AddStreamParams( // Generate extra ssrcs for include_rtx_streams case. if (include_rtx_streams) { // Generate an RTX ssrc for every ssrc in the group. - std::vector rtx_ssrcs; + std::vector rtx_ssrcs; GenerateSsrcs(*current_streams, static_cast(ssrcs.size()), &rtx_ssrcs); for (size_t i = 0; i < ssrcs.size(); ++i) { diff --git a/talk/session/media/mediasession.h b/talk/session/media/mediasession.h index 98ae60a372..e92628e711 100644 --- a/talk/session/media/mediasession.h +++ b/talk/session/media/mediasession.h @@ -249,10 +249,10 @@ class MediaContentDescription : public ContentDescription { streams_.push_back(stream); } // Legacy streams have an ssrc, but nothing else. - void AddLegacyStream(uint32 ssrc) { + void AddLegacyStream(uint32_t ssrc) { streams_.push_back(StreamParams::CreateLegacy(ssrc)); } - void AddLegacyStream(uint32 ssrc, uint32 fid_ssrc) { + void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) { StreamParams sp = StreamParams::CreateLegacy(ssrc); sp.AddFidSsrc(ssrc, fid_ssrc); streams_.push_back(sp); @@ -266,7 +266,7 @@ class MediaContentDescription : public ContentDescription { it->cname = cname; } } - uint32 first_ssrc() const { + uint32_t first_ssrc() const { if (streams_.empty()) { return 0; } diff --git a/talk/session/media/mediasession_unittest.cc b/talk/session/media/mediasession_unittest.cc index 3d69465dec..72aefc884c 100644 --- a/talk/session/media/mediasession_unittest.cc +++ b/talk/session/media/mediasession_unittest.cc @@ -176,11 +176,11 @@ static const RtpHeaderExtension kVideoRtpExtensionAnswer[] = { RtpHeaderExtension("urn:ietf:params:rtp-hdrext:toffset", 14), }; -static const uint32 kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31}; -static const uint32 kSimSsrc[] = {10, 20, 30}; -static const uint32 kFec1Ssrc[] = {10, 11}; -static const uint32 kFec2Ssrc[] = {20, 21}; -static const uint32 kFec3Ssrc[] = {30, 31}; +static const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31}; +static const uint32_t kSimSsrc[] = {10, 20, 30}; +static const uint32_t kFec1Ssrc[] = {10, 11}; +static const uint32_t kFec2Ssrc[] = {20, 21}; +static const uint32_t kFec3Ssrc[] = {30, 31}; static const char kMediaStream1[] = "stream_1"; static const char kMediaStream2[] = "stream_2"; @@ -1810,10 +1810,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) { EXPECT_TRUE(streams[0].has_ssrc_group("SIM")); // And a FID group for RTX. EXPECT_TRUE(streams[0].has_ssrc_group("FID")); - std::vector primary_ssrcs; + std::vector primary_ssrcs; streams[0].GetPrimarySsrcs(&primary_ssrcs); EXPECT_EQ(3u, primary_ssrcs.size()); - std::vector fid_ssrcs; + std::vector fid_ssrcs; streams[0].GetFidSsrcs(primary_ssrcs, &fid_ssrcs); EXPECT_EQ(3u, fid_ssrcs.size()); } diff --git a/talk/session/media/planarfunctions_unittest.cc b/talk/session/media/planarfunctions_unittest.cc index e7a666e0b4..886aa590ba 100644 --- a/talk/session/media/planarfunctions_unittest.cc +++ b/talk/session/media/planarfunctions_unittest.cc @@ -76,21 +76,21 @@ class PlanarFunctionsTest : public testing::TestWithParam { // Initialize the color band for testing. void InitializeColorBand() { - testing_color_y_.reset(new uint8[kTestingColorNum]); - testing_color_u_.reset(new uint8[kTestingColorNum]); - testing_color_v_.reset(new uint8[kTestingColorNum]); - testing_color_r_.reset(new uint8[kTestingColorNum]); - testing_color_g_.reset(new uint8[kTestingColorNum]); - testing_color_b_.reset(new uint8[kTestingColorNum]); + testing_color_y_.reset(new uint8_t[kTestingColorNum]); + testing_color_u_.reset(new uint8_t[kTestingColorNum]); + testing_color_v_.reset(new uint8_t[kTestingColorNum]); + testing_color_r_.reset(new uint8_t[kTestingColorNum]); + testing_color_g_.reset(new uint8_t[kTestingColorNum]); + testing_color_b_.reset(new uint8_t[kTestingColorNum]); int color_counter = 0; for (int i = 0; i < kTestingColorChannelResolution; ++i) { - uint8 color_r = static_cast( - i * 255 / (kTestingColorChannelResolution - 1)); + uint8_t color_r = + static_cast(i * 255 / (kTestingColorChannelResolution - 1)); for (int j = 0; j < kTestingColorChannelResolution; ++j) { - uint8 color_g = static_cast( + uint8_t color_g = static_cast( j * 255 / (kTestingColorChannelResolution - 1)); for (int k = 0; k < kTestingColorChannelResolution; ++k) { - uint8 color_b = static_cast( + uint8_t color_b = static_cast( k * 255 / (kTestingColorChannelResolution - 1)); testing_color_r_[color_counter] = color_r; testing_color_g_[color_counter] = color_g; @@ -107,16 +107,20 @@ class PlanarFunctionsTest : public testing::TestWithParam { } // Simple and slow RGB->YUV conversion. From NTSC standard, c/o Wikipedia. // (from lmivideoframe_unittest.cc) - void ConvertRgbPixel(uint8 r, uint8 g, uint8 b, - uint8* y, uint8* u, uint8* v) { + void ConvertRgbPixel(uint8_t r, + uint8_t g, + uint8_t b, + uint8_t* y, + uint8_t* u, + uint8_t* v) { *y = ClampUint8(.257 * r + .504 * g + .098 * b + 16); *u = ClampUint8(-.148 * r - .291 * g + .439 * b + 128); *v = ClampUint8(.439 * r - .368 * g - .071 * b + 128); } - uint8 ClampUint8(double value) { + uint8_t ClampUint8(double value) { value = std::max(0., std::min(255., value)); - uint8 uint8_value = static_cast(value); + uint8_t uint8_value = static_cast(value); return uint8_value; } @@ -127,11 +131,13 @@ class PlanarFunctionsTest : public testing::TestWithParam { // c2 c3 c4 c5 ... // ............... // The size of each chrome block is (block_size) x (block_size). - uint8* CreateFakeYuvTestingImage(int height, int width, int block_size, - libyuv::JpegSubsamplingType subsample_type, - uint8* &y_pointer, - uint8* &u_pointer, - uint8* &v_pointer) { + uint8_t* CreateFakeYuvTestingImage(int height, + int width, + int block_size, + libyuv::JpegSubsamplingType subsample_type, + uint8_t*& y_pointer, + uint8_t*& u_pointer, + uint8_t*& v_pointer) { if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } int y_size = height * width; int u_size, v_size; @@ -156,13 +162,13 @@ class PlanarFunctionsTest : public testing::TestWithParam { return NULL; break; } - uint8* image_pointer = new uint8[y_size + u_size + v_size + kAlignment]; + uint8_t* image_pointer = new uint8_t[y_size + u_size + v_size + kAlignment]; y_pointer = ALIGNP(image_pointer, kAlignment); u_pointer = ALIGNP(&image_pointer[y_size], kAlignment); v_pointer = ALIGNP(&image_pointer[y_size + u_size], kAlignment); - uint8* current_y_pointer = y_pointer; - uint8* current_u_pointer = u_pointer; - uint8* current_v_pointer = v_pointer; + uint8_t* current_y_pointer = y_pointer; + uint8_t* current_u_pointer = u_pointer; + uint8_t* current_v_pointer = v_pointer; for (int j = 0; j < height; ++j) { for (int i = 0; i < width; ++i) { int color = ((i / block_size) + (j / block_size)) % kTestingColorNum; @@ -184,9 +190,11 @@ class PlanarFunctionsTest : public testing::TestWithParam { // c2 c3 c4 c5 ... // ............... // The size of each chrome block is (block_size) x (block_size). - uint8* CreateFakeInterleaveYuvTestingImage( - int height, int width, int block_size, - uint8* &yuv_pointer, FourCC fourcc_type) { + uint8_t* CreateFakeInterleaveYuvTestingImage(int height, + int width, + int block_size, + uint8_t*& yuv_pointer, + FourCC fourcc_type) { if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } if (fourcc_type != FOURCC_YUY2 && fourcc_type != FOURCC_UYVY) { LOG(LS_ERROR) << "Format " << static_cast(fourcc_type) @@ -196,9 +204,9 @@ class PlanarFunctionsTest : public testing::TestWithParam { // Regularize the width of the output to be even. int awidth = (width + 1) & ~1; - uint8* image_pointer = new uint8[2 * height * awidth + kAlignment]; + uint8_t* image_pointer = new uint8_t[2 * height * awidth + kAlignment]; yuv_pointer = ALIGNP(image_pointer, kAlignment); - uint8* current_yuv_pointer = yuv_pointer; + uint8_t* current_yuv_pointer = yuv_pointer; switch (fourcc_type) { case FOURCC_YUY2: { for (int j = 0; j < height; ++j) { @@ -209,13 +217,15 @@ class PlanarFunctionsTest : public testing::TestWithParam { kTestingColorNum; current_yuv_pointer[0] = testing_color_y_[color1]; if (i < width) { - current_yuv_pointer[1] = static_cast( - (static_cast(testing_color_u_[color1]) + - static_cast(testing_color_u_[color2])) / 2); + current_yuv_pointer[1] = static_cast( + (static_cast(testing_color_u_[color1]) + + static_cast(testing_color_u_[color2])) / + 2); current_yuv_pointer[2] = testing_color_y_[color2]; - current_yuv_pointer[3] = static_cast( - (static_cast(testing_color_v_[color1]) + - static_cast(testing_color_v_[color2])) / 2); + current_yuv_pointer[3] = static_cast( + (static_cast(testing_color_v_[color1]) + + static_cast(testing_color_v_[color2])) / + 2); } else { current_yuv_pointer[1] = testing_color_u_[color1]; current_yuv_pointer[2] = 0; @@ -233,13 +243,15 @@ class PlanarFunctionsTest : public testing::TestWithParam { int color2 = (((i + 1) / block_size) + (j / block_size)) % kTestingColorNum; if (i < width) { - current_yuv_pointer[0] = static_cast( - (static_cast(testing_color_u_[color1]) + - static_cast(testing_color_u_[color2])) / 2); + current_yuv_pointer[0] = static_cast( + (static_cast(testing_color_u_[color1]) + + static_cast(testing_color_u_[color2])) / + 2); current_yuv_pointer[1] = testing_color_y_[color1]; - current_yuv_pointer[2] = static_cast( - (static_cast(testing_color_v_[color1]) + - static_cast(testing_color_v_[color2])) / 2); + current_yuv_pointer[2] = static_cast( + (static_cast(testing_color_v_[color1]) + + static_cast(testing_color_v_[color2])) / + 2); current_yuv_pointer[3] = testing_color_y_[color2]; } else { current_yuv_pointer[0] = testing_color_u_[color1]; @@ -263,16 +275,20 @@ class PlanarFunctionsTest : public testing::TestWithParam { // c2 c3 c4 c5 ... // ............... // The size of each chrome block is (block_size) x (block_size). - uint8* CreateFakeNV12TestingImage(int height, int width, int block_size, - uint8* &y_pointer, uint8* &uv_pointer) { + uint8_t* CreateFakeNV12TestingImage(int height, + int width, + int block_size, + uint8_t*& y_pointer, + uint8_t*& uv_pointer) { if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } - uint8* image_pointer = new uint8[height * width + - ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; + uint8_t* image_pointer = + new uint8_t[height * width + + ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; y_pointer = ALIGNP(image_pointer, kAlignment); uv_pointer = y_pointer + height * width; - uint8* current_uv_pointer = uv_pointer; - uint8* current_y_pointer = y_pointer; + uint8_t* current_uv_pointer = uv_pointer; + uint8_t* current_y_pointer = y_pointer; for (int j = 0; j < height; ++j) { for (int i = 0; i < width; ++i) { int color = ((i / block_size) + (j / block_size)) % @@ -299,14 +315,17 @@ class PlanarFunctionsTest : public testing::TestWithParam { // c2 c3 c4 c5 ... // ............... // The size of each chrome block is (block_size) x (block_size). - uint8* CreateFakeM420TestingImage( - int height, int width, int block_size, uint8* &m420_pointer) { + uint8_t* CreateFakeM420TestingImage(int height, + int width, + int block_size, + uint8_t*& m420_pointer) { if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } - uint8* image_pointer = new uint8[height * width + - ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; + uint8_t* image_pointer = + new uint8_t[height * width + + ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; m420_pointer = ALIGNP(image_pointer, kAlignment); - uint8* current_m420_pointer = m420_pointer; + uint8_t* current_m420_pointer = m420_pointer; for (int j = 0; j < height; ++j) { for (int i = 0; i < width; ++i) { int color = ((i / block_size) + (j / block_size)) % @@ -332,22 +351,25 @@ class PlanarFunctionsTest : public testing::TestWithParam { // c2 c3 c4 c5 ... // ............... // The size of each chrome block is (block_size) x (block_size). - uint8* CreateFakeArgbTestingImage(int height, int width, int block_size, - uint8* &argb_pointer, FourCC fourcc_type) { + uint8_t* CreateFakeArgbTestingImage(int height, + int width, + int block_size, + uint8_t*& argb_pointer, + FourCC fourcc_type) { if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } - uint8* image_pointer = NULL; + uint8_t* image_pointer = NULL; if (fourcc_type == FOURCC_ABGR || fourcc_type == FOURCC_BGRA || fourcc_type == FOURCC_ARGB) { - image_pointer = new uint8[height * width * 4 + kAlignment]; + image_pointer = new uint8_t[height * width * 4 + kAlignment]; } else if (fourcc_type == FOURCC_RAW || fourcc_type == FOURCC_24BG) { - image_pointer = new uint8[height * width * 3 + kAlignment]; + image_pointer = new uint8_t[height * width * 3 + kAlignment]; } else { LOG(LS_ERROR) << "Format " << static_cast(fourcc_type) << " is not supported."; return NULL; } argb_pointer = ALIGNP(image_pointer, kAlignment); - uint8* current_pointer = argb_pointer; + uint8_t* current_pointer = argb_pointer; switch (fourcc_type) { case FOURCC_ARGB: { for (int j = 0; j < height; ++j) { @@ -422,8 +444,10 @@ class PlanarFunctionsTest : public testing::TestWithParam { // Check if two memory chunks are equal. // (tolerate MSE errors within a threshold). - static bool IsMemoryEqual(const uint8* ibuf, const uint8* obuf, - int osize, double average_error) { + static bool IsMemoryEqual(const uint8_t* ibuf, + const uint8_t* obuf, + int osize, + double average_error) { double sse = cricket::ComputeSumSquareError(ibuf, obuf, osize); double error = sse / osize; // Mean Squared Error. double PSNR = cricket::ComputePSNR(sse, osize); @@ -433,7 +457,7 @@ class PlanarFunctionsTest : public testing::TestWithParam { } // Returns the index of the first differing byte. Easier to debug than memcmp. - static int FindDiff(const uint8* buf1, const uint8* buf2, int len) { + static int FindDiff(const uint8_t* buf1, const uint8_t* buf2, int len) { int i = 0; while (i < len && buf1[i] == buf2[i]) { i++; @@ -442,12 +466,12 @@ class PlanarFunctionsTest : public testing::TestWithParam { } // Dump the result image (ARGB format). - void DumpArgbImage(const uint8* obuf, int width, int height) { + void DumpArgbImage(const uint8_t* obuf, int width, int height) { DumpPlanarArgbTestImage(GetTestName(), obuf, width, height); } // Dump the result image (YUV420 format). - void DumpYuvImage(const uint8* obuf, int width, int height) { + void DumpYuvImage(const uint8_t* obuf, int width, int height) { DumpPlanarYuvTestImage(GetTestName(), obuf, width, height); } @@ -462,16 +486,18 @@ class PlanarFunctionsTest : public testing::TestWithParam { int repeat_; // Y, U, V and R, G, B channels of testing colors. - rtc::scoped_ptr testing_color_y_; - rtc::scoped_ptr testing_color_u_; - rtc::scoped_ptr testing_color_v_; - rtc::scoped_ptr testing_color_r_; - rtc::scoped_ptr testing_color_g_; - rtc::scoped_ptr testing_color_b_; + rtc::scoped_ptr testing_color_y_; + rtc::scoped_ptr testing_color_u_; + rtc::scoped_ptr testing_color_v_; + rtc::scoped_ptr testing_color_r_; + rtc::scoped_ptr testing_color_g_; + rtc::scoped_ptr testing_color_b_; }; TEST_F(PlanarFunctionsTest, I420Copy) { - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; + uint8_t* y_pointer = nullptr; + uint8_t* u_pointer = nullptr; + uint8_t* v_pointer = nullptr; int y_pitch = kWidth; int u_pitch = (kWidth + 1) >> 1; int v_pitch = (kWidth + 1) >> 1; @@ -479,16 +505,15 @@ TEST_F(PlanarFunctionsTest, I420Copy) { int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); int block_size = 3; // Generate a fake input image. - rtc::scoped_ptr yuv_input( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_pointer, u_pointer, v_pointer)); + rtc::scoped_ptr yuv_input(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, + v_pointer)); // Allocate space for the output image. - rtc::scoped_ptr yuv_output( - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment]); - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); - uint8 *u_output_pointer = y_output_pointer + y_size; - uint8 *v_output_pointer = u_output_pointer + uv_size; + rtc::scoped_ptr yuv_output( + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); + uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); + uint8_t* u_output_pointer = y_output_pointer + y_size; + uint8_t* v_output_pointer = u_output_pointer + uv_size; for (int i = 0; i < repeat_; ++i) { libyuv::I420Copy(y_pointer, y_pitch, @@ -508,7 +533,9 @@ TEST_F(PlanarFunctionsTest, I420Copy) { } TEST_F(PlanarFunctionsTest, I422ToI420) { - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; + uint8_t* y_pointer = nullptr; + uint8_t* u_pointer = nullptr; + uint8_t* v_pointer = nullptr; int y_pitch = kWidth; int u_pitch = (kWidth + 1) >> 1; int v_pitch = (kWidth + 1) >> 1; @@ -516,23 +543,22 @@ TEST_F(PlanarFunctionsTest, I422ToI420) { int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); int block_size = 2; // Generate a fake input image. - rtc::scoped_ptr yuv_input( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv422, - y_pointer, u_pointer, v_pointer)); + rtc::scoped_ptr yuv_input(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv422, y_pointer, u_pointer, + v_pointer)); // Allocate space for the output image. - rtc::scoped_ptr yuv_output( - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment]); - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); - uint8 *u_output_pointer = y_output_pointer + y_size; - uint8 *v_output_pointer = u_output_pointer + uv_size; + rtc::scoped_ptr yuv_output( + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); + uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); + uint8_t* u_output_pointer = y_output_pointer + y_size; + uint8_t* v_output_pointer = u_output_pointer + uv_size; // Generate the expected output. - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, - *v_expected_pointer = NULL; - rtc::scoped_ptr yuv_output_expected( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_expected_pointer, u_expected_pointer, v_expected_pointer)); + uint8_t* y_expected_pointer = nullptr; + uint8_t* u_expected_pointer = nullptr; + uint8_t* v_expected_pointer = nullptr; + rtc::scoped_ptr yuv_output_expected(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, + u_expected_pointer, v_expected_pointer)); for (int i = 0; i < repeat_; ++i) { libyuv::I422ToI420(y_pointer, y_pitch, @@ -556,7 +582,7 @@ TEST_F(PlanarFunctionsTest, I422ToI420) { TEST_P(PlanarFunctionsTest, M420ToI420) { // Get the unalignment offset int unalignment = GetParam(); - uint8 *m420_pointer = NULL; + uint8_t* m420_pointer = NULL; int y_pitch = kWidth; int m420_pitch = kWidth; int u_pitch = (kWidth + 1) >> 1; @@ -565,21 +591,22 @@ TEST_P(PlanarFunctionsTest, M420ToI420) { int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); int block_size = 2; // Generate a fake input image. - rtc::scoped_ptr yuv_input( + rtc::scoped_ptr yuv_input( CreateFakeM420TestingImage(kHeight, kWidth, block_size, m420_pointer)); // Allocate space for the output image. - rtc::scoped_ptr yuv_output( - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + unalignment; - uint8 *u_output_pointer = y_output_pointer + y_size; - uint8 *v_output_pointer = u_output_pointer + uv_size; + rtc::scoped_ptr yuv_output( + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); + uint8_t* y_output_pointer = + ALIGNP(yuv_output.get(), kAlignment) + unalignment; + uint8_t* u_output_pointer = y_output_pointer + y_size; + uint8_t* v_output_pointer = u_output_pointer + uv_size; // Generate the expected output. - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, - *v_expected_pointer = NULL; - rtc::scoped_ptr yuv_output_expected( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_expected_pointer, u_expected_pointer, v_expected_pointer)); + uint8_t* y_expected_pointer = nullptr; + uint8_t* u_expected_pointer = nullptr; + uint8_t* v_expected_pointer = nullptr; + rtc::scoped_ptr yuv_output_expected(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, + u_expected_pointer, v_expected_pointer)); for (int i = 0; i < repeat_; ++i) { libyuv::M420ToI420(m420_pointer, m420_pitch, @@ -600,7 +627,8 @@ TEST_P(PlanarFunctionsTest, M420ToI420) { TEST_P(PlanarFunctionsTest, NV12ToI420) { // Get the unalignment offset int unalignment = GetParam(); - uint8 *y_pointer = NULL, *uv_pointer = NULL; + uint8_t* y_pointer = nullptr; + uint8_t* uv_pointer = nullptr; int y_pitch = kWidth; int uv_pitch = 2 * ((kWidth + 1) >> 1); int u_pitch = (kWidth + 1) >> 1; @@ -609,22 +637,22 @@ TEST_P(PlanarFunctionsTest, NV12ToI420) { int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); int block_size = 2; // Generate a fake input image. - rtc::scoped_ptr yuv_input( - CreateFakeNV12TestingImage(kHeight, kWidth, block_size, - y_pointer, uv_pointer)); + rtc::scoped_ptr yuv_input(CreateFakeNV12TestingImage( + kHeight, kWidth, block_size, y_pointer, uv_pointer)); // Allocate space for the output image. - rtc::scoped_ptr yuv_output( - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + unalignment; - uint8 *u_output_pointer = y_output_pointer + y_size; - uint8 *v_output_pointer = u_output_pointer + uv_size; + rtc::scoped_ptr yuv_output( + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); + uint8_t* y_output_pointer = + ALIGNP(yuv_output.get(), kAlignment) + unalignment; + uint8_t* u_output_pointer = y_output_pointer + y_size; + uint8_t* v_output_pointer = u_output_pointer + uv_size; // Generate the expected output. - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, - *v_expected_pointer = NULL; - rtc::scoped_ptr yuv_output_expected( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_expected_pointer, u_expected_pointer, v_expected_pointer)); + uint8_t* y_expected_pointer = nullptr; + uint8_t* u_expected_pointer = nullptr; + uint8_t* v_expected_pointer = nullptr; + rtc::scoped_ptr yuv_output_expected(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, + u_expected_pointer, v_expected_pointer)); for (int i = 0; i < repeat_; ++i) { libyuv::NV12ToI420(y_pointer, y_pitch, @@ -644,50 +672,49 @@ TEST_P(PlanarFunctionsTest, NV12ToI420) { } // A common macro for testing converting YUY2/UYVY to I420. -#define TEST_YUVTOI420(SRC_NAME, MSE, BLOCK_SIZE) \ -TEST_P(PlanarFunctionsTest, SRC_NAME##ToI420) { \ - /* Get the unalignment offset.*/ \ - int unalignment = GetParam(); \ - uint8 *yuv_pointer = NULL; \ - int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ - int y_pitch = kWidth; \ - int u_pitch = (kWidth + 1) >> 1; \ - int v_pitch = (kWidth + 1) >> 1; \ - int y_size = kHeight * kWidth; \ - int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ - int block_size = 2; \ - /* Generate a fake input image.*/ \ - rtc::scoped_ptr yuv_input( \ - CreateFakeInterleaveYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, \ - yuv_pointer, FOURCC_##SRC_NAME)); \ - /* Allocate space for the output image.*/ \ - rtc::scoped_ptr yuv_output( \ - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + \ - unalignment; \ - uint8 *u_output_pointer = y_output_pointer + y_size; \ - uint8 *v_output_pointer = u_output_pointer + uv_size; \ - /* Generate the expected output.*/ \ - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, \ - *v_expected_pointer = NULL; \ - rtc::scoped_ptr yuv_output_expected( \ - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, \ - libyuv::kJpegYuv420, \ - y_expected_pointer, u_expected_pointer, v_expected_pointer)); \ - for (int i = 0; i < repeat_; ++i) { \ - libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, \ - y_output_pointer, y_pitch, \ - u_output_pointer, u_pitch, \ - v_output_pointer, v_pitch, \ - kWidth, kHeight); \ - } \ - /* Compare the output frame with what is expected.*/ \ - /* Note: MSE should be set to a larger threshold if an odd block width*/ \ - /* is used, since the conversion will be lossy.*/ \ - EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_expected_pointer, \ - I420_SIZE(kHeight, kWidth), MSE)); \ - if (dump_) { DumpYuvImage(y_output_pointer, kWidth, kHeight); } \ -} \ +#define TEST_YUVTOI420(SRC_NAME, MSE, BLOCK_SIZE) \ + TEST_P(PlanarFunctionsTest, SRC_NAME##ToI420) { \ + /* Get the unalignment offset.*/ \ + int unalignment = GetParam(); \ + uint8_t* yuv_pointer = nullptr; \ + int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ + int y_pitch = kWidth; \ + int u_pitch = (kWidth + 1) >> 1; \ + int v_pitch = (kWidth + 1) >> 1; \ + int y_size = kHeight * kWidth; \ + int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ + int block_size = 2; \ + /* Generate a fake input image.*/ \ + rtc::scoped_ptr yuv_input(CreateFakeInterleaveYuvTestingImage( \ + kHeight, kWidth, BLOCK_SIZE, yuv_pointer, FOURCC_##SRC_NAME)); \ + /* Allocate space for the output image.*/ \ + rtc::scoped_ptr yuv_output( \ + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ + uint8_t* y_output_pointer = \ + ALIGNP(yuv_output.get(), kAlignment) + unalignment; \ + uint8_t* u_output_pointer = y_output_pointer + y_size; \ + uint8_t* v_output_pointer = u_output_pointer + uv_size; \ + /* Generate the expected output.*/ \ + uint8_t* y_expected_pointer = nullptr; \ + uint8_t* u_expected_pointer = nullptr; \ + uint8_t* v_expected_pointer = nullptr; \ + rtc::scoped_ptr yuv_output_expected(CreateFakeYuvTestingImage( \ + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, \ + u_expected_pointer, v_expected_pointer)); \ + for (int i = 0; i < repeat_; ++i) { \ + libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, y_output_pointer, \ + y_pitch, u_output_pointer, u_pitch, \ + v_output_pointer, v_pitch, kWidth, kHeight); \ + } \ + /* Compare the output frame with what is expected.*/ \ + /* Note: MSE should be set to a larger threshold if an odd block width*/ \ + /* is used, since the conversion will be lossy.*/ \ + EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_expected_pointer, \ + I420_SIZE(kHeight, kWidth), MSE)); \ + if (dump_) { \ + DumpYuvImage(y_output_pointer, kWidth, kHeight); \ + } \ + } // TEST_P(PlanarFunctionsTest, YUV2ToI420) TEST_YUVTOI420(YUY2, 1.e-6, 2); @@ -695,37 +722,38 @@ TEST_YUVTOI420(YUY2, 1.e-6, 2); TEST_YUVTOI420(UYVY, 1.e-6, 2); // A common macro for testing converting I420 to ARGB, BGRA and ABGR. -#define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ -TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; \ - uint8 *argb_expected_pointer = NULL; \ - int y_pitch = kWidth; \ - int u_pitch = (kWidth + 1) >> 1; \ - int v_pitch = (kWidth + 1) >> 1; \ - /* Generate a fake input image.*/ \ - rtc::scoped_ptr yuv_input( \ - CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ - y_pointer, u_pointer, v_pointer)); \ - /* Generate the expected output.*/ \ - rtc::scoped_ptr argb_expected( \ - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ - argb_expected_pointer, FOURCC_##DST_NAME)); \ - /* Allocate space for the output.*/ \ - rtc::scoped_ptr argb_output( \ - new uint8[kHeight * kWidth * 4 + kAlignment]); \ - uint8 *argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ - for (int i = 0; i < repeat_; ++i) { \ - libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, \ - u_pointer, u_pitch, \ - v_pointer, v_pitch, \ - argb_pointer, \ - kWidth * 4, \ - kWidth, kHeight); \ - } \ - EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ - kHeight * kWidth * 4, MSE)); \ - if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } \ -} +#define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ + TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ + uint8_t* y_pointer = nullptr; \ + uint8_t* u_pointer = nullptr; \ + uint8_t* v_pointer = nullptr; \ + uint8_t* argb_expected_pointer = NULL; \ + int y_pitch = kWidth; \ + int u_pitch = (kWidth + 1) >> 1; \ + int v_pitch = (kWidth + 1) >> 1; \ + /* Generate a fake input image.*/ \ + rtc::scoped_ptr yuv_input( \ + CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ + y_pointer, u_pointer, v_pointer)); \ + /* Generate the expected output.*/ \ + rtc::scoped_ptr argb_expected( \ + CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ + argb_expected_pointer, FOURCC_##DST_NAME)); \ + /* Allocate space for the output.*/ \ + rtc::scoped_ptr argb_output( \ + new uint8_t[kHeight * kWidth * 4 + kAlignment]); \ + uint8_t* argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ + for (int i = 0; i < repeat_; ++i) { \ + libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, u_pointer, u_pitch, \ + v_pointer, v_pitch, argb_pointer, \ + kWidth * 4, kWidth, kHeight); \ + } \ + EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ + kHeight* kWidth * 4, MSE)); \ + if (dump_) { \ + DumpArgbImage(argb_pointer, kWidth, kHeight); \ + } \ + } // TEST_F(PlanarFunctionsTest, I420ToARGB) TEST_YUVTORGB(I420, ARGB, libyuv::kJpegYuv420, 3., 2); @@ -738,34 +766,35 @@ TEST_YUVTORGB(I422, ARGB, libyuv::kJpegYuv422, 3., 2); // TEST_F(PlanarFunctionsTest, I444ToARGB) TEST_YUVTORGB(I444, ARGB, libyuv::kJpegYuv444, 3., 3); // Note: an empirical MSE tolerance 3.0 is used here for the probable -// error from float-to-uint8 type conversion. +// error from float-to-uint8_t type conversion. TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; + uint8_t* y_pointer = nullptr; + uint8_t* u_pointer = nullptr; + uint8_t* v_pointer = nullptr; int y_pitch = kWidth; int u_pitch = (kWidth + 1) >> 1; int v_pitch = (kWidth + 1) >> 1; int block_size = 3; // Generate a fake input image. - rtc::scoped_ptr yuv_input( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_pointer, u_pointer, v_pointer)); + rtc::scoped_ptr yuv_input(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, + v_pointer)); // As the comparison standard, we convert a grayscale image (by setting both // U and V channels to be 128) using an I420 converter. int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); - rtc::scoped_ptr uv(new uint8[uv_size + kAlignment]); + rtc::scoped_ptr uv(new uint8_t[uv_size + kAlignment]); u_pointer = v_pointer = ALIGNP(uv.get(), kAlignment); memset(u_pointer, 128, uv_size); // Allocate space for the output image and generate the expected output. - rtc::scoped_ptr argb_expected( - new uint8[kHeight * kWidth * 4 + kAlignment]); - rtc::scoped_ptr argb_output( - new uint8[kHeight * kWidth * 4 + kAlignment]); - uint8 *argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment); + rtc::scoped_ptr argb_expected( + new uint8_t[kHeight * kWidth * 4 + kAlignment]); + rtc::scoped_ptr argb_output( + new uint8_t[kHeight * kWidth * 4 + kAlignment]); + uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); + uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment); libyuv::I420ToARGB(y_pointer, y_pitch, u_pointer, u_pitch, @@ -787,35 +816,36 @@ TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { TEST_P(PlanarFunctionsTest, I400ToARGB) { // Get the unalignment offset int unalignment = GetParam(); - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; + uint8_t* y_pointer = nullptr; + uint8_t* u_pointer = nullptr; + uint8_t* v_pointer = nullptr; int y_pitch = kWidth; int u_pitch = (kWidth + 1) >> 1; int v_pitch = (kWidth + 1) >> 1; int block_size = 3; // Generate a fake input image. - rtc::scoped_ptr yuv_input( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_pointer, u_pointer, v_pointer)); + rtc::scoped_ptr yuv_input(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, + v_pointer)); // As the comparison standard, we convert a grayscale image (by setting both // U and V channels to be 128) using an I420 converter. int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); // 1 byte extra if in the unaligned mode. - rtc::scoped_ptr uv(new uint8[uv_size * 2 + kAlignment]); + rtc::scoped_ptr uv(new uint8_t[uv_size * 2 + kAlignment]); u_pointer = ALIGNP(uv.get(), kAlignment); v_pointer = u_pointer + uv_size; memset(u_pointer, 128, uv_size); memset(v_pointer, 128, uv_size); // Allocate space for the output image and generate the expected output. - rtc::scoped_ptr argb_expected( - new uint8[kHeight * kWidth * 4 + kAlignment]); + rtc::scoped_ptr argb_expected( + new uint8_t[kHeight * kWidth * 4 + kAlignment]); // 1 byte extra if in the misalinged mode. - rtc::scoped_ptr argb_output( - new uint8[kHeight * kWidth * 4 + kAlignment + unalignment]); - uint8 *argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; + rtc::scoped_ptr argb_output( + new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); + uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); + uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; libyuv::I420ToARGB(y_pointer, y_pitch, u_pointer, u_pitch, @@ -839,22 +869,20 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { // Get the unalignment offset int unalignment = GetParam(); // Create a fake ARGB input image. - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; - uint8 *argb_pointer = NULL; + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; + uint8_t* argb_pointer = NULL; int block_size = 3; // Generate a fake input image. - rtc::scoped_ptr argb_input( - CreateFakeArgbTestingImage(kHeight, kWidth, block_size, - argb_pointer, FOURCC_ARGB)); + rtc::scoped_ptr argb_input(CreateFakeArgbTestingImage( + kHeight, kWidth, block_size, argb_pointer, FOURCC_ARGB)); // Generate the expected output. Only Y channel is used - rtc::scoped_ptr yuv_expected( - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, - libyuv::kJpegYuv420, - y_pointer, u_pointer, v_pointer)); + rtc::scoped_ptr yuv_expected(CreateFakeYuvTestingImage( + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, + v_pointer)); // Allocate space for the Y output. - rtc::scoped_ptr y_output( - new uint8[kHeight * kWidth + kAlignment + unalignment]); - uint8 *y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; + rtc::scoped_ptr y_output( + new uint8_t[kHeight * kWidth + kAlignment + unalignment]); + uint8_t* y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; for (int i = 0; i < repeat_; ++i) { libyuv::ARGBToI400(argb_pointer, kWidth * 4, y_output_pointer, kWidth, @@ -862,7 +890,7 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { } // Check if the output matches the input Y channel. // Note: an empirical MSE tolerance 2.0 is used here for the probable - // error from float-to-uint8 type conversion. + // error from float-to-uint8_t type conversion. EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_pointer, kHeight * kWidth, 2.)); if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } @@ -870,31 +898,32 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { // A common macro for testing converting RAW, BG24, BGRA, and ABGR // to ARGB. -#define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ -TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ - int unalignment = GetParam(); /* Get the unalignment offset.*/ \ - uint8 *argb_expected_pointer = NULL, *src_pointer = NULL; \ - /* Generate a fake input image.*/ \ - rtc::scoped_ptr src_input( \ - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ - src_pointer, FOURCC_##FC_ID)); \ - /* Generate the expected output.*/ \ - rtc::scoped_ptr argb_expected( \ - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ - argb_expected_pointer, FOURCC_ARGB)); \ - /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ - rtc::scoped_ptr argb_output( \ - new uint8[kHeight * kWidth * 4 + kAlignment + unalignment]); \ - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; \ - for (int i = 0; i < repeat_; ++i) { \ - libyuv:: SRC_NAME##ToARGB(src_pointer, kWidth * (BPP), argb_pointer, \ - kWidth * 4, kWidth, kHeight); \ - } \ - /* Compare the result; expect identical.*/ \ - EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ - kHeight * kWidth * 4, 1.e-6)); \ - if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } \ -} +#define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ + TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ + int unalignment = GetParam(); /* Get the unalignment offset.*/ \ + uint8_t* argb_expected_pointer = NULL, * src_pointer = NULL; \ + /* Generate a fake input image.*/ \ + rtc::scoped_ptr src_input(CreateFakeArgbTestingImage( \ + kHeight, kWidth, BLOCK_SIZE, src_pointer, FOURCC_##FC_ID)); \ + /* Generate the expected output.*/ \ + rtc::scoped_ptr argb_expected(CreateFakeArgbTestingImage( \ + kHeight, kWidth, BLOCK_SIZE, argb_expected_pointer, FOURCC_ARGB)); \ + /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ + rtc::scoped_ptr argb_output( \ + new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); \ + uint8_t* argb_pointer = \ + ALIGNP(argb_output.get(), kAlignment) + unalignment; \ + for (int i = 0; i < repeat_; ++i) { \ + libyuv::SRC_NAME##ToARGB(src_pointer, kWidth*(BPP), argb_pointer, \ + kWidth * 4, kWidth, kHeight); \ + } \ + /* Compare the result; expect identical.*/ \ + EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ + kHeight* kWidth * 4, 1.e-6)); \ + if (dump_) { \ + DumpArgbImage(argb_pointer, kWidth, kHeight); \ + } \ + } TEST_ARGB(RAW, RAW, 3, 3); // TEST_P(PlanarFunctionsTest, RAWToARGB) TEST_ARGB(BG24, 24BG, 3, 3); // TEST_P(PlanarFunctionsTest, BG24ToARGB) diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc index f7ab0bed18..8a95b7541b 100644 --- a/talk/session/media/srtpfilter.cc +++ b/talk/session/media/srtpfilter.cc @@ -147,9 +147,11 @@ bool SrtpFilter::SetProvisionalAnswer( } bool SrtpFilter::SetRtpParams(const std::string& send_cs, - const uint8* send_key, int send_key_len, + const uint8_t* send_key, + int send_key_len, const std::string& recv_cs, - const uint8* recv_key, int recv_key_len) { + const uint8_t* recv_key, + int recv_key_len) { if (IsActive()) { LOG(LS_ERROR) << "Tried to set SRTP Params when filter already active"; return false; @@ -178,9 +180,11 @@ bool SrtpFilter::SetRtpParams(const std::string& send_cs, // - In the muxed case, they are keyed with the same keys, so // this function is not needed bool SrtpFilter::SetRtcpParams(const std::string& send_cs, - const uint8* send_key, int send_key_len, + const uint8_t* send_key, + int send_key_len, const std::string& recv_cs, - const uint8* recv_key, int recv_key_len) { + const uint8_t* recv_key, + int recv_key_len) { // This can only be called once, but can be safely called after // SetRtpParams if (send_rtcp_session_ || recv_rtcp_session_) { @@ -216,8 +220,11 @@ bool SrtpFilter::ProtectRtp(void* p, int in_len, int max_len, int* out_len) { return send_session_->ProtectRtp(p, in_len, max_len, out_len); } -bool SrtpFilter::ProtectRtp(void* p, int in_len, int max_len, int* out_len, - int64* index) { +bool SrtpFilter::ProtectRtp(void* p, + int in_len, + int max_len, + int* out_len, + int64_t* index) { if (!IsActive()) { LOG(LS_WARNING) << "Failed to ProtectRtp: SRTP not active"; return false; @@ -261,7 +268,7 @@ bool SrtpFilter::UnprotectRtcp(void* p, int in_len, int* out_len) { } } -bool SrtpFilter::GetRtpAuthParams(uint8** key, int* key_len, int* tag_len) { +bool SrtpFilter::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { if (!IsActive()) { LOG(LS_WARNING) << "Failed to GetRtpAuthParams: SRTP not active"; return false; @@ -271,7 +278,7 @@ bool SrtpFilter::GetRtpAuthParams(uint8** key, int* key_len, int* tag_len) { return send_session_->GetRtpAuthParams(key, key_len, tag_len); } -void SrtpFilter::set_signal_silent_time(uint32 signal_silent_time_in_ms) { +void SrtpFilter::set_signal_silent_time(uint32_t signal_silent_time_in_ms) { signal_silent_time_in_ms_ = signal_silent_time_in_ms; if (IsActive()) { ASSERT(send_session_ != NULL); @@ -416,7 +423,7 @@ bool SrtpFilter::ApplyParams(const CryptoParams& send_params, } // TODO(juberti): Zero these buffers after use. bool ret; - uint8 send_key[SRTP_MASTER_KEY_LEN], recv_key[SRTP_MASTER_KEY_LEN]; + uint8_t send_key[SRTP_MASTER_KEY_LEN], recv_key[SRTP_MASTER_KEY_LEN]; ret = (ParseKeyParams(send_params.key_params, send_key, sizeof(send_key)) && ParseKeyParams(recv_params.key_params, recv_key, sizeof(recv_key))); if (ret) { @@ -446,7 +453,8 @@ bool SrtpFilter::ResetParams() { } bool SrtpFilter::ParseKeyParams(const std::string& key_params, - uint8* key, int len) { + uint8_t* key, + int len) { // example key_params: "inline:YUJDZGVmZ2hpSktMbW9QUXJzVHVWd3l6MTIzNDU2" // Fail if key-method is wrong. @@ -499,11 +507,11 @@ SrtpSession::~SrtpSession() { } } -bool SrtpSession::SetSend(const std::string& cs, const uint8* key, int len) { +bool SrtpSession::SetSend(const std::string& cs, const uint8_t* key, int len) { return SetKey(ssrc_any_outbound, cs, key, len); } -bool SrtpSession::SetRecv(const std::string& cs, const uint8* key, int len) { +bool SrtpSession::SetRecv(const std::string& cs, const uint8_t* key, int len) { return SetKey(ssrc_any_inbound, cs, key, len); } @@ -522,7 +530,7 @@ bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len) { *out_len = in_len; int err = srtp_protect(session_, p, out_len); - uint32 ssrc; + uint32_t ssrc; if (GetRtpSsrc(p, in_len, &ssrc)) { srtp_stat_->AddProtectRtpResult(ssrc, err); } @@ -538,8 +546,11 @@ bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len) { return true; } -bool SrtpSession::ProtectRtp(void* p, int in_len, int max_len, int* out_len, - int64* index) { +bool SrtpSession::ProtectRtp(void* p, + int in_len, + int max_len, + int* out_len, + int64_t* index) { if (!ProtectRtp(p, in_len, max_len, out_len)) { return false; } @@ -552,7 +563,7 @@ bool SrtpSession::ProtectRtcp(void* p, int in_len, int max_len, int* out_len) { return false; } - int need_len = in_len + sizeof(uint32) + rtcp_auth_tag_len_; // NOLINT + int need_len = in_len + sizeof(uint32_t) + rtcp_auth_tag_len_; // NOLINT if (max_len < need_len) { LOG(LS_WARNING) << "Failed to protect SRTCP packet: The buffer length " << max_len << " is less than the needed " << need_len; @@ -577,7 +588,7 @@ bool SrtpSession::UnprotectRtp(void* p, int in_len, int* out_len) { *out_len = in_len; int err = srtp_unprotect(session_, p, out_len); - uint32 ssrc; + uint32_t ssrc; if (GetRtpSsrc(p, in_len, &ssrc)) { srtp_stat_->AddUnprotectRtpResult(ssrc, err); } @@ -604,8 +615,7 @@ bool SrtpSession::UnprotectRtcp(void* p, int in_len, int* out_len) { return true; } -bool SrtpSession::GetRtpAuthParams(uint8** key, int* key_len, - int* tag_len) { +bool SrtpSession::GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len) { #if defined(ENABLE_EXTERNAL_AUTH) ExternalHmacContext* external_hmac = NULL; // stream_template will be the reference context for other streams. @@ -630,24 +640,28 @@ bool SrtpSession::GetRtpAuthParams(uint8** key, int* key_len, #endif } -bool SrtpSession::GetSendStreamPacketIndex(void* p, int in_len, int64* index) { +bool SrtpSession::GetSendStreamPacketIndex(void* p, + int in_len, + int64_t* index) { srtp_hdr_t* hdr = reinterpret_cast(p); srtp_stream_ctx_t* stream = srtp_get_stream(session_, hdr->ssrc); if (stream == NULL) return false; // Shift packet index, put into network byte order - *index = static_cast( + *index = static_cast( rtc::NetworkToHost64(rdbx_get_packet_index(&stream->rtp_rdbx) << 16)); return true; } -void SrtpSession::set_signal_silent_time(uint32 signal_silent_time_in_ms) { +void SrtpSession::set_signal_silent_time(uint32_t signal_silent_time_in_ms) { srtp_stat_->set_signal_silent_time(signal_silent_time_in_ms); } -bool SrtpSession::SetKey(int type, const std::string& cs, - const uint8* key, int len) { +bool SrtpSession::SetKey(int type, + const std::string& cs, + const uint8_t* key, + int len) { if (session_) { LOG(LS_ERROR) << "Failed to create SRTP session: " << "SRTP session already created"; @@ -680,7 +694,7 @@ bool SrtpSession::SetKey(int type, const std::string& cs, policy.ssrc.type = static_cast(type); policy.ssrc.value = 0; - policy.key = const_cast(key); + policy.key = const_cast(key); // TODO(astor) parse window size from WSH session-param policy.window_size = 1024; policy.allow_repeat_tx = 1; @@ -799,11 +813,11 @@ SrtpSession::SrtpSession() { SrtpSession::~SrtpSession() { } -bool SrtpSession::SetSend(const std::string& cs, const uint8* key, int len) { +bool SrtpSession::SetSend(const std::string& cs, const uint8_t* key, int len) { return SrtpNotAvailable(__FUNCTION__); } -bool SrtpSession::SetRecv(const std::string& cs, const uint8* key, int len) { +bool SrtpSession::SetRecv(const std::string& cs, const uint8_t* key, int len) { return SrtpNotAvailable(__FUNCTION__); } @@ -825,7 +839,7 @@ bool SrtpSession::UnprotectRtcp(void* data, int in_len, int* out_len) { return SrtpNotAvailable(__FUNCTION__); } -void SrtpSession::set_signal_silent_time(uint32 signal_silent_time) { +void SrtpSession::set_signal_silent_time(uint32_t signal_silent_time) { // Do nothing. } @@ -840,7 +854,7 @@ SrtpStat::SrtpStat() : signal_silent_time_(1000) { } -void SrtpStat::AddProtectRtpResult(uint32 ssrc, int result) { +void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { FailureKey key; key.ssrc = ssrc; key.mode = SrtpFilter::PROTECT; @@ -857,7 +871,7 @@ void SrtpStat::AddProtectRtpResult(uint32 ssrc, int result) { HandleSrtpResult(key); } -void SrtpStat::AddUnprotectRtpResult(uint32 ssrc, int result) { +void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) { FailureKey key; key.ssrc = ssrc; key.mode = SrtpFilter::UNPROTECT; @@ -893,7 +907,7 @@ void SrtpStat::HandleSrtpResult(const SrtpStat::FailureKey& key) { if (key.error != SrtpFilter::ERROR_NONE) { // For errors, signal first time and wait for 1 sec. FailureStat* stat = &(failures_[key]); - uint32 current_time = rtc::Time(); + uint32_t current_time = rtc::Time(); if (stat->last_signal_time == 0 || rtc::TimeDiff(current_time, stat->last_signal_time) > static_cast(signal_silent_time_)) { @@ -912,11 +926,11 @@ SrtpStat::SrtpStat() LOG(WARNING) << "SRTP implementation is missing."; } -void SrtpStat::AddProtectRtpResult(uint32 ssrc, int result) { +void SrtpStat::AddProtectRtpResult(uint32_t ssrc, int result) { SrtpNotAvailable(__FUNCTION__); } -void SrtpStat::AddUnprotectRtpResult(uint32 ssrc, int result) { +void SrtpStat::AddUnprotectRtpResult(uint32_t ssrc, int result) { SrtpNotAvailable(__FUNCTION__); } diff --git a/talk/session/media/srtpfilter.h b/talk/session/media/srtpfilter.h index 1b52614151..3c3a8e848b 100644 --- a/talk/session/media/srtpfilter.h +++ b/talk/session/media/srtpfilter.h @@ -105,20 +105,27 @@ class SrtpFilter { // Just set up both sets of keys directly. // Used with DTLS-SRTP. bool SetRtpParams(const std::string& send_cs, - const uint8* send_key, int send_key_len, + const uint8_t* send_key, + int send_key_len, const std::string& recv_cs, - const uint8* recv_key, int recv_key_len); + const uint8_t* recv_key, + int recv_key_len); bool SetRtcpParams(const std::string& send_cs, - const uint8* send_key, int send_key_len, + const uint8_t* send_key, + int send_key_len, const std::string& recv_cs, - const uint8* recv_key, int recv_key_len); + const uint8_t* recv_key, + int recv_key_len); // Encrypts/signs an individual RTP/RTCP packet, in-place. // If an HMAC is used, this will increase the packet size. bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); // Overloaded version, outputs packet index. - bool ProtectRtp(void* data, int in_len, int max_len, int* out_len, - int64* index); + bool ProtectRtp(void* data, + int in_len, + int max_len, + int* out_len, + int64_t* index); bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); // Decrypts/verifies an invidiual RTP/RTCP packet. // If an HMAC is used, this will decrease the packet size. @@ -126,12 +133,12 @@ class SrtpFilter { bool UnprotectRtcp(void* data, int in_len, int* out_len); // Returns rtp auth params from srtp context. - bool GetRtpAuthParams(uint8** key, int* key_len, int* tag_len); + bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); // Update the silent threshold (in ms) for signaling errors. - void set_signal_silent_time(uint32 signal_silent_time_in_ms); + void set_signal_silent_time(uint32_t signal_silent_time_in_ms); - sigslot::repeater3 SignalSrtpError; + sigslot::repeater3 SignalSrtpError; protected: bool ExpectOffer(ContentSource source); @@ -147,7 +154,7 @@ class SrtpFilter { bool ApplyParams(const CryptoParams& send_params, const CryptoParams& recv_params); bool ResetParams(); - static bool ParseKeyParams(const std::string& params, uint8* key, int len); + static bool ParseKeyParams(const std::string& params, uint8_t* key, int len); private: enum State { @@ -174,7 +181,7 @@ class SrtpFilter { ST_RECEIVEDPRANSWER }; State state_; - uint32 signal_silent_time_in_ms_; + uint32_t signal_silent_time_in_ms_; std::vector offer_params_; rtc::scoped_ptr send_session_; rtc::scoped_ptr recv_session_; @@ -192,17 +199,20 @@ class SrtpSession { // Configures the session for sending data using the specified // cipher-suite and key. Receiving must be done by a separate session. - bool SetSend(const std::string& cs, const uint8* key, int len); + bool SetSend(const std::string& cs, const uint8_t* key, int len); // Configures the session for receiving data using the specified // cipher-suite and key. Sending must be done by a separate session. - bool SetRecv(const std::string& cs, const uint8* key, int len); + bool SetRecv(const std::string& cs, const uint8_t* key, int len); // Encrypts/signs an individual RTP/RTCP packet, in-place. // If an HMAC is used, this will increase the packet size. bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); // Overloaded version, outputs packet index. - bool ProtectRtp(void* data, int in_len, int max_len, int* out_len, - int64* index); + bool ProtectRtp(void* data, + int in_len, + int max_len, + int* out_len, + int64_t* index); bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); // Decrypts/verifies an invidiual RTP/RTCP packet. // If an HMAC is used, this will decrease the packet size. @@ -210,21 +220,21 @@ class SrtpSession { bool UnprotectRtcp(void* data, int in_len, int* out_len); // Helper method to get authentication params. - bool GetRtpAuthParams(uint8** key, int* key_len, int* tag_len); + bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); // Update the silent threshold (in ms) for signaling errors. - void set_signal_silent_time(uint32 signal_silent_time_in_ms); + void set_signal_silent_time(uint32_t signal_silent_time_in_ms); // Calls srtp_shutdown if it's initialized. static void Terminate(); - sigslot::repeater3 + sigslot::repeater3 SignalSrtpError; private: - bool SetKey(int type, const std::string& cs, const uint8* key, int len); + bool SetKey(int type, const std::string& cs, const uint8_t* key, int len); // Returns send stream current packet index from srtp db. - bool GetSendStreamPacketIndex(void* data, int in_len, int64* index); + bool GetSendStreamPacketIndex(void* data, int in_len, int64_t* index); static bool Init(); void HandleEvent(const srtp_event_data_t* ev); @@ -248,23 +258,23 @@ class SrtpStat { SrtpStat(); // Report RTP protection results to the handler. - void AddProtectRtpResult(uint32 ssrc, int result); + void AddProtectRtpResult(uint32_t ssrc, int result); // Report RTP unprotection results to the handler. - void AddUnprotectRtpResult(uint32 ssrc, int result); + void AddUnprotectRtpResult(uint32_t ssrc, int result); // Report RTCP protection results to the handler. void AddProtectRtcpResult(int result); // Report RTCP unprotection results to the handler. void AddUnprotectRtcpResult(int result); // Get silent time (in ms) for SRTP statistics handler. - uint32 signal_silent_time() const { return signal_silent_time_; } + uint32_t signal_silent_time() const { return signal_silent_time_; } // Set silent time (in ms) for SRTP statistics handler. - void set_signal_silent_time(uint32 signal_silent_time) { + void set_signal_silent_time(uint32_t signal_silent_time) { signal_silent_time_ = signal_silent_time; } // Sigslot for reporting errors. - sigslot::signal3 + sigslot::signal3 SignalSrtpError; private: @@ -275,19 +285,17 @@ class SrtpStat { mode(SrtpFilter::PROTECT), error(SrtpFilter::ERROR_NONE) { } - FailureKey(uint32 in_ssrc, SrtpFilter::Mode in_mode, + FailureKey(uint32_t in_ssrc, + SrtpFilter::Mode in_mode, SrtpFilter::Error in_error) - : ssrc(in_ssrc), - mode(in_mode), - error(in_error) { - } + : ssrc(in_ssrc), mode(in_mode), error(in_error) {} bool operator <(const FailureKey& key) const { return (ssrc < key.ssrc) || (ssrc == key.ssrc && mode < key.mode) || (ssrc == key.ssrc && mode == key.mode && error < key.error); } - uint32 ssrc; + uint32_t ssrc; SrtpFilter::Mode mode; SrtpFilter::Error error; }; @@ -298,13 +306,12 @@ class SrtpStat { FailureStat() : last_signal_time(0) { } - explicit FailureStat(uint32 in_last_signal_time) - : last_signal_time(in_last_signal_time) { - } + explicit FailureStat(uint32_t in_last_signal_time) + : last_signal_time(in_last_signal_time) {} void Reset() { last_signal_time = 0; } - uint32 last_signal_time; + uint32_t last_signal_time; }; // Inspect SRTP result and signal error if needed. @@ -312,7 +319,7 @@ class SrtpStat { std::map failures_; // Threshold in ms to silent the signaling errors. - uint32 signal_silent_time_; + uint32_t signal_silent_time_; RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); }; diff --git a/talk/session/media/srtpfilter_unittest.cc b/talk/session/media/srtpfilter_unittest.cc index 55408e6bd6..8122455205 100644 --- a/talk/session/media/srtpfilter_unittest.cc +++ b/talk/session/media/srtpfilter_unittest.cc @@ -46,8 +46,8 @@ using cricket::CryptoParams; using cricket::CS_LOCAL; using cricket::CS_REMOTE; -static const uint8 kTestKey1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234"; -static const uint8 kTestKey2[] = "4321ZYXWVUTSRQPONMLKJIHGFEDCBA"; +static const uint8_t kTestKey1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234"; +static const uint8_t kTestKey2[] = "4321ZYXWVUTSRQPONMLKJIHGFEDCBA"; static const int kTestKeyLen = 30; static const std::string kTestKeyParams1 = "inline:WVNfX19zZW1jdGwgKCkgewkyMjA7fQp9CnVubGVz"; @@ -99,8 +99,8 @@ class SrtpFilterTest : public testing::Test { memcpy(rtp_packet, kPcmuFrame, rtp_len); // In order to be able to run this test function multiple times we can not // use the same sequence number twice. Increase the sequence number by one. - rtc::SetBE16(reinterpret_cast(rtp_packet) + 2, - ++sequence_number_); + rtc::SetBE16(reinterpret_cast(rtp_packet) + 2, + ++sequence_number_); memcpy(original_rtp_packet, rtp_packet, rtp_len); memcpy(rtcp_packet, kRtcpReport, rtcp_len); @@ -574,7 +574,7 @@ TEST_F(SrtpFilterTest, TestGetSendAuthParams) { kTestKey1, kTestKeyLen, CS_AES_CM_128_HMAC_SHA1_32, kTestKey2, kTestKeyLen)); - uint8* auth_key = NULL; + uint8_t* auth_key = NULL; int auth_key_len = 0, auth_tag_len = 0; EXPECT_TRUE(f1_.GetRtpAuthParams(&auth_key, &auth_key_len, &auth_tag_len)); EXPECT_TRUE(auth_key != NULL); @@ -669,12 +669,12 @@ TEST_F(SrtpSessionTest, TestProtect_AES_CM_128_HMAC_SHA1_32) { TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) { EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_32, kTestKey1, kTestKeyLen)); - int64 index; + int64_t index; int out_len = 0; EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len, &index)); // |index| will be shifted by 16. - int64 be64_index = static_cast(rtc::NetworkToHost64(1 << 16)); + int64_t be64_index = static_cast(rtc::NetworkToHost64(1 << 16)); EXPECT_EQ(be64_index, index); } @@ -711,46 +711,46 @@ TEST_F(SrtpSessionTest, TestBuffersTooSmall) { } TEST_F(SrtpSessionTest, TestReplay) { - static const uint16 kMaxSeqnum = static_cast(-1); - static const uint16 seqnum_big = 62275; - static const uint16 seqnum_small = 10; - static const uint16 replay_window = 1024; + static const uint16_t kMaxSeqnum = static_cast(-1); + static const uint16_t seqnum_big = 62275; + static const uint16_t seqnum_small = 10; + static const uint16_t replay_window = 1024; int out_len; EXPECT_TRUE(s1_.SetSend(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); EXPECT_TRUE(s2_.SetRecv(CS_AES_CM_128_HMAC_SHA1_80, kTestKey1, kTestKeyLen)); // Initial sequence number. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum_big); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum_big); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); // Replay within the 1024 window should succeed. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, - seqnum_big - replay_window + 1); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, + seqnum_big - replay_window + 1); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); // Replay out side of the 1024 window should fail. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, - seqnum_big - replay_window - 1); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, + seqnum_big - replay_window - 1); EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); // Increment sequence number to a small number. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum_small); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum_small); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); // Replay around 0 but out side of the 1024 window should fail. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, - kMaxSeqnum + seqnum_small - replay_window - 1); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, + kMaxSeqnum + seqnum_small - replay_window - 1); EXPECT_FALSE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); // Replay around 0 but within the 1024 window should succeed. - for (uint16 seqnum = 65000; seqnum < 65003; ++seqnum) { - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum); + for (uint16_t seqnum = 65000; seqnum < 65003; ++seqnum) { + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); } @@ -760,8 +760,7 @@ TEST_F(SrtpSessionTest, TestReplay) { // without the fix, the loop above would keep incrementing local sequence // number in libsrtp, eventually the new sequence number would go out side // of the window. - rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, - seqnum_small + 1); + rtc::SetBE16(reinterpret_cast(rtp_packet_) + 2, seqnum_small + 1); EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len)); } @@ -779,7 +778,8 @@ class SrtpStatTest } protected: - void OnSrtpError(uint32 ssrc, cricket::SrtpFilter::Mode mode, + void OnSrtpError(uint32_t ssrc, + cricket::SrtpFilter::Mode mode, cricket::SrtpFilter::Error error) { ssrc_ = ssrc; mode_ = mode; @@ -792,7 +792,7 @@ class SrtpStatTest } cricket::SrtpStat srtp_stat_; - uint32 ssrc_; + uint32_t ssrc_; int mode_; cricket::SrtpFilter::Error error_; diff --git a/talk/session/media/yuvscaler_unittest.cc b/talk/session/media/yuvscaler_unittest.cc index 20182467ae..b6b06374a5 100644 --- a/talk/session/media/yuvscaler_unittest.cc +++ b/talk/session/media/yuvscaler_unittest.cc @@ -65,10 +65,10 @@ static const int kAlignment = 16; #endif #if defined(__GNUC__) && defined(__i386__) -static inline uint64 __rdtsc(void) { +static inline uint64_t __rdtsc(void) { uint32_t a, d; __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); - return (reinterpret_cast(d) << 32) + a; + return (reinterpret_cast(d) << 32) + a; } static inline void _mm_clflush(volatile void *__p) { @@ -76,7 +76,7 @@ static inline void _mm_clflush(volatile void *__p) { } #endif -static void FlushCache(uint8* dst, int count) { +static void FlushCache(uint8_t* dst, int count) { while (count >= 32) { _mm_clflush(dst); dst += 32; @@ -101,13 +101,16 @@ class YuvScalerTest : public testing::Test { *error = 0.; size_t isize = I420_SIZE(iw, ih); size_t osize = I420_SIZE(ow, oh); - scoped_ptr ibuffer(new uint8[isize + kAlignment + memoffset]()); - scoped_ptr obuffer(new uint8[osize + kAlignment + memoffset]()); - scoped_ptr xbuffer(new uint8[osize + kAlignment + memoffset]()); + scoped_ptr ibuffer( + new uint8_t[isize + kAlignment + memoffset]()); + scoped_ptr obuffer( + new uint8_t[osize + kAlignment + memoffset]()); + scoped_ptr xbuffer( + new uint8_t[osize + kAlignment + memoffset]()); - uint8 *ibuf = ALIGNP(ibuffer.get(), kAlignment) + memoffset; - uint8 *obuf = ALIGNP(obuffer.get(), kAlignment) + memoffset; - uint8 *xbuf = ALIGNP(xbuffer.get(), kAlignment) + memoffset; + uint8_t* ibuf = ALIGNP(ibuffer.get(), kAlignment) + memoffset; + uint8_t* obuf = ALIGNP(obuffer.get(), kAlignment) + memoffset; + uint8_t* xbuf = ALIGNP(xbuffer.get(), kAlignment) + memoffset; if (usefile) { if (!LoadPlanarYuvTestImage("faces", iw, ih, ibuf) || @@ -133,7 +136,7 @@ class YuvScalerTest : public testing::Test { // TODO(fbarchard): set flags for libyuv libyuv::MaskCpuFlags(cpuflags); #ifdef TEST_RSTSC - uint64 t = 0; + uint64_t t = 0; #endif for (int i = 0; i < repeat_; ++i) { #ifdef TEST_UNCACHED @@ -141,12 +144,12 @@ class YuvScalerTest : public testing::Test { FlushCache(obuf, osize); #endif #ifdef TEST_RSTSC - uint64 t1 = __rdtsc(); + uint64_t t1 = __rdtsc(); #endif EXPECT_EQ(0, libyuv::ScaleOffset(ibuf, iw, ih, obuf, ow, oh, offset, interpolate)); #ifdef TEST_RSTSC - uint64 t2 = __rdtsc(); + uint64_t t2 = __rdtsc(); t += t2 - t1; #endif } @@ -172,7 +175,7 @@ class YuvScalerTest : public testing::Test { } // Returns the index of the first differing byte. Easier to debug than memcmp. - static int FindDiff(const uint8* buf1, const uint8* buf2, int len) { + static int FindDiff(const uint8_t* buf1, const uint8_t* buf2, int len) { int i = 0; while (i < len && buf1[i] == buf2[i]) { i++; @@ -189,8 +192,8 @@ class YuvScalerTest : public testing::Test { TEST_F(YuvScalerTest, TestCopy) { const int iw = 640, ih = 360; const int ow = 640, oh = 360; - ALIGN16(uint8 ibuf[I420_SIZE(iw, ih)]); - ALIGN16(uint8 obuf[I420_SIZE(ow, oh)]); + ALIGN16(uint8_t ibuf[I420_SIZE(iw, ih)]); + ALIGN16(uint8_t obuf[I420_SIZE(ow, oh)]); // Load the frame, scale it, check it. ASSERT_TRUE(LoadPlanarYuvTestImage("faces", iw, ih, ibuf)); @@ -206,11 +209,11 @@ TEST_F(YuvScalerTest, TestOffset16_10Copy) { const int iw = 640, ih = 360; const int ow = 640, oh = 480; const int offset = (480 - 360) / 2; - scoped_ptr ibuffer(new uint8[I420_SIZE(iw, ih) + kAlignment]); - scoped_ptr obuffer(new uint8[I420_SIZE(ow, oh) + kAlignment]); + scoped_ptr ibuffer(new uint8_t[I420_SIZE(iw, ih) + kAlignment]); + scoped_ptr obuffer(new uint8_t[I420_SIZE(ow, oh) + kAlignment]); - uint8 *ibuf = ALIGNP(ibuffer.get(), kAlignment); - uint8 *obuf = ALIGNP(obuffer.get(), kAlignment); + uint8_t* ibuf = ALIGNP(ibuffer.get(), kAlignment); + uint8_t* obuf = ALIGNP(obuffer.get(), kAlignment); // Load the frame, scale it, check it. ASSERT_TRUE(LoadPlanarYuvTestImage("faces", iw, ih, ibuf)); diff --git a/webrtc/base/asyncinvoker.cc b/webrtc/base/asyncinvoker.cc index 563ccb7afd..8285d5545b 100644 --- a/webrtc/base/asyncinvoker.cc +++ b/webrtc/base/asyncinvoker.cc @@ -36,7 +36,7 @@ void AsyncInvoker::OnMessage(Message* msg) { closure->Execute(); } -void AsyncInvoker::Flush(Thread* thread, uint32 id /*= MQID_ANY*/) { +void AsyncInvoker::Flush(Thread* thread, uint32_t id /*= MQID_ANY*/) { if (destroying_) return; // Run this on |thread| to reduce the number of context switches. @@ -57,7 +57,7 @@ void AsyncInvoker::Flush(Thread* thread, uint32 id /*= MQID_ANY*/) { void AsyncInvoker::DoInvoke(Thread* thread, const scoped_refptr& closure, - uint32 id) { + uint32_t id) { if (destroying_) { LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; return; @@ -67,8 +67,8 @@ void AsyncInvoker::DoInvoke(Thread* thread, void AsyncInvoker::DoInvokeDelayed(Thread* thread, const scoped_refptr& closure, - uint32 delay_ms, - uint32 id) { + uint32_t delay_ms, + uint32_t id) { if (destroying_) { LOG(LS_WARNING) << "Tried to invoke while destroying the invoker."; return; @@ -85,7 +85,7 @@ GuardedAsyncInvoker::GuardedAsyncInvoker() : thread_(Thread::Current()) { GuardedAsyncInvoker::~GuardedAsyncInvoker() { } -bool GuardedAsyncInvoker::Flush(uint32 id) { +bool GuardedAsyncInvoker::Flush(uint32_t id) { rtc::CritScope cs(&crit_); if (thread_ == nullptr) return false; diff --git a/webrtc/base/asyncinvoker.h b/webrtc/base/asyncinvoker.h index 2d2c65c7a2..a35133706a 100644 --- a/webrtc/base/asyncinvoker.h +++ b/webrtc/base/asyncinvoker.h @@ -74,9 +74,7 @@ class AsyncInvoker : public MessageHandler { // Call |functor| asynchronously on |thread|, with no callback upon // completion. Returns immediately. template - void AsyncInvoke(Thread* thread, - const FunctorT& functor, - uint32 id = 0) { + void AsyncInvoke(Thread* thread, const FunctorT& functor, uint32_t id = 0) { scoped_refptr closure( new RefCountedObject >(functor)); DoInvoke(thread, closure, id); @@ -87,8 +85,8 @@ class AsyncInvoker : public MessageHandler { template void AsyncInvokeDelayed(Thread* thread, const FunctorT& functor, - uint32 delay_ms, - uint32 id = 0) { + uint32_t delay_ms, + uint32_t id = 0) { scoped_refptr closure( new RefCountedObject >(functor)); DoInvokeDelayed(thread, closure, delay_ms, id); @@ -100,7 +98,7 @@ class AsyncInvoker : public MessageHandler { const FunctorT& functor, void (HostT::*callback)(ReturnT), HostT* callback_host, - uint32 id = 0) { + uint32_t id = 0) { scoped_refptr closure( new RefCountedObject >( this, Thread::Current(), functor, callback, callback_host)); @@ -114,7 +112,7 @@ class AsyncInvoker : public MessageHandler { const FunctorT& functor, void (HostT::*callback)(), HostT* callback_host, - uint32 id = 0) { + uint32_t id = 0) { scoped_refptr closure( new RefCountedObject >( this, Thread::Current(), functor, callback, callback_host)); @@ -126,19 +124,20 @@ class AsyncInvoker : public MessageHandler { // before returning. Optionally filter by message id. // The destructor will not wait for outstanding calls, so if that // behavior is desired, call Flush() before destroying this object. - void Flush(Thread* thread, uint32 id = MQID_ANY); + void Flush(Thread* thread, uint32_t id = MQID_ANY); // Signaled when this object is destructed. sigslot::signal0<> SignalInvokerDestroyed; private: void OnMessage(Message* msg) override; - void DoInvoke(Thread* thread, const scoped_refptr& closure, - uint32 id); + void DoInvoke(Thread* thread, + const scoped_refptr& closure, + uint32_t id); void DoInvokeDelayed(Thread* thread, const scoped_refptr& closure, - uint32 delay_ms, - uint32 id); + uint32_t delay_ms, + uint32_t id); bool destroying_; RTC_DISALLOW_COPY_AND_ASSIGN(AsyncInvoker); @@ -159,12 +158,12 @@ class GuardedAsyncInvoker : public sigslot::has_slots<> { // complete before returning. Optionally filter by message id. The destructor // will not wait for outstanding calls, so if that behavior is desired, call // Flush() first. Returns false if the thread has died. - bool Flush(uint32 id = MQID_ANY); + bool Flush(uint32_t id = MQID_ANY); // Call |functor| asynchronously with no callback upon completion. Returns // immediately. Returns false if the thread has died. template - bool AsyncInvoke(const FunctorT& functor, uint32 id = 0) { + bool AsyncInvoke(const FunctorT& functor, uint32_t id = 0) { rtc::CritScope cs(&crit_); if (thread_ == nullptr) return false; @@ -176,8 +175,8 @@ class GuardedAsyncInvoker : public sigslot::has_slots<> { // completion. Returns immediately. Returns false if the thread has died. template bool AsyncInvokeDelayed(const FunctorT& functor, - uint32 delay_ms, - uint32 id = 0) { + uint32_t delay_ms, + uint32_t id = 0) { rtc::CritScope cs(&crit_); if (thread_ == nullptr) return false; @@ -192,7 +191,7 @@ class GuardedAsyncInvoker : public sigslot::has_slots<> { bool AsyncInvoke(const FunctorT& functor, void (HostT::*callback)(ReturnT), HostT* callback_host, - uint32 id = 0) { + uint32_t id = 0) { rtc::CritScope cs(&crit_); if (thread_ == nullptr) return false; @@ -207,7 +206,7 @@ class GuardedAsyncInvoker : public sigslot::has_slots<> { bool AsyncInvoke(const FunctorT& functor, void (HostT::*callback)(), HostT* callback_host, - uint32 id = 0) { + uint32_t id = 0) { rtc::CritScope cs(&crit_); if (thread_ == nullptr) return false; diff --git a/webrtc/base/asyncpacketsocket.h b/webrtc/base/asyncpacketsocket.h index f0c221da1d..07cacf751f 100644 --- a/webrtc/base/asyncpacketsocket.h +++ b/webrtc/base/asyncpacketsocket.h @@ -28,7 +28,7 @@ struct PacketTimeUpdateParams { int rtp_sendtime_extension_id; // extension header id present in packet. std::vector srtp_auth_key; // Authentication key. int srtp_auth_tag_len; // Authentication tag length. - int64 srtp_packet_index; // Required for Rtp Packet authentication. + int64_t srtp_packet_index; // Required for Rtp Packet authentication. }; // This structure holds meta information for the packet which is about to send @@ -45,19 +45,19 @@ struct PacketOptions { // received by socket. struct PacketTime { PacketTime() : timestamp(-1), not_before(-1) {} - PacketTime(int64 timestamp, int64 not_before) - : timestamp(timestamp), not_before(not_before) { - } + PacketTime(int64_t timestamp, int64_t not_before) + : timestamp(timestamp), not_before(not_before) {} - int64 timestamp; // Receive time after socket delivers the data. - int64 not_before; // Earliest possible time the data could have arrived, - // indicating the potential error in the |timestamp| value, - // in case the system, is busy. For example, the time of - // the last select() call. - // If unknown, this value will be set to zero. + int64_t timestamp; // Receive time after socket delivers the data. + + // Earliest possible time the data could have arrived, indicating the + // potential error in the |timestamp| value, in case the system, is busy. For + // example, the time of the last select() call. + // If unknown, this value will be set to zero. + int64_t not_before; }; -inline PacketTime CreatePacketTime(int64 not_before) { +inline PacketTime CreatePacketTime(int64_t not_before) { return PacketTime(TimeMicros(), not_before); } diff --git a/webrtc/base/asyncsocket.cc b/webrtc/base/asyncsocket.cc index dc0de3dd48..db451c6382 100644 --- a/webrtc/base/asyncsocket.cc +++ b/webrtc/base/asyncsocket.cc @@ -96,7 +96,7 @@ AsyncSocket::ConnState AsyncSocketAdapter::GetState() const { return socket_->GetState(); } -int AsyncSocketAdapter::EstimateMTU(uint16* mtu) { +int AsyncSocketAdapter::EstimateMTU(uint16_t* mtu) { return socket_->EstimateMTU(mtu); } diff --git a/webrtc/base/asyncsocket.h b/webrtc/base/asyncsocket.h index 37bad4c831..7a859be962 100644 --- a/webrtc/base/asyncsocket.h +++ b/webrtc/base/asyncsocket.h @@ -64,7 +64,7 @@ class AsyncSocketAdapter : public AsyncSocket, public sigslot::has_slots<> { int GetError() const override; void SetError(int error) override; ConnState GetState() const override; - int EstimateMTU(uint16* mtu) override; + int EstimateMTU(uint16_t* mtu) override; int GetOption(Option opt, int* value) override; int SetOption(Option opt, int value) override; diff --git a/webrtc/base/asynctcpsocket.cc b/webrtc/base/asynctcpsocket.cc index 97d1e17176..66fd3f1e00 100644 --- a/webrtc/base/asynctcpsocket.cc +++ b/webrtc/base/asynctcpsocket.cc @@ -24,7 +24,7 @@ namespace rtc { static const size_t kMaxPacketSize = 64 * 1024; -typedef uint16 PacketLength; +typedef uint16_t PacketLength; static const size_t kPacketLenSize = sizeof(PacketLength); static const size_t kBufSize = kMaxPacketSize + kPacketLenSize; diff --git a/webrtc/base/autodetectproxy.cc b/webrtc/base/autodetectproxy.cc index 4ebc2d4da1..22950fb2b3 100644 --- a/webrtc/base/autodetectproxy.cc +++ b/webrtc/base/autodetectproxy.cc @@ -102,7 +102,7 @@ void AutoDetectProxy::OnMessage(Message *msg) { IPAddress address_ip = proxy().address.ipaddr(); - uint16 address_port = proxy().address.port(); + uint16_t address_port = proxy().address.port(); char autoconfig_url[kSavedStringLimit]; SaveStringToStack(autoconfig_url, diff --git a/webrtc/base/autodetectproxy_unittest.cc b/webrtc/base/autodetectproxy_unittest.cc index 4a2688265c..bc57304c0a 100644 --- a/webrtc/base/autodetectproxy_unittest.cc +++ b/webrtc/base/autodetectproxy_unittest.cc @@ -19,7 +19,7 @@ namespace rtc { static const char kUserAgent[] = ""; static const char kPath[] = "/"; static const char kHost[] = "relay.google.com"; -static const uint16 kPort = 443; +static const uint16_t kPort = 443; static const bool kSecure = true; // At most, AutoDetectProxy should take ~6 seconds. Each connect step is // allotted 2 seconds, with the initial resolution + connect given an @@ -37,10 +37,10 @@ class AutoDetectProxyTest : public testing::Test, public sigslot::has_slots<> { AutoDetectProxyTest() : auto_detect_proxy_(NULL), done_(false) {} protected: - bool Create(const std::string &user_agent, - const std::string &path, - const std::string &host, - uint16 port, + bool Create(const std::string& user_agent, + const std::string& path, + const std::string& host, + uint16_t port, bool secure, bool startnow) { auto_detect_proxy_ = new AutoDetectProxy(user_agent); diff --git a/webrtc/base/bandwidthsmoother.cc b/webrtc/base/bandwidthsmoother.cc index 09c7b9941b..d48c12e6c6 100644 --- a/webrtc/base/bandwidthsmoother.cc +++ b/webrtc/base/bandwidthsmoother.cc @@ -16,7 +16,7 @@ namespace rtc { BandwidthSmoother::BandwidthSmoother(int initial_bandwidth_guess, - uint32 time_between_increase, + uint32_t time_between_increase, double percent_increase, size_t samples_count_to_average, double min_sample_count_percent) @@ -33,7 +33,7 @@ BandwidthSmoother::~BandwidthSmoother() = default; // Samples a new bandwidth measurement // returns true if the bandwidth estimation changed -bool BandwidthSmoother::Sample(uint32 sample_time, int bandwidth) { +bool BandwidthSmoother::Sample(uint32_t sample_time, int bandwidth) { if (bandwidth < 0) { return false; } diff --git a/webrtc/base/bandwidthsmoother.h b/webrtc/base/bandwidthsmoother.h index dbb4c81558..eae565ead3 100644 --- a/webrtc/base/bandwidthsmoother.h +++ b/webrtc/base/bandwidthsmoother.h @@ -31,7 +31,7 @@ namespace rtc { class BandwidthSmoother { public: BandwidthSmoother(int initial_bandwidth_guess, - uint32 time_between_increase, + uint32_t time_between_increase, double percent_increase, size_t samples_count_to_average, double min_sample_count_percent); @@ -40,16 +40,16 @@ class BandwidthSmoother { // Samples a new bandwidth measurement. // bandwidth is expected to be non-negative. // returns true if the bandwidth estimation changed - bool Sample(uint32 sample_time, int bandwidth); + bool Sample(uint32_t sample_time, int bandwidth); int get_bandwidth_estimation() const { return bandwidth_estimation_; } private: - uint32 time_between_increase_; + uint32_t time_between_increase_; double percent_increase_; - uint32 time_at_last_change_; + uint32_t time_at_last_change_; int bandwidth_estimation_; RollingAccumulator accumulator_; double min_sample_count_percent_; diff --git a/webrtc/base/basictypes_unittest.cc b/webrtc/base/basictypes_unittest.cc index 4e243fdcae..df5ed5e7e5 100644 --- a/webrtc/base/basictypes_unittest.cc +++ b/webrtc/base/basictypes_unittest.cc @@ -14,18 +14,9 @@ namespace rtc { -static_assert(sizeof(int8) == 1, "Unexpected size"); -static_assert(sizeof(uint8) == 1, "Unexpected size"); -static_assert(sizeof(int16) == 2, "Unexpected size"); -static_assert(sizeof(uint16) == 2, "Unexpected size"); -static_assert(sizeof(int32) == 4, "Unexpected size"); -static_assert(sizeof(uint32) == 4, "Unexpected size"); -static_assert(sizeof(int64) == 8, "Unexpected size"); -static_assert(sizeof(uint64) == 8, "Unexpected size"); - TEST(BasicTypesTest, Endian) { - uint16 v16 = 0x1234u; - uint8 first_byte = *reinterpret_cast(&v16); + uint16_t v16 = 0x1234u; + uint8_t first_byte = *reinterpret_cast(&v16); #if defined(RTC_ARCH_CPU_LITTLE_ENDIAN) EXPECT_EQ(0x34u, first_byte); #elif defined(RTC_ARCH_CPU_BIG_ENDIAN) @@ -33,33 +24,6 @@ TEST(BasicTypesTest, Endian) { #endif } -TEST(BasicTypesTest, SizeOfTypes) { - int8 i8 = -1; - uint8 u8 = 1u; - int16 i16 = -1; - uint16 u16 = 1u; - int32 i32 = -1; - uint32 u32 = 1u; - int64 i64 = -1; - uint64 u64 = 1u; - EXPECT_EQ(1u, sizeof(i8)); - EXPECT_EQ(1u, sizeof(u8)); - EXPECT_EQ(2u, sizeof(i16)); - EXPECT_EQ(2u, sizeof(u16)); - EXPECT_EQ(4u, sizeof(i32)); - EXPECT_EQ(4u, sizeof(u32)); - EXPECT_EQ(8u, sizeof(i64)); - EXPECT_EQ(8u, sizeof(u64)); - EXPECT_GT(0, i8); - EXPECT_LT(0u, u8); - EXPECT_GT(0, i16); - EXPECT_LT(0u, u16); - EXPECT_GT(0, i32); - EXPECT_LT(0u, u32); - EXPECT_GT(0, i64); - EXPECT_LT(0u, u64); -} - TEST(BasicTypesTest, SizeOfConstants) { EXPECT_EQ(8u, sizeof(INT64_C(0))); EXPECT_EQ(8u, sizeof(UINT64_C(0))); diff --git a/webrtc/base/bitbuffer_unittest.cc b/webrtc/base/bitbuffer_unittest.cc index b9c348eb0d..99701f7cab 100644 --- a/webrtc/base/bitbuffer_unittest.cc +++ b/webrtc/base/bitbuffer_unittest.cc @@ -16,9 +16,9 @@ namespace rtc { TEST(BitBufferTest, ConsumeBits) { - const uint8 bytes[64] = {0}; + const uint8_t bytes[64] = {0}; BitBuffer buffer(bytes, 32); - uint64 total_bits = 32 * 8; + uint64_t total_bits = 32 * 8; EXPECT_EQ(total_bits, buffer.RemainingBitCount()); EXPECT_TRUE(buffer.ConsumeBits(3)); total_bits -= 3; @@ -38,10 +38,10 @@ TEST(BitBufferTest, ConsumeBits) { } TEST(BitBufferTest, ReadBytesAligned) { - const uint8 bytes[] = {0x0A, 0xBC, 0xDE, 0xF1, 0x23, 0x45, 0x67, 0x89}; - uint8 val8; - uint16 val16; - uint32 val32; + const uint8_t bytes[] = {0x0A, 0xBC, 0xDE, 0xF1, 0x23, 0x45, 0x67, 0x89}; + uint8_t val8; + uint16_t val16; + uint32_t val32; BitBuffer buffer(bytes, 8); EXPECT_TRUE(buffer.ReadUInt8(&val8)); EXPECT_EQ(0x0Au, val8); @@ -54,10 +54,11 @@ TEST(BitBufferTest, ReadBytesAligned) { } TEST(BitBufferTest, ReadBytesOffset4) { - const uint8 bytes[] = {0x0A, 0xBC, 0xDE, 0xF1, 0x23, 0x45, 0x67, 0x89, 0x0A}; - uint8 val8; - uint16 val16; - uint32 val32; + const uint8_t bytes[] = {0x0A, 0xBC, 0xDE, 0xF1, 0x23, + 0x45, 0x67, 0x89, 0x0A}; + uint8_t val8; + uint16_t val16; + uint32_t val32; BitBuffer buffer(bytes, 9); EXPECT_TRUE(buffer.ConsumeBits(4)); @@ -88,11 +89,11 @@ TEST(BitBufferTest, ReadBytesOffset3) { // The bytes. It almost looks like counting down by two at a time, except the // jump at 5->3->0, since that's when the high bit is turned off. - const uint8 bytes[] = {0x1F, 0xDB, 0x97, 0x53, 0x0E, 0xCA, 0x86, 0x42}; + const uint8_t bytes[] = {0x1F, 0xDB, 0x97, 0x53, 0x0E, 0xCA, 0x86, 0x42}; - uint8 val8; - uint16 val16; - uint32 val32; + uint8_t val8; + uint16_t val16; + uint32_t val32; BitBuffer buffer(bytes, 8); EXPECT_TRUE(buffer.ConsumeBits(3)); EXPECT_TRUE(buffer.ReadUInt8(&val8)); @@ -101,7 +102,7 @@ TEST(BitBufferTest, ReadBytesOffset3) { EXPECT_EQ(0xDCBAu, val16); EXPECT_TRUE(buffer.ReadUInt32(&val32)); EXPECT_EQ(0x98765432u, val32); - // 5 bits left unread. Not enough to read a uint8. + // 5 bits left unread. Not enough to read a uint8_t. EXPECT_EQ(5u, buffer.RemainingBitCount()); EXPECT_FALSE(buffer.ReadUInt8(&val8)); } @@ -110,7 +111,7 @@ TEST(BitBufferTest, ReadBits) { // Bit values are: // 0b01001101, // 0b00110010 - const uint8 bytes[] = {0x4D, 0x32}; + const uint8_t bytes[] = {0x4D, 0x32}; uint32_t val; BitBuffer buffer(bytes, 2); EXPECT_TRUE(buffer.ReadBits(&val, 3)); @@ -136,7 +137,7 @@ TEST(BitBufferTest, ReadBits) { } TEST(BitBufferTest, SetOffsetValues) { - uint8 bytes[4] = {0}; + uint8_t bytes[4] = {0}; BitBufferWriter buffer(bytes, 4); size_t byte_offset, bit_offset; @@ -174,31 +175,31 @@ TEST(BitBufferTest, SetOffsetValues) { #endif } -uint64 GolombEncoded(uint32 val) { +uint64_t GolombEncoded(uint32_t val) { val++; - uint32 bit_counter = val; - uint64 bit_count = 0; + uint32_t bit_counter = val; + uint64_t bit_count = 0; while (bit_counter > 0) { bit_count++; bit_counter >>= 1; } - return static_cast(val) << (64 - (bit_count * 2 - 1)); + return static_cast(val) << (64 - (bit_count * 2 - 1)); } TEST(BitBufferTest, GolombUint32Values) { ByteBuffer byteBuffer; byteBuffer.Resize(16); - BitBuffer buffer(reinterpret_cast(byteBuffer.Data()), + BitBuffer buffer(reinterpret_cast(byteBuffer.Data()), byteBuffer.Capacity()); - // Test over the uint32 range with a large enough step that the test doesn't + // Test over the uint32_t range with a large enough step that the test doesn't // take forever. Around 20,000 iterations should do. - const int kStep = std::numeric_limits::max() / 20000; - for (uint32 i = 0; i < std::numeric_limits::max() - kStep; + const int kStep = std::numeric_limits::max() / 20000; + for (uint32_t i = 0; i < std::numeric_limits::max() - kStep; i += kStep) { - uint64 encoded_val = GolombEncoded(i); + uint64_t encoded_val = GolombEncoded(i); byteBuffer.Clear(); byteBuffer.WriteUInt64(encoded_val); - uint32 decoded_val; + uint32_t decoded_val; EXPECT_TRUE(buffer.Seek(0, 0)); EXPECT_TRUE(buffer.ReadExponentialGolomb(&decoded_val)); EXPECT_EQ(i, decoded_val); @@ -225,11 +226,11 @@ TEST(BitBufferTest, SignedGolombValues) { } TEST(BitBufferTest, NoGolombOverread) { - const uint8 bytes[] = {0x00, 0xFF, 0xFF}; + const uint8_t bytes[] = {0x00, 0xFF, 0xFF}; // Make sure the bit buffer correctly enforces byte length on golomb reads. // If it didn't, the above buffer would be valid at 3 bytes. BitBuffer buffer(bytes, 1); - uint32 decoded_val; + uint32_t decoded_val; EXPECT_FALSE(buffer.ReadExponentialGolomb(&decoded_val)); BitBuffer longer_buffer(bytes, 2); @@ -243,7 +244,7 @@ TEST(BitBufferTest, NoGolombOverread) { } TEST(BitBufferWriterTest, SymmetricReadWrite) { - uint8 bytes[16] = {0}; + uint8_t bytes[16] = {0}; BitBufferWriter buffer(bytes, 4); // Write some bit data at various sizes. @@ -257,7 +258,7 @@ TEST(BitBufferWriterTest, SymmetricReadWrite) { EXPECT_FALSE(buffer.WriteBits(1, 1)); EXPECT_TRUE(buffer.Seek(0, 0)); - uint32 val; + uint32_t val; EXPECT_TRUE(buffer.ReadBits(&val, 3)); EXPECT_EQ(0x2u, val); EXPECT_TRUE(buffer.ReadBits(&val, 2)); @@ -275,7 +276,7 @@ TEST(BitBufferWriterTest, SymmetricReadWrite) { } TEST(BitBufferWriterTest, SymmetricBytesMisaligned) { - uint8 bytes[16] = {0}; + uint8_t bytes[16] = {0}; BitBufferWriter buffer(bytes, 16); // Offset 3, to get things misaligned. @@ -285,9 +286,9 @@ TEST(BitBufferWriterTest, SymmetricBytesMisaligned) { EXPECT_TRUE(buffer.WriteUInt32(0x789ABCDEu)); buffer.Seek(0, 3); - uint8 val8; - uint16 val16; - uint32 val32; + uint8_t val8; + uint16_t val16; + uint32_t val32; EXPECT_TRUE(buffer.ReadUInt8(&val8)); EXPECT_EQ(0x12u, val8); EXPECT_TRUE(buffer.ReadUInt16(&val16)); @@ -298,22 +299,22 @@ TEST(BitBufferWriterTest, SymmetricBytesMisaligned) { TEST(BitBufferWriterTest, SymmetricGolomb) { char test_string[] = "my precious"; - uint8 bytes[64] = {0}; + uint8_t bytes[64] = {0}; BitBufferWriter buffer(bytes, 64); for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) { EXPECT_TRUE(buffer.WriteExponentialGolomb(test_string[i])); } buffer.Seek(0, 0); for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) { - uint32 val; + uint32_t val; EXPECT_TRUE(buffer.ReadExponentialGolomb(&val)); - EXPECT_LE(val, std::numeric_limits::max()); + EXPECT_LE(val, std::numeric_limits::max()); EXPECT_EQ(test_string[i], static_cast(val)); } } TEST(BitBufferWriterTest, WriteClearsBits) { - uint8 bytes[] = {0xFF, 0xFF}; + uint8_t bytes[] = {0xFF, 0xFF}; BitBufferWriter buffer(bytes, 2); EXPECT_TRUE(buffer.ConsumeBits(3)); EXPECT_TRUE(buffer.WriteBits(0, 1)); diff --git a/webrtc/base/bytebuffer.cc b/webrtc/base/bytebuffer.cc index 4b6a1d8d62..8bc1f23670 100644 --- a/webrtc/base/bytebuffer.cc +++ b/webrtc/base/bytebuffer.cc @@ -66,16 +66,16 @@ ByteBuffer::~ByteBuffer() { delete[] bytes_; } -bool ByteBuffer::ReadUInt8(uint8* val) { +bool ByteBuffer::ReadUInt8(uint8_t* val) { if (!val) return false; return ReadBytes(reinterpret_cast(val), 1); } -bool ByteBuffer::ReadUInt16(uint16* val) { +bool ByteBuffer::ReadUInt16(uint16_t* val) { if (!val) return false; - uint16 v; + uint16_t v; if (!ReadBytes(reinterpret_cast(&v), 2)) { return false; } else { @@ -84,10 +84,10 @@ bool ByteBuffer::ReadUInt16(uint16* val) { } } -bool ByteBuffer::ReadUInt24(uint32* val) { +bool ByteBuffer::ReadUInt24(uint32_t* val) { if (!val) return false; - uint32 v = 0; + uint32_t v = 0; char* read_into = reinterpret_cast(&v); if (byte_order_ == ORDER_NETWORK || IsHostBigEndian()) { ++read_into; @@ -101,10 +101,10 @@ bool ByteBuffer::ReadUInt24(uint32* val) { } } -bool ByteBuffer::ReadUInt32(uint32* val) { +bool ByteBuffer::ReadUInt32(uint32_t* val) { if (!val) return false; - uint32 v; + uint32_t v; if (!ReadBytes(reinterpret_cast(&v), 4)) { return false; } else { @@ -113,10 +113,10 @@ bool ByteBuffer::ReadUInt32(uint32* val) { } } -bool ByteBuffer::ReadUInt64(uint64* val) { +bool ByteBuffer::ReadUInt64(uint64_t* val) { if (!val) return false; - uint64 v; + uint64_t v; if (!ReadBytes(reinterpret_cast(&v), 8)) { return false; } else { @@ -147,17 +147,17 @@ bool ByteBuffer::ReadBytes(char* val, size_t len) { } } -void ByteBuffer::WriteUInt8(uint8 val) { +void ByteBuffer::WriteUInt8(uint8_t val) { WriteBytes(reinterpret_cast(&val), 1); } -void ByteBuffer::WriteUInt16(uint16 val) { - uint16 v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork16(val) : val; +void ByteBuffer::WriteUInt16(uint16_t val) { + uint16_t v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork16(val) : val; WriteBytes(reinterpret_cast(&v), 2); } -void ByteBuffer::WriteUInt24(uint32 val) { - uint32 v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork32(val) : val; +void ByteBuffer::WriteUInt24(uint32_t val) { + uint32_t v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork32(val) : val; char* start = reinterpret_cast(&v); if (byte_order_ == ORDER_NETWORK || IsHostBigEndian()) { ++start; @@ -165,13 +165,13 @@ void ByteBuffer::WriteUInt24(uint32 val) { WriteBytes(start, 3); } -void ByteBuffer::WriteUInt32(uint32 val) { - uint32 v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork32(val) : val; +void ByteBuffer::WriteUInt32(uint32_t val) { + uint32_t v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork32(val) : val; WriteBytes(reinterpret_cast(&v), 4); } -void ByteBuffer::WriteUInt64(uint64 val) { - uint64 v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork64(val) : val; +void ByteBuffer::WriteUInt64(uint64_t val) { + uint64_t v = (byte_order_ == ORDER_NETWORK) ? HostToNetwork64(val) : val; WriteBytes(reinterpret_cast(&v), 8); } diff --git a/webrtc/base/bytebuffer.h b/webrtc/base/bytebuffer.h index 6cab2a829f..ad2e552ed6 100644 --- a/webrtc/base/bytebuffer.h +++ b/webrtc/base/bytebuffer.h @@ -47,11 +47,11 @@ class ByteBuffer { // Read a next value from the buffer. Return false if there isn't // enough data left for the specified type. - bool ReadUInt8(uint8* val); - bool ReadUInt16(uint16* val); - bool ReadUInt24(uint32* val); - bool ReadUInt32(uint32* val); - bool ReadUInt64(uint64* val); + bool ReadUInt8(uint8_t* val); + bool ReadUInt16(uint16_t* val); + bool ReadUInt24(uint32_t* val); + bool ReadUInt32(uint32_t* val); + bool ReadUInt64(uint64_t* val); bool ReadBytes(char* val, size_t len); // Appends next |len| bytes from the buffer to |val|. Returns false @@ -60,11 +60,11 @@ class ByteBuffer { // Write value to the buffer. Resizes the buffer when it is // neccessary. - void WriteUInt8(uint8 val); - void WriteUInt16(uint16 val); - void WriteUInt24(uint32 val); - void WriteUInt32(uint32 val); - void WriteUInt64(uint64 val); + void WriteUInt8(uint8_t val); + void WriteUInt16(uint16_t val); + void WriteUInt24(uint32_t val); + void WriteUInt32(uint32_t val); + void WriteUInt64(uint64_t val); void WriteString(const std::string& val); void WriteBytes(const char* val, size_t len); diff --git a/webrtc/base/bytebuffer_unittest.cc b/webrtc/base/bytebuffer_unittest.cc index f4b0504efc..56b0e055f5 100644 --- a/webrtc/base/bytebuffer_unittest.cc +++ b/webrtc/base/bytebuffer_unittest.cc @@ -16,9 +16,9 @@ namespace rtc { TEST(ByteBufferTest, TestByteOrder) { - uint16 n16 = 1; - uint32 n32 = 1; - uint64 n64 = 1; + uint16_t n16 = 1; + uint32_t n32 = 1; + uint64_t n64 = 1; EXPECT_EQ(n16, NetworkToHost16(HostToNetwork16(n16))); EXPECT_EQ(n32, NetworkToHost32(HostToNetwork32(n32))); @@ -117,45 +117,45 @@ TEST(ByteBufferTest, TestReadWriteBuffer) { for (size_t i = 0; i < ARRAY_SIZE(orders); i++) { ByteBuffer buffer(orders[i]); EXPECT_EQ(orders[i], buffer.Order()); - uint8 ru8; + uint8_t ru8; EXPECT_FALSE(buffer.ReadUInt8(&ru8)); - // Write and read uint8. - uint8 wu8 = 1; + // Write and read uint8_t. + uint8_t wu8 = 1; buffer.WriteUInt8(wu8); EXPECT_TRUE(buffer.ReadUInt8(&ru8)); EXPECT_EQ(wu8, ru8); EXPECT_EQ(0U, buffer.Length()); - // Write and read uint16. - uint16 wu16 = (1 << 8) + 1; + // Write and read uint16_t. + uint16_t wu16 = (1 << 8) + 1; buffer.WriteUInt16(wu16); - uint16 ru16; + uint16_t ru16; EXPECT_TRUE(buffer.ReadUInt16(&ru16)); EXPECT_EQ(wu16, ru16); EXPECT_EQ(0U, buffer.Length()); // Write and read uint24. - uint32 wu24 = (3 << 16) + (2 << 8) + 1; + uint32_t wu24 = (3 << 16) + (2 << 8) + 1; buffer.WriteUInt24(wu24); - uint32 ru24; + uint32_t ru24; EXPECT_TRUE(buffer.ReadUInt24(&ru24)); EXPECT_EQ(wu24, ru24); EXPECT_EQ(0U, buffer.Length()); - // Write and read uint32. - uint32 wu32 = (4 << 24) + (3 << 16) + (2 << 8) + 1; + // Write and read uint32_t. + uint32_t wu32 = (4 << 24) + (3 << 16) + (2 << 8) + 1; buffer.WriteUInt32(wu32); - uint32 ru32; + uint32_t ru32; EXPECT_TRUE(buffer.ReadUInt32(&ru32)); EXPECT_EQ(wu32, ru32); EXPECT_EQ(0U, buffer.Length()); - // Write and read uint64. - uint32 another32 = (8 << 24) + (7 << 16) + (6 << 8) + 5; - uint64 wu64 = (static_cast(another32) << 32) + wu32; + // Write and read uint64_t. + uint32_t another32 = (8 << 24) + (7 << 16) + (6 << 8) + 5; + uint64_t wu64 = (static_cast(another32) << 32) + wu32; buffer.WriteUInt64(wu64); - uint64 ru64; + uint64_t ru64; EXPECT_TRUE(buffer.ReadUInt64(&ru64)); EXPECT_EQ(wu64, ru64); EXPECT_EQ(0U, buffer.Length()); diff --git a/webrtc/base/byteorder.h b/webrtc/base/byteorder.h index d907d9e412..d579e6e185 100644 --- a/webrtc/base/byteorder.h +++ b/webrtc/base/byteorder.h @@ -27,104 +27,102 @@ namespace rtc { // TODO: Optimized versions, with direct read/writes of // integers in host-endian format, when the platform supports it. -inline void Set8(void* memory, size_t offset, uint8 v) { - static_cast(memory)[offset] = v; +inline void Set8(void* memory, size_t offset, uint8_t v) { + static_cast(memory)[offset] = v; } -inline uint8 Get8(const void* memory, size_t offset) { - return static_cast(memory)[offset]; +inline uint8_t Get8(const void* memory, size_t offset) { + return static_cast(memory)[offset]; } -inline void SetBE16(void* memory, uint16 v) { - Set8(memory, 0, static_cast(v >> 8)); - Set8(memory, 1, static_cast(v >> 0)); +inline void SetBE16(void* memory, uint16_t v) { + Set8(memory, 0, static_cast(v >> 8)); + Set8(memory, 1, static_cast(v >> 0)); } -inline void SetBE32(void* memory, uint32 v) { - Set8(memory, 0, static_cast(v >> 24)); - Set8(memory, 1, static_cast(v >> 16)); - Set8(memory, 2, static_cast(v >> 8)); - Set8(memory, 3, static_cast(v >> 0)); +inline void SetBE32(void* memory, uint32_t v) { + Set8(memory, 0, static_cast(v >> 24)); + Set8(memory, 1, static_cast(v >> 16)); + Set8(memory, 2, static_cast(v >> 8)); + Set8(memory, 3, static_cast(v >> 0)); } -inline void SetBE64(void* memory, uint64 v) { - Set8(memory, 0, static_cast(v >> 56)); - Set8(memory, 1, static_cast(v >> 48)); - Set8(memory, 2, static_cast(v >> 40)); - Set8(memory, 3, static_cast(v >> 32)); - Set8(memory, 4, static_cast(v >> 24)); - Set8(memory, 5, static_cast(v >> 16)); - Set8(memory, 6, static_cast(v >> 8)); - Set8(memory, 7, static_cast(v >> 0)); +inline void SetBE64(void* memory, uint64_t v) { + Set8(memory, 0, static_cast(v >> 56)); + Set8(memory, 1, static_cast(v >> 48)); + Set8(memory, 2, static_cast(v >> 40)); + Set8(memory, 3, static_cast(v >> 32)); + Set8(memory, 4, static_cast(v >> 24)); + Set8(memory, 5, static_cast(v >> 16)); + Set8(memory, 6, static_cast(v >> 8)); + Set8(memory, 7, static_cast(v >> 0)); } -inline uint16 GetBE16(const void* memory) { - return static_cast((Get8(memory, 0) << 8) | - (Get8(memory, 1) << 0)); +inline uint16_t GetBE16(const void* memory) { + return static_cast((Get8(memory, 0) << 8) | (Get8(memory, 1) << 0)); } -inline uint32 GetBE32(const void* memory) { - return (static_cast(Get8(memory, 0)) << 24) | - (static_cast(Get8(memory, 1)) << 16) | - (static_cast(Get8(memory, 2)) << 8) | - (static_cast(Get8(memory, 3)) << 0); +inline uint32_t GetBE32(const void* memory) { + return (static_cast(Get8(memory, 0)) << 24) | + (static_cast(Get8(memory, 1)) << 16) | + (static_cast(Get8(memory, 2)) << 8) | + (static_cast(Get8(memory, 3)) << 0); } -inline uint64 GetBE64(const void* memory) { - return (static_cast(Get8(memory, 0)) << 56) | - (static_cast(Get8(memory, 1)) << 48) | - (static_cast(Get8(memory, 2)) << 40) | - (static_cast(Get8(memory, 3)) << 32) | - (static_cast(Get8(memory, 4)) << 24) | - (static_cast(Get8(memory, 5)) << 16) | - (static_cast(Get8(memory, 6)) << 8) | - (static_cast(Get8(memory, 7)) << 0); +inline uint64_t GetBE64(const void* memory) { + return (static_cast(Get8(memory, 0)) << 56) | + (static_cast(Get8(memory, 1)) << 48) | + (static_cast(Get8(memory, 2)) << 40) | + (static_cast(Get8(memory, 3)) << 32) | + (static_cast(Get8(memory, 4)) << 24) | + (static_cast(Get8(memory, 5)) << 16) | + (static_cast(Get8(memory, 6)) << 8) | + (static_cast(Get8(memory, 7)) << 0); } -inline void SetLE16(void* memory, uint16 v) { - Set8(memory, 0, static_cast(v >> 0)); - Set8(memory, 1, static_cast(v >> 8)); +inline void SetLE16(void* memory, uint16_t v) { + Set8(memory, 0, static_cast(v >> 0)); + Set8(memory, 1, static_cast(v >> 8)); } -inline void SetLE32(void* memory, uint32 v) { - Set8(memory, 0, static_cast(v >> 0)); - Set8(memory, 1, static_cast(v >> 8)); - Set8(memory, 2, static_cast(v >> 16)); - Set8(memory, 3, static_cast(v >> 24)); +inline void SetLE32(void* memory, uint32_t v) { + Set8(memory, 0, static_cast(v >> 0)); + Set8(memory, 1, static_cast(v >> 8)); + Set8(memory, 2, static_cast(v >> 16)); + Set8(memory, 3, static_cast(v >> 24)); } -inline void SetLE64(void* memory, uint64 v) { - Set8(memory, 0, static_cast(v >> 0)); - Set8(memory, 1, static_cast(v >> 8)); - Set8(memory, 2, static_cast(v >> 16)); - Set8(memory, 3, static_cast(v >> 24)); - Set8(memory, 4, static_cast(v >> 32)); - Set8(memory, 5, static_cast(v >> 40)); - Set8(memory, 6, static_cast(v >> 48)); - Set8(memory, 7, static_cast(v >> 56)); +inline void SetLE64(void* memory, uint64_t v) { + Set8(memory, 0, static_cast(v >> 0)); + Set8(memory, 1, static_cast(v >> 8)); + Set8(memory, 2, static_cast(v >> 16)); + Set8(memory, 3, static_cast(v >> 24)); + Set8(memory, 4, static_cast(v >> 32)); + Set8(memory, 5, static_cast(v >> 40)); + Set8(memory, 6, static_cast(v >> 48)); + Set8(memory, 7, static_cast(v >> 56)); } -inline uint16 GetLE16(const void* memory) { - return static_cast((Get8(memory, 0) << 0) | - (Get8(memory, 1) << 8)); +inline uint16_t GetLE16(const void* memory) { + return static_cast((Get8(memory, 0) << 0) | (Get8(memory, 1) << 8)); } -inline uint32 GetLE32(const void* memory) { - return (static_cast(Get8(memory, 0)) << 0) | - (static_cast(Get8(memory, 1)) << 8) | - (static_cast(Get8(memory, 2)) << 16) | - (static_cast(Get8(memory, 3)) << 24); +inline uint32_t GetLE32(const void* memory) { + return (static_cast(Get8(memory, 0)) << 0) | + (static_cast(Get8(memory, 1)) << 8) | + (static_cast(Get8(memory, 2)) << 16) | + (static_cast(Get8(memory, 3)) << 24); } -inline uint64 GetLE64(const void* memory) { - return (static_cast(Get8(memory, 0)) << 0) | - (static_cast(Get8(memory, 1)) << 8) | - (static_cast(Get8(memory, 2)) << 16) | - (static_cast(Get8(memory, 3)) << 24) | - (static_cast(Get8(memory, 4)) << 32) | - (static_cast(Get8(memory, 5)) << 40) | - (static_cast(Get8(memory, 6)) << 48) | - (static_cast(Get8(memory, 7)) << 56); +inline uint64_t GetLE64(const void* memory) { + return (static_cast(Get8(memory, 0)) << 0) | + (static_cast(Get8(memory, 1)) << 8) | + (static_cast(Get8(memory, 2)) << 16) | + (static_cast(Get8(memory, 3)) << 24) | + (static_cast(Get8(memory, 4)) << 32) | + (static_cast(Get8(memory, 5)) << 40) | + (static_cast(Get8(memory, 6)) << 48) | + (static_cast(Get8(memory, 7)) << 56); } // Check if the current host is big endian. @@ -133,33 +131,33 @@ inline bool IsHostBigEndian() { return 0 == *reinterpret_cast(&number); } -inline uint16 HostToNetwork16(uint16 n) { - uint16 result; +inline uint16_t HostToNetwork16(uint16_t n) { + uint16_t result; SetBE16(&result, n); return result; } -inline uint32 HostToNetwork32(uint32 n) { - uint32 result; +inline uint32_t HostToNetwork32(uint32_t n) { + uint32_t result; SetBE32(&result, n); return result; } -inline uint64 HostToNetwork64(uint64 n) { - uint64 result; +inline uint64_t HostToNetwork64(uint64_t n) { + uint64_t result; SetBE64(&result, n); return result; } -inline uint16 NetworkToHost16(uint16 n) { +inline uint16_t NetworkToHost16(uint16_t n) { return GetBE16(&n); } -inline uint32 NetworkToHost32(uint32 n) { +inline uint32_t NetworkToHost32(uint32_t n) { return GetBE32(&n); } -inline uint64 NetworkToHost64(uint64 n) { +inline uint64_t NetworkToHost64(uint64_t n) { return GetBE64(&n); } diff --git a/webrtc/base/byteorder_unittest.cc b/webrtc/base/byteorder_unittest.cc index f4e7df3b71..c3135aa7c9 100644 --- a/webrtc/base/byteorder_unittest.cc +++ b/webrtc/base/byteorder_unittest.cc @@ -17,7 +17,7 @@ namespace rtc { // Test memory set functions put values into memory in expected order. TEST(ByteOrderTest, TestSet) { - uint8 buf[8] = { 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u }; + uint8_t buf[8] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; Set8(buf, 0, 0xfb); Set8(buf, 1, 0x12); EXPECT_EQ(0xfb, buf[0]); @@ -60,7 +60,7 @@ TEST(ByteOrderTest, TestSet) { // Test memory get functions get values from memory in expected order. TEST(ByteOrderTest, TestGet) { - uint8 buf[8]; + uint8_t buf[8]; buf[0] = 0x01u; buf[1] = 0x23u; buf[2] = 0x45u; diff --git a/webrtc/base/crc32.cc b/webrtc/base/crc32.cc index d643a25a4b..eae338ad16 100644 --- a/webrtc/base/crc32.cc +++ b/webrtc/base/crc32.cc @@ -18,14 +18,14 @@ namespace rtc { // CRC32 polynomial, in reversed form. // See RFC 1952, or http://en.wikipedia.org/wiki/Cyclic_redundancy_check -static const uint32 kCrc32Polynomial = 0xEDB88320; -static uint32 kCrc32Table[256] = { 0 }; +static const uint32_t kCrc32Polynomial = 0xEDB88320; +static uint32_t kCrc32Table[256] = {0}; static void EnsureCrc32TableInited() { if (kCrc32Table[ARRAY_SIZE(kCrc32Table) - 1]) return; // already inited - for (uint32 i = 0; i < ARRAY_SIZE(kCrc32Table); ++i) { - uint32 c = i; + for (uint32_t i = 0; i < ARRAY_SIZE(kCrc32Table); ++i) { + uint32_t c = i; for (size_t j = 0; j < 8; ++j) { if (c & 1) { c = kCrc32Polynomial ^ (c >> 1); @@ -37,11 +37,11 @@ static void EnsureCrc32TableInited() { } } -uint32 UpdateCrc32(uint32 start, const void* buf, size_t len) { +uint32_t UpdateCrc32(uint32_t start, const void* buf, size_t len) { EnsureCrc32TableInited(); - uint32 c = start ^ 0xFFFFFFFF; - const uint8* u = static_cast(buf); + uint32_t c = start ^ 0xFFFFFFFF; + const uint8_t* u = static_cast(buf); for (size_t i = 0; i < len; ++i) { c = kCrc32Table[(c ^ u[i]) & 0xFF] ^ (c >> 8); } diff --git a/webrtc/base/crc32.h b/webrtc/base/crc32.h index 99b4cac894..9661876298 100644 --- a/webrtc/base/crc32.h +++ b/webrtc/base/crc32.h @@ -19,13 +19,13 @@ namespace rtc { // Updates a CRC32 checksum with |len| bytes from |buf|. |initial| holds the // checksum result from the previous update; for the first call, it should be 0. -uint32 UpdateCrc32(uint32 initial, const void* buf, size_t len); +uint32_t UpdateCrc32(uint32_t initial, const void* buf, size_t len); // Computes a CRC32 checksum using |len| bytes from |buf|. -inline uint32 ComputeCrc32(const void* buf, size_t len) { +inline uint32_t ComputeCrc32(const void* buf, size_t len) { return UpdateCrc32(0, buf, len); } -inline uint32 ComputeCrc32(const std::string& str) { +inline uint32_t ComputeCrc32(const std::string& str) { return ComputeCrc32(str.c_str(), str.size()); } diff --git a/webrtc/base/crc32_unittest.cc b/webrtc/base/crc32_unittest.cc index 0bfdeeea0d..6da5c32378 100644 --- a/webrtc/base/crc32_unittest.cc +++ b/webrtc/base/crc32_unittest.cc @@ -25,7 +25,7 @@ TEST(Crc32Test, TestBasic) { TEST(Crc32Test, TestMultipleUpdates) { std::string input = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; - uint32 c = 0; + uint32_t c = 0; for (size_t i = 0; i < input.size(); ++i) { c = UpdateCrc32(c, &input[i], 1); } diff --git a/webrtc/base/dbus_unittest.cc b/webrtc/base/dbus_unittest.cc index 505ddbbc8d..17752f143f 100644 --- a/webrtc/base/dbus_unittest.cc +++ b/webrtc/base/dbus_unittest.cc @@ -18,7 +18,7 @@ namespace rtc { #define SIG_NAME "NameAcquired" -static const uint32 kTimeoutMs = 5000U; +static const uint32_t kTimeoutMs = 5000U; class DBusSigFilterTest : public DBusSigFilter { public: diff --git a/webrtc/base/faketaskrunner.h b/webrtc/base/faketaskrunner.h index 5408ab8b2c..88e48261b3 100644 --- a/webrtc/base/faketaskrunner.h +++ b/webrtc/base/faketaskrunner.h @@ -25,12 +25,12 @@ class FakeTaskRunner : public TaskRunner { virtual void WakeTasks() { RunTasks(); } - virtual int64 CurrentTime() { + virtual int64_t CurrentTime() { // Implement if needed. return current_time_++; } - int64 current_time_; + int64_t current_time_; }; } // namespace rtc diff --git a/webrtc/base/fileutils.h b/webrtc/base/fileutils.h index 8d085ef8ab..bf02571d93 100644 --- a/webrtc/base/fileutils.h +++ b/webrtc/base/fileutils.h @@ -234,7 +234,7 @@ class FilesystemInterface { // Delete the contents of the folder returned by GetAppTempFolder bool CleanAppTempFolder(); - virtual bool GetDiskFreeSpace(const Pathname& path, int64 *freebytes) = 0; + virtual bool GetDiskFreeSpace(const Pathname& path, int64_t* freebytes) = 0; // Returns the absolute path of the current directory. virtual Pathname GetCurrentDirectory() = 0; @@ -379,7 +379,7 @@ class Filesystem { return EnsureDefaultFilesystem()->CleanAppTempFolder(); } - static bool GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { + static bool GetDiskFreeSpace(const Pathname& path, int64_t* freebytes) { return EnsureDefaultFilesystem()->GetDiskFreeSpace(path, freebytes); } diff --git a/webrtc/base/fileutils_mock.h b/webrtc/base/fileutils_mock.h index e9d20a75f4..428d444e12 100644 --- a/webrtc/base/fileutils_mock.h +++ b/webrtc/base/fileutils_mock.h @@ -237,7 +237,7 @@ class FakeFileSystem : public FilesystemInterface { EXPECT_TRUE(false) << "Unsupported operation"; return false; } - bool GetDiskFreeSpace(const Pathname &path, int64 *freebytes) { + bool GetDiskFreeSpace(const Pathname& path, int64_t* freebytes) { EXPECT_TRUE(false) << "Unsupported operation"; return false; } diff --git a/webrtc/base/fileutils_unittest.cc b/webrtc/base/fileutils_unittest.cc index 9076bc7870..6e98e14509 100644 --- a/webrtc/base/fileutils_unittest.cc +++ b/webrtc/base/fileutils_unittest.cc @@ -90,29 +90,29 @@ TEST(FilesystemTest, TestGetDiskFreeSpace) { Pathname path; ASSERT_TRUE(Filesystem::GetAppDataFolder(&path, true)); - int64 free1 = 0; + int64_t free1 = 0; EXPECT_TRUE(Filesystem::IsFolder(path)); EXPECT_FALSE(Filesystem::IsFile(path)); EXPECT_TRUE(Filesystem::GetDiskFreeSpace(path, &free1)); EXPECT_GT(free1, 0); - int64 free2 = 0; + int64_t free2 = 0; path.AppendFolder("this_folder_doesnt_exist"); EXPECT_FALSE(Filesystem::IsFolder(path)); EXPECT_TRUE(Filesystem::IsAbsent(path)); EXPECT_TRUE(Filesystem::GetDiskFreeSpace(path, &free2)); // These should be the same disk, and disk free space should not have changed // by more than 1% between the two calls. - EXPECT_LT(static_cast(free1 * .9), free2); - EXPECT_LT(free2, static_cast(free1 * 1.1)); + EXPECT_LT(static_cast(free1 * .9), free2); + EXPECT_LT(free2, static_cast(free1 * 1.1)); - int64 free3 = 0; + int64_t free3 = 0; path.clear(); EXPECT_TRUE(path.empty()); EXPECT_TRUE(Filesystem::GetDiskFreeSpace(path, &free3)); // Current working directory may not be where exe is. - // EXPECT_LT(static_cast(free1 * .9), free3); - // EXPECT_LT(free3, static_cast(free1 * 1.1)); + // EXPECT_LT(static_cast(free1 * .9), free3); + // EXPECT_LT(free3, static_cast(free1 * 1.1)); EXPECT_GT(free3, 0); } diff --git a/webrtc/base/gunit.h b/webrtc/base/gunit.h index 7431fcf308..c2bc844d5f 100644 --- a/webrtc/base/gunit.h +++ b/webrtc/base/gunit.h @@ -20,22 +20,21 @@ #endif // Wait until "ex" is true, or "timeout" expires. -#define WAIT(ex, timeout) \ - for (uint32 start = rtc::Time(); \ - !(ex) && rtc::Time() < start + timeout;) \ +#define WAIT(ex, timeout) \ + for (uint32_t start = rtc::Time(); !(ex) && rtc::Time() < start + timeout;) \ rtc::Thread::Current()->ProcessMessages(1); // This returns the result of the test in res, so that we don't re-evaluate // the expression in the XXXX_WAIT macros below, since that causes problems // when the expression is only true the first time you check it. -#define WAIT_(ex, timeout, res) \ - do { \ - uint32 start = rtc::Time(); \ - res = (ex); \ +#define WAIT_(ex, timeout, res) \ + do { \ + uint32_t start = rtc::Time(); \ + res = (ex); \ while (!res && rtc::Time() < start + timeout) { \ - rtc::Thread::Current()->ProcessMessages(1); \ - res = (ex); \ - } \ + rtc::Thread::Current()->ProcessMessages(1); \ + res = (ex); \ + } \ } while (0); // The typical EXPECT_XXXX and ASSERT_XXXXs, but done until true or a timeout. diff --git a/webrtc/base/helpers.cc b/webrtc/base/helpers.cc index 0102c10e7b..8e59b6410c 100644 --- a/webrtc/base/helpers.cc +++ b/webrtc/base/helpers.cc @@ -152,7 +152,7 @@ class TestRandomGenerator : public RandomGenerator { bool Init(const void* seed, size_t len) override { return true; } bool Generate(void* buf, size_t len) override { for (size_t i = 0; i < len; ++i) { - static_cast(buf)[i] = static_cast(GetRandom()); + static_cast(buf)[i] = static_cast(GetRandom()); } return true; } @@ -219,7 +219,7 @@ bool CreateRandomString(size_t len, const char* table, int table_size, std::string* str) { str->clear(); - scoped_ptr bytes(new uint8[len]); + scoped_ptr bytes(new uint8_t[len]); if (!Rng().Generate(bytes.get(), len)) { LOG(LS_ERROR) << "Failed to generate random string!"; return false; @@ -241,20 +241,20 @@ bool CreateRandomString(size_t len, const std::string& table, static_cast(table.size()), str); } -uint32 CreateRandomId() { - uint32 id; +uint32_t CreateRandomId() { + uint32_t id; if (!Rng().Generate(&id, sizeof(id))) { LOG(LS_ERROR) << "Failed to generate random id!"; } return id; } -uint64 CreateRandomId64() { - return static_cast(CreateRandomId()) << 32 | CreateRandomId(); +uint64_t CreateRandomId64() { + return static_cast(CreateRandomId()) << 32 | CreateRandomId(); } -uint32 CreateRandomNonZeroId() { - uint32 id; +uint32_t CreateRandomNonZeroId() { + uint32_t id; do { id = CreateRandomId(); } while (id == 0); @@ -262,8 +262,8 @@ uint32 CreateRandomNonZeroId() { } double CreateRandomDouble() { - return CreateRandomId() / (std::numeric_limits::max() + - std::numeric_limits::epsilon()); + return CreateRandomId() / (std::numeric_limits::max() + + std::numeric_limits::epsilon()); } } // namespace rtc diff --git a/webrtc/base/helpers.h b/webrtc/base/helpers.h index e46d12a330..102c08bd0d 100644 --- a/webrtc/base/helpers.h +++ b/webrtc/base/helpers.h @@ -40,13 +40,13 @@ bool CreateRandomString(size_t length, const std::string& table, std::string* str); // Generates a random id. -uint32 CreateRandomId(); +uint32_t CreateRandomId(); // Generates a 64 bit random id. -uint64 CreateRandomId64(); +uint64_t CreateRandomId64(); // Generates a random id > 0. -uint32 CreateRandomNonZeroId(); +uint32_t CreateRandomNonZeroId(); // Generates a random double between 0.0 (inclusive) and 1.0 (exclusive). double CreateRandomDouble(); diff --git a/webrtc/base/httpbase_unittest.cc b/webrtc/base/httpbase_unittest.cc index d4dd7750a6..8d8e09715f 100644 --- a/webrtc/base/httpbase_unittest.cc +++ b/webrtc/base/httpbase_unittest.cc @@ -145,7 +145,7 @@ void HttpBaseTest::VerifyHeaderComplete(size_t event_count, bool empty_doc) { std::string header; EXPECT_EQ(HVER_1_1, data.version); - EXPECT_EQ(static_cast(HC_OK), data.scode); + EXPECT_EQ(static_cast(HC_OK), data.scode); EXPECT_TRUE(data.hasHeader(HH_PROXY_AUTHORIZATION, &header)); EXPECT_EQ("42", header); EXPECT_TRUE(data.hasHeader(HH_CONNECTION, &header)); @@ -215,7 +215,7 @@ void HttpBaseTest::VerifyDocumentStreamOpenEvent() { // HTTP headers haven't arrived yet EXPECT_EQ(0U, events.size()); - EXPECT_EQ(static_cast(HC_INTERNAL_SERVER_ERROR), data.scode); + EXPECT_EQ(static_cast(HC_INTERNAL_SERVER_ERROR), data.scode); LOG_F(LS_VERBOSE) << "Exit"; } diff --git a/webrtc/base/httpcommon-inl.h b/webrtc/base/httpcommon-inl.h index 2f525ce792..d1c0bf01cf 100644 --- a/webrtc/base/httpcommon-inl.h +++ b/webrtc/base/httpcommon-inl.h @@ -52,7 +52,7 @@ void Url::do_set_address(const CTYPE* val, size_t len) { host_.assign(val, colon - val); // Note: In every case, we're guaranteed that colon is followed by a null, // or non-numeric character. - port_ = static_cast(::strtoul(colon + 1, NULL, 10)); + port_ = static_cast(::strtoul(colon + 1, NULL, 10)); // TODO: Consider checking for invalid data following port number. } else { host_.assign(val, len); diff --git a/webrtc/base/httpcommon.cc b/webrtc/base/httpcommon.cc index 138ca42ffc..0c3547e4e7 100644 --- a/webrtc/base/httpcommon.cc +++ b/webrtc/base/httpcommon.cc @@ -149,12 +149,12 @@ bool FromString(HttpHeader& header, const std::string& str) { return Enum::Parse(header, str); } -bool HttpCodeHasBody(uint32 code) { +bool HttpCodeHasBody(uint32_t code) { return !HttpCodeIsInformational(code) && (code != HC_NO_CONTENT) && (code != HC_NOT_MODIFIED); } -bool HttpCodeIsCacheable(uint32 code) { +bool HttpCodeIsCacheable(uint32_t code) { switch (code) { case HC_OK: case HC_NON_AUTHORITATIVE: @@ -599,32 +599,29 @@ HttpResponseData::copy(const HttpResponseData& src) { HttpData::copy(src); } -void -HttpResponseData::set_success(uint32 scode) { +void HttpResponseData::set_success(uint32_t scode) { this->scode = scode; message.clear(); setHeader(HH_CONTENT_LENGTH, "0", false); } -void -HttpResponseData::set_success(const std::string& content_type, - StreamInterface* document, - uint32 scode) { +void HttpResponseData::set_success(const std::string& content_type, + StreamInterface* document, + uint32_t scode) { this->scode = scode; message.erase(message.begin(), message.end()); setContent(content_type, document); } -void -HttpResponseData::set_redirect(const std::string& location, uint32 scode) { +void HttpResponseData::set_redirect(const std::string& location, + uint32_t scode) { this->scode = scode; message.clear(); setHeader(HH_LOCATION, location); setHeader(HH_CONTENT_LENGTH, "0", false); } -void -HttpResponseData::set_error(uint32 scode) { +void HttpResponseData::set_error(uint32_t scode) { this->scode = scode; message.clear(); setHeader(HH_CONTENT_LENGTH, "0", false); @@ -911,7 +908,7 @@ HttpAuthResult HttpAuthenticate( bool specify_credentials = !username.empty(); size_t steps = 0; - //uint32 now = Time(); + // uint32_t now = Time(); NegotiateAuthContext * neg = static_cast(context); if (neg) { diff --git a/webrtc/base/httpcommon.h b/webrtc/base/httpcommon.h index 7b20facaa7..addc1bc30d 100644 --- a/webrtc/base/httpcommon.h +++ b/webrtc/base/httpcommon.h @@ -112,8 +112,8 @@ enum HttpHeader { HH_LAST = HH_WWW_AUTHENTICATE }; -const uint16 HTTP_DEFAULT_PORT = 80; -const uint16 HTTP_SECURE_PORT = 443; +const uint16_t HTTP_DEFAULT_PORT = 80; +const uint16_t HTTP_SECURE_PORT = 443; ////////////////////////////////////////////////////////////////////// // Utility Functions @@ -132,14 +132,24 @@ bool FromString(HttpVerb& verb, const std::string& str); const char* ToString(HttpHeader header); bool FromString(HttpHeader& header, const std::string& str); -inline bool HttpCodeIsInformational(uint32 code) { return ((code / 100) == 1); } -inline bool HttpCodeIsSuccessful(uint32 code) { return ((code / 100) == 2); } -inline bool HttpCodeIsRedirection(uint32 code) { return ((code / 100) == 3); } -inline bool HttpCodeIsClientError(uint32 code) { return ((code / 100) == 4); } -inline bool HttpCodeIsServerError(uint32 code) { return ((code / 100) == 5); } +inline bool HttpCodeIsInformational(uint32_t code) { + return ((code / 100) == 1); +} +inline bool HttpCodeIsSuccessful(uint32_t code) { + return ((code / 100) == 2); +} +inline bool HttpCodeIsRedirection(uint32_t code) { + return ((code / 100) == 3); +} +inline bool HttpCodeIsClientError(uint32_t code) { + return ((code / 100) == 4); +} +inline bool HttpCodeIsServerError(uint32_t code) { + return ((code / 100) == 5); +} -bool HttpCodeHasBody(uint32 code); -bool HttpCodeIsCacheable(uint32 code); +bool HttpCodeHasBody(uint32_t code); +bool HttpCodeIsCacheable(uint32_t code); bool HttpHeaderIsEndToEnd(HttpHeader header); bool HttpHeaderIsCollapsible(HttpHeader header); @@ -163,7 +173,7 @@ bool HttpHasNthAttribute(HttpAttributeList& attributes, // Convert RFC1123 date (DoW, DD Mon YYYY HH:MM:SS TZ) to unix timestamp bool HttpDateToSeconds(const std::string& date, time_t* seconds); -inline uint16 HttpDefaultPort(bool secure) { +inline uint16_t HttpDefaultPort(bool secure) { return secure ? HTTP_SECURE_PORT : HTTP_DEFAULT_PORT; } @@ -196,9 +206,10 @@ public: static int Decode(const string& source, string& destination); Url(const string& url) { do_set_url(url.c_str(), url.size()); } - Url(const string& path, const string& host, uint16 port = HTTP_DEFAULT_PORT) - : host_(host), port_(port), secure_(HTTP_SECURE_PORT == port) - { set_full_path(path); } + Url(const string& path, const string& host, uint16_t port = HTTP_DEFAULT_PORT) + : host_(host), port_(port), secure_(HTTP_SECURE_PORT == port) { + set_full_path(path); + } bool valid() const { return !host_.empty(); } void clear() { @@ -233,8 +244,8 @@ public: void set_host(const string& val) { host_ = val; } const string& host() const { return host_; } - void set_port(uint16 val) { port_ = val; } - uint16 port() const { return port_; } + void set_port(uint16_t val) { port_ = val; } + uint16_t port() const { return port_; } void set_secure(bool val) { secure_ = val; } bool secure() const { return secure_; } @@ -267,7 +278,7 @@ private: void do_get_full_path(string* val) const; string host_, path_, query_; - uint16 port_; + uint16_t port_; bool secure_; }; @@ -393,7 +404,7 @@ struct HttpRequestData : public HttpData { }; struct HttpResponseData : public HttpData { - uint32 scode; + uint32_t scode; std::string message; HttpResponseData() : scode(HC_INTERNAL_SERVER_ERROR) { } @@ -401,12 +412,13 @@ struct HttpResponseData : public HttpData { void copy(const HttpResponseData& src); // Convenience methods - void set_success(uint32 scode = HC_OK); - void set_success(const std::string& content_type, StreamInterface* document, - uint32 scode = HC_OK); + void set_success(uint32_t scode = HC_OK); + void set_success(const std::string& content_type, + StreamInterface* document, + uint32_t scode = HC_OK); void set_redirect(const std::string& location, - uint32 scode = HC_MOVED_TEMPORARILY); - void set_error(uint32 scode); + uint32_t scode = HC_MOVED_TEMPORARILY); + void set_error(uint32_t scode); size_t formatLeader(char* buffer, size_t size) const override; HttpError parseLeader(const char* line, size_t len) override; diff --git a/webrtc/base/ipaddress.cc b/webrtc/base/ipaddress.cc index 3dd856a64a..316207fe49 100644 --- a/webrtc/base/ipaddress.cc +++ b/webrtc/base/ipaddress.cc @@ -43,10 +43,10 @@ static const in6_addr k6BonePrefix = {{{0x3f, 0xfe, 0}}}; bool IPAddress::strip_sensitive_ = false; -static bool IsPrivateV4(uint32 ip); +static bool IsPrivateV4(uint32_t ip); static in_addr ExtractMappedAddress(const in6_addr& addr); -uint32 IPAddress::v4AddressAsHostOrderInteger() const { +uint32_t IPAddress::v4AddressAsHostOrderInteger() const { if (family_ == AF_INET) { return NetworkToHost32(u_.ip4.s_addr); } else { @@ -215,7 +215,7 @@ std::ostream& operator<<(std::ostream& os, const InterfaceAddress& ip) { return os; } -bool IsPrivateV4(uint32 ip_in_host_order) { +bool IsPrivateV4(uint32_t ip_in_host_order) { return ((ip_in_host_order >> 24) == 127) || ((ip_in_host_order >> 24) == 10) || ((ip_in_host_order >> 20) == ((172 << 4) | 1)) || @@ -321,8 +321,8 @@ size_t HashIP(const IPAddress& ip) { } case AF_INET6: { in6_addr v6addr = ip.ipv6_address(); - const uint32* v6_as_ints = - reinterpret_cast(&v6addr.s6_addr); + const uint32_t* v6_as_ints = + reinterpret_cast(&v6addr.s6_addr); return v6_as_ints[0] ^ v6_as_ints[1] ^ v6_as_ints[2] ^ v6_as_ints[3]; } } @@ -341,7 +341,7 @@ IPAddress TruncateIP(const IPAddress& ip, int length) { return IPAddress(INADDR_ANY); } int mask = (0xFFFFFFFF << (32 - length)); - uint32 host_order_ip = NetworkToHost32(ip.ipv4_address().s_addr); + uint32_t host_order_ip = NetworkToHost32(ip.ipv4_address().s_addr); in_addr masked; masked.s_addr = HostToNetwork32(host_order_ip & mask); return IPAddress(masked); @@ -356,12 +356,11 @@ IPAddress TruncateIP(const IPAddress& ip, int length) { int position = length / 32; int inner_length = 32 - (length - (position * 32)); // Note: 64bit mask constant needed to allow possible 32-bit left shift. - uint32 inner_mask = 0xFFFFFFFFLL << inner_length; - uint32* v6_as_ints = - reinterpret_cast(&v6addr.s6_addr); + uint32_t inner_mask = 0xFFFFFFFFLL << inner_length; + uint32_t* v6_as_ints = reinterpret_cast(&v6addr.s6_addr); for (int i = 0; i < 4; ++i) { if (i == position) { - uint32 host_order_inner = NetworkToHost32(v6_as_ints[i]); + uint32_t host_order_inner = NetworkToHost32(v6_as_ints[i]); v6_as_ints[i] = HostToNetwork32(host_order_inner & inner_mask); } else if (i > position) { v6_as_ints[i] = 0; @@ -373,7 +372,7 @@ IPAddress TruncateIP(const IPAddress& ip, int length) { } int CountIPMaskBits(IPAddress mask) { - uint32 word_to_count = 0; + uint32_t word_to_count = 0; int bits = 0; switch (mask.family()) { case AF_INET: { @@ -382,8 +381,8 @@ int CountIPMaskBits(IPAddress mask) { } case AF_INET6: { in6_addr v6addr = mask.ipv6_address(); - const uint32* v6_as_ints = - reinterpret_cast(&v6addr.s6_addr); + const uint32_t* v6_as_ints = + reinterpret_cast(&v6addr.s6_addr); int i = 0; for (; i < 4; ++i) { if (v6_as_ints[i] != 0xFFFFFFFF) { @@ -408,7 +407,7 @@ int CountIPMaskBits(IPAddress mask) { // http://graphics.stanford.edu/~seander/bithacks.html // Counts the trailing 0s in the word. unsigned int zeroes = 32; - word_to_count &= -static_cast(word_to_count); + word_to_count &= -static_cast(word_to_count); if (word_to_count) zeroes--; if (word_to_count & 0x0000FFFF) zeroes -= 16; if (word_to_count & 0x00FF00FF) zeroes -= 8; diff --git a/webrtc/base/ipaddress.h b/webrtc/base/ipaddress.h index 0f32d3a166..fe2d6e2c92 100644 --- a/webrtc/base/ipaddress.h +++ b/webrtc/base/ipaddress.h @@ -62,7 +62,7 @@ class IPAddress { u_.ip6 = ip6; } - explicit IPAddress(uint32 ip_in_host_byte_order) : family_(AF_INET) { + explicit IPAddress(uint32_t ip_in_host_byte_order) : family_(AF_INET) { memset(&u_, 0, sizeof(u_)); u_.ip4.s_addr = HostToNetwork32(ip_in_host_byte_order); } @@ -107,7 +107,7 @@ class IPAddress { IPAddress AsIPv6Address() const; // For socketaddress' benefit. Returns the IP in host byte order. - uint32 v4AddressAsHostOrderInteger() const; + uint32_t v4AddressAsHostOrderInteger() const; // Whether this is an unspecified IP address. bool IsNil() const; diff --git a/webrtc/base/logging.cc b/webrtc/base/logging.cc index fd5e1cd716..b60a244429 100644 --- a/webrtc/base/logging.cc +++ b/webrtc/base/logging.cc @@ -118,7 +118,7 @@ LogMessage::LogMessage(const char* file, int line, LoggingSeverity sev, tag_(kLibjingle), warn_slow_logs_delay_(WARN_SLOW_LOGS_DELAY) { if (timestamp_) { - uint32 time = TimeSince(LogStartTime()); + uint32_t time = TimeSince(LogStartTime()); // Also ensure WallClockStartTime is initialized, so that it matches // LogStartTime. WallClockStartTime(); @@ -197,7 +197,7 @@ LogMessage::~LogMessage() { OutputToDebug(str, severity_, tag_); } - uint32 before = Time(); + uint32_t before = Time(); // Must lock streams_ before accessing CritScope cs(&crit_); for (StreamList::iterator it = streams_.begin(); it != streams_.end(); ++it) { @@ -205,7 +205,7 @@ LogMessage::~LogMessage() { it->first->OnLogMessage(str); } } - uint32 delay = TimeSince(before); + uint32_t delay = TimeSince(before); if (delay >= warn_slow_logs_delay_) { rtc::LogMessage slow_log_warning(__FILE__, __LINE__, LS_WARNING); // If our warning is slow, we don't want to warn about it, because @@ -217,13 +217,13 @@ LogMessage::~LogMessage() { } } -uint32 LogMessage::LogStartTime() { - static const uint32 g_start = Time(); +uint32_t LogMessage::LogStartTime() { + static const uint32_t g_start = Time(); return g_start; } -uint32 LogMessage::WallClockStartTime() { - static const uint32 g_start_wallclock = time(NULL); +uint32_t LogMessage::WallClockStartTime() { + static const uint32_t g_start_wallclock = time(NULL); return g_start_wallclock; } diff --git a/webrtc/base/logging.h b/webrtc/base/logging.h index b8f460c1bd..71c6c53482 100644 --- a/webrtc/base/logging.h +++ b/webrtc/base/logging.h @@ -131,7 +131,7 @@ class LogSink { class LogMessage { public: - static const uint32 WARN_SLOW_LOGS_DELAY = 50; // ms + static const uint32_t WARN_SLOW_LOGS_DELAY = 50; // ms LogMessage(const char* file, int line, LoggingSeverity sev, LogErrorContext err_ctx = ERRCTX_NONE, int err = 0, @@ -152,11 +152,11 @@ class LogMessage { // If this is not called externally, the LogMessage ctor also calls it, in // which case the logging start time will be the time of the first LogMessage // instance is created. - static uint32 LogStartTime(); + static uint32_t LogStartTime(); // Returns the wall clock equivalent of |LogStartTime|, in seconds from the // epoch. - static uint32 WallClockStartTime(); + static uint32_t WallClockStartTime(); // LogThreads: Display the thread identifier of the current thread static void LogThreads(bool on = true); @@ -218,7 +218,7 @@ class LogMessage { // If time it takes to write to stream is more than this, log one // additional warning about it. - uint32 warn_slow_logs_delay_; + uint32_t warn_slow_logs_delay_; // Global lock for the logging subsystem static CriticalSection crit_; diff --git a/webrtc/base/logging_unittest.cc b/webrtc/base/logging_unittest.cc index 58ad6b710d..3719cde4e9 100644 --- a/webrtc/base/logging_unittest.cc +++ b/webrtc/base/logging_unittest.cc @@ -123,7 +123,7 @@ TEST(LogTest, MultipleThreads) { TEST(LogTest, WallClockStartTime) { - uint32 time = LogMessage::WallClockStartTime(); + uint32_t time = LogMessage::WallClockStartTime(); // Expect the time to be in a sensible range, e.g. > 2012-01-01. EXPECT_GT(time, 1325376000u); } @@ -139,7 +139,7 @@ TEST(LogTest, Perf) { stream.DisableBuffering(); LogMessage::AddLogToStream(&stream, LS_SENSITIVE); - uint32 start = Time(), finish; + uint32_t start = Time(), finish; std::string message('X', 80); for (int i = 0; i < 1000; ++i) { LOG(LS_SENSITIVE) << message; diff --git a/webrtc/base/macasyncsocket.cc b/webrtc/base/macasyncsocket.cc index ee982ffff1..1f12500b73 100644 --- a/webrtc/base/macasyncsocket.cc +++ b/webrtc/base/macasyncsocket.cc @@ -276,7 +276,7 @@ int MacAsyncSocket::Close() { return 0; } -int MacAsyncSocket::EstimateMTU(uint16* mtu) { +int MacAsyncSocket::EstimateMTU(uint16_t* mtu) { ASSERT(false && "NYI"); return -1; } diff --git a/webrtc/base/macasyncsocket.h b/webrtc/base/macasyncsocket.h index 735147443a..5861ee3276 100644 --- a/webrtc/base/macasyncsocket.h +++ b/webrtc/base/macasyncsocket.h @@ -49,7 +49,7 @@ class MacAsyncSocket : public AsyncSocket, public sigslot::has_slots<> { int GetError() const override; void SetError(int error) override; ConnState GetState() const override; - int EstimateMTU(uint16* mtu) override; + int EstimateMTU(uint16_t* mtu) override; int GetOption(Option opt, int* value) override; int SetOption(Option opt, int value) override; diff --git a/webrtc/base/maccocoasocketserver_unittest.mm b/webrtc/base/maccocoasocketserver_unittest.mm index 932b4a14f5..5401ffb329 100644 --- a/webrtc/base/maccocoasocketserver_unittest.mm +++ b/webrtc/base/maccocoasocketserver_unittest.mm @@ -32,7 +32,7 @@ class WakeThread : public Thread { // Test that MacCocoaSocketServer::Wait works as expected. TEST(MacCocoaSocketServer, TestWait) { MacCocoaSocketServer server; - uint32 start = Time(); + uint32_t start = Time(); server.Wait(1000, true); EXPECT_GE(TimeSince(start), 1000); } @@ -41,7 +41,7 @@ TEST(MacCocoaSocketServer, TestWait) { TEST(MacCocoaSocketServer, TestWakeup) { MacCFSocketServer server; WakeThread thread(&server); - uint32 start = Time(); + uint32_t start = Time(); thread.Start(); server.Wait(10000, true); EXPECT_LT(TimeSince(start), 10000); diff --git a/webrtc/base/macsocketserver_unittest.cc b/webrtc/base/macsocketserver_unittest.cc index 97732d705d..ecb9a706b7 100644 --- a/webrtc/base/macsocketserver_unittest.cc +++ b/webrtc/base/macsocketserver_unittest.cc @@ -35,7 +35,7 @@ class WakeThread : public Thread { // Test that MacCFSocketServer::Wait works as expected. TEST(MacCFSocketServerTest, TestWait) { MacCFSocketServer server; - uint32 start = Time(); + uint32_t start = Time(); server.Wait(1000, true); EXPECT_GE(TimeSince(start), 1000); } @@ -44,7 +44,7 @@ TEST(MacCFSocketServerTest, TestWait) { TEST(MacCFSocketServerTest, TestWakeup) { MacCFSocketServer server; WakeThread thread(&server); - uint32 start = Time(); + uint32_t start = Time(); thread.Start(); server.Wait(10000, true); EXPECT_LT(TimeSince(start), 10000); @@ -53,7 +53,7 @@ TEST(MacCFSocketServerTest, TestWakeup) { // Test that MacCarbonSocketServer::Wait works as expected. TEST(MacCarbonSocketServerTest, TestWait) { MacCarbonSocketServer server; - uint32 start = Time(); + uint32_t start = Time(); server.Wait(1000, true); EXPECT_GE(TimeSince(start), 1000); } @@ -62,7 +62,7 @@ TEST(MacCarbonSocketServerTest, TestWait) { TEST(MacCarbonSocketServerTest, TestWakeup) { MacCarbonSocketServer server; WakeThread thread(&server); - uint32 start = Time(); + uint32_t start = Time(); thread.Start(); server.Wait(10000, true); EXPECT_LT(TimeSince(start), 10000); @@ -71,7 +71,7 @@ TEST(MacCarbonSocketServerTest, TestWakeup) { // Test that MacCarbonAppSocketServer::Wait works as expected. TEST(MacCarbonAppSocketServerTest, TestWait) { MacCarbonAppSocketServer server; - uint32 start = Time(); + uint32_t start = Time(); server.Wait(1000, true); EXPECT_GE(TimeSince(start), 1000); } @@ -80,7 +80,7 @@ TEST(MacCarbonAppSocketServerTest, TestWait) { TEST(MacCarbonAppSocketServerTest, TestWakeup) { MacCarbonAppSocketServer server; WakeThread thread(&server); - uint32 start = Time(); + uint32_t start = Time(); thread.Start(); server.Wait(10000, true); EXPECT_LT(TimeSince(start), 10000); diff --git a/webrtc/base/md5.cc b/webrtc/base/md5.cc index 6d47b6001c..fda6ddd238 100644 --- a/webrtc/base/md5.cc +++ b/webrtc/base/md5.cc @@ -30,7 +30,7 @@ namespace rtc { #ifdef RTC_ARCH_CPU_LITTLE_ENDIAN #define ByteReverse(buf, len) // Nothing. #else // RTC_ARCH_CPU_BIG_ENDIAN -static void ByteReverse(uint32* buf, int len) { +static void ByteReverse(uint32_t* buf, int len) { for (int i = 0; i < len; ++i) { buf[i] = rtc::GetLE32(&buf[i]); } @@ -49,18 +49,18 @@ void MD5Init(MD5Context* ctx) { } // Update context to reflect the concatenation of another buffer full of bytes. -void MD5Update(MD5Context* ctx, const uint8* buf, size_t len) { +void MD5Update(MD5Context* ctx, const uint8_t* buf, size_t len) { // Update bitcount. - uint32 t = ctx->bits[0]; - if ((ctx->bits[0] = t + (static_cast(len) << 3)) < t) { + uint32_t t = ctx->bits[0]; + if ((ctx->bits[0] = t + (static_cast(len) << 3)) < t) { ctx->bits[1]++; // Carry from low to high. } - ctx->bits[1] += static_cast(len >> 29); + ctx->bits[1] += static_cast(len >> 29); t = (t >> 3) & 0x3f; // Bytes already in shsInfo->data. // Handle any leading odd-sized chunks. if (t) { - uint8* p = reinterpret_cast(ctx->in) + t; + uint8_t* p = reinterpret_cast(ctx->in) + t; t = 64-t; if (len < t) { @@ -89,13 +89,13 @@ void MD5Update(MD5Context* ctx, const uint8* buf, size_t len) { // Final wrapup - pad to 64-byte boundary with the bit pattern. // 1 0* (64-bit count of bits processed, MSB-first) -void MD5Final(MD5Context* ctx, uint8 digest[16]) { +void MD5Final(MD5Context* ctx, uint8_t digest[16]) { // Compute number of bytes mod 64. - uint32 count = (ctx->bits[0] >> 3) & 0x3F; + uint32_t count = (ctx->bits[0] >> 3) & 0x3F; // Set the first char of padding to 0x80. This is safe since there is // always at least one byte free. - uint8* p = reinterpret_cast(ctx->in) + count; + uint8_t* p = reinterpret_cast(ctx->in) + count; *p++ = 0x80; // Bytes of padding needed to make 64 bytes. @@ -140,11 +140,11 @@ void MD5Final(MD5Context* ctx, uint8 digest[16]) { // The core of the MD5 algorithm, this alters an existing MD5 hash to // reflect the addition of 16 longwords of new data. MD5Update blocks // the data and converts bytes into longwords for this routine. -void MD5Transform(uint32 buf[4], const uint32 in[16]) { - uint32 a = buf[0]; - uint32 b = buf[1]; - uint32 c = buf[2]; - uint32 d = buf[3]; +void MD5Transform(uint32_t buf[4], const uint32_t in[16]) { + uint32_t a = buf[0]; + uint32_t b = buf[1]; + uint32_t c = buf[2]; + uint32_t d = buf[3]; MD5STEP(F1, a, b, c, d, in[ 0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[ 1] + 0xe8c7b756, 12); diff --git a/webrtc/base/md5.h b/webrtc/base/md5.h index 80294bb483..45e00b73d1 100644 --- a/webrtc/base/md5.h +++ b/webrtc/base/md5.h @@ -18,24 +18,26 @@ // Changes(fbarchard): Ported to C++ and Google style guide. // Made context first parameter in MD5Final for consistency with Sha1. // Changes(hellner): added rtc namespace +// Changes(pbos): Reverted types back to uint32(8)_t with _t suffix. #ifndef WEBRTC_BASE_MD5_H_ #define WEBRTC_BASE_MD5_H_ -#include "webrtc/base/basictypes.h" +#include +#include namespace rtc { struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - uint32 in[16]; + uint32_t buf[4]; + uint32_t bits[2]; + uint32_t in[16]; }; void MD5Init(MD5Context* context); -void MD5Update(MD5Context* context, const uint8* data, size_t len); -void MD5Final(MD5Context* context, uint8 digest[16]); -void MD5Transform(uint32 buf[4], const uint32 in[16]); +void MD5Update(MD5Context* context, const uint8_t* data, size_t len); +void MD5Final(MD5Context* context, uint8_t digest[16]); +void MD5Transform(uint32_t buf[4], const uint32_t in[16]); } // namespace rtc diff --git a/webrtc/base/md5digest.cc b/webrtc/base/md5digest.cc index 1d014c3588..74f6bede29 100644 --- a/webrtc/base/md5digest.cc +++ b/webrtc/base/md5digest.cc @@ -17,14 +17,14 @@ size_t Md5Digest::Size() const { } void Md5Digest::Update(const void* buf, size_t len) { - MD5Update(&ctx_, static_cast(buf), len); + MD5Update(&ctx_, static_cast(buf), len); } size_t Md5Digest::Finish(void* buf, size_t len) { if (len < kSize) { return 0; } - MD5Final(&ctx_, static_cast(buf)); + MD5Final(&ctx_, static_cast(buf)); MD5Init(&ctx_); // Reset for next use. return kSize; } diff --git a/webrtc/base/messagedigest.cc b/webrtc/base/messagedigest.cc index 8af60d9a96..0c2b4a16ac 100644 --- a/webrtc/base/messagedigest.cc +++ b/webrtc/base/messagedigest.cc @@ -117,7 +117,7 @@ size_t ComputeHmac(MessageDigest* digest, } // Copy the key to a block-sized buffer to simplify padding. // If the key is longer than a block, hash it and use the result instead. - scoped_ptr new_key(new uint8[block_len]); + scoped_ptr new_key(new uint8_t[block_len]); if (key_len > block_len) { ComputeDigest(digest, key, key_len, new_key.get(), block_len); memset(new_key.get() + digest->Size(), 0, block_len - digest->Size()); @@ -126,13 +126,14 @@ size_t ComputeHmac(MessageDigest* digest, memset(new_key.get() + key_len, 0, block_len - key_len); } // Set up the padding from the key, salting appropriately for each padding. - scoped_ptr o_pad(new uint8[block_len]), i_pad(new uint8[block_len]); + scoped_ptr o_pad(new uint8_t[block_len]); + scoped_ptr i_pad(new uint8_t[block_len]); for (size_t i = 0; i < block_len; ++i) { o_pad[i] = 0x5c ^ new_key[i]; i_pad[i] = 0x36 ^ new_key[i]; } // Inner hash; hash the inner padding, and then the input buffer. - scoped_ptr inner(new uint8[digest->Size()]); + scoped_ptr inner(new uint8_t[digest->Size()]); digest->Update(i_pad.get(), block_len); digest->Update(input, in_len); digest->Finish(inner.get(), digest->Size()); diff --git a/webrtc/base/messagequeue.cc b/webrtc/base/messagequeue.cc index 5cf448e3bd..857cf12927 100644 --- a/webrtc/base/messagequeue.cc +++ b/webrtc/base/messagequeue.cc @@ -27,7 +27,7 @@ typedef rtc::PhysicalSocketServer DefaultSocketServer; namespace rtc { -const uint32 kMaxMsgLatency = 150; // 150 ms +const uint32_t kMaxMsgLatency = 150; // 150 ms //------------------------------------------------------------------ // MessageQueueManager @@ -188,8 +188,8 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) { int cmsTotal = cmsWait; int cmsElapsed = 0; - uint32 msStart = Time(); - uint32 msCurrent = msStart; + uint32_t msStart = Time(); + uint32_t msCurrent = msStart; while (true) { // Check for sent messages ReceiveSends(); @@ -227,7 +227,7 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) { // Log a warning for time-sensitive messages that we're late to deliver. if (pmsg->ts_sensitive) { - int32 delay = TimeDiff(msCurrent, pmsg->ts_sensitive); + int32_t delay = TimeDiff(msCurrent, pmsg->ts_sensitive); if (delay > 0) { LOG_F(LS_WARNING) << "id: " << pmsg->message_id << " delay: " << (delay + kMaxMsgLatency) << "ms"; @@ -276,8 +276,10 @@ bool MessageQueue::Get(Message *pmsg, int cmsWait, bool process_io) { void MessageQueue::ReceiveSends() { } -void MessageQueue::Post(MessageHandler *phandler, uint32 id, - MessageData *pdata, bool time_sensitive) { +void MessageQueue::Post(MessageHandler* phandler, + uint32_t id, + MessageData* pdata, + bool time_sensitive) { if (fStop_) return; @@ -299,20 +301,23 @@ void MessageQueue::Post(MessageHandler *phandler, uint32 id, void MessageQueue::PostDelayed(int cmsDelay, MessageHandler* phandler, - uint32 id, + uint32_t id, MessageData* pdata) { return DoDelayPost(cmsDelay, TimeAfter(cmsDelay), phandler, id, pdata); } -void MessageQueue::PostAt(uint32 tstamp, +void MessageQueue::PostAt(uint32_t tstamp, MessageHandler* phandler, - uint32 id, + uint32_t id, MessageData* pdata) { return DoDelayPost(TimeUntil(tstamp), tstamp, phandler, id, pdata); } -void MessageQueue::DoDelayPost(int cmsDelay, uint32 tstamp, - MessageHandler *phandler, uint32 id, MessageData* pdata) { +void MessageQueue::DoDelayPost(int cmsDelay, + uint32_t tstamp, + MessageHandler* phandler, + uint32_t id, + MessageData* pdata) { if (fStop_) return; @@ -350,7 +355,8 @@ int MessageQueue::GetDelay() { return kForever; } -void MessageQueue::Clear(MessageHandler *phandler, uint32 id, +void MessageQueue::Clear(MessageHandler* phandler, + uint32_t id, MessageList* removed) { CritScope cs(&crit_); diff --git a/webrtc/base/messagequeue.h b/webrtc/base/messagequeue.h index 23dbafc124..c3ab3b6669 100644 --- a/webrtc/base/messagequeue.h +++ b/webrtc/base/messagequeue.h @@ -123,8 +123,8 @@ class DisposeData : public MessageData { T* data_; }; -const uint32 MQID_ANY = static_cast(-1); -const uint32 MQID_DISPOSE = static_cast(-2); +const uint32_t MQID_ANY = static_cast(-1); +const uint32_t MQID_DISPOSE = static_cast(-2); // No destructor @@ -132,14 +132,14 @@ struct Message { Message() { memset(this, 0, sizeof(*this)); } - inline bool Match(MessageHandler* handler, uint32 id) const { + inline bool Match(MessageHandler* handler, uint32_t id) const { return (handler == NULL || handler == phandler) && (id == MQID_ANY || id == message_id); } MessageHandler *phandler; - uint32 message_id; + uint32_t message_id; MessageData *pdata; - uint32 ts_sensitive; + uint32_t ts_sensitive; }; typedef std::list MessageList; @@ -149,8 +149,8 @@ typedef std::list MessageList; class DelayedMessage { public: - DelayedMessage(int delay, uint32 trigger, uint32 num, const Message& msg) - : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) { } + DelayedMessage(int delay, uint32_t trigger, uint32_t num, const Message& msg) + : cmsDelay_(delay), msTrigger_(trigger), num_(num), msg_(msg) {} bool operator< (const DelayedMessage& dmsg) const { return (dmsg.msTrigger_ < msTrigger_) @@ -158,8 +158,8 @@ class DelayedMessage { } int cmsDelay_; // for debugging - uint32 msTrigger_; - uint32 num_; + uint32_t msTrigger_; + uint32_t num_; Message msg_; }; @@ -190,17 +190,20 @@ class MessageQueue { virtual bool Get(Message *pmsg, int cmsWait = kForever, bool process_io = true); virtual bool Peek(Message *pmsg, int cmsWait = 0); - virtual void Post(MessageHandler *phandler, uint32 id = 0, - MessageData *pdata = NULL, bool time_sensitive = false); + virtual void Post(MessageHandler* phandler, + uint32_t id = 0, + MessageData* pdata = NULL, + bool time_sensitive = false); virtual void PostDelayed(int cmsDelay, MessageHandler* phandler, - uint32 id = 0, + uint32_t id = 0, MessageData* pdata = NULL); - virtual void PostAt(uint32 tstamp, + virtual void PostAt(uint32_t tstamp, MessageHandler* phandler, - uint32 id = 0, + uint32_t id = 0, MessageData* pdata = NULL); - virtual void Clear(MessageHandler *phandler, uint32 id = MQID_ANY, + virtual void Clear(MessageHandler* phandler, + uint32_t id = MQID_ANY, MessageList* removed = NULL); virtual void Dispatch(Message *pmsg); virtual void ReceiveSends(); @@ -232,8 +235,11 @@ class MessageQueue { void reheap() { make_heap(c.begin(), c.end(), comp); } }; - void DoDelayPost(int cmsDelay, uint32 tstamp, MessageHandler *phandler, - uint32 id, MessageData* pdata); + void DoDelayPost(int cmsDelay, + uint32_t tstamp, + MessageHandler* phandler, + uint32_t id, + MessageData* pdata); // The SocketServer is not owned by MessageQueue. SocketServer* ss_; @@ -244,7 +250,7 @@ class MessageQueue { Message msgPeek_; MessageList msgq_; PriorityQueue dmsgq_; - uint32 dmsgq_next_num_; + uint32_t dmsgq_next_num_; mutable CriticalSection crit_; private: diff --git a/webrtc/base/natsocketfactory.cc b/webrtc/base/natsocketfactory.cc index a23a7e8a77..548a80caa8 100644 --- a/webrtc/base/natsocketfactory.cc +++ b/webrtc/base/natsocketfactory.cc @@ -26,7 +26,7 @@ size_t PackAddressForNAT(char* buf, size_t buf_size, buf[0] = 0; buf[1] = family; // Writes the port. - *(reinterpret_cast(&buf[2])) = HostToNetwork16(remote_addr.port()); + *(reinterpret_cast(&buf[2])) = HostToNetwork16(remote_addr.port()); if (family == AF_INET) { ASSERT(buf_size >= kNATEncodedIPv4AddressSize); in_addr v4addr = ip.ipv4_address(); @@ -49,7 +49,8 @@ size_t UnpackAddressFromNAT(const char* buf, size_t buf_size, ASSERT(buf_size >= 8); ASSERT(buf[0] == 0); int family = buf[1]; - uint16 port = NetworkToHost16(*(reinterpret_cast(&buf[2]))); + uint16_t port = + NetworkToHost16(*(reinterpret_cast(&buf[2]))); if (family == AF_INET) { const in_addr* v4addr = reinterpret_cast(&buf[4]); *remote_addr = SocketAddress(IPAddress(*v4addr), port); @@ -220,7 +221,7 @@ class NATSocket : public AsyncSocket, public sigslot::has_slots<> { ConnState GetState() const override { return connected_ ? CS_CONNECTED : CS_CLOSED; } - int EstimateMTU(uint16* mtu) override { return socket_->EstimateMTU(mtu); } + int EstimateMTU(uint16_t* mtu) override { return socket_->EstimateMTU(mtu); } int GetOption(Option opt, int* value) override { return socket_->GetOption(opt, value); } diff --git a/webrtc/base/network.cc b/webrtc/base/network.cc index bc7d50528c..bc714e30f4 100644 --- a/webrtc/base/network.cc +++ b/webrtc/base/network.cc @@ -62,8 +62,8 @@ namespace { // limit of IPv6 networks but could be changed by set_max_ipv6_networks(). const int kMaxIPv6Networks = 5; -const uint32 kUpdateNetworksMessage = 1; -const uint32 kSignalNetworksMessage = 2; +const uint32_t kUpdateNetworksMessage = 1; +const uint32_t kSignalNetworksMessage = 2; // Fetch list of networks every two seconds. const int kNetworksUpdateIntervalMs = 2000; diff --git a/webrtc/base/nullsocketserver_unittest.cc b/webrtc/base/nullsocketserver_unittest.cc index 4bb1d7f8eb..2aa38b490d 100644 --- a/webrtc/base/nullsocketserver_unittest.cc +++ b/webrtc/base/nullsocketserver_unittest.cc @@ -14,7 +14,7 @@ namespace rtc { -static const uint32 kTimeout = 5000U; +static const uint32_t kTimeout = 5000U; class NullSocketServerTest : public testing::Test, @@ -38,7 +38,7 @@ TEST_F(NullSocketServerTest, WaitAndSet) { } TEST_F(NullSocketServerTest, TestWait) { - uint32 start = Time(); + uint32_t start = Time(); ss_.Wait(200, true); // The actual wait time is dependent on the resolution of the timer used by // the Event class. Allow for the event to signal ~20ms early. diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc index c759ee5f15..67ed5db4b5 100644 --- a/webrtc/base/opensslstreamadapter.cc +++ b/webrtc/base/opensslstreamadapter.cc @@ -384,17 +384,16 @@ bool OpenSSLStreamAdapter::GetSslCipherSuite(int* cipher) { // Key Extractor interface bool OpenSSLStreamAdapter::ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) { #ifdef HAVE_DTLS_SRTP int i; - i = SSL_export_keying_material(ssl_, result, result_len, - label.c_str(), label.length(), - const_cast(context), + i = SSL_export_keying_material(ssl_, result, result_len, label.c_str(), + label.length(), const_cast(context), context_len, use_context); if (i != 1) diff --git a/webrtc/base/opensslstreamadapter.h b/webrtc/base/opensslstreamadapter.h index 56bba41c90..0f3ded9cb4 100644 --- a/webrtc/base/opensslstreamadapter.h +++ b/webrtc/base/opensslstreamadapter.h @@ -94,10 +94,10 @@ class OpenSSLStreamAdapter : public SSLStreamAdapter { // Key Extractor interface bool ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) override; // DTLS-SRTP interface diff --git a/webrtc/base/pathutils.cc b/webrtc/base/pathutils.cc index 7671bfc29f..b5227ecb10 100644 --- a/webrtc/base/pathutils.cc +++ b/webrtc/base/pathutils.cc @@ -225,12 +225,13 @@ bool Pathname::SetFilename(const std::string& filename) { } #if defined(WEBRTC_WIN) -bool Pathname::GetDrive(char *drive, uint32 bytes) const { +bool Pathname::GetDrive(char* drive, uint32_t bytes) const { return GetDrive(drive, bytes, folder_); } // static -bool Pathname::GetDrive(char *drive, uint32 bytes, +bool Pathname::GetDrive(char* drive, + uint32_t bytes, const std::string& pathname) { // need at lease 4 bytes to save c: if (bytes < 4 || pathname.size() < 3) { diff --git a/webrtc/base/pathutils.h b/webrtc/base/pathutils.h index 8f07e1dbc0..2d5819f1b6 100644 --- a/webrtc/base/pathutils.h +++ b/webrtc/base/pathutils.h @@ -92,8 +92,10 @@ public: bool SetFilename(const std::string& filename); #if defined(WEBRTC_WIN) - bool GetDrive(char *drive, uint32 bytes) const; - static bool GetDrive(char *drive, uint32 bytes,const std::string& pathname); + bool GetDrive(char* drive, uint32_t bytes) const; + static bool GetDrive(char* drive, + uint32_t bytes, + const std::string& pathname); #endif private: diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc index b9c2a07aa5..01f0731f3c 100644 --- a/webrtc/base/physicalsocketserver.cc +++ b/webrtc/base/physicalsocketserver.cc @@ -68,26 +68,26 @@ namespace rtc { #if defined(WEBRTC_WIN) // Standard MTUs, from RFC 1191 -const uint16 PACKET_MAXIMUMS[] = { - 65535, // Theoretical maximum, Hyperchannel - 32000, // Nothing - 17914, // 16Mb IBM Token Ring - 8166, // IEEE 802.4 - //4464, // IEEE 802.5 (4Mb max) - 4352, // FDDI - //2048, // Wideband Network - 2002, // IEEE 802.5 (4Mb recommended) - //1536, // Expermental Ethernet Networks - //1500, // Ethernet, Point-to-Point (default) - 1492, // IEEE 802.3 - 1006, // SLIP, ARPANET - //576, // X.25 Networks - //544, // DEC IP Portal - //512, // NETBIOS - 508, // IEEE 802/Source-Rt Bridge, ARCNET - 296, // Point-to-Point (low delay) - 68, // Official minimum - 0, // End of list marker +const uint16_t PACKET_MAXIMUMS[] = { + 65535, // Theoretical maximum, Hyperchannel + 32000, // Nothing + 17914, // 16Mb IBM Token Ring + 8166, // IEEE 802.4 + // 4464, // IEEE 802.5 (4Mb max) + 4352, // FDDI + // 2048, // Wideband Network + 2002, // IEEE 802.5 (4Mb recommended) + // 1536, // Expermental Ethernet Networks + // 1500, // Ethernet, Point-to-Point (default) + 1492, // IEEE 802.3 + 1006, // SLIP, ARPANET + // 576, // X.25 Networks + // 544, // DEC IP Portal + // 512, // NETBIOS + 508, // IEEE 802/Source-Rt Bridge, ARCNET + 296, // Point-to-Point (low delay) + 68, // Official minimum + 0, // End of list marker }; static const int IP_HEADER_SIZE = 20u; @@ -398,7 +398,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { return err; } - int EstimateMTU(uint16* mtu) override { + int EstimateMTU(uint16_t* mtu) override { SocketAddress addr = GetRemoteAddress(); if (addr.IsAny()) { SetError(ENOTCONN); @@ -420,7 +420,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { } for (int level = 0; PACKET_MAXIMUMS[level + 1] > 0; ++level) { - int32 size = PACKET_MAXIMUMS[level] - header_size; + int32_t size = PACKET_MAXIMUMS[level] - header_size; WinPing::PingResult result = ping.Ping(addr.ipaddr(), size, ICMP_PING_TIMEOUT_MILLIS, 1, false); @@ -541,7 +541,7 @@ class PhysicalSocket : public AsyncSocket, public sigslot::has_slots<> { PhysicalSocketServer* ss_; SOCKET s_; - uint8 enabled_events_; + uint8_t enabled_events_; bool udp_; int error_; // Protects |error_| that is accessed from different threads. @@ -572,28 +572,28 @@ class EventDispatcher : public Dispatcher { virtual void Signal() { CritScope cs(&crit_); if (!fSignaled_) { - const uint8 b[1] = { 0 }; + const uint8_t b[1] = {0}; if (VERIFY(1 == write(afd_[1], b, sizeof(b)))) { fSignaled_ = true; } } } - uint32 GetRequestedEvents() override { return DE_READ; } + uint32_t GetRequestedEvents() override { return DE_READ; } - void OnPreEvent(uint32 ff) override { + void OnPreEvent(uint32_t ff) override { // It is not possible to perfectly emulate an auto-resetting event with // pipes. This simulates it by resetting before the event is handled. CritScope cs(&crit_); if (fSignaled_) { - uint8 b[4]; // Allow for reading more than 1 byte, but expect 1. + uint8_t b[4]; // Allow for reading more than 1 byte, but expect 1. VERIFY(1 == read(afd_[0], b, sizeof(b))); fSignaled_ = false; } } - void OnEvent(uint32 ff, int err) override { ASSERT(false); } + void OnEvent(uint32_t ff, int err) override { ASSERT(false); } int GetDescriptor() override { return afd_[0]; } @@ -661,7 +661,7 @@ class PosixSignalHandler { // Set a flag saying we've seen this signal. received_signal_[signum] = true; // Notify application code that we got a signal. - const uint8 b[1] = { 0 }; + const uint8_t b[1] = {0}; if (-1 == write(afd_[1], b, sizeof(b))) { // Nothing we can do here. If there's an error somehow then there's // nothing we can safely do from a signal handler. @@ -718,7 +718,7 @@ class PosixSignalHandler { // will still be handled, so this isn't a problem. // Volatile is not necessary here for correctness, but this data _is_ volatile // so I've marked it as such. - volatile uint8 received_signal_[kNumPosixSignals]; + volatile uint8_t received_signal_[kNumPosixSignals]; }; class PosixSignalDispatcher : public Dispatcher { @@ -731,12 +731,12 @@ class PosixSignalDispatcher : public Dispatcher { owner_->Remove(this); } - uint32 GetRequestedEvents() override { return DE_READ; } + uint32_t GetRequestedEvents() override { return DE_READ; } - void OnPreEvent(uint32 ff) override { + void OnPreEvent(uint32_t ff) override { // Events might get grouped if signals come very fast, so we read out up to // 16 bytes to make sure we keep the pipe empty. - uint8 b[16]; + uint8_t b[16]; ssize_t ret = read(GetDescriptor(), b, sizeof(b)); if (ret < 0) { LOG_ERR(LS_WARNING) << "Error in read()"; @@ -745,7 +745,7 @@ class PosixSignalDispatcher : public Dispatcher { } } - void OnEvent(uint32 ff, int err) override { + void OnEvent(uint32_t ff, int err) override { for (int signum = 0; signum < PosixSignalHandler::kNumPosixSignals; ++signum) { if (PosixSignalHandler::Instance()->IsSignalSet(signum)) { @@ -856,16 +856,16 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket { } } - uint32 GetRequestedEvents() override { return enabled_events_; } + uint32_t GetRequestedEvents() override { return enabled_events_; } - void OnPreEvent(uint32 ff) override { + void OnPreEvent(uint32_t ff) override { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; if ((ff & DE_CLOSE) != 0) state_ = CS_CLOSED; } - void OnEvent(uint32 ff, int err) override { + void OnEvent(uint32_t ff, int err) override { // Make sure we deliver connect/accept first. Otherwise, consumers may see // something like a READ followed by a CONNECT, which would be odd. if ((ff & DE_CONNECT) != 0) { @@ -920,11 +920,11 @@ class FileDispatcher: public Dispatcher, public AsyncFile { bool IsDescriptorClosed() override { return false; } - uint32 GetRequestedEvents() override { return flags_; } + uint32_t GetRequestedEvents() override { return flags_; } - void OnPreEvent(uint32 ff) override {} + void OnPreEvent(uint32_t ff) override {} - void OnEvent(uint32 ff, int err) override { + void OnEvent(uint32_t ff, int err) override { if ((ff & DE_READ) != 0) SignalReadEvent(this); if ((ff & DE_WRITE) != 0) @@ -958,8 +958,8 @@ AsyncFile* PhysicalSocketServer::CreateFile(int fd) { #endif // WEBRTC_POSIX #if defined(WEBRTC_WIN) -static uint32 FlagsToEvents(uint32 events) { - uint32 ffFD = FD_CLOSE; +static uint32_t FlagsToEvents(uint32_t events) { + uint32_t ffFD = FD_CLOSE; if (events & DE_READ) ffFD |= FD_READ; if (events & DE_WRITE) @@ -993,16 +993,11 @@ class EventDispatcher : public Dispatcher { WSASetEvent(hev_); } - virtual uint32 GetRequestedEvents() { - return 0; - } + virtual uint32_t GetRequestedEvents() { return 0; } - virtual void OnPreEvent(uint32 ff) { - WSAResetEvent(hev_); - } + virtual void OnPreEvent(uint32_t ff) { WSAResetEvent(hev_); } - virtual void OnEvent(uint32 ff, int err) { - } + virtual void OnEvent(uint32_t ff, int err) {} virtual WSAEVENT GetWSAEvent() { return hev_; @@ -1077,17 +1072,15 @@ class SocketDispatcher : public Dispatcher, public PhysicalSocket { return PhysicalSocket::Close(); } - virtual uint32 GetRequestedEvents() { - return enabled_events_; - } + virtual uint32_t GetRequestedEvents() { return enabled_events_; } - virtual void OnPreEvent(uint32 ff) { + virtual void OnPreEvent(uint32_t ff) { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; // We set CS_CLOSED from CheckSignalClose. } - virtual void OnEvent(uint32 ff, int err) { + virtual void OnEvent(uint32_t ff, int err) { int cache_id = id_; // Make sure we deliver connect/accept first. Otherwise, consumers may see // something like a READ followed by a CONNECT, which would be odd. @@ -1154,7 +1147,7 @@ class Signaler : public EventDispatcher { } ~Signaler() override { } - void OnEvent(uint32 ff, int err) override { + void OnEvent(uint32_t ff, int err) override { if (pf_) *pf_ = false; } @@ -1312,7 +1305,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { if (fd > fdmax) fdmax = fd; - uint32 ff = pdispatcher->GetRequestedEvents(); + uint32_t ff = pdispatcher->GetRequestedEvents(); if (ff & (DE_READ | DE_ACCEPT)) FD_SET(fd, &fdsRead); if (ff & (DE_WRITE | DE_CONNECT)) @@ -1345,7 +1338,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { for (size_t i = 0; i < dispatchers_.size(); ++i) { Dispatcher *pdispatcher = dispatchers_[i]; int fd = pdispatcher->GetDescriptor(); - uint32 ff = 0; + uint32_t ff = 0; int errcode = 0; // Reap any error code, which can be signaled through reads or writes. @@ -1479,7 +1472,7 @@ bool PhysicalSocketServer::InstallSignal(int signum, void (*handler)(int)) { bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { int cmsTotal = cmsWait; int cmsElapsed = 0; - uint32 msStart = Time(); + uint32_t msStart = Time(); fWait_ = true; while (fWait_) { @@ -1590,7 +1583,7 @@ bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { } } #endif - uint32 ff = 0; + uint32_t ff = 0; int errcode = 0; if (wsaEvents.lNetworkEvents & FD_READ) ff |= DE_READ; diff --git a/webrtc/base/physicalsocketserver.h b/webrtc/base/physicalsocketserver.h index 15be789e26..af09e0b988 100644 --- a/webrtc/base/physicalsocketserver.h +++ b/webrtc/base/physicalsocketserver.h @@ -41,9 +41,9 @@ class PosixSignalDispatcher; class Dispatcher { public: virtual ~Dispatcher() {} - virtual uint32 GetRequestedEvents() = 0; - virtual void OnPreEvent(uint32 ff) = 0; - virtual void OnEvent(uint32 ff, int err) = 0; + virtual uint32_t GetRequestedEvents() = 0; + virtual void OnPreEvent(uint32_t ff) = 0; + virtual void OnEvent(uint32_t ff, int err) = 0; #if defined(WEBRTC_WIN) virtual WSAEVENT GetWSAEvent() = 0; virtual SOCKET GetSocket() = 0; diff --git a/webrtc/base/profiler.cc b/webrtc/base/profiler.cc index 9f781fbe14..873b1989f7 100644 --- a/webrtc/base/profiler.cc +++ b/webrtc/base/profiler.cc @@ -55,7 +55,7 @@ void ProfilerEvent::Start() { ++start_count_; } -void ProfilerEvent::Stop(uint64 stop_time) { +void ProfilerEvent::Stop(uint64_t stop_time) { --start_count_; ASSERT(start_count_ >= 0); if (start_count_ == 0) { @@ -114,7 +114,7 @@ void Profiler::StartEvent(const std::string& event_name) { void Profiler::StopEvent(const std::string& event_name) { // Get the time ASAP, then wait for the lock. - uint64 stop_time = TimeNanos(); + uint64_t stop_time = TimeNanos(); SharedScope scope(&lock_); EventMap::iterator it = events_.find(event_name); if (it != events_.end()) { diff --git a/webrtc/base/profiler.h b/webrtc/base/profiler.h index 68a35b2710..419763fc8a 100644 --- a/webrtc/base/profiler.h +++ b/webrtc/base/profiler.h @@ -91,7 +91,7 @@ class ProfilerEvent { ProfilerEvent(); void Start(); void Stop(); - void Stop(uint64 stop_time); + void Stop(uint64_t stop_time); double standard_deviation() const; double total_time() const { return total_time_; } double mean() const { return mean_; } @@ -101,7 +101,7 @@ class ProfilerEvent { bool is_started() const { return start_count_ > 0; } private: - uint64 current_start_time_; + uint64_t current_start_time_; double total_time_; double mean_; double sum_of_squared_differences_; diff --git a/webrtc/base/proxydetect.cc b/webrtc/base/proxydetect.cc index 16bf822c11..b144d20a97 100644 --- a/webrtc/base/proxydetect.cc +++ b/webrtc/base/proxydetect.cc @@ -213,13 +213,13 @@ bool ProxyItemMatch(const Url& url, char * item, size_t len) { int a, b, c, d, m; int match = sscanf(item, "%d.%d.%d.%d/%d", &a, &b, &c, &d, &m); if (match >= 4) { - uint32 ip = ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | - (d & 0xFF); + uint32_t ip = ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | + (d & 0xFF); if ((match < 5) || (m > 32)) m = 32; else if (m < 0) m = 0; - uint32 mask = (m == 0) ? 0 : (~0UL) << (32 - m); + uint32_t mask = (m == 0) ? 0 : (~0UL) << (32 - m); SocketAddress addr(url.host(), 0); // TODO: Support IPv6 proxyitems. This code block is IPv4 only anyway. return !addr.IsUnresolved() && @@ -289,7 +289,7 @@ bool ParseProxy(const std::string& saddress, ProxyInfo* proxy) { ProxyType ptype; std::string host; - uint16 port; + uint16_t port; const char* address = saddress.c_str(); while (*address) { @@ -323,7 +323,7 @@ bool ParseProxy(const std::string& saddress, ProxyInfo* proxy) { *colon = 0; char * endptr; - port = static_cast(strtol(colon + 1, &endptr, 0)); + port = static_cast(strtol(colon + 1, &endptr, 0)); if (*endptr != 0) { LOG(LS_WARNING) << "Proxy address with invalid port [" << buffer << "]"; continue; @@ -397,7 +397,7 @@ bool GetFirefoxProfilePath(Pathname* path) { return false; } char buffer[NAME_MAX + 1]; - if (0 != FSRefMakePath(&fr, reinterpret_cast(buffer), + if (0 != FSRefMakePath(&fr, reinterpret_cast(buffer), ARRAY_SIZE(buffer))) { LOG(LS_ERROR) << "FSRefMakePath failed"; return false; diff --git a/webrtc/base/ratetracker.cc b/webrtc/base/ratetracker.cc index 57906f71e0..5cb449016e 100644 --- a/webrtc/base/ratetracker.cc +++ b/webrtc/base/ratetracker.cc @@ -19,13 +19,12 @@ namespace rtc { -RateTracker::RateTracker( - uint32 bucket_milliseconds, size_t bucket_count) +RateTracker::RateTracker(uint32_t bucket_milliseconds, size_t bucket_count) : bucket_milliseconds_(bucket_milliseconds), - bucket_count_(bucket_count), - sample_buckets_(new size_t[bucket_count + 1]), - total_sample_count_(0u), - bucket_start_time_milliseconds_(~0u) { + bucket_count_(bucket_count), + sample_buckets_(new size_t[bucket_count + 1]), + total_sample_count_(0u), + bucket_start_time_milliseconds_(~0u) { RTC_CHECK(bucket_milliseconds > 0u); RTC_CHECK(bucket_count > 0u); } @@ -35,26 +34,27 @@ RateTracker::~RateTracker() { } double RateTracker::ComputeRateForInterval( - uint32 interval_milliseconds) const { + uint32_t interval_milliseconds) const { if (bucket_start_time_milliseconds_ == ~0u) { return 0.0; } - uint32 current_time = Time(); + uint32_t current_time = Time(); // Calculate which buckets to sum up given the current time. If the time // has passed to a new bucket then we have to skip some of the oldest buckets. - uint32 available_interval_milliseconds = std::min( + uint32_t available_interval_milliseconds = std::min( interval_milliseconds, - bucket_milliseconds_ * static_cast(bucket_count_)); + bucket_milliseconds_ * static_cast(bucket_count_)); // number of old buckets (i.e. after the current bucket in the ring buffer) // that are expired given our current time interval. size_t buckets_to_skip; // Number of milliseconds of the first bucket that are not a portion of the // current interval. - uint32 milliseconds_to_skip; + uint32_t milliseconds_to_skip; if (current_time > initialization_time_milliseconds_ + available_interval_milliseconds) { - uint32 time_to_skip = current_time - bucket_start_time_milliseconds_ + - static_cast(bucket_count_) * bucket_milliseconds_ - + uint32_t time_to_skip = + current_time - bucket_start_time_milliseconds_ + + static_cast(bucket_count_) * bucket_milliseconds_ - available_interval_milliseconds; buckets_to_skip = time_to_skip / bucket_milliseconds_; milliseconds_to_skip = time_to_skip % bucket_milliseconds_; @@ -91,7 +91,7 @@ double RateTracker::ComputeTotalRate() const { if (bucket_start_time_milliseconds_ == ~0u) { return 0.0; } - uint32 current_time = Time(); + uint32_t current_time = Time(); if (TimeIsLaterOrEqual(current_time, initialization_time_milliseconds_)) { return 0.0; } @@ -106,7 +106,7 @@ size_t RateTracker::TotalSampleCount() const { void RateTracker::AddSamples(size_t sample_count) { EnsureInitialized(); - uint32 current_time = Time(); + uint32_t current_time = Time(); // Advance the current bucket as needed for the current time, and reset // bucket counts as we advance. for (size_t i = 0u; i <= bucket_count_ && @@ -125,7 +125,7 @@ void RateTracker::AddSamples(size_t sample_count) { total_sample_count_ += sample_count; } -uint32 RateTracker::Time() const { +uint32_t RateTracker::Time() const { return rtc::Time(); } diff --git a/webrtc/base/ratetracker.h b/webrtc/base/ratetracker.h index 0e2e040e88..d49d7cacdd 100644 --- a/webrtc/base/ratetracker.h +++ b/webrtc/base/ratetracker.h @@ -21,19 +21,19 @@ namespace rtc { // that over each bucket the rate was constant. class RateTracker { public: - RateTracker(uint32 bucket_milliseconds, size_t bucket_count); + RateTracker(uint32_t bucket_milliseconds, size_t bucket_count); virtual ~RateTracker(); // Computes the average rate over the most recent interval_milliseconds, // or if the first sample was added within this period, computes the rate // since the first sample was added. - double ComputeRateForInterval(uint32 interval_milliseconds) const; + double ComputeRateForInterval(uint32_t interval_milliseconds) const; // Computes the average rate over the rate tracker's recording interval // of bucket_milliseconds * bucket_count. double ComputeRate() const { - return ComputeRateForInterval( - bucket_milliseconds_ * static_cast(bucket_count_)); + return ComputeRateForInterval(bucket_milliseconds_ * + static_cast(bucket_count_)); } // Computes the average rate since the first sample was added to the @@ -49,19 +49,19 @@ class RateTracker { protected: // overrideable for tests - virtual uint32 Time() const; + virtual uint32_t Time() const; private: void EnsureInitialized(); size_t NextBucketIndex(size_t bucket_index) const; - const uint32 bucket_milliseconds_; + const uint32_t bucket_milliseconds_; const size_t bucket_count_; size_t* sample_buckets_; size_t total_sample_count_; size_t current_bucket_; - uint32 bucket_start_time_milliseconds_; - uint32 initialization_time_milliseconds_; + uint32_t bucket_start_time_milliseconds_; + uint32_t initialization_time_milliseconds_; }; } // namespace rtc diff --git a/webrtc/base/ratetracker_unittest.cc b/webrtc/base/ratetracker_unittest.cc index 043f53718b..2187282cd3 100644 --- a/webrtc/base/ratetracker_unittest.cc +++ b/webrtc/base/ratetracker_unittest.cc @@ -16,11 +16,11 @@ namespace rtc { class RateTrackerForTest : public RateTracker { public: RateTrackerForTest() : RateTracker(100u, 10u), time_(0) {} - virtual uint32 Time() const { return time_; } - void AdvanceTime(uint32 delta) { time_ += delta; } + virtual uint32_t Time() const { return time_; } + void AdvanceTime(uint32_t delta) { time_ += delta; } private: - uint32 time_; + uint32_t time_; }; TEST(RateTrackerTest, Test30FPS) { diff --git a/webrtc/base/rtccertificate.cc b/webrtc/base/rtccertificate.cc index d912eb4b2e..a176d9080b 100644 --- a/webrtc/base/rtccertificate.cc +++ b/webrtc/base/rtccertificate.cc @@ -28,7 +28,7 @@ RTCCertificate::RTCCertificate(SSLIdentity* identity) RTCCertificate::~RTCCertificate() { } -uint64 RTCCertificate::expires_timestamp_ns() const { +uint64_t RTCCertificate::expires_timestamp_ns() const { // TODO(hbos): Update once SSLIdentity/SSLCertificate supports expires field. return 0; } diff --git a/webrtc/base/rtccertificate.h b/webrtc/base/rtccertificate.h index cb6835566e..d238938ae1 100644 --- a/webrtc/base/rtccertificate.h +++ b/webrtc/base/rtccertificate.h @@ -27,7 +27,7 @@ class RTCCertificate : public RefCountInterface { // Takes ownership of |identity|. static scoped_refptr Create(scoped_ptr identity); - uint64 expires_timestamp_ns() const; + uint64_t expires_timestamp_ns() const; bool HasExpired() const; const SSLCertificate& ssl_certificate() const; diff --git a/webrtc/base/sha1.cc b/webrtc/base/sha1.cc index b2af313be7..5816152b16 100644 --- a/webrtc/base/sha1.cc +++ b/webrtc/base/sha1.cc @@ -96,6 +96,11 @@ * Modified 05/2015 * By Sergey Ulanov * Removed static buffer to make computation thread-safe. + * + * ----------------- + * Modified 10/2015 + * By Peter Boström + * Change uint32(8) back to uint32(8)_t (undoes (03/2012) change). */ // Enabling SHA1HANDSOFF preserves the caller's data buffer. @@ -156,13 +161,13 @@ void SHAPrintContext(SHA1_CTX *context, char *msg) { #endif /* VERBOSE */ // Hash a single 512-bit block. This is the core of the algorithm. -void SHA1Transform(uint32 state[5], const uint8 buffer[64]) { +void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]) { union CHAR64LONG16 { - uint8 c[64]; - uint32 l[16]; + uint8_t c[64]; + uint32_t l[16]; }; #ifdef SHA1HANDSOFF - uint8 workspace[64]; + uint8_t workspace[64]; memcpy(workspace, buffer, 64); CHAR64LONG16* block = reinterpret_cast(workspace); #else @@ -172,11 +177,11 @@ void SHA1Transform(uint32 state[5], const uint8 buffer[64]) { #endif // Copy context->state[] to working vars. - uint32 a = state[0]; - uint32 b = state[1]; - uint32 c = state[2]; - uint32 d = state[3]; - uint32 e = state[4]; + uint32_t a = state[0]; + uint32_t b = state[1]; + uint32_t c = state[2]; + uint32_t d = state[3]; + uint32_t e = state[4]; // 4 rounds of 20 operations each. Loop unrolled. // Note(fbarchard): The following has lint warnings for multiple ; on @@ -225,7 +230,7 @@ void SHA1Init(SHA1_CTX* context) { } // Run your data through this. -void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { +void SHA1Update(SHA1_CTX* context, const uint8_t* data, size_t input_len) { size_t i = 0; #ifdef VERBOSE @@ -236,15 +241,15 @@ void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { size_t index = (context->count[0] >> 3) & 63; // Update number of bits. - // TODO: Use uint64 instead of 2 uint32 for count. + // TODO: Use uint64_t instead of 2 uint32_t for count. // count[0] has low 29 bits for byte count + 3 pad 0's making 32 bits for // bit count. - // Add bit count to low uint32 - context->count[0] += static_cast(input_len << 3); - if (context->count[0] < static_cast(input_len << 3)) { + // Add bit count to low uint32_t + context->count[0] += static_cast(input_len << 3); + if (context->count[0] < static_cast(input_len << 3)) { ++context->count[1]; // if overlow (carry), add one to high word } - context->count[1] += static_cast(input_len >> 29); + context->count[1] += static_cast(input_len >> 29); if ((index + input_len) > 63) { i = 64 - index; memcpy(&context->buffer[index], data, i); @@ -262,21 +267,21 @@ void SHA1Update(SHA1_CTX* context, const uint8* data, size_t input_len) { } // Add padding and return the message digest. -void SHA1Final(SHA1_CTX* context, uint8 digest[SHA1_DIGEST_SIZE]) { - uint8 finalcount[8]; +void SHA1Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]) { + uint8_t finalcount[8]; for (int i = 0; i < 8; ++i) { // Endian independent - finalcount[i] = static_cast( - (context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8) ) & 255); + finalcount[i] = static_cast( + (context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) & 255); } - SHA1Update(context, reinterpret_cast("\200"), 1); + SHA1Update(context, reinterpret_cast("\200"), 1); while ((context->count[0] & 504) != 448) { - SHA1Update(context, reinterpret_cast("\0"), 1); + SHA1Update(context, reinterpret_cast("\0"), 1); } SHA1Update(context, finalcount, 8); // Should cause a SHA1Transform(). for (int i = 0; i < SHA1_DIGEST_SIZE; ++i) { - digest[i] = static_cast( - (context->state[i >> 2] >> ((3 - (i & 3)) * 8) ) & 255); + digest[i] = static_cast( + (context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255); } // Wipe variables. diff --git a/webrtc/base/sha1.h b/webrtc/base/sha1.h index 4862a00498..aa5a6a5506 100644 --- a/webrtc/base/sha1.h +++ b/webrtc/base/sha1.h @@ -5,27 +5,28 @@ * */ -// Ported to C++, Google style, under namespace rtc and uses basictypes.h +// Ported to C++, Google style, under namespace rtc. #ifndef WEBRTC_BASE_SHA1_H_ #define WEBRTC_BASE_SHA1_H_ -#include "webrtc/base/basictypes.h" +#include +#include namespace rtc { struct SHA1_CTX { - uint32 state[5]; - // TODO: Change bit count to uint64. - uint32 count[2]; // Bit count of input. - uint8 buffer[64]; + uint32_t state[5]; + // TODO: Change bit count to uint64_t. + uint32_t count[2]; // Bit count of input. + uint8_t buffer[64]; }; #define SHA1_DIGEST_SIZE 20 void SHA1Init(SHA1_CTX* context); -void SHA1Update(SHA1_CTX* context, const uint8* data, size_t len); -void SHA1Final(SHA1_CTX* context, uint8 digest[SHA1_DIGEST_SIZE]); +void SHA1Update(SHA1_CTX* context, const uint8_t* data, size_t len); +void SHA1Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]); #endif // WEBRTC_BASE_SHA1_H_ diff --git a/webrtc/base/sha1digest.cc b/webrtc/base/sha1digest.cc index 5ba0c54425..c090a06bb0 100644 --- a/webrtc/base/sha1digest.cc +++ b/webrtc/base/sha1digest.cc @@ -17,14 +17,14 @@ size_t Sha1Digest::Size() const { } void Sha1Digest::Update(const void* buf, size_t len) { - SHA1Update(&ctx_, static_cast(buf), len); + SHA1Update(&ctx_, static_cast(buf), len); } size_t Sha1Digest::Finish(void* buf, size_t len) { if (len < kSize) { return 0; } - SHA1Final(&ctx_, static_cast(buf)); + SHA1Final(&ctx_, static_cast(buf)); SHA1Init(&ctx_); // Reset for next use. return kSize; } diff --git a/webrtc/base/sharedexclusivelock_unittest.cc b/webrtc/base/sharedexclusivelock_unittest.cc index c124db5c82..2857e00449 100644 --- a/webrtc/base/sharedexclusivelock_unittest.cc +++ b/webrtc/base/sharedexclusivelock_unittest.cc @@ -20,8 +20,8 @@ namespace rtc { -static const uint32 kMsgRead = 0; -static const uint32 kMsgWrite = 0; +static const uint32_t kMsgRead = 0; +static const uint32_t kMsgWrite = 0; static const int kNoWaitThresholdInMs = 10; static const int kWaitThresholdInMs = 80; static const int kProcessTimeInMs = 100; @@ -69,7 +69,7 @@ class ReadTask : public SharedExclusiveTask { TypedMessageData* message_data = static_cast*>(message->pdata); - uint32 start_time = Time(); + uint32_t start_time = Time(); { SharedScope ss(shared_exclusive_lock_); waiting_time_in_ms_ = TimeDiff(Time(), start_time); @@ -102,7 +102,7 @@ class WriteTask : public SharedExclusiveTask { TypedMessageData* message_data = static_cast*>(message->pdata); - uint32 start_time = Time(); + uint32_t start_time = Time(); { ExclusiveScope es(shared_exclusive_lock_); waiting_time_in_ms_ = TimeDiff(Time(), start_time); diff --git a/webrtc/base/socket.h b/webrtc/base/socket.h index 5512c5de0a..8d98d273df 100644 --- a/webrtc/base/socket.h +++ b/webrtc/base/socket.h @@ -158,10 +158,10 @@ class Socket { }; virtual ConnState GetState() const = 0; - // Fills in the given uint16 with the current estimate of the MTU along the + // Fills in the given uint16_t with the current estimate of the MTU along the // path to the address to which this socket is connected. NOTE: This method // can block for up to 10 seconds on Windows. - virtual int EstimateMTU(uint16* mtu) = 0; + virtual int EstimateMTU(uint16_t* mtu) = 0; enum Option { OPT_DONTFRAGMENT, diff --git a/webrtc/base/socket_unittest.cc b/webrtc/base/socket_unittest.cc index 6104eda4e4..d078d7cd17 100644 --- a/webrtc/base/socket_unittest.cc +++ b/webrtc/base/socket_unittest.cc @@ -929,7 +929,7 @@ void SocketTest::UdpReadyToSend(const IPAddress& loopback) { client->SetOption(rtc::Socket::OPT_SNDBUF, send_buffer_size); int error = 0; - uint32 start_ms = Time(); + uint32_t start_ms = Time(); int sent_packet_num = 0; int expected_error = EWOULDBLOCK; while (start_ms + kTimeout > Time()) { @@ -990,7 +990,7 @@ void SocketTest::GetSetOptionsInternal(const IPAddress& loopback) { mtu_socket( ss_->CreateAsyncSocket(loopback.family(), SOCK_DGRAM)); mtu_socket->Bind(SocketAddress(loopback, 0)); - uint16 mtu; + uint16_t mtu; // should fail until we connect ASSERT_EQ(-1, mtu_socket->EstimateMTU(&mtu)); mtu_socket->Connect(SocketAddress(loopback, 0)); diff --git a/webrtc/base/socketadapters.cc b/webrtc/base/socketadapters.cc index b1c2a87aa9..af2efb82c7 100644 --- a/webrtc/base/socketadapters.cc +++ b/webrtc/base/socketadapters.cc @@ -137,41 +137,41 @@ AsyncProxyServerSocket::~AsyncProxyServerSocket() = default; // This is a SSL v2 CLIENT_HELLO message. // TODO: Should this have a session id? The response doesn't have a // certificate, so the hello should have a session id. -static const uint8 kSslClientHello[] = { - 0x80, 0x46, // msg len - 0x01, // CLIENT_HELLO - 0x03, 0x01, // SSL 3.1 - 0x00, 0x2d, // ciphersuite len - 0x00, 0x00, // session id len - 0x00, 0x10, // challenge len - 0x01, 0x00, 0x80, 0x03, 0x00, 0x80, 0x07, 0x00, 0xc0, // ciphersuites - 0x06, 0x00, 0x40, 0x02, 0x00, 0x80, 0x04, 0x00, 0x80, // - 0x00, 0x00, 0x04, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x0a, // - 0x00, 0xfe, 0xfe, 0x00, 0x00, 0x09, 0x00, 0x00, 0x64, // - 0x00, 0x00, 0x62, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, // - 0x1f, 0x17, 0x0c, 0xa6, 0x2f, 0x00, 0x78, 0xfc, // challenge - 0x46, 0x55, 0x2e, 0xb1, 0x83, 0x39, 0xf1, 0xea // +static const uint8_t kSslClientHello[] = { + 0x80, 0x46, // msg len + 0x01, // CLIENT_HELLO + 0x03, 0x01, // SSL 3.1 + 0x00, 0x2d, // ciphersuite len + 0x00, 0x00, // session id len + 0x00, 0x10, // challenge len + 0x01, 0x00, 0x80, 0x03, 0x00, 0x80, 0x07, 0x00, 0xc0, // ciphersuites + 0x06, 0x00, 0x40, 0x02, 0x00, 0x80, 0x04, 0x00, 0x80, // + 0x00, 0x00, 0x04, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x0a, // + 0x00, 0xfe, 0xfe, 0x00, 0x00, 0x09, 0x00, 0x00, 0x64, // + 0x00, 0x00, 0x62, 0x00, 0x00, 0x03, 0x00, 0x00, 0x06, // + 0x1f, 0x17, 0x0c, 0xa6, 0x2f, 0x00, 0x78, 0xfc, // challenge + 0x46, 0x55, 0x2e, 0xb1, 0x83, 0x39, 0xf1, 0xea // }; // This is a TLSv1 SERVER_HELLO message. -static const uint8 kSslServerHello[] = { - 0x16, // handshake message - 0x03, 0x01, // SSL 3.1 - 0x00, 0x4a, // message len - 0x02, // SERVER_HELLO - 0x00, 0x00, 0x46, // handshake len - 0x03, 0x01, // SSL 3.1 - 0x42, 0x85, 0x45, 0xa7, 0x27, 0xa9, 0x5d, 0xa0, // server random - 0xb3, 0xc5, 0xe7, 0x53, 0xda, 0x48, 0x2b, 0x3f, // - 0xc6, 0x5a, 0xca, 0x89, 0xc1, 0x58, 0x52, 0xa1, // - 0x78, 0x3c, 0x5b, 0x17, 0x46, 0x00, 0x85, 0x3f, // - 0x20, // session id len - 0x0e, 0xd3, 0x06, 0x72, 0x5b, 0x5b, 0x1b, 0x5f, // session id - 0x15, 0xac, 0x13, 0xf9, 0x88, 0x53, 0x9d, 0x9b, // - 0xe8, 0x3d, 0x7b, 0x0c, 0x30, 0x32, 0x6e, 0x38, // - 0x4d, 0xa2, 0x75, 0x57, 0x41, 0x6c, 0x34, 0x5c, // - 0x00, 0x04, // RSA/RC4-128/MD5 - 0x00 // null compression +static const uint8_t kSslServerHello[] = { + 0x16, // handshake message + 0x03, 0x01, // SSL 3.1 + 0x00, 0x4a, // message len + 0x02, // SERVER_HELLO + 0x00, 0x00, 0x46, // handshake len + 0x03, 0x01, // SSL 3.1 + 0x42, 0x85, 0x45, 0xa7, 0x27, 0xa9, 0x5d, 0xa0, // server random + 0xb3, 0xc5, 0xe7, 0x53, 0xda, 0x48, 0x2b, 0x3f, // + 0xc6, 0x5a, 0xca, 0x89, 0xc1, 0x58, 0x52, 0xa1, // + 0x78, 0x3c, 0x5b, 0x17, 0x46, 0x00, 0x85, 0x3f, // + 0x20, // session id len + 0x0e, 0xd3, 0x06, 0x72, 0x5b, 0x5b, 0x1b, 0x5f, // session id + 0x15, 0xac, 0x13, 0xf9, 0x88, 0x53, 0x9d, 0x9b, // + 0xe8, 0x3d, 0x7b, 0x0c, 0x30, 0x32, 0x6e, 0x38, // + 0x4d, 0xa2, 0x75, 0x57, 0x41, 0x6c, 0x34, 0x5c, // + 0x00, 0x04, // RSA/RC4-128/MD5 + 0x00 // null compression }; AsyncSSLSocket::AsyncSSLSocket(AsyncSocket* socket) @@ -564,7 +564,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { ByteBuffer response(data, *len); if (state_ == SS_HELLO) { - uint8 ver, method; + uint8_t ver, method; if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&method)) return; @@ -583,7 +583,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { return; } } else if (state_ == SS_AUTH) { - uint8 ver, status; + uint8_t ver, status; if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&status)) return; @@ -595,7 +595,7 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { SendConnect(); } else if (state_ == SS_CONNECT) { - uint8 ver, rep, rsv, atyp; + uint8_t ver, rep, rsv, atyp; if (!response.ReadUInt8(&ver) || !response.ReadUInt8(&rep) || !response.ReadUInt8(&rsv) || @@ -607,15 +607,15 @@ void AsyncSocksProxySocket::ProcessInput(char* data, size_t* len) { return; } - uint16 port; + uint16_t port; if (atyp == 1) { - uint32 addr; + uint32_t addr; if (!response.ReadUInt32(&addr) || !response.ReadUInt16(&port)) return; LOG(LS_VERBOSE) << "Bound on " << addr << ":" << port; } else if (atyp == 3) { - uint8 len; + uint8_t len; std::string addr; if (!response.ReadUInt8(&len) || !response.ReadString(&addr, len) || @@ -670,9 +670,9 @@ void AsyncSocksProxySocket::SendHello() { void AsyncSocksProxySocket::SendAuth() { ByteBuffer request; request.WriteUInt8(1); // Negotiation Version - request.WriteUInt8(static_cast(user_.size())); + request.WriteUInt8(static_cast(user_.size())); request.WriteString(user_); // Username - request.WriteUInt8(static_cast(pass_.GetLength())); + request.WriteUInt8(static_cast(pass_.GetLength())); size_t len = pass_.GetLength() + 1; char * sensitive = new char[len]; pass_.CopyTo(sensitive, true); @@ -691,7 +691,7 @@ void AsyncSocksProxySocket::SendConnect() { if (dest_.IsUnresolved()) { std::string hostname = dest_.hostname(); request.WriteUInt8(3); // DOMAINNAME - request.WriteUInt8(static_cast(hostname.size())); + request.WriteUInt8(static_cast(hostname.size())); request.WriteString(hostname); // Destination Hostname } else { request.WriteUInt8(1); // IPV4 @@ -738,7 +738,7 @@ void AsyncSocksProxyServerSocket::DirectSend(const ByteBuffer& buf) { } void AsyncSocksProxyServerSocket::HandleHello(ByteBuffer* request) { - uint8 ver, num_methods; + uint8_t ver, num_methods; if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&num_methods)) { Error(0); @@ -751,7 +751,7 @@ void AsyncSocksProxyServerSocket::HandleHello(ByteBuffer* request) { } // Handle either no-auth (0) or user/pass auth (2) - uint8 method = 0xFF; + uint8_t method = 0xFF; if (num_methods > 0 && !request->ReadUInt8(&method)) { Error(0); return; @@ -768,7 +768,7 @@ void AsyncSocksProxyServerSocket::HandleHello(ByteBuffer* request) { } } -void AsyncSocksProxyServerSocket::SendHelloReply(uint8 method) { +void AsyncSocksProxyServerSocket::SendHelloReply(uint8_t method) { ByteBuffer response; response.WriteUInt8(5); // Socks Version response.WriteUInt8(method); // Auth method @@ -776,7 +776,7 @@ void AsyncSocksProxyServerSocket::SendHelloReply(uint8 method) { } void AsyncSocksProxyServerSocket::HandleAuth(ByteBuffer* request) { - uint8 ver, user_len, pass_len; + uint8_t ver, user_len, pass_len; std::string user, pass; if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&user_len) || @@ -792,7 +792,7 @@ void AsyncSocksProxyServerSocket::HandleAuth(ByteBuffer* request) { state_ = SS_CONNECT; } -void AsyncSocksProxyServerSocket::SendAuthReply(uint8 result) { +void AsyncSocksProxyServerSocket::SendAuthReply(uint8_t result) { ByteBuffer response; response.WriteUInt8(1); // Negotiation Version response.WriteUInt8(result); @@ -800,9 +800,9 @@ void AsyncSocksProxyServerSocket::SendAuthReply(uint8 result) { } void AsyncSocksProxyServerSocket::HandleConnect(ByteBuffer* request) { - uint8 ver, command, reserved, addr_type; - uint32 ip; - uint16 port; + uint8_t ver, command, reserved, addr_type; + uint32_t ip; + uint16_t port; if (!request->ReadUInt8(&ver) || !request->ReadUInt8(&command) || !request->ReadUInt8(&reserved) || diff --git a/webrtc/base/socketadapters.h b/webrtc/base/socketadapters.h index b7d3d4b4fc..ece591d29f 100644 --- a/webrtc/base/socketadapters.h +++ b/webrtc/base/socketadapters.h @@ -196,9 +196,9 @@ class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { void DirectSend(const ByteBuffer& buf); void HandleHello(ByteBuffer* request); - void SendHelloReply(uint8 method); + void SendHelloReply(uint8_t method); void HandleAuth(ByteBuffer* request); - void SendAuthReply(uint8 result); + void SendAuthReply(uint8_t result); void HandleConnect(ByteBuffer* request); void SendConnectResult(int result, const SocketAddress& addr) override; diff --git a/webrtc/base/socketaddress.cc b/webrtc/base/socketaddress.cc index b15c0c48b6..3f13c385a9 100644 --- a/webrtc/base/socketaddress.cc +++ b/webrtc/base/socketaddress.cc @@ -47,7 +47,7 @@ SocketAddress::SocketAddress(const std::string& hostname, int port) { SetPort(port); } -SocketAddress::SocketAddress(uint32 ip_as_host_order_integer, int port) { +SocketAddress::SocketAddress(uint32_t ip_as_host_order_integer, int port) { SetIP(IPAddress(ip_as_host_order_integer)); SetPort(port); } @@ -86,7 +86,7 @@ SocketAddress& SocketAddress::operator=(const SocketAddress& addr) { return *this; } -void SocketAddress::SetIP(uint32 ip_as_host_order_integer) { +void SocketAddress::SetIP(uint32_t ip_as_host_order_integer) { hostname_.clear(); literal_ = false; ip_ = IPAddress(ip_as_host_order_integer); @@ -109,7 +109,7 @@ void SocketAddress::SetIP(const std::string& hostname) { scope_id_ = 0; } -void SocketAddress::SetResolvedIP(uint32 ip_as_host_order_integer) { +void SocketAddress::SetResolvedIP(uint32_t ip_as_host_order_integer) { ip_ = IPAddress(ip_as_host_order_integer); scope_id_ = 0; } @@ -121,10 +121,10 @@ void SocketAddress::SetResolvedIP(const IPAddress& ip) { void SocketAddress::SetPort(int port) { ASSERT((0 <= port) && (port < 65536)); - port_ = static_cast(port); + port_ = static_cast(port); } -uint32 SocketAddress::ip() const { +uint32_t SocketAddress::ip() const { return ip_.v4AddressAsHostOrderInteger(); } @@ -132,7 +132,7 @@ const IPAddress& SocketAddress::ipaddr() const { return ip_; } -uint16 SocketAddress::port() const { +uint16_t SocketAddress::port() const { return port_; } @@ -279,7 +279,9 @@ bool SocketAddress::FromSockAddr(const sockaddr_in& saddr) { } static size_t ToSockAddrStorageHelper(sockaddr_storage* addr, - IPAddress ip, uint16 port, int scope_id) { + IPAddress ip, + uint16_t port, + int scope_id) { memset(addr, 0, sizeof(sockaddr_storage)); addr->ss_family = static_cast(ip.family()); if (addr->ss_family == AF_INET6) { @@ -305,15 +307,15 @@ size_t SocketAddress::ToSockAddrStorage(sockaddr_storage* addr) const { return ToSockAddrStorageHelper(addr, ip_, port_, scope_id_); } -std::string SocketAddress::IPToString(uint32 ip_as_host_order_integer) { +std::string SocketAddress::IPToString(uint32_t ip_as_host_order_integer) { return IPAddress(ip_as_host_order_integer).ToString(); } -std::string IPToSensitiveString(uint32 ip_as_host_order_integer) { +std::string IPToSensitiveString(uint32_t ip_as_host_order_integer) { return IPAddress(ip_as_host_order_integer).ToSensitiveString(); } -bool SocketAddress::StringToIP(const std::string& hostname, uint32* ip) { +bool SocketAddress::StringToIP(const std::string& hostname, uint32_t* ip) { in_addr addr; if (rtc::inet_pton(AF_INET, hostname.c_str(), &addr) == 0) return false; @@ -340,8 +342,8 @@ bool SocketAddress::StringToIP(const std::string& hostname, IPAddress* ip) { return false; } -uint32 SocketAddress::StringToIP(const std::string& hostname) { - uint32 ip = 0; +uint32_t SocketAddress::StringToIP(const std::string& hostname) { + uint32_t ip = 0; StringToIP(hostname, &ip); return ip; } diff --git a/webrtc/base/socketaddress.h b/webrtc/base/socketaddress.h index f8256fc629..44183f3aeb 100644 --- a/webrtc/base/socketaddress.h +++ b/webrtc/base/socketaddress.h @@ -36,7 +36,7 @@ class SocketAddress { // Creates the address with the given IP and port. // IP is given as an integer in host byte order. V4 only, to be deprecated. - SocketAddress(uint32 ip_as_host_order_integer, int port); + SocketAddress(uint32_t ip_as_host_order_integer, int port); // Creates the address with the given IP and port. SocketAddress(const IPAddress& ip, int port); @@ -58,7 +58,7 @@ class SocketAddress { // Changes the IP of this address to the given one, and clears the hostname // IP is given as an integer in host byte order. V4 only, to be deprecated.. - void SetIP(uint32 ip_as_host_order_integer); + void SetIP(uint32_t ip_as_host_order_integer); // Changes the IP of this address to the given one, and clears the hostname. void SetIP(const IPAddress& ip); @@ -70,7 +70,7 @@ class SocketAddress { // Sets the IP address while retaining the hostname. Useful for bypassing // DNS for a pre-resolved IP. // IP is given as an integer in host byte order. V4 only, to be deprecated. - void SetResolvedIP(uint32 ip_as_host_order_integer); + void SetResolvedIP(uint32_t ip_as_host_order_integer); // Sets the IP address while retaining the hostname. Useful for bypassing // DNS for a pre-resolved IP. @@ -84,14 +84,14 @@ class SocketAddress { // Returns the IP address as a host byte order integer. // Returns 0 for non-v4 addresses. - uint32 ip() const; + uint32_t ip() const; const IPAddress& ipaddr() const; int family() const {return ip_.family(); } // Returns the port part of this address. - uint16 port() const; + uint16_t port() const; // Returns the scope ID associated with this address. Scope IDs are a // necessary addition to IPv6 link-local addresses, with different network @@ -181,18 +181,18 @@ class SocketAddress { // Converts the IP address given in 'compact form' into dotted form. // IP is given as an integer in host byte order. V4 only, to be deprecated. // TODO: Deprecate this. - static std::string IPToString(uint32 ip_as_host_order_integer); + static std::string IPToString(uint32_t ip_as_host_order_integer); // Same as IPToString but anonymizes it by hiding the last part. // TODO: Deprecate this. - static std::string IPToSensitiveString(uint32 ip_as_host_order_integer); + static std::string IPToSensitiveString(uint32_t ip_as_host_order_integer); // Converts the IP address given in dotted form into compact form. // Only dotted names (A.B.C.D) are converted. // Output integer is returned in host byte order. // TODO: Deprecate, replace wth agnostic versions. - static bool StringToIP(const std::string& str, uint32* ip); - static uint32 StringToIP(const std::string& str); + static bool StringToIP(const std::string& str, uint32_t* ip); + static uint32_t StringToIP(const std::string& str); // Converts the IP address given in printable form into an IPAddress. static bool StringToIP(const std::string& str, IPAddress* ip); @@ -200,7 +200,7 @@ class SocketAddress { private: std::string hostname_; IPAddress ip_; - uint16 port_; + uint16_t port_; int scope_id_; bool literal_; // Indicates that 'hostname_' contains a literal IP string. }; diff --git a/webrtc/base/sslfingerprint.cc b/webrtc/base/sslfingerprint.cc index a6101810b7..1939b4fd0b 100644 --- a/webrtc/base/sslfingerprint.cc +++ b/webrtc/base/sslfingerprint.cc @@ -30,7 +30,7 @@ SSLFingerprint* SSLFingerprint::Create( SSLFingerprint* SSLFingerprint::Create( const std::string& algorithm, const rtc::SSLCertificate* cert) { - uint8 digest_val[64]; + uint8_t digest_val[64]; size_t digest_len; bool ret = cert->ComputeDigest( algorithm, digest_val, sizeof(digest_val), &digest_len); @@ -58,13 +58,13 @@ SSLFingerprint* SSLFingerprint::CreateFromRfc4572( if (!value_len) return NULL; - return new SSLFingerprint(algorithm, - reinterpret_cast(value), + return new SSLFingerprint(algorithm, reinterpret_cast(value), value_len); } -SSLFingerprint::SSLFingerprint( - const std::string& algorithm, const uint8* digest_in, size_t digest_len) +SSLFingerprint::SSLFingerprint(const std::string& algorithm, + const uint8_t* digest_in, + size_t digest_len) : algorithm(algorithm) { digest.SetData(digest_in, digest_len); } diff --git a/webrtc/base/sslfingerprint.h b/webrtc/base/sslfingerprint.h index 355c6bae6d..735238dde6 100644 --- a/webrtc/base/sslfingerprint.h +++ b/webrtc/base/sslfingerprint.h @@ -31,7 +31,8 @@ struct SSLFingerprint { static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm, const std::string& fingerprint); - SSLFingerprint(const std::string& algorithm, const uint8* digest_in, + SSLFingerprint(const std::string& algorithm, + const uint8_t* digest_in, size_t digest_len); SSLFingerprint(const SSLFingerprint& from); diff --git a/webrtc/base/sslstreamadapter.cc b/webrtc/base/sslstreamadapter.cc index 0ce49d1359..9d5297564f 100644 --- a/webrtc/base/sslstreamadapter.cc +++ b/webrtc/base/sslstreamadapter.cc @@ -57,10 +57,10 @@ bool SSLStreamAdapter::GetSslCipherSuite(int* cipher) { } bool SSLStreamAdapter::ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) { return false; // Default is unsupported } diff --git a/webrtc/base/sslstreamadapter.h b/webrtc/base/sslstreamadapter.h index fa4965149b..65a7729d16 100644 --- a/webrtc/base/sslstreamadapter.h +++ b/webrtc/base/sslstreamadapter.h @@ -167,10 +167,10 @@ class SSLStreamAdapter : public StreamAdapterInterface { // result -- where to put the computed value // result_len -- the length of the computed value virtual bool ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len); // DTLS-SRTP interface diff --git a/webrtc/base/sslstreamadapter_unittest.cc b/webrtc/base/sslstreamadapter_unittest.cc index 386fe4f986..c65bb63ec0 100644 --- a/webrtc/base/sslstreamadapter_unittest.cc +++ b/webrtc/base/sslstreamadapter_unittest.cc @@ -334,7 +334,7 @@ class SSLStreamAdapterTestBase : public testing::Test, size_t data_len, size_t *written, int *error) { // Randomly drop loss_ percent of packets - if (rtc::CreateRandomId() % 100 < static_cast(loss_)) { + if (rtc::CreateRandomId() % 100 < static_cast(loss_)) { LOG(LS_INFO) << "Randomly dropping packet, size=" << data_len; *written = data_len; return rtc::SR_SUCCESS; diff --git a/webrtc/base/systeminfo.cc b/webrtc/base/systeminfo.cc index 540de82313..bfc96b3763 100644 --- a/webrtc/base/systeminfo.cc +++ b/webrtc/base/systeminfo.cc @@ -161,8 +161,8 @@ std::string SystemInfo::GetCpuVendor() { // Returns the amount of installed physical memory in Bytes. Cacheable. // Returns -1 on error. -int64 SystemInfo::GetMemorySize() { - int64 memory = -1; +int64_t SystemInfo::GetMemorySize() { + int64_t memory = -1; #if defined(WEBRTC_WIN) MEMORYSTATUSEX status = {0}; @@ -180,8 +180,8 @@ int64 SystemInfo::GetMemorySize() { if (error || memory == 0) memory = -1; #elif defined(WEBRTC_LINUX) - memory = static_cast(sysconf(_SC_PHYS_PAGES)) * - static_cast(sysconf(_SC_PAGESIZE)); + memory = static_cast(sysconf(_SC_PHYS_PAGES)) * + static_cast(sysconf(_SC_PAGESIZE)); if (memory < 0) { LOG(LS_WARNING) << "sysconf(_SC_PHYS_PAGES) failed." << "sysconf(_SC_PHYS_PAGES) " << sysconf(_SC_PHYS_PAGES) diff --git a/webrtc/base/systeminfo.h b/webrtc/base/systeminfo.h index e2237026fb..99d18b2960 100644 --- a/webrtc/base/systeminfo.h +++ b/webrtc/base/systeminfo.h @@ -36,7 +36,7 @@ class SystemInfo { Architecture GetCpuArchitecture(); std::string GetCpuVendor(); // Total amount of physical memory, in bytes. - int64 GetMemorySize(); + int64_t GetMemorySize(); // The model name of the machine, e.g. "MacBookAir1,1" std::string GetMachineModel(); diff --git a/webrtc/base/task.cc b/webrtc/base/task.cc index d81a6d2429..bdf8f1df03 100644 --- a/webrtc/base/task.cc +++ b/webrtc/base/task.cc @@ -14,7 +14,7 @@ namespace rtc { -int32 Task::unique_id_seed_ = 0; +int32_t Task::unique_id_seed_ = 0; Task::Task(TaskParent *parent) : TaskParent(this, parent), @@ -48,11 +48,11 @@ Task::~Task() { } } -int64 Task::CurrentTime() { +int64_t Task::CurrentTime() { return GetRunner()->CurrentTime(); } -int64 Task::ElapsedTime() { +int64_t Task::ElapsedTime() { return CurrentTime() - start_time_; } @@ -240,7 +240,7 @@ bool Task::TimedOut() { } void Task::ResetTimeout() { - int64 previous_timeout_time = timeout_time_; + int64_t previous_timeout_time = timeout_time_; bool timeout_allowed = (state_ != STATE_INIT) && (state_ != STATE_DONE) && (state_ != STATE_ERROR); @@ -254,7 +254,7 @@ void Task::ResetTimeout() { } void Task::ClearTimeout() { - int64 previous_timeout_time = timeout_time_; + int64_t previous_timeout_time = timeout_time_; timeout_time_ = 0; GetRunner()->UpdateTaskTimeout(this, previous_timeout_time); } diff --git a/webrtc/base/task.h b/webrtc/base/task.h index 3e43e11dae..28702e49a7 100644 --- a/webrtc/base/task.h +++ b/webrtc/base/task.h @@ -95,7 +95,7 @@ class Task : public TaskParent { Task(TaskParent *parent); ~Task() override; - int32 unique_id() { return unique_id_; } + int32_t unique_id() { return unique_id_; } void Start(); void Step(); @@ -103,14 +103,14 @@ class Task : public TaskParent { bool HasError() const { return (GetState() == STATE_ERROR); } bool Blocked() const { return blocked_; } bool IsDone() const { return done_; } - int64 ElapsedTime(); + int64_t ElapsedTime(); // Called from outside to stop task without any more callbacks void Abort(bool nowake = false); bool TimedOut(); - int64 timeout_time() const { return timeout_time_; } + int64_t timeout_time() const { return timeout_time_; } int timeout_seconds() const { return timeout_seconds_; } void set_timeout_seconds(int timeout_seconds); @@ -134,7 +134,7 @@ class Task : public TaskParent { // Called inside to advise that the task should wake and signal an error void Error(); - int64 CurrentTime(); + int64_t CurrentTime(); virtual std::string GetStateName(int state) const; virtual int Process(int state); @@ -160,13 +160,13 @@ class Task : public TaskParent { bool aborted_; bool busy_; bool error_; - int64 start_time_; - int64 timeout_time_; + int64_t start_time_; + int64_t timeout_time_; int timeout_seconds_; bool timeout_suspended_; - int32 unique_id_; - - static int32 unique_id_seed_; + int32_t unique_id_; + + static int32_t unique_id_seed_; }; } // namespace rtc diff --git a/webrtc/base/task_unittest.cc b/webrtc/base/task_unittest.cc index 1135a73a0f..7f67841641 100644 --- a/webrtc/base/task_unittest.cc +++ b/webrtc/base/task_unittest.cc @@ -31,8 +31,8 @@ namespace rtc { -static int64 GetCurrentTime() { - return static_cast(Time()) * 10000; +static int64_t GetCurrentTime() { + return static_cast(Time()) * 10000; } // feel free to change these numbers. Note that '0' won't work, though @@ -98,9 +98,7 @@ class HappyTask : public IdTimeoutTask { class MyTaskRunner : public TaskRunner { public: virtual void WakeTasks() { RunTasks(); } - virtual int64 CurrentTime() { - return GetCurrentTime(); - } + virtual int64_t CurrentTime() { return GetCurrentTime(); } bool timeout_change() const { return timeout_change_; @@ -490,9 +488,7 @@ class DeleteTestTaskRunner : public TaskRunner { DeleteTestTaskRunner() { } virtual void WakeTasks() { } - virtual int64 CurrentTime() { - return GetCurrentTime(); - } + virtual int64_t CurrentTime() { return GetCurrentTime(); } private: RTC_DISALLOW_COPY_AND_ASSIGN(DeleteTestTaskRunner); }; diff --git a/webrtc/base/taskrunner.cc b/webrtc/base/taskrunner.cc index bc4ab5e44f..e7278f10a1 100644 --- a/webrtc/base/taskrunner.cc +++ b/webrtc/base/taskrunner.cc @@ -64,7 +64,7 @@ void TaskRunner::InternalRunTasks(bool in_destructor) { tasks_running_ = true; - int64 previous_timeout_time = next_task_timeout(); + int64_t previous_timeout_time = next_task_timeout(); int did_run = true; while (did_run) { @@ -135,7 +135,7 @@ void TaskRunner::PollTasks() { } } -int64 TaskRunner::next_task_timeout() const { +int64_t TaskRunner::next_task_timeout() const { if (next_timeout_task_) { return next_timeout_task_->timeout_time(); } @@ -150,9 +150,9 @@ int64 TaskRunner::next_task_timeout() const { // effectively making the task scheduler O-1 instead of O-N void TaskRunner::UpdateTaskTimeout(Task* task, - int64 previous_task_timeout_time) { + int64_t previous_task_timeout_time) { ASSERT(task != NULL); - int64 previous_timeout_time = next_task_timeout(); + int64_t previous_timeout_time = next_task_timeout(); bool task_is_timeout_task = next_timeout_task_ != NULL && task->unique_id() == next_timeout_task_->unique_id(); if (task_is_timeout_task) { @@ -190,7 +190,7 @@ void TaskRunner::RecalcNextTimeout(Task *exclude_task) { // we're not excluding it // it has the closest timeout time - int64 next_timeout_time = 0; + int64_t next_timeout_time = 0; next_timeout_task_ = NULL; for (size_t i = 0; i < tasks_.size(); ++i) { @@ -210,8 +210,8 @@ void TaskRunner::RecalcNextTimeout(Task *exclude_task) { } } -void TaskRunner::CheckForTimeoutChange(int64 previous_timeout_time) { - int64 next_timeout = next_task_timeout(); +void TaskRunner::CheckForTimeoutChange(int64_t previous_timeout_time) { + int64_t next_timeout = next_task_timeout(); bool timeout_change = (previous_timeout_time == 0 && next_timeout != 0) || next_timeout < previous_timeout_time || (previous_timeout_time <= CurrentTime() && diff --git a/webrtc/base/taskrunner.h b/webrtc/base/taskrunner.h index bdcebc4bdc..9a43aac068 100644 --- a/webrtc/base/taskrunner.h +++ b/webrtc/base/taskrunner.h @@ -20,9 +20,9 @@ namespace rtc { class Task; -const int64 kSecToMsec = 1000; -const int64 kMsecTo100ns = 10000; -const int64 kSecTo100ns = kSecToMsec * kMsecTo100ns; +const int64_t kSecToMsec = 1000; +const int64_t kMsecTo100ns = 10000; +const int64_t kSecTo100ns = kSecToMsec * kMsecTo100ns; class TaskRunner : public TaskParent, public sigslot::has_slots<> { public: @@ -36,13 +36,13 @@ class TaskRunner : public TaskParent, public sigslot::has_slots<> { // the units and that rollover while the computer is running. // // On Windows, GetSystemTimeAsFileTime is the typical implementation. - virtual int64 CurrentTime() = 0 ; + virtual int64_t CurrentTime() = 0; void StartTask(Task *task); void RunTasks(); void PollTasks(); - void UpdateTaskTimeout(Task *task, int64 previous_task_timeout_time); + void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time); #ifdef _DEBUG bool is_ok_to_delete(Task* task) { @@ -60,7 +60,7 @@ class TaskRunner : public TaskParent, public sigslot::has_slots<> { // Returns the next absolute time when a task times out // OR "0" if there is no next timeout. - int64 next_task_timeout() const; + int64_t next_task_timeout() const; protected: // The primary usage of this method is to know if @@ -82,7 +82,7 @@ class TaskRunner : public TaskParent, public sigslot::has_slots<> { private: void InternalRunTasks(bool in_destructor); - void CheckForTimeoutChange(int64 previous_timeout_time); + void CheckForTimeoutChange(int64_t previous_timeout_time); std::vector tasks_; Task *next_timeout_task_; diff --git a/webrtc/base/testclient.cc b/webrtc/base/testclient.cc index 8483c4e8f4..c7484fa541 100644 --- a/webrtc/base/testclient.cc +++ b/webrtc/base/testclient.cc @@ -34,7 +34,7 @@ TestClient::~TestClient() { bool TestClient::CheckConnState(AsyncPacketSocket::State state) { // Wait for our timeout value until the socket reaches the desired state. - uint32 end = TimeAfter(kTimeoutMs); + uint32_t end = TimeAfter(kTimeoutMs); while (socket_->GetState() != state && TimeUntil(end) > 0) Thread::Current()->ProcessMessages(1); return (socket_->GetState() == state); @@ -63,7 +63,7 @@ TestClient::Packet* TestClient::NextPacket(int timeout_ms) { // Pumping another thread's queue could lead to messages being dispatched from // the wrong thread to non-thread-safe objects. - uint32 end = TimeAfter(timeout_ms); + uint32_t end = TimeAfter(timeout_ms); while (TimeUntil(end) > 0) { { CritScope cs(&crit_); diff --git a/webrtc/base/testutils.h b/webrtc/base/testutils.h index 4c978e7955..e56895d7ea 100644 --- a/webrtc/base/testutils.h +++ b/webrtc/base/testutils.h @@ -542,29 +542,33 @@ inline AssertionResult CmpHelperFileEq(const char* expected_expression, // order /////////////////////////////////////////////////////////////////////////////// -#define BYTE_CAST(x) static_cast((x) & 0xFF) +#define BYTE_CAST(x) static_cast((x)&0xFF) // Declare a N-bit integer as a little-endian sequence of bytes -#define LE16(x) BYTE_CAST(((uint16)x) >> 0), BYTE_CAST(((uint16)x) >> 8) +#define LE16(x) BYTE_CAST(((uint16_t)x) >> 0), BYTE_CAST(((uint16_t)x) >> 8) -#define LE32(x) BYTE_CAST(((uint32)x) >> 0), BYTE_CAST(((uint32)x) >> 8), \ - BYTE_CAST(((uint32)x) >> 16), BYTE_CAST(((uint32)x) >> 24) +#define LE32(x) \ + BYTE_CAST(((uint32_t)x) >> 0), BYTE_CAST(((uint32_t)x) >> 8), \ + BYTE_CAST(((uint32_t)x) >> 16), BYTE_CAST(((uint32_t)x) >> 24) -#define LE64(x) BYTE_CAST(((uint64)x) >> 0), BYTE_CAST(((uint64)x) >> 8), \ - BYTE_CAST(((uint64)x) >> 16), BYTE_CAST(((uint64)x) >> 24), \ - BYTE_CAST(((uint64)x) >> 32), BYTE_CAST(((uint64)x) >> 40), \ - BYTE_CAST(((uint64)x) >> 48), BYTE_CAST(((uint64)x) >> 56) +#define LE64(x) \ + BYTE_CAST(((uint64_t)x) >> 0), BYTE_CAST(((uint64_t)x) >> 8), \ + BYTE_CAST(((uint64_t)x) >> 16), BYTE_CAST(((uint64_t)x) >> 24), \ + BYTE_CAST(((uint64_t)x) >> 32), BYTE_CAST(((uint64_t)x) >> 40), \ + BYTE_CAST(((uint64_t)x) >> 48), BYTE_CAST(((uint64_t)x) >> 56) // Declare a N-bit integer as a big-endian (Internet) sequence of bytes -#define BE16(x) BYTE_CAST(((uint16)x) >> 8), BYTE_CAST(((uint16)x) >> 0) +#define BE16(x) BYTE_CAST(((uint16_t)x) >> 8), BYTE_CAST(((uint16_t)x) >> 0) -#define BE32(x) BYTE_CAST(((uint32)x) >> 24), BYTE_CAST(((uint32)x) >> 16), \ - BYTE_CAST(((uint32)x) >> 8), BYTE_CAST(((uint32)x) >> 0) +#define BE32(x) \ + BYTE_CAST(((uint32_t)x) >> 24), BYTE_CAST(((uint32_t)x) >> 16), \ + BYTE_CAST(((uint32_t)x) >> 8), BYTE_CAST(((uint32_t)x) >> 0) -#define BE64(x) BYTE_CAST(((uint64)x) >> 56), BYTE_CAST(((uint64)x) >> 48), \ - BYTE_CAST(((uint64)x) >> 40), BYTE_CAST(((uint64)x) >> 32), \ - BYTE_CAST(((uint64)x) >> 24), BYTE_CAST(((uint64)x) >> 16), \ - BYTE_CAST(((uint64)x) >> 8), BYTE_CAST(((uint64)x) >> 0) +#define BE64(x) \ + BYTE_CAST(((uint64_t)x) >> 56), BYTE_CAST(((uint64_t)x) >> 48), \ + BYTE_CAST(((uint64_t)x) >> 40), BYTE_CAST(((uint64_t)x) >> 32), \ + BYTE_CAST(((uint64_t)x) >> 24), BYTE_CAST(((uint64_t)x) >> 16), \ + BYTE_CAST(((uint64_t)x) >> 8), BYTE_CAST(((uint64_t)x) >> 0) // Declare a N-bit integer as a this-endian (local machine) sequence of bytes #ifndef BIG_ENDIAN diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc index 48a914451d..8ab381f4df 100644 --- a/webrtc/base/thread.cc +++ b/webrtc/base/thread.cc @@ -385,7 +385,7 @@ void Thread::Stop() { Join(); } -void Thread::Send(MessageHandler *phandler, uint32 id, MessageData *pdata) { +void Thread::Send(MessageHandler* phandler, uint32_t id, MessageData* pdata) { if (fStop_) return; @@ -495,7 +495,8 @@ void Thread::InvokeEnd() { TRACE_EVENT_END0("webrtc", "Thread::Invoke"); } -void Thread::Clear(MessageHandler *phandler, uint32 id, +void Thread::Clear(MessageHandler* phandler, + uint32_t id, MessageList* removed) { CritScope cs(&crit_); @@ -524,7 +525,7 @@ void Thread::Clear(MessageHandler *phandler, uint32 id, } bool Thread::ProcessMessages(int cmsLoop) { - uint32 msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); + uint32_t msEnd = (kForever == cmsLoop) ? 0 : TimeAfter(cmsLoop); int cmsNext = cmsLoop; while (true) { diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h index 1a04de56c4..9cbe8ec4dc 100644 --- a/webrtc/base/thread.h +++ b/webrtc/base/thread.h @@ -155,8 +155,9 @@ class Thread : public MessageQueue { // ProcessMessages occasionally. virtual void Run(); - virtual void Send(MessageHandler *phandler, uint32 id = 0, - MessageData *pdata = NULL); + virtual void Send(MessageHandler* phandler, + uint32_t id = 0, + MessageData* pdata = NULL); // Convenience method to invoke a functor on another thread. Caller must // provide the |ReturnT| template argument, which cannot (easily) be deduced. @@ -176,7 +177,7 @@ class Thread : public MessageQueue { // From MessageQueue void Clear(MessageHandler* phandler, - uint32 id = MQID_ANY, + uint32_t id = MQID_ANY, MessageList* removed = NULL) override; void ReceiveSends() override; diff --git a/webrtc/base/thread_unittest.cc b/webrtc/base/thread_unittest.cc index 7b9481e823..e50e45cd8a 100644 --- a/webrtc/base/thread_unittest.cc +++ b/webrtc/base/thread_unittest.cc @@ -66,9 +66,9 @@ class SocketClient : public TestGenerator, public sigslot::has_slots<> { void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size, const SocketAddress& remote_addr, const PacketTime& packet_time) { - EXPECT_EQ(size, sizeof(uint32)); - uint32 prev = reinterpret_cast(buf)[0]; - uint32 result = Next(prev); + EXPECT_EQ(size, sizeof(uint32_t)); + uint32_t prev = reinterpret_cast(buf)[0]; + uint32_t result = Next(prev); post_thread_->PostDelayed(200, post_handler_, 0, new TestMessage(result)); } diff --git a/webrtc/base/timeutils.cc b/webrtc/base/timeutils.cc index ffaf3266cc..fac5b66c7e 100644 --- a/webrtc/base/timeutils.cc +++ b/webrtc/base/timeutils.cc @@ -32,10 +32,10 @@ namespace rtc { -const uint32 HALF = 0x80000000; +const uint32_t HALF = 0x80000000; -uint64 TimeNanos() { - int64 ticks = 0; +uint64_t TimeNanos() { + int64_t ticks = 0; #if defined(WEBRTC_MAC) static mach_timebase_info_data_t timebase; if (timebase.denom == 0) { @@ -52,11 +52,11 @@ uint64 TimeNanos() { // TODO: Do we need to handle the case when CLOCK_MONOTONIC // is not supported? clock_gettime(CLOCK_MONOTONIC, &ts); - ticks = kNumNanosecsPerSec * static_cast(ts.tv_sec) + - static_cast(ts.tv_nsec); + ticks = kNumNanosecsPerSec * static_cast(ts.tv_sec) + + static_cast(ts.tv_nsec); #elif defined(WEBRTC_WIN) static volatile LONG last_timegettime = 0; - static volatile int64 num_wrap_timegettime = 0; + static volatile int64_t num_wrap_timegettime = 0; volatile LONG* last_timegettime_ptr = &last_timegettime; DWORD now = timeGetTime(); // Atomically update the last gotten time @@ -78,16 +78,16 @@ uint64 TimeNanos() { return ticks; } -uint32 Time() { - return static_cast(TimeNanos() / kNumNanosecsPerMillisec); +uint32_t Time() { + return static_cast(TimeNanos() / kNumNanosecsPerMillisec); } -uint64 TimeMicros() { - return static_cast(TimeNanos() / kNumNanosecsPerMicrosec); +uint64_t TimeMicros() { + return static_cast(TimeNanos() / kNumNanosecsPerMicrosec); } #if defined(WEBRTC_WIN) -static const uint64 kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL; +static const uint64_t kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL; struct timeval { long tv_sec, tv_usec; // NOLINT @@ -105,7 +105,7 @@ static int gettimeofday(struct timeval *tv, void *tz) { li.HighPart = ft.dwHighDateTime; // Convert to seconds and microseconds since Unix time Epoch. - int64 micros = (li.QuadPart - kFileTimeToUnixTimeEpochOffset) / 10; + int64_t micros = (li.QuadPart - kFileTimeToUnixTimeEpochOffset) / 10; tv->tv_sec = static_cast(micros / kNumMicrosecsPerSec); // NOLINT tv->tv_usec = static_cast(micros % kNumMicrosecsPerSec); // NOLINT @@ -135,13 +135,13 @@ void CurrentTmTime(struct tm *tm, int *microseconds) { *microseconds = timeval.tv_usec; } -uint32 TimeAfter(int32 elapsed) { +uint32_t TimeAfter(int32_t elapsed) { RTC_DCHECK_GE(elapsed, 0); - RTC_DCHECK_LT(static_cast(elapsed), HALF); + RTC_DCHECK_LT(static_cast(elapsed), HALF); return Time() + elapsed; } -bool TimeIsBetween(uint32 earlier, uint32 middle, uint32 later) { +bool TimeIsBetween(uint32_t earlier, uint32_t middle, uint32_t later) { if (earlier <= later) { return ((earlier <= middle) && (middle <= later)); } else { @@ -149,27 +149,27 @@ bool TimeIsBetween(uint32 earlier, uint32 middle, uint32 later) { } } -bool TimeIsLaterOrEqual(uint32 earlier, uint32 later) { +bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later) { #if EFFICIENT_IMPLEMENTATION - int32 diff = later - earlier; - return (diff >= 0 && static_cast(diff) < HALF); + int32_t diff = later - earlier; + return (diff >= 0 && static_cast(diff) < HALF); #else const bool later_or_equal = TimeIsBetween(earlier, later, earlier + HALF); return later_or_equal; #endif } -bool TimeIsLater(uint32 earlier, uint32 later) { +bool TimeIsLater(uint32_t earlier, uint32_t later) { #if EFFICIENT_IMPLEMENTATION - int32 diff = later - earlier; - return (diff > 0 && static_cast(diff) < HALF); + int32_t diff = later - earlier; + return (diff > 0 && static_cast(diff) < HALF); #else const bool earlier_or_equal = TimeIsBetween(later, earlier, later + HALF); return !earlier_or_equal; #endif } -int32 TimeDiff(uint32 later, uint32 earlier) { +int32_t TimeDiff(uint32_t later, uint32_t earlier) { #if EFFICIENT_IMPLEMENTATION return later - earlier; #else @@ -193,7 +193,7 @@ int32 TimeDiff(uint32 later, uint32 earlier) { TimestampWrapAroundHandler::TimestampWrapAroundHandler() : last_ts_(0), num_wrap_(0) {} -int64 TimestampWrapAroundHandler::Unwrap(uint32 ts) { +int64_t TimestampWrapAroundHandler::Unwrap(uint32_t ts) { if (ts < last_ts_) { if (last_ts_ > 0xf0000000 && ts < 0x0fffffff) { ++num_wrap_; diff --git a/webrtc/base/timeutils.h b/webrtc/base/timeutils.h index ca041a7d11..bdeccc3739 100644 --- a/webrtc/base/timeutils.h +++ b/webrtc/base/timeutils.h @@ -17,66 +17,68 @@ namespace rtc { -static const int64 kNumMillisecsPerSec = INT64_C(1000); -static const int64 kNumMicrosecsPerSec = INT64_C(1000000); -static const int64 kNumNanosecsPerSec = INT64_C(1000000000); +static const int64_t kNumMillisecsPerSec = INT64_C(1000); +static const int64_t kNumMicrosecsPerSec = INT64_C(1000000); +static const int64_t kNumNanosecsPerSec = INT64_C(1000000000); -static const int64 kNumMicrosecsPerMillisec = kNumMicrosecsPerSec / - kNumMillisecsPerSec; -static const int64 kNumNanosecsPerMillisec = kNumNanosecsPerSec / - kNumMillisecsPerSec; -static const int64 kNumNanosecsPerMicrosec = kNumNanosecsPerSec / - kNumMicrosecsPerSec; +static const int64_t kNumMicrosecsPerMillisec = + kNumMicrosecsPerSec / kNumMillisecsPerSec; +static const int64_t kNumNanosecsPerMillisec = + kNumNanosecsPerSec / kNumMillisecsPerSec; +static const int64_t kNumNanosecsPerMicrosec = + kNumNanosecsPerSec / kNumMicrosecsPerSec; // January 1970, in NTP milliseconds. -static const int64 kJan1970AsNtpMillisecs = INT64_C(2208988800000); +static const int64_t kJan1970AsNtpMillisecs = INT64_C(2208988800000); -typedef uint32 TimeStamp; +typedef uint32_t TimeStamp; // Returns the current time in milliseconds. -uint32 Time(); +uint32_t Time(); // Returns the current time in microseconds. -uint64 TimeMicros(); +uint64_t TimeMicros(); // Returns the current time in nanoseconds. -uint64 TimeNanos(); +uint64_t TimeNanos(); // Stores current time in *tm and microseconds in *microseconds. void CurrentTmTime(struct tm *tm, int *microseconds); // Returns a future timestamp, 'elapsed' milliseconds from now. -uint32 TimeAfter(int32 elapsed); +uint32_t TimeAfter(int32_t elapsed); // Comparisons between time values, which can wrap around. -bool TimeIsBetween(uint32 earlier, uint32 middle, uint32 later); // Inclusive -bool TimeIsLaterOrEqual(uint32 earlier, uint32 later); // Inclusive -bool TimeIsLater(uint32 earlier, uint32 later); // Exclusive +bool TimeIsBetween(uint32_t earlier, + uint32_t middle, + uint32_t later); // Inclusive +bool TimeIsLaterOrEqual(uint32_t earlier, uint32_t later); // Inclusive +bool TimeIsLater(uint32_t earlier, uint32_t later); // Exclusive // Returns the later of two timestamps. -inline uint32 TimeMax(uint32 ts1, uint32 ts2) { +inline uint32_t TimeMax(uint32_t ts1, uint32_t ts2) { return TimeIsLaterOrEqual(ts1, ts2) ? ts2 : ts1; } // Returns the earlier of two timestamps. -inline uint32 TimeMin(uint32 ts1, uint32 ts2) { +inline uint32_t TimeMin(uint32_t ts1, uint32_t ts2) { return TimeIsLaterOrEqual(ts1, ts2) ? ts1 : ts2; } // Number of milliseconds that would elapse between 'earlier' and 'later' // timestamps. The value is negative if 'later' occurs before 'earlier'. -int32 TimeDiff(uint32 later, uint32 earlier); +int32_t TimeDiff(uint32_t later, uint32_t earlier); // The number of milliseconds that have elapsed since 'earlier'. -inline int32 TimeSince(uint32 earlier) { +inline int32_t TimeSince(uint32_t earlier) { return TimeDiff(Time(), earlier); } // The number of milliseconds that will elapse between now and 'later'. -inline int32 TimeUntil(uint32 later) { +inline int32_t TimeUntil(uint32_t later) { return TimeDiff(later, Time()); } // Converts a unix timestamp in nanoseconds to an NTP timestamp in ms. -inline int64 UnixTimestampNanosecsToNtpMillisecs(int64 unix_ts_ns) { +inline int64_t UnixTimestampNanosecsToNtpMillisecs(int64_t unix_ts_ns) { return unix_ts_ns / kNumNanosecsPerMillisec + kJan1970AsNtpMillisecs; } @@ -84,11 +86,11 @@ class TimestampWrapAroundHandler { public: TimestampWrapAroundHandler(); - int64 Unwrap(uint32 ts); + int64_t Unwrap(uint32_t ts); private: - uint32 last_ts_; - int64 num_wrap_; + uint32_t last_ts_; + int64_t num_wrap_; }; } // namespace rtc diff --git a/webrtc/base/timeutils_unittest.cc b/webrtc/base/timeutils_unittest.cc index 087fb0c28b..d1b9ad4f96 100644 --- a/webrtc/base/timeutils_unittest.cc +++ b/webrtc/base/timeutils_unittest.cc @@ -16,9 +16,9 @@ namespace rtc { TEST(TimeTest, TimeInMs) { - uint32 ts_earlier = Time(); + uint32_t ts_earlier = Time(); Thread::SleepMs(100); - uint32 ts_now = Time(); + uint32_t ts_now = Time(); // Allow for the thread to wakeup ~20ms early. EXPECT_GE(ts_now, ts_earlier + 80); // Make sure the Time is not returning in smaller unit like microseconds. @@ -152,8 +152,8 @@ class TimestampWrapAroundHandlerTest : public testing::Test { }; TEST_F(TimestampWrapAroundHandlerTest, Unwrap) { - uint32 ts = 0xfffffff2; - int64 unwrapped_ts = ts; + uint32_t ts = 0xfffffff2; + int64_t unwrapped_ts = ts; EXPECT_EQ(ts, wraparound_handler_.Unwrap(ts)); ts = 2; unwrapped_ts += 0x10; diff --git a/webrtc/base/unixfilesystem.cc b/webrtc/base/unixfilesystem.cc index 081d561dba..30d6e7872e 100644 --- a/webrtc/base/unixfilesystem.cc +++ b/webrtc/base/unixfilesystem.cc @@ -502,7 +502,8 @@ bool UnixFilesystem::GetAppTempFolder(Pathname* path) { #endif } -bool UnixFilesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { +bool UnixFilesystem::GetDiskFreeSpace(const Pathname& path, + int64_t* freebytes) { #ifdef __native_client__ return false; #else // __native_client__ @@ -526,9 +527,9 @@ bool UnixFilesystem::GetDiskFreeSpace(const Pathname& path, int64 *freebytes) { return false; #endif // WEBRTC_ANDROID #if defined(WEBRTC_LINUX) - *freebytes = static_cast(vfs.f_bsize) * vfs.f_bavail; + *freebytes = static_cast(vfs.f_bsize) * vfs.f_bavail; #elif defined(WEBRTC_MAC) - *freebytes = static_cast(vfs.f_frsize) * vfs.f_bavail; + *freebytes = static_cast(vfs.f_frsize) * vfs.f_bavail; #endif return true; diff --git a/webrtc/base/unixfilesystem.h b/webrtc/base/unixfilesystem.h index e220911187..dbfbaf0a7d 100644 --- a/webrtc/base/unixfilesystem.h +++ b/webrtc/base/unixfilesystem.h @@ -107,7 +107,7 @@ class UnixFilesystem : public FilesystemInterface { // Get a temporary folder that is unique to the current user and application. bool GetAppTempFolder(Pathname* path) override; - bool GetDiskFreeSpace(const Pathname& path, int64* freebytes) override; + bool GetDiskFreeSpace(const Pathname& path, int64_t* freebytes) override; // Returns the absolute path of the current directory. Pathname GetCurrentDirectory() override; diff --git a/webrtc/base/virtualsocket_unittest.cc b/webrtc/base/virtualsocket_unittest.cc index a656691b50..694b154a4d 100644 --- a/webrtc/base/virtualsocket_unittest.cc +++ b/webrtc/base/virtualsocket_unittest.cc @@ -27,15 +27,18 @@ using namespace rtc; // Sends at a constant rate but with random packet sizes. struct Sender : public MessageHandler { - Sender(Thread* th, AsyncSocket* s, uint32 rt) - : thread(th), socket(new AsyncUDPSocket(s)), - done(false), rate(rt), count(0) { + Sender(Thread* th, AsyncSocket* s, uint32_t rt) + : thread(th), + socket(new AsyncUDPSocket(s)), + done(false), + rate(rt), + count(0) { last_send = rtc::Time(); thread->PostDelayed(NextDelay(), this, 1); } - uint32 NextDelay() { - uint32 size = (rand() % 4096) + 1; + uint32_t NextDelay() { + uint32_t size = (rand() % 4096) + 1; return 1000 * size / rate; } @@ -45,11 +48,11 @@ struct Sender : public MessageHandler { if (done) return; - uint32 cur_time = rtc::Time(); - uint32 delay = cur_time - last_send; - uint32 size = rate * delay / 1000; - size = std::min(size, 4096); - size = std::max(size, sizeof(uint32)); + uint32_t cur_time = rtc::Time(); + uint32_t delay = cur_time - last_send; + uint32_t size = rate * delay / 1000; + size = std::min(size, 4096); + size = std::max(size, sizeof(uint32_t)); count += size; memcpy(dummy, &cur_time, sizeof(cur_time)); @@ -63,16 +66,23 @@ struct Sender : public MessageHandler { scoped_ptr socket; rtc::PacketOptions options; bool done; - uint32 rate; // bytes per second - uint32 count; - uint32 last_send; + uint32_t rate; // bytes per second + uint32_t count; + uint32_t last_send; char dummy[4096]; }; struct Receiver : public MessageHandler, public sigslot::has_slots<> { - Receiver(Thread* th, AsyncSocket* s, uint32 bw) - : thread(th), socket(new AsyncUDPSocket(s)), bandwidth(bw), done(false), - count(0), sec_count(0), sum(0), sum_sq(0), samples(0) { + Receiver(Thread* th, AsyncSocket* s, uint32_t bw) + : thread(th), + socket(new AsyncUDPSocket(s)), + bandwidth(bw), + done(false), + count(0), + sec_count(0), + sum(0), + sum_sq(0), + samples(0) { socket->SignalReadPacket.connect(this, &Receiver::OnReadPacket); thread->PostDelayed(1000, this, 1); } @@ -90,9 +100,9 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> { count += size; sec_count += size; - uint32 send_time = *reinterpret_cast(data); - uint32 recv_time = rtc::Time(); - uint32 delay = recv_time - send_time; + uint32_t send_time = *reinterpret_cast(data); + uint32_t recv_time = rtc::Time(); + uint32_t delay = recv_time - send_time; sum += delay; sum_sq += delay * delay; samples += 1; @@ -114,13 +124,13 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> { Thread* thread; scoped_ptr socket; - uint32 bandwidth; + uint32_t bandwidth; bool done; size_t count; size_t sec_count; double sum; double sum_sq; - uint32 samples; + uint32_t samples; }; class VirtualSocketServerTest : public testing::Test { @@ -143,8 +153,8 @@ class VirtualSocketServerTest : public testing::Test { } else if (post_ip.family() == AF_INET6) { in6_addr post_ip6 = post_ip.ipv6_address(); in6_addr pre_ip6 = pre_ip.ipv6_address(); - uint32* post_as_ints = reinterpret_cast(&post_ip6.s6_addr); - uint32* pre_as_ints = reinterpret_cast(&pre_ip6.s6_addr); + uint32_t* post_as_ints = reinterpret_cast(&post_ip6.s6_addr); + uint32_t* pre_as_ints = reinterpret_cast(&pre_ip6.s6_addr); EXPECT_EQ(post_as_ints[3], pre_as_ints[3]); } } @@ -620,8 +630,8 @@ class VirtualSocketServerTest : public testing::Test { } // Next, deliver packets at random intervals - const uint32 mean = 50; - const uint32 stddev = 50; + const uint32_t mean = 50; + const uint32_t stddev = 50; ss_->set_delay_mean(mean); ss_->set_delay_stddev(stddev); @@ -654,7 +664,7 @@ class VirtualSocketServerTest : public testing::Test { EXPECT_EQ(recv_socket->GetLocalAddress().family(), initial_addr.family()); ASSERT_EQ(0, send_socket->Connect(recv_socket->GetLocalAddress())); - uint32 bandwidth = 64 * 1024; + uint32_t bandwidth = 64 * 1024; ss_->set_bandwidth(bandwidth); Thread* pthMain = Thread::Current(); @@ -679,8 +689,8 @@ class VirtualSocketServerTest : public testing::Test { LOG(LS_VERBOSE) << "seed = " << seed; srand(static_cast(seed)); - const uint32 mean = 2000; - const uint32 stddev = 500; + const uint32_t mean = 2000; + const uint32_t stddev = 500; ss_->set_delay_mean(mean); ss_->set_delay_stddev(stddev); @@ -1008,16 +1018,16 @@ TEST_F(VirtualSocketServerTest, CanSendDatagramFromUnboundIPv6ToIPv4Any) { } TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { - const uint32 kTestMean[] = { 10, 100, 333, 1000 }; + const uint32_t kTestMean[] = {10, 100, 333, 1000}; const double kTestDev[] = { 0.25, 0.1, 0.01 }; // TODO: The current code only works for 1000 data points or more. - const uint32 kTestSamples[] = { /*10, 100,*/ 1000 }; + const uint32_t kTestSamples[] = {/*10, 100,*/ 1000}; for (size_t midx = 0; midx < ARRAY_SIZE(kTestMean); ++midx) { for (size_t didx = 0; didx < ARRAY_SIZE(kTestDev); ++didx) { for (size_t sidx = 0; sidx < ARRAY_SIZE(kTestSamples); ++sidx) { ASSERT_LT(0u, kTestSamples[sidx]); - const uint32 kStdDev = - static_cast(kTestDev[didx] * kTestMean[midx]); + const uint32_t kStdDev = + static_cast(kTestDev[didx] * kTestMean[midx]); VirtualSocketServer::Function* f = VirtualSocketServer::CreateDistribution(kTestMean[midx], kStdDev, @@ -1025,12 +1035,12 @@ TEST_F(VirtualSocketServerTest, CreatesStandardDistribution) { ASSERT_TRUE(NULL != f); ASSERT_EQ(kTestSamples[sidx], f->size()); double sum = 0; - for (uint32 i = 0; i < f->size(); ++i) { + for (uint32_t i = 0; i < f->size(); ++i) { sum += (*f)[i].second; } const double mean = sum / f->size(); double sum_sq_dev = 0; - for (uint32 i = 0; i < f->size(); ++i) { + for (uint32_t i = 0; i < f->size(); ++i) { double dev = (*f)[i].second - mean; sum_sq_dev += dev * dev; } diff --git a/webrtc/base/virtualsocketserver.cc b/webrtc/base/virtualsocketserver.cc index 4568bf239a..867aeec630 100644 --- a/webrtc/base/virtualsocketserver.cc +++ b/webrtc/base/virtualsocketserver.cc @@ -37,15 +37,16 @@ const in6_addr kInitialNextIPv6 = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 } } }; -const uint16 kFirstEphemeralPort = 49152; -const uint16 kLastEphemeralPort = 65535; -const uint16 kEphemeralPortCount = kLastEphemeralPort - kFirstEphemeralPort + 1; -const uint32 kDefaultNetworkCapacity = 64 * 1024; -const uint32 kDefaultTcpBufferSize = 32 * 1024; +const uint16_t kFirstEphemeralPort = 49152; +const uint16_t kLastEphemeralPort = 65535; +const uint16_t kEphemeralPortCount = + kLastEphemeralPort - kFirstEphemeralPort + 1; +const uint32_t kDefaultNetworkCapacity = 64 * 1024; +const uint32_t kDefaultTcpBufferSize = 32 * 1024; -const uint32 UDP_HEADER_SIZE = 28; // IP + UDP headers -const uint32 TCP_HEADER_SIZE = 40; // IP + TCP headers -const uint32 TCP_MSS = 1400; // Maximum segment size +const uint32_t UDP_HEADER_SIZE = 28; // IP + UDP headers +const uint32_t TCP_HEADER_SIZE = 40; // IP + TCP headers +const uint32_t TCP_MSS = 1400; // Maximum segment size // Note: The current algorithm doesn't work for sample sizes smaller than this. const int NUM_SAMPLES = 1000; @@ -375,7 +376,7 @@ int VirtualSocket::SetOption(Option opt, int value) { return 0; // 0 is success to emulate setsockopt() } -int VirtualSocket::EstimateMTU(uint16* mtu) { +int VirtualSocket::EstimateMTU(uint16_t* mtu) { if (CS_CONNECTED != state_) return ENOTCONN; else @@ -532,15 +533,15 @@ IPAddress VirtualSocketServer::GetNextIP(int family) { return next_ip; } else if (family == AF_INET6) { IPAddress next_ip(next_ipv6_); - uint32* as_ints = reinterpret_cast(&next_ipv6_.s6_addr); + uint32_t* as_ints = reinterpret_cast(&next_ipv6_.s6_addr); as_ints[3] += 1; return next_ip; } return IPAddress(); } -uint16 VirtualSocketServer::GetNextPort() { - uint16 port = next_port_; +uint16_t VirtualSocketServer::GetNextPort() { + uint16_t port = next_port_; if (next_port_ < kLastEphemeralPort) { ++next_port_; } else { @@ -602,7 +603,7 @@ bool VirtualSocketServer::ProcessMessagesUntilIdle() { return !msg_queue_->IsQuitting(); } -void VirtualSocketServer::SetNextPortForTesting(uint16 port) { +void VirtualSocketServer::SetNextPortForTesting(uint16_t port) { next_port_ = port; } @@ -731,7 +732,7 @@ static double Random() { int VirtualSocketServer::Connect(VirtualSocket* socket, const SocketAddress& remote_addr, bool use_delay) { - uint32 delay = use_delay ? GetRandomTransitDelay() : 0; + uint32_t delay = use_delay ? GetRandomTransitDelay() : 0; VirtualSocket* remote = LookupBinding(remote_addr); if (!CanInteractWith(socket, remote)) { LOG(LS_INFO) << "Address family mismatch between " @@ -790,7 +791,7 @@ int VirtualSocketServer::SendUdp(VirtualSocket* socket, CritScope cs(&socket->crit_); - uint32 cur_time = Time(); + uint32_t cur_time = Time(); PurgeNetworkPackets(socket, cur_time); // Determine whether we have enough bandwidth to accept this packet. To do @@ -830,7 +831,7 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) { CritScope cs(&socket->crit_); - uint32 cur_time = Time(); + uint32_t cur_time = Time(); PurgeNetworkPackets(socket, cur_time); while (true) { @@ -865,7 +866,7 @@ void VirtualSocketServer::SendTcp(VirtualSocket* socket) { void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, VirtualSocket* recipient, - uint32 cur_time, + uint32_t cur_time, const char* data, size_t data_size, size_t header_size, @@ -874,12 +875,12 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, entry.size = data_size + header_size; sender->network_size_ += entry.size; - uint32 send_delay = SendDelay(static_cast(sender->network_size_)); + uint32_t send_delay = SendDelay(static_cast(sender->network_size_)); entry.done_time = cur_time + send_delay; sender->network_.push_back(entry); // Find the delay for crossing the many virtual hops of the network. - uint32 transit_delay = GetRandomTransitDelay(); + uint32_t transit_delay = GetRandomTransitDelay(); // When the incoming packet is from a binding of the any address, translate it // to the default route here such that the recipient will see the default @@ -893,7 +894,7 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, // Post the packet as a message to be delivered (on our own thread) Packet* p = new Packet(data, data_size, sender_addr); - uint32 ts = TimeAfter(send_delay + transit_delay); + uint32_t ts = TimeAfter(send_delay + transit_delay); if (ordered) { // Ensure that new packets arrive after previous ones // TODO: consider ordering on a per-socket basis, since this @@ -905,7 +906,7 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender, } void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket, - uint32 cur_time) { + uint32_t cur_time) { while (!socket->network_.empty() && (socket->network_.front().done_time <= cur_time)) { ASSERT(socket->network_size_ >= socket->network_.front().size); @@ -914,7 +915,7 @@ void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket, } } -uint32 VirtualSocketServer::SendDelay(uint32 size) { +uint32_t VirtualSocketServer::SendDelay(uint32_t size) { if (bandwidth_ == 0) return 0; else @@ -925,14 +926,14 @@ uint32 VirtualSocketServer::SendDelay(uint32 size) { void PrintFunction(std::vector >* f) { return; double sum = 0; - for (uint32 i = 0; i < f->size(); ++i) { + for (uint32_t i = 0; i < f->size(); ++i) { std::cout << (*f)[i].first << '\t' << (*f)[i].second << std::endl; sum += (*f)[i].second; } if (!f->empty()) { const double mean = sum / f->size(); double sum_sq_dev = 0; - for (uint32 i = 0; i < f->size(); ++i) { + for (uint32_t i = 0; i < f->size(); ++i) { double dev = (*f)[i].second - mean; sum_sq_dev += dev * dev; } @@ -970,7 +971,9 @@ static double Pareto(double x, double min, double k) { #endif VirtualSocketServer::Function* VirtualSocketServer::CreateDistribution( - uint32 mean, uint32 stddev, uint32 samples) { + uint32_t mean, + uint32_t stddev, + uint32_t samples) { Function* f = new Function(); if (0 == stddev) { @@ -981,7 +984,7 @@ VirtualSocketServer::Function* VirtualSocketServer::CreateDistribution( start = mean - 4 * static_cast(stddev); double end = mean + 4 * static_cast(stddev); - for (uint32 i = 0; i < samples; i++) { + for (uint32_t i = 0; i < samples; i++) { double x = start + (end - start) * i / (samples - 1); double y = Normal(x, mean, stddev); f->push_back(Point(x, y)); @@ -990,11 +993,11 @@ VirtualSocketServer::Function* VirtualSocketServer::CreateDistribution( return Resample(Invert(Accumulate(f)), 0, 1, samples); } -uint32 VirtualSocketServer::GetRandomTransitDelay() { +uint32_t VirtualSocketServer::GetRandomTransitDelay() { size_t index = rand() % delay_dist_->size(); double delay = (*delay_dist_)[index].second; //LOG_F(LS_INFO) << "random[" << index << "] = " << delay; - return static_cast(delay); + return static_cast(delay); } struct FunctionDomainCmp { @@ -1031,8 +1034,10 @@ VirtualSocketServer::Function* VirtualSocketServer::Invert(Function* f) { return f; } -VirtualSocketServer::Function* VirtualSocketServer::Resample( - Function* f, double x1, double x2, uint32 samples) { +VirtualSocketServer::Function* VirtualSocketServer::Resample(Function* f, + double x1, + double x2, + uint32_t samples) { Function* g = new Function(); for (size_t i = 0; i < samples; i++) { diff --git a/webrtc/base/virtualsocketserver.h b/webrtc/base/virtualsocketserver.h index f1f5d6df15..daf0145a26 100644 --- a/webrtc/base/virtualsocketserver.h +++ b/webrtc/base/virtualsocketserver.h @@ -45,39 +45,35 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { // Limits the network bandwidth (maximum bytes per second). Zero means that // all sends occur instantly. Defaults to 0. - uint32 bandwidth() const { return bandwidth_; } - void set_bandwidth(uint32 bandwidth) { bandwidth_ = bandwidth; } + uint32_t bandwidth() const { return bandwidth_; } + void set_bandwidth(uint32_t bandwidth) { bandwidth_ = bandwidth; } // Limits the amount of data which can be in flight on the network without // packet loss (on a per sender basis). Defaults to 64 KB. - uint32 network_capacity() const { return network_capacity_; } - void set_network_capacity(uint32 capacity) { - network_capacity_ = capacity; - } + uint32_t network_capacity() const { return network_capacity_; } + void set_network_capacity(uint32_t capacity) { network_capacity_ = capacity; } // The amount of data which can be buffered by tcp on the sender's side - uint32 send_buffer_capacity() const { return send_buffer_capacity_; } - void set_send_buffer_capacity(uint32 capacity) { + uint32_t send_buffer_capacity() const { return send_buffer_capacity_; } + void set_send_buffer_capacity(uint32_t capacity) { send_buffer_capacity_ = capacity; } // The amount of data which can be buffered by tcp on the receiver's side - uint32 recv_buffer_capacity() const { return recv_buffer_capacity_; } - void set_recv_buffer_capacity(uint32 capacity) { + uint32_t recv_buffer_capacity() const { return recv_buffer_capacity_; } + void set_recv_buffer_capacity(uint32_t capacity) { recv_buffer_capacity_ = capacity; } // Controls the (transit) delay for packets sent in the network. This does // not inclue the time required to sit in the send queue. Both of these // values are measured in milliseconds. Defaults to no delay. - uint32 delay_mean() const { return delay_mean_; } - uint32 delay_stddev() const { return delay_stddev_; } - uint32 delay_samples() const { return delay_samples_; } - void set_delay_mean(uint32 delay_mean) { delay_mean_ = delay_mean; } - void set_delay_stddev(uint32 delay_stddev) { - delay_stddev_ = delay_stddev; - } - void set_delay_samples(uint32 delay_samples) { + uint32_t delay_mean() const { return delay_mean_; } + uint32_t delay_stddev() const { return delay_stddev_; } + uint32_t delay_samples() const { return delay_samples_; } + void set_delay_mean(uint32_t delay_mean) { delay_mean_ = delay_mean; } + void set_delay_stddev(uint32_t delay_stddev) { delay_stddev_ = delay_stddev; } + void set_delay_samples(uint32_t delay_samples) { delay_samples_ = delay_samples; } @@ -108,8 +104,9 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { typedef std::pair Point; typedef std::vector Function; - static Function* CreateDistribution(uint32 mean, uint32 stddev, - uint32 samples); + static Function* CreateDistribution(uint32_t mean, + uint32_t stddev, + uint32_t samples); // Similar to Thread::ProcessMessages, but it only processes messages until // there are no immediate messages or pending network traffic. Returns false @@ -117,7 +114,7 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { bool ProcessMessagesUntilIdle(); // Sets the next port number to use for testing. - void SetNextPortForTesting(uint16 port); + void SetNextPortForTesting(uint16_t port); // Close a pair of Tcp connections by addresses. Both connections will have // its own OnClose invoked. @@ -127,7 +124,7 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { protected: // Returns a new IP not used before in this network. IPAddress GetNextIP(int family); - uint16 GetNextPort(); + uint16_t GetNextPort(); VirtualSocket* CreateSocketInternal(int family, int type); @@ -169,24 +166,31 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { void SendTcp(VirtualSocket* socket); // Places a packet on the network. - void AddPacketToNetwork(VirtualSocket* socket, VirtualSocket* recipient, - uint32 cur_time, const char* data, size_t data_size, - size_t header_size, bool ordered); + void AddPacketToNetwork(VirtualSocket* socket, + VirtualSocket* recipient, + uint32_t cur_time, + const char* data, + size_t data_size, + size_t header_size, + bool ordered); // Removes stale packets from the network - void PurgeNetworkPackets(VirtualSocket* socket, uint32 cur_time); + void PurgeNetworkPackets(VirtualSocket* socket, uint32_t cur_time); // Computes the number of milliseconds required to send a packet of this size. - uint32 SendDelay(uint32 size); + uint32_t SendDelay(uint32_t size); // Returns a random transit delay chosen from the appropriate distribution. - uint32 GetRandomTransitDelay(); + uint32_t GetRandomTransitDelay(); // Basic operations on functions. Those that return a function also take // ownership of the function given (and hence, may modify or delete it). static Function* Accumulate(Function* f); static Function* Invert(Function* f); - static Function* Resample(Function* f, double x1, double x2, uint32 samples); + static Function* Resample(Function* f, + double x1, + double x2, + uint32_t samples); static double Evaluate(Function* f, double x); // NULL out our message queue if it goes away. Necessary in the case where @@ -222,23 +226,23 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { bool server_owned_; MessageQueue* msg_queue_; bool stop_on_idle_; - uint32 network_delay_; + uint32_t network_delay_; in_addr next_ipv4_; in6_addr next_ipv6_; - uint16 next_port_; + uint16_t next_port_; AddressMap* bindings_; ConnectionMap* connections_; IPAddress default_route_v4_; IPAddress default_route_v6_; - uint32 bandwidth_; - uint32 network_capacity_; - uint32 send_buffer_capacity_; - uint32 recv_buffer_capacity_; - uint32 delay_mean_; - uint32 delay_stddev_; - uint32 delay_samples_; + uint32_t bandwidth_; + uint32_t network_capacity_; + uint32_t send_buffer_capacity_; + uint32_t recv_buffer_capacity_; + uint32_t delay_mean_; + uint32_t delay_stddev_; + uint32_t delay_samples_; Function* delay_dist_; CriticalSection delay_crit_; @@ -276,7 +280,7 @@ class VirtualSocket : public AsyncSocket, public MessageHandler { ConnState GetState() const override; int GetOption(Option opt, int* value) override; int SetOption(Option opt, int value) override; - int EstimateMTU(uint16* mtu) override; + int EstimateMTU(uint16_t* mtu) override; void OnMessage(Message* pmsg) override; bool was_any() { return was_any_; } @@ -288,7 +292,7 @@ class VirtualSocket : public AsyncSocket, public MessageHandler { private: struct NetworkEntry { size_t size; - uint32 done_time; + uint32_t done_time; }; typedef std::deque ListenQueue; diff --git a/webrtc/base/win32.cc b/webrtc/base/win32.cc index 1f32e48fc7..6e09829153 100644 --- a/webrtc/base/win32.cc +++ b/webrtc/base/win32.cc @@ -82,8 +82,7 @@ const char* inet_ntop_v6(const void* src, char* dst, socklen_t size) { if (size < INET6_ADDRSTRLEN) { return NULL; } - const uint16* as_shorts = - reinterpret_cast(src); + const uint16_t* as_shorts = reinterpret_cast(src); int runpos[8]; int current = 1; int max = 0; @@ -214,8 +213,8 @@ int inet_pton_v6(const char* src, void* dst) { struct in6_addr an_addr; memset(&an_addr, 0, sizeof(an_addr)); - uint16* addr_cursor = reinterpret_cast(&an_addr.s6_addr[0]); - uint16* addr_end = reinterpret_cast(&an_addr.s6_addr[16]); + uint16_t* addr_cursor = reinterpret_cast(&an_addr.s6_addr[0]); + uint16_t* addr_end = reinterpret_cast(&an_addr.s6_addr[16]); bool seencompressed = false; // Addresses that start with "::" (i.e., a run of initial zeros) or @@ -228,7 +227,7 @@ int inet_pton_v6(const char* src, void* dst) { if (rtc::strchr(addrstart, ".")) { const char* colon = rtc::strchr(addrstart, "::"); if (colon) { - uint16 a_short; + uint16_t a_short; int bytesread = 0; if (sscanf(addrstart, "%hx%n", &a_short, &bytesread) != 1 || a_short != 0xFFFF || bytesread != 4) { @@ -283,7 +282,7 @@ int inet_pton_v6(const char* src, void* dst) { ++readcursor; } } else { - uint16 word; + uint16_t word; int bytesread = 0; if (sscanf(readcursor, "%hx%n", &word, &bytesread) != 1) { return 0; @@ -362,7 +361,7 @@ void UnixTimeToFileTime(const time_t& ut, FILETIME* ft) { // base date value. const ULONGLONG RATIO = 10000000; ULARGE_INTEGER current_ul; - current_ul.QuadPart = base_ul.QuadPart + static_cast(ut) * RATIO; + current_ul.QuadPart = base_ul.QuadPart + static_cast(ut) * RATIO; memcpy(ft, ¤t_ul, sizeof(FILETIME)); } diff --git a/webrtc/base/win32.h b/webrtc/base/win32.h index 9824f6b1db..dba9b773b5 100644 --- a/webrtc/base/win32.h +++ b/webrtc/base/win32.h @@ -85,7 +85,7 @@ void UnixTimeToFileTime(const time_t& ut, FILETIME * ft); bool Utf8ToWindowsFilename(const std::string& utf8, std::wstring* filename); // Convert a FILETIME to a UInt64 -inline uint64 ToUInt64(const FILETIME& ft) { +inline uint64_t ToUInt64(const FILETIME& ft) { ULARGE_INTEGER r = {{ft.dwLowDateTime, ft.dwHighDateTime}}; return r.QuadPart; } diff --git a/webrtc/base/win32_unittest.cc b/webrtc/base/win32_unittest.cc index 2bd93acc1c..15b2614111 100644 --- a/webrtc/base/win32_unittest.cc +++ b/webrtc/base/win32_unittest.cc @@ -32,7 +32,7 @@ TEST_F(Win32Test, FileTimeToUInt64Test) { ft.dwHighDateTime = 0xBAADF00D; ft.dwLowDateTime = 0xFEED3456; - uint64 expected = 0xBAADF00DFEED3456; + uint64_t expected = 0xBAADF00DFEED3456; EXPECT_EQ(expected, ToUInt64(ft)); } diff --git a/webrtc/base/win32filesystem.cc b/webrtc/base/win32filesystem.cc index 9ca4c996d6..8ac918ff83 100644 --- a/webrtc/base/win32filesystem.cc +++ b/webrtc/base/win32filesystem.cc @@ -379,7 +379,7 @@ bool Win32Filesystem::GetAppTempFolder(Pathname* path) { } bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, - int64 *free_bytes) { + int64_t* free_bytes) { if (!free_bytes) { return false; } @@ -405,11 +405,11 @@ bool Win32Filesystem::GetDiskFreeSpace(const Pathname& path, return false; } - int64 total_number_of_bytes; // receives the number of bytes on disk - int64 total_number_of_free_bytes; // receives the free bytes on disk + int64_t total_number_of_bytes; // receives the number of bytes on disk + int64_t total_number_of_free_bytes; // receives the free bytes on disk // make sure things won't change in 64 bit machine // TODO replace with compile time assert - ASSERT(sizeof(ULARGE_INTEGER) == sizeof(uint64)); //NOLINT + ASSERT(sizeof(ULARGE_INTEGER) == sizeof(uint64_t)); // NOLINT if (::GetDiskFreeSpaceEx(target_drive, (PULARGE_INTEGER)free_bytes, (PULARGE_INTEGER)&total_number_of_bytes, diff --git a/webrtc/base/win32filesystem.h b/webrtc/base/win32filesystem.h index 0ae921843e..439b2c6268 100644 --- a/webrtc/base/win32filesystem.h +++ b/webrtc/base/win32filesystem.h @@ -91,7 +91,7 @@ class Win32Filesystem : public FilesystemInterface { // Get a temporary folder that is unique to the current user and application. virtual bool GetAppTempFolder(Pathname* path); - virtual bool GetDiskFreeSpace(const Pathname& path, int64 *free_bytes); + virtual bool GetDiskFreeSpace(const Pathname& path, int64_t* free_bytes); virtual Pathname GetCurrentDirectory(); }; diff --git a/webrtc/base/win32regkey.cc b/webrtc/base/win32regkey.cc index 1ed0d4ea29..ccf931c14a 100644 --- a/webrtc/base/win32regkey.cc +++ b/webrtc/base/win32regkey.cc @@ -100,22 +100,22 @@ HRESULT RegKey::SetValue(const wchar_t* full_key_name, HRESULT RegKey::SetValue(const wchar_t* full_key_name, const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count) { ASSERT(full_key_name != NULL); return SetValueStaticHelper(full_key_name, value_name, REG_BINARY, - const_cast(value), byte_count); + const_cast(value), byte_count); } HRESULT RegKey::SetValueMultiSZ(const wchar_t* full_key_name, const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count) { ASSERT(full_key_name != NULL); return SetValueStaticHelper(full_key_name, value_name, REG_MULTI_SZ, - const_cast(value), byte_count); + const_cast(value), byte_count); } HRESULT RegKey::GetValue(const wchar_t* full_key_name, @@ -208,7 +208,7 @@ HRESULT RegKey::GetValue(const wchar_t* full_key_name, HRESULT RegKey::GetValue(const wchar_t* full_key_name, const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count) { ASSERT(full_key_name != NULL); ASSERT(value != NULL); @@ -407,11 +407,11 @@ HRESULT RegKey::SetValueStaticHelper(const wchar_t* full_key_name, hr = key.SetValue(value_name, static_cast(value)); break; case REG_BINARY: - hr = key.SetValue(value_name, static_cast(value), + hr = key.SetValue(value_name, static_cast(value), byte_count); break; case REG_MULTI_SZ: - hr = key.SetValue(value_name, static_cast(value), + hr = key.SetValue(value_name, static_cast(value), byte_count, type); break; default: @@ -461,7 +461,7 @@ HRESULT RegKey::GetValueStaticHelper(const wchar_t* full_key_name, std::vector*>(value)); break; case REG_BINARY: - hr = key.GetValue(value_name, reinterpret_cast(value), + hr = key.GetValue(value_name, reinterpret_cast(value), byte_count); break; default: @@ -482,7 +482,7 @@ HRESULT RegKey::GetValueStaticHelper(const wchar_t* full_key_name, // GET helper HRESULT RegKey::GetValueHelper(const wchar_t* value_name, DWORD* type, - uint8** value, + uint8_t** value, DWORD* byte_count) const { ASSERT(byte_count != NULL); ASSERT(value != NULL); @@ -608,7 +608,7 @@ HRESULT RegKey::GetValue(const wchar_t* value_name, std::wstring* value) const { } // convert REG_MULTI_SZ bytes to string array -HRESULT RegKey::MultiSZBytesToStringArray(const uint8* buffer, +HRESULT RegKey::MultiSZBytesToStringArray(const uint8_t* buffer, DWORD byte_count, std::vector* value) { ASSERT(buffer != NULL); @@ -640,7 +640,7 @@ HRESULT RegKey::GetValue(const wchar_t* value_name, DWORD byte_count = 0; DWORD type = 0; - uint8* buffer = 0; + uint8_t* buffer = 0; // first get the size of the buffer HRESULT hr = GetValueHelper(value_name, &type, &buffer, &byte_count); @@ -655,7 +655,7 @@ HRESULT RegKey::GetValue(const wchar_t* value_name, // Binary data Get HRESULT RegKey::GetValue(const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count) const { ASSERT(byte_count != NULL); ASSERT(value != NULL); @@ -668,9 +668,9 @@ HRESULT RegKey::GetValue(const wchar_t* value_name, // Raw data get HRESULT RegKey::GetValue(const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count, - DWORD*type) const { + DWORD* type) const { ASSERT(type != NULL); ASSERT(byte_count != NULL); ASSERT(value != NULL); @@ -682,9 +682,9 @@ HRESULT RegKey::GetValue(const wchar_t* value_name, HRESULT RegKey::SetValue(const wchar_t* value_name, DWORD value) const { ASSERT(h_key_ != NULL); - LONG res = ::RegSetValueEx(h_key_, value_name, NULL, REG_DWORD, - reinterpret_cast(&value), - sizeof(DWORD)); + LONG res = + ::RegSetValueEx(h_key_, value_name, NULL, REG_DWORD, + reinterpret_cast(&value), sizeof(DWORD)); return HRESULT_FROM_WIN32(res); } @@ -693,7 +693,7 @@ HRESULT RegKey::SetValue(const wchar_t* value_name, DWORD64 value) const { ASSERT(h_key_ != NULL); LONG res = ::RegSetValueEx(h_key_, value_name, NULL, REG_QWORD, - reinterpret_cast(&value), + reinterpret_cast(&value), sizeof(DWORD64)); return HRESULT_FROM_WIN32(res); } @@ -705,14 +705,14 @@ HRESULT RegKey::SetValue(const wchar_t* value_name, ASSERT(h_key_ != NULL); LONG res = ::RegSetValueEx(h_key_, value_name, NULL, REG_SZ, - reinterpret_cast(value), + reinterpret_cast(value), (lstrlen(value) + 1) * sizeof(wchar_t)); return HRESULT_FROM_WIN32(res); } // Binary data set HRESULT RegKey::SetValue(const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count) const { ASSERT(h_key_ != NULL); @@ -728,7 +728,7 @@ HRESULT RegKey::SetValue(const wchar_t* value_name, // Raw data set HRESULT RegKey::SetValue(const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count, DWORD type) const { ASSERT(value != NULL); @@ -964,7 +964,7 @@ std::wstring RegKey::GetParentKeyInfo(std::wstring* key_name) { } // get the number of values for this key -uint32 RegKey::GetValueCount() { +uint32_t RegKey::GetValueCount() { DWORD num_values = 0; if (ERROR_SUCCESS != ::RegQueryInfoKey( @@ -1007,7 +1007,7 @@ HRESULT RegKey::GetValueNameAt(int index, std::wstring* value_name, return HRESULT_FROM_WIN32(res); } -uint32 RegKey::GetSubkeyCount() { +uint32_t RegKey::GetSubkeyCount() { // number of values for key DWORD num_subkeys = 0; diff --git a/webrtc/base/win32regkey.h b/webrtc/base/win32regkey.h index 5508ea7309..d5c51b9b06 100644 --- a/webrtc/base/win32regkey.h +++ b/webrtc/base/win32regkey.h @@ -64,7 +64,7 @@ class RegKey { bool HasValue(const wchar_t* value_name) const; // get the number of values for this key - uint32 GetValueCount(); + uint32_t GetValueCount(); // Called to get the value name for the given value name index // Use GetValueCount() to get the total value_name count for this key @@ -80,7 +80,7 @@ class RegKey { bool HasSubkey(const wchar_t* key_name) const; // get the number of subkeys for this key - uint32 GetSubkeyCount(); + uint32_t GetSubkeyCount(); // Called to get the key name for the given key index // Use GetSubkeyCount() to get the total count for this key @@ -92,10 +92,10 @@ class RegKey { // SETTERS - // set an int32 value - use when reading multiple values from a key + // set an int32_t value - use when reading multiple values from a key HRESULT SetValue(const wchar_t* value_name, DWORD value) const; - // set an int64 value + // set an int64_t value HRESULT SetValue(const wchar_t* value_name, DWORD64 value) const; // set a string value @@ -103,21 +103,21 @@ class RegKey { // set binary data HRESULT SetValue(const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count) const; // set raw data, including type HRESULT SetValue(const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count, DWORD type) const; // GETTERS - // get an int32 value + // get an int32_t value HRESULT GetValue(const wchar_t* value_name, DWORD* value) const; - // get an int64 value + // get an int64_t value HRESULT GetValue(const wchar_t* value_name, DWORD64* value) const; // get a string value - the caller must free the return buffer @@ -132,12 +132,12 @@ class RegKey { // get binary data - the caller must free the return buffer HRESULT GetValue(const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count) const; // get raw data, including type - the caller must free the return buffer HRESULT GetValue(const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count, DWORD* type) const; @@ -154,12 +154,12 @@ class RegKey { // SETTERS - // STATIC int32 set + // STATIC int32_t set static HRESULT SetValue(const wchar_t* full_key_name, const wchar_t* value_name, DWORD value); - // STATIC int64 set + // STATIC int64_t set static HRESULT SetValue(const wchar_t* full_key_name, const wchar_t* value_name, DWORD64 value); @@ -182,23 +182,23 @@ class RegKey { // STATIC binary data set static HRESULT SetValue(const wchar_t* full_key_name, const wchar_t* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count); // STATIC multi-string set static HRESULT SetValueMultiSZ(const wchar_t* full_key_name, const TCHAR* value_name, - const uint8* value, + const uint8_t* value, DWORD byte_count); // GETTERS - // STATIC int32 get + // STATIC int32_t get static HRESULT GetValue(const wchar_t* full_key_name, const wchar_t* value_name, DWORD* value); - // STATIC int64 get + // STATIC int64_t get // // Note: if you are using time64 you should // likely use GetLimitedTimeValue (util.h) instead of this method. @@ -233,7 +233,7 @@ class RegKey { // STATIC get binary data - the caller must free the return buffer static HRESULT GetValue(const wchar_t* full_key_name, const wchar_t* value_name, - uint8** value, + uint8_t** value, DWORD* byte_count); // Get type of a registry value @@ -297,7 +297,8 @@ class RegKey { // helper function to get any value from the registry // used when the size of the data is unknown HRESULT GetValueHelper(const wchar_t* value_name, - DWORD* type, uint8** value, + DWORD* type, + uint8_t** value, DWORD* byte_count) const; // helper function to get the parent key name and the subkey from a string @@ -320,7 +321,7 @@ class RegKey { DWORD* byte_count = NULL); // convert REG_MULTI_SZ bytes to string array - static HRESULT MultiSZBytesToStringArray(const uint8* buffer, + static HRESULT MultiSZBytesToStringArray(const uint8_t* buffer, DWORD byte_count, std::vector* value); diff --git a/webrtc/base/win32regkey_unittest.cc b/webrtc/base/win32regkey_unittest.cc index d26305147f..389c3a243c 100644 --- a/webrtc/base/win32regkey_unittest.cc +++ b/webrtc/base/win32regkey_unittest.cc @@ -150,18 +150,18 @@ void RegKeyHelperFunctionsTest() { std::vector result; EXPECT_SUCCEEDED(RegKey::MultiSZBytesToStringArray( - reinterpret_cast(kMultiSZ), sizeof(kMultiSZ), &result)); + reinterpret_cast(kMultiSZ), sizeof(kMultiSZ), &result)); EXPECT_EQ(result.size(), 3); EXPECT_STREQ(result[0].c_str(), L"abc"); EXPECT_STREQ(result[1].c_str(), L"def"); EXPECT_STREQ(result[2].c_str(), L"P12345"); EXPECT_SUCCEEDED(RegKey::MultiSZBytesToStringArray( - reinterpret_cast(kEmptyMultiSZ), - sizeof(kEmptyMultiSZ), &result)); + reinterpret_cast(kEmptyMultiSZ), sizeof(kEmptyMultiSZ), + &result)); EXPECT_EQ(result.size(), 0); EXPECT_FALSE(SUCCEEDED(RegKey::MultiSZBytesToStringArray( - reinterpret_cast(kInvalidMultiSZ), + reinterpret_cast(kInvalidMultiSZ), sizeof(kInvalidMultiSZ), &result))); } @@ -173,7 +173,7 @@ void RegKeyNonStaticFunctionsTest() { DWORD int_val = 0; DWORD64 int64_val = 0; wchar_t* str_val = NULL; - uint8* binary_val = NULL; + uint8_t* binary_val = NULL; DWORD uint8_count = 0; // Just in case... @@ -265,7 +265,8 @@ void RegKeyNonStaticFunctionsTest() { // set a binary value EXPECT_SUCCEEDED(r_key.SetValue(kValNameBinary, - reinterpret_cast(kBinaryVal), sizeof(kBinaryVal) - 1)); + reinterpret_cast(kBinaryVal), + sizeof(kBinaryVal) - 1)); // check that the value exists EXPECT_TRUE(r_key.HasValue(kValNameBinary)); @@ -277,7 +278,8 @@ void RegKeyNonStaticFunctionsTest() { // set it again EXPECT_SUCCEEDED(r_key.SetValue(kValNameBinary, - reinterpret_cast(kBinaryVal2), sizeof(kBinaryVal) - 1)); + reinterpret_cast(kBinaryVal2), + sizeof(kBinaryVal) - 1)); // read it again EXPECT_SUCCEEDED(r_key.GetValue(kValNameBinary, &binary_val, &uint8_count)); @@ -303,10 +305,11 @@ void RegKeyNonStaticFunctionsTest() { // set a binary value EXPECT_SUCCEEDED(r_key.SetValue(kValNameBinary, - reinterpret_cast(kBinaryVal), sizeof(kBinaryVal) - 1)); + reinterpret_cast(kBinaryVal), + sizeof(kBinaryVal) - 1)); // get the value count - uint32 value_count = r_key.GetValueCount(); + uint32_t value_count = r_key.GetValueCount(); EXPECT_EQ(value_count, 4); // check the value names @@ -332,7 +335,7 @@ void RegKeyNonStaticFunctionsTest() { // check that there are no more values EXPECT_FAILED(r_key.GetValueNameAt(4, &value_name, &type)); - uint32 subkey_count = r_key.GetSubkeyCount(); + uint32_t subkey_count = r_key.GetSubkeyCount(); EXPECT_EQ(subkey_count, 0); // now create a subkey and make sure we can get the name @@ -366,7 +369,7 @@ void RegKeyStaticFunctionsTest() { double double_val = 0; wchar_t* str_val = NULL; std::wstring wstr_val; - uint8* binary_val = NULL; + uint8_t* binary_val = NULL; DWORD uint8_count = 0; // Just in case... @@ -377,7 +380,7 @@ void RegKeyStaticFunctionsTest() { EXPECT_EQ(RegKey::GetValue(kFullRkey1, kValNameInt, &int_val), HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)); - // set int32 + // set int32_t EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1, kValNameInt, kIntVal)); // check that the value exists @@ -397,7 +400,7 @@ void RegKeyStaticFunctionsTest() { // check that the value is gone EXPECT_FALSE(RegKey::HasValue(kFullRkey1, kValNameInt)); - // set int64 + // set int64_t EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1, kValNameInt64, kIntVal64)); // check that the value exists @@ -473,8 +476,9 @@ void RegKeyStaticFunctionsTest() { EXPECT_FALSE(RegKey::HasValue(kFullRkey1, kValNameStr)); // set binary - EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1, kValNameBinary, - reinterpret_cast(kBinaryVal), sizeof(kBinaryVal)-1)); + EXPECT_SUCCEEDED(RegKey::SetValue( + kFullRkey1, kValNameBinary, reinterpret_cast(kBinaryVal), + sizeof(kBinaryVal) - 1)); // check that the value exists EXPECT_TRUE(RegKey::HasValue(kFullRkey1, kValNameBinary)); @@ -492,8 +496,9 @@ void RegKeyStaticFunctionsTest() { EXPECT_FALSE(RegKey::HasValue(kFullRkey1, kValNameBinary)); // special case - set a binary value with length 0 - EXPECT_SUCCEEDED(RegKey::SetValue(kFullRkey1, kValNameBinary, - reinterpret_cast(kBinaryVal), 0)); + EXPECT_SUCCEEDED( + RegKey::SetValue(kFullRkey1, kValNameBinary, + reinterpret_cast(kBinaryVal), 0)); // check that the value exists EXPECT_TRUE(RegKey::HasValue(kFullRkey1, kValNameBinary)); @@ -532,20 +537,24 @@ void RegKeyStaticFunctionsTest() { // test read/write REG_MULTI_SZ value std::vector result; - EXPECT_SUCCEEDED(RegKey::SetValueMultiSZ(kFullRkey1, kValNameMultiStr, - reinterpret_cast(kMultiSZ), sizeof(kMultiSZ))); + EXPECT_SUCCEEDED(RegKey::SetValueMultiSZ( + kFullRkey1, kValNameMultiStr, reinterpret_cast(kMultiSZ), + sizeof(kMultiSZ))); EXPECT_SUCCEEDED(RegKey::GetValue(kFullRkey1, kValNameMultiStr, &result)); EXPECT_EQ(result.size(), 3); EXPECT_STREQ(result[0].c_str(), L"abc"); EXPECT_STREQ(result[1].c_str(), L"def"); EXPECT_STREQ(result[2].c_str(), L"P12345"); - EXPECT_SUCCEEDED(RegKey::SetValueMultiSZ(kFullRkey1, kValNameMultiStr, - reinterpret_cast(kEmptyMultiSZ), sizeof(kEmptyMultiSZ))); + EXPECT_SUCCEEDED(RegKey::SetValueMultiSZ( + kFullRkey1, kValNameMultiStr, + reinterpret_cast(kEmptyMultiSZ), sizeof(kEmptyMultiSZ))); EXPECT_SUCCEEDED(RegKey::GetValue(kFullRkey1, kValNameMultiStr, &result)); EXPECT_EQ(result.size(), 0); // writing REG_MULTI_SZ value will automatically add ending null characters - EXPECT_SUCCEEDED(RegKey::SetValueMultiSZ(kFullRkey1, kValNameMultiStr, - reinterpret_cast(kInvalidMultiSZ), sizeof(kInvalidMultiSZ))); + EXPECT_SUCCEEDED( + RegKey::SetValueMultiSZ(kFullRkey1, kValNameMultiStr, + reinterpret_cast(kInvalidMultiSZ), + sizeof(kInvalidMultiSZ))); EXPECT_SUCCEEDED(RegKey::GetValue(kFullRkey1, kValNameMultiStr, &result)); EXPECT_EQ(result.size(), 1); EXPECT_STREQ(result[0].c_str(), L"678"); diff --git a/webrtc/base/win32socketserver.cc b/webrtc/base/win32socketserver.cc index 2adb0d3d27..743f8c0d59 100644 --- a/webrtc/base/win32socketserver.cc +++ b/webrtc/base/win32socketserver.cc @@ -28,26 +28,26 @@ namespace rtc { // TODO: Move this to a common place where PhysicalSocketServer can // share it. // Standard MTUs -static const uint16 PACKET_MAXIMUMS[] = { - 65535, // Theoretical maximum, Hyperchannel - 32000, // Nothing - 17914, // 16Mb IBM Token Ring - 8166, // IEEE 802.4 - // 4464 // IEEE 802.5 (4Mb max) - 4352, // FDDI - // 2048, // Wideband Network - 2002, // IEEE 802.5 (4Mb recommended) - // 1536, // Expermental Ethernet Networks - // 1500, // Ethernet, Point-to-Point (default) - 1492, // IEEE 802.3 - 1006, // SLIP, ARPANET - // 576, // X.25 Networks - // 544, // DEC IP Portal - // 512, // NETBIOS - 508, // IEEE 802/Source-Rt Bridge, ARCNET - 296, // Point-to-Point (low delay) - 68, // Official minimum - 0, // End of list marker +static const uint16_t PACKET_MAXIMUMS[] = { + 65535, // Theoretical maximum, Hyperchannel + 32000, // Nothing + 17914, // 16Mb IBM Token Ring + 8166, // IEEE 802.4 + // 4464 // IEEE 802.5 (4Mb max) + 4352, // FDDI + // 2048, // Wideband Network + 2002, // IEEE 802.5 (4Mb recommended) + // 1536, // Expermental Ethernet Networks + // 1500, // Ethernet, Point-to-Point (default) + 1492, // IEEE 802.3 + 1006, // SLIP, ARPANET + // 576, // X.25 Networks + // 544, // DEC IP Portal + // 512, // NETBIOS + 508, // IEEE 802/Source-Rt Bridge, ARCNET + 296, // Point-to-Point (low delay) + 68, // Official minimum + 0, // End of list marker }; static const int IP_HEADER_SIZE = 20u; @@ -143,7 +143,7 @@ void ReportWSAError(LPCSTR context, int error, const SocketAddress& address) {} struct Win32Socket::DnsLookup { HANDLE handle; - uint16 port; + uint16_t port; char buffer[MAXGETHOSTSTRUCT]; }; @@ -512,7 +512,7 @@ int Win32Socket::Close() { return err; } -int Win32Socket::EstimateMTU(uint16* mtu) { +int Win32Socket::EstimateMTU(uint16_t* mtu) { SocketAddress addr = GetRemoteAddress(); if (addr.IsAny()) { error_ = ENOTCONN; @@ -526,7 +526,7 @@ int Win32Socket::EstimateMTU(uint16* mtu) { } for (int level = 0; PACKET_MAXIMUMS[level + 1] > 0; ++level) { - int32 size = PACKET_MAXIMUMS[level] - IP_HEADER_SIZE - ICMP_HEADER_SIZE; + int32_t size = PACKET_MAXIMUMS[level] - IP_HEADER_SIZE - ICMP_HEADER_SIZE; WinPing::PingResult result = ping.Ping(addr.ipaddr(), size, ICMP_PING_TIMEOUT_MILLIS, 1, false); if (result == WinPing::PING_FAIL) { @@ -627,7 +627,7 @@ void Win32Socket::OnSocketNotify(SOCKET socket, int event, int error) { if (error != ERROR_SUCCESS) { ReportWSAError("WSAAsync:connect notify", error, addr_); #ifdef _DEBUG - int32 duration = TimeSince(connect_time_); + int32_t duration = TimeSince(connect_time_); LOG(LS_INFO) << "WSAAsync:connect error (" << duration << " ms), faking close"; #endif @@ -640,7 +640,7 @@ void Win32Socket::OnSocketNotify(SOCKET socket, int event, int error) { SignalCloseEvent(this, error); } else { #ifdef _DEBUG - int32 duration = TimeSince(connect_time_); + int32_t duration = TimeSince(connect_time_); LOG(LS_INFO) << "WSAAsync:connect (" << duration << " ms)"; #endif state_ = CS_CONNECTED; @@ -679,10 +679,10 @@ void Win32Socket::OnDnsNotify(HANDLE task, int error) { if (!dns_ || dns_->handle != task) return; - uint32 ip = 0; + uint32_t ip = 0; if (error == 0) { hostent* pHost = reinterpret_cast(dns_->buffer); - uint32 net_ip = *reinterpret_cast(pHost->h_addr_list[0]); + uint32_t net_ip = *reinterpret_cast(pHost->h_addr_list[0]); ip = NetworkToHost32(net_ip); } @@ -762,7 +762,7 @@ bool Win32SocketServer::Wait(int cms, bool process_io) { if (process_io) { // Spin the Win32 message pump at least once, and as long as requested. // This is the Thread::ProcessMessages case. - uint32 start = Time(); + uint32_t start = Time(); do { MSG msg; SetTimer(wnd_.handle(), 0, cms, NULL); diff --git a/webrtc/base/win32socketserver.h b/webrtc/base/win32socketserver.h index a03f6c028c..b468cfd9e3 100644 --- a/webrtc/base/win32socketserver.h +++ b/webrtc/base/win32socketserver.h @@ -52,7 +52,7 @@ class Win32Socket : public AsyncSocket { virtual int GetError() const; virtual void SetError(int error); virtual ConnState GetState() const; - virtual int EstimateMTU(uint16* mtu); + virtual int EstimateMTU(uint16_t* mtu); virtual int GetOption(Option opt, int* value); virtual int SetOption(Option opt, int value); @@ -72,7 +72,7 @@ class Win32Socket : public AsyncSocket { int error_; ConnState state_; SocketAddress addr_; // address that we connected to (see DoConnect) - uint32 connect_time_; + uint32_t connect_time_; bool closing_; int close_error_; diff --git a/webrtc/base/win32socketserver_unittest.cc b/webrtc/base/win32socketserver_unittest.cc index 1d3ef2ea37..daf9e70d1f 100644 --- a/webrtc/base/win32socketserver_unittest.cc +++ b/webrtc/base/win32socketserver_unittest.cc @@ -17,7 +17,7 @@ namespace rtc { // Test that Win32SocketServer::Wait works as expected. TEST(Win32SocketServerTest, TestWait) { Win32SocketServer server(NULL); - uint32 start = Time(); + uint32_t start = Time(); server.Wait(1000, true); EXPECT_GE(TimeSince(start), 1000); } diff --git a/webrtc/base/window.h b/webrtc/base/window.h index 9f4381a610..b1f1724e63 100644 --- a/webrtc/base/window.h +++ b/webrtc/base/window.h @@ -40,7 +40,7 @@ class WindowId { typedef unsigned int WindowT; #endif - static WindowId Cast(uint64 id) { + static WindowId Cast(uint64_t id) { #if defined(WEBRTC_WIN) return WindowId(reinterpret_cast(id)); #else @@ -48,11 +48,11 @@ class WindowId { #endif } - static uint64 Format(const WindowT& id) { + static uint64_t Format(const WindowT& id) { #if defined(WEBRTC_WIN) - return static_cast(reinterpret_cast(id)); + return static_cast(reinterpret_cast(id)); #else - return static_cast(id); + return static_cast(id); #endif } diff --git a/webrtc/base/winping.cc b/webrtc/base/winping.cc index fa8dfc2877..be436c3cb0 100644 --- a/webrtc/base/winping.cc +++ b/webrtc/base/winping.cc @@ -126,11 +126,11 @@ const char * const ICMP_SEND_FUNC = "IcmpSendEcho"; const char * const ICMP6_CREATE_FUNC = "Icmp6CreateFile"; const char * const ICMP6_SEND_FUNC = "Icmp6SendEcho2"; -inline uint32 ReplySize(uint32 data_size, int family) { +inline uint32_t ReplySize(uint32_t data_size, int family) { if (family == AF_INET) { // A ping error message is 8 bytes long, so make sure we allow for at least // 8 bytes of reply data. - return sizeof(ICMP_ECHO_REPLY) + std::max(8, data_size); + return sizeof(ICMP_ECHO_REPLY) + std::max(8, data_size); } else if (family == AF_INET6) { // Per MSDN, Send6IcmpEcho2 needs at least one ICMPV6_ECHO_REPLY, // 8 bytes for ICMP header, _and_ an IO_BLOCK_STATUS (2 pointers), @@ -208,10 +208,11 @@ WinPing::~WinPing() { delete[] reply_; } -WinPing::PingResult WinPing::Ping( - IPAddress ip, uint32 data_size, uint32 timeout, uint8 ttl, - bool allow_fragments) { - +WinPing::PingResult WinPing::Ping(IPAddress ip, + uint32_t data_size, + uint32_t timeout, + uint8_t ttl, + bool allow_fragments) { if (data_size == 0 || timeout == 0 || ttl == 0) { LOG(LERROR) << "IcmpSendEcho: data_size/timeout/ttl is 0."; return PING_INVALID_PARAMS; @@ -225,7 +226,7 @@ WinPing::PingResult WinPing::Ping( ipopt.Flags |= IP_FLAG_DF; ipopt.Ttl = ttl; - uint32 reply_size = ReplySize(data_size, ip.family()); + uint32_t reply_size = ReplySize(data_size, ip.family()); if (data_size > dlen_) { delete [] data_; @@ -241,19 +242,16 @@ WinPing::PingResult WinPing::Ping( } DWORD result = 0; if (ip.family() == AF_INET) { - result = send_(hping_, ip.ipv4_address().S_un.S_addr, - data_, uint16(data_size), &ipopt, - reply_, reply_size, timeout); + result = send_(hping_, ip.ipv4_address().S_un.S_addr, data_, + uint16_t(data_size), &ipopt, reply_, reply_size, timeout); } else if (ip.family() == AF_INET6) { sockaddr_in6 src = {0}; sockaddr_in6 dst = {0}; src.sin6_family = AF_INET6; dst.sin6_family = AF_INET6; dst.sin6_addr = ip.ipv6_address(); - result = send6_(hping6_, NULL, NULL, NULL, - &src, &dst, - data_, int16(data_size), &ipopt, - reply_, reply_size, timeout); + result = send6_(hping6_, NULL, NULL, NULL, &src, &dst, data_, + int16_t(data_size), &ipopt, reply_, reply_size, timeout); } if (result == 0) { DWORD error = GetLastError(); diff --git a/webrtc/base/winping.h b/webrtc/base/winping.h index 75f82b7b4a..ddaefc5253 100644 --- a/webrtc/base/winping.h +++ b/webrtc/base/winping.h @@ -76,9 +76,11 @@ public: // Attempts to send a ping with the given parameters. enum PingResult { PING_FAIL, PING_INVALID_PARAMS, PING_TOO_LARGE, PING_TIMEOUT, PING_SUCCESS }; - PingResult Ping( - IPAddress ip, uint32 data_size, uint32 timeout_millis, uint8 ttl, - bool allow_fragments); + PingResult Ping(IPAddress ip, + uint32_t data_size, + uint32_t timeout_millis, + uint8_t ttl, + bool allow_fragments); private: HMODULE dll_; @@ -90,9 +92,9 @@ private: PIcmp6CreateFile create6_; PIcmp6SendEcho2 send6_; char* data_; - uint32 dlen_; + uint32_t dlen_; char* reply_; - uint32 rlen_; + uint32_t rlen_; bool valid_; }; diff --git a/webrtc/base/x11windowpicker.cc b/webrtc/base/x11windowpicker.cc index f7c79111e3..21f71c61e3 100644 --- a/webrtc/base/x11windowpicker.cc +++ b/webrtc/base/x11windowpicker.cc @@ -277,7 +277,7 @@ class XWindowEnumerator { return true; } - uint8* GetWindowIcon(const WindowId& id, int* width, int* height) { + uint8_t* GetWindowIcon(const WindowId& id, int* width, int* height) { if (!Init()) { return NULL; } @@ -297,14 +297,14 @@ class XWindowEnumerator { LOG(LS_ERROR) << "Failed to get size of the icon."; return NULL; } - // Get the icon data, the format is one uint32 each for width and height, + // Get the icon data, the format is one uint32_t each for width and height, // followed by the actual pixel data. if (size >= 2 && XGetWindowProperty( display_, id.id(), net_wm_icon_, 0, size, False, XA_CARDINAL, &ret_type, &format, &length, &bytes_after, &data) == Success && data) { - uint32* data_ptr = reinterpret_cast(data); + uint32_t* data_ptr = reinterpret_cast(data); int w, h; w = data_ptr[0]; h = data_ptr[1]; @@ -313,8 +313,7 @@ class XWindowEnumerator { LOG(LS_ERROR) << "Not a vaild icon."; return NULL; } - uint8* rgba = - ArgbToRgba(&data_ptr[2], 0, 0, w, h, w, h, true); + uint8_t* rgba = ArgbToRgba(&data_ptr[2], 0, 0, w, h, w, h, true); XFree(data); *width = w; *height = h; @@ -325,7 +324,7 @@ class XWindowEnumerator { } } - uint8* GetWindowThumbnail(const WindowId& id, int width, int height) { + uint8_t* GetWindowThumbnail(const WindowId& id, int width, int height) { if (!Init()) { return NULL; } @@ -390,12 +389,8 @@ class XWindowEnumerator { return NULL; } - uint8* data = GetDrawableThumbnail(src_pixmap, - attr.visual, - src_width, - src_height, - width, - height); + uint8_t* data = GetDrawableThumbnail(src_pixmap, attr.visual, src_width, + src_height, width, height); XFreePixmap(display_, src_pixmap); return data; } @@ -408,7 +403,7 @@ class XWindowEnumerator { return XScreenCount(display_); } - uint8* GetDesktopThumbnail(const DesktopId& id, int width, int height) { + uint8_t* GetDesktopThumbnail(const DesktopId& id, int width, int height) { if (!Init()) { return NULL; } @@ -445,12 +440,12 @@ class XWindowEnumerator { } private: - uint8* GetDrawableThumbnail(Drawable src_drawable, - Visual* visual, - int src_width, - int src_height, - int dst_width, - int dst_height) { + uint8_t* GetDrawableThumbnail(Drawable src_drawable, + Visual* visual, + int src_width, + int src_height, + int dst_width, + int dst_height) { if (!has_render_extension_) { // Without the Xrender extension we would have to read the full window and // scale it down in our process. Xrender is over a decade old so we aren't @@ -561,14 +556,9 @@ class XWindowEnumerator { dst_width, dst_height, AllPlanes, ZPixmap); - uint8* data = ArgbToRgba(reinterpret_cast(image->data), - centered_x, - centered_y, - scaled_width, - scaled_height, - dst_width, - dst_height, - false); + uint8_t* data = ArgbToRgba(reinterpret_cast(image->data), + centered_x, centered_y, scaled_width, + scaled_height, dst_width, dst_height, false); XDestroyImage(image); XRenderFreePicture(display_, dst); XFreePixmap(display_, dst_pixmap); @@ -576,17 +566,23 @@ class XWindowEnumerator { return data; } - uint8* ArgbToRgba(uint32* argb_data, int x, int y, int w, int h, - int stride_x, int stride_y, bool has_alpha) { - uint8* p; + uint8_t* ArgbToRgba(uint32_t* argb_data, + int x, + int y, + int w, + int h, + int stride_x, + int stride_y, + bool has_alpha) { + uint8_t* p; int len = stride_x * stride_y * 4; - uint8* data = new uint8[len]; + uint8_t* data = new uint8_t[len]; memset(data, 0, len); p = data + 4 * (y * stride_x + x); for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { - uint32 argb; - uint32 rgba; + uint32_t argb; + uint32_t rgba; argb = argb_data[stride_x * (y + i) + x + j]; rgba = (argb << 8) | (argb >> 24); *p = rgba >> 24; @@ -691,7 +687,7 @@ class XWindowEnumerator { return 0; } if (type != None) { - int64 state = static_cast(*data); + int64_t state = static_cast(*data); XFree(data); return state == NormalState ? window : 0; } @@ -789,13 +785,14 @@ bool X11WindowPicker::MoveToFront(const WindowId& id) { return enumerator_->MoveToFront(id); } - -uint8* X11WindowPicker::GetWindowIcon(const WindowId& id, int* width, +uint8_t* X11WindowPicker::GetWindowIcon(const WindowId& id, + int* width, int* height) { return enumerator_->GetWindowIcon(id, width, height); } -uint8* X11WindowPicker::GetWindowThumbnail(const WindowId& id, int width, +uint8_t* X11WindowPicker::GetWindowThumbnail(const WindowId& id, + int width, int height) { return enumerator_->GetWindowThumbnail(id, width, height); } @@ -804,7 +801,7 @@ int X11WindowPicker::GetNumDesktops() { return enumerator_->GetNumDesktops(); } -uint8* X11WindowPicker::GetDesktopThumbnail(const DesktopId& id, +uint8_t* X11WindowPicker::GetDesktopThumbnail(const DesktopId& id, int width, int height) { return enumerator_->GetDesktopThumbnail(id, width, height); diff --git a/webrtc/base/x11windowpicker.h b/webrtc/base/x11windowpicker.h index b340b88429..501adf5820 100644 --- a/webrtc/base/x11windowpicker.h +++ b/webrtc/base/x11windowpicker.h @@ -38,10 +38,10 @@ class X11WindowPicker : public WindowPicker { bool GetDesktopDimensions(const DesktopId& id, int* width, int* height) override; - uint8* GetWindowIcon(const WindowId& id, int* width, int* height); - uint8* GetWindowThumbnail(const WindowId& id, int width, int height); + uint8_t* GetWindowIcon(const WindowId& id, int* width, int* height); + uint8_t* GetWindowThumbnail(const WindowId& id, int width, int height); int GetNumDesktops(); - uint8* GetDesktopThumbnail(const DesktopId& id, int width, int height); + uint8_t* GetDesktopThumbnail(const DesktopId& id, int width, int height); private: scoped_ptr enumerator_; diff --git a/webrtc/examples/android/media_demo/jni/jni_helpers.h b/webrtc/examples/android/media_demo/jni/jni_helpers.h index c3f2b5d628..3d8ff48111 100644 --- a/webrtc/examples/android/media_demo/jni/jni_helpers.h +++ b/webrtc/examples/android/media_demo/jni/jni_helpers.h @@ -51,7 +51,7 @@ jmethodID GetMethodID(JNIEnv* jni, jclass c, const std::string& name, const char* signature); // Return a |jlong| that will automatically convert back to |ptr| when assigned -// to a |uint64| +// to a |uint64_t| jlong jlongFromPointer(void* ptr); // Given a (UTF-16) jstring return a new UTF-8 native string. diff --git a/webrtc/examples/peerconnection/client/defaults.cc b/webrtc/examples/peerconnection/client/defaults.cc index b686cd7fa6..3090c15ca1 100644 --- a/webrtc/examples/peerconnection/client/defaults.cc +++ b/webrtc/examples/peerconnection/client/defaults.cc @@ -24,7 +24,7 @@ const char kAudioLabel[] = "audio_label"; const char kVideoLabel[] = "video_label"; const char kStreamLabel[] = "stream_label"; -const uint16 kDefaultServerPort = 8888; +const uint16_t kDefaultServerPort = 8888; std::string GetEnvVarOrDefault(const char* env_var_name, const char* default_value) { diff --git a/webrtc/examples/peerconnection/client/defaults.h b/webrtc/examples/peerconnection/client/defaults.h index ab8276b7b9..7b503974e5 100644 --- a/webrtc/examples/peerconnection/client/defaults.h +++ b/webrtc/examples/peerconnection/client/defaults.h @@ -19,7 +19,7 @@ extern const char kAudioLabel[]; extern const char kVideoLabel[]; extern const char kStreamLabel[]; -extern const uint16 kDefaultServerPort; +extern const uint16_t kDefaultServerPort; std::string GetEnvVarOrDefault(const char* env_var_name, const char* default_value); diff --git a/webrtc/examples/peerconnection/client/flagdefs.h b/webrtc/examples/peerconnection/client/flagdefs.h index 00e134d94a..0cffffb135 100644 --- a/webrtc/examples/peerconnection/client/flagdefs.h +++ b/webrtc/examples/peerconnection/client/flagdefs.h @@ -14,7 +14,7 @@ #include "webrtc/base/flags.h" -extern const uint16 kDefaultServerPort; // From defaults.[h|cc] +extern const uint16_t kDefaultServerPort; // From defaults.[h|cc] // Define flags for the peerconnect_client testing tool, in a separate // header file so that they can be shared across the different main.cc's diff --git a/webrtc/examples/peerconnection/client/linux/main_wnd.cc b/webrtc/examples/peerconnection/client/linux/main_wnd.cc index 02b6e32a17..254fb946f9 100644 --- a/webrtc/examples/peerconnection/client/linux/main_wnd.cc +++ b/webrtc/examples/peerconnection/client/linux/main_wnd.cc @@ -394,20 +394,20 @@ void GtkMainWnd::OnRedraw() { if (!draw_buffer_.get()) { draw_buffer_size_ = (width * height * 4) * 4; - draw_buffer_.reset(new uint8[draw_buffer_size_]); + draw_buffer_.reset(new uint8_t[draw_buffer_size_]); gtk_widget_set_size_request(draw_area_, width * 2, height * 2); } - const uint32* image = reinterpret_cast( - remote_renderer->image()); - uint32* scaled = reinterpret_cast(draw_buffer_.get()); + const uint32_t* image = + reinterpret_cast(remote_renderer->image()); + uint32_t* scaled = reinterpret_cast(draw_buffer_.get()); for (int r = 0; r < height; ++r) { for (int c = 0; c < width; ++c) { int x = c * 2; scaled[x] = scaled[x + 1] = image[c]; } - uint32* prev_line = scaled; + uint32_t* prev_line = scaled; scaled += width * 2; memcpy(scaled, prev_line, (width * 2) * 4); @@ -417,8 +417,8 @@ void GtkMainWnd::OnRedraw() { VideoRenderer* local_renderer = local_renderer_.get(); if (local_renderer && local_renderer->image()) { - image = reinterpret_cast(local_renderer->image()); - scaled = reinterpret_cast(draw_buffer_.get()); + image = reinterpret_cast(local_renderer->image()); + scaled = reinterpret_cast(draw_buffer_.get()); // Position the local preview on the right side. scaled += (width * 2) - (local_renderer->width() / 2); // right margin... @@ -474,7 +474,7 @@ void GtkMainWnd::VideoRenderer::SetSize(int width, int height) { width_ = width; height_ = height; - image_.reset(new uint8[width * height * 4]); + image_.reset(new uint8_t[width * height * 4]); gdk_threads_leave(); } @@ -495,8 +495,8 @@ void GtkMainWnd::VideoRenderer::RenderFrame( width_ * 4); // Convert the B,G,R,A frame to R,G,B,A, which is accepted by GTK. // The 'A' is just padding for GTK, so we can use it as temp. - uint8* pix = image_.get(); - uint8* end = image_.get() + size; + uint8_t* pix = image_.get(); + uint8_t* end = image_.get() + size; while (pix < end) { pix[3] = pix[0]; // Save B to A. pix[0] = pix[2]; // Set Red. diff --git a/webrtc/examples/peerconnection/client/linux/main_wnd.h b/webrtc/examples/peerconnection/client/linux/main_wnd.h index cfb237645f..1a91082768 100644 --- a/webrtc/examples/peerconnection/client/linux/main_wnd.h +++ b/webrtc/examples/peerconnection/client/linux/main_wnd.h @@ -79,9 +79,7 @@ class GtkMainWnd : public MainWindow { virtual void SetSize(int width, int height); virtual void RenderFrame(const cricket::VideoFrame* frame); - const uint8* image() const { - return image_.get(); - } + const uint8_t* image() const { return image_.get(); } int width() const { return width_; @@ -92,7 +90,7 @@ class GtkMainWnd : public MainWindow { } protected: - rtc::scoped_ptr image_; + rtc::scoped_ptr image_; int width_; int height_; GtkMainWnd* main_wnd_; @@ -113,7 +111,7 @@ class GtkMainWnd : public MainWindow { bool autocall_; rtc::scoped_ptr local_renderer_; rtc::scoped_ptr remote_renderer_; - rtc::scoped_ptr draw_buffer_; + rtc::scoped_ptr draw_buffer_; int draw_buffer_size_; }; diff --git a/webrtc/examples/peerconnection/client/main_wnd.cc b/webrtc/examples/peerconnection/client/main_wnd.cc index fa356ff119..30b12a8511 100644 --- a/webrtc/examples/peerconnection/client/main_wnd.cc +++ b/webrtc/examples/peerconnection/client/main_wnd.cc @@ -234,7 +234,7 @@ void MainWnd::OnPaint() { int height = abs(bmi.bmiHeader.biHeight); int width = bmi.bmiHeader.biWidth; - const uint8* image = remote_renderer->image(); + const uint8_t* image = remote_renderer->image(); if (image != NULL) { HDC dc_mem = ::CreateCompatibleDC(ps.hdc); ::SetStretchBltMode(dc_mem, HALFTONE); @@ -594,7 +594,7 @@ void MainWnd::VideoRenderer::SetSize(int width, int height) { bmi_.bmiHeader.biHeight = -height; bmi_.bmiHeader.biSizeImage = width * height * (bmi_.bmiHeader.biBitCount >> 3); - image_.reset(new uint8[bmi_.bmiHeader.biSizeImage]); + image_.reset(new uint8_t[bmi_.bmiHeader.biSizeImage]); } void MainWnd::VideoRenderer::RenderFrame( diff --git a/webrtc/examples/peerconnection/client/main_wnd.h b/webrtc/examples/peerconnection/client/main_wnd.h index c11e94d30d..9f61a568fd 100644 --- a/webrtc/examples/peerconnection/client/main_wnd.h +++ b/webrtc/examples/peerconnection/client/main_wnd.h @@ -120,7 +120,7 @@ class MainWnd : public MainWindow { virtual void RenderFrame(const cricket::VideoFrame* frame); const BITMAPINFO& bmi() const { return bmi_; } - const uint8* image() const { return image_.get(); } + const uint8_t* image() const { return image_.get(); } protected: enum { @@ -130,7 +130,7 @@ class MainWnd : public MainWindow { HWND wnd_; BITMAPINFO bmi_; - rtc::scoped_ptr image_; + rtc::scoped_ptr image_; CRITICAL_SECTION buffer_lock_; rtc::scoped_refptr rendered_track_; }; diff --git a/webrtc/libjingle/xmpp/pingtask.cc b/webrtc/libjingle/xmpp/pingtask.cc index d44a6d1d84..479dc23ff5 100644 --- a/webrtc/libjingle/xmpp/pingtask.cc +++ b/webrtc/libjingle/xmpp/pingtask.cc @@ -18,8 +18,8 @@ namespace buzz { PingTask::PingTask(buzz::XmppTaskParentInterface* parent, rtc::MessageQueue* message_queue, - uint32 ping_period_millis, - uint32 ping_timeout_millis) + uint32_t ping_period_millis, + uint32_t ping_timeout_millis) : buzz::XmppTask(parent, buzz::XmppEngine::HL_SINGLE), message_queue_(message_queue), ping_period_millis_(ping_period_millis), @@ -56,7 +56,7 @@ int PingTask::ProcessStart() { ping_response_deadline_ = 0; } - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); // If the ping timed out, signal. if (ping_response_deadline_ != 0 && now >= ping_response_deadline_) { diff --git a/webrtc/libjingle/xmpp/pingtask.h b/webrtc/libjingle/xmpp/pingtask.h index 9ea905b089..22fd94d721 100644 --- a/webrtc/libjingle/xmpp/pingtask.h +++ b/webrtc/libjingle/xmpp/pingtask.h @@ -28,8 +28,9 @@ namespace buzz { class PingTask : public buzz::XmppTask, private rtc::MessageHandler { public: PingTask(buzz::XmppTaskParentInterface* parent, - rtc::MessageQueue* message_queue, uint32 ping_period_millis, - uint32 ping_timeout_millis); + rtc::MessageQueue* message_queue, + uint32_t ping_period_millis, + uint32_t ping_timeout_millis); virtual bool HandleStanza(const buzz::XmlElement* stanza); virtual int ProcessStart(); @@ -43,10 +44,10 @@ class PingTask : public buzz::XmppTask, private rtc::MessageHandler { virtual void OnMessage(rtc::Message* msg); rtc::MessageQueue* message_queue_; - uint32 ping_period_millis_; - uint32 ping_timeout_millis_; - uint32 next_ping_time_; - uint32 ping_response_deadline_; // 0 if the response has been received + uint32_t ping_period_millis_; + uint32_t ping_timeout_millis_; + uint32_t next_ping_time_; + uint32_t ping_response_deadline_; // 0 if the response has been received }; } // namespace buzz diff --git a/webrtc/libjingle/xmpp/pingtask_unittest.cc b/webrtc/libjingle/xmpp/pingtask_unittest.cc index 08a5770cd0..b9aab6b3f2 100644 --- a/webrtc/libjingle/xmpp/pingtask_unittest.cc +++ b/webrtc/libjingle/xmpp/pingtask_unittest.cc @@ -74,7 +74,7 @@ buzz::XmppReturnStatus PingXmppClient::SendStanza( } TEST_F(PingTaskTest, TestSuccess) { - uint32 ping_period_millis = 100; + uint32_t ping_period_millis = 100; buzz::PingTask* task = new buzz::PingTask(xmpp_client, rtc::Thread::Current(), ping_period_millis, ping_period_millis / 10); @@ -89,7 +89,7 @@ TEST_F(PingTaskTest, TestSuccess) { TEST_F(PingTaskTest, TestTimeout) { respond_to_pings = false; - uint32 ping_timeout_millis = 200; + uint32_t ping_timeout_millis = 200; buzz::PingTask* task = new buzz::PingTask(xmpp_client, rtc::Thread::Current(), ping_timeout_millis * 10, ping_timeout_millis); diff --git a/webrtc/libjingle/xmpp/xmpppump.cc b/webrtc/libjingle/xmpp/xmpppump.cc index 45259b1215..a428ffa4dc 100644 --- a/webrtc/libjingle/xmpp/xmpppump.cc +++ b/webrtc/libjingle/xmpp/xmpppump.cc @@ -49,8 +49,8 @@ void XmppPump::WakeTasks() { rtc::Thread::Current()->Post(this); } -int64 XmppPump::CurrentTime() { - return (int64)rtc::Time(); +int64_t XmppPump::CurrentTime() { + return (int64_t)rtc::Time(); } void XmppPump::OnMessage(rtc::Message *pmsg) { diff --git a/webrtc/libjingle/xmpp/xmpppump.h b/webrtc/libjingle/xmpp/xmpppump.h index 8163298769..bd1b5628b5 100644 --- a/webrtc/libjingle/xmpp/xmpppump.h +++ b/webrtc/libjingle/xmpp/xmpppump.h @@ -44,7 +44,7 @@ public: void WakeTasks(); - int64 CurrentTime(); + int64_t CurrentTime(); void OnMessage(rtc::Message *pmsg); diff --git a/webrtc/libjingle/xmpp/xmppthread.cc b/webrtc/libjingle/xmpp/xmppthread.cc index faf21642e6..f492cdf6c4 100644 --- a/webrtc/libjingle/xmpp/xmppthread.cc +++ b/webrtc/libjingle/xmpp/xmppthread.cc @@ -16,8 +16,8 @@ namespace buzz { namespace { -const uint32 MSG_LOGIN = 1; -const uint32 MSG_DISCONNECT = 2; +const uint32_t MSG_LOGIN = 1; +const uint32_t MSG_DISCONNECT = 2; struct LoginData: public rtc::MessageData { LoginData(const buzz::XmppClientSettings& s) : xcs(s) {} diff --git a/webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc b/webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc index dfbb6b7c52..b78b96dc86 100644 --- a/webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc +++ b/webrtc/modules/rtp_rtcp/source/h264_bitstream_parser.cc @@ -90,11 +90,9 @@ rtc::ByteBuffer* ParseRbsp(const uint8_t* bytes, size_t length) { return false; \ } -H264BitstreamParser::PpsState::PpsState() { -} +H264BitstreamParser::PpsState::PpsState() {} -H264BitstreamParser::SpsState::SpsState() { -} +H264BitstreamParser::SpsState::SpsState() {} // These functions are similar to webrtc::H264SpsParser::Parse, and based on the // same version of the H.264 standard. You can find it here: @@ -107,7 +105,7 @@ bool H264BitstreamParser::ParseSpsNalu(const uint8_t* sps, size_t length) { // copy. We'll eventually write this back. rtc::scoped_ptr sps_rbsp( ParseRbsp(sps + kNaluHeaderAndTypeSize, length - kNaluHeaderAndTypeSize)); - rtc::BitBuffer sps_parser(reinterpret_cast(sps_rbsp->Data()), + rtc::BitBuffer sps_parser(reinterpret_cast(sps_rbsp->Data()), sps_rbsp->Length()); uint8_t byte_tmp; @@ -115,7 +113,7 @@ bool H264BitstreamParser::ParseSpsNalu(const uint8_t* sps, size_t length) { uint32_t bits_tmp; // profile_idc: u(8). - uint8 profile_idc; + uint8_t profile_idc; RETURN_FALSE_ON_FAIL(sps_parser.ReadUInt8(&profile_idc)); // constraint_set0_flag through constraint_set5_flag + reserved_zero_2bits // 1 bit each for the flags + 2 bits = 8 bits = 1 byte. @@ -131,7 +129,7 @@ bool H264BitstreamParser::ParseSpsNalu(const uint8_t* sps, size_t length) { profile_idc == 86 || profile_idc == 118 || profile_idc == 128 || profile_idc == 138 || profile_idc == 139 || profile_idc == 134) { // chroma_format_idc: ue(v) - uint32 chroma_format_idc; + uint32_t chroma_format_idc; RETURN_FALSE_ON_FAIL(sps_parser.ReadExponentialGolomb(&chroma_format_idc)); if (chroma_format_idc == 3) { // separate_colour_plane_flag: u(1) @@ -213,7 +211,7 @@ bool H264BitstreamParser::ParsePpsNalu(const uint8_t* pps, size_t length) { pps_parsed_ = false; rtc::scoped_ptr buffer( ParseRbsp(pps + kNaluHeaderAndTypeSize, length - kNaluHeaderAndTypeSize)); - rtc::BitBuffer parser(reinterpret_cast(buffer->Data()), + rtc::BitBuffer parser(reinterpret_cast(buffer->Data()), buffer->Length()); uint32_t bits_tmp; @@ -322,7 +320,8 @@ bool H264BitstreamParser::ParseNonParameterSetNalu(const uint8_t* source, rtc::scoped_ptr slice_rbsp(ParseRbsp( source + kNaluHeaderAndTypeSize, source_length - kNaluHeaderAndTypeSize)); rtc::BitBuffer slice_reader( - reinterpret_cast(slice_rbsp->Data()), slice_rbsp->Length()); + reinterpret_cast(slice_rbsp->Data()), + slice_rbsp->Length()); // Check to see if this is an IDR slice, which has an extra field to parse // out. bool is_idr = (source[kNaluHeaderSize] & 0x0F) == kNaluIdr; @@ -349,7 +348,7 @@ bool H264BitstreamParser::ParseNonParameterSetNalu(const uint8_t* source, // Represented by log2_max_frame_num_minus4 + 4 bits. RETURN_FALSE_ON_FAIL( slice_reader.ReadBits(&bits_tmp, sps_.log2_max_frame_num_minus4 + 4)); - uint32 field_pic_flag = 0; + uint32_t field_pic_flag = 0; if (sps_.frame_mbs_only_flag == 0) { // field_pic_flag: u(1) RETURN_FALSE_ON_FAIL(slice_reader.ReadBits(&field_pic_flag, 1)); diff --git a/webrtc/modules/rtp_rtcp/source/h264_sps_parser.cc b/webrtc/modules/rtp_rtcp/source/h264_sps_parser.cc index d8f9afdd04..00ab9d4a65 100644 --- a/webrtc/modules/rtp_rtcp/source/h264_sps_parser.cc +++ b/webrtc/modules/rtp_rtcp/source/h264_sps_parser.cc @@ -21,7 +21,7 @@ namespace webrtc { -H264SpsParser::H264SpsParser(const uint8* sps, size_t byte_length) +H264SpsParser::H264SpsParser(const uint8_t* sps, size_t byte_length) : sps_(sps), byte_length_(byte_length), width_(), height_() { } @@ -62,22 +62,22 @@ bool H264SpsParser::Parse() { // chroma_format_idc -> affects crop units // pic_{width,height}_* -> resolution of the frame in macroblocks (16x16). // frame_crop_*_offset -> crop information - rtc::BitBuffer parser(reinterpret_cast(rbsp_buffer.Data()), + rtc::BitBuffer parser(reinterpret_cast(rbsp_buffer.Data()), rbsp_buffer.Length()); // The golomb values we have to read, not just consume. - uint32 golomb_ignored; + uint32_t golomb_ignored; // separate_colour_plane_flag is optional (assumed 0), but has implications // about the ChromaArrayType, which modifies how we treat crop coordinates. - uint32 separate_colour_plane_flag = 0; + uint32_t separate_colour_plane_flag = 0; // chroma_format_idc will be ChromaArrayType if separate_colour_plane_flag is // 0. It defaults to 1, when not specified. - uint32 chroma_format_idc = 1; + uint32_t chroma_format_idc = 1; // profile_idc: u(8). We need it to determine if we need to read/skip chroma // formats. - uint8 profile_idc; + uint8_t profile_idc; RETURN_FALSE_ON_FAIL(parser.ReadUInt8(&profile_idc)); // constraint_set0_flag through constraint_set5_flag + reserved_zero_2bits // 1 bit each for the flags + 2 bits = 8 bits = 1 byte. @@ -104,12 +104,12 @@ bool H264SpsParser::Parse() { // qpprime_y_zero_transform_bypass_flag: u(1) RETURN_FALSE_ON_FAIL(parser.ConsumeBits(1)); // seq_scaling_matrix_present_flag: u(1) - uint32 seq_scaling_matrix_present_flag; + uint32_t seq_scaling_matrix_present_flag; RETURN_FALSE_ON_FAIL(parser.ReadBits(&seq_scaling_matrix_present_flag, 1)); if (seq_scaling_matrix_present_flag) { // seq_scaling_list_present_flags. Either 8 or 12, depending on // chroma_format_idc. - uint32 seq_scaling_list_present_flags; + uint32_t seq_scaling_list_present_flags; if (chroma_format_idc != 3) { RETURN_FALSE_ON_FAIL( parser.ReadBits(&seq_scaling_list_present_flags, 8)); @@ -129,7 +129,7 @@ bool H264SpsParser::Parse() { // log2_max_frame_num_minus4: ue(v) RETURN_FALSE_ON_FAIL(parser.ReadExponentialGolomb(&golomb_ignored)); // pic_order_cnt_type: ue(v) - uint32 pic_order_cnt_type; + uint32_t pic_order_cnt_type; RETURN_FALSE_ON_FAIL(parser.ReadExponentialGolomb(&pic_order_cnt_type)); if (pic_order_cnt_type == 0) { // log2_max_pic_order_cnt_lsb_minus4: ue(v) @@ -142,7 +142,7 @@ bool H264SpsParser::Parse() { // offset_for_top_to_bottom_field: se(v) RETURN_FALSE_ON_FAIL(parser.ReadExponentialGolomb(&golomb_ignored)); // num_ref_frames_in_pic_order_cnt_cycle: ue(v) - uint32 num_ref_frames_in_pic_order_cnt_cycle; + uint32_t num_ref_frames_in_pic_order_cnt_cycle; RETURN_FALSE_ON_FAIL( parser.ReadExponentialGolomb(&num_ref_frames_in_pic_order_cnt_cycle)); for (size_t i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; ++i) { @@ -161,14 +161,14 @@ bool H264SpsParser::Parse() { // to signify resolutions that aren't multiples of 16. // // pic_width_in_mbs_minus1: ue(v) - uint32 pic_width_in_mbs_minus1; + uint32_t pic_width_in_mbs_minus1; RETURN_FALSE_ON_FAIL(parser.ReadExponentialGolomb(&pic_width_in_mbs_minus1)); // pic_height_in_map_units_minus1: ue(v) - uint32 pic_height_in_map_units_minus1; + uint32_t pic_height_in_map_units_minus1; RETURN_FALSE_ON_FAIL( parser.ReadExponentialGolomb(&pic_height_in_map_units_minus1)); // frame_mbs_only_flag: u(1) - uint32 frame_mbs_only_flag; + uint32_t frame_mbs_only_flag; RETURN_FALSE_ON_FAIL(parser.ReadBits(&frame_mbs_only_flag, 1)); if (!frame_mbs_only_flag) { // mb_adaptive_frame_field_flag: u(1) @@ -180,11 +180,11 @@ bool H264SpsParser::Parse() { // MORE IMPORTANT ONES! Now we're at the frame crop information. // // frame_cropping_flag: u(1) - uint32 frame_cropping_flag; - uint32 frame_crop_left_offset = 0; - uint32 frame_crop_right_offset = 0; - uint32 frame_crop_top_offset = 0; - uint32 frame_crop_bottom_offset = 0; + uint32_t frame_cropping_flag; + uint32_t frame_crop_left_offset = 0; + uint32_t frame_crop_right_offset = 0; + uint32_t frame_crop_top_offset = 0; + uint32_t frame_crop_bottom_offset = 0; RETURN_FALSE_ON_FAIL(parser.ReadBits(&frame_cropping_flag, 1)); if (frame_cropping_flag) { // frame_crop_{left, right, top, bottom}_offset: ue(v) diff --git a/webrtc/modules/rtp_rtcp/source/h264_sps_parser.h b/webrtc/modules/rtp_rtcp/source/h264_sps_parser.h index ab8cca35d5..c05ee67923 100644 --- a/webrtc/modules/rtp_rtcp/source/h264_sps_parser.h +++ b/webrtc/modules/rtp_rtcp/source/h264_sps_parser.h @@ -19,18 +19,18 @@ namespace webrtc { // Currently, only resolution is read without being ignored. class H264SpsParser { public: - H264SpsParser(const uint8* sps, size_t byte_length); + H264SpsParser(const uint8_t* sps, size_t byte_length); // Parses the SPS to completion. Returns true if the SPS was parsed correctly. bool Parse(); - uint16 width() { return width_; } - uint16 height() { return height_; } + uint16_t width() { return width_; } + uint16_t height() { return height_; } private: - const uint8* const sps_; + const uint8_t* const sps_; const size_t byte_length_; - uint16 width_; - uint16 height_; + uint16_t width_; + uint16_t height_; }; } // namespace webrtc diff --git a/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc b/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc index 621db108b1..ceadf4cb6b 100644 --- a/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc +++ b/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc @@ -38,8 +38,8 @@ static const size_t kSpsBufferMaxSize = 256; // The fake SPS that this generates also always has at least one emulation byte // at offset 2, since the first two bytes are always 0, and has a 0x3 as the // level_idc, to make sure the parser doesn't eat all 0x3 bytes. -void GenerateFakeSps(uint16 width, uint16 height, uint8 buffer[]) { - uint8 rbsp[kSpsBufferMaxSize] = {0}; +void GenerateFakeSps(uint16_t width, uint16_t height, uint8_t buffer[]) { + uint8_t rbsp[kSpsBufferMaxSize] = {0}; rtc::BitBufferWriter writer(rbsp, kSpsBufferMaxSize); // Profile byte. writer.WriteUInt8(0); @@ -63,11 +63,11 @@ void GenerateFakeSps(uint16 width, uint16 height, uint8 buffer[]) { // gaps_in_frame_num_value_allowed_flag: u(1). writer.WriteBits(0, 1); // Next are width/height. First, calculate the mbs/map_units versions. - uint16 width_in_mbs_minus1 = (width + 15) / 16 - 1; + uint16_t width_in_mbs_minus1 = (width + 15) / 16 - 1; // For the height, we're going to define frame_mbs_only_flag, so we need to // divide by 2. See the parser for the full calculation. - uint16 height_in_map_units_minus1 = ((height + 15) / 16 - 1) / 2; + uint16_t height_in_map_units_minus1 = ((height + 15) / 16 - 1) / 2; // Write each as ue(v). writer.WriteExponentialGolomb(width_in_mbs_minus1); writer.WriteExponentialGolomb(height_in_map_units_minus1); @@ -118,9 +118,9 @@ void GenerateFakeSps(uint16 width, uint16 height, uint8 buffer[]) { TEST(H264SpsParserTest, TestSampleSPSHdLandscape) { // SPS for a 1280x720 camera capture from ffmpeg on osx. Contains // emulation bytes but no cropping. - const uint8 buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, - 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, - 0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60}; + const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05, + 0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00, + 0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60}; H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer)); EXPECT_TRUE(parser.Parse()); EXPECT_EQ(1280u, parser.width()); @@ -130,9 +130,9 @@ TEST(H264SpsParserTest, TestSampleSPSHdLandscape) { TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) { // SPS for a 640x360 camera capture from ffmpeg on osx. Contains emulation // bytes and cropping (360 isn't divisible by 16). - const uint8 buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F, - 0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80, - 0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80}; + const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F, + 0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80, + 0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80}; H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer)); EXPECT_TRUE(parser.Parse()); EXPECT_EQ(640u, parser.width()); @@ -142,9 +142,9 @@ TEST(H264SpsParserTest, TestSampleSPSVgaLandscape) { TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) { // SPS for a 200x400 camera capture from ffmpeg on osx. Horizontal and // veritcal crop (neither dimension is divisible by 16). - const uint8 buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E, - 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, - 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; + const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E, + 0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00, + 0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60}; H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer)); EXPECT_TRUE(parser.Parse()); EXPECT_EQ(200u, parser.width()); @@ -152,7 +152,7 @@ TEST(H264SpsParserTest, TestSampleSPSWeirdResolution) { } TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { - uint8 buffer[kSpsBufferMaxSize] = {0}; + uint8_t buffer[kSpsBufferMaxSize] = {0}; GenerateFakeSps(320u, 180u, buffer); H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer)); EXPECT_TRUE(parser.Parse()); @@ -161,7 +161,7 @@ TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) { } TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) { - uint8 buffer[kSpsBufferMaxSize] = {0}; + uint8_t buffer[kSpsBufferMaxSize] = {0}; GenerateFakeSps(156u, 122u, buffer); H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer)); EXPECT_TRUE(parser.Parse()); diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.cc index 36646a9877..61ef80bbf1 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.cc @@ -56,10 +56,10 @@ rtc::scoped_refptr VideoFrameBufferForPixelBuffer( rtc::scoped_refptr buffer = new rtc::RefCountedObject(width, height); CVPixelBufferLockBaseAddress(pixel_buffer, kCVPixelBufferLock_ReadOnly); - const uint8* src_y = reinterpret_cast( + const uint8_t* src_y = reinterpret_cast( CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 0)); int src_y_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 0); - const uint8* src_uv = reinterpret_cast( + const uint8_t* src_uv = reinterpret_cast( CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 1)); int src_uv_stride = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 1); int ret = libyuv::NV12ToI420( diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc index fec32261b7..69e52a5b27 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc @@ -136,10 +136,10 @@ bool CopyVideoFrameToPixelBuffer(const webrtc::VideoFrame& frame, LOG(LS_ERROR) << "Failed to lock base address: " << cvRet; return false; } - uint8* dst_y = reinterpret_cast( + uint8_t* dst_y = reinterpret_cast( CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 0)); int dst_stride_y = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 0); - uint8* dst_uv = reinterpret_cast( + uint8_t* dst_uv = reinterpret_cast( CVPixelBufferGetBaseAddressOfPlane(pixel_buffer, 1)); int dst_stride_uv = CVPixelBufferGetBytesPerRowOfPlane(pixel_buffer, 1); // Convert I420 to NV12. diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc index 43a7de0458..caca96d3d8 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc @@ -123,7 +123,7 @@ bool H264CMSampleBufferToAnnexBBuffer( // Read the length of the next packet of data. Must convert from big endian // to host endian. RTC_DCHECK_GE(bytes_remaining, (size_t)nalu_header_size); - uint32_t* uint32_data_ptr = reinterpret_cast(data_ptr); + uint32_t* uint32_data_ptr = reinterpret_cast(data_ptr); uint32_t packet_size = CFSwapInt32BigToHost(*uint32_data_ptr); // Update buffer. annexb_buffer->AppendData(kAnnexBHeaderBytes, sizeof(kAnnexBHeaderBytes)); diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h index f1a069d831..672fa3aa89 100644 --- a/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h +++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_unittest.h @@ -848,7 +848,7 @@ class TestVp8Simulcast : public ::testing::Test { // 3rd stream: -1, -1, -1, -1, .... // Regarding the 3rd stream, note that a stream/encoder with 1 temporal layer // should always have temporal layer idx set to kNoTemporalIdx = -1. - // Since CodecSpecificInfoVP8.temporalIdx is uint8, this will wrap to 255. + // Since CodecSpecificInfoVP8.temporalIdx is uint8_t, this will wrap to 255. // TODO(marpan): Although this seems safe for now, we should fix this. void TestSpatioTemporalLayers321PatternEncoder() { int temporal_layer_profile[3] = {3, 2, 1}; diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc index ce600ec1a5..239ced8f90 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.cc @@ -98,9 +98,9 @@ void Vp9FrameBufferPool::ClearPool() { } // static -int32 Vp9FrameBufferPool::VpxGetFrameBuffer(void* user_priv, - size_t min_size, - vpx_codec_frame_buffer* fb) { +int32_t Vp9FrameBufferPool::VpxGetFrameBuffer(void* user_priv, + size_t min_size, + vpx_codec_frame_buffer* fb) { RTC_DCHECK(user_priv); RTC_DCHECK(fb); Vp9FrameBufferPool* pool = static_cast(user_priv); @@ -118,8 +118,8 @@ int32 Vp9FrameBufferPool::VpxGetFrameBuffer(void* user_priv, } // static -int32 Vp9FrameBufferPool::VpxReleaseFrameBuffer(void* user_priv, - vpx_codec_frame_buffer* fb) { +int32_t Vp9FrameBufferPool::VpxReleaseFrameBuffer(void* user_priv, + vpx_codec_frame_buffer* fb) { RTC_DCHECK(user_priv); RTC_DCHECK(fb); Vp9FrameBuffer* buffer = static_cast(fb->priv); diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h b/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h index 1ee5124ac8..97ed41a015 100644 --- a/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h +++ b/webrtc/modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h @@ -88,9 +88,9 @@ class Vp9FrameBufferPool { // |fb| Pointer to the libvpx frame buffer object, this is updated to // use the pool's buffer. // Returns 0 on success. Returns < 0 on failure. - static int32 VpxGetFrameBuffer(void* user_priv, - size_t min_size, - vpx_codec_frame_buffer* fb); + static int32_t VpxGetFrameBuffer(void* user_priv, + size_t min_size, + vpx_codec_frame_buffer* fb); // InitializeVpxUsePool configures libvpx to call this function when it has // finished using one of the pool's frame buffer. Parameters: @@ -98,8 +98,8 @@ class Vp9FrameBufferPool { // to be a pointer to the pool. // |fb| Pointer to the libvpx frame buffer object, its |priv| will be // a pointer to one of the pool's Vp9FrameBuffer. - static int32 VpxReleaseFrameBuffer(void* user_priv, - vpx_codec_frame_buffer* fb); + static int32_t VpxReleaseFrameBuffer(void* user_priv, + vpx_codec_frame_buffer* fb); private: // Protects |allocated_buffers_|. diff --git a/webrtc/p2p/base/asyncstuntcpsocket.cc b/webrtc/p2p/base/asyncstuntcpsocket.cc index 2b1b693588..444f06146a 100644 --- a/webrtc/p2p/base/asyncstuntcpsocket.cc +++ b/webrtc/p2p/base/asyncstuntcpsocket.cc @@ -20,13 +20,13 @@ namespace cricket { static const size_t kMaxPacketSize = 64 * 1024; -typedef uint16 PacketLength; +typedef uint16_t PacketLength; static const size_t kPacketLenSize = sizeof(PacketLength); static const size_t kPacketLenOffset = 2; static const size_t kBufSize = kMaxPacketSize + kStunHeaderSize; static const size_t kTurnChannelDataHdrSize = 4; -inline bool IsStunMessage(uint16 msg_type) { +inline bool IsStunMessage(uint16_t msg_type) { // The first two bits of a channel data message are 0b01. return (msg_type & 0xC000) ? false : true; } @@ -129,7 +129,7 @@ size_t AsyncStunTCPSocket::GetExpectedLength(const void* data, size_t len, PacketLength pkt_len = rtc::GetBE16(static_cast(data) + kPacketLenOffset); size_t expected_pkt_len; - uint16 msg_type = rtc::GetBE16(data); + uint16_t msg_type = rtc::GetBE16(data); if (IsStunMessage(msg_type)) { // STUN message. expected_pkt_len = kStunHeaderSize + pkt_len; diff --git a/webrtc/p2p/base/basicpacketsocketfactory.cc b/webrtc/p2p/base/basicpacketsocketfactory.cc index 9b12e78d87..697518da9d 100644 --- a/webrtc/p2p/base/basicpacketsocketfactory.cc +++ b/webrtc/p2p/base/basicpacketsocketfactory.cc @@ -44,7 +44,9 @@ BasicPacketSocketFactory::~BasicPacketSocketFactory() { } AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket( - const SocketAddress& address, uint16 min_port, uint16 max_port) { + const SocketAddress& address, + uint16_t min_port, + uint16_t max_port) { // UDP sockets are simple. rtc::AsyncSocket* socket = socket_factory()->CreateAsyncSocket( @@ -62,9 +64,10 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket( } AsyncPacketSocket* BasicPacketSocketFactory::CreateServerTcpSocket( - const SocketAddress& local_address, uint16 min_port, uint16 max_port, + const SocketAddress& local_address, + uint16_t min_port, + uint16_t max_port, int opts) { - // Fail if TLS is required. if (opts & PacketSocketFactory::OPT_TLS) { LOG(LS_ERROR) << "TLS support currently is not available."; @@ -176,9 +179,10 @@ AsyncResolverInterface* BasicPacketSocketFactory::CreateAsyncResolver() { return new rtc::AsyncResolver(); } -int BasicPacketSocketFactory::BindSocket( - AsyncSocket* socket, const SocketAddress& local_address, - uint16 min_port, uint16 max_port) { +int BasicPacketSocketFactory::BindSocket(AsyncSocket* socket, + const SocketAddress& local_address, + uint16_t min_port, + uint16_t max_port) { int ret = -1; if (min_port == 0 && max_port == 0) { // If there's no port range, let the OS pick a port for us. diff --git a/webrtc/p2p/base/basicpacketsocketfactory.h b/webrtc/p2p/base/basicpacketsocketfactory.h index b23a67729e..5046e0f518 100644 --- a/webrtc/p2p/base/basicpacketsocketfactory.h +++ b/webrtc/p2p/base/basicpacketsocketfactory.h @@ -27,11 +27,11 @@ class BasicPacketSocketFactory : public PacketSocketFactory { ~BasicPacketSocketFactory() override; AsyncPacketSocket* CreateUdpSocket(const SocketAddress& local_address, - uint16 min_port, - uint16 max_port) override; + uint16_t min_port, + uint16_t max_port) override; AsyncPacketSocket* CreateServerTcpSocket(const SocketAddress& local_address, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, int opts) override; AsyncPacketSocket* CreateClientTcpSocket(const SocketAddress& local_address, const SocketAddress& remote_address, @@ -44,8 +44,8 @@ class BasicPacketSocketFactory : public PacketSocketFactory { private: int BindSocket(AsyncSocket* socket, const SocketAddress& local_address, - uint16 min_port, - uint16 max_port); + uint16_t min_port, + uint16_t max_port); SocketFactory* socket_factory(); diff --git a/webrtc/p2p/base/candidate.h b/webrtc/p2p/base/candidate.h index 2655c1b26c..3f0ea43cde 100644 --- a/webrtc/p2p/base/candidate.h +++ b/webrtc/p2p/base/candidate.h @@ -43,11 +43,11 @@ class Candidate { Candidate(int component, const std::string& protocol, const rtc::SocketAddress& address, - uint32 priority, + uint32_t priority, const std::string& username, const std::string& password, const std::string& type, - uint32 generation, + uint32_t generation, const std::string& foundation) : id_(rtc::CreateRandomString(8)), component_(component), @@ -81,8 +81,8 @@ class Candidate { address_ = address; } - uint32 priority() const { return priority_; } - void set_priority(const uint32 priority) { priority_ = priority; } + uint32_t priority() const { return priority_; } + void set_priority(const uint32_t priority) { priority_ = priority; } // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc // doesn't use it. @@ -98,11 +98,11 @@ class Candidate { // TODO(pthatcher): Remove once Chromium's jingle/glue/utils.cc // doesn't use it. void set_preference(float preference) { - // Limiting priority to UINT_MAX when value exceeds uint32 max. + // Limiting priority to UINT_MAX when value exceeds uint32_t max. // This can happen for e.g. when preference = 3. - uint64 prio_val = static_cast(preference * 127) << 24; - priority_ = - static_cast(std::min(prio_val, static_cast(UINT_MAX))); + uint64_t prio_val = static_cast(preference * 127) << 24; + priority_ = static_cast( + std::min(prio_val, static_cast(UINT_MAX))); } const std::string & username() const { return username_; } @@ -125,8 +125,8 @@ class Candidate { } // Candidates in a new generation replace those in the old generation. - uint32 generation() const { return generation_; } - void set_generation(uint32 generation) { generation_ = generation; } + uint32_t generation() const { return generation_; } + void set_generation(uint32_t generation) { generation_ = generation; } const std::string generation_str() const { std::ostringstream ost; ost << generation_; @@ -177,9 +177,9 @@ class Candidate { return ToStringInternal(true); } - uint32 GetPriority(uint32 type_preference, - int network_adapter_preference, - int relay_preference) const { + uint32_t GetPriority(uint32_t type_preference, + int network_adapter_preference, + int relay_preference) const { // RFC 5245 - 4.1.2.1. // priority = (2^24)*(type preference) + // (2^8)*(local preference) + @@ -222,13 +222,13 @@ class Candidate { std::string protocol_; std::string relay_protocol_; rtc::SocketAddress address_; - uint32 priority_; + uint32_t priority_; std::string username_; std::string password_; std::string type_; std::string network_name_; rtc::AdapterType network_type_; - uint32 generation_; + uint32_t generation_; std::string foundation_; rtc::SocketAddress related_address_; std::string tcptype_; diff --git a/webrtc/p2p/base/dtlstransport.h b/webrtc/p2p/base/dtlstransport.h index c448eb16fc..e9a1ae2ada 100644 --- a/webrtc/p2p/base/dtlstransport.h +++ b/webrtc/p2p/base/dtlstransport.h @@ -229,10 +229,10 @@ class DtlsTransport : public Base { error_desc); } // Apply remote fingerprint. - if (!channel->SetRemoteFingerprint( - remote_fingerprint_->algorithm, - reinterpret_cast(remote_fingerprint_->digest.data()), - remote_fingerprint_->digest.size())) { + if (!channel->SetRemoteFingerprint(remote_fingerprint_->algorithm, + reinterpret_cast( + remote_fingerprint_->digest.data()), + remote_fingerprint_->digest.size())) { return BadTransportDescription("Failed to apply remote fingerprint.", error_desc); } diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index 26bb1814d5..bba7eb9de7 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -31,11 +31,11 @@ static const size_t kMinRtpPacketLen = 12; static const size_t kMaxPendingPackets = 1; static bool IsDtlsPacket(const char* data, size_t len) { - const uint8* u = reinterpret_cast(data); + const uint8_t* u = reinterpret_cast(data); return (len >= kDtlsRecordHeaderLen && (u[0] > 19 && u[0] < 64)); } static bool IsRtpPacket(const char* data, size_t len) { - const uint8* u = reinterpret_cast(data); + const uint8_t* u = reinterpret_cast(data); return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80); } @@ -196,9 +196,8 @@ bool DtlsTransportChannelWrapper::GetSslCipherSuite(int* cipher) { bool DtlsTransportChannelWrapper::SetRemoteFingerprint( const std::string& digest_alg, - const uint8* digest, + const uint8_t* digest, size_t digest_len) { - rtc::Buffer remote_fingerprint_value(digest, digest_len); if (dtls_state_ != STATE_NONE && @@ -570,7 +569,7 @@ bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data, size_t size) { // Sanity check we're not passing junk that // just looks like DTLS. - const uint8* tmp_data = reinterpret_cast(data); + const uint8_t* tmp_data = reinterpret_cast(data); size_t tmp_size = size; while (tmp_size > 0) { if (tmp_size < kDtlsRecordHeaderLen) diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index d27d30e01e..9a2ccdee99 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -104,7 +104,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { rtc::scoped_refptr GetLocalCertificate() const override; bool SetRemoteFingerprint(const std::string& digest_alg, - const uint8* digest, + const uint8_t* digest, size_t digest_len) override; bool IsDtlsActive() const override { return dtls_state_ != STATE_NONE; } @@ -152,10 +152,10 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { // encryption. DTLS-SRTP uses this to extract the needed SRTP keys. // See the SSLStreamAdapter documentation for info on the specific parameters. bool ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) override { return (dtls_.get()) ? dtls_->ExportKeyingMaterial(label, context, context_len, @@ -170,7 +170,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { TransportChannelState GetState() const override { return channel_->GetState(); } - void SetIceTiebreaker(uint64 tiebreaker) override { + void SetIceTiebreaker(uint64_t tiebreaker) override { channel_->SetIceTiebreaker(tiebreaker); } void SetIceCredentials(const std::string& ice_ufrag, diff --git a/webrtc/p2p/base/dtlstransportchannel_unittest.cc b/webrtc/p2p/base/dtlstransportchannel_unittest.cc index cad5b563a5..460e294a00 100644 --- a/webrtc/p2p/base/dtlstransportchannel_unittest.cc +++ b/webrtc/p2p/base/dtlstransportchannel_unittest.cc @@ -34,7 +34,7 @@ static const char kIcePwd1[] = "TESTICEPWD00000000000001"; static const size_t kPacketNumOffset = 8; static const size_t kPacketHeaderLen = 12; -static bool IsRtpLeadByte(uint8 b) { +static bool IsRtpLeadByte(uint8_t b) { return ((b & 0xC0) == 0x80); } @@ -254,7 +254,7 @@ class DtlsTestClient : public sigslot::has_slots<> { memset(packet.get(), sent & 0xff, size); packet[0] = (srtp) ? 0x80 : 0x00; rtc::SetBE32(packet.get() + kPacketNumOffset, - static_cast(sent)); + static_cast(sent)); // Only set the bypass flag if we've activated DTLS. int flags = (certificate_ && srtp) ? cricket::PF_SRTP_BYPASS : 0; @@ -287,14 +287,14 @@ class DtlsTestClient : public sigslot::has_slots<> { return received_.size(); } - bool VerifyPacket(const char* data, size_t size, uint32* out_num) { + bool VerifyPacket(const char* data, size_t size, uint32_t* out_num) { if (size != packet_size_ || - (data[0] != 0 && static_cast(data[0]) != 0x80)) { + (data[0] != 0 && static_cast(data[0]) != 0x80)) { return false; } - uint32 packet_num = rtc::GetBE32(data + kPacketNumOffset); + uint32_t packet_num = rtc::GetBE32(data + kPacketNumOffset); for (size_t i = kPacketHeaderLen; i < size; ++i) { - if (static_cast(data[i]) != (packet_num & 0xff)) { + if (static_cast(data[i]) != (packet_num & 0xff)) { return false; } } @@ -309,10 +309,10 @@ class DtlsTestClient : public sigslot::has_slots<> { if (size <= packet_size_) { return false; } - uint32 packet_num = rtc::GetBE32(data + kPacketNumOffset); + uint32_t packet_num = rtc::GetBE32(data + kPacketNumOffset); int num_matches = 0; for (size_t i = kPacketNumOffset; i < size; ++i) { - if (static_cast(data[i]) == (packet_num & 0xff)) { + if (static_cast(data[i]) == (packet_num & 0xff)) { ++num_matches; } } @@ -329,7 +329,7 @@ class DtlsTestClient : public sigslot::has_slots<> { const char* data, size_t size, const rtc::PacketTime& packet_time, int flags) { - uint32 packet_num = 0; + uint32_t packet_num = 0; ASSERT_TRUE(VerifyPacket(data, size, &packet_num)); received_.insert(packet_num); // Only DTLS-SRTP packets should have the bypass flag set. diff --git a/webrtc/p2p/base/faketransportcontroller.h b/webrtc/p2p/base/faketransportcontroller.h index 6d337a45a9..7d8e3d77e8 100644 --- a/webrtc/p2p/base/faketransportcontroller.h +++ b/webrtc/p2p/base/faketransportcontroller.h @@ -51,7 +51,7 @@ class FakeTransportChannel : public TransportChannelImpl, dtls_fingerprint_("", nullptr, 0) {} ~FakeTransportChannel() { Reset(); } - uint64 IceTiebreaker() const { return tiebreaker_; } + uint64_t IceTiebreaker() const { return tiebreaker_; } IceMode remote_ice_mode() const { return remote_ice_mode_; } const std::string& ice_ufrag() const { return ice_ufrag_; } const std::string& ice_pwd() const { return ice_pwd_; } @@ -82,7 +82,7 @@ class FakeTransportChannel : public TransportChannelImpl, void SetIceRole(IceRole role) override { role_ = role; } IceRole GetIceRole() const override { return role_; } - void SetIceTiebreaker(uint64 tiebreaker) override { + void SetIceTiebreaker(uint64_t tiebreaker) override { tiebreaker_ = tiebreaker; } void SetIceCredentials(const std::string& ice_ufrag, @@ -98,7 +98,7 @@ class FakeTransportChannel : public TransportChannelImpl, void SetRemoteIceMode(IceMode mode) override { remote_ice_mode_ = mode; } bool SetRemoteFingerprint(const std::string& alg, - const uint8* digest, + const uint8_t* digest, size_t digest_len) override { dtls_fingerprint_ = rtc::SSLFingerprint(alg, digest, digest_len); return true; @@ -266,10 +266,10 @@ class FakeTransportChannel : public TransportChannelImpl, } bool ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) override { if (!chosen_srtp_cipher_.empty()) { memset(result, 0xff, result_len); @@ -323,7 +323,7 @@ class FakeTransportChannel : public TransportChannelImpl, int receiving_timeout_ = -1; bool gather_continually_ = false; IceRole role_ = ICEROLE_UNKNOWN; - uint64 tiebreaker_ = 0; + uint64_t tiebreaker_ = 0; std::string ice_ufrag_; std::string ice_pwd_; std::string remote_ice_ufrag_; diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc index 1b7cb58756..fc72131233 100644 --- a/webrtc/p2p/base/p2ptransportchannel.cc +++ b/webrtc/p2p/base/p2ptransportchannel.cc @@ -30,18 +30,18 @@ enum { MSG_SORT = 1, MSG_CHECK_AND_PING }; // we don't want to degrade the quality on a modem. These numbers should work // well on a 28.8K modem, which is the slowest connection on which the voice // quality is reasonable at all. -static const uint32 PING_PACKET_SIZE = 60 * 8; +static const uint32_t PING_PACKET_SIZE = 60 * 8; // STRONG_PING_DELAY (480ms) is applied when the best connection is both // writable and receiving. -static const uint32 STRONG_PING_DELAY = 1000 * PING_PACKET_SIZE / 1000; +static const uint32_t STRONG_PING_DELAY = 1000 * PING_PACKET_SIZE / 1000; // WEAK_PING_DELAY (48ms) is applied when the best connection is either not // writable or not receiving. -static const uint32 WEAK_PING_DELAY = 1000 * PING_PACKET_SIZE / 10000; +static const uint32_t WEAK_PING_DELAY = 1000 * PING_PACKET_SIZE / 10000; // If the current best connection is both writable and receiving, then we will // also try hard to make sure it is pinged at this rate (a little less than // 2 * STRONG_PING_DELAY). -static const uint32 MAX_CURRENT_STRONG_DELAY = 900; +static const uint32_t MAX_CURRENT_STRONG_DELAY = 900; static const int MIN_CHECK_RECEIVING_DELAY = 50; // ms @@ -225,14 +225,14 @@ P2PTransportChannel::P2PTransportChannel(const std::string& transport_name, P2PTransportChannel::~P2PTransportChannel() { ASSERT(worker_thread_ == rtc::Thread::Current()); - for (uint32 i = 0; i < allocator_sessions_.size(); ++i) + for (size_t i = 0; i < allocator_sessions_.size(); ++i) delete allocator_sessions_[i]; } // Add the allocator session to our list so that we know which sessions // are still active. void P2PTransportChannel::AddAllocatorSession(PortAllocatorSession* session) { - session->set_generation(static_cast(allocator_sessions_.size())); + session->set_generation(static_cast(allocator_sessions_.size())); allocator_sessions_.push_back(session); // We now only want to apply new candidates that we receive to the ports @@ -275,7 +275,7 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) { } } -void P2PTransportChannel::SetIceTiebreaker(uint64 tiebreaker) { +void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) { ASSERT(worker_thread_ == rtc::Thread::Current()); if (!ports_.empty()) { LOG(LS_ERROR) @@ -553,7 +553,7 @@ void P2PTransportChannel::OnUnknownAddress( // The foundation of the candidate is set to an arbitrary value, different // from the foundation for all other remote candidates. remote_candidate.set_foundation( - rtc::ToString(rtc::ComputeCrc32(remote_candidate.id()))); + rtc::ToString(rtc::ComputeCrc32(remote_candidate.id()))); remote_candidate.set_priority(remote_candidate_priority); } @@ -638,7 +638,7 @@ void P2PTransportChannel::OnNominated(Connection* conn) { void P2PTransportChannel::AddRemoteCandidate(const Candidate& candidate) { ASSERT(worker_thread_ == rtc::Thread::Current()); - uint32 generation = candidate.generation(); + uint32_t generation = candidate.generation(); // Network may not guarantee the order of the candidate delivery. If a // remote candidate with an older generation arrives, drop it. if (generation != 0 && generation < remote_candidate_generation_) { @@ -765,7 +765,7 @@ bool P2PTransportChannel::FindConnection( return citer != connections_.end(); } -uint32 P2PTransportChannel::GetRemoteCandidateGeneration( +uint32_t P2PTransportChannel::GetRemoteCandidateGeneration( const Candidate& candidate) { // We need to keep track of the remote ice restart so newer // connections are prioritized over the older. @@ -777,7 +777,7 @@ uint32 P2PTransportChannel::GetRemoteCandidateGeneration( // Check if remote candidate is already cached. bool P2PTransportChannel::IsDuplicateRemoteCandidate( const Candidate& candidate) { - for (uint32 i = 0; i < remote_candidates_.size(); ++i) { + for (size_t i = 0; i < remote_candidates_.size(); ++i) { if (remote_candidates_[i].IsEquivalent(candidate)) { return true; } @@ -790,7 +790,7 @@ void P2PTransportChannel::RememberRemoteCandidate( const Candidate& remote_candidate, PortInterface* origin_port) { // Remove any candidates whose generation is older than this one. The // presence of a new generation indicates that the old ones are not useful. - uint32 i = 0; + size_t i = 0; while (i < remote_candidates_.size()) { if (remote_candidates_[i].generation() < remote_candidate.generation()) { LOG(INFO) << "Pruning candidate from old generation: " @@ -824,7 +824,7 @@ int P2PTransportChannel::SetOption(rtc::Socket::Option opt, int value) { it->second = value; } - for (uint32 i = 0; i < ports_.size(); ++i) { + for (size_t i = 0; i < ports_.size(); ++i) { int val = ports_[i]->SetOption(opt, value); if (val < 0) { // Because this also occurs deferred, probably no point in reporting an @@ -911,11 +911,11 @@ rtc::DiffServCodePoint P2PTransportChannel::DefaultDscpValue() const { // Monitor connection states. void P2PTransportChannel::UpdateConnectionStates() { - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); // We need to copy the list of connections since some may delete themselves // when we call UpdateState. - for (uint32 i = 0; i < connections_.size(); ++i) + for (size_t i = 0; i < connections_.size(); ++i) connections_[i]->UpdateState(now); } @@ -947,7 +947,7 @@ void P2PTransportChannel::SortConnections() { std::stable_sort(connections_.begin(), connections_.end(), cmp); LOG(LS_VERBOSE) << "Sorting " << connections_.size() << " available connections:"; - for (uint32 i = 0; i < connections_.size(); ++i) { + for (size_t i = 0; i < connections_.size(); ++i) { LOG(LS_VERBOSE) << connections_[i]->ToString(); } @@ -971,7 +971,7 @@ void P2PTransportChannel::SortConnections() { // Check if all connections are timedout. bool all_connections_timedout = true; - for (uint32 i = 0; i < connections_.size(); ++i) { + for (size_t i = 0; i < connections_.size(); ++i) { if (connections_[i]->write_state() != Connection::STATE_WRITE_TIMEOUT) { all_connections_timedout = false; break; @@ -1120,7 +1120,7 @@ Connection* P2PTransportChannel::GetBestConnectionOnNetwork( return best_connection_; // Otherwise, we return the top-most in sorted order. - for (uint32 i = 0; i < connections_.size(); ++i) { + for (size_t i = 0; i < connections_.size(); ++i) { if (connections_[i]->port()->Network() == network) return connections_[i]; } @@ -1198,7 +1198,7 @@ bool P2PTransportChannel::IsPingable(Connection* conn) { // reconnecting. The newly created connection should be selected as the ping // target to become writable instead. See the big comment in CompareConnections. Connection* P2PTransportChannel::FindNextPingableConnection() { - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); if (best_connection_ && best_connection_->connected() && best_connection_->writable() && (best_connection_->last_ping_sent() + MAX_CURRENT_STRONG_DELAY <= now)) { diff --git a/webrtc/p2p/base/p2ptransportchannel.h b/webrtc/p2p/base/p2ptransportchannel.h index 0e5e01982c..5249639763 100644 --- a/webrtc/p2p/base/p2ptransportchannel.h +++ b/webrtc/p2p/base/p2ptransportchannel.h @@ -62,7 +62,7 @@ class P2PTransportChannel : public TransportChannelImpl, TransportChannelState GetState() const override; void SetIceRole(IceRole role) override; IceRole GetIceRole() const override { return ice_role_; } - void SetIceTiebreaker(uint64 tiebreaker) override; + void SetIceTiebreaker(uint64_t tiebreaker) override; void SetIceCredentials(const std::string& ice_ufrag, const std::string& ice_pwd) override; void SetRemoteIceCredentials(const std::string& ice_ufrag, @@ -127,10 +127,10 @@ class P2PTransportChannel : public TransportChannelImpl, // Allows key material to be extracted for external encryption. bool ExportKeyingMaterial(const std::string& label, - const uint8* context, + const uint8_t* context, size_t context_len, bool use_context, - uint8* result, + uint8_t* result, size_t result_len) override { return false; } @@ -142,7 +142,7 @@ class P2PTransportChannel : public TransportChannelImpl, // Set DTLS Remote fingerprint. Must be after local identity set. bool SetRemoteFingerprint(const std::string& digest_alg, - const uint8* digest, + const uint8_t* digest, size_t digest_len) override { return false; } @@ -182,7 +182,7 @@ class P2PTransportChannel : public TransportChannelImpl, PortInterface* origin_port); bool FindConnection(cricket::Connection* connection) const; - uint32 GetRemoteCandidateGeneration(const Candidate& candidate); + uint32_t GetRemoteCandidateGeneration(const Candidate& candidate); bool IsDuplicateRemoteCandidate(const Candidate& candidate); void RememberRemoteCandidate(const Candidate& remote_candidate, PortInterface* origin_port); @@ -243,13 +243,13 @@ class P2PTransportChannel : public TransportChannelImpl, std::string remote_ice_pwd_; IceMode remote_ice_mode_; IceRole ice_role_; - uint64 tiebreaker_; - uint32 remote_candidate_generation_; + uint64_t tiebreaker_; + uint32_t remote_candidate_generation_; IceGatheringState gathering_state_; int check_receiving_delay_; int receiving_timeout_; - uint32 last_ping_sent_ms_ = 0; + uint32_t last_ping_sent_ms_ = 0; bool gather_continually_ = false; RTC_DISALLOW_COPY_AND_ASSIGN(P2PTransportChannel); diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index 56635dce44..86f4ec3852 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -93,8 +93,8 @@ static const char* kIcePwd[4] = {"TESTICEPWD00000000000000", "TESTICEPWD00000000000002", "TESTICEPWD00000000000003"}; -static const uint64 kTiebreaker1 = 11111; -static const uint64 kTiebreaker2 = 22222; +static const uint64_t kTiebreaker1 = 11111; +static const uint64_t kTiebreaker2 = 22222; enum { MSG_CANDIDATE @@ -239,11 +239,11 @@ class P2PTransportChannelTestBase : public testing::Test, void SetIceRole(cricket::IceRole role) { role_ = role; } cricket::IceRole ice_role() { return role_; } - void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } - uint64 GetIceTiebreaker() { return tiebreaker_; } + void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; } + uint64_t GetIceTiebreaker() { return tiebreaker_; } void OnRoleConflict(bool role_conflict) { role_conflict_ = role_conflict; } bool role_conflict() { return role_conflict_; } - void SetAllocationStepDelay(uint32 delay) { + void SetAllocationStepDelay(uint32_t delay) { allocator_->set_step_delay(delay); } void SetAllowTcpListen(bool allow_tcp_listen) { @@ -255,7 +255,7 @@ class P2PTransportChannelTestBase : public testing::Test, ChannelData cd1_; ChannelData cd2_; cricket::IceRole role_; - uint64 tiebreaker_; + uint64_t tiebreaker_; bool role_conflict_; bool save_candidates_; std::vector saved_candidates_; @@ -382,13 +382,13 @@ class P2PTransportChannelTestBase : public testing::Test, void SetIceRole(int endpoint, cricket::IceRole role) { GetEndpoint(endpoint)->SetIceRole(role); } - void SetIceTiebreaker(int endpoint, uint64 tiebreaker) { + void SetIceTiebreaker(int endpoint, uint64_t tiebreaker) { GetEndpoint(endpoint)->SetIceTiebreaker(tiebreaker); } bool GetRoleConflict(int endpoint) { return GetEndpoint(endpoint)->role_conflict(); } - void SetAllocationStepDelay(int endpoint, uint32 delay) { + void SetAllocationStepDelay(int endpoint, uint32_t delay) { return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); } void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { @@ -491,7 +491,7 @@ class P2PTransportChannelTestBase : public testing::Test, } void Test(const Result& expected) { - int32 connect_start = rtc::Time(), connect_time; + int32_t connect_start = rtc::Time(), connect_time; // Create the channels and wait for them to connect. CreateChannels(1); @@ -515,7 +515,7 @@ class P2PTransportChannelTestBase : public testing::Test, // This may take up to 2 seconds. if (ep1_ch1()->best_connection() && ep2_ch1()->best_connection()) { - int32 converge_start = rtc::Time(), converge_time; + int32_t converge_start = rtc::Time(), converge_time; int converge_wait = 2000; EXPECT_TRUE_WAIT_MARGIN(CheckCandidate1(expected), converge_wait, converge_wait); @@ -1807,7 +1807,7 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { ch.AddRemoteCandidate(CreateCandidate("1.1.1.1", 1, 1)); cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); ASSERT_TRUE(conn1 != nullptr); - uint32 remote_priority = conn1->remote_candidate().priority(); + uint32_t remote_priority = conn1->remote_candidate().priority(); // Create a higher priority candidate and make the connection // receiving/writable. This will prune conn1. @@ -1828,7 +1828,7 @@ TEST_F(P2PTransportChannelPingTest, ConnectionResurrection) { request.SetType(cricket::STUN_BINDING_REQUEST); request.AddAttribute(new cricket::StunByteStringAttribute( cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); - uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; + uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; request.AddAttribute(new cricket::StunUInt32Attribute( cricket::STUN_ATTR_PRIORITY, prflx_priority)); EXPECT_NE(prflx_priority, remote_priority); @@ -1945,7 +1945,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionFromUnknownAddress) { request.SetType(cricket::STUN_BINDING_REQUEST); request.AddAttribute(new cricket::StunByteStringAttribute( cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); - uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; + uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; request.AddAttribute(new cricket::StunUInt32Attribute( cricket::STUN_ATTR_PRIORITY, prflx_priority)); cricket::Port* port = GetPort(&ch); @@ -2032,7 +2032,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) { request.SetType(cricket::STUN_BINDING_REQUEST); request.AddAttribute(new cricket::StunByteStringAttribute( cricket::STUN_ATTR_USERNAME, kIceUfrag[1])); - uint32 prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; + uint32_t prflx_priority = cricket::ICE_TYPE_PREFERENCE_PRFLX << 24; request.AddAttribute(new cricket::StunUInt32Attribute( cricket::STUN_ATTR_PRIORITY, prflx_priority)); request.AddAttribute( diff --git a/webrtc/p2p/base/packetsocketfactory.h b/webrtc/p2p/base/packetsocketfactory.h index e51c7873b6..54037241b0 100644 --- a/webrtc/p2p/base/packetsocketfactory.h +++ b/webrtc/p2p/base/packetsocketfactory.h @@ -30,12 +30,12 @@ class PacketSocketFactory { virtual ~PacketSocketFactory() { } virtual AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, - uint16 min_port, - uint16 max_port) = 0; + uint16_t min_port, + uint16_t max_port) = 0; virtual AsyncPacketSocket* CreateServerTcpSocket( const SocketAddress& local_address, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, int opts) = 0; // TODO: |proxy_info| and |user_agent| should be set diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc index ce2855106c..39fff5f648 100644 --- a/webrtc/p2p/base/port.cc +++ b/webrtc/p2p/base/port.cc @@ -30,17 +30,16 @@ namespace { // pings fail to have a response. inline bool TooManyFailures( const std::vector& pings_since_last_response, - uint32 maximum_failures, - uint32 rtt_estimate, - uint32 now) { - + uint32_t maximum_failures, + uint32_t rtt_estimate, + uint32_t now) { // If we haven't sent that many pings, then we can't have failed that many. if (pings_since_last_response.size() < maximum_failures) return false; // Check if the window in which we would expect a response to the ping has // already elapsed. - uint32 expected_response_time = + uint32_t expected_response_time = pings_since_last_response[maximum_failures - 1].sent_time + rtt_estimate; return now > expected_response_time; } @@ -48,9 +47,8 @@ inline bool TooManyFailures( // Determines whether we have gone too long without seeing any response. inline bool TooLongWithoutResponse( const std::vector& pings_since_last_response, - uint32 maximum_time, - uint32 now) { - + uint32_t maximum_time, + uint32_t now) { if (pings_since_last_response.size() == 0) return false; @@ -60,15 +58,15 @@ inline bool TooLongWithoutResponse( // We will restrict RTT estimates (when used for determining state) to be // within a reasonable range. -const uint32 MINIMUM_RTT = 100; // 0.1 seconds -const uint32 MAXIMUM_RTT = 3000; // 3 seconds +const uint32_t MINIMUM_RTT = 100; // 0.1 seconds +const uint32_t MAXIMUM_RTT = 3000; // 3 seconds // When we don't have any RTT data, we have to pick something reasonable. We // use a large value just in case the connection is really slow. -const uint32 DEFAULT_RTT = MAXIMUM_RTT; +const uint32_t DEFAULT_RTT = MAXIMUM_RTT; // Computes our estimate of the RTT given the current estimate. -inline uint32 ConservativeRTTEstimate(uint32 rtt) { +inline uint32_t ConservativeRTTEstimate(uint32_t rtt) { return std::max(MINIMUM_RTT, std::min(MAXIMUM_RTT, 2 * rtt)); } @@ -128,7 +126,7 @@ static std::string ComputeFoundation( const rtc::SocketAddress& base_address) { std::ostringstream ost; ost << type << base_address.ipaddr().ToString() << protocol; - return rtc::ToString(rtc::ComputeCrc32(ost.str())); + return rtc::ToString(rtc::ComputeCrc32(ost.str())); } Port::Port(rtc::Thread* thread, @@ -162,8 +160,8 @@ Port::Port(rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username_fragment, const std::string& password) : thread_(thread), @@ -212,7 +210,7 @@ Port::~Port() { ++iter; } - for (uint32 i = 0; i < list.size(); i++) + for (uint32_t i = 0; i < list.size(); i++) delete list[i]; } @@ -231,8 +229,8 @@ void Port::AddAddress(const rtc::SocketAddress& address, const std::string& relay_protocol, const std::string& tcptype, const std::string& type, - uint32 type_preference, - uint32 relay_preference, + uint32_t type_preference, + uint32_t relay_preference, bool final) { if (protocol == TCP_PROTOCOL_NAME && type == LOCAL_PORT_TYPE) { ASSERT(!tcptype.empty()); @@ -465,7 +463,7 @@ bool Port::MaybeIceRoleConflict( // Validate ICE_CONTROLLING or ICE_CONTROLLED attributes. bool ret = true; IceRole remote_ice_role = ICEROLE_UNKNOWN; - uint64 remote_tiebreaker = 0; + uint64_t remote_tiebreaker = 0; const StunUInt64Attribute* stun_attr = stun_msg->GetUInt64(STUN_ATTR_ICE_CONTROLLING); if (stun_attr) { @@ -697,8 +695,8 @@ class ConnectionRequest : public StunRequest { if (connection_->port()->send_retransmit_count_attribute()) { request->AddAttribute(new StunUInt32Attribute( STUN_ATTR_RETRANSMIT_COUNT, - static_cast( - connection_->pings_since_last_response_.size() - 1))); + static_cast(connection_->pings_since_last_response_.size() - + 1))); } // Adding ICE_CONTROLLED or ICE_CONTROLLING attribute based on the role. @@ -727,7 +725,8 @@ class ConnectionRequest : public StunRequest { // priority = (2^24)*(type preference) + // (2^8)*(local preference) + // (2^0)*(256 - component ID) - uint32 prflx_priority = ICE_TYPE_PREFERENCE_PRFLX << 24 | + uint32_t prflx_priority = + ICE_TYPE_PREFERENCE_PRFLX << 24 | (connection_->local_candidate().priority() & 0x00FFFFFF); request->AddAttribute( new StunUInt32Attribute(STUN_ATTR_PRIORITY, prflx_priority)); @@ -811,8 +810,8 @@ const Candidate& Connection::local_candidate() const { return port_->Candidates()[local_candidate_index_]; } -uint64 Connection::priority() const { - uint64 priority = 0; +uint64_t Connection::priority() const { + uint64_t priority = 0; // RFC 5245 - 5.7.2. Computing Pair Priority and Ordering Pairs // Let G be the priority for the candidate provided by the controlling // agent. Let D be the priority for the candidate provided by the @@ -820,8 +819,8 @@ uint64 Connection::priority() const { // pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) IceRole role = port_->GetIceRole(); if (role != ICEROLE_UNKNOWN) { - uint32 g = 0; - uint32 d = 0; + uint32_t g = 0; + uint32_t d = 0; if (role == ICEROLE_CONTROLLING) { g = local_candidate().priority(); d = remote_candidate_.priority(); @@ -1020,8 +1019,8 @@ void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { *s = oss.str(); } -void Connection::UpdateState(uint32 now) { - uint32 rtt = ConservativeRTTEstimate(rtt_); +void Connection::UpdateState(uint32_t now) { + uint32_t rtt = ConservativeRTTEstimate(rtt_); if (LOG_CHECK_LEVEL(LS_VERBOSE)) { std::string pings; @@ -1052,7 +1051,7 @@ void Connection::UpdateState(uint32 now) { TooLongWithoutResponse(pings_since_last_response_, CONNECTION_WRITE_CONNECT_TIMEOUT, now)) { - uint32 max_pings = CONNECTION_WRITE_CONNECT_FAILURES; + uint32_t max_pings = CONNECTION_WRITE_CONNECT_FAILURES; LOG_J(LS_INFO, this) << "Unwritable after " << max_pings << " ping failures and " << now - pings_since_last_response_[0].sent_time @@ -1077,7 +1076,7 @@ void Connection::UpdateState(uint32 now) { } // Check the receiving state. - uint32 last_recv_time = last_received(); + uint32_t last_recv_time = last_received(); bool receiving = now <= last_recv_time + receiving_timeout_; set_receiving(receiving); if (dead(now)) { @@ -1085,7 +1084,7 @@ void Connection::UpdateState(uint32 now) { } } -void Connection::Ping(uint32 now) { +void Connection::Ping(uint32_t now) { last_ping_sent_ = now; ConnectionRequest *req = new ConnectionRequest(this); pings_since_last_response_.push_back(SentPing(req->id(), now)); @@ -1113,7 +1112,7 @@ void Connection::ReceivedPingResponse() { last_ping_response_received_ = rtc::Time(); } -bool Connection::dead(uint32 now) const { +bool Connection::dead(uint32_t now) const { if (now < (time_created_ms_ + MIN_CONNECTION_LIFETIME)) { // A connection that hasn't passed its minimum lifetime is still alive. // We do this to prevent connections from being pruned too quickly @@ -1198,7 +1197,7 @@ void Connection::OnConnectionRequestResponse(ConnectionRequest* request, // connection. rtc::LoggingSeverity sev = !writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; - uint32 rtt = request->Elapsed(); + uint32_t rtt = request->Elapsed(); ReceivedPingResponse(); @@ -1299,7 +1298,7 @@ void Connection::OnMessage(rtc::Message *pmsg) { delete this; } -uint32 Connection::last_received() { +uint32_t Connection::last_received() { return std::max(last_data_received_, std::max(last_ping_received_, last_ping_response_received_)); } @@ -1366,7 +1365,7 @@ void Connection::MaybeAddPrflxCandidate(ConnectionRequest* request, << "stun response message"; return; } - const uint32 priority = priority_attr->value(); + const uint32_t priority = priority_attr->value(); std::string id = rtc::CreateRandomString(8); Candidate new_local_candidate; diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h index c6b7f609aa..dc548763de 100644 --- a/webrtc/p2p/base/port.h +++ b/webrtc/p2p/base/port.h @@ -52,19 +52,19 @@ extern const char TCPTYPE_SIMOPEN_STR[]; // The minimum time we will wait before destroying a connection after creating // it. -const uint32 MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds. +const uint32_t MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds. // The timeout duration when a connection does not receive anything. -const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds +const uint32_t WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds // The length of time we wait before timing out writability on a connection. -const uint32 CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds +const uint32_t CONNECTION_WRITE_TIMEOUT = 15 * 1000; // 15 seconds // The length of time we wait before we become unwritable. -const uint32 CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds +const uint32_t CONNECTION_WRITE_CONNECT_TIMEOUT = 5 * 1000; // 5 seconds // The number of pings that must fail to respond before we become unwritable. -const uint32 CONNECTION_WRITE_CONNECT_FAILURES = 5; +const uint32_t CONNECTION_WRITE_CONNECT_FAILURES = 5; // This is the length of time that we wait for a ping response to come back. const int CONNECTION_RESPONSE_TIMEOUT = 5 * 1000; // 5 seconds @@ -122,8 +122,8 @@ class Port : public PortInterface, public rtc::MessageHandler, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username_fragment, const std::string& password); virtual ~Port(); @@ -135,8 +135,8 @@ class Port : public PortInterface, public rtc::MessageHandler, IceRole GetIceRole() const { return ice_role_; } void SetIceRole(IceRole role) { ice_role_ = role; } - void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; } - uint64 IceTiebreaker() const { return tiebreaker_; } + void SetIceTiebreaker(uint64_t tiebreaker) { tiebreaker_ = tiebreaker; } + uint64_t IceTiebreaker() const { return tiebreaker_; } virtual bool SharedSocket() const { return shared_socket_; } void ResetSharedSocket() { shared_socket_ = false; } @@ -167,8 +167,8 @@ class Port : public PortInterface, public rtc::MessageHandler, } // Identifies the generation that this port was created in. - uint32 generation() { return generation_; } - void set_generation(uint32 generation) { generation_ = generation; } + uint32_t generation() { return generation_; } + void set_generation(uint32_t generation) { generation_ = generation; } // ICE requires a single username/password per content/media line. So the // |ice_username_fragment_| of the ports that belongs to the same content will @@ -257,8 +257,8 @@ class Port : public PortInterface, public rtc::MessageHandler, // Debugging description of this port virtual std::string ToString() const; const rtc::IPAddress& ip() const { return ip_; } - uint16 min_port() { return min_port_; } - uint16 max_port() { return max_port_; } + uint16_t min_port() { return min_port_; } + uint16_t max_port() { return max_port_; } // Timeout shortening function to speed up unit tests. void set_timeout_delay(int delay) { timeout_delay_ = delay; } @@ -282,7 +282,7 @@ class Port : public PortInterface, public rtc::MessageHandler, // Returns the index of the new local candidate. size_t AddPrflxCandidate(const Candidate& local); - void set_candidate_filter(uint32 candidate_filter) { + void set_candidate_filter(uint32_t candidate_filter) { candidate_filter_ = candidate_filter; } @@ -301,8 +301,8 @@ class Port : public PortInterface, public rtc::MessageHandler, const std::string& relay_protocol, const std::string& tcptype, const std::string& type, - uint32 type_preference, - uint32 relay_preference, + uint32_t type_preference, + uint32_t relay_preference, bool final); // Adds the given connection to the list. (Deleting removes them.) @@ -333,7 +333,7 @@ class Port : public PortInterface, public rtc::MessageHandler, return rtc::DSCP_NO_CHANGE; } - uint32 candidate_filter() { return candidate_filter_; } + uint32_t candidate_filter() { return candidate_filter_; } private: void Construct(); @@ -352,11 +352,11 @@ class Port : public PortInterface, public rtc::MessageHandler, bool send_retransmit_count_attribute_; rtc::Network* network_; rtc::IPAddress ip_; - uint16 min_port_; - uint16 max_port_; + uint16_t min_port_; + uint16_t max_port_; std::string content_name_; int component_; - uint32 generation_; + uint32_t generation_; // In order to establish a connection to this Port (so that real data can be // sent through), the other side must send us a STUN binding request that is // authenticated with this username_fragment and password. @@ -372,7 +372,7 @@ class Port : public PortInterface, public rtc::MessageHandler, int timeout_delay_; bool enable_port_packets_; IceRole ice_role_; - uint64 tiebreaker_; + uint64_t tiebreaker_; bool shared_socket_; // Information to use when going through a proxy. std::string user_agent_; @@ -382,7 +382,7 @@ class Port : public PortInterface, public rtc::MessageHandler, // make its own decision on how to create candidates. For example, // when IceTransportsType is set to relay, both RelayPort and // TurnPort will hide raddr to avoid local address leakage. - uint32 candidate_filter_; + uint32_t candidate_filter_; friend class Connection; }; @@ -393,12 +393,11 @@ class Connection : public rtc::MessageHandler, public sigslot::has_slots<> { public: struct SentPing { - SentPing(const std::string id, uint32 sent_time) - : id(id), - sent_time(sent_time) {} + SentPing(const std::string id, uint32_t sent_time) + : id(id), sent_time(sent_time) {} std::string id; - uint32 sent_time; + uint32_t sent_time; }; // States are from RFC 5245. http://tools.ietf.org/html/rfc5245#section-5.7.4 @@ -422,7 +421,7 @@ class Connection : public rtc::MessageHandler, const Candidate& remote_candidate() const { return remote_candidate_; } // Returns the pair priority. - uint64 priority() const; + uint64_t priority() const; enum WriteState { STATE_WRITABLE = 0, // we have received ping responses recently @@ -444,10 +443,10 @@ class Connection : public rtc::MessageHandler, return write_state_ != STATE_WRITE_TIMEOUT; } // A connection is dead if it can be safely deleted. - bool dead(uint32 now) const; + bool dead(uint32_t now) const; // Estimate of the round-trip time over this connection. - uint32 rtt() const { return rtt_; } + uint32_t rtt() const { return rtt_; } size_t sent_total_bytes(); size_t sent_bytes_second(); @@ -501,7 +500,7 @@ class Connection : public rtc::MessageHandler, remote_ice_mode_ = mode; } - void set_receiving_timeout(uint32 receiving_timeout_ms) { + void set_receiving_timeout(uint32_t receiving_timeout_ms) { receiving_timeout_ = receiving_timeout_ms; } @@ -510,16 +509,16 @@ class Connection : public rtc::MessageHandler, // Checks that the state of this connection is up-to-date. The argument is // the current time, which is compared against various timeouts. - void UpdateState(uint32 now); + void UpdateState(uint32_t now); // Called when this connection should try checking writability again. - uint32 last_ping_sent() const { return last_ping_sent_; } - void Ping(uint32 now); + uint32_t last_ping_sent() const { return last_ping_sent_; } + void Ping(uint32_t now); void ReceivedPingResponse(); // Called whenever a valid ping is received on this connection. This is // public because the connection intercepts the first ping for us. - uint32 last_ping_received() const { return last_ping_received_; } + uint32_t last_ping_received() const { return last_ping_received_; } void ReceivedPing(); // Debugging description of this connection @@ -555,7 +554,7 @@ class Connection : public rtc::MessageHandler, // Returns the last received time of any data, stun request, or stun // response in milliseconds - uint32 last_received(); + uint32_t last_received(); protected: enum { MSG_DELETE = 0, MSG_FIRST_AVAILABLE }; @@ -599,18 +598,18 @@ class Connection : public rtc::MessageHandler, bool nominated_; IceMode remote_ice_mode_; StunRequestManager requests_; - uint32 rtt_; - uint32 last_ping_sent_; // last time we sent a ping to the other side - uint32 last_ping_received_; // last time we received a ping from the other - // side - uint32 last_data_received_; - uint32 last_ping_response_received_; + uint32_t rtt_; + uint32_t last_ping_sent_; // last time we sent a ping to the other side + uint32_t last_ping_received_; // last time we received a ping from the other + // side + uint32_t last_data_received_; + uint32_t last_ping_response_received_; std::vector pings_since_last_response_; rtc::RateTracker recv_rate_tracker_; rtc::RateTracker send_rate_tracker_; - uint32 sent_packets_discarded_; - uint32 sent_packets_total_; + uint32_t sent_packets_discarded_; + uint32_t sent_packets_total_; private: void MaybeAddPrflxCandidate(ConnectionRequest* request, @@ -619,8 +618,8 @@ class Connection : public rtc::MessageHandler, bool reported_; State state_; // Time duration to switch from receiving to not receiving. - uint32 receiving_timeout_; - uint32 time_created_ms_; + uint32_t receiving_timeout_; + uint32_t time_created_ms_; friend class Port; friend class ConnectionRequest; diff --git a/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc index 4c262bc93e..4a4ed32456 100644 --- a/webrtc/p2p/base/port_unittest.cc +++ b/webrtc/p2p/base/port_unittest.cc @@ -62,8 +62,9 @@ static const RelayCredentials kRelayCredentials("test", "test"); // TODO: Update these when RFC5245 is completely supported. // Magic value of 30 is from RFC3484, for IPv4 addresses. -static const uint32 kDefaultPrflxPriority = ICE_TYPE_PREFERENCE_PRFLX << 24 | - 30 << 8 | (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); +static const uint32_t kDefaultPrflxPriority = + ICE_TYPE_PREFERENCE_PRFLX << 24 | 30 << 8 | + (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); static const int kTiebreaker1 = 11111; static const int kTiebreaker2 = 22222; @@ -100,13 +101,19 @@ class TestPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username_fragment, const std::string& password) - : Port(thread, type, factory, network, ip, min_port, max_port, - username_fragment, password) { - } + : Port(thread, + type, + factory, + network, + ip, + min_port, + max_port, + username_fragment, + password) {} ~TestPort() {} // Expose GetStunMessage so that we can test it. @@ -249,9 +256,7 @@ class TestChannel : public sigslot::has_slots<> { void Ping() { Ping(0); } - void Ping(uint32 now) { - conn_->Ping(now); - } + void Ping(uint32_t now) { conn_->Ping(now); } void Stop() { if (conn_) { conn_->Destroy(); @@ -904,8 +909,8 @@ class FakePacketSocketFactory : public rtc::PacketSocketFactory { ~FakePacketSocketFactory() override { } AsyncPacketSocket* CreateUdpSocket(const SocketAddress& address, - uint16 min_port, - uint16 max_port) override { + uint16_t min_port, + uint16_t max_port) override { EXPECT_TRUE(next_udp_socket_ != NULL); AsyncPacketSocket* result = next_udp_socket_; next_udp_socket_ = NULL; @@ -913,8 +918,8 @@ class FakePacketSocketFactory : public rtc::PacketSocketFactory { } AsyncPacketSocket* CreateServerTcpSocket(const SocketAddress& local_address, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, int opts) override { EXPECT_TRUE(next_server_tcp_socket_ != NULL); AsyncPacketSocket* result = next_server_tcp_socket_; @@ -1967,13 +1972,13 @@ TEST_F(PortTest, TestHandleStunBindingIndication) { rtc::PacketTime()); ASSERT_TRUE_WAIT(lport->last_stun_msg() != NULL, 1000); EXPECT_EQ(STUN_BINDING_RESPONSE, lport->last_stun_msg()->type()); - uint32 last_ping_received1 = lconn->last_ping_received(); + uint32_t last_ping_received1 = lconn->last_ping_received(); // Adding a delay of 100ms. rtc::Thread::Current()->ProcessMessages(100); // Pinging lconn using stun indication message. lconn->OnReadPacket(buf->Data(), buf->Length(), rtc::PacketTime()); - uint32 last_ping_received2 = lconn->last_ping_received(); + uint32_t last_ping_received2 = lconn->last_ping_received(); EXPECT_GT(last_ping_received2, last_ping_received1); } @@ -1993,15 +1998,15 @@ TEST_F(PortTest, TestComputeCandidatePriority) { port->AddCandidateAddress(SocketAddress("3ffe::1234:5678", 1234)); // These should all be: // (90 << 24) | ([rfc3484 pref value] << 8) | (256 - 177) - uint32 expected_priority_v4 = 1509957199U; - uint32 expected_priority_v6 = 1509959759U; - uint32 expected_priority_ula = 1509962319U; - uint32 expected_priority_v4mapped = expected_priority_v4; - uint32 expected_priority_v4compat = 1509949775U; - uint32 expected_priority_6to4 = 1509954639U; - uint32 expected_priority_teredo = 1509952079U; - uint32 expected_priority_sitelocal = 1509949775U; - uint32 expected_priority_6bone = 1509949775U; + uint32_t expected_priority_v4 = 1509957199U; + uint32_t expected_priority_v6 = 1509959759U; + uint32_t expected_priority_ula = 1509962319U; + uint32_t expected_priority_v4mapped = expected_priority_v4; + uint32_t expected_priority_v4compat = 1509949775U; + uint32_t expected_priority_6to4 = 1509954639U; + uint32_t expected_priority_teredo = 1509952079U; + uint32_t expected_priority_sitelocal = 1509949775U; + uint32_t expected_priority_6bone = 1509949775U; ASSERT_EQ(expected_priority_v4, port->Candidates()[0].priority()); ASSERT_EQ(expected_priority_v6, port->Candidates()[1].priority()); ASSERT_EQ(expected_priority_ula, port->Candidates()[2].priority()); @@ -2233,10 +2238,10 @@ TEST_F(PortTest, TestWritableState) { // Ask the connection to update state as if enough time has passed to lose // full writability and 5 pings went unresponded to. We'll accomplish the // latter by sending pings but not pumping messages. - for (uint32 i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { + for (uint32_t i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { ch1.Ping(i); } - uint32 unreliable_timeout_delay = CONNECTION_WRITE_CONNECT_TIMEOUT + 500u; + uint32_t unreliable_timeout_delay = CONNECTION_WRITE_CONNECT_TIMEOUT + 500u; ch1.conn()->UpdateState(unreliable_timeout_delay); EXPECT_EQ(Connection::STATE_WRITE_UNRELIABLE, ch1.conn()->write_state()); @@ -2250,7 +2255,7 @@ TEST_F(PortTest, TestWritableState) { // Wait long enough for a full timeout (past however long we've already // waited). - for (uint32 i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { + for (uint32_t i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { ch1.Ping(unreliable_timeout_delay + i); } ch1.conn()->UpdateState(unreliable_timeout_delay + CONNECTION_WRITE_TIMEOUT + @@ -2283,7 +2288,7 @@ TEST_F(PortTest, TestTimeoutForNeverWritable) { EXPECT_EQ(Connection::STATE_WRITE_INIT, ch1.conn()->write_state()); // Attempt to go directly to write timeout. - for (uint32 i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { + for (uint32_t i = 1; i <= CONNECTION_WRITE_CONNECT_FAILURES; ++i) { ch1.Ping(i); } ch1.conn()->UpdateState(CONNECTION_WRITE_TIMEOUT + 500u); diff --git a/webrtc/p2p/base/portallocator.cc b/webrtc/p2p/base/portallocator.cc index b97ad554d6..5c4243abf6 100644 --- a/webrtc/p2p/base/portallocator.cc +++ b/webrtc/p2p/base/portallocator.cc @@ -17,7 +17,7 @@ PortAllocatorSession::PortAllocatorSession(const std::string& content_name, int component, const std::string& ice_ufrag, const std::string& ice_pwd, - uint32 flags) + uint32_t flags) : content_name_(content_name), component_(component), flags_(flags), diff --git a/webrtc/p2p/base/portallocator.h b/webrtc/p2p/base/portallocator.h index 69b5ed0582..4f8ec2fbe6 100644 --- a/webrtc/p2p/base/portallocator.h +++ b/webrtc/p2p/base/portallocator.h @@ -55,12 +55,12 @@ enum { PORTALLOCATOR_DISABLE_UDP_RELAY = 0x1000, }; -const uint32 kDefaultPortAllocatorFlags = 0; +const uint32_t kDefaultPortAllocatorFlags = 0; -const uint32 kDefaultStepDelay = 1000; // 1 sec step delay. +const uint32_t kDefaultStepDelay = 1000; // 1 sec step delay. // As per RFC 5245 Appendix B.1, STUN transactions need to be paced at certain // internal. Less than 20ms is not acceptable. We choose 50ms as our default. -const uint32 kMinimumStepDelay = 50; +const uint32_t kMinimumStepDelay = 50; // CF = CANDIDATE FILTER enum { @@ -78,13 +78,13 @@ class PortAllocatorSession : public sigslot::has_slots<> { int component, const std::string& ice_ufrag, const std::string& ice_pwd, - uint32 flags); + uint32_t flags); // Subclasses should clean up any ports created. virtual ~PortAllocatorSession() {} - uint32 flags() const { return flags_; } - void set_flags(uint32 flags) { flags_ = flags; } + uint32_t flags() const { return flags_; } + void set_flags(uint32_t flags) { flags_ = flags; } std::string content_name() const { return content_name_; } int component() const { return component_; } @@ -101,8 +101,8 @@ class PortAllocatorSession : public sigslot::has_slots<> { const std::vector&> SignalCandidatesReady; sigslot::signal1 SignalCandidatesAllocationDone; - virtual uint32 generation() { return generation_; } - virtual void set_generation(uint32 generation) { generation_ = generation; } + virtual uint32_t generation() { return generation_; } + virtual void set_generation(uint32_t generation) { generation_ = generation; } sigslot::signal1 SignalDestroyed; const std::string& ice_ufrag() const { return ice_ufrag_; } @@ -118,8 +118,8 @@ class PortAllocatorSession : public sigslot::has_slots<> { int component_; private: - uint32 flags_; - uint32 generation_; + uint32_t flags_; + uint32_t generation_; std::string ice_ufrag_; std::string ice_pwd_; }; @@ -144,8 +144,8 @@ class PortAllocator : public sigslot::has_slots<> { const std::string& ice_ufrag, const std::string& ice_pwd); - uint32 flags() const { return flags_; } - void set_flags(uint32 flags) { flags_ = flags; } + uint32_t flags() const { return flags_; } + void set_flags(uint32_t flags) { flags_ = flags; } const std::string& user_agent() const { return agent_; } const rtc::ProxyInfo& proxy() const { return proxy_; } @@ -167,18 +167,16 @@ class PortAllocator : public sigslot::has_slots<> { return true; } - uint32 step_delay() const { return step_delay_; } - void set_step_delay(uint32 delay) { - step_delay_ = delay; - } + uint32_t step_delay() const { return step_delay_; } + void set_step_delay(uint32_t delay) { step_delay_ = delay; } bool allow_tcp_listen() const { return allow_tcp_listen_; } void set_allow_tcp_listen(bool allow_tcp_listen) { allow_tcp_listen_ = allow_tcp_listen; } - uint32 candidate_filter() { return candidate_filter_; } - bool set_candidate_filter(uint32 filter) { + uint32_t candidate_filter() { return candidate_filter_; } + bool set_candidate_filter(uint32_t filter) { // TODO(mallinath) - Do transition check? candidate_filter_ = filter; return true; @@ -195,14 +193,14 @@ class PortAllocator : public sigslot::has_slots<> { const std::string& ice_ufrag, const std::string& ice_pwd) = 0; - uint32 flags_; + uint32_t flags_; std::string agent_; rtc::ProxyInfo proxy_; int min_port_; int max_port_; - uint32 step_delay_; + uint32_t step_delay_; bool allow_tcp_listen_; - uint32 candidate_filter_; + uint32_t candidate_filter_; std::string origin_; }; diff --git a/webrtc/p2p/base/portinterface.h b/webrtc/p2p/base/portinterface.h index 3c246da58a..0c5948e8ae 100644 --- a/webrtc/p2p/base/portinterface.h +++ b/webrtc/p2p/base/portinterface.h @@ -47,8 +47,8 @@ class PortInterface { virtual void SetIceRole(IceRole role) = 0; virtual IceRole GetIceRole() const = 0; - virtual void SetIceTiebreaker(uint64 tiebreaker) = 0; - virtual uint64 IceTiebreaker() const = 0; + virtual void SetIceTiebreaker(uint64_t tiebreaker) = 0; + virtual uint64_t IceTiebreaker() const = 0; virtual bool SharedSocket() const = 0; diff --git a/webrtc/p2p/base/pseudotcp.cc b/webrtc/p2p/base/pseudotcp.cc index a54127bbb4..5f035ca652 100644 --- a/webrtc/p2p/base/pseudotcp.cc +++ b/webrtc/p2p/base/pseudotcp.cc @@ -39,40 +39,40 @@ namespace cricket { ////////////////////////////////////////////////////////////////////// // Standard MTUs -const uint16 PACKET_MAXIMUMS[] = { - 65535, // Theoretical maximum, Hyperchannel - 32000, // Nothing - 17914, // 16Mb IBM Token Ring - 8166, // IEEE 802.4 - //4464, // IEEE 802.5 (4Mb max) - 4352, // FDDI - //2048, // Wideband Network - 2002, // IEEE 802.5 (4Mb recommended) - //1536, // Expermental Ethernet Networks - //1500, // Ethernet, Point-to-Point (default) - 1492, // IEEE 802.3 - 1006, // SLIP, ARPANET - //576, // X.25 Networks - //544, // DEC IP Portal - //512, // NETBIOS - 508, // IEEE 802/Source-Rt Bridge, ARCNET - 296, // Point-to-Point (low delay) - //68, // Official minimum - 0, // End of list marker +const uint16_t PACKET_MAXIMUMS[] = { + 65535, // Theoretical maximum, Hyperchannel + 32000, // Nothing + 17914, // 16Mb IBM Token Ring + 8166, // IEEE 802.4 + // 4464, // IEEE 802.5 (4Mb max) + 4352, // FDDI + // 2048, // Wideband Network + 2002, // IEEE 802.5 (4Mb recommended) + // 1536, // Expermental Ethernet Networks + // 1500, // Ethernet, Point-to-Point (default) + 1492, // IEEE 802.3 + 1006, // SLIP, ARPANET + // 576, // X.25 Networks + // 544, // DEC IP Portal + // 512, // NETBIOS + 508, // IEEE 802/Source-Rt Bridge, ARCNET + 296, // Point-to-Point (low delay) + // 68, // Official minimum + 0, // End of list marker }; -const uint32 MAX_PACKET = 65535; +const uint32_t MAX_PACKET = 65535; // Note: we removed lowest level because packet overhead was larger! -const uint32 MIN_PACKET = 296; +const uint32_t MIN_PACKET = 296; -const uint32 IP_HEADER_SIZE = 20; // (+ up to 40 bytes of options?) -const uint32 UDP_HEADER_SIZE = 8; +const uint32_t IP_HEADER_SIZE = 20; // (+ up to 40 bytes of options?) +const uint32_t UDP_HEADER_SIZE = 8; // TODO: Make JINGLE_HEADER_SIZE transparent to this code? -const uint32 JINGLE_HEADER_SIZE = 64; // when relay framing is in use +const uint32_t JINGLE_HEADER_SIZE = 64; // when relay framing is in use // Default size for receive and send buffer. -const uint32 DEFAULT_RCV_BUF_SIZE = 60 * 1024; -const uint32 DEFAULT_SND_BUF_SIZE = 90 * 1024; +const uint32_t DEFAULT_RCV_BUF_SIZE = 60 * 1024; +const uint32_t DEFAULT_SND_BUF_SIZE = 90 * 1024; ////////////////////////////////////////////////////////////////////// // Global Constants and Functions @@ -102,55 +102,59 @@ const uint32 DEFAULT_SND_BUF_SIZE = 90 * 1024; #define PSEUDO_KEEPALIVE 0 -const uint32 HEADER_SIZE = 24; -const uint32 PACKET_OVERHEAD = HEADER_SIZE + UDP_HEADER_SIZE + IP_HEADER_SIZE + JINGLE_HEADER_SIZE; +const uint32_t HEADER_SIZE = 24; +const uint32_t PACKET_OVERHEAD = + HEADER_SIZE + UDP_HEADER_SIZE + IP_HEADER_SIZE + JINGLE_HEADER_SIZE; -const uint32 MIN_RTO = 250; // 250 ms (RFC1122, Sec 4.2.3.1 "fractions of a second") -const uint32 DEF_RTO = 3000; // 3 seconds (RFC1122, Sec 4.2.3.1) -const uint32 MAX_RTO = 60000; // 60 seconds -const uint32 DEF_ACK_DELAY = 100; // 100 milliseconds +const uint32_t MIN_RTO = + 250; // 250 ms (RFC1122, Sec 4.2.3.1 "fractions of a second") +const uint32_t DEF_RTO = 3000; // 3 seconds (RFC1122, Sec 4.2.3.1) +const uint32_t MAX_RTO = 60000; // 60 seconds +const uint32_t DEF_ACK_DELAY = 100; // 100 milliseconds -const uint8 FLAG_CTL = 0x02; -const uint8 FLAG_RST = 0x04; +const uint8_t FLAG_CTL = 0x02; +const uint8_t FLAG_RST = 0x04; -const uint8 CTL_CONNECT = 0; +const uint8_t CTL_CONNECT = 0; // TCP options. -const uint8 TCP_OPT_EOL = 0; // End of list. -const uint8 TCP_OPT_NOOP = 1; // No-op. -const uint8 TCP_OPT_MSS = 2; // Maximum segment size. -const uint8 TCP_OPT_WND_SCALE = 3; // Window scale factor. +const uint8_t TCP_OPT_EOL = 0; // End of list. +const uint8_t TCP_OPT_NOOP = 1; // No-op. +const uint8_t TCP_OPT_MSS = 2; // Maximum segment size. +const uint8_t TCP_OPT_WND_SCALE = 3; // Window scale factor. const long DEFAULT_TIMEOUT = 4000; // If there are no pending clocks, wake up every 4 seconds const long CLOSED_TIMEOUT = 60 * 1000; // If the connection is closed, once per minute #if PSEUDO_KEEPALIVE // !?! Rethink these times -const uint32 IDLE_PING = 20 * 1000; // 20 seconds (note: WinXP SP2 firewall udp timeout is 90 seconds) -const uint32 IDLE_TIMEOUT = 90 * 1000; // 90 seconds; +const uint32_t IDLE_PING = + 20 * + 1000; // 20 seconds (note: WinXP SP2 firewall udp timeout is 90 seconds) +const uint32_t IDLE_TIMEOUT = 90 * 1000; // 90 seconds; #endif // PSEUDO_KEEPALIVE ////////////////////////////////////////////////////////////////////// // Helper Functions ////////////////////////////////////////////////////////////////////// -inline void long_to_bytes(uint32 val, void* buf) { - *static_cast(buf) = rtc::HostToNetwork32(val); +inline void long_to_bytes(uint32_t val, void* buf) { + *static_cast(buf) = rtc::HostToNetwork32(val); } -inline void short_to_bytes(uint16 val, void* buf) { - *static_cast(buf) = rtc::HostToNetwork16(val); +inline void short_to_bytes(uint16_t val, void* buf) { + *static_cast(buf) = rtc::HostToNetwork16(val); } -inline uint32 bytes_to_long(const void* buf) { - return rtc::NetworkToHost32(*static_cast(buf)); +inline uint32_t bytes_to_long(const void* buf) { + return rtc::NetworkToHost32(*static_cast(buf)); } -inline uint16 bytes_to_short(const void* buf) { - return rtc::NetworkToHost16(*static_cast(buf)); +inline uint16_t bytes_to_short(const void* buf) { + return rtc::NetworkToHost16(*static_cast(buf)); } -uint32 bound(uint32 lower, uint32 middle, uint32 upper) { +uint32_t bound(uint32_t lower, uint32_t middle, uint32_t upper) { return std::min(std::max(lower, middle), upper); } @@ -196,7 +200,7 @@ void ReportStats() { // PseudoTcp ////////////////////////////////////////////////////////////////////// -uint32 PseudoTcp::Now() { +uint32_t PseudoTcp::Now() { #if 0 // Use this to synchronize timers with logging timestamps (easier debug) return rtc::TimeSince(StartTime()); #else @@ -204,7 +208,7 @@ uint32 PseudoTcp::Now() { #endif } -PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32 conv) +PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv) : m_notify(notify), m_shutdown(SD_NONE), m_error(0), @@ -212,11 +216,10 @@ PseudoTcp::PseudoTcp(IPseudoTcpNotify* notify, uint32 conv) m_rbuf(m_rbuf_len), m_sbuf_len(DEFAULT_SND_BUF_SIZE), m_sbuf(m_sbuf_len) { - // Sanity check on buffer sizes (needed for OnTcpWriteable notification logic) ASSERT(m_rbuf_len + MIN_PACKET < m_sbuf_len); - uint32 now = Now(); + uint32_t now = Now(); m_state = TCP_LISTEN; m_conv = conv; @@ -273,14 +276,14 @@ int PseudoTcp::Connect() { return 0; } -void PseudoTcp::NotifyMTU(uint16 mtu) { +void PseudoTcp::NotifyMTU(uint16_t mtu) { m_mtu_advise = mtu; if (m_state == TCP_ESTABLISHED) { adjustMTU(); } } -void PseudoTcp::NotifyClock(uint32 now) { +void PseudoTcp::NotifyClock(uint32_t now) { if (m_state == TCP_CLOSED) return; @@ -303,13 +306,13 @@ void PseudoTcp::NotifyClock(uint32 now) { return; } - uint32 nInFlight = m_snd_nxt - m_snd_una; + uint32_t nInFlight = m_snd_nxt - m_snd_una; m_ssthresh = std::max(nInFlight / 2, 2 * m_mss); //LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss; m_cwnd = m_mss; // Back off retransmit timer. Note: the limit is lower when connecting. - uint32 rto_limit = (m_state < TCP_ESTABLISHED) ? DEF_RTO : MAX_RTO; + uint32_t rto_limit = (m_state < TCP_ESTABLISHED) ? DEF_RTO : MAX_RTO; m_rx_rto = std::min(rto_limit, m_rx_rto * 2); m_rto_base = now; } @@ -355,10 +358,10 @@ bool PseudoTcp::NotifyPacket(const char* buffer, size_t len) { LOG_F(WARNING) << "packet too large"; return false; } - return parse(reinterpret_cast(buffer), uint32(len)); + return parse(reinterpret_cast(buffer), uint32_t(len)); } -bool PseudoTcp::GetNextClock(uint32 now, long& timeout) { +bool PseudoTcp::GetNextClock(uint32_t now, long& timeout) { return clock_check(now, timeout); } @@ -391,21 +394,21 @@ void PseudoTcp::SetOption(Option opt, int value) { } } -uint32 PseudoTcp::GetCongestionWindow() const { +uint32_t PseudoTcp::GetCongestionWindow() const { return m_cwnd; } -uint32 PseudoTcp::GetBytesInFlight() const { +uint32_t PseudoTcp::GetBytesInFlight() const { return m_snd_nxt - m_snd_una; } -uint32 PseudoTcp::GetBytesBufferedNotSent() const { +uint32_t PseudoTcp::GetBytesBufferedNotSent() const { size_t buffered_bytes = 0; m_sbuf.GetBuffered(&buffered_bytes); - return static_cast(m_snd_una + buffered_bytes - m_snd_nxt); + return static_cast(m_snd_una + buffered_bytes - m_snd_nxt); } -uint32 PseudoTcp::GetRoundTripTimeEstimateMs() const { +uint32_t PseudoTcp::GetRoundTripTimeEstimateMs() const { return m_rx_srtt; } @@ -433,11 +436,11 @@ int PseudoTcp::Recv(char* buffer, size_t len) { size_t available_space = 0; m_rbuf.GetWriteRemaining(&available_space); - if (uint32(available_space) - m_rcv_wnd >= - std::min(m_rbuf_len / 2, m_mss)) { + if (uint32_t(available_space) - m_rcv_wnd >= + std::min(m_rbuf_len / 2, m_mss)) { // TODO(jbeda): !?! Not sure about this was closed business bool bWasClosed = (m_rcv_wnd == 0); - m_rcv_wnd = static_cast(available_space); + m_rcv_wnd = static_cast(available_space); if (bWasClosed) { attemptSend(sfImmediateAck); @@ -462,7 +465,7 @@ int PseudoTcp::Send(const char* buffer, size_t len) { return SOCKET_ERROR; } - int written = queue(buffer, uint32(len), false); + int written = queue(buffer, uint32_t(len), false); attemptSend(); return written; } @@ -480,13 +483,13 @@ int PseudoTcp::GetError() { // Internal Implementation // -uint32 PseudoTcp::queue(const char* data, uint32 len, bool bCtrl) { +uint32_t PseudoTcp::queue(const char* data, uint32_t len, bool bCtrl) { size_t available_space = 0; m_sbuf.GetWriteRemaining(&available_space); - if (len > static_cast(available_space)) { + if (len > static_cast(available_space)) { ASSERT(!bCtrl); - len = static_cast(available_space); + len = static_cast(available_space); } // We can concatenate data if the last segment is the same type @@ -497,29 +500,31 @@ uint32 PseudoTcp::queue(const char* data, uint32 len, bool bCtrl) { } else { size_t snd_buffered = 0; m_sbuf.GetBuffered(&snd_buffered); - SSegment sseg(static_cast(m_snd_una + snd_buffered), len, bCtrl); + SSegment sseg(static_cast(m_snd_una + snd_buffered), len, bCtrl); m_slist.push_back(sseg); } size_t written = 0; m_sbuf.Write(data, len, &written, NULL); - return static_cast(written); + return static_cast(written); } -IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32 seq, uint8 flags, - uint32 offset, uint32 len) { +IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32_t seq, + uint8_t flags, + uint32_t offset, + uint32_t len) { ASSERT(HEADER_SIZE + len <= MAX_PACKET); - uint32 now = Now(); + uint32_t now = Now(); - rtc::scoped_ptr buffer(new uint8[MAX_PACKET]); + rtc::scoped_ptr buffer(new uint8_t[MAX_PACKET]); long_to_bytes(m_conv, buffer.get()); long_to_bytes(seq, buffer.get() + 4); long_to_bytes(m_rcv_nxt, buffer.get() + 8); buffer[12] = 0; buffer[13] = flags; - short_to_bytes( - static_cast(m_rcv_wnd >> m_rwnd_scale), buffer.get() + 14); + short_to_bytes(static_cast(m_rcv_wnd >> m_rwnd_scale), + buffer.get() + 14); // Timestamp computations long_to_bytes(now, buffer.get() + 16); @@ -532,7 +537,7 @@ IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32 seq, uint8 flags, buffer.get() + HEADER_SIZE, len, offset, &bytes_read); RTC_UNUSED(result); ASSERT(result == rtc::SR_SUCCESS); - ASSERT(static_cast(bytes_read) == len); + ASSERT(static_cast(bytes_read) == len); } #if _DEBUGMSG >= _DBG_VERBOSE @@ -564,7 +569,7 @@ IPseudoTcpNotify::WriteResult PseudoTcp::packet(uint32 seq, uint8 flags, return IPseudoTcpNotify::WR_SUCCESS; } -bool PseudoTcp::parse(const uint8* buffer, uint32 size) { +bool PseudoTcp::parse(const uint8_t* buffer, uint32_t size) { if (size < 12) return false; @@ -595,7 +600,7 @@ bool PseudoTcp::parse(const uint8* buffer, uint32 size) { return process(seg); } -bool PseudoTcp::clock_check(uint32 now, long& nTimeout) { +bool PseudoTcp::clock_check(uint32_t now, long& nTimeout) { if (m_shutdown == SD_FORCEFUL) return false; @@ -616,19 +621,19 @@ bool PseudoTcp::clock_check(uint32 now, long& nTimeout) { if (m_t_ack) { nTimeout = - std::min(nTimeout, rtc::TimeDiff(m_t_ack + m_ack_delay, now)); + std::min(nTimeout, rtc::TimeDiff(m_t_ack + m_ack_delay, now)); } if (m_rto_base) { nTimeout = - std::min(nTimeout, rtc::TimeDiff(m_rto_base + m_rx_rto, now)); + std::min(nTimeout, rtc::TimeDiff(m_rto_base + m_rx_rto, now)); } if (m_snd_wnd == 0) { nTimeout = - std::min(nTimeout, rtc::TimeDiff(m_lastsend + m_rx_rto, now)); + std::min(nTimeout, rtc::TimeDiff(m_lastsend + m_rx_rto, now)); } #if PSEUDO_KEEPALIVE if (m_state == TCP_ESTABLISHED) { - nTimeout = std::min( + nTimeout = std::min( nTimeout, rtc::TimeDiff(m_lasttraffic + (m_bOutgoing ? IDLE_PING * 3 / 2 : IDLE_PING), now)); @@ -647,7 +652,7 @@ bool PseudoTcp::process(Segment& seg) { return false; } - uint32 now = Now(); + uint32_t now = Now(); m_lasttraffic = m_lastrecv = now; m_bOutgoing = false; @@ -704,20 +709,22 @@ bool PseudoTcp::process(Segment& seg) { if ((seg.ack > m_snd_una) && (seg.ack <= m_snd_nxt)) { // Calculate round-trip time if (seg.tsecr) { - int32 rtt = rtc::TimeDiff(now, seg.tsecr); + int32_t rtt = rtc::TimeDiff(now, seg.tsecr); if (rtt >= 0) { if (m_rx_srtt == 0) { m_rx_srtt = rtt; m_rx_rttvar = rtt / 2; } else { - uint32 unsigned_rtt = static_cast(rtt); - uint32 abs_err = unsigned_rtt > m_rx_srtt ? unsigned_rtt - m_rx_srtt - : m_rx_srtt - unsigned_rtt; + uint32_t unsigned_rtt = static_cast(rtt); + uint32_t abs_err = unsigned_rtt > m_rx_srtt + ? unsigned_rtt - m_rx_srtt + : m_rx_srtt - unsigned_rtt; m_rx_rttvar = (3 * m_rx_rttvar + abs_err) / 4; m_rx_srtt = (7 * m_rx_srtt + rtt) / 8; } - m_rx_rto = bound( - MIN_RTO, m_rx_srtt + std::max(1, 4 * m_rx_rttvar), MAX_RTO); + m_rx_rto = + bound(MIN_RTO, m_rx_srtt + std::max(1, 4 * m_rx_rttvar), + MAX_RTO); #if _DEBUGMSG >= _DBG_VERBOSE LOG(LS_INFO) << "rtt: " << rtt << " srtt: " << m_rx_srtt @@ -728,16 +735,16 @@ bool PseudoTcp::process(Segment& seg) { } } - m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; + m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; - uint32 nAcked = seg.ack - m_snd_una; + uint32_t nAcked = seg.ack - m_snd_una; m_snd_una = seg.ack; m_rto_base = (m_snd_una == m_snd_nxt) ? 0 : now; m_sbuf.ConsumeReadData(nAcked); - for (uint32 nFree = nAcked; nFree > 0; ) { + for (uint32_t nFree = nAcked; nFree > 0;) { ASSERT(!m_slist.empty()); if (nFree < m_slist.front().len) { m_slist.front().len -= nFree; @@ -753,7 +760,7 @@ bool PseudoTcp::process(Segment& seg) { if (m_dup_acks >= 3) { if (m_snd_una >= m_recover) { // NewReno - uint32 nInFlight = m_snd_nxt - m_snd_una; + uint32_t nInFlight = m_snd_nxt - m_snd_una; m_cwnd = std::min(m_ssthresh, nInFlight + m_mss); // (Fast Retransmit) #if _DEBUGMSG >= _DBG_NORMAL LOG(LS_INFO) << "exit recovery"; @@ -775,12 +782,12 @@ bool PseudoTcp::process(Segment& seg) { if (m_cwnd < m_ssthresh) { m_cwnd += m_mss; } else { - m_cwnd += std::max(1, m_mss * m_mss / m_cwnd); + m_cwnd += std::max(1, m_mss * m_mss / m_cwnd); } } } else if (seg.ack == m_snd_una) { // !?! Note, tcp says don't do this... but otherwise how does a closed window become open? - m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; + m_snd_wnd = static_cast(seg.wnd) << m_swnd_scale; // Check duplicate acks if (seg.len > 0) { @@ -797,7 +804,7 @@ bool PseudoTcp::process(Segment& seg) { return false; } m_recover = m_snd_nxt; - uint32 nInFlight = m_snd_nxt - m_snd_una; + uint32_t nInFlight = m_snd_nxt - m_snd_una; m_ssthresh = std::max(nInFlight / 2, 2 * m_mss); //LOG(LS_INFO) << "m_ssthresh: " << m_ssthresh << " nInFlight: " << nInFlight << " m_mss: " << m_mss; m_cwnd = m_ssthresh + 3 * m_mss; @@ -823,10 +830,11 @@ bool PseudoTcp::process(Segment& seg) { // If we make room in the send queue, notify the user // The goal it to make sure we always have at least enough data to fill the // window. We'd like to notify the app when we are halfway to that point. - const uint32 kIdealRefillSize = (m_sbuf_len + m_rbuf_len) / 2; + const uint32_t kIdealRefillSize = (m_sbuf_len + m_rbuf_len) / 2; size_t snd_buffered = 0; m_sbuf.GetBuffered(&snd_buffered); - if (m_bWriteEnable && static_cast(snd_buffered) < kIdealRefillSize) { + if (m_bWriteEnable && + static_cast(snd_buffered) < kIdealRefillSize) { m_bWriteEnable = false; if (m_notify) { m_notify->OnTcpWriteable(this); @@ -862,7 +870,7 @@ bool PseudoTcp::process(Segment& seg) { // Adjust the incoming segment to fit our receive buffer if (seg.seq < m_rcv_nxt) { - uint32 nAdjust = m_rcv_nxt - seg.seq; + uint32_t nAdjust = m_rcv_nxt - seg.seq; if (nAdjust < seg.len) { seg.seq += nAdjust; seg.data += nAdjust; @@ -875,8 +883,10 @@ bool PseudoTcp::process(Segment& seg) { size_t available_space = 0; m_rbuf.GetWriteRemaining(&available_space); - if ((seg.seq + seg.len - m_rcv_nxt) > static_cast(available_space)) { - uint32 nAdjust = seg.seq + seg.len - m_rcv_nxt - static_cast(available_space); + if ((seg.seq + seg.len - m_rcv_nxt) > + static_cast(available_space)) { + uint32_t nAdjust = + seg.seq + seg.len - m_rcv_nxt - static_cast(available_space); if (nAdjust < seg.len) { seg.len -= nAdjust; } else { @@ -893,7 +903,7 @@ bool PseudoTcp::process(Segment& seg) { m_rcv_nxt += seg.len; } } else { - uint32 nOffset = seg.seq - m_rcv_nxt; + uint32_t nOffset = seg.seq - m_rcv_nxt; rtc::StreamResult result = m_rbuf.WriteOffset(seg.data, seg.len, nOffset, NULL); @@ -910,7 +920,7 @@ bool PseudoTcp::process(Segment& seg) { while ((it != m_rlist.end()) && (it->seq <= m_rcv_nxt)) { if (it->seq + it->len > m_rcv_nxt) { sflags = sfImmediateAck; // (Fast Recovery) - uint32 nAdjust = (it->seq + it->len) - m_rcv_nxt; + uint32_t nAdjust = (it->seq + it->len) - m_rcv_nxt; #if _DEBUGMSG >= _DBG_NORMAL LOG(LS_INFO) << "Recovered " << nAdjust << " bytes (" << m_rcv_nxt << " -> " << m_rcv_nxt + nAdjust << ")"; #endif // _DEBUGMSG @@ -950,17 +960,17 @@ bool PseudoTcp::process(Segment& seg) { return true; } -bool PseudoTcp::transmit(const SList::iterator& seg, uint32 now) { +bool PseudoTcp::transmit(const SList::iterator& seg, uint32_t now) { if (seg->xmit >= ((m_state == TCP_ESTABLISHED) ? 15 : 30)) { LOG_F(LS_VERBOSE) << "too many retransmits"; return false; } - uint32 nTransmit = std::min(seg->len, m_mss); + uint32_t nTransmit = std::min(seg->len, m_mss); while (true) { - uint32 seq = seg->seq; - uint8 flags = (seg->bCtrl ? FLAG_CTL : 0); + uint32_t seq = seg->seq; + uint8_t flags = (seg->bCtrl ? FLAG_CTL : 0); IPseudoTcpNotify::WriteResult wres = packet(seq, flags, seg->seq - m_snd_una, @@ -1020,7 +1030,7 @@ bool PseudoTcp::transmit(const SList::iterator& seg, uint32 now) { } void PseudoTcp::attemptSend(SendFlags sflags) { - uint32 now = Now(); + uint32_t now = Now(); if (rtc::TimeDiff(now, m_lastsend) > static_cast(m_rx_rto)) { m_cwnd = m_mss; @@ -1032,18 +1042,18 @@ void PseudoTcp::attemptSend(SendFlags sflags) { #endif // _DEBUGMSG while (true) { - uint32 cwnd = m_cwnd; + uint32_t cwnd = m_cwnd; if ((m_dup_acks == 1) || (m_dup_acks == 2)) { // Limited Transmit cwnd += m_dup_acks * m_mss; } - uint32 nWindow = std::min(m_snd_wnd, cwnd); - uint32 nInFlight = m_snd_nxt - m_snd_una; - uint32 nUseable = (nInFlight < nWindow) ? (nWindow - nInFlight) : 0; + uint32_t nWindow = std::min(m_snd_wnd, cwnd); + uint32_t nInFlight = m_snd_nxt - m_snd_una; + uint32_t nUseable = (nInFlight < nWindow) ? (nWindow - nInFlight) : 0; size_t snd_buffered = 0; m_sbuf.GetBuffered(&snd_buffered); - uint32 nAvailable = - std::min(static_cast(snd_buffered) - nInFlight, m_mss); + uint32_t nAvailable = + std::min(static_cast(snd_buffered) - nInFlight, m_mss); if (nAvailable > nUseable) { if (nUseable * 4 < nWindow) { @@ -1116,8 +1126,7 @@ void PseudoTcp::attemptSend(SendFlags sflags) { } } -void -PseudoTcp::closedown(uint32 err) { +void PseudoTcp::closedown(uint32_t err) { LOG(LS_INFO) << "State: TCP_CLOSED"; m_state = TCP_CLOSED; if (m_notify) { @@ -1130,7 +1139,7 @@ void PseudoTcp::adjustMTU() { // Determine our current mss level, so that we can adjust appropriately later for (m_msslevel = 0; PACKET_MAXIMUMS[m_msslevel + 1] > 0; ++m_msslevel) { - if (static_cast(PACKET_MAXIMUMS[m_msslevel]) <= m_mtu_advise) { + if (static_cast(PACKET_MAXIMUMS[m_msslevel]) <= m_mtu_advise) { break; } } @@ -1166,19 +1175,18 @@ PseudoTcp::queueConnectMessage() { buf.WriteUInt8(1); buf.WriteUInt8(m_rwnd_scale); } - m_snd_wnd = static_cast(buf.Length()); - queue(buf.Data(), static_cast(buf.Length()), true); + m_snd_wnd = static_cast(buf.Length()); + queue(buf.Data(), static_cast(buf.Length()), true); } -void -PseudoTcp::parseOptions(const char* data, uint32 len) { - std::set options_specified; +void PseudoTcp::parseOptions(const char* data, uint32_t len) { + std::set options_specified; // See http://www.freesoft.org/CIE/Course/Section4/8.htm for // parsing the options list. rtc::ByteBuffer buf(data, len); while (buf.Length()) { - uint8 kind = TCP_OPT_EOL; + uint8_t kind = TCP_OPT_EOL; buf.ReadUInt8(&kind); if (kind == TCP_OPT_EOL) { @@ -1192,7 +1200,7 @@ PseudoTcp::parseOptions(const char* data, uint32 len) { // Length of this option. ASSERT(len != 0); RTC_UNUSED(len); - uint8 opt_len = 0; + uint8_t opt_len = 0; buf.ReadUInt8(&opt_len); // Content of this option. @@ -1218,8 +1226,7 @@ PseudoTcp::parseOptions(const char* data, uint32 len) { } } -void -PseudoTcp::applyOption(char kind, const char* data, uint32 len) { +void PseudoTcp::applyOption(char kind, const char* data, uint32_t len) { if (kind == TCP_OPT_MSS) { LOG(LS_WARNING) << "Peer specified MSS option which is not supported."; // TODO: Implement. @@ -1234,20 +1241,17 @@ PseudoTcp::applyOption(char kind, const char* data, uint32 len) { } } -void -PseudoTcp::applyWindowScaleOption(uint8 scale_factor) { +void PseudoTcp::applyWindowScaleOption(uint8_t scale_factor) { m_swnd_scale = scale_factor; } -void -PseudoTcp::resizeSendBuffer(uint32 new_size) { +void PseudoTcp::resizeSendBuffer(uint32_t new_size) { m_sbuf_len = new_size; m_sbuf.SetCapacity(new_size); } -void -PseudoTcp::resizeReceiveBuffer(uint32 new_size) { - uint8 scale_factor = 0; +void PseudoTcp::resizeReceiveBuffer(uint32_t new_size) { + uint8_t scale_factor = 0; // Determine the scale factor such that the scaled window size can fit // in a 16-bit unsigned integer. @@ -1272,7 +1276,7 @@ PseudoTcp::resizeReceiveBuffer(uint32 new_size) { size_t available_space = 0; m_rbuf.GetWriteRemaining(&available_space); - m_rcv_wnd = static_cast(available_space); + m_rcv_wnd = static_cast(available_space); } } // namespace cricket diff --git a/webrtc/p2p/base/pseudotcp.h b/webrtc/p2p/base/pseudotcp.h index b2cfcb79ef..6d402daa6f 100644 --- a/webrtc/p2p/base/pseudotcp.h +++ b/webrtc/p2p/base/pseudotcp.h @@ -30,7 +30,7 @@ class IPseudoTcpNotify { virtual void OnTcpOpen(PseudoTcp* tcp) = 0; virtual void OnTcpReadable(PseudoTcp* tcp) = 0; virtual void OnTcpWriteable(PseudoTcp* tcp) = 0; - virtual void OnTcpClosed(PseudoTcp* tcp, uint32 error) = 0; + virtual void OnTcpClosed(PseudoTcp* tcp, uint32_t error) = 0; // Write the packet onto the network enum WriteResult { WR_SUCCESS, WR_TOO_LARGE, WR_FAIL }; @@ -47,9 +47,9 @@ class IPseudoTcpNotify { class PseudoTcp { public: - static uint32 Now(); + static uint32_t Now(); - PseudoTcp(IPseudoTcpNotify* notify, uint32 conv); + PseudoTcp(IPseudoTcpNotify* notify, uint32_t conv); virtual ~PseudoTcp(); int Connect(); @@ -64,11 +64,11 @@ class PseudoTcp { TcpState State() const { return m_state; } // Call this when the PMTU changes. - void NotifyMTU(uint16 mtu); + void NotifyMTU(uint16_t mtu); // Call this based on timeout value returned from GetNextClock. // It's ok to call this too frequently. - void NotifyClock(uint32 now); + void NotifyClock(uint32_t now); // Call this whenever a packet arrives. // Returns true if the packet was processed successfully. @@ -76,7 +76,7 @@ class PseudoTcp { // Call this to determine the next time NotifyClock should be called. // Returns false if the socket is ready to be destroyed. - bool GetNextClock(uint32 now, long& timeout); + bool GetNextClock(uint32_t now, long& timeout); // Call these to get/set option values to tailor this PseudoTcp // instance's behaviour for the kind of data it will carry. @@ -94,47 +94,46 @@ class PseudoTcp { void SetOption(Option opt, int value); // Returns current congestion window in bytes. - uint32 GetCongestionWindow() const; + uint32_t GetCongestionWindow() const; // Returns amount of data in bytes that has been sent, but haven't // been acknowledged. - uint32 GetBytesInFlight() const; + uint32_t GetBytesInFlight() const; // Returns number of bytes that were written in buffer and haven't // been sent. - uint32 GetBytesBufferedNotSent() const; + uint32_t GetBytesBufferedNotSent() const; // Returns current round-trip time estimate in milliseconds. - uint32 GetRoundTripTimeEstimateMs() const; + uint32_t GetRoundTripTimeEstimateMs() const; protected: enum SendFlags { sfNone, sfDelayedAck, sfImmediateAck }; struct Segment { - uint32 conv, seq, ack; - uint8 flags; - uint16 wnd; + uint32_t conv, seq, ack; + uint8_t flags; + uint16_t wnd; const char * data; - uint32 len; - uint32 tsval, tsecr; + uint32_t len; + uint32_t tsval, tsecr; }; struct SSegment { - SSegment(uint32 s, uint32 l, bool c) - : seq(s), len(l), /*tstamp(0),*/ xmit(0), bCtrl(c) { - } - uint32 seq, len; - //uint32 tstamp; - uint8 xmit; + SSegment(uint32_t s, uint32_t l, bool c) + : seq(s), len(l), /*tstamp(0),*/ xmit(0), bCtrl(c) {} + uint32_t seq, len; + // uint32_t tstamp; + uint8_t xmit; bool bCtrl; }; typedef std::list SList; struct RSegment { - uint32 seq, len; + uint32_t seq, len; }; - uint32 queue(const char* data, uint32 len, bool bCtrl); + uint32_t queue(const char* data, uint32_t len, bool bCtrl); // Creates a packet and submits it to the network. This method can either // send payload or just an ACK packet. @@ -144,18 +143,20 @@ class PseudoTcp { // |offset| is the offset to read from |m_sbuf|. // |len| is the number of bytes to read from |m_sbuf| as payload. If this // value is 0 then this is an ACK packet, otherwise this packet has payload. - IPseudoTcpNotify::WriteResult packet(uint32 seq, uint8 flags, - uint32 offset, uint32 len); - bool parse(const uint8* buffer, uint32 size); + IPseudoTcpNotify::WriteResult packet(uint32_t seq, + uint8_t flags, + uint32_t offset, + uint32_t len); + bool parse(const uint8_t* buffer, uint32_t size); void attemptSend(SendFlags sflags = sfNone); - void closedown(uint32 err = 0); + void closedown(uint32_t err = 0); - bool clock_check(uint32 now, long& nTimeout); + bool clock_check(uint32_t now, long& nTimeout); bool process(Segment& seg); - bool transmit(const SList::iterator& seg, uint32 now); + bool transmit(const SList::iterator& seg, uint32_t now); void adjustMTU(); @@ -172,20 +173,20 @@ class PseudoTcp { void queueConnectMessage(); // Parse TCP options in the header. - void parseOptions(const char* data, uint32 len); + void parseOptions(const char* data, uint32_t len); // Apply a TCP option that has been read from the header. - void applyOption(char kind, const char* data, uint32 len); + void applyOption(char kind, const char* data, uint32_t len); // Apply window scale option. - void applyWindowScaleOption(uint8 scale_factor); + void applyWindowScaleOption(uint8_t scale_factor); // Resize the send buffer with |new_size| in bytes. - void resizeSendBuffer(uint32 new_size); + void resizeSendBuffer(uint32_t new_size); // Resize the receive buffer with |new_size| in bytes. This call adjusts // window scale factor |m_swnd_scale| accordingly. - void resizeReceiveBuffer(uint32 new_size); + void resizeReceiveBuffer(uint32_t new_size); IPseudoTcpNotify* m_notify; enum Shutdown { SD_NONE, SD_GRACEFUL, SD_FORCEFUL } m_shutdown; @@ -193,43 +194,43 @@ class PseudoTcp { // TCB data TcpState m_state; - uint32 m_conv; + uint32_t m_conv; bool m_bReadEnable, m_bWriteEnable, m_bOutgoing; - uint32 m_lasttraffic; + uint32_t m_lasttraffic; // Incoming data typedef std::list RList; RList m_rlist; - uint32 m_rbuf_len, m_rcv_nxt, m_rcv_wnd, m_lastrecv; - uint8 m_rwnd_scale; // Window scale factor. + uint32_t m_rbuf_len, m_rcv_nxt, m_rcv_wnd, m_lastrecv; + uint8_t m_rwnd_scale; // Window scale factor. rtc::FifoBuffer m_rbuf; // Outgoing data SList m_slist; - uint32 m_sbuf_len, m_snd_nxt, m_snd_wnd, m_lastsend, m_snd_una; - uint8 m_swnd_scale; // Window scale factor. + uint32_t m_sbuf_len, m_snd_nxt, m_snd_wnd, m_lastsend, m_snd_una; + uint8_t m_swnd_scale; // Window scale factor. rtc::FifoBuffer m_sbuf; // Maximum segment size, estimated protocol level, largest segment sent - uint32 m_mss, m_msslevel, m_largest, m_mtu_advise; + uint32_t m_mss, m_msslevel, m_largest, m_mtu_advise; // Retransmit timer - uint32 m_rto_base; + uint32_t m_rto_base; // Timestamp tracking - uint32 m_ts_recent, m_ts_lastack; + uint32_t m_ts_recent, m_ts_lastack; // Round-trip calculation - uint32 m_rx_rttvar, m_rx_srtt, m_rx_rto; + uint32_t m_rx_rttvar, m_rx_srtt, m_rx_rto; // Congestion avoidance, Fast retransmit/recovery, Delayed ACKs - uint32 m_ssthresh, m_cwnd; - uint8 m_dup_acks; - uint32 m_recover; - uint32 m_t_ack; + uint32_t m_ssthresh, m_cwnd; + uint8_t m_dup_acks; + uint32_t m_recover; + uint32_t m_t_ack; // Configuration options bool m_use_nagling; - uint32 m_ack_delay; + uint32_t m_ack_delay; // This is used by unit tests to test backward compatibility of // PseudoTcp implementations that don't support window scaling. diff --git a/webrtc/p2p/base/pseudotcp_unittest.cc b/webrtc/p2p/base/pseudotcp_unittest.cc index 03e72932a0..c9ccbca1d9 100644 --- a/webrtc/p2p/base/pseudotcp_unittest.cc +++ b/webrtc/p2p/base/pseudotcp_unittest.cc @@ -27,9 +27,8 @@ static const int kBlockSize = 4096; class PseudoTcpForTest : public cricket::PseudoTcp { public: - PseudoTcpForTest(cricket::IPseudoTcpNotify* notify, uint32 conv) - : PseudoTcp(notify, conv) { - } + PseudoTcpForTest(cricket::IPseudoTcpNotify* notify, uint32_t conv) + : PseudoTcp(notify, conv) {} bool isReceiveBufferFull() const { return PseudoTcp::isReceiveBufferFull(); @@ -127,7 +126,7 @@ class PseudoTcpTestBase : public testing::Test, // virtual void OnTcpReadable(PseudoTcp* tcp) // and // virtual void OnTcpWritable(PseudoTcp* tcp) - virtual void OnTcpClosed(PseudoTcp* tcp, uint32 error) { + virtual void OnTcpClosed(PseudoTcp* tcp, uint32_t error) { // Consider ourselves closed when the remote side gets OnTcpClosed. // TODO: OnTcpClosed is only ever notified in case of error in // the current implementation. Solicited close is not (yet) supported. @@ -141,7 +140,7 @@ class PseudoTcpTestBase : public testing::Test, const char* buffer, size_t len) { // Randomly drop the desired percentage of packets. // Also drop packets that are larger than the configured MTU. - if (rtc::CreateRandomId() % 100 < static_cast(loss_)) { + if (rtc::CreateRandomId() % 100 < static_cast(loss_)) { LOG(LS_VERBOSE) << "Randomly dropping packet, size=" << len; } else if (len > static_cast(std::min(local_mtu_, remote_mtu_))) { LOG(LS_VERBOSE) << "Dropping packet that exceeds path MTU, size=" << len; @@ -156,7 +155,7 @@ class PseudoTcpTestBase : public testing::Test, void UpdateLocalClock() { UpdateClock(&local_, MSG_LCLOCK); } void UpdateRemoteClock() { UpdateClock(&remote_, MSG_RCLOCK); } - void UpdateClock(PseudoTcp* tcp, uint32 message) { + void UpdateClock(PseudoTcp* tcp, uint32_t message) { long interval = 0; // NOLINT tcp->GetNextClock(PseudoTcp::Now(), interval); interval = std::max(interval, 0L); // sometimes interval is < 0 @@ -209,7 +208,7 @@ class PseudoTcpTestBase : public testing::Test, class PseudoTcpTest : public PseudoTcpTestBase { public: void TestTransfer(int size) { - uint32 start, elapsed; + uint32_t start, elapsed; size_t received; // Create some dummy data to send. send_stream_.ReserveSize(size); @@ -326,7 +325,7 @@ class PseudoTcpTestPingPong : public PseudoTcpTestBase { bytes_per_send_ = bytes; } void TestPingPong(int size, int iterations) { - uint32 start, elapsed; + uint32_t start, elapsed; iterations_remaining_ = iterations; receiver_ = &remote_; sender_ = &local_; @@ -489,12 +488,12 @@ class PseudoTcpTestReceiveWindow : public PseudoTcpTestBase { } } - uint32 EstimateReceiveWindowSize() const { - return static_cast(recv_position_[0]); + uint32_t EstimateReceiveWindowSize() const { + return static_cast(recv_position_[0]); } - uint32 EstimateSendWindowSize() const { - return static_cast(send_position_[0] - recv_position_[0]); + uint32_t EstimateSendWindowSize() const { + return static_cast(send_position_[0] - recv_position_[0]); } private: diff --git a/webrtc/p2p/base/relayport.cc b/webrtc/p2p/base/relayport.cc index fc077ff1e1..ccddab0e98 100644 --- a/webrtc/p2p/base/relayport.cc +++ b/webrtc/p2p/base/relayport.cc @@ -16,7 +16,7 @@ namespace cricket { -static const uint32 kMessageConnectTimeout = 1; +static const uint32_t kMessageConnectTimeout = 1; static const int kKeepAliveDelay = 10 * 60 * 1000; static const int kRetryTimeout = 50 * 1000; // ICE says 50 secs // How long to wait for a socket to connect to remote host in milliseconds @@ -171,19 +171,26 @@ class AllocateRequest : public StunRequest { private: RelayEntry* entry_; RelayConnection* connection_; - uint32 start_time_; + uint32_t start_time_; }; RelayPort::RelayPort(rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password) - : Port(thread, RELAY_PORT_TYPE, factory, network, ip, min_port, max_port, - username, password), + : Port(thread, + RELAY_PORT_TYPE, + factory, + network, + ip, + min_port, + max_port, + username, + password), ready_(false), error_(0) { entries_.push_back( diff --git a/webrtc/p2p/base/relayport.h b/webrtc/p2p/base/relayport.h index 629714267d..8452b5b430 100644 --- a/webrtc/p2p/base/relayport.h +++ b/webrtc/p2p/base/relayport.h @@ -35,15 +35,14 @@ class RelayPort : public Port { typedef std::pair OptionValue; // RelayPort doesn't yet do anything fancy in the ctor. - static RelayPort* Create( - rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, - const std::string& username, - const std::string& password) { + static RelayPort* Create(rtc::Thread* thread, + rtc::PacketSocketFactory* factory, + rtc::Network* network, + const rtc::IPAddress& ip, + uint16_t min_port, + uint16_t max_port, + const std::string& username, + const std::string& password) { return new RelayPort(thread, factory, network, ip, min_port, max_port, username, password); } @@ -74,8 +73,8 @@ class RelayPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network*, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password); bool Init(); diff --git a/webrtc/p2p/base/relayserver.cc b/webrtc/p2p/base/relayserver.cc index 19e9268277..e208d70d0f 100644 --- a/webrtc/p2p/base/relayserver.cc +++ b/webrtc/p2p/base/relayserver.cc @@ -27,7 +27,7 @@ namespace cricket { const int MAX_LIFETIME = 15 * 60 * 1000; // The number of bytes in each of the usernames we use. -const uint32 USERNAME_LENGTH = 16; +const uint32_t USERNAME_LENGTH = 16; // Calls SendTo on the given socket and logs any bad results. void Send(rtc::AsyncPacketSocket* socket, const char* bytes, size_t size, @@ -263,8 +263,8 @@ void RelayServer::OnExternalPacket( return; } - uint32 length = - std::min(static_cast(username_attr->length()), USERNAME_LENGTH); + uint32_t length = + std::min(static_cast(username_attr->length()), USERNAME_LENGTH); std::string username(username_attr->bytes(), length); // TODO: Check the HMAC. @@ -355,7 +355,7 @@ void RelayServer::HandleStunAllocate( // else-branch will then disappear. // Compute the appropriate lifetime for this binding. - uint32 lifetime = MAX_LIFETIME; + uint32_t lifetime = MAX_LIFETIME; const StunUInt32Attribute* lifetime_attr = request.GetUInt32(STUN_ATTR_LIFETIME); if (lifetime_attr) @@ -530,7 +530,7 @@ void RelayServer::RemoveBinding(RelayServerBinding* binding) { void RelayServer::OnMessage(rtc::Message *pmsg) { #if ENABLE_DEBUG - static const uint32 kMessageAcceptConnection = 1; + static const uint32_t kMessageAcceptConnection = 1; ASSERT(pmsg->message_id == kMessageAcceptConnection); #endif rtc::MessageData* data = pmsg->pdata; @@ -616,7 +616,7 @@ void RelayServerConnection::Send( StunByteStringAttribute* data_attr = StunAttribute::CreateByteString(STUN_ATTR_DATA); ASSERT(size <= 65536); - data_attr->CopyBytes(data, uint16(size)); + data_attr->CopyBytes(data, uint16_t(size)); msg.AddAttribute(data_attr); SendStun(msg); @@ -648,13 +648,16 @@ void RelayServerConnection::Unlock() { } // IDs used for posted messages: -const uint32 MSG_LIFETIME_TIMER = 1; +const uint32_t MSG_LIFETIME_TIMER = 1; -RelayServerBinding::RelayServerBinding( - RelayServer* server, const std::string& username, - const std::string& password, uint32 lifetime) - : server_(server), username_(username), password_(password), - lifetime_(lifetime) { +RelayServerBinding::RelayServerBinding(RelayServer* server, + const std::string& username, + const std::string& password, + uint32_t lifetime) + : server_(server), + username_(username), + password_(password), + lifetime_(lifetime) { // For now, every connection uses the standard magic cookie value. magic_cookie_.append( reinterpret_cast(TURN_MAGIC_COOKIE_VALUE), diff --git a/webrtc/p2p/base/relayserver.h b/webrtc/p2p/base/relayserver.h index e0e45d5254..f1109f1ce4 100644 --- a/webrtc/p2p/base/relayserver.h +++ b/webrtc/p2p/base/relayserver.h @@ -181,13 +181,14 @@ class RelayServerConnection { // or in other words, that are "bound" together. class RelayServerBinding : public rtc::MessageHandler { public: - RelayServerBinding( - RelayServer* server, const std::string& username, - const std::string& password, uint32 lifetime); + RelayServerBinding(RelayServer* server, + const std::string& username, + const std::string& password, + uint32_t lifetime); virtual ~RelayServerBinding(); RelayServer* server() { return server_; } - uint32 lifetime() { return lifetime_; } + uint32_t lifetime() { return lifetime_; } const std::string& username() { return username_; } const std::string& password() { return password_; } const std::string& magic_cookie() { return magic_cookie_; } @@ -225,8 +226,8 @@ class RelayServerBinding : public rtc::MessageHandler { std::vector internal_connections_; std::vector external_connections_; - uint32 lifetime_; - uint32 last_used_; + uint32_t lifetime_; + uint32_t last_used_; // TODO: bandwidth }; diff --git a/webrtc/p2p/base/relayserver_unittest.cc b/webrtc/p2p/base/relayserver_unittest.cc index 4f1164acc6..83e5353fc9 100644 --- a/webrtc/p2p/base/relayserver_unittest.cc +++ b/webrtc/p2p/base/relayserver_unittest.cc @@ -24,7 +24,7 @@ using rtc::SocketAddress; using namespace cricket; -static const uint32 LIFETIME = 4; // seconds +static const uint32_t LIFETIME = 4; // seconds static const SocketAddress server_int_addr("127.0.0.1", 5000); static const SocketAddress server_ext_addr("127.0.0.1", 5001); static const SocketAddress client1_addr("127.0.0.1", 6000 + (rand() % 1000)); diff --git a/webrtc/p2p/base/stun.cc b/webrtc/p2p/base/stun.cc index 866621f75d..9c22995755 100644 --- a/webrtc/p2p/base/stun.cc +++ b/webrtc/p2p/base/stun.cc @@ -38,7 +38,7 @@ const char STUN_ERROR_REASON_SERVER_ERROR[] = "Server Error"; const char TURN_MAGIC_COOKIE_VALUE[] = { '\x72', '\xC6', '\x4B', '\xC6' }; const char EMPTY_TRANSACTION_ID[] = "0000000000000000"; -const uint32 STUN_FINGERPRINT_XOR_VALUE = 0x5354554E; +const uint32_t STUN_FINGERPRINT_XOR_VALUE = 0x5354554E; // StunMessage @@ -82,7 +82,7 @@ bool StunMessage::AddAttribute(StunAttribute* attr) { if (attr_length % 4 != 0) { attr_length += (4 - (attr_length % 4)); } - length_ += static_cast(attr_length + 4); + length_ += static_cast(attr_length + 4); return true; } @@ -135,7 +135,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, } // Getting the message length from the STUN header. - uint16 msg_length = rtc::GetBE16(&data[2]); + uint16_t msg_length = rtc::GetBE16(&data[2]); if (size != (msg_length + kStunHeaderSize)) { return false; } @@ -144,7 +144,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, size_t current_pos = kStunHeaderSize; bool has_message_integrity_attr = false; while (current_pos < size) { - uint16 attr_type, attr_length; + uint16_t attr_type, attr_length; // Getting attribute type and length. attr_type = rtc::GetBE16(&data[current_pos]); attr_length = rtc::GetBE16(&data[current_pos + sizeof(attr_type)]); @@ -187,8 +187,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // |0 0| STUN Message Type | Message Length | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - rtc::SetBE16(temp_data.get() + 2, - static_cast(new_adjusted_len)); + rtc::SetBE16(temp_data.get() + 2, static_cast(new_adjusted_len)); } char hmac[kStunMessageIntegritySize]; @@ -262,12 +261,12 @@ bool StunMessage::ValidateFingerprint(const char* data, size_t size) { // Check the fingerprint type and length. const char* fingerprint_attr_data = data + size - fingerprint_attr_size; if (rtc::GetBE16(fingerprint_attr_data) != STUN_ATTR_FINGERPRINT || - rtc::GetBE16(fingerprint_attr_data + sizeof(uint16)) != + rtc::GetBE16(fingerprint_attr_data + sizeof(uint16_t)) != StunUInt32Attribute::SIZE) return false; // Check the fingerprint value. - uint32 fingerprint = + uint32_t fingerprint = rtc::GetBE32(fingerprint_attr_data + kStunAttributeHeaderSize); return ((fingerprint ^ STUN_FINGERPRINT_XOR_VALUE) == rtc::ComputeCrc32(data, size - fingerprint_attr_size)); @@ -287,7 +286,7 @@ bool StunMessage::AddFingerprint() { int msg_len_for_crc32 = static_cast( buf.Length() - kStunAttributeHeaderSize - fingerprint_attr->length()); - uint32 c = rtc::ComputeCrc32(buf.Data(), msg_len_for_crc32); + uint32_t c = rtc::ComputeCrc32(buf.Data(), msg_len_for_crc32); // Insert the correct CRC-32, XORed with a constant, into the attribute. fingerprint_attr->SetValue(c ^ STUN_FINGERPRINT_XOR_VALUE); @@ -315,8 +314,8 @@ bool StunMessage::Read(ByteBuffer* buf) { if (!buf->ReadString(&transaction_id, kStunTransactionIdLength)) return false; - uint32 magic_cookie_int = - *reinterpret_cast(magic_cookie.data()); + uint32_t magic_cookie_int = + *reinterpret_cast(magic_cookie.data()); if (rtc::NetworkToHost32(magic_cookie_int) != kStunMagicCookie) { // If magic cookie is invalid it means that the peer implements // RFC3489 instead of RFC5389. @@ -332,7 +331,7 @@ bool StunMessage::Read(ByteBuffer* buf) { size_t rest = buf->Length() - length_; while (buf->Length() > rest) { - uint16 attr_type, attr_length; + uint16_t attr_type, attr_length; if (!buf->ReadUInt16(&attr_type)) return false; if (!buf->ReadUInt16(&attr_length)) @@ -366,7 +365,7 @@ bool StunMessage::Write(ByteBuffer* buf) const { for (size_t i = 0; i < attrs_->size(); ++i) { buf->WriteUInt16((*attrs_)[i]->type()); - buf->WriteUInt16(static_cast((*attrs_)[i]->length())); + buf->WriteUInt16(static_cast((*attrs_)[i]->length())); if (!(*attrs_)[i]->Write(buf)) return false; } @@ -395,8 +394,8 @@ StunAttributeValueType StunMessage::GetAttributeValueType(int type) const { StunAttribute* StunMessage::CreateAttribute(int type, size_t length) /*const*/ { StunAttributeValueType value_type = GetAttributeValueType(type); - return StunAttribute::Create(value_type, type, - static_cast(length), this); + return StunAttribute::Create(value_type, type, static_cast(length), + this); } const StunAttribute* StunMessage::GetAttribute(int type) const { @@ -414,7 +413,7 @@ bool StunMessage::IsValidTransactionId(const std::string& transaction_id) { // StunAttribute -StunAttribute::StunAttribute(uint16 type, uint16 length) +StunAttribute::StunAttribute(uint16_t type, uint16_t length) : type_(type), length_(length) { } @@ -434,7 +433,8 @@ void StunAttribute::WritePadding(rtc::ByteBuffer* buf) const { } StunAttribute* StunAttribute::Create(StunAttributeValueType value_type, - uint16 type, uint16 length, + uint16_t type, + uint16_t length, StunMessage* owner) { switch (value_type) { case STUN_VALUE_ADDRESS: @@ -456,23 +456,23 @@ StunAttribute* StunAttribute::Create(StunAttributeValueType value_type, } } -StunAddressAttribute* StunAttribute::CreateAddress(uint16 type) { +StunAddressAttribute* StunAttribute::CreateAddress(uint16_t type) { return new StunAddressAttribute(type, 0); } -StunXorAddressAttribute* StunAttribute::CreateXorAddress(uint16 type) { +StunXorAddressAttribute* StunAttribute::CreateXorAddress(uint16_t type) { return new StunXorAddressAttribute(type, 0, NULL); } -StunUInt64Attribute* StunAttribute::CreateUInt64(uint16 type) { +StunUInt64Attribute* StunAttribute::CreateUInt64(uint16_t type) { return new StunUInt64Attribute(type); } -StunUInt32Attribute* StunAttribute::CreateUInt32(uint16 type) { +StunUInt32Attribute* StunAttribute::CreateUInt32(uint16_t type) { return new StunUInt32Attribute(type); } -StunByteStringAttribute* StunAttribute::CreateByteString(uint16 type) { +StunByteStringAttribute* StunAttribute::CreateByteString(uint16_t type) { return new StunByteStringAttribute(type, 0); } @@ -485,26 +485,26 @@ StunUInt16ListAttribute* StunAttribute::CreateUnknownAttributes() { return new StunUInt16ListAttribute(STUN_ATTR_UNKNOWN_ATTRIBUTES, 0); } -StunAddressAttribute::StunAddressAttribute(uint16 type, - const rtc::SocketAddress& addr) - : StunAttribute(type, 0) { +StunAddressAttribute::StunAddressAttribute(uint16_t type, + const rtc::SocketAddress& addr) + : StunAttribute(type, 0) { SetAddress(addr); } -StunAddressAttribute::StunAddressAttribute(uint16 type, uint16 length) +StunAddressAttribute::StunAddressAttribute(uint16_t type, uint16_t length) : StunAttribute(type, length) { } bool StunAddressAttribute::Read(ByteBuffer* buf) { - uint8 dummy; + uint8_t dummy; if (!buf->ReadUInt8(&dummy)) return false; - uint8 stun_family; + uint8_t stun_family; if (!buf->ReadUInt8(&stun_family)) { return false; } - uint16 port; + uint16_t port; if (!buf->ReadUInt16(&port)) return false; if (stun_family == STUN_ADDRESS_IPV4) { @@ -557,15 +557,16 @@ bool StunAddressAttribute::Write(ByteBuffer* buf) const { return true; } -StunXorAddressAttribute::StunXorAddressAttribute(uint16 type, - const rtc::SocketAddress& addr) +StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, + const rtc::SocketAddress& addr) : StunAddressAttribute(type, addr), owner_(NULL) { } -StunXorAddressAttribute::StunXorAddressAttribute(uint16 type, - uint16 length, +StunXorAddressAttribute::StunXorAddressAttribute(uint16_t type, + uint16_t length, StunMessage* owner) - : StunAddressAttribute(type, length), owner_(owner) {} + : StunAddressAttribute(type, length), owner_(owner) { +} rtc::IPAddress StunXorAddressAttribute::GetXoredIP() const { if (owner_) { @@ -581,10 +582,10 @@ rtc::IPAddress StunXorAddressAttribute::GetXoredIP() const { in6_addr v6addr = ip.ipv6_address(); const std::string& transaction_id = owner_->transaction_id(); if (transaction_id.length() == kStunTransactionIdLength) { - uint32 transactionid_as_ints[3]; + uint32_t transactionid_as_ints[3]; memcpy(&transactionid_as_ints[0], transaction_id.c_str(), transaction_id.length()); - uint32* ip_as_ints = reinterpret_cast(&v6addr.s6_addr); + uint32_t* ip_as_ints = reinterpret_cast(&v6addr.s6_addr); // Transaction ID is in network byte order, but magic cookie // is stored in host byte order. ip_as_ints[0] = @@ -606,7 +607,7 @@ rtc::IPAddress StunXorAddressAttribute::GetXoredIP() const { bool StunXorAddressAttribute::Read(ByteBuffer* buf) { if (!StunAddressAttribute::Read(buf)) return false; - uint16 xoredport = port() ^ (kStunMagicCookie >> 16); + uint16_t xoredport = port() ^ (kStunMagicCookie >> 16); rtc::IPAddress xored_ip = GetXoredIP(); SetAddress(rtc::SocketAddress(xored_ip, xoredport)); return true; @@ -640,11 +641,11 @@ bool StunXorAddressAttribute::Write(ByteBuffer* buf) const { return true; } -StunUInt32Attribute::StunUInt32Attribute(uint16 type, uint32 value) +StunUInt32Attribute::StunUInt32Attribute(uint16_t type, uint32_t value) : StunAttribute(type, SIZE), bits_(value) { } -StunUInt32Attribute::StunUInt32Attribute(uint16 type) +StunUInt32Attribute::StunUInt32Attribute(uint16_t type) : StunAttribute(type, SIZE), bits_(0) { } @@ -670,11 +671,11 @@ bool StunUInt32Attribute::Write(ByteBuffer* buf) const { return true; } -StunUInt64Attribute::StunUInt64Attribute(uint16 type, uint64 value) +StunUInt64Attribute::StunUInt64Attribute(uint16_t type, uint64_t value) : StunAttribute(type, SIZE), bits_(value) { } -StunUInt64Attribute::StunUInt64Attribute(uint16 type) +StunUInt64Attribute::StunUInt64Attribute(uint16_t type) : StunAttribute(type, SIZE), bits_(0) { } @@ -689,24 +690,24 @@ bool StunUInt64Attribute::Write(ByteBuffer* buf) const { return true; } -StunByteStringAttribute::StunByteStringAttribute(uint16 type) +StunByteStringAttribute::StunByteStringAttribute(uint16_t type) : StunAttribute(type, 0), bytes_(NULL) { } -StunByteStringAttribute::StunByteStringAttribute(uint16 type, +StunByteStringAttribute::StunByteStringAttribute(uint16_t type, const std::string& str) : StunAttribute(type, 0), bytes_(NULL) { CopyBytes(str.c_str(), str.size()); } -StunByteStringAttribute::StunByteStringAttribute(uint16 type, +StunByteStringAttribute::StunByteStringAttribute(uint16_t type, const void* bytes, size_t length) : StunAttribute(type, 0), bytes_(NULL) { CopyBytes(bytes, length); } -StunByteStringAttribute::StunByteStringAttribute(uint16 type, uint16 length) +StunByteStringAttribute::StunByteStringAttribute(uint16_t type, uint16_t length) : StunAttribute(type, length), bytes_(NULL) { } @@ -724,13 +725,13 @@ void StunByteStringAttribute::CopyBytes(const void* bytes, size_t length) { SetBytes(new_bytes, length); } -uint8 StunByteStringAttribute::GetByte(size_t index) const { +uint8_t StunByteStringAttribute::GetByte(size_t index) const { ASSERT(bytes_ != NULL); ASSERT(index < length()); - return static_cast(bytes_[index]); + return static_cast(bytes_[index]); } -void StunByteStringAttribute::SetByte(size_t index, uint8 value) { +void StunByteStringAttribute::SetByte(size_t index, uint8_t value) { ASSERT(bytes_ != NULL); ASSERT(index < length()); bytes_[index] = value; @@ -755,17 +756,18 @@ bool StunByteStringAttribute::Write(ByteBuffer* buf) const { void StunByteStringAttribute::SetBytes(char* bytes, size_t length) { delete [] bytes_; bytes_ = bytes; - SetLength(static_cast(length)); + SetLength(static_cast(length)); } -StunErrorCodeAttribute::StunErrorCodeAttribute(uint16 type, int code, +StunErrorCodeAttribute::StunErrorCodeAttribute(uint16_t type, + int code, const std::string& reason) : StunAttribute(type, 0) { SetCode(code); SetReason(reason); } -StunErrorCodeAttribute::StunErrorCodeAttribute(uint16 type, uint16 length) +StunErrorCodeAttribute::StunErrorCodeAttribute(uint16_t type, uint16_t length) : StunAttribute(type, length), class_(0), number_(0) { } @@ -777,17 +779,17 @@ int StunErrorCodeAttribute::code() const { } void StunErrorCodeAttribute::SetCode(int code) { - class_ = static_cast(code / 100); - number_ = static_cast(code % 100); + class_ = static_cast(code / 100); + number_ = static_cast(code % 100); } void StunErrorCodeAttribute::SetReason(const std::string& reason) { - SetLength(MIN_SIZE + static_cast(reason.size())); + SetLength(MIN_SIZE + static_cast(reason.size())); reason_ = reason; } bool StunErrorCodeAttribute::Read(ByteBuffer* buf) { - uint32 val; + uint32_t val; if (length() < MIN_SIZE || !buf->ReadUInt32(&val)) return false; @@ -811,9 +813,9 @@ bool StunErrorCodeAttribute::Write(ByteBuffer* buf) const { return true; } -StunUInt16ListAttribute::StunUInt16ListAttribute(uint16 type, uint16 length) +StunUInt16ListAttribute::StunUInt16ListAttribute(uint16_t type, uint16_t length) : StunAttribute(type, length) { - attr_types_ = new std::vector(); + attr_types_ = new std::vector(); } StunUInt16ListAttribute::~StunUInt16ListAttribute() { @@ -824,17 +826,17 @@ size_t StunUInt16ListAttribute::Size() const { return attr_types_->size(); } -uint16 StunUInt16ListAttribute::GetType(int index) const { +uint16_t StunUInt16ListAttribute::GetType(int index) const { return (*attr_types_)[index]; } -void StunUInt16ListAttribute::SetType(int index, uint16 value) { +void StunUInt16ListAttribute::SetType(int index, uint16_t value) { (*attr_types_)[index] = value; } -void StunUInt16ListAttribute::AddType(uint16 value) { +void StunUInt16ListAttribute::AddType(uint16_t value) { attr_types_->push_back(value); - SetLength(static_cast(attr_types_->size() * 2)); + SetLength(static_cast(attr_types_->size() * 2)); } bool StunUInt16ListAttribute::Read(ByteBuffer* buf) { @@ -842,7 +844,7 @@ bool StunUInt16ListAttribute::Read(ByteBuffer* buf) { return false; for (size_t i = 0; i < length() / 2; i++) { - uint16 attr; + uint16_t attr; if (!buf->ReadUInt16(&attr)) return false; attr_types_->push_back(attr); diff --git a/webrtc/p2p/base/stun.h b/webrtc/p2p/base/stun.h index 4bf6547885..75b89afb8a 100644 --- a/webrtc/p2p/base/stun.h +++ b/webrtc/p2p/base/stun.h @@ -97,7 +97,7 @@ extern const char STUN_ERROR_REASON_STALE_NONCE[]; extern const char STUN_ERROR_REASON_SERVER_ERROR[]; // The mask used to determine whether a STUN message is a request/response etc. -const uint32 kStunTypeMask = 0x0110; +const uint32_t kStunTypeMask = 0x0110; // STUN Attribute header length. const size_t kStunAttributeHeaderSize = 4; @@ -106,7 +106,7 @@ const size_t kStunAttributeHeaderSize = 4; const size_t kStunHeaderSize = 20; const size_t kStunTransactionIdOffset = 8; const size_t kStunTransactionIdLength = 12; -const uint32 kStunMagicCookie = 0x2112A442; +const uint32_t kStunMagicCookie = 0x2112A442; const size_t kStunMagicCookieLength = sizeof(kStunMagicCookie); // Following value corresponds to an earlier version of STUN from @@ -145,7 +145,7 @@ class StunMessage { // is determined by the lengths of the transaction ID. bool IsLegacy() const; - void SetType(int type) { type_ = static_cast(type); } + void SetType(int type) { type_ = static_cast(type); } bool SetTransactionID(const std::string& str); // Gets the desired attribute value, or NULL if no such attribute type exists. @@ -198,8 +198,8 @@ class StunMessage { const StunAttribute* GetAttribute(int type) const; static bool IsValidTransactionId(const std::string& transaction_id); - uint16 type_; - uint16 length_; + uint16_t type_; + uint16_t length_; std::string transaction_id_; std::vector* attrs_; }; @@ -228,37 +228,39 @@ class StunAttribute { virtual bool Write(rtc::ByteBuffer* buf) const = 0; // Creates an attribute object with the given type and smallest length. - static StunAttribute* Create(StunAttributeValueType value_type, uint16 type, - uint16 length, StunMessage* owner); + static StunAttribute* Create(StunAttributeValueType value_type, + uint16_t type, + uint16_t length, + StunMessage* owner); // TODO: Allow these create functions to take parameters, to reduce // the amount of work callers need to do to initialize attributes. - static StunAddressAttribute* CreateAddress(uint16 type); - static StunXorAddressAttribute* CreateXorAddress(uint16 type); - static StunUInt32Attribute* CreateUInt32(uint16 type); - static StunUInt64Attribute* CreateUInt64(uint16 type); - static StunByteStringAttribute* CreateByteString(uint16 type); + static StunAddressAttribute* CreateAddress(uint16_t type); + static StunXorAddressAttribute* CreateXorAddress(uint16_t type); + static StunUInt32Attribute* CreateUInt32(uint16_t type); + static StunUInt64Attribute* CreateUInt64(uint16_t type); + static StunByteStringAttribute* CreateByteString(uint16_t type); static StunErrorCodeAttribute* CreateErrorCode(); static StunUInt16ListAttribute* CreateUnknownAttributes(); protected: - StunAttribute(uint16 type, uint16 length); - void SetLength(uint16 length) { length_ = length; } + StunAttribute(uint16_t type, uint16_t length); + void SetLength(uint16_t length) { length_ = length; } void WritePadding(rtc::ByteBuffer* buf) const; void ConsumePadding(rtc::ByteBuffer* buf) const; private: - uint16 type_; - uint16 length_; + uint16_t type_; + uint16_t length_; }; // Implements STUN attributes that record an Internet address. class StunAddressAttribute : public StunAttribute { public: - static const uint16 SIZE_UNDEF = 0; - static const uint16 SIZE_IP4 = 8; - static const uint16 SIZE_IP6 = 20; - StunAddressAttribute(uint16 type, const rtc::SocketAddress& addr); - StunAddressAttribute(uint16 type, uint16 length); + static const uint16_t SIZE_UNDEF = 0; + static const uint16_t SIZE_IP4 = 8; + static const uint16_t SIZE_IP6 = 20; + StunAddressAttribute(uint16_t type, const rtc::SocketAddress& addr); + StunAddressAttribute(uint16_t type, uint16_t length); virtual StunAttributeValueType value_type() const { return STUN_VALUE_ADDRESS; @@ -276,7 +278,7 @@ class StunAddressAttribute : public StunAttribute { const rtc::SocketAddress& GetAddress() const { return address_; } const rtc::IPAddress& ipaddr() const { return address_.ipaddr(); } - uint16 port() const { return address_.port(); } + uint16_t port() const { return address_.port(); } void SetAddress(const rtc::SocketAddress& addr) { address_ = addr; @@ -286,7 +288,7 @@ class StunAddressAttribute : public StunAttribute { address_.SetIP(ip); EnsureAddressLength(); } - void SetPort(uint16 port) { address_.SetPort(port); } + void SetPort(uint16_t port) { address_.SetPort(port); } virtual bool Read(rtc::ByteBuffer* buf); virtual bool Write(rtc::ByteBuffer* buf) const; @@ -316,9 +318,8 @@ class StunAddressAttribute : public StunAttribute { // transaction ID of the message. class StunXorAddressAttribute : public StunAddressAttribute { public: - StunXorAddressAttribute(uint16 type, const rtc::SocketAddress& addr); - StunXorAddressAttribute(uint16 type, uint16 length, - StunMessage* owner); + StunXorAddressAttribute(uint16_t type, const rtc::SocketAddress& addr); + StunXorAddressAttribute(uint16_t type, uint16_t length, StunMessage* owner); virtual StunAttributeValueType value_type() const { return STUN_VALUE_XOR_ADDRESS; @@ -337,16 +338,16 @@ class StunXorAddressAttribute : public StunAddressAttribute { // Implements STUN attributes that record a 32-bit integer. class StunUInt32Attribute : public StunAttribute { public: - static const uint16 SIZE = 4; - StunUInt32Attribute(uint16 type, uint32 value); - explicit StunUInt32Attribute(uint16 type); + static const uint16_t SIZE = 4; + StunUInt32Attribute(uint16_t type, uint32_t value); + explicit StunUInt32Attribute(uint16_t type); virtual StunAttributeValueType value_type() const { return STUN_VALUE_UINT32; } - uint32 value() const { return bits_; } - void SetValue(uint32 bits) { bits_ = bits; } + uint32_t value() const { return bits_; } + void SetValue(uint32_t bits) { bits_ = bits; } bool GetBit(size_t index) const; void SetBit(size_t index, bool value); @@ -355,36 +356,36 @@ class StunUInt32Attribute : public StunAttribute { virtual bool Write(rtc::ByteBuffer* buf) const; private: - uint32 bits_; + uint32_t bits_; }; class StunUInt64Attribute : public StunAttribute { public: - static const uint16 SIZE = 8; - StunUInt64Attribute(uint16 type, uint64 value); - explicit StunUInt64Attribute(uint16 type); + static const uint16_t SIZE = 8; + StunUInt64Attribute(uint16_t type, uint64_t value); + explicit StunUInt64Attribute(uint16_t type); virtual StunAttributeValueType value_type() const { return STUN_VALUE_UINT64; } - uint64 value() const { return bits_; } - void SetValue(uint64 bits) { bits_ = bits; } + uint64_t value() const { return bits_; } + void SetValue(uint64_t bits) { bits_ = bits; } virtual bool Read(rtc::ByteBuffer* buf); virtual bool Write(rtc::ByteBuffer* buf) const; private: - uint64 bits_; + uint64_t bits_; }; // Implements STUN attributes that record an arbitrary byte string. class StunByteStringAttribute : public StunAttribute { public: - explicit StunByteStringAttribute(uint16 type); - StunByteStringAttribute(uint16 type, const std::string& str); - StunByteStringAttribute(uint16 type, const void* bytes, size_t length); - StunByteStringAttribute(uint16 type, uint16 length); + explicit StunByteStringAttribute(uint16_t type); + StunByteStringAttribute(uint16_t type, const std::string& str); + StunByteStringAttribute(uint16_t type, const void* bytes, size_t length); + StunByteStringAttribute(uint16_t type, uint16_t length); ~StunByteStringAttribute(); virtual StunAttributeValueType value_type() const { @@ -397,8 +398,8 @@ class StunByteStringAttribute : public StunAttribute { void CopyBytes(const char* bytes); // uses strlen void CopyBytes(const void* bytes, size_t length); - uint8 GetByte(size_t index) const; - void SetByte(size_t index, uint8 value); + uint8_t GetByte(size_t index) const; + void SetByte(size_t index, uint8_t value); virtual bool Read(rtc::ByteBuffer* buf); virtual bool Write(rtc::ByteBuffer* buf) const; @@ -412,9 +413,9 @@ class StunByteStringAttribute : public StunAttribute { // Implements STUN attributes that record an error code. class StunErrorCodeAttribute : public StunAttribute { public: - static const uint16 MIN_SIZE = 4; - StunErrorCodeAttribute(uint16 type, int code, const std::string& reason); - StunErrorCodeAttribute(uint16 type, uint16 length); + static const uint16_t MIN_SIZE = 4; + StunErrorCodeAttribute(uint16_t type, int code, const std::string& reason); + StunErrorCodeAttribute(uint16_t type, uint16_t length); ~StunErrorCodeAttribute(); virtual StunAttributeValueType value_type() const { @@ -429,23 +430,23 @@ class StunErrorCodeAttribute : public StunAttribute { int eclass() const { return class_; } int number() const { return number_; } const std::string& reason() const { return reason_; } - void SetClass(uint8 eclass) { class_ = eclass; } - void SetNumber(uint8 number) { number_ = number; } + void SetClass(uint8_t eclass) { class_ = eclass; } + void SetNumber(uint8_t number) { number_ = number; } void SetReason(const std::string& reason); bool Read(rtc::ByteBuffer* buf); bool Write(rtc::ByteBuffer* buf) const; private: - uint8 class_; - uint8 number_; + uint8_t class_; + uint8_t number_; std::string reason_; }; // Implements STUN attributes that record a list of attribute names. class StunUInt16ListAttribute : public StunAttribute { public: - StunUInt16ListAttribute(uint16 type, uint16 length); + StunUInt16ListAttribute(uint16_t type, uint16_t length); ~StunUInt16ListAttribute(); virtual StunAttributeValueType value_type() const { @@ -453,15 +454,15 @@ class StunUInt16ListAttribute : public StunAttribute { } size_t Size() const; - uint16 GetType(int index) const; - void SetType(int index, uint16 value); - void AddType(uint16 value); + uint16_t GetType(int index) const; + void SetType(int index, uint16_t value); + void AddType(uint16_t value); bool Read(rtc::ByteBuffer* buf); bool Write(rtc::ByteBuffer* buf) const; private: - std::vector* attr_types_; + std::vector* attr_types_; }; // Returns the (successful) response type for the given request type. diff --git a/webrtc/p2p/base/stun_unittest.cc b/webrtc/p2p/base/stun_unittest.cc index 9d5779d7d6..cd4f7e1cbb 100644 --- a/webrtc/p2p/base/stun_unittest.cc +++ b/webrtc/p2p/base/stun_unittest.cc @@ -165,7 +165,7 @@ static const unsigned char kStunMessageWithPaddedByteStringAttribute[] = { 0x61, 0x62, 0x63, 0xcc // abc }; -// Message with an Unknown Attributes (uint16 list) attribute. +// Message with an Unknown Attributes (uint16_t list) attribute. static const unsigned char kStunMessageWithUInt16ListAttribute[] = { 0x00, 0x01, 0x00, 0x0c, 0x21, 0x12, 0xa4, 0x42, diff --git a/webrtc/p2p/base/stunport.cc b/webrtc/p2p/base/stunport.cc index 696d323e64..615bbfe55a 100644 --- a/webrtc/p2p/base/stunport.cc +++ b/webrtc/p2p/base/stunport.cc @@ -106,7 +106,7 @@ class StunBindingRequest : public StunRequest { UDPPort* port_; bool keep_alive_; const rtc::SocketAddress server_addr_; - uint32 start_time_; + uint32_t start_time_; }; UDPPort::AddressResolver::AddressResolver( @@ -182,14 +182,21 @@ UDPPort::UDPPort(rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const std::string& origin, bool emit_localhost_for_anyaddress) - : Port(thread, LOCAL_PORT_TYPE, factory, network, ip, min_port, max_port, - username, password), + : Port(thread, + LOCAL_PORT_TYPE, + factory, + network, + ip, + min_port, + max_port, + username, + password), requests_(thread), socket_(NULL), error_(0), diff --git a/webrtc/p2p/base/stunport.h b/webrtc/p2p/base/stunport.h index 2967c15d95..488739c936 100644 --- a/webrtc/p2p/base/stunport.h +++ b/webrtc/p2p/base/stunport.h @@ -50,8 +50,8 @@ class UDPPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const std::string& origin, @@ -110,8 +110,8 @@ class UDPPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const std::string& origin, @@ -220,7 +220,8 @@ class StunPort : public UDPPort { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const ServerAddresses& servers, @@ -247,14 +248,22 @@ class StunPort : public UDPPort { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const ServerAddresses& servers, const std::string& origin) - : UDPPort(thread, factory, network, ip, min_port, max_port, username, - password, origin, false) { + : UDPPort(thread, + factory, + network, + ip, + min_port, + max_port, + username, + password, + origin, + false) { // UDPPort will set these to local udp, updating these to STUN. set_type(STUN_PORT_TYPE); set_server_addresses(servers); diff --git a/webrtc/p2p/base/stunport_unittest.cc b/webrtc/p2p/base/stunport_unittest.cc index 173bcaebed..037d448b9e 100644 --- a/webrtc/p2p/base/stunport_unittest.cc +++ b/webrtc/p2p/base/stunport_unittest.cc @@ -30,7 +30,7 @@ static const SocketAddress kStunHostnameAddr("localhost", 5000); static const SocketAddress kBadHostnameAddr("not-a-real-hostname", 5000); static const int kTimeoutMs = 10000; // stun prio = 100 << 24 | 30 (IPV4) << 8 | 256 - 0 -static const uint32 kStunCandidatePriority = 1677729535; +static const uint32_t kStunCandidatePriority = 1677729535; // Tests connecting a StunPort to a fake STUN server (cricket::StunServer) // TODO: Use a VirtualSocketServer here. We have to use a diff --git a/webrtc/p2p/base/stunrequest.cc b/webrtc/p2p/base/stunrequest.cc index c5700c0466..df5614d3cc 100644 --- a/webrtc/p2p/base/stunrequest.cc +++ b/webrtc/p2p/base/stunrequest.cc @@ -18,7 +18,7 @@ namespace cricket { -const uint32 MSG_STUN_SEND = 1; +const uint32_t MSG_STUN_SEND = 1; const int MAX_SENDS = 9; const int DELAY_UNIT = 100; // 100 milliseconds @@ -68,7 +68,7 @@ void StunRequestManager::Clear() { for (RequestMap::iterator i = requests_.begin(); i != requests_.end(); ++i) requests.push_back(i->second); - for (uint32 i = 0; i < requests.size(); ++i) { + for (uint32_t i = 0; i < requests.size(); ++i) { // StunRequest destructor calls Remove() which deletes requests // from |requests_|. delete requests[i]; @@ -171,7 +171,7 @@ const StunMessage* StunRequest::msg() const { return msg_; } -uint32 StunRequest::Elapsed() const { +uint32_t StunRequest::Elapsed() const { return rtc::TimeSince(tstamp_); } diff --git a/webrtc/p2p/base/stunrequest.h b/webrtc/p2p/base/stunrequest.h index e6b9e7dcfd..267b4a1959 100644 --- a/webrtc/p2p/base/stunrequest.h +++ b/webrtc/p2p/base/stunrequest.h @@ -90,7 +90,7 @@ class StunRequest : public rtc::MessageHandler { const StunMessage* msg() const; // Time elapsed since last send (in ms) - uint32 Elapsed() const; + uint32_t Elapsed() const; protected: int count_; @@ -118,7 +118,7 @@ class StunRequest : public rtc::MessageHandler { StunRequestManager* manager_; StunMessage* msg_; - uint32 tstamp_; + uint32_t tstamp_; friend class StunRequestManager; }; diff --git a/webrtc/p2p/base/stunrequest_unittest.cc b/webrtc/p2p/base/stunrequest_unittest.cc index 3ff6cbaf72..8a23834891 100644 --- a/webrtc/p2p/base/stunrequest_unittest.cc +++ b/webrtc/p2p/base/stunrequest_unittest.cc @@ -146,13 +146,13 @@ TEST_F(StunRequestTest, TestUnexpected) { TEST_F(StunRequestTest, TestBackoff) { StunMessage* req = CreateStunMessage(STUN_BINDING_REQUEST, NULL); - uint32 start = rtc::Time(); + uint32_t start = rtc::Time(); manager_.Send(new StunRequestThunker(req, this)); StunMessage* res = CreateStunMessage(STUN_BINDING_RESPONSE, req); for (int i = 0; i < 9; ++i) { while (request_count_ == i) rtc::Thread::Current()->ProcessMessages(1); - int32 elapsed = rtc::TimeSince(start); + int32_t elapsed = rtc::TimeSince(start); LOG(LS_INFO) << "STUN request #" << (i + 1) << " sent at " << elapsed << " ms"; EXPECT_GE(TotalDelay(i + 1), elapsed); diff --git a/webrtc/p2p/base/tcpport.cc b/webrtc/p2p/base/tcpport.cc index 86982b01c6..2590d0aca8 100644 --- a/webrtc/p2p/base/tcpport.cc +++ b/webrtc/p2p/base/tcpport.cc @@ -76,13 +76,20 @@ TCPPort::TCPPort(rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, bool allow_listen) - : Port(thread, LOCAL_PORT_TYPE, factory, network, ip, min_port, max_port, - username, password), + : Port(thread, + LOCAL_PORT_TYPE, + factory, + network, + ip, + min_port, + max_port, + username, + password), incoming_only_(false), allow_listen_(allow_listen), socket_(NULL), diff --git a/webrtc/p2p/base/tcpport.h b/webrtc/p2p/base/tcpport.h index d86f750e9f..a64c5eeab9 100644 --- a/webrtc/p2p/base/tcpport.h +++ b/webrtc/p2p/base/tcpport.h @@ -32,8 +32,8 @@ class TCPPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, bool allow_listen) { @@ -61,8 +61,8 @@ class TCPPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, bool allow_listen); diff --git a/webrtc/p2p/base/transport.h b/webrtc/p2p/base/transport.h index 6324cd6864..dfd512fe5d 100644 --- a/webrtc/p2p/base/transport.h +++ b/webrtc/p2p/base/transport.h @@ -160,8 +160,8 @@ class Transport : public sigslot::has_slots<> { void SetIceRole(IceRole role); IceRole ice_role() const { return ice_role_; } - void SetIceTiebreaker(uint64 IceTiebreaker) { tiebreaker_ = IceTiebreaker; } - uint64 IceTiebreaker() { return tiebreaker_; } + void SetIceTiebreaker(uint64_t IceTiebreaker) { tiebreaker_ = IceTiebreaker; } + uint64_t IceTiebreaker() { return tiebreaker_; } void SetIceConfig(const IceConfig& config); @@ -290,7 +290,7 @@ class Transport : public sigslot::has_slots<> { bool channels_destroyed_ = false; bool connect_requested_ = false; IceRole ice_role_ = ICEROLE_UNKNOWN; - uint64 tiebreaker_ = 0; + uint64_t tiebreaker_ = 0; IceMode remote_ice_mode_ = ICEMODE_FULL; IceConfig ice_config_; rtc::scoped_ptr local_description_; diff --git a/webrtc/p2p/base/transportchannel.h b/webrtc/p2p/base/transportchannel.h index ca7d7cf833..1223618d0b 100644 --- a/webrtc/p2p/base/transportchannel.h +++ b/webrtc/p2p/base/transportchannel.h @@ -124,11 +124,11 @@ class TransportChannel : public sigslot::has_slots<> { // Allows key material to be extracted for external encryption. virtual bool ExportKeyingMaterial(const std::string& label, - const uint8* context, - size_t context_len, - bool use_context, - uint8* result, - size_t result_len) = 0; + const uint8_t* context, + size_t context_len, + bool use_context, + uint8_t* result, + size_t result_len) = 0; // Signalled each time a packet is received on this channel. sigslot::signal5, IceRole ice_role_ = ICEROLE_CONTROLLING; // Flag which will be set to true after the first role switch bool ice_role_switch_ = false; - uint64 ice_tiebreaker_ = rtc::CreateRandomId64(); + uint64_t ice_tiebreaker_ = rtc::CreateRandomId64(); rtc::scoped_refptr certificate_; }; diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc index 2e4e26d0d1..3fdcac5f31 100644 --- a/webrtc/p2p/base/turnport.cc +++ b/webrtc/p2p/base/turnport.cc @@ -38,7 +38,7 @@ static const size_t TURN_CHANNEL_HEADER_SIZE = 4U; // STUN_ERROR_ALLOCATION_MISMATCH error per rfc5766. static const size_t MAX_ALLOCATE_MISMATCH_RETRIES = 2; -inline bool IsTurnChannelData(uint16 msg_type) { +inline bool IsTurnChannelData(uint16_t msg_type) { return ((msg_type & 0xC000) == 0x4000); // MSB are 0b01 } @@ -196,8 +196,8 @@ TurnPort::TurnPort(rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const ProtocolAddress& server_address, @@ -534,7 +534,7 @@ void TurnPort::OnReadPacket( // Check the message type, to see if is a Channel Data message. // The message will either be channel data, a TURN data indication, or // a response to a previous request. - uint16 msg_type = rtc::GetBE16(data); + uint16_t msg_type = rtc::GetBE16(data); if (IsTurnChannelData(msg_type)) { HandleChannelData(msg_type, data, size, packet_time); } else if (msg_type == TURN_DATA_INDICATION) { @@ -779,7 +779,7 @@ void TurnPort::HandleChannelData(int channel_id, const char* data, // +-------------------------------+ // Extract header fields from the message. - uint16 len = rtc::GetBE16(data + 2); + uint16_t len = rtc::GetBE16(data + 2); if (len > size - TURN_CHANNEL_HEADER_SIZE) { LOG_J(LS_WARNING, this) << "Received TURN channel data message with " << "incorrect length, len=" << len; @@ -1325,7 +1325,7 @@ int TurnEntry::Send(const void* data, size_t size, bool payload, } else { // If the channel is bound, we can send the data as a Channel Message. buf.WriteUInt16(channel_id_); - buf.WriteUInt16(static_cast(size)); + buf.WriteUInt16(static_cast(size)); buf.WriteBytes(reinterpret_cast(data), size); } return port_->Send(buf.Data(), buf.Length(), options); diff --git a/webrtc/p2p/base/turnport.h b/webrtc/p2p/base/turnport.h index 52546e09a3..3bca727346 100644 --- a/webrtc/p2p/base/turnport.h +++ b/webrtc/p2p/base/turnport.h @@ -57,8 +57,8 @@ class TurnPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, // ice username. const std::string& password, // ice password. const ProtocolAddress& server_address, @@ -149,8 +149,8 @@ class TurnPort : public Port { rtc::PacketSocketFactory* factory, rtc::Network* network, const rtc::IPAddress& ip, - uint16 min_port, - uint16 max_port, + uint16_t min_port, + uint16_t max_port, const std::string& username, const std::string& password, const ProtocolAddress& server_address, diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc index 7d82d55c5d..8d40a9030c 100644 --- a/webrtc/p2p/base/turnserver.cc +++ b/webrtc/p2p/base/turnserver.cc @@ -40,7 +40,7 @@ static const size_t kNonceSize = 40; static const size_t TURN_CHANNEL_HEADER_SIZE = 4U; // TODO(mallinath) - Move these to a common place. -inline bool IsTurnChannelData(uint16 msg_type) { +inline bool IsTurnChannelData(uint16_t msg_type) { // The first two bits of a channel data message are 0b01. return ((msg_type & 0xC000) == 0x4000); } @@ -200,7 +200,7 @@ void TurnServer::OnInternalPacket(rtc::AsyncPacketSocket* socket, InternalSocketMap::iterator iter = server_sockets_.find(socket); ASSERT(iter != server_sockets_.end()); TurnServerConnection conn(addr, iter->second, socket); - uint16 msg_type = rtc::GetBE16(data); + uint16_t msg_type = rtc::GetBE16(data); if (!IsTurnChannelData(msg_type)) { // This is a STUN message. HandleStunMessage(&conn, data, size); @@ -394,7 +394,7 @@ void TurnServer::HandleAllocateRequest(TurnServerConnection* conn, std::string TurnServer::GenerateNonce() const { // Generate a nonce of the form hex(now + HMAC-MD5(nonce_key_, now)) - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); std::string input(reinterpret_cast(&now), sizeof(now)); std::string nonce = rtc::hex_encode(input.c_str(), input.size()); nonce += rtc::ComputeHmac(rtc::DIGEST_MD5, nonce_key_, input); @@ -409,7 +409,7 @@ bool TurnServer::ValidateNonce(const std::string& nonce) const { } // Decode the timestamp. - uint32 then; + uint32_t then; char* p = reinterpret_cast(&then); size_t len = rtc::hex_decode(p, sizeof(then), nonce.substr(0, sizeof(then) * 2)); @@ -761,7 +761,7 @@ void TurnServerAllocation::HandleChannelBindRequest(const TurnMessage* msg) { void TurnServerAllocation::HandleChannelData(const char* data, size_t size) { // Extract the channel number from the data. - uint16 channel_id = rtc::GetBE16(data); + uint16_t channel_id = rtc::GetBE16(data); Channel* channel = FindChannel(channel_id); if (channel) { // Send the data to the peer address. @@ -784,7 +784,7 @@ void TurnServerAllocation::OnExternalPacket( // There is a channel bound to this address. Send as a channel message. rtc::ByteBuffer buf; buf.WriteUInt16(channel->id()); - buf.WriteUInt16(static_cast(size)); + buf.WriteUInt16(static_cast(size)); buf.WriteBytes(data, size); server_->Send(&conn_, buf); } else if (HasPermission(addr.ipaddr())) { @@ -806,7 +806,7 @@ void TurnServerAllocation::OnExternalPacket( int TurnServerAllocation::ComputeLifetime(const TurnMessage* msg) { // Return the smaller of our default lifetime and the requested lifetime. - uint32 lifetime = kDefaultAllocationTimeout / 1000; // convert to seconds + uint32_t lifetime = kDefaultAllocationTimeout / 1000; // convert to seconds const StunUInt32Attribute* lifetime_attr = msg->GetUInt32(STUN_ATTR_LIFETIME); if (lifetime_attr && lifetime_attr->value() < lifetime) { lifetime = lifetime_attr->value(); diff --git a/webrtc/p2p/client/basicportallocator.cc b/webrtc/p2p/client/basicportallocator.cc index f343b352ee..21c8921f40 100644 --- a/webrtc/p2p/client/basicportallocator.cc +++ b/webrtc/p2p/client/basicportallocator.cc @@ -59,7 +59,7 @@ int ShakeDelay() { } // namespace namespace cricket { -const uint32 DISABLE_ALL_PHASES = +const uint32_t DISABLE_ALL_PHASES = PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; @@ -157,7 +157,7 @@ BasicPortAllocatorSession::~BasicPortAllocatorSession() { if (network_thread_ != NULL) network_thread_->Clear(this); - for (uint32 i = 0; i < sequences_.size(); ++i) { + for (uint32_t i = 0; i < sequences_.size(); ++i) { // AllocationSequence should clear it's map entry for turn ports before // ports are destroyed. sequences_[i]->Clear(); @@ -167,10 +167,10 @@ BasicPortAllocatorSession::~BasicPortAllocatorSession() { for (it = ports_.begin(); it != ports_.end(); it++) delete it->port(); - for (uint32 i = 0; i < configs_.size(); ++i) + for (uint32_t i = 0; i < configs_.size(); ++i) delete configs_[i]; - for (uint32 i = 0; i < sequences_.size(); ++i) + for (uint32_t i = 0; i < sequences_.size(); ++i) delete sequences_[i]; } @@ -198,7 +198,7 @@ void BasicPortAllocatorSession::StopGettingPorts() { void BasicPortAllocatorSession::ClearGettingPorts() { network_thread_->Clear(this, MSG_ALLOCATE); - for (uint32 i = 0; i < sequences_.size(); ++i) + for (uint32_t i = 0; i < sequences_.size(); ++i) sequences_[i]->Stop(); } @@ -335,12 +335,12 @@ void BasicPortAllocatorSession::DoAllocate() { LOG(LS_WARNING) << "Machine has no networks; no ports will be allocated"; done_signal_needed = true; } else { - for (uint32 i = 0; i < networks.size(); ++i) { + for (uint32_t i = 0; i < networks.size(); ++i) { PortConfiguration* config = NULL; if (configs_.size() > 0) config = configs_.back(); - uint32 sequence_flags = flags(); + uint32_t sequence_flags = flags(); if ((sequence_flags & DISABLE_ALL_PHASES) == DISABLE_ALL_PHASES) { // If all the ports are disabled we should just fire the allocation // done event and return. @@ -406,9 +406,12 @@ void BasicPortAllocatorSession::OnNetworksChanged() { } void BasicPortAllocatorSession::DisableEquivalentPhases( - rtc::Network* network, PortConfiguration* config, uint32* flags) { - for (uint32 i = 0; i < sequences_.size() && - (*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES; ++i) { + rtc::Network* network, + PortConfiguration* config, + uint32_t* flags) { + for (uint32_t i = 0; i < sequences_.size() && + (*flags & DISABLE_ALL_PHASES) != DISABLE_ALL_PHASES; + ++i) { sequences_[i]->DisableEquivalentPhases(network, config, flags); } } @@ -429,7 +432,7 @@ void BasicPortAllocatorSession::AddAllocatedPort(Port* port, PORTALLOCATOR_ENABLE_STUN_RETRANSMIT_ATTRIBUTE) != 0); // Push down the candidate_filter to individual port. - uint32 candidate_filter = allocator_->candidate_filter(); + uint32_t candidate_filter = allocator_->candidate_filter(); // When adapter enumeration is disabled, disable CF_HOST at port level so // local address is not leaked by stunport in the candidate's related address. @@ -572,7 +575,7 @@ void BasicPortAllocatorSession::OnProtocolEnabled(AllocationSequence* seq, } bool BasicPortAllocatorSession::CheckCandidateFilter(const Candidate& c) { - uint32 filter = allocator_->candidate_filter(); + uint32_t filter = allocator_->candidate_filter(); // When binding to any address, before sending packets out, the getsockname // returns all 0s, but after sending packets, it'll be the NIC used to @@ -714,7 +717,7 @@ BasicPortAllocatorSession::PortData* BasicPortAllocatorSession::FindPort( AllocationSequence::AllocationSequence(BasicPortAllocatorSession* session, rtc::Network* network, PortConfiguration* config, - uint32 flags) + uint32_t flags) : session_(session), network_(network), ip_(network->GetBestIP()), @@ -757,7 +760,7 @@ AllocationSequence::~AllocationSequence() { } void AllocationSequence::DisableEquivalentPhases(rtc::Network* network, - PortConfiguration* config, uint32* flags) { + PortConfiguration* config, uint32_t* flags) { if (network_removed_) { // If the network of this allocation sequence has ever gone away, // it won't be equivalent to the new network. diff --git a/webrtc/p2p/client/basicportallocator.h b/webrtc/p2p/client/basicportallocator.h index ac2cfbfc13..c8bcad21a9 100644 --- a/webrtc/p2p/client/basicportallocator.h +++ b/webrtc/p2p/client/basicportallocator.h @@ -171,7 +171,8 @@ class BasicPortAllocatorSession : public PortAllocatorSession, void OnNetworksChanged(); void OnAllocationSequenceObjectsCreated(); void DisableEquivalentPhases(rtc::Network* network, - PortConfiguration* config, uint32* flags); + PortConfiguration* config, + uint32_t* flags); void AddAllocatedPort(Port* port, AllocationSequence* seq, bool prepare_address); void OnCandidateReady(Port* port, const Candidate& c); @@ -258,7 +259,7 @@ class AllocationSequence : public rtc::MessageHandler, AllocationSequence(BasicPortAllocatorSession* session, rtc::Network* network, PortConfiguration* config, - uint32 flags); + uint32_t flags); ~AllocationSequence(); bool Init(); void Clear(); @@ -272,7 +273,7 @@ class AllocationSequence : public rtc::MessageHandler, // equivalent network setup. void DisableEquivalentPhases(rtc::Network* network, PortConfiguration* config, - uint32* flags); + uint32_t* flags); // Starts and stops the sequence. When started, it will continue allocating // new ports on its own timed schedule. @@ -300,7 +301,7 @@ class AllocationSequence : public rtc::MessageHandler, private: typedef std::vector ProtocolList; - bool IsFlagSet(uint32 flag) { return ((flags_ & flag) != 0); } + bool IsFlagSet(uint32_t flag) { return ((flags_ & flag) != 0); } void CreateUDPPorts(); void CreateTCPPorts(); void CreateStunPorts(); @@ -321,7 +322,7 @@ class AllocationSequence : public rtc::MessageHandler, rtc::IPAddress ip_; PortConfiguration* config_; State state_; - uint32 flags_; + uint32_t flags_; ProtocolList protocols_; rtc::scoped_ptr udp_socket_; // There will be only one udp port per AllocationSequence. diff --git a/webrtc/p2p/client/portallocator_unittest.cc b/webrtc/p2p/client/portallocator_unittest.cc index b0c77d36c6..9617688302 100644 --- a/webrtc/p2p/client/portallocator_unittest.cc +++ b/webrtc/p2p/client/portallocator_unittest.cc @@ -249,7 +249,7 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> { // also the related address for TURN candidate if it is expected. Otherwise, // it should be ignore. void CheckDisableAdapterEnumeration( - uint32 total_ports, + uint32_t total_ports, const rtc::IPAddress& host_candidate_addr, const rtc::IPAddress& stun_candidate_addr, const rtc::IPAddress& relay_candidate_udp_transport_addr, @@ -264,7 +264,7 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> { session_->StartGettingPorts(); EXPECT_TRUE_WAIT(candidate_allocation_done_, kDefaultAllocationTimeout); - uint32 total_candidates = 0; + uint32_t total_candidates = 0; if (!host_candidate_addr.IsNil()) { EXPECT_PRED5(CheckCandidate, candidates_[total_candidates], cricket::ICE_CANDIDATE_COMPONENT_RTP, "local", "udp", diff --git a/webrtc/p2p/client/socketmonitor.h b/webrtc/p2p/client/socketmonitor.h index e0dd81ef6c..eb11516002 100644 --- a/webrtc/p2p/client/socketmonitor.h +++ b/webrtc/p2p/client/socketmonitor.h @@ -53,7 +53,7 @@ public: rtc::Thread* worker_thread_; rtc::Thread* monitoring_thread_; rtc::CriticalSection crit_; - uint32 rate_; + uint32_t rate_; bool monitoring_; }; diff --git a/webrtc/p2p/stunprober/stunprober.cc b/webrtc/p2p/stunprober/stunprober.cc index 5bfa711405..d7d527a37b 100644 --- a/webrtc/p2p/stunprober/stunprober.cc +++ b/webrtc/p2p/stunprober/stunprober.cc @@ -44,16 +44,16 @@ class StunProber::Requester : public sigslot::has_slots<> { // Each Request maps to a request and response. struct Request { // Actual time the STUN bind request was sent. - int64 sent_time_ms = 0; + int64_t sent_time_ms = 0; // Time the response was received. - int64 received_time_ms = 0; + int64_t received_time_ms = 0; // Server reflexive address from STUN response for this given request. rtc::SocketAddress srflx_addr; rtc::IPAddress server_addr; - int64 rtt() { return received_time_ms - sent_time_ms; } + int64_t rtt() { return received_time_ms - sent_time_ms; } void ProcessResponse(const char* buf, size_t buf_len); }; @@ -97,8 +97,8 @@ class StunProber::Requester : public sigslot::has_slots<> { std::vector requests_; std::vector server_ips_; - int16 num_request_sent_ = 0; - int16 num_response_received_ = 0; + int16_t num_request_sent_ = 0; + int16_t num_response_received_ = 0; rtc::ThreadChecker& thread_checker_; @@ -169,7 +169,7 @@ void StunProber::Requester::SendStunRequest() { void StunProber::Requester::Request::ProcessResponse(const char* buf, size_t buf_len) { - int64 now = rtc::Time(); + int64_t now = rtc::Time(); rtc::ByteBuffer message(buf, buf_len); cricket::StunMessage stun_response; if (!stun_response.Read(&message)) { @@ -376,7 +376,7 @@ bool StunProber::SendNextRequest() { void StunProber::MaybeScheduleStunRequests() { RTC_DCHECK(thread_checker_.CalledOnValidThread()); - uint32 now = rtc::Time(); + uint32_t now = rtc::Time(); if (Done()) { invoker_.AsyncInvokeDelayed( @@ -404,8 +404,8 @@ bool StunProber::GetStats(StunProber::Stats* prob_stats) const { StunProber::Stats stats; int rtt_sum = 0; - int64 first_sent_time = 0; - int64 last_sent_time = 0; + int64_t first_sent_time = 0; + int64_t last_sent_time = 0; NatType nat_type = NATTYPE_INVALID; // Track of how many srflx IP that we have seen. diff --git a/webrtc/p2p/stunprober/stunprober.h b/webrtc/p2p/stunprober/stunprober.h index 88dedd50d8..b71d52374f 100644 --- a/webrtc/p2p/stunprober/stunprober.h +++ b/webrtc/p2p/stunprober/stunprober.h @@ -146,15 +146,15 @@ class StunProber : public sigslot::has_slots<> { Requester* current_requester_ = nullptr; // The time when the next request should go out. - uint64 next_request_time_ms_ = 0; + uint64_t next_request_time_ms_ = 0; // Total requests sent so far. - uint32 num_request_sent_ = 0; + uint32_t num_request_sent_ = 0; bool shared_socket_mode_ = false; // How many requests should be done against each resolved IP. - uint32 requests_per_ip_ = 0; + uint32_t requests_per_ip_ = 0; // Milliseconds to pause between each STUN request. int interval_ms_; diff --git a/webrtc/p2p/stunprober/stunprober_unittest.cc b/webrtc/p2p/stunprober/stunprober_unittest.cc index 3e030144da..cdcc14a36f 100644 --- a/webrtc/p2p/stunprober/stunprober_unittest.cc +++ b/webrtc/p2p/stunprober/stunprober_unittest.cc @@ -59,8 +59,8 @@ class StunProberTest : public testing::Test { const std::vector& addrs, const rtc::NetworkManager::NetworkList& networks, bool shared_socket, - uint16 interval, - uint16 pings_per_ip) { + uint16_t interval, + uint16_t pings_per_ip) { prober.reset( new StunProber(socket_factory, rtc::Thread::Current(), networks)); prober->Start(addrs, shared_socket, interval, pings_per_ip, @@ -89,12 +89,12 @@ class StunProberTest : public testing::Test { // Set up the expected results for verification. std::set srflx_addresses; srflx_addresses.insert(kStunMappedAddr.ToString()); - const uint32 total_pings_tried = - static_cast(pings_per_ip * addrs.size()); + const uint32_t total_pings_tried = + static_cast(pings_per_ip * addrs.size()); // The reported total_pings should not count for pings sent to the // kFailedStunAddr. - const uint32 total_pings_reported = total_pings_tried - pings_per_ip; + const uint32_t total_pings_reported = total_pings_tried - pings_per_ip; StartProbing(socket_factory.get(), addrs, networks, shared_mode, 3, pings_per_ip); @@ -106,9 +106,9 @@ class StunProberTest : public testing::Test { EXPECT_EQ(stats.success_percent, 100); EXPECT_TRUE(stats.nat_type > stunprober::NATTYPE_NONE); EXPECT_EQ(stats.srflx_addrs, srflx_addresses); - EXPECT_EQ(static_cast(stats.num_request_sent), + EXPECT_EQ(static_cast(stats.num_request_sent), total_pings_reported); - EXPECT_EQ(static_cast(stats.num_response_received), + EXPECT_EQ(static_cast(stats.num_response_received), total_pings_reported); } diff --git a/webrtc/tools/converter/converter.cc b/webrtc/tools/converter/converter.cc index 6c9154c7da..a9b453d509 100644 --- a/webrtc/tools/converter/converter.cc +++ b/webrtc/tools/converter/converter.cc @@ -45,13 +45,13 @@ bool Converter::ConvertRGBAToI420Video(std::string frames_dir, } int input_frame_size = InputFrameSize(); - uint8* rgba_buffer = new uint8[input_frame_size]; + uint8_t* rgba_buffer = new uint8_t[input_frame_size]; int y_plane_size = YPlaneSize(); - uint8* dst_y = new uint8[y_plane_size]; + uint8_t* dst_y = new uint8_t[y_plane_size]; int u_plane_size = UPlaneSize(); - uint8* dst_u = new uint8[u_plane_size]; + uint8_t* dst_u = new uint8_t[u_plane_size]; int v_plane_size = VPlaneSize(); - uint8* dst_v = new uint8[v_plane_size]; + uint8_t* dst_v = new uint8_t[v_plane_size]; int counter = 0; // Counter to form frame names. bool success = false; // Is conversion successful. @@ -106,9 +106,12 @@ bool Converter::ConvertRGBAToI420Video(std::string frames_dir, return success; } -bool Converter::AddYUVToFile(uint8* y_plane, int y_plane_size, - uint8* u_plane, int u_plane_size, - uint8* v_plane, int v_plane_size, +bool Converter::AddYUVToFile(uint8_t* y_plane, + int y_plane_size, + uint8_t* u_plane, + int u_plane_size, + uint8_t* v_plane, + int v_plane_size, FILE* output_file) { bool success = AddYUVPlaneToFile(y_plane, y_plane_size, output_file) && AddYUVPlaneToFile(u_plane, u_plane_size, output_file) && @@ -116,7 +119,8 @@ bool Converter::AddYUVToFile(uint8* y_plane, int y_plane_size, return success; } -bool Converter::AddYUVPlaneToFile(uint8* yuv_plane, int yuv_plane_size, +bool Converter::AddYUVPlaneToFile(uint8_t* yuv_plane, + int yuv_plane_size, FILE* file) { size_t bytes_written = fwrite(yuv_plane, 1, yuv_plane_size, file); diff --git a/webrtc/tools/converter/converter.h b/webrtc/tools/converter/converter.h index a23d5a14d4..f7641ff60d 100644 --- a/webrtc/tools/converter/converter.h +++ b/webrtc/tools/converter/converter.h @@ -75,13 +75,16 @@ class Converter { // Writes the Y, U and V (in this order) planes to the file, thus adding a // raw YUV frame to the file. - bool AddYUVToFile(uint8* y_plane, int y_plane_size, - uint8* u_plane, int u_plane_size, - uint8* v_plane, int v_plane_size, + bool AddYUVToFile(uint8_t* y_plane, + int y_plane_size, + uint8_t* u_plane, + int u_plane_size, + uint8_t* v_plane, + int v_plane_size, FILE* output_file); // Adds the Y, U or V plane to the file. - bool AddYUVPlaneToFile(uint8* yuv_plane, int yuv_plane_size, FILE* file); + bool AddYUVPlaneToFile(uint8_t* yuv_plane, int yuv_plane_size, FILE* file); // Reads a RGBA frame from input_file_name with input_frame_size size in bytes // into the buffer. diff --git a/webrtc/tools/frame_analyzer/video_quality_analysis.cc b/webrtc/tools/frame_analyzer/video_quality_analysis.cc index 5c707bb6e3..172baa72b8 100644 --- a/webrtc/tools/frame_analyzer/video_quality_analysis.cc +++ b/webrtc/tools/frame_analyzer/video_quality_analysis.cc @@ -90,8 +90,11 @@ bool GetNextStatsLine(FILE* stats_file, char* line) { return true; } -bool ExtractFrameFromYuvFile(const char* i420_file_name, int width, int height, - int frame_number, uint8* result_frame) { +bool ExtractFrameFromYuvFile(const char* i420_file_name, + int width, + int height, + int frame_number, + uint8_t* result_frame) { int frame_size = GetI420FrameSize(width, height); int offset = frame_number * frame_size; // Calculate offset for the frame. bool errors = false; @@ -117,8 +120,11 @@ bool ExtractFrameFromYuvFile(const char* i420_file_name, int width, int height, return !errors; } -bool ExtractFrameFromY4mFile(const char* y4m_file_name, int width, int height, - int frame_number, uint8* result_frame) { +bool ExtractFrameFromY4mFile(const char* y4m_file_name, + int width, + int height, + int frame_number, + uint8_t* result_frame) { int frame_size = GetI420FrameSize(width, height); int frame_offset = frame_number * frame_size; bool errors = false; @@ -170,20 +176,22 @@ bool ExtractFrameFromY4mFile(const char* y4m_file_name, int width, int height, } double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type, - const uint8* ref_frame, const uint8* test_frame, - int width, int height) { + const uint8_t* ref_frame, + const uint8_t* test_frame, + int width, + int height) { if (!ref_frame || !test_frame) return -1; else if (height < 0 || width < 0) return -1; int half_width = (width + 1) >> 1; int half_height = (height + 1) >> 1; - const uint8* src_y_a = ref_frame; - const uint8* src_u_a = src_y_a + width * height; - const uint8* src_v_a = src_u_a + half_width * half_height; - const uint8* src_y_b = test_frame; - const uint8* src_u_b = src_y_b + width * height; - const uint8* src_v_b = src_u_b + half_width * half_height; + const uint8_t* src_y_a = ref_frame; + const uint8_t* src_u_a = src_y_a + width * height; + const uint8_t* src_v_a = src_u_a + half_width * half_height; + const uint8_t* src_y_b = test_frame; + const uint8_t* src_u_b = src_y_b + width * height; + const uint8_t* src_v_b = src_u_b + half_width * half_height; int stride_y = width; int stride_uv = half_width; @@ -230,8 +238,8 @@ void RunAnalysis(const char* reference_file_name, const char* test_file_name, char line[STATS_LINE_LENGTH]; // Allocate buffers for test and reference frames. - uint8* test_frame = new uint8[size]; - uint8* reference_frame = new uint8[size]; + uint8_t* test_frame = new uint8_t[size]; + uint8_t* reference_frame = new uint8_t[size]; int previous_frame_number = -1; // While there are entries in the stats file. diff --git a/webrtc/tools/frame_analyzer/video_quality_analysis.h b/webrtc/tools/frame_analyzer/video_quality_analysis.h index 49b6f1210e..475b2fa197 100644 --- a/webrtc/tools/frame_analyzer/video_quality_analysis.h +++ b/webrtc/tools/frame_analyzer/video_quality_analysis.h @@ -62,8 +62,10 @@ void RunAnalysis(const char* reference_file_name, const char* test_file_name, // frames are exactly the same) will be 48. In the case of SSIM the max return // value will be 1. double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type, - const uint8* ref_frame, const uint8* test_frame, - int width, int height); + const uint8_t* ref_frame, + const uint8_t* test_frame, + int width, + int height); // Prints the result from the analysis in Chromium performance // numbers compatible format to stdout. If the results object contains no frames @@ -101,14 +103,19 @@ bool IsThereBarcodeError(std::string line); int ExtractDecodedFrameNumber(std::string line); // Extracts an I420 frame at position frame_number from the raw YUV file. -bool ExtractFrameFromYuvFile(const char* i420_file_name, int width, int height, - int frame_number, uint8* result_frame); +bool ExtractFrameFromYuvFile(const char* i420_file_name, + int width, + int height, + int frame_number, + uint8_t* result_frame); // Extracts an I420 frame at position frame_number from the Y4M file. The first // frame has corresponded |frame_number| 0. -bool ExtractFrameFromY4mFile(const char* i420_file_name, int width, int height, - int frame_number, uint8* result_frame); - +bool ExtractFrameFromY4mFile(const char* i420_file_name, + int width, + int height, + int frame_number, + uint8_t* result_frame); } // namespace test } // namespace webrtc diff --git a/webrtc/tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc b/webrtc/tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc index 3fb468bce6..bae145a78f 100644 --- a/webrtc/tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc +++ b/webrtc/tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc @@ -34,8 +34,8 @@ void CompareFiles(const char* reference_file_name, const char* test_file_name, int size = webrtc::test::GetI420FrameSize(width, height); // Allocate buffers for test and reference frames. - uint8* test_frame = new uint8[size]; - uint8* ref_frame = new uint8[size]; + uint8_t* test_frame = new uint8_t[size]; + uint8_t* ref_frame = new uint8_t[size]; bool read_result = true; for(int frame_counter = 0; frame_counter < MAX_NUM_FRAMES_PER_FILE; diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h index 3034c7e74a..d8754908bd 100644 --- a/webrtc/typedefs.h +++ b/webrtc/typedefs.h @@ -62,19 +62,8 @@ #define WEBRTC_CPU_DETECTION #endif -#if !defined(_MSC_VER) +// TODO(pbos): Use webrtc/base/basictypes.h instead to include fixed-size ints. #include -#else -// Define C99 equivalent types, since pre-2010 MSVC doesn't provide stdint.h. -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef __int64 int64_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; -#endif // Annotate a function indicating the caller must examine the return value. // Use like: diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc index 581a7685b2..0677093959 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc +++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.cc @@ -207,8 +207,8 @@ bool ConferenceTransport::DispatchPackets() { packet_queue_.pop_front(); } - int32 elapsed_time_ms = rtc::TimeSince(packet.send_time_ms_); - int32 sleep_ms = rtt_ms_ / 2 - elapsed_time_ms; + int32_t elapsed_time_ms = rtc::TimeSince(packet.send_time_ms_); + int32_t sleep_ms = rtt_ms_ / 2 - elapsed_time_ms; if (sleep_ms > 0) { // Every packet should be delayed by half of RTT. webrtc::SleepMs(sleep_ms); diff --git a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h index 602f07fa43..2194de9280 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h +++ b/webrtc/voice_engine/test/auto_test/fakes/conference_transport.h @@ -108,7 +108,7 @@ class ConferenceTransport: public webrtc::Transport { enum Type { Rtp, Rtcp, } type_; Packet() : len_(0) {} - Packet(Type type, const void* data, size_t len, uint32 time_ms) + Packet(Type type, const void* data, size_t len, uint32_t time_ms) : type_(type), len_(len), send_time_ms_(time_ms) { EXPECT_LE(len_, kMaxPacketSizeByte); memcpy(data_, data, len_); @@ -116,7 +116,7 @@ class ConferenceTransport: public webrtc::Transport { uint8_t data_[kMaxPacketSizeByte]; size_t len_; - uint32 send_time_ms_; + uint32_t send_time_ms_; }; static bool Run(void* transport) { diff --git a/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.cc b/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.cc index 9d7239e6d5..d4438a4e15 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.cc +++ b/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.cc @@ -14,7 +14,7 @@ namespace voetest { -void LoudestFilter::RemoveTimeoutStreams(uint32 time_ms) { +void LoudestFilter::RemoveTimeoutStreams(uint32_t time_ms) { auto it = stream_levels_.begin(); while (it != stream_levels_.end()) { if (rtc::TimeDiff(time_ms, it->second.last_time_ms) > @@ -41,7 +41,7 @@ unsigned int LoudestFilter::FindQuietestStream() { } bool LoudestFilter::ForwardThisPacket(const webrtc::RTPHeader& rtp_header) { - uint32 time_now_ms = rtc::Time(); + uint32_t time_now_ms = rtc::Time(); RemoveTimeoutStreams(time_now_ms); int source_ssrc = rtp_header.ssrc; diff --git a/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.h b/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.h index 79b0105c5a..73b801cc98 100644 --- a/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.h +++ b/webrtc/voice_engine/test/auto_test/fakes/loudest_filter.h @@ -29,21 +29,21 @@ class LoudestFilter { private: struct Status { - void Set(int audio_level, uint32 last_time_ms) { + void Set(int audio_level, uint32_t last_time_ms) { this->audio_level = audio_level; this->last_time_ms = last_time_ms; } int audio_level; - uint32 last_time_ms; + uint32_t last_time_ms; }; - void RemoveTimeoutStreams(uint32 time_ms); + void RemoveTimeoutStreams(uint32_t time_ms); unsigned int FindQuietestStream(); // Keeps the streams being forwarded in pair. std::map stream_levels_; - const int32 kStreamTimeOutMs = 5000; + const int32_t kStreamTimeOutMs = 5000; const size_t kMaxMixSize = 3; const int kInvalidAudioLevel = 128; }; diff --git a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc index d2407f30e4..f9d227188b 100644 --- a/webrtc/voice_engine/test/auto_test/voe_conference_test.cc +++ b/webrtc/voice_engine/test/auto_test/voe_conference_test.cc @@ -72,7 +72,7 @@ TEST(VoeConferenceTest, RttAndStartNtpTime) { const int kStatsRequestIntervalMs = 1000; const int kStatsBufferSize = 3; - uint32 deadline = rtc::TimeAfter(kMaxRunTimeMs); + uint32_t deadline = rtc::TimeAfter(kMaxRunTimeMs); // Run the following up to |kMaxRunTimeMs| milliseconds. int successive_pass = 0; webrtc::CallStatistics stats_1;