Implement legacy offer_to_receive options for Unified Plan

This implements the WebRTC specification for handling
the legacy offer options offer_to_receive_audio and
offer_to_receive_video. They are not implemented for CreateAnswer.

With Unified Plan semantics, clients should switch to the
RtpTransceiver API for ensuring the correct media sections are
offered.

Bug: webrtc:7600
Change-Id: I6ced00b86b165a352bd0ca3d64b48fadcfd12235
Reviewed-on: https://webrtc-review.googlesource.com/41341
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21784}
diff --git a/pc/peerconnectionwrapper.cc b/pc/peerconnectionwrapper.cc
index 21d1542..c09258d 100644
--- a/pc/peerconnectionwrapper.cc
+++ b/pc/peerconnectionwrapper.cc
@@ -24,6 +24,8 @@
 
 namespace webrtc {
 
+using RTCOfferAnswerOptions = PeerConnectionInterface::RTCOfferAnswerOptions;
+
 namespace {
 const uint32_t kDefaultTimeout = 10000U;
 }
@@ -57,7 +59,7 @@
 
 std::unique_ptr<SessionDescriptionInterface>
 PeerConnectionWrapper::CreateOffer() {
-  return CreateOffer(PeerConnectionInterface::RTCOfferAnswerOptions());
+  return CreateOffer(RTCOfferAnswerOptions());
 }
 
 std::unique_ptr<SessionDescriptionInterface> PeerConnectionWrapper::CreateOffer(
@@ -72,8 +74,7 @@
 
 std::unique_ptr<SessionDescriptionInterface>
 PeerConnectionWrapper::CreateOfferAndSetAsLocal() {
-  return CreateOfferAndSetAsLocal(
-      PeerConnectionInterface::RTCOfferAnswerOptions());
+  return CreateOfferAndSetAsLocal(RTCOfferAnswerOptions());
 }
 
 std::unique_ptr<SessionDescriptionInterface>
@@ -89,7 +90,7 @@
 
 std::unique_ptr<SessionDescriptionInterface>
 PeerConnectionWrapper::CreateAnswer() {
-  return CreateAnswer(PeerConnectionInterface::RTCOfferAnswerOptions());
+  return CreateAnswer(RTCOfferAnswerOptions());
 }
 
 std::unique_ptr<SessionDescriptionInterface>
@@ -105,8 +106,7 @@
 
 std::unique_ptr<SessionDescriptionInterface>
 PeerConnectionWrapper::CreateAnswerAndSetAsLocal() {
-  return CreateAnswerAndSetAsLocal(
-      PeerConnectionInterface::RTCOfferAnswerOptions());
+  return CreateAnswerAndSetAsLocal(RTCOfferAnswerOptions());
 }
 
 std::unique_ptr<SessionDescriptionInterface>
@@ -181,12 +181,20 @@
 
 bool PeerConnectionWrapper::ExchangeOfferAnswerWith(
     PeerConnectionWrapper* answerer) {
+  return ExchangeOfferAnswerWith(answerer, RTCOfferAnswerOptions(),
+                                 RTCOfferAnswerOptions());
+}
+
+bool PeerConnectionWrapper::ExchangeOfferAnswerWith(
+    PeerConnectionWrapper* answerer,
+    const PeerConnectionInterface::RTCOfferAnswerOptions& offer_options,
+    const PeerConnectionInterface::RTCOfferAnswerOptions& answer_options) {
   RTC_DCHECK(answerer);
   if (answerer == this) {
     RTC_LOG(LS_ERROR) << "Cannot exchange offer/answer with ourself!";
     return false;
   }
-  auto offer = CreateOffer();
+  auto offer = CreateOffer(offer_options);
   EXPECT_TRUE(offer);
   if (!offer) {
     return false;
@@ -202,7 +210,7 @@
   if (!set_remote_offer) {
     return false;
   }
-  auto answer = answerer->CreateAnswer();
+  auto answer = answerer->CreateAnswer(answer_options);
   EXPECT_TRUE(answer);
   if (!answer) {
     return false;