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

This reverts commit d7ee72041f882c023c73e27a7436c626c4e43604.

Reason for revert: Broke downstream build which was using SdpAudioFormat operator<<

Original change's description:
> Reland "Remove our stream << overloads from non-test build targets."
> 
> This is a reland of c841d18d257ba8e4ed7d77d105e3c46006bb1e7e
> 
> Original change's description:
> > 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}
> 
> TBR=deadbeef@webrtc.org,kwiberg@webrtc.org,asapersson@webrtc.org,jonasolsson@webrtc.org,benwright@webrtc.org
> 
> Bug: webrtc:8982
> Change-Id: Ibe08c6270e5e693eb661a6ce9e8f074b34ef8123
> Reviewed-on: https://webrtc-review.googlesource.com/71161
> Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
> Reviewed-by: Jonas Olsson <jonasolsson@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22949}

TBR=deadbeef@webrtc.org,kwiberg@webrtc.org,asapersson@webrtc.org,jonasolsson@webrtc.org,benwright@webrtc.org

Change-Id: I3c2b18ec2877d68a522ecbae7a2955c4eecf36df
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8982
Reviewed-on: https://webrtc-review.googlesource.com/71446
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22963}
diff --git a/api/audio_codecs/audio_format.cc b/api/audio_codecs/audio_format.cc
index 9db5ce0..82c166f 100644
--- a/api/audio_codecs/audio_format.cc
+++ b/api/audio_codecs/audio_format.cc
@@ -68,6 +68,20 @@
   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)
@@ -94,4 +108,23 @@
   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 553ab8f..2a85c6f 100644
--- a/api/audio_codecs/audio_format.h
+++ b/api/audio_codecs/audio_format.h
@@ -12,6 +12,7 @@
 #define API_AUDIO_CODECS_AUDIO_FORMAT_H_
 
 #include <map>
+#include <ostream>
 #include <string>
 #include <utility>
 
@@ -61,6 +62,7 @@
 };
 
 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
@@ -119,6 +121,8 @@
                                            // 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 {
@@ -132,6 +136,8 @@
   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 55ac15e..5a8ba03 100644
--- a/api/rtcerror.cc
+++ b/api/rtcerror.cc
@@ -93,6 +93,10 @@
   }
 }
 
+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 c87ce91..d7dec29 100644
--- a/api/rtcerror.h
+++ b/api/rtcerror.h
@@ -11,9 +11,7 @@
 #ifndef API_RTCERROR_H_
 #define API_RTCERROR_H_
 
-#ifdef UNIT_TEST
 #include <ostream>
-#endif  // UNIT_TEST
 #include <string>
 #include <utility>  // For std::move.
 
@@ -145,15 +143,9 @@
 // error type.
 //
 // Only intended to be used for logging/disagnostics.
-std::string ToString(RTCErrorType error);
+std::ostream& operator<<(std::ostream& stream, 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
+std::string ToString(RTCErrorType error);
 
 // 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
diff --git a/api/rtptransceiverinterface.h b/api/rtptransceiverinterface.h
index 7d2a1df..7805579 100644
--- a/api/rtptransceiverinterface.h
+++ b/api/rtptransceiverinterface.h
@@ -30,6 +30,9 @@
   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
diff --git a/common_types.h b/common_types.h
index 580f83a..ae47811 100644
--- a/common_types.h
+++ b/common_types.h
@@ -223,6 +223,16 @@
   }
 
   bool operator!=(const CodecInst& other) const { return !(*this == other); }
+
+  friend std::ostream& operator<<(std::ostream& os, const CodecInst& ci) {
+    os << "{pltype: " << ci.pltype;
+    os << ", plname: " << ci.plname;
+    os << ", plfreq: " << ci.plfreq;
+    os << ", pacsize: " << ci.pacsize;
+    os << ", channels: " << ci.channels;
+    os << ", rate: " << ci.rate << "}";
+    return os;
+  }
 };
 
 // RTP
diff --git a/media/base/codec.h b/media/base/codec.h
index 7bbb7db..30844c7 100644
--- a/media/base/codec.h
+++ b/media/base/codec.h
@@ -149,6 +149,28 @@
   }
 };
 
+inline std::ostream& operator<<(std::ostream& os, const AudioCodec& ac) {
+  os << "{id: " << ac.id;
+  os << ", name: " << ac.name;
+  os << ", clockrate: " << ac.clockrate;
+  os << ", bitrate: " << ac.bitrate;
+  os << ", channels: " << ac.channels;
+  os << ", params: {";
+  const char* sep = "";
+  for (const auto& kv : ac.params) {
+    os << sep << kv.first << ": " << kv.second;
+    sep = ", ";
+  }
+  os << "}, feedback_params: {";
+  sep = "";
+  for (const FeedbackParam& fp : ac.feedback_params.params()) {
+    os << sep << fp.id() << ": " << fp.param();
+    sep = ", ";
+  }
+  os << "}}";
+  return os;
+}
+
 struct VideoCodec : public Codec {
   // Creates a codec with the given parameters.
   VideoCodec(int id, const std::string& name);
diff --git a/modules/video_coding/codecs/h264/include/h264_globals.h b/modules/video_coding/codecs/h264/include/h264_globals.h
index bfeba67..365dbca 100644
--- a/modules/video_coding/codecs/h264/include/h264_globals.h
+++ b/modules/video_coding/codecs/h264/include/h264_globals.h
@@ -53,6 +53,11 @@
   return "";
 }
 
+inline std::ostream& operator<<(std::ostream& stream,
+                                H264PacketizationMode mode) {
+  return stream << ToString(mode);
+}
+
 struct NaluInfo {
   uint8_t type;
   int sps_id;
diff --git a/pc/rtpmediautils.h b/pc/rtpmediautils.h
index 5f02d89..6de6f8f 100644
--- a/pc/rtpmediautils.h
+++ b/pc/rtpmediautils.h
@@ -44,14 +44,6 @@
 // Returns an unspecified string representation of the given direction.
 const char* RtpTransceiverDirectionToString(RtpTransceiverDirection direction);
 
-#ifdef UNIT_TEST
-inline std::ostream& operator<<(  // no-presubmit-check TODO(webrtc:8982)
-    std::ostream& os,             // no-presubmit-check TODO(webrtc:8982)
-    RtpTransceiverDirection direction) {
-  return os << RtpTransceiverDirectionToString(direction);
-}
-#endif  // UNIT_TEST
-
 }  // namespace webrtc
 
 #endif  // PC_RTPMEDIAUTILS_H_
diff --git a/pc/rtptransceiver.cc b/pc/rtptransceiver.cc
index 37770b5..41ee487 100644
--- a/pc/rtptransceiver.cc
+++ b/pc/rtptransceiver.cc
@@ -16,6 +16,10 @@
 
 namespace webrtc {
 
+std::ostream& operator<<(std::ostream& os, RtpTransceiverDirection direction) {
+  return os << RtpTransceiverDirectionToString(direction);
+}
+
 RtpTransceiver::RtpTransceiver(cricket::MediaType media_type)
     : unified_plan_(false), media_type_(media_type) {
   RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO ||
diff --git a/rtc_base/ipaddress.cc b/rtc_base/ipaddress.cc
index e6a02c4..3f7698a 100644
--- a/rtc_base/ipaddress.cc
+++ b/rtc_base/ipaddress.cc
@@ -120,6 +120,11 @@
   return false;
 }
 
+std::ostream& operator<<(std::ostream& os, const IPAddress& ip) {
+  os << ip.ToString();
+  return os;
+}
+
 in6_addr IPAddress::ipv6_address() const {
   return u_.ip6;
 }
@@ -211,6 +216,10 @@
   return *this;
 }
 
+std::ostream& operator<<(std::ostream& os, const InterfaceAddress& ip) {
+  return os << ip.ToString();
+}
+
 std::string InterfaceAddress::ToString() const {
   std::string result = IPAddress::ToString();
 
diff --git a/rtc_base/ipaddress.h b/rtc_base/ipaddress.h
index c965cf1..aa8bb1a 100644
--- a/rtc_base/ipaddress.h
+++ b/rtc_base/ipaddress.h
@@ -83,13 +83,7 @@
   bool operator!=(const IPAddress& other) const;
   bool operator <(const IPAddress& other) const;
   bool operator >(const IPAddress& other) const;
-
-#ifdef UNIT_TEST
-  inline std::ostream& operator<<(  // no-presubmit-check TODO(webrtc:8982)
-      std::ostream& os) {           // no-presubmit-check TODO(webrtc:8982)
-    return os << ToString();
-  }
-#endif  // UNIT_TEST
+  friend std::ostream& operator<<(std::ostream& os, const IPAddress& addr);
 
   int family() const { return family_; }
   in_addr ipv4_address() const;
@@ -147,6 +141,8 @@
   bool operator!=(const InterfaceAddress& other) const;
 
   int ipv6_flags() const { return ipv6_flags_; }
+  friend std::ostream& operator<<(std::ostream& os,
+                                  const InterfaceAddress& addr);
 
   std::string ToString() const;
 
diff --git a/rtc_base/socketaddress.cc b/rtc_base/socketaddress.cc
index a58c001..bddb7bc 100644
--- a/rtc_base/socketaddress.cc
+++ b/rtc_base/socketaddress.cc
@@ -199,6 +199,11 @@
   return true;
 }
 
+std::ostream& operator<<(std::ostream& os, const SocketAddress& addr) {
+  os << addr.HostAsURIString() << ":" << addr.port();
+  return os;
+}
+
 bool SocketAddress::IsAnyIP() const {
   return IPIsAny(ip_);
 }
diff --git a/rtc_base/socketaddress.h b/rtc_base/socketaddress.h
index 90919c2..d58eed8 100644
--- a/rtc_base/socketaddress.h
+++ b/rtc_base/socketaddress.h
@@ -13,9 +13,6 @@
 
 #include <iosfwd>
 #include <string>
-#ifdef UNIT_TEST
-#include <ostream>  // no-presubmit-check TODO(webrtc:8982)
-#endif              // UNIT_TEST
 #include <vector>
 #include "rtc_base/basictypes.h"
 #include "rtc_base/ipaddress.h"
@@ -129,12 +126,7 @@
   // Parses hostname:port and [hostname]:port.
   bool FromString(const std::string& str);
 
-#ifdef UNIT_TEST
-  inline std::ostream& operator<<(  // no-presubmit-check TODO(webrtc:8982)
-      std::ostream& os) {           // no-presubmit-check TODO(webrtc:8982)
-    return os << HostAsURIString() << ":" << port();
-  }
-#endif  // UNIT_TEST
+  friend std::ostream& operator<<(std::ostream& os, const SocketAddress& addr);
 
   // Determines whether this represents a missing / any IP address.
   // That is, 0.0.0.0 or ::.