[Cast] Rename Negotiate/OnNegotiated methods

This patch renames SenderSession Negotiate to NegotiateMirroring and
OnNegotiated to OnMirroringNegotiated, in advance of a larger patch that
exposes remoting on the SenderSession.

Bug: b/184186374
Change-Id: Ibfa38a822d6fdf5a39ebb83ef493442451fcc91e
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2798518
Reviewed-by: Ryan Keane <rwkeane@google.com>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
diff --git a/cast/standalone_receiver/streaming_playback_controller.cc b/cast/standalone_receiver/streaming_playback_controller.cc
index 4c3f627..f9196ae 100644
--- a/cast/standalone_receiver/streaming_playback_controller.cc
+++ b/cast/standalone_receiver/streaming_playback_controller.cc
@@ -53,7 +53,7 @@
 }
 #endif  // defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS)
 
-void StreamingPlaybackController::OnNegotiated(
+void StreamingPlaybackController::OnMirroringNegotiated(
     const ReceiverSession* session,
     ReceiverSession::ConfiguredReceivers receivers) {
   TRACE_DEFAULT_SCOPED(TraceCategory::kStandaloneReceiver);
diff --git a/cast/standalone_receiver/streaming_playback_controller.h b/cast/standalone_receiver/streaming_playback_controller.h
index d2ab72f..1e81ed5 100644
--- a/cast/standalone_receiver/streaming_playback_controller.h
+++ b/cast/standalone_receiver/streaming_playback_controller.h
@@ -33,8 +33,9 @@
                               StreamingPlaybackController::Client* client);
 
   // ReceiverSession::Client overrides.
-  void OnNegotiated(const ReceiverSession* session,
-                    ReceiverSession::ConfiguredReceivers receivers) override;
+  void OnMirroringNegotiated(
+      const ReceiverSession* session,
+      ReceiverSession::ConfiguredReceivers receivers) override;
 
   void OnReceiversDestroying(const ReceiverSession* session,
                              ReceiversDestroyingReason reason) override;
diff --git a/cast/standalone_sender/looping_file_cast_agent.cc b/cast/standalone_sender/looping_file_cast_agent.cc
index e5d7581..9d4558a 100644
--- a/cast/standalone_sender/looping_file_cast_agent.cc
+++ b/cast/standalone_sender/looping_file_cast_agent.cc
@@ -289,13 +289,13 @@
 
   OSP_VLOG << "Starting session negotiation.";
   const Error negotiation_error =
-      current_session_->Negotiate({audio_config}, {video_config});
+      current_session_->NegotiateMirroring({audio_config}, {video_config});
   if (!negotiation_error.ok()) {
     OSP_LOG_ERROR << "Failed to negotiate a session: " << negotiation_error;
   }
 }
 
-void LoopingFileCastAgent::OnNegotiated(
+void LoopingFileCastAgent::OnMirroringNegotiated(
     const SenderSession* session,
     SenderSession::ConfiguredSenders senders,
     capture_recommendations::Recommendations capture_recommendations) {
diff --git a/cast/standalone_sender/looping_file_cast_agent.h b/cast/standalone_sender/looping_file_cast_agent.h
index 74ca7f3..cc2d586 100644
--- a/cast/standalone_sender/looping_file_cast_agent.h
+++ b/cast/standalone_sender/looping_file_cast_agent.h
@@ -143,10 +143,10 @@
   void CreateAndStartSession();
 
   // SenderSession::Client overrides.
-  void OnNegotiated(const SenderSession* session,
-                    SenderSession::ConfiguredSenders senders,
-                    capture_recommendations::Recommendations
-                        capture_recommendations) override;
+  void OnMirroringNegotiated(const SenderSession* session,
+                             SenderSession::ConfiguredSenders senders,
+                             capture_recommendations::Recommendations
+                                 capture_recommendations) override;
   void OnError(const SenderSession* session, Error error) override;
 
   // Helper for stopping the current session, and/or unwinding a remote
diff --git a/cast/streaming/receiver_session.cc b/cast/streaming/receiver_session.cc
index 4e976e0..68c1ee4 100644
--- a/cast/streaming/receiver_session.cc
+++ b/cast/streaming/receiver_session.cc
@@ -192,7 +192,7 @@
 
   // Only spawn receivers if we know we have a valid answer message.
   ConfiguredReceivers receivers = SpawnReceivers(properties);
-  client_->OnNegotiated(this, std::move(receivers));
+  client_->OnMirroringNegotiated(this, std::move(receivers));
   const Error result = messager_.SendMessage(ReceiverMessage{
       ReceiverMessage::Type::kAnswer, properties.sequence_number,
       true /* valid */, std::move(answer)});
diff --git a/cast/streaming/receiver_session.h b/cast/streaming/receiver_session.h
index b29b6d5..b8365a3 100644
--- a/cast/streaming/receiver_session.h
+++ b/cast/streaming/receiver_session.h
@@ -51,23 +51,25 @@
   };
 
   // The embedder should provide a client for handling connections.
-  // When a connection is established, the OnNegotiated callback is called.
+  // When a connection is established, the OnMirroringNegotiated callback is
+  // called.
   class Client {
    public:
     enum ReceiversDestroyingReason { kEndOfSession, kRenegotiated };
 
     // Called when a new set of receivers has been negotiated. This may be
     // called multiple times during a session, as renegotiations occur.
-    virtual void OnNegotiated(const ReceiverSession* session,
-                              ConfiguredReceivers receivers) = 0;
+    virtual void OnMirroringNegotiated(const ReceiverSession* session,
+                                       ConfiguredReceivers receivers) = 0;
 
     // Called immediately preceding the destruction of this session's receivers.
-    // If |reason| is |kEndOfSession|, OnNegotiated() will never be called
-    // again; if it is |kRenegotiated|, OnNegotiated() will be called again
-    // soon with a new set of Receivers to use.
+    // If |reason| is |kEndOfSession|, OnMirroringNegotiated() will never be
+    // called again; if it is |kRenegotiated|, OnMirroringNegotiated() will be
+    // called again soon with a new set of Receivers to use.
     //
     // Before returning, the implementation must ensure that all references to
-    // the Receivers, from the last call to OnNegotiated(), have been cleared.
+    // the Receivers, from the last call to OnMirroringNegotiated(), have been
+    // cleared.
     virtual void OnReceiversDestroying(const ReceiverSession* session,
                                        ReceiversDestroyingReason reason) = 0;
 
diff --git a/cast/streaming/receiver_session_unittest.cc b/cast/streaming/receiver_session_unittest.cc
index afbc556..1914cbd 100644
--- a/cast/streaming/receiver_session_unittest.cc
+++ b/cast/streaming/receiver_session_unittest.cc
@@ -249,7 +249,7 @@
 class FakeClient : public ReceiverSession::Client {
  public:
   MOCK_METHOD(void,
-              OnNegotiated,
+              OnMirroringNegotiated,
               (const ReceiverSession*, ReceiverSession::ConfiguredReceivers),
               (override));
   MOCK_METHOD(void,
@@ -315,7 +315,7 @@
 
 TEST_F(ReceiverSessionTest, CanNegotiateWithDefaultPreferences) {
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _))
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _))
       .WillOnce([](const ReceiverSession* session_,
                    ReceiverSession::ConfiguredReceivers cr) {
         EXPECT_TRUE(cr.audio_receiver);
@@ -378,7 +378,7 @@
       ReceiverSession::Preferences{{VideoCodec::kVp9}, {AudioCodec::kOpus}});
 
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(&session, _))
+  EXPECT_CALL(client_, OnMirroringNegotiated(&session, _))
       .WillOnce([](const ReceiverSession* session_,
                    ReceiverSession::ConfiguredReceivers cr) {
         EXPECT_TRUE(cr.audio_receiver);
@@ -421,7 +421,7 @@
                                                        std::move(display)});
 
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(&session, _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(&session, _));
   EXPECT_CALL(client_, OnReceiversDestroying(
                            &session, ReceiverSession::Client::kEndOfSession));
   message_port_->ReceiveMessage(kValidOfferMessage);
@@ -474,7 +474,7 @@
 
 TEST_F(ReceiverSessionTest, HandlesNoValidAudioStream) {
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _));
   EXPECT_CALL(client_,
               OnReceiversDestroying(session_.get(),
                                     ReceiverSession::Client::kEndOfSession));
@@ -511,7 +511,7 @@
 
 TEST_F(ReceiverSessionTest, HandlesNoValidVideoStream) {
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _));
   EXPECT_CALL(client_,
               OnReceiversDestroying(session_.get(),
                                     ReceiverSession::Client::kEndOfSession));
@@ -533,7 +533,8 @@
 }
 
 TEST_F(ReceiverSessionTest, HandlesNoValidStreams) {
-  // We shouldn't call OnNegotiated if we failed to negotiate any streams.
+  // We shouldn't call OnMirroringNegotiated if we failed to negotiate any
+  // streams.
   message_port_->ReceiveMessage(kNoAudioOrVideoOfferMessage);
   AssertGotAnErrorAnswerResponse();
 }
@@ -595,11 +596,11 @@
 
 TEST_F(ReceiverSessionTest, NotifiesReceiverDestruction) {
   InSequence s;
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _));
   EXPECT_CALL(client_,
               OnReceiversDestroying(session_.get(),
                                     ReceiverSession::Client::kRenegotiated));
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _));
   EXPECT_CALL(client_,
               OnReceiversDestroying(session_.get(),
                                     ReceiverSession::Client::kEndOfSession));
@@ -637,7 +638,7 @@
   // state() will not be called again--we just need to get the bind event.
   EXPECT_CALL(*environment_, GetBoundLocalEndpoint())
       .WillOnce(Return(IPEndpoint{{10, 0, 0, 2}, 4567}));
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _));
   EXPECT_CALL(client_,
               OnReceiversDestroying(session_.get(),
                                     ReceiverSession::Client::kEndOfSession));
diff --git a/cast/streaming/sender_session.cc b/cast/streaming/sender_session.cc
index 0c90e93..91ed975 100644
--- a/cast/streaming/sender_session.cc
+++ b/cast/streaming/sender_session.cc
@@ -165,8 +165,9 @@
 
 SenderSession::~SenderSession() = default;
 
-Error SenderSession::Negotiate(std::vector<AudioCaptureConfig> audio_configs,
-                               std::vector<VideoCaptureConfig> video_configs) {
+Error SenderSession::NegotiateMirroring(
+    std::vector<AudioCaptureConfig> audio_configs,
+    std::vector<VideoCaptureConfig> video_configs) {
   // Negotiating with no streams doesn't make any sense.
   if (audio_configs.empty() && video_configs.empty()) {
     return Error(Error::Code::kParameterInvalid,
@@ -212,8 +213,9 @@
   if (senders.audio_sender == nullptr && senders.video_sender == nullptr) {
     return;
   }
-  client_->OnNegotiated(this, std::move(senders),
-                        capture_recommendations::GetRecommendations(answer));
+  client_->OnMirroringNegotiated(
+      this, std::move(senders),
+      capture_recommendations::GetRecommendations(answer));
 }
 
 std::unique_ptr<Sender> SenderSession::CreateSender(Ssrc receiver_ssrc,
diff --git a/cast/streaming/sender_session.h b/cast/streaming/sender_session.h
index 61864d0..cba1620 100644
--- a/cast/streaming/sender_session.h
+++ b/cast/streaming/sender_session.h
@@ -50,21 +50,23 @@
   };
 
   // The embedder should provide a client for handling the negotiation.
-  // When the negotiation is complete, the OnNegotiated callback is called.
+  // When the negotiation is complete, the OnMirroringNegotiated callback is
+  // called.
   class Client {
    public:
     // Called when a new set of senders has been negotiated. This may be
-    // called multiple times during a session, once for every time Negotiate()
-    // is called on the SenderSession object. The negotiation call also includes
-    // capture recommendations that can be used by the sender to provide
-    // an optimal video stream for the receiver.
-    virtual void OnNegotiated(
+    // called multiple times during a session, once for every time
+    // NegotiateMirroring() is called on the SenderSession object. The
+    // negotiation call also includes capture recommendations that can be used
+    // by the sender to provide an optimal video stream for the receiver.
+    virtual void OnMirroringNegotiated(
         const SenderSession* session,
         ConfiguredSenders senders,
         capture_recommendations::Recommendations capture_recommendations) = 0;
 
     // Called whenever an error occurs. Ends the ongoing session, and the caller
-    // must call Negotiate() again if they wish to re-establish streaming.
+    // must call NegotiateMirroring() again if they wish to re-establish
+    // streaming.
     virtual void OnError(const SenderSession* session, Error error) = 0;
 
    protected:
@@ -95,8 +97,8 @@
   // Starts an OFFER/ANSWER exchange with the already configured receiver
   // over the message port. The caller should assume any configured senders
   // become invalid when calling this method.
-  Error Negotiate(std::vector<AudioCaptureConfig> audio_configs,
-                  std::vector<VideoCaptureConfig> video_configs);
+  Error NegotiateMirroring(std::vector<AudioCaptureConfig> audio_configs,
+                           std::vector<VideoCaptureConfig> video_configs);
 
   // Get the current network usage (in bits per second). This includes all
   // senders managed by this session, and is a best guess based on receiver
diff --git a/cast/streaming/sender_session_unittest.cc b/cast/streaming/sender_session_unittest.cc
index 3667309..4aaf9e4 100644
--- a/cast/streaming/sender_session_unittest.cc
+++ b/cast/streaming/sender_session_unittest.cc
@@ -127,7 +127,7 @@
 class FakeClient : public SenderSession::Client {
  public:
   MOCK_METHOD(void,
-              OnNegotiated,
+              OnMirroringNegotiated,
               (const SenderSession*,
                SenderSession::ConfiguredSenders,
                capture_recommendations::Recommendations),
@@ -159,7 +159,7 @@
   }
 
   std::string NegotiateOfferAndConstructAnswer() {
-    const Error error = session_->Negotiate(
+    const Error error = session_->NegotiateMirroring(
         std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
         std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
     if (!error.ok()) {
@@ -220,8 +220,8 @@
 };
 
 TEST_F(SenderSessionTest, ComplainsIfNoConfigsToOffer) {
-  const Error error = session_->Negotiate(std::vector<AudioCaptureConfig>{},
-                                          std::vector<VideoCaptureConfig>{});
+  const Error error = session_->NegotiateMirroring(
+      std::vector<AudioCaptureConfig>{}, std::vector<VideoCaptureConfig>{});
 
   EXPECT_EQ(error,
             Error(Error::Code::kParameterInvalid,
@@ -229,7 +229,7 @@
 }
 
 TEST_F(SenderSessionTest, ComplainsIfInvalidAudioCaptureConfig) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigInvalidChannels},
       std::vector<VideoCaptureConfig>{});
 
@@ -238,7 +238,7 @@
 }
 
 TEST_F(SenderSessionTest, ComplainsIfInvalidVideoCaptureConfig) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigInvalid});
   EXPECT_EQ(error,
@@ -246,7 +246,7 @@
 }
 
 TEST_F(SenderSessionTest, ComplainsIfMissingResolutions) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigMissingResolutions});
   EXPECT_EQ(error,
@@ -259,9 +259,9 @@
   AudioCaptureConfig audio_config = kAudioCaptureConfigValid;
   audio_config.bit_rate = 0;
 
-  const Error error =
-      session_->Negotiate(std::vector<AudioCaptureConfig>{audio_config},
-                          std::vector<VideoCaptureConfig>{video_config});
+  const Error error = session_->NegotiateMirroring(
+      std::vector<AudioCaptureConfig>{audio_config},
+      std::vector<VideoCaptureConfig>{video_config});
   EXPECT_TRUE(error.ok());
 
   const auto& messages = message_port_->posted_messages();
@@ -273,7 +273,7 @@
 }
 
 TEST_F(SenderSessionTest, SendsOfferWithSimpleVideoOnly) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
   EXPECT_TRUE(error.ok());
@@ -287,7 +287,7 @@
 }
 
 TEST_F(SenderSessionTest, SendsOfferAudioOnly) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{});
   EXPECT_TRUE(error.ok());
@@ -301,7 +301,7 @@
 }
 
 TEST_F(SenderSessionTest, SendsOfferMessage) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -346,7 +346,7 @@
 TEST_F(SenderSessionTest, HandlesValidAnswer) {
   std::string answer = NegotiateOfferAndConstructAnswer();
 
-  EXPECT_CALL(client_, OnNegotiated(session_.get(), _, _));
+  EXPECT_CALL(client_, OnMirroringNegotiated(session_.get(), _, _));
   message_port_->ReceiveMessage(answer);
 }
 
@@ -356,7 +356,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesMalformedAnswer) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -368,7 +368,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesImproperlyFormattedAnswer) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -377,7 +377,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesInvalidAnswer) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -386,7 +386,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesNullAnswer) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -396,7 +396,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesInvalidSequenceNumber) {
-  const Error error = session_->Negotiate(
+  const Error error = session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -405,7 +405,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesUnknownTypeMessageWithValidSeqNum) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -416,7 +416,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesInvalidTypeMessageWithValidSeqNum) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -427,7 +427,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesInvalidTypeMessage) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -437,7 +437,7 @@
 }
 
 TEST_F(SenderSessionTest, HandlesErrorMessage) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});
 
@@ -447,7 +447,7 @@
 }
 
 TEST_F(SenderSessionTest, DoesNotCrashOnMessagePortError) {
-  session_->Negotiate(
+  session_->NegotiateMirroring(
       std::vector<AudioCaptureConfig>{kAudioCaptureConfigValid},
       std::vector<VideoCaptureConfig>{kVideoCaptureConfigValid});