Adding getParameters/setParameters APIs to RtpReceiver.

This is similar to how a "receive" method is used to apply
RtpParameters to an RtpReceiver in ORTC. Currently, SetParameters
doesn't allow changing the parameters, so the main use of the API is
to retrieve the set of configured codecs. But other uses will likely
be made possible in the future.

R=glaznev@webrtc.org, pthatcher@webrtc.org, tkchin@webrtc.org

Review URL: https://codereview.webrtc.org/1917193008 .

Cr-Commit-Position: refs/heads/master@{#12761}
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index 67c16ec..7a0d1ef 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -1533,24 +1533,49 @@
   InvokeOnWorker(Bind(&SetRawAudioSink_w, media_channel(), ssrc, &sink));
 }
 
-webrtc::RtpParameters VoiceChannel::GetRtpParameters(uint32_t ssrc) const {
+webrtc::RtpParameters VoiceChannel::GetRtpSendParameters(uint32_t ssrc) const {
   return worker_thread()->Invoke<webrtc::RtpParameters>(
-      Bind(&VoiceChannel::GetRtpParameters_w, this, ssrc));
+      Bind(&VoiceChannel::GetRtpSendParameters_w, this, ssrc));
 }
 
-webrtc::RtpParameters VoiceChannel::GetRtpParameters_w(uint32_t ssrc) const {
-  return media_channel()->GetRtpParameters(ssrc);
+webrtc::RtpParameters VoiceChannel::GetRtpSendParameters_w(
+    uint32_t ssrc) const {
+  return media_channel()->GetRtpSendParameters(ssrc);
 }
 
-bool VoiceChannel::SetRtpParameters(uint32_t ssrc,
-                                    const webrtc::RtpParameters& parameters) {
+bool VoiceChannel::SetRtpSendParameters(
+    uint32_t ssrc,
+    const webrtc::RtpParameters& parameters) {
   return InvokeOnWorker(
-      Bind(&VoiceChannel::SetRtpParameters_w, this, ssrc, parameters));
+      Bind(&VoiceChannel::SetRtpSendParameters_w, this, ssrc, parameters));
 }
 
-bool VoiceChannel::SetRtpParameters_w(uint32_t ssrc,
-                                      webrtc::RtpParameters parameters) {
-  return media_channel()->SetRtpParameters(ssrc, parameters);
+bool VoiceChannel::SetRtpSendParameters_w(uint32_t ssrc,
+                                          webrtc::RtpParameters parameters) {
+  return media_channel()->SetRtpSendParameters(ssrc, parameters);
+}
+
+webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters(
+    uint32_t ssrc) const {
+  return worker_thread()->Invoke<webrtc::RtpParameters>(
+      Bind(&VoiceChannel::GetRtpReceiveParameters_w, this, ssrc));
+}
+
+webrtc::RtpParameters VoiceChannel::GetRtpReceiveParameters_w(
+    uint32_t ssrc) const {
+  return media_channel()->GetRtpReceiveParameters(ssrc);
+}
+
+bool VoiceChannel::SetRtpReceiveParameters(
+    uint32_t ssrc,
+    const webrtc::RtpParameters& parameters) {
+  return InvokeOnWorker(
+      Bind(&VoiceChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
+}
+
+bool VoiceChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
+                                             webrtc::RtpParameters parameters) {
+  return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
 }
 
 bool VoiceChannel::GetStats(VoiceMediaInfo* stats) {
@@ -1843,24 +1868,49 @@
                              ssrc, mute, options));
 }
 
-webrtc::RtpParameters VideoChannel::GetRtpParameters(uint32_t ssrc) const {
+webrtc::RtpParameters VideoChannel::GetRtpSendParameters(uint32_t ssrc) const {
   return worker_thread()->Invoke<webrtc::RtpParameters>(
-      Bind(&VideoChannel::GetRtpParameters_w, this, ssrc));
+      Bind(&VideoChannel::GetRtpSendParameters_w, this, ssrc));
 }
 
-webrtc::RtpParameters VideoChannel::GetRtpParameters_w(uint32_t ssrc) const {
-  return media_channel()->GetRtpParameters(ssrc);
+webrtc::RtpParameters VideoChannel::GetRtpSendParameters_w(
+    uint32_t ssrc) const {
+  return media_channel()->GetRtpSendParameters(ssrc);
 }
 
-bool VideoChannel::SetRtpParameters(uint32_t ssrc,
-                                    const webrtc::RtpParameters& parameters) {
+bool VideoChannel::SetRtpSendParameters(
+    uint32_t ssrc,
+    const webrtc::RtpParameters& parameters) {
   return InvokeOnWorker(
-      Bind(&VideoChannel::SetRtpParameters_w, this, ssrc, parameters));
+      Bind(&VideoChannel::SetRtpSendParameters_w, this, ssrc, parameters));
 }
 
-bool VideoChannel::SetRtpParameters_w(uint32_t ssrc,
-                                      webrtc::RtpParameters parameters) {
-  return media_channel()->SetRtpParameters(ssrc, parameters);
+bool VideoChannel::SetRtpSendParameters_w(uint32_t ssrc,
+                                          webrtc::RtpParameters parameters) {
+  return media_channel()->SetRtpSendParameters(ssrc, parameters);
+}
+
+webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters(
+    uint32_t ssrc) const {
+  return worker_thread()->Invoke<webrtc::RtpParameters>(
+      Bind(&VideoChannel::GetRtpReceiveParameters_w, this, ssrc));
+}
+
+webrtc::RtpParameters VideoChannel::GetRtpReceiveParameters_w(
+    uint32_t ssrc) const {
+  return media_channel()->GetRtpReceiveParameters(ssrc);
+}
+
+bool VideoChannel::SetRtpReceiveParameters(
+    uint32_t ssrc,
+    const webrtc::RtpParameters& parameters) {
+  return InvokeOnWorker(
+      Bind(&VideoChannel::SetRtpReceiveParameters_w, this, ssrc, parameters));
+}
+
+bool VideoChannel::SetRtpReceiveParameters_w(uint32_t ssrc,
+                                             webrtc::RtpParameters parameters) {
+  return media_channel()->SetRtpReceiveParameters(ssrc, parameters);
 }
 
 void VideoChannel::ChangeState_w() {
diff --git a/webrtc/pc/channel.h b/webrtc/pc/channel.h
index 2f66f12..32828bb 100644
--- a/webrtc/pc/channel.h
+++ b/webrtc/pc/channel.h
@@ -404,8 +404,12 @@
   bool SetOutputVolume(uint32_t ssrc, double volume);
   void SetRawAudioSink(uint32_t ssrc,
                        std::unique_ptr<webrtc::AudioSinkInterface> sink);
-  webrtc::RtpParameters GetRtpParameters(uint32_t ssrc) const;
-  bool SetRtpParameters(uint32_t ssrc, const webrtc::RtpParameters& parameters);
+  webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const;
+  bool SetRtpSendParameters(uint32_t ssrc,
+                            const webrtc::RtpParameters& parameters);
+  webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const;
+  bool SetRtpReceiveParameters(uint32_t ssrc,
+                               const webrtc::RtpParameters& parameters);
 
   // Get statistics about the current media session.
   bool GetStats(VoiceMediaInfo* stats);
@@ -426,8 +430,11 @@
   int GetInputLevel_w();
   int GetOutputLevel_w();
   void GetActiveStreams_w(AudioInfo::StreamList* actives);
-  webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const;
-  bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
+  webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
+  bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
+  webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const;
+  bool SetRtpReceiveParameters_w(uint32_t ssrc,
+                                 webrtc::RtpParameters parameters);
 
  private:
   // overrides from BaseChannel
@@ -505,8 +512,12 @@
   sigslot::signal2<VideoChannel*, const VideoMediaInfo&> SignalMediaMonitor;
 
   bool SetVideoSend(uint32_t ssrc, bool enable, const VideoOptions* options);
-  webrtc::RtpParameters GetRtpParameters(uint32_t ssrc) const;
-  bool SetRtpParameters(uint32_t ssrc, const webrtc::RtpParameters& parameters);
+  webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const;
+  bool SetRtpSendParameters(uint32_t ssrc,
+                            const webrtc::RtpParameters& parameters);
+  webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const;
+  bool SetRtpReceiveParameters(uint32_t ssrc,
+                               const webrtc::RtpParameters& parameters);
 
  private:
   // overrides from BaseChannel
@@ -519,8 +530,11 @@
                           ContentAction action,
                           std::string* error_desc) override;
   bool GetStats_w(VideoMediaInfo* stats);
-  webrtc::RtpParameters GetRtpParameters_w(uint32_t ssrc) const;
-  bool SetRtpParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
+  webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const;
+  bool SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters);
+  webrtc::RtpParameters GetRtpReceiveParameters_w(uint32_t ssrc) const;
+  bool SetRtpReceiveParameters_w(uint32_t ssrc,
+                                 webrtc::RtpParameters parameters);
 
   void OnMessage(rtc::Message* pmsg) override;
   void GetSrtpCryptoSuites_n(std::vector<int>* crypto_suites) const override;
diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc
index 81339cf..5c5eefa 100644
--- a/webrtc/pc/channel_unittest.cc
+++ b/webrtc/pc/channel_unittest.cc
@@ -1887,7 +1887,7 @@
     EXPECT_TRUE(
         channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
     EXPECT_EQ(media_channel1_->max_bps(), -1);
-    VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
+    VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), -1);
   }
 
   void CanChangeMaxBitrate() {
@@ -1895,16 +1895,16 @@
     EXPECT_TRUE(
         channel1_->SetLocalContent(&local_media_content1_, CA_OFFER, NULL));
 
-    EXPECT_TRUE(
-        channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(1000)));
-    VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), 1000);
-    VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), 1000);
+    EXPECT_TRUE(channel1_->SetRtpSendParameters(
+        kSsrc1, BitrateLimitedParameters(1000)));
+    VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1), 1000);
+    VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), 1000);
     EXPECT_EQ(-1, media_channel1_->max_bps());
 
     EXPECT_TRUE(
-        channel1_->SetRtpParameters(kSsrc1, BitrateLimitedParameters(-1)));
-    VerifyMaxBitrate(channel1_->GetRtpParameters(kSsrc1), -1);
-    VerifyMaxBitrate(media_channel1_->GetRtpParameters(kSsrc1), -1);
+        channel1_->SetRtpSendParameters(kSsrc1, BitrateLimitedParameters(-1)));
+    VerifyMaxBitrate(channel1_->GetRtpSendParameters(kSsrc1), -1);
+    VerifyMaxBitrate(media_channel1_->GetRtpSendParameters(kSsrc1), -1);
     EXPECT_EQ(-1, media_channel1_->max_bps());
   }