diff --git a/api/stats/rtc_stats.h b/api/stats/rtc_stats.h index a5fae52c29..2af9768a99 100644 --- a/api/stats/rtc_stats.h +++ b/api/stats/rtc_stats.h @@ -158,7 +158,7 @@ class RTC_EXPORT RTCStats { const char this_class::kType[] = type_str; \ \ std::unique_ptr this_class::copy() const { \ - return std::unique_ptr(new this_class(*this)); \ + return std::make_unique(*this); \ } \ \ const char* this_class::type() const { return this_class::kType; } \ @@ -189,7 +189,7 @@ class RTC_EXPORT RTCStats { const char this_class::kType[] = type_str; \ \ std::unique_ptr this_class::copy() const { \ - return std::unique_ptr(new this_class(*this)); \ + return std::make_unique(*this); \ } \ \ const char* this_class::type() const { return this_class::kType; } \ diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc index 084bd118ec..15e72c4530 100644 --- a/pc/rtc_stats_collector.cc +++ b/pc/rtc_stats_collector.cc @@ -360,10 +360,10 @@ std::unique_ptr CodecStatsFromRtpCodecParameters( RTC_DCHECK_LE(codec_params.payload_type, 127); RTC_DCHECK(codec_params.clock_rate); uint32_t payload_type = static_cast(codec_params.payload_type); - std::unique_ptr codec_stats( - new RTCCodecStats(RTCCodecStatsIDFromTransportAndCodecParameters( - direction, transport_id, codec_params), - timestamp_us)); + std::unique_ptr codec_stats(std::make_unique( + RTCCodecStatsIDFromTransportAndCodecParameters(direction, transport_id, + codec_params), + timestamp_us)); codec_stats->payload_type = payload_type; codec_stats->mime_type = codec_params.mime_type(); if (codec_params.clock_rate) { @@ -846,9 +846,11 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us, if (!stats) { std::unique_ptr candidate_stats; if (is_local) - candidate_stats.reset(new RTCLocalIceCandidateStats(id, timestamp_us)); + candidate_stats = + std::make_unique(id, timestamp_us); else - candidate_stats.reset(new RTCRemoteIceCandidateStats(id, timestamp_us)); + candidate_stats = + std::make_unique(id, timestamp_us); candidate_stats->transport_id = transport_id; if (is_local) { candidate_stats->network_type = @@ -920,7 +922,7 @@ ProduceMediaStreamTrackStatsFromVoiceSenderInfo( const cricket::VoiceSenderInfo& voice_sender_info, int attachment_id) { std::unique_ptr audio_track_stats( - new RTCMediaStreamTrackStats( + std::make_unique( RTCMediaStreamTrackStatsIDFromDirectionAndAttachment( kDirectionOutbound, attachment_id), timestamp_us, RTCMediaStreamTrackKind::kAudio)); @@ -955,7 +957,7 @@ ProduceMediaStreamTrackStatsFromVoiceReceiverInfo( // Since receiver tracks can't be reattached, we use the SSRC as // an attachment identifier. std::unique_ptr audio_track_stats( - new RTCMediaStreamTrackStats( + std::make_unique( RTCMediaStreamTrackStatsIDFromDirectionAndAttachment( kDirectionInbound, attachment_id), timestamp_us, RTCMediaStreamTrackKind::kAudio)); @@ -1009,7 +1011,7 @@ ProduceMediaStreamTrackStatsFromVideoSenderInfo( const cricket::VideoSenderInfo& video_sender_info, int attachment_id) { std::unique_ptr video_track_stats( - new RTCMediaStreamTrackStats( + std::make_unique( RTCMediaStreamTrackStatsIDFromDirectionAndAttachment( kDirectionOutbound, attachment_id), timestamp_us, RTCMediaStreamTrackKind::kVideo)); @@ -1038,7 +1040,7 @@ ProduceMediaStreamTrackStatsFromVideoReceiverInfo( const cricket::VideoReceiverInfo& video_receiver_info, int attachment_id) { std::unique_ptr video_track_stats( - new RTCMediaStreamTrackStats( + std::make_unique( RTCMediaStreamTrackStatsIDFromDirectionAndAttachment( kDirectionInbound, attachment_id), timestamp_us, RTCMediaStreamTrackKind::kVideo)); @@ -1667,8 +1669,8 @@ void RTCStatsCollector::ProduceDataChannelStats_s( std::vector data_stats = pc_->GetDataChannelStats(); for (const auto& stats : data_stats) { std::unique_ptr data_channel_stats( - new RTCDataChannelStats("D" + rtc::ToString(stats.internal_id), - timestamp_us)); + std::make_unique( + "D" + rtc::ToString(stats.internal_id), timestamp_us)); data_channel_stats->label = std::move(stats.label); data_channel_stats->protocol = std::move(stats.protocol); data_channel_stats->data_channel_identifier = stats.id; @@ -1699,7 +1701,7 @@ void RTCStatsCollector::ProduceIceCandidateAndPairStats_n( for (const auto& info : channel_stats.ice_transport_stats.connection_infos) { std::unique_ptr candidate_pair_stats( - new RTCIceCandidatePairStats( + std::make_unique( RTCIceCandidatePairStatsIDFromConnectionInfo(info), timestamp_us)); @@ -1815,7 +1817,8 @@ void RTCStatsCollector::ProduceMediaStreamStats_s( // Build stats for each stream ID known. for (auto& it : track_ids) { std::unique_ptr stream_stats( - new RTCMediaStreamStats("DEPRECATED_S" + it.first, timestamp_us)); + std::make_unique("DEPRECATED_S" + it.first, + timestamp_us)); stream_stats->stream_identifier = it.first; stream_stats->track_ids = it.second; report->AddStats(std::move(stream_stats)); @@ -1953,7 +1956,7 @@ void RTCStatsCollector::ProducePeerConnectionStats_s( rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls; std::unique_ptr stats( - new RTCPeerConnectionStats("P", timestamp_us)); + std::make_unique("P", timestamp_us)); stats->data_channels_opened = internal_record_.data_channels_opened; stats->data_channels_closed = internal_record_.data_channels_closed; report->AddStats(std::move(stats)); @@ -2200,9 +2203,10 @@ void RTCStatsCollector::ProduceTransportStats_n( for (const cricket::TransportChannelStats& channel_stats : transport_stats.channel_stats) { std::unique_ptr transport_stats( - new RTCTransportStats(RTCTransportStatsIDFromTransportChannel( - transport_name, channel_stats.component), - timestamp_us)); + std::make_unique( + RTCTransportStatsIDFromTransportChannel(transport_name, + channel_stats.component), + timestamp_us)); transport_stats->packets_sent = channel_stats.ice_transport_stats.packets_sent; transport_stats->packets_received = diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc index 321d8db86f..b1b081fcff 100644 --- a/stats/rtcstats_objects.cc +++ b/stats/rtcstats_objects.cc @@ -335,7 +335,7 @@ RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id, : RTCIceCandidateStats(std::move(id), timestamp_us, false) {} std::unique_ptr RTCLocalIceCandidateStats::copy() const { - return std::unique_ptr(new RTCLocalIceCandidateStats(*this)); + return std::make_unique(*this); } const char* RTCLocalIceCandidateStats::type() const { @@ -353,7 +353,7 @@ RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id, : RTCIceCandidateStats(std::move(id), timestamp_us, true) {} std::unique_ptr RTCRemoteIceCandidateStats::copy() const { - return std::unique_ptr(new RTCRemoteIceCandidateStats(*this)); + return std::make_unique(*this); } const char* RTCRemoteIceCandidateStats::type() const {