Rename LOG_ERROR to RTC_LOG_ERROR Use the RTC-prefixed error logging macro name and update call sites. The LOG_ERROR macro was introduced in https://webrtc-review.googlesource.com/c/src/+/433760 as part of the WebRTC API layer. The name is quite generic, and has high chances of collision with others when the header is leaked / included with other libraries. Would be good to rename to something more specific, like RTC_LOG_ERROR or similar. Bug: webrtc:517208673 Change-Id: I489af1d968c3c251b7094f27468e2c4a07de7d80 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/476520 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Boris Tsirkin <btsirkin@meta.com> Cr-Commit-Position: refs/heads/main@{#47854}
diff --git a/api/rtc_error.h b/api/rtc_error.h index 2742b58..7710eeb 100644 --- a/api/rtc_error.h +++ b/api/rtc_error.h
@@ -265,10 +265,10 @@ // Example usage: // // if (failed) { -// return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) << "Yikes"); +// return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) << "Yikes"); // } // -#define LOG_ERROR(x) LogErrorImpl(x, LS_ERROR, __FILE__, __LINE__) +#define RTC_LOG_ERROR(x) LogErrorImpl(x, LS_ERROR, __FILE__, __LINE__) // RTCErrorOr<T> is the union of an RTCError object and a T object. RTCErrorOr // models the concept of an object that is either a usable value, or an error
diff --git a/api/rtc_error_unittest.cc b/api/rtc_error_unittest.cc index 2267384..47db720 100644 --- a/api/rtc_error_unittest.cc +++ b/api/rtc_error_unittest.cc
@@ -259,7 +259,7 @@ EXPECT_STREQ(error.message(), "StringyBuilder #2"); } -// Tests `LOG_ERROR`. +// Tests `RTC_LOG_ERROR`. TEST(RTCErrorOrTest, BuildStringLog) { class LogSinkImpl : public LogSink { public: @@ -270,7 +270,7 @@ } log_monitor; auto foo = [&]() { - return LOG_ERROR(RTCError::InvalidParameter("BuildStringLog")); + return RTC_LOG_ERROR(RTCError::InvalidParameter("BuildStringLog")); }; LogMessage::AddLogToStream(&log_monitor, LS_ERROR);
diff --git a/media/base/codec_list.cc b/media/base/codec_list.cc index a293244..8c61b89 100644 --- a/media/base/codec_list.cc +++ b/media/base/codec_list.cc
@@ -39,8 +39,8 @@ RTC_LOG(LS_ERROR) << "Duplicate payload type in codec list, " << codec << " and " << codecs[it->second] << " have the same ID"; - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Duplicate payload type in codec list"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Duplicate payload type in codec list"); } } } @@ -75,8 +75,8 @@ if (!(FromString(apt_it->second, &associated_pt))) { RTC_LOG(LS_ERROR) << "Non-numeric argument to rtx apt: " << codec << " apt=" << apt_it->second; - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Non-numeric argument to rtx apt parameter"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Non-numeric argument to rtx apt parameter"); } if (codec.id != PayloadType::NotSet() && pt_to_index.count(associated_pt) != 1) { @@ -84,7 +84,7 @@ << "Surprising condition: RTX codec APT not found: " << codec << " points to a PT that occurs " << pt_to_index.count(associated_pt) << " times"; - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "PT pointed to by rtx apt parameter does not exist"); }
diff --git a/media/base/media_engine.cc b/media/base/media_engine.cc index 27fbdbc..9840b71 100644 --- a/media/base/media_engine.cc +++ b/media/base/media_engine.cc
@@ -112,9 +112,9 @@ } } if (!codecFound) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Attempted to use an unsupported codec for layer " - << i); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Attempted to use an unsupported codec for layer " << i); } } if (rtp_parameters.encodings[i].scalability_mode) { @@ -133,7 +133,7 @@ } if (!scalabilityModeFound) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_MODIFICATION) << "Attempted to set RtpParameters scalabilityMode " "to an unsupported value for the current codecs."); @@ -148,7 +148,7 @@ } } if (!scalabilityModeFound) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_MODIFICATION) << "Attempted to set RtpParameters scalabilityMode " "to an unsupported value for the current codecs."); @@ -167,39 +167,41 @@ bool has_scale_resolution_down_to = false; for (size_t i = 0; i < rtp_parameters.encodings.size(); ++i) { if (rtp_parameters.encodings[i].bitrate_priority <= 0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) - << "Attempted to set RtpParameters bitrate_priority to " - "an invalid number. bitrate_priority must be > 0."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_RANGE) + << "Attempted to set RtpParameters bitrate_priority to " + "an invalid number. bitrate_priority must be > 0."); } if (rtp_parameters.encodings[i].scale_resolution_down_by && *rtp_parameters.encodings[i].scale_resolution_down_by < 1.0) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_RANGE) << "Attempted to set RtpParameters scale_resolution_down_by to an " "invalid value. scale_resolution_down_by must be >= 1.0"); } if (rtp_parameters.encodings[i].max_framerate && *rtp_parameters.encodings[i].max_framerate < 0.0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) - << "Attempted to set RtpParameters max_framerate to an " - "invalid value. max_framerate must be >= 0.0"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_RANGE) + << "Attempted to set RtpParameters max_framerate to an " + "invalid value. max_framerate must be >= 0.0"); } if (rtp_parameters.encodings[i].min_bitrate_bps && rtp_parameters.encodings[i].max_bitrate_bps) { if (*rtp_parameters.encodings[i].max_bitrate_bps < *rtp_parameters.encodings[i].min_bitrate_bps) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) - << "Attempted to set RtpParameters min bitrate " - "larger than max bitrate."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) + << "Attempted to set RtpParameters min bitrate " + "larger than max bitrate."); } } if (rtp_parameters.encodings[i].num_temporal_layers) { if (*rtp_parameters.encodings[i].num_temporal_layers < 1 || SafeGt(*rtp_parameters.encodings[i].num_temporal_layers, kMaxTemporalStreams)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) - << "Attempted to set RtpParameters " - "num_temporal_layers to an invalid number."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) + << "Attempted to set RtpParameters " + "num_temporal_layers to an invalid number."); } } @@ -207,32 +209,32 @@ has_scale_resolution_down_to = true; if (rtp_parameters.encodings[i].scale_resolution_down_to->width <= 0 || rtp_parameters.encodings[i].scale_resolution_down_to->height <= 0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "The resolution dimensions must be positive."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "The resolution dimensions must be positive."); } } if (!field_trials.IsEnabled("WebRTC-MixedCodecSimulcast")) { if (i > 0 && rtp_parameters.encodings[i - 1].codec != rtp_parameters.encodings[i].codec) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Attempted to use different codec values for " - "different encodings."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Attempted to use different codec values for " + "different encodings."); } } if (rtp_parameters.encodings[i].csrcs.has_value() && rtp_parameters.encodings[i].csrcs.value().size() > kRtpCsrcSize) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_RANGE) << "Attempted to set more than the maximum allowed number of CSRCs."); } if (i > 0 && rtp_parameters.encodings[i - 1].csrcs != rtp_parameters.encodings[i].csrcs) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Attempted to set different CSRCs for different " - "encodings."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Attempted to set different CSRCs for different " + "encodings."); } } @@ -242,9 +244,9 @@ return encoding.active && !encoding.scale_resolution_down_to.has_value(); })) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "If a resolution is specified on any encoding then " - "it must be specified on all encodings."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "If a resolution is specified on any encoding then " + "it must be specified on all encodings."); } // In a mixed codec scenario, we only support scalability modes without @@ -258,7 +260,7 @@ auto num_spatial_layers = ScalabilityModeStringToNumSpatialLayers(*scalability_mode); if (num_spatial_layers && *num_spatial_layers > 1) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::UNSUPPORTED_OPERATION) << "Attempted to use a scalabilityMode with spatial layers in " "a mixed codec scenario."); @@ -284,18 +286,18 @@ std::optional<Codec> send_codec, const FieldTrialsView& field_trials) { if (rtp_parameters.encodings.size() != old_rtp_parameters.encodings.size()) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_MODIFICATION) << "Attempted to set RtpParameters with different encoding count"); } if (rtp_parameters.rtcp != old_rtp_parameters.rtcp) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_MODIFICATION) << "Attempted to set RtpParameters with modified RTCP parameters"); } if (rtp_parameters.header_extensions != old_rtp_parameters.header_extensions) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_MODIFICATION) << "Attempted to set RtpParameters with modified header extensions"); } @@ -304,16 +306,17 @@ const RtpEncodingParameters& encoding2) { return encoding1.rid == encoding2.rid; })) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Attempted to change RID values in the encodings."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Attempted to change RID values in the encodings."); } if (!absl::c_equal(old_rtp_parameters.encodings, rtp_parameters.encodings, [](const RtpEncodingParameters& encoding1, const RtpEncodingParameters& encoding2) { return encoding1.ssrc == encoding2.ssrc; })) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Attempted to set RtpParameters with modified SSRC"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Attempted to set RtpParameters with modified SSRC"); } return CheckRtpParametersValues(rtp_parameters, send_codecs, send_codec,
diff --git a/pc/channel.cc b/pc/channel.cc index 218c876..7be8a00 100644 --- a/pc/channel.cc +++ b/pc/channel.cc
@@ -506,7 +506,7 @@ : (RTCError::InvalidState() << "No transport assigned."); if (!error.ok()) { error.string_builder() << " (mid=" << mid() << ")"; - return LOG_ERROR(error); + return RTC_LOG_ERROR(error); } if (payload_types) {
diff --git a/pc/codec_vendor.cc b/pc/codec_vendor.cc index 5ebc18b..47f4881 100644 --- a/pc/codec_vendor.cc +++ b/pc/codec_vendor.cc
@@ -1033,10 +1033,10 @@ if (!IsMediaContentOfType(current_content, media_description_options.type)) { // Can happen if the remote side re-uses a MID while recycling. - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Media type for content with mid='" - << current_content->mid() - << "' does not match expected type."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Media type for content with mid='" + << current_content->mid() + << "' does not match expected type."); } const MediaContentDescription* mcd = current_content->media_description(); @@ -1199,10 +1199,10 @@ if (!IsMediaContentOfType(current_content, media_description_options.type)) { // Can happen if the remote side re-uses a MID while recycling. - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Media type for content with mid='" - << current_content->mid() - << "' does not match expected type."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Media type for content with mid='" + << current_content->mid() + << "' does not match expected type."); } const MediaContentDescription* mcd = current_content->media_description();
diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc index 3ce3c26..b6d6639 100644 --- a/pc/data_channel_controller.cc +++ b/pc/data_channel_controller.cc
@@ -433,7 +433,7 @@ RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(!pc_->IsClosed()); if (!config.IsValid()) { - return LOG_ERROR(RTCError::InvalidParameter("Invalid DataChannelInit")); + return RTC_LOG_ERROR(RTCError::InvalidParameter("Invalid DataChannelInit")); } bool ready_to_send = false;
diff --git a/pc/ice_server_parsing.cc b/pc/ice_server_parsing.cc index e2b8726..67e626a 100644 --- a/pc/ice_server_parsing.cc +++ b/pc/ice_server_parsing.cc
@@ -194,21 +194,21 @@ if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present. std::vector<absl::string_view> transport_tokens = split(tokens[1], '='); if (transport_tokens[0] != kTransport) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::SYNTAX_ERROR) << "ICE server parsing failed: Invalid transport parameter key."); } if (transport_tokens.size() < 2) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::SYNTAX_ERROR) << "ICE server parsing failed: Transport parameter missing value."); } std::optional<ProtocolType> proto = StringToProto(transport_tokens[1]); if (!proto || (*proto != PROTO_UDP && *proto != PROTO_TCP)) { - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Transport parameter " - "should always be udp or tcp."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Transport parameter " + "should always be udp or tcp."); } turn_transport_type = *proto; transport_given_explicitly = true; @@ -218,7 +218,7 @@ GetServiceTypeAndHostnameFromUri(uri_without_transport); if (service_type == ServiceType::INVALID) { RTC_LOG(LS_ERROR) << "Invalid transport parameter in ICE URI: " << url; - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::SYNTAX_ERROR) << "ICE server parsing failed: Invalid transport parameter in ICE URI"); } @@ -230,7 +230,7 @@ if ((service_type == ServiceType::STUN || service_type == ServiceType::STUNS) && tokens.size() > 1) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::SYNTAX_ERROR) << "ICE server parsing failed: Invalid stun url with query parameters"); } @@ -251,23 +251,24 @@ if (hoststring.find('@') != absl::string_view::npos) { RTC_LOG(LS_ERROR) << "Invalid url with long deprecated user@host syntax: " << uri_without_transport; - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Invalid url with long " - "deprecated user@host syntax"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Invalid url with long " + "deprecated user@host syntax"); } auto [success, address, port] = ParseHostnameAndPortFromString(hoststring, default_port); if (!success) { RTC_LOG(LS_ERROR) << "Invalid hostname format: " << uri_without_transport; - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Invalid hostname format"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Invalid hostname format"); } if (port <= 0 || port > 0xffff) { RTC_LOG(LS_ERROR) << "Invalid port: " << port; - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Invalid port"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Invalid port"); } switch (service_type) { @@ -280,13 +281,14 @@ if (server.username.empty() || server.password.empty()) { // The WebRTC spec requires throwing an InvalidAccessError when username // or credential are ommitted; this is the native equivalent. - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "ICE server parsing failed: TURN server with empty " - "username or password"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "ICE server parsing failed: TURN server with empty " + "username or password"); } // RFC 8489 limits the size of the STUN username field to 509 characters. if (server.username.size() > kMaxTurnUsernameLength) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "ICE server parsing failed: TURN server username is too long"); } @@ -301,7 +303,7 @@ if (!IPFromString(address, &ip)) { // When hostname is set, the server address must be a // resolved ip address. - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "ICE server parsing failed: IceServer has hostname field " "set, but URI does not contain an IP address."); @@ -325,8 +327,9 @@ default: // We shouldn't get to this point with an invalid service_type, we should // have returned an error already. - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "ICE server parsing failed: Unexpected service type"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INTERNAL_ERROR) + << "ICE server parsing failed: Unexpected service type"); } return RTCError::OK(); } @@ -341,8 +344,8 @@ if (!server.urls.empty()) { for (const std::string& url : server.urls) { if (url.empty()) { - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Empty uri."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Empty uri."); } RTCError err = ParseIceServerUrl(server, url, stun_servers, turn_servers); @@ -359,8 +362,8 @@ return err; } } else { - return LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) - << "ICE server parsing failed: Empty uri."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::SYNTAX_ERROR) + << "ICE server parsing failed: Empty uri."); } } return RTCError::OK();
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index 9ee5195..2ec3050 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc
@@ -465,8 +465,8 @@ RTCError JsepTransportController::RollbackTransports_n() { bundles_.Rollback(); if (!transports_.RollbackTransports()) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to roll back transport state."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to roll back transport state."); } return RTCError::OK(); } @@ -750,9 +750,10 @@ JsepTransport* transport = GetJsepTransportForMid(content_info.mid()); if (!transport) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Could not find transport for m= section with mid='" - << content_info.mid() << "'"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "Could not find transport for m= section with mid='" + << content_info.mid() << "'"); } if (established_bundle_group && @@ -794,7 +795,7 @@ } if (!error.ok()) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "Failed to apply the description for m= section with mid='" << content_info.mid() << "': " << error.message());
diff --git a/pc/media_session.cc b/pc/media_session.cc index 227b888..b0ee166 100644 --- a/pc/media_session.cc +++ b/pc/media_session.cc
@@ -403,8 +403,8 @@ if (!AddStreamParams(media_description_options.sender_options, session_options.rtcp_cname, ssrc_generator, current_streams, offer, field_trials)) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to add stream parameters"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to add stream parameters"); } return CreateContentOffer(media_description_options, session_options, @@ -854,7 +854,7 @@ if (!offer_bundle.content_names().empty()) { offer->AddGroup(offer_bundle); if (!UpdateTransportInfoForBundle(offer_bundle, offer.get())) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INTERNAL_ERROR) << "CreateOffer failed to UpdateTransportInfoForBundle"); } @@ -889,8 +889,8 @@ const MediaSessionOptions& session_options, const SessionDescription* current_description) const { if (!offer) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Called without offer."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Called without offer."); } // Must have options for exactly as many sections as in the offer. @@ -1060,7 +1060,7 @@ // Share the same ICE credentials and crypto params across all contents, // as BUNDLE requires. if (!UpdateTransportInfoForBundle(answer_bundle, answer.get())) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INTERNAL_ERROR) << "CreateAnswer failed to UpdateTransportInfoForBundle."); } @@ -1407,7 +1407,7 @@ media_description_options.transport_options, current_description, !offer_content->rejected && bundle_transport == nullptr, ice_credentials); if (!transport) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INTERNAL_ERROR) << "Failed to create transport answer, transport is missing"); } @@ -1462,8 +1462,8 @@ ssrc_generator(), current_streams, answer_content.get(), transport_desc_factory_->trials())) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to set codecs in answer"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to set codecs in answer"); } RTC_DCHECK(codec_lookup_helper_->PayloadTypeSuggester()); if (!CreateMediaContentAnswer( @@ -1475,8 +1475,8 @@ offer_description->extmap_allow_mixed() ? RtpTransceiverIdDomain::kTwoByteAllowed : RtpTransceiverIdDomain::kOneByteOnly)) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to create answer"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to create answer"); } bool secure = bundle_transport ? bundle_transport->description.secure() @@ -1517,7 +1517,7 @@ media_description_options.transport_options, current_description, !offer_content->rejected && bundle_transport == nullptr, ice_credentials); if (!data_transport) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INTERNAL_ERROR) << "Failed to create transport answer, data transport is missing"); } @@ -1554,8 +1554,8 @@ offer_description->extmap_allow_mixed() ? RtpTransceiverIdDomain::kTwoByteAllowed : RtpTransceiverIdDomain::kOneByteOnly)) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to create answer"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to create answer"); } // Respond with sctpmap if the offer uses sctpmap. bool offer_uses_sctpmap = offer_data_description->use_sctpmap(); @@ -1614,9 +1614,9 @@ !offer_content->rejected && bundle_transport == nullptr, ice_credentials); if (!unsupported_transport) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to create transport answer, unsupported " - "transport is missing"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to create transport answer, unsupported " + "transport is missing"); } RTC_CHECK(IsMediaContentOfType(offer_content, MediaType::UNSUPPORTED));
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 6e6927a..a3d1c26 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc
@@ -275,9 +275,9 @@ // in new candidates being gathered. if (previous_ice_candidate_pool_size.has_value() && ice_candidate_pool_size != previous_ice_candidate_pool_size.value()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Can't change candidate pool size after calling " - "SetLocalDescription."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Can't change candidate pool size after calling " + "SetLocalDescription."); } return RTCError::OK(); @@ -330,8 +330,9 @@ configuration.stable_writable_connection_ping_interval_ms; if (configuration != modified_config) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Modifying the configuration in an unsupported way."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Modifying the configuration in an unsupported way."); } RTCError err = IceConfig(modified_config).IsValid(); @@ -847,26 +848,26 @@ RTC_DCHECK_RUN_ON(signaling_thread()); TRACE_EVENT0("webrtc", "PeerConnection::AddTrack"); if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } if (!track) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Track is null."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Track is null."); } if (!(track->kind() == MediaStreamTrackInterface::kAudioKind || track->kind() == MediaStreamTrackInterface::kVideoKind)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Track has invalid kind: " << track->kind()); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Track has invalid kind: " << track->kind()); } if (IsClosed()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "PeerConnection is closed."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) + << "PeerConnection is closed."); } if (rtp_manager()->FindSenderForTrack(track.get())) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Sender already exists for track " << track->id() - << "."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Sender already exists for track " << track->id() + << "."); } RTCErrorOr<scoped_refptr<RtpSenderInterface>> sender_or_error; if (IsUnifiedPlan()) { @@ -892,16 +893,16 @@ scoped_refptr<RtpSenderInterface> sender) { RTC_DCHECK_RUN_ON(signaling_thread()); if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } if (!sender) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Sender is null."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Sender is null."); } if (IsClosed()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "PeerConnection is closed."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) + << "PeerConnection is closed."); } if (IsUnifiedPlan()) { auto transceiver = FindTransceiverBySender(sender); @@ -931,9 +932,9 @@ } RTC_ALLOW_PLAN_B_DEPRECATION_END(); if (!removed) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Couldn't find sender " << sender->id() - << " to remove."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Couldn't find sender " << sender->id() + << " to remove."); } } sdp_handler_->UpdateNegotiationNeeded(); @@ -949,8 +950,8 @@ RTCErrorOr<scoped_refptr<RtpTransceiverInterface>> PeerConnection::AddTransceiver(scoped_refptr<MediaStreamTrackInterface> track) { if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } return AddTransceiver(track, RtpTransceiverInit()); @@ -961,14 +962,14 @@ const RtpTransceiverInit& init) { RTC_DCHECK_RUN_ON(signaling_thread()); if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } RTC_CHECK(IsUnifiedPlan()) << "AddTransceiver is only available with Unified Plan SdpSemantics"; if (!track) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "track is null"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "track is null"); } MediaType media_type; if (track->kind() == MediaStreamTrackInterface::kAudioKind) { @@ -976,8 +977,8 @@ } else if (track->kind() == MediaStreamTrackInterface::kVideoKind) { media_type = MediaType::VIDEO; } else { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Track kind is not audio or video"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Track kind is not audio or video"); } return AddTransceiver(media_type, track, init); } @@ -992,14 +993,14 @@ const RtpTransceiverInit& init) { RTC_DCHECK_RUN_ON(signaling_thread()); if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } RTC_CHECK(IsUnifiedPlan()) << "AddTransceiver is only available with Unified Plan SdpSemantics"; if (!(media_type == MediaType::AUDIO || media_type == MediaType::VIDEO)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "media type is not audio or video"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "media type is not audio or video"); } return AddTransceiver(media_type, nullptr, init); } @@ -1011,8 +1012,8 @@ bool update_negotiation_needed) { RTC_DCHECK_RUN_ON(signaling_thread()); if (!ConfiguredForMedia()) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) - << "Not configured for media"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_OPERATION) + << "Not configured for media"); } RTC_DCHECK( (media_type == MediaType::AUDIO || media_type == MediaType::VIDEO)); @@ -1028,24 +1029,25 @@ return !encoding.rid.empty(); }); if (num_rids > 0 && num_rids != init.send_encodings.size()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "RIDs must be provided for either all or none of the " - "send encodings."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "RIDs must be provided for either all or none of the " + "send encodings."); } if (num_rids > 0 && absl::c_any_of(init.send_encodings, [](const RtpEncodingParameters& encoding) { return !IsLegalRsidName(encoding.rid); })) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Invalid RID value provided."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Invalid RID value provided."); } if (absl::c_any_of(init.send_encodings, [](const RtpEncodingParameters& encoding) { return encoding.ssrc.has_value(); })) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) << "Attempted to set an unimplemented parameter of RtpParameters."); } @@ -1083,7 +1085,7 @@ } if (UnimplementedRtpParameterHasValue(parameters)) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) << "Attempted to set an unimplemented parameter of RtpParameters."); } @@ -1104,7 +1106,7 @@ if (result.type() == RTCErrorType::INVALID_MODIFICATION) { result.set_type(RTCErrorType::UNSUPPORTED_OPERATION); } - return LOG_ERROR(RTCError(result.type()) << result.message()); + return RTC_LOG_ERROR(RTCError(result.type()) << result.message()); } RTC_LOG(LS_INFO) << "Adding " << MediaTypeToString(media_type) @@ -1386,8 +1388,9 @@ TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); if (IsClosed()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "CreateDataChannelOrError: PeerConnection is closed."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_STATE) + << "CreateDataChannelOrError: PeerConnection is closed."); } bool first_datachannel = !data_channel_controller_.HasUsedDataChannels(); @@ -1515,8 +1518,8 @@ RTC_DCHECK_RUN_ON(signaling_thread()); TRACE_EVENT0("webrtc", "PeerConnection::SetConfiguration"); if (IsClosed()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "SetConfiguration: PeerConnection is closed."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) + << "SetConfiguration: PeerConnection is closed."); } const bool has_local_description = local_description() != nullptr; @@ -1532,9 +1535,9 @@ if (has_local_description && configuration.crypto_options != configuration_.crypto_options) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Can't change crypto_options after calling " - "SetLocalDescription."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Can't change crypto_options after calling " + "SetLocalDescription."); } // Create a new, configuration object whose peerconnection config @@ -1595,8 +1598,8 @@ new_states = transport_controller_n()->GetTransportStates_n(); return result; })) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to apply configuration to PortAllocator."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to apply configuration to PortAllocator."); } transport_controller_s()->SetTransportStates(std::move(new_states)); @@ -1634,36 +1637,36 @@ RTC_DCHECK_RUN_ON(worker_thread()); if (!call_) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "PeerConnection is closed."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) + << "PeerConnection is closed."); } const bool has_min = bitrate.min_bitrate_bps.has_value(); const bool has_start = bitrate.start_bitrate_bps.has_value(); const bool has_max = bitrate.max_bitrate_bps.has_value(); if (has_min && *bitrate.min_bitrate_bps < 0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "min_bitrate_bps <= 0"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "min_bitrate_bps <= 0"); } if (has_start) { if (has_min && *bitrate.start_bitrate_bps < *bitrate.min_bitrate_bps) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "start_bitrate_bps < min_bitrate_bps"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "start_bitrate_bps < min_bitrate_bps"); } else if (*bitrate.start_bitrate_bps < 0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "curent_bitrate_bps < 0"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "start_bitrate_bps < 0"); } } if (has_max) { if (has_start && *bitrate.max_bitrate_bps < *bitrate.start_bitrate_bps) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "max_bitrate_bps < start_bitrate_bps"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "max_bitrate_bps < start_bitrate_bps"); } else if (has_min && *bitrate.max_bitrate_bps < *bitrate.min_bitrate_bps) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "max_bitrate_bps < min_bitrate_bps"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "max_bitrate_bps < min_bitrate_bps"); } else if (*bitrate.max_bitrate_bps < 0) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "max_bitrate_bps < 0"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "max_bitrate_bps < 0"); } } @@ -3044,8 +3047,8 @@ transport_controller_n()->GetSctpTransport(mid); RTC_DCHECK(sctp_transport); if (!sctp_transport || !sctp_transport->Start(options)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) - << "Failed to start SCTP transport."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_MODIFICATION) + << "Failed to start SCTP transport."); } return RTCError::OK(); });
diff --git a/pc/rtp_sender.cc b/pc/rtp_sender.cc index 4c1a91f..8ba0ac9 100644 --- a/pc/rtp_sender.cc +++ b/pc/rtp_sender.cc
@@ -439,9 +439,9 @@ std::optional<RTCError> RtpSenderBase::ValidateAndMaybeUpdateInitParameters( const RtpParameters& parameters) { if (UnimplementedRtpParameterHasValue(parameters)) { - return LOG_ERROR(RTCError::UnsupportedParameter() - << "Attempted to set an unimplemented parameter of " - "RtpParameters."); + return RTC_LOG_ERROR(RTCError::UnsupportedParameter() + << "Attempted to set an unimplemented parameter of " + "RtpParameters."); } if (ssrc_ == 0) { auto result = CheckRtpParametersInvalidModificationAndValues( @@ -627,20 +627,21 @@ RTCError RtpSenderBase::CheckSetParameters(const RtpParameters& parameters) { RTC_DCHECK_RUN_ON(signaling_thread_); if (stopped_) { - return LOG_ERROR(RTCError::InvalidState() - << "Cannot set parameters on a stopped sender."); + return RTC_LOG_ERROR(RTCError::InvalidState() + << "Cannot set parameters on a stopped sender."); } if (!last_transaction_id_) { - return LOG_ERROR(RTCError::InvalidState() - << "Failed to set parameters since getParameters() has " - "never been called" - " on this sender"); + return RTC_LOG_ERROR( + RTCError::InvalidState() + << "Failed to set parameters since getParameters() has " + "never been called" + " on this sender"); } if (last_transaction_id_ != parameters.transaction_id) { - return LOG_ERROR(RTCError::InvalidModification() - << "Failed to set parameters since the transaction_id " - "doesn't match" - " the last value returned from getParameters()"); + return RTC_LOG_ERROR(RTCError::InvalidModification() + << "Failed to set parameters since the transaction_id " + "doesn't match" + " the last value returned from getParameters()"); } return RTCError::OK(); @@ -992,8 +993,8 @@ const std::vector<std::string>& rids) { RTC_DCHECK_RUN_ON(signaling_thread_); if (stopped_) { - return LOG_ERROR(RTCError::InvalidState() - << "Cannot disable encodings on a stopped sender."); + return RTC_LOG_ERROR(RTCError::InvalidState() + << "Cannot disable encodings on a stopped sender."); } bool all_already_disabled = true; @@ -1014,9 +1015,9 @@ [&rid](const RtpEncodingParameters& encoding) { return encoding.rid == rid; })) { - return LOG_ERROR(RTCError::InvalidParameter() - << "RID: " << rid - << " does not refer to a valid layer."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "RID: " << rid + << " does not refer to a valid layer."); } } @@ -1393,15 +1394,15 @@ const auto parameters = GetParametersInternal(); for (const auto& rid : rids) { if (rid.empty()) { - return LOG_ERROR(RTCError::InvalidParameter() - << "Attempted to specify an empty rid."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "Attempted to specify an empty rid."); } if (!absl::c_any_of(parameters.encodings, [&rid](const RtpEncodingParameters& parameters) { return parameters.rid == rid; })) { - return LOG_ERROR(RTCError::InvalidParameter() - << "Attempted to specify a rid not configured."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "Attempted to specify a rid not configured."); } } worker_thread_->PostTask(SafeTask(worker_safety_, [this, rids, ssrc = ssrc_] {
diff --git a/pc/rtp_transceiver.cc b/pc/rtp_transceiver.cc index 4f8a3e4..11108d3 100644 --- a/pc/rtp_transceiver.cc +++ b/pc/rtp_transceiver.cc
@@ -103,16 +103,18 @@ return IsSameRtpCodec(codec_capability, codec); }); })) { - return LOG_ERROR(RTCError::InvalidModification() - << "Invalid codec preferences: Missing codec from codec " - "capabilities."); + return RTC_LOG_ERROR( + RTCError::InvalidModification() + << "Invalid codec preferences: Missing codec from codec " + "capabilities."); } // If `codecs` only contains entries for RTX, RED, FEC or Comfort Noise, throw // InvalidModificationError. if (!HasAnyMediaCodec(codecs)) { - return LOG_ERROR(RTCError::InvalidModification() - << "Invalid codec preferences: codec list must have a non " - "RTX, RED, FEC or Comfort Noise entry."); + return RTC_LOG_ERROR( + RTCError::InvalidModification() + << "Invalid codec preferences: codec list must have a non " + "RTX, RED, FEC or Comfort Noise entry."); } return RTCError::OK(); } @@ -923,15 +925,15 @@ RTCError RtpTransceiver::SetDirectionWithError( RtpTransceiverDirection new_direction) { if (unified_plan_ && stopping()) { - return LOG_ERROR(RTCError::InvalidState() - << "Cannot set direction on a stopping transceiver."); + return RTC_LOG_ERROR(RTCError::InvalidState() + << "Cannot set direction on a stopping transceiver."); } if (new_direction == direction_) return RTCError::OK(); if (new_direction == RtpTransceiverDirection::kStopped) { - return LOG_ERROR(RTCError::InvalidParameter() - << "The set direction 'stopped' is invalid."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "The set direction 'stopped' is invalid."); } direction_ = new_direction; @@ -956,9 +958,9 @@ RTC_DCHECK_RUN_ON(thread_); if (sframe_enabled_.has_value() && sframe_enabled_.value() == false) { - return LOG_ERROR(RTCError::InvalidModification() - << "Cannot enable Sframe after it has been " - "disabled by a completed negotiation."); + return RTC_LOG_ERROR(RTCError::InvalidModification() + << "Cannot enable Sframe after it has been " + "disabled by a completed negotiation."); } sframe_enabled_ = true;
diff --git a/pc/rtp_transmission_manager.cc b/pc/rtp_transmission_manager.cc index c75534b..5213a0f 100644 --- a/pc/rtp_transmission_manager.cc +++ b/pc/rtp_transmission_manager.cc
@@ -169,9 +169,10 @@ RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(!IsUnifiedPlan()); if (stream_ids.size() > 1u) { - return LOG_ERROR(RTCError::UnsupportedOperation() - << "AddTrack with more than one stream is not supported " - "with Plan B semantics."); + return RTC_LOG_ERROR( + RTCError::UnsupportedOperation() + << "AddTrack with more than one stream is not supported " + "with Plan B semantics."); } std::vector<std::string> adjusted_stream_ids; if (stream_ids.empty()) { @@ -224,8 +225,8 @@ << MediaTypeToString(transceiver->media_type()) << " transceiver for AddTrack."; if (transceiver->stopping()) { - return LOG_ERROR(RTCError::InvalidParameter() - << "The existing transceiver is stopping."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "The existing transceiver is stopping."); } if (transceiver->direction() == RtpTransceiverDirection::kRecvOnly) {
diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 5bf6067..0a7b677 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc
@@ -412,13 +412,13 @@ if (!RtpTransceiverDirectionHasRecv(local_direction) && RtpTransceiverDirectionHasSend(remote_direction)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Incompatible receive direction"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Incompatible receive direction"); } if (!RtpTransceiverDirectionHasSend(local_direction) && RtpTransceiverDirectionHasRecv(remote_direction)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Incompatible send direction"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Incompatible send direction"); } } return RTCError::OK(); @@ -444,8 +444,8 @@ const MediaContentDescription* offer_media = offer_contents[i].media_description(); if (answer_media->sframe_enabled() && !offer_media->sframe_enabled()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kSframeNotInOffer); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kSframeNotInOffer); } } return RTCError::OK(); @@ -482,17 +482,17 @@ const TransportInfo* tinfo = desc->GetTransportInfoByName(mid); if (!media || !tinfo) { // Something is not right. - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kInvalidSdp); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kInvalidSdp); } if (dtls_enabled) { if (!tinfo->description.identity_fingerprint) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kSdpWithoutDtlsFingerprint); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kSdpWithoutDtlsFingerprint); } } else { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kSdpWithoutCrypto); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kSdpWithoutCrypto); } } return RTCError::OK(); @@ -540,17 +540,18 @@ flat_set<absl::string_view> mids; for (const ContentInfo& content : description.contents()) { if (content.mid().empty()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "A media section is missing a MID attribute."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "A media section is missing a MID attribute."); } if (content.mid().size() > kMidMaxSize) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "The MID attribute exceeds the maximum supported " - "length of 16 characters."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "The MID attribute exceeds the maximum supported " + "length of 16 characters."); } if (!mids.insert(content.mid()).second) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Duplicate a=mid value '" << content.mid() << "'."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Duplicate a=mid value '" << content.mid() + << "'."); } } return RTCError::OK(); @@ -570,7 +571,8 @@ << ". All codecs must share the same type, " "encoding name, clock rate and parameters."; - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) << sb.Release()); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << sb.Release()); } payload_to_codec_parameters.insert( std::make_pair(codec_parameters.payload_type, codec_parameters)); @@ -591,9 +593,9 @@ const ContentInfo* content_description = description.GetContentByName(content_name); if (!content_description) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "A BUNDLE group contains a MID='" << content_name - << "' matching no m= section."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "A BUNDLE group contains a MID='" + << content_name << "' matching no m= section."); } const MediaContentDescription* media_description = content_description->media_description(); @@ -624,7 +626,7 @@ if (existing_extension != id_to_extension.end() && !(extension.uri == existing_extension->second.uri && extension.encrypt == existing_extension->second.encrypt)) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "A BUNDLE group contains a codec collision for " "header extension id=" @@ -648,9 +650,9 @@ const ContentInfo* content_description = description.GetContentByName(content_name); if (!content_description) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "A BUNDLE group contains a MID='" << content_name - << "' matching no m= section."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "A BUNDLE group contains a MID='" + << content_name << "' matching no m= section."); } const MediaContentDescription* media_description = content_description->media_description(); @@ -687,10 +689,10 @@ return ext.uri == RtpExtension::kRidUri; }); if (it == extensions.end()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "The media section with MID='" << content.mid() - << "' negotiates simulcast but does not negotiate " - "the RID RTP header extension."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "The media section with MID='" << content.mid() + << "' negotiates simulcast but does not negotiate " + "the RID RTP header extension."); } } return RTCError::OK(); @@ -711,11 +713,11 @@ group.ssrcs.size() != 2) || (group.semantics == kSimSsrcGroupSemantics && group.ssrcs.size() > kMaxSimulcastStreams)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "The media section with MID='" << content.mid() - << "' has a ssrc-group with semantics " - << group.semantics - << " and an unexpected number of SSRCs."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "The media section with MID='" << content.mid() + << "' has a ssrc-group with semantics " << group.semantics + << " and an unexpected number of SSRCs."); } } } @@ -739,8 +741,8 @@ } const MediaContentDescription* media = content_info.media_description(); if (required_to_negotiate && !session_level_support && !media->cryptex()) { - return LOG_ERROR(RTCError::InvalidParameter() - << "cryptex required but not negotiated."); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "cryptex required but not negotiated."); } if (media->cryptex_level() == @@ -767,7 +769,8 @@ } } if (!first_media_content) { - return LOG_ERROR(RTCError::InvalidParameter() << "Inconsistent bundle"); + return RTC_LOG_ERROR(RTCError::InvalidParameter() + << "Inconsistent bundle"); } // If this content is the first non-datachannel media content in the // bundle, this is implicitly consistent. @@ -776,7 +779,7 @@ } if (first_media_content->media_description()->cryptex_level() != media->cryptex_level()) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError::InvalidParameter() << "The media section with MID='" << content_info.mid() << "' is not consistent with the cryptex level of its bundle"); @@ -800,7 +803,7 @@ if (type == MediaType::AUDIO || type == MediaType::VIDEO) { for (const auto& codec : media_description->codecs()) { if (!PayloadType::IsValid(codec.id, media_description->rtcp_mux())) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "The media section with MID='" << content.mid() << "' used an invalid payload type " << codec.id << " for codec '" @@ -2196,7 +2199,7 @@ error = UpdateSessionState(type, CS_LOCAL, local_description()->description(), bundle_groups_by_mid); if (!error.ok()) { - return LOG_ERROR(error); + return RTC_LOG_ERROR(error); } // Now that we have a local description, we can push down remote candidates. @@ -2204,8 +2207,8 @@ pending_ice_restarts_.clear(); if (session_error() != SessionError::kNone) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << GetSessionErrorMsg()); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << GetSessionErrorMsg()); } // Validate SSRCs, we do not allow duplicates. @@ -2216,8 +2219,9 @@ for (uint32_t ssrc : stream.ssrcs) { auto result = used_ssrcs.insert(ssrc); if (!result.second) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Duplicate ssrc " << ssrc << " is not allowed"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Duplicate ssrc " << ssrc + << " is not allowed"); } } } @@ -3639,9 +3643,10 @@ auto state = signaling_state(); if (state != PeerConnectionInterface::kHaveLocalOffer && state != PeerConnectionInterface::kHaveRemoteOffer) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "Called in wrong signalingState: " - << PeerConnectionInterface::AsString(signaling_state())); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_STATE) + << "Called in wrong signalingState: " + << PeerConnectionInterface::AsString(signaling_state())); } RTC_DCHECK_RUN_ON(signaling_thread()); RTC_DCHECK(IsUnifiedPlan()); @@ -4117,15 +4122,17 @@ RTC_DCHECK_EQ(SessionError::kNone, session_error()); if (!sdesc || !sdesc->description()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) << kInvalidSdp); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kInvalidSdp); } SdpType type = sdesc->GetType(); if ((source == CS_LOCAL && !ExpectSetLocalDescription(type)) || (source == CS_REMOTE && !ExpectSetRemoteDescription(type))) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_STATE) - << "Called in wrong state: " - << PeerConnectionInterface::AsString(signaling_state())); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_STATE) + << "Called in wrong state: " + << PeerConnectionInterface::AsString(signaling_state())); } RTCError error = ValidateMids(*sdesc->description()); @@ -4151,8 +4158,8 @@ // Verify ice-ufrag and ice-pwd. if (!VerifyIceUfragPwdPresent(sdesc->description(), bundle_groups_by_mid)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kSdpWithoutIceUfragPwd); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kSdpWithoutIceUfragPwd); } // Validate that there are no collisions of bundled payload types. @@ -4181,8 +4188,8 @@ if (!pc_->ValidateBundleSettings(sdesc->description(), bundle_groups_by_mid)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kBundleWithoutRtcpMux); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kBundleWithoutRtcpMux); } error = ValidatePayloadTypes(*sdesc->description()); @@ -4203,8 +4210,8 @@ if (!MediaSectionsHaveSameCount(*offer_desc, *sdesc->description()) || !MediaSectionsInSameOrder(*offer_desc, nullptr, *sdesc->description(), type)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kMlineMismatchInAnswer); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kMlineMismatchInAnswer); } } else { // The re-offers should respect the order of m= sections in current @@ -4228,8 +4235,8 @@ if (current_desc && !MediaSectionsInSameOrder(*current_desc, secondary_current_desc, *sdesc->description(), type)) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << kMlineMismatchInSubsequentOffer); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << kMlineMismatchInSubsequentOffer); } } @@ -4244,10 +4251,11 @@ if ((desc.type() == MediaType::AUDIO || desc.type() == MediaType::VIDEO) && desc.streams().size() > 1u) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Media section has more than one track specified " - "with a=ssrc lines which is not supported with " - "Unified Plan."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "Media section has more than one track specified " + "with a=ssrc lines which is not supported with " + "Unified Plan."); } } // Validate spec-simulcast which only works if the remote end negotiated the @@ -4303,9 +4311,10 @@ if (pc_->configuration()->bundle_policy == PeerConnectionInterface::kBundlePolicyMaxBundle && bundle_groups_by_mid.empty()) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "max-bundle configured but session description has " - "no BUNDLE group"); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_PARAMETER) + << "max-bundle configured but session description has " + "no BUNDLE group"); } } @@ -4375,8 +4384,8 @@ } else if (media_type == MediaType::UNSUPPORTED) { RTC_LOG(LS_INFO) << "Ignoring unsupported media type"; } else { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Unknown section type."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Unknown section type."); } } @@ -4449,8 +4458,8 @@ } if (!transceiver) { // This may happen normally when media sections are rejected. - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Transceiver not found based on m-line index"); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Transceiver not found based on m-line index"); } } else { RTC_DCHECK_EQ(source, CS_REMOTE); @@ -4514,7 +4523,7 @@ } if (transceiver->media_type() != media_desc->type()) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "Transceiver type does not match media description type."); } @@ -4594,8 +4603,8 @@ error.set_error_detail(RTCErrorDetailType::DATA_CHANNEL_FAILURE); pc_->DestroyDataChannelTransport(error); } else if (!pc_->CreateDataChannelTransport(content.mid())) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to create data channel."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to create data channel."); } return RTCError::OK(); } @@ -5179,8 +5188,8 @@ } else if (options.offer_to_receive_audio == 1) { AddUpToOneReceivingTransceiverOfType(MediaType::AUDIO); } else if (options.offer_to_receive_audio > 1) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) - << "offer_to_receive_audio > 1 is not supported."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) + << "offer_to_receive_audio > 1 is not supported."); } if (options.offer_to_receive_video == 0) { @@ -5188,8 +5197,8 @@ } else if (options.offer_to_receive_video == 1) { AddUpToOneReceivingTransceiverOfType(MediaType::VIDEO); } else if (options.offer_to_receive_video > 1) { - return LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) - << "offer_to_receive_video > 1 is not supported."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::UNSUPPORTED_PARAMETER) + << "offer_to_receive_video > 1 is not supported."); } return RTCError::OK(); @@ -5869,7 +5878,7 @@ return content_info.mid() == candidate->sdp_mid(); }); if (it == contents.end()) { - return LOG_ERROR( + return RTC_LOG_ERROR( RTCError(RTCErrorType::INVALID_PARAMETER) << "Mid " << candidate->sdp_mid() << " specified but no media section with that mid found."); @@ -5883,15 +5892,15 @@ if (mediacontent_index < content_size) { return &description->description()->contents()[mediacontent_index]; } else { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_RANGE) - << "Media line index (" << candidate->sdp_mline_index() - << ") out of range (number of mlines: " << content_size - << ")."); + return RTC_LOG_ERROR( + RTCError(RTCErrorType::INVALID_RANGE) + << "Media line index (" << candidate->sdp_mline_index() + << ") out of range (number of mlines: " << content_size << ")."); } } - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "Neither sdp_mline_index nor sdp_mid specified."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "Neither sdp_mline_index nor sdp_mid specified."); } RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) { @@ -5936,8 +5945,8 @@ const ContentInfo* data = GetFirstDataContent(&desc); if (data && !data->rejected && !pc_->CreateDataChannelTransport(data->mid())) { - return LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) - << "Failed to create data channel."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INTERNAL_ERROR) + << "Failed to create data channel."); } RTCError error = worker_tasks.Run();
diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index edecc6c..17fc42b 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc
@@ -1814,11 +1814,11 @@ payload_to_codec_parameters.find(codec_parameters.payload_type); if (existing_codec_parameters != payload_to_codec_parameters.end() && codec_parameters != existing_codec_parameters->second) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "A BUNDLE group contains a codec collision for " - << "payload_type='" << codec_parameters.payload_type - << ". All codecs must share the same type, " - << "encoding name, clock rate and parameters."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "A BUNDLE group contains a codec collision for " + << "payload_type='" << codec_parameters.payload_type + << "'. All codecs must share the same type, " + << "encoding name, clock rate and parameters."); } payload_to_codec_parameters.try_emplace(codec_parameters.payload_type, codec_parameters); @@ -1842,9 +1842,9 @@ const ContentInfo* content_description = description.GetContentByName(content_name); if (content_description == nullptr) { - return LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) - << "A BUNDLE group contains a MID='" << content_name - << "' matching no m= section."); + return RTC_LOG_ERROR(RTCError(RTCErrorType::INVALID_PARAMETER) + << "A BUNDLE group contains a MID='" + << content_name << "' matching no m= section."); } const MediaContentDescription* media_description = content_description->media_description();