Remove our stream << overloads from non-test build targets.

Most are removed entirely, but RtcErrorType, RtpTransceiverDirection, IPAddress and
SocketAddress are kept behind gtest's #ifdef UNIT_TEST.

Bug: webrtc:8982
Change-Id: I36db19891e7d25aeacb08b9a08aa2b4004765e70
Reviewed-on: https://webrtc-review.googlesource.com/64143
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22916}
diff --git a/api/audio_codecs/audio_format.cc b/api/audio_codecs/audio_format.cc
index 82c166f..9db5ce0 100644
--- a/api/audio_codecs/audio_format.cc
+++ b/api/audio_codecs/audio_format.cc
@@ -68,20 +68,6 @@
   swap(a.parameters, b.parameters);
 }
 
-std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf) {
-  os << "{name: " << saf.name;
-  os << ", clockrate_hz: " << saf.clockrate_hz;
-  os << ", num_channels: " << saf.num_channels;
-  os << ", parameters: {";
-  const char* sep = "";
-  for (const auto& kv : saf.parameters) {
-    os << sep << kv.first << ": " << kv.second;
-    sep = ", ";
-  }
-  os << "}}";
-  return os;
-}
-
 AudioCodecInfo::AudioCodecInfo(int sample_rate_hz,
                                size_t num_channels,
                                int bitrate_bps)
@@ -108,23 +94,4 @@
   RTC_DCHECK_GE(max_bitrate_bps, default_bitrate_bps);
 }
 
-std::ostream& operator<<(std::ostream& os, const AudioCodecInfo& aci) {
-  os << "{sample_rate_hz: " << aci.sample_rate_hz;
-  os << ", num_channels: " << aci.num_channels;
-  os << ", default_bitrate_bps: " << aci.default_bitrate_bps;
-  os << ", min_bitrate_bps: " << aci.min_bitrate_bps;
-  os << ", max_bitrate_bps: " << aci.max_bitrate_bps;
-  os << ", allow_comfort_noise: " << aci.allow_comfort_noise;
-  os << ", supports_network_adaption: " << aci.supports_network_adaption;
-  os << "}";
-  return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const AudioCodecSpec& acs) {
-  os << "{format: " << acs.format;
-  os << ", info: " << acs.info;
-  os << "}";
-  return os;
-}
-
 }  // namespace webrtc
diff --git a/api/audio_codecs/audio_format.h b/api/audio_codecs/audio_format.h
index 2a85c6f..553ab8f 100644
--- a/api/audio_codecs/audio_format.h
+++ b/api/audio_codecs/audio_format.h
@@ -12,7 +12,6 @@
 #define API_AUDIO_CODECS_AUDIO_FORMAT_H_
 
 #include <map>
-#include <ostream>
 #include <string>
 #include <utility>
 
@@ -62,7 +61,6 @@
 };
 
 void swap(SdpAudioFormat& a, SdpAudioFormat& b);
-std::ostream& operator<<(std::ostream& os, const SdpAudioFormat& saf);
 
 // Information about how an audio format is treated by the codec implementation.
 // Contains basic information, such as sample rate and number of channels, which
@@ -121,8 +119,6 @@
                                            // network conditions.
 };
 
-std::ostream& operator<<(std::ostream& os, const AudioCodecInfo& aci);
-
 // AudioCodecSpec ties an audio format to specific information about the codec
 // and its implementation.
 struct AudioCodecSpec {
@@ -136,8 +132,6 @@
   AudioCodecInfo info;
 };
 
-std::ostream& operator<<(std::ostream& os, const AudioCodecSpec& acs);
-
 }  // namespace webrtc
 
 #endif  // API_AUDIO_CODECS_AUDIO_FORMAT_H_
diff --git a/api/rtcerror.cc b/api/rtcerror.cc
index 5a8ba03..55ac15e 100644
--- a/api/rtcerror.cc
+++ b/api/rtcerror.cc
@@ -93,10 +93,6 @@
   }
 }
 
-std::ostream& operator<<(std::ostream& stream, RTCErrorType error) {
-  return stream << ToString(error);
-}
-
 // TODO(jonasolsson): Change to use absl::string_view when it's available.
 std::string ToString(RTCErrorType error) {
   int index = static_cast<int>(error);
diff --git a/api/rtcerror.h b/api/rtcerror.h
index d7dec29..c87ce91 100644
--- a/api/rtcerror.h
+++ b/api/rtcerror.h
@@ -11,7 +11,9 @@
 #ifndef API_RTCERROR_H_
 #define API_RTCERROR_H_
 
+#ifdef UNIT_TEST
 #include <ostream>
+#endif  // UNIT_TEST
 #include <string>
 #include <utility>  // For std::move.
 
@@ -143,10 +145,16 @@
 // error type.
 //
 // Only intended to be used for logging/disagnostics.
-std::ostream& operator<<(std::ostream& stream, RTCErrorType error);
-
 std::string ToString(RTCErrorType error);
 
+#ifdef UNIT_TEST
+inline std::ostream& operator<<(  // no-presubmit-check TODO(webrtc:8982)
+    std::ostream& stream,         // no-presubmit-check TODO(webrtc:8982)
+    RTCErrorType error) {
+  return stream << ToString(error);
+}
+#endif  // UNIT_TEST
+
 // Helper macro that can be used by implementations to create an error with a
 // message and log it. |message| should be a string literal or movable
 // std::string.
diff --git a/api/rtptransceiverinterface.h b/api/rtptransceiverinterface.h
index 7805579..7d2a1df 100644
--- a/api/rtptransceiverinterface.h
+++ b/api/rtptransceiverinterface.h
@@ -30,9 +30,6 @@
   kInactive
 };
 
-// This is provided as a debugging aid. The format of the output is unspecified.
-std::ostream& operator<<(std::ostream& os, RtpTransceiverDirection direction);
-
 // Structure for initializing an RtpTransceiver in a call to
 // PeerConnectionInterface::AddTransceiver.
 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit