Provide move semantic for cricket::Codec and subclasses

The cricket::Codec class contains std containers like
std::map<std::string, std::string> and is expensive to copy. This CL
adds move constructors and move assignment operators for it and all
subclasses.

This CL also:
 * Implement functions with '= default' instead of doing it manually.
 * Makes codec::Matches symmetric. We currently don't check if the
   payload type of the callee is static, and might incorrectly return
   true in these cases.

BUG=None

Review-Url: https://codereview.webrtc.org/2481193002
Cr-Original-Commit-Position: refs/heads/master@{#14956}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 3663c523820c520806e5a9a0269063cc1adf3657
diff --git a/media/base/codec.cc b/media/base/codec.cc
index b920b14..66bc9ff 100644
--- a/media/base/codec.cc
+++ b/media/base/codec.cc
@@ -77,17 +77,10 @@
 Codec::Codec() : id(0), clockrate(0) {}
 
 Codec::Codec(const Codec& c) = default;
-
+Codec::Codec(Codec&& c) = default;
 Codec::~Codec() = default;
-
-Codec& Codec::operator=(const Codec& c) {
-  this->id = c.id;  // id is reserved in objective-c
-  name = c.name;
-  clockrate = c.clockrate;
-  params = c.params;
-  feedback_params = c.feedback_params;
-  return *this;
-}
+Codec& Codec::operator=(const Codec& c) = default;
+Codec& Codec::operator=(Codec&& c) = default;
 
 bool Codec::operator==(const Codec& c) const {
   return this->id == c.id &&  // id is reserved in objective-c
@@ -99,8 +92,9 @@
   // Match the codec id/name based on the typical static/dynamic name rules.
   // Matching is case-insensitive.
   const int kMaxStaticPayloadId = 95;
-  return (codec.id <= kMaxStaticPayloadId) ?
-      (id == codec.id) : (_stricmp(name.c_str(), codec.name.c_str()) == 0);
+  return (id <= kMaxStaticPayloadId || codec.id <= kMaxStaticPayloadId)
+             ? (id == codec.id)
+             : (_stricmp(name.c_str(), codec.name.c_str()) == 0);
 }
 
 bool Codec::GetParam(const std::string& name, std::string* out) const {
@@ -161,13 +155,9 @@
 }
 
 AudioCodec::AudioCodec(const AudioCodec& c) = default;
-
-AudioCodec& AudioCodec::operator=(const AudioCodec& c) {
-  Codec::operator=(c);
-  bitrate = c.bitrate;
-  channels = c.channels;
-  return *this;
-}
+AudioCodec::AudioCodec(AudioCodec&& c) = default;
+AudioCodec& AudioCodec::operator=(const AudioCodec& c) = default;
+AudioCodec& AudioCodec::operator=(AudioCodec&& c) = default;
 
 bool AudioCodec::operator==(const AudioCodec& c) const {
   return bitrate == c.bitrate && channels == c.channels && Codec::operator==(c);
@@ -220,11 +210,9 @@
 }
 
 VideoCodec::VideoCodec(const VideoCodec& c) = default;
-
-VideoCodec& VideoCodec::operator=(const VideoCodec& c) {
-  Codec::operator=(c);
-  return *this;
-}
+VideoCodec::VideoCodec(VideoCodec&& c) = default;
+VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default;
+VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default;
 
 bool VideoCodec::operator==(const VideoCodec& c) const {
   return Codec::operator==(c);
@@ -285,8 +273,9 @@
 }
 
 DataCodec::DataCodec(const DataCodec& c) = default;
-
+DataCodec::DataCodec(DataCodec&& c) = default;
 DataCodec& DataCodec::operator=(const DataCodec& c) = default;
+DataCodec& DataCodec::operator=(DataCodec&& c) = default;
 
 std::string DataCodec::ToString() const {
   std::ostringstream os;
diff --git a/media/base/codec.h b/media/base/codec.h
index 7a90375..bfbff23 100644
--- a/media/base/codec.h
+++ b/media/base/codec.h
@@ -74,6 +74,7 @@
   // Creates an empty codec.
   Codec();
   Codec(const Codec& c);
+  Codec(Codec&& c);
   virtual ~Codec();
 
   // Indicates if this codec is compatible with the specified codec.
@@ -100,6 +101,7 @@
   virtual webrtc::RtpCodecParameters ToCodecParameters() const;
 
   Codec& operator=(const Codec& c);
+  Codec& operator=(Codec&& c);
 
   bool operator==(const Codec& c) const;
 
@@ -121,6 +123,7 @@
   // Creates an empty codec.
   AudioCodec();
   AudioCodec(const AudioCodec& c);
+  AudioCodec(AudioCodec&& c);
   virtual ~AudioCodec() = default;
 
   // Indicates if this codec is compatible with the specified codec.
@@ -131,6 +134,7 @@
   webrtc::RtpCodecParameters ToCodecParameters() const override;
 
   AudioCodec& operator=(const AudioCodec& c);
+  AudioCodec& operator=(AudioCodec&& c);
 
   bool operator==(const AudioCodec& c) const;
 
@@ -147,11 +151,13 @@
   // Creates an empty codec.
   VideoCodec();
   VideoCodec(const VideoCodec& c);
+  VideoCodec(VideoCodec&& c);
   virtual ~VideoCodec() = default;
 
   std::string ToString() const;
 
   VideoCodec& operator=(const VideoCodec& c);
+  VideoCodec& operator=(VideoCodec&& c);
 
   bool operator==(const VideoCodec& c) const;
 
@@ -181,9 +187,11 @@
   DataCodec(int id, const std::string& name);
   DataCodec();
   DataCodec(const DataCodec& c);
+  DataCodec(DataCodec&& c);
   virtual ~DataCodec() = default;
 
   DataCodec& operator=(const DataCodec& c);
+  DataCodec& operator=(DataCodec&& c);
 
   std::string ToString() const;
 };
diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc
index 6aedab2..93300e4 100644
--- a/media/engine/webrtcvoiceengine_unittest.cc
+++ b/media/engine/webrtcvoiceengine_unittest.cc
@@ -3411,18 +3411,10 @@
   EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
       cricket::AudioCodec(96, "iLBC", 8000, 0, 1), nullptr));
   EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
-      cricket::AudioCodec(96, "PCMU", 8000, 0, 1), nullptr));
-  EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
-      cricket::AudioCodec(96, "PCMA", 8000, 0, 1), nullptr));
-  EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
-      cricket::AudioCodec(96, "G722", 8000, 0, 1), nullptr));
-  EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
       cricket::AudioCodec(96, "CN", 32000, 0, 1), nullptr));
   EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
       cricket::AudioCodec(96, "CN", 16000, 0, 1), nullptr));
   EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
-      cricket::AudioCodec(96, "CN", 8000, 0, 1), nullptr));
-  EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(
       cricket::AudioCodec(96, "telephone-event", 8000, 0, 1), nullptr));
   // Check codecs with an id by id.
   EXPECT_TRUE(cricket::WebRtcVoiceEngine::ToCodecInst(