Move instantiation of webrtc::Call into a MediaController class so that it can be used for both audio and video media channels.

I'm not super happy with the GetVoE() function added on MediaEngineInterface, but this will eventually be gone, once webrtc::Call owns the shared VoE state (or initially, maps ADM* to an implicitly created VoE).

BUG=webrtc:4690
R=pbos@webrtc.org, pthatcher@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#9939}
diff --git a/talk/media/webrtc/webrtcvoiceengine.h b/talk/media/webrtc/webrtcvoiceengine.h
index 951c878..e8ae157 100644
--- a/talk/media/webrtc/webrtcvoiceengine.h
+++ b/talk/media/webrtc/webrtcvoiceengine.h
@@ -100,7 +100,9 @@
   void Terminate();
 
   int GetCapabilities();
-  VoiceMediaChannel* CreateChannel(const AudioOptions& options);
+  webrtc::VoiceEngine* GetVoE() { return voe()->engine(); }
+  VoiceMediaChannel* CreateChannel(webrtc::Call* call,
+                                   const AudioOptions& options);
 
   AudioOptions GetOptions() const { return options_; }
   bool SetOptions(const AudioOptions& options);
@@ -280,7 +282,8 @@
 class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
                                 public webrtc::Transport {
  public:
-  explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine *engine);
+  explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
+                                   webrtc::Call* call);
   ~WebRtcVoiceMediaChannel() override;
 
   int voe_channel() const { return voe_channel_; }
@@ -356,8 +359,6 @@
   int GetReceiveChannelNum(uint32 ssrc) const;
   int GetSendChannelNum(uint32 ssrc) const;
 
-  void SetCall(webrtc::Call* call);
-
  private:
   bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer);
   bool MuteStream(uint32 ssrc, bool mute);
@@ -402,8 +403,9 @@
 
   bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
                           const RtpHeaderExtension* extension);
-  void TryAddAudioRecvStream(uint32 ssrc);
-  void TryRemoveAudioRecvStream(uint32 ssrc);
+  void RecreateAudioReceiveStreams();
+  void AddAudioReceiveStream(uint32 ssrc);
+  void RemoveAudioReceiveStream(uint32 ssrc);
   bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs);
 
   bool SetChannelRecvRtpHeaderExtensions(
@@ -415,7 +417,7 @@
 
   rtc::ThreadChecker thread_checker_;
 
-  WebRtcVoiceEngine* engine_;
+  WebRtcVoiceEngine* const engine_;
   const int voe_channel_;
   rtc::scoped_ptr<WebRtcSoundclipStream> ringback_tone_;
   std::set<int> ringback_channels_;  // channels playing ringback
@@ -432,7 +434,7 @@
   bool typing_noise_detected_;
   SendFlags desired_send_;
   SendFlags send_;
-  webrtc::Call* call_;
+  webrtc::Call* const call_;
 
   // send_channels_ contains the channels which are being used for sending.
   // When the default channel (voe_channel) is used for sending, it is