| Index: talk/session/media/channelmanager.cc
 | 
| diff --git a/talk/session/media/channelmanager.cc b/talk/session/media/channelmanager.cc
 | 
| index f39e966e5158941188e32fa21ec115cfce37f377..3caa8a51fd6e208c734b16f9e8b38be9ba774830 100644
 | 
| --- a/talk/session/media/channelmanager.cc
 | 
| +++ b/talk/session/media/channelmanager.cc
 | 
| @@ -33,6 +33,7 @@
 | 
|  
 | 
|  #include <algorithm>
 | 
|  
 | 
| +#include "talk/app/webrtc/mediacontroller.h"
 | 
|  #include "talk/media/base/capturemanager.h"
 | 
|  #include "talk/media/base/hybriddataengine.h"
 | 
|  #include "talk/media/base/rtpdataengine.h"
 | 
| @@ -308,7 +309,7 @@ void ChannelManager::Terminate_w() {
 | 
|      DestroyVideoChannel_w(video_channels_.back());
 | 
|    }
 | 
|    while (!voice_channels_.empty()) {
 | 
| -    DestroyVoiceChannel_w(voice_channels_.back(), nullptr);
 | 
| +    DestroyVoiceChannel_w(voice_channels_.back());
 | 
|    }
 | 
|    if (!SetCaptureDevice_w(NULL)) {
 | 
|      LOG(LS_WARNING) << "failed to delete video capturer";
 | 
| @@ -320,20 +321,24 @@ VoiceChannel* ChannelManager::CreateVoiceChannel(
 | 
|      BaseSession* session,
 | 
|      const std::string& content_name,
 | 
|      bool rtcp,
 | 
| +    webrtc::MediaController* media_controller,
 | 
|      const AudioOptions& options) {
 | 
|    return worker_thread_->Invoke<VoiceChannel*>(
 | 
|        Bind(&ChannelManager::CreateVoiceChannel_w, this, session, content_name,
 | 
| -           rtcp, options));
 | 
| +           rtcp, media_controller, options));
 | 
|  }
 | 
|  
 | 
|  VoiceChannel* ChannelManager::CreateVoiceChannel_w(
 | 
|      BaseSession* session,
 | 
|      const std::string& content_name,
 | 
|      bool rtcp,
 | 
| +    webrtc::MediaController* media_controller,
 | 
|      const AudioOptions& options) {
 | 
|    ASSERT(initialized_);
 | 
|    ASSERT(worker_thread_ == rtc::Thread::Current());
 | 
| -  VoiceMediaChannel* media_channel = media_engine_->CreateChannel(options);
 | 
| +  ASSERT(nullptr != media_controller);
 | 
| +  VoiceMediaChannel* media_channel =
 | 
| +      media_engine_->CreateChannel(media_controller->call_w(), options);
 | 
|    if (!media_channel)
 | 
|      return nullptr;
 | 
|  
 | 
| @@ -348,17 +353,14 @@ VoiceChannel* ChannelManager::CreateVoiceChannel_w(
 | 
|    return voice_channel;
 | 
|  }
 | 
|  
 | 
| -void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel,
 | 
| -                                         VideoChannel* video_channel) {
 | 
| +void ChannelManager::DestroyVoiceChannel(VoiceChannel* voice_channel) {
 | 
|    if (voice_channel) {
 | 
|      worker_thread_->Invoke<void>(
 | 
| -        Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel,
 | 
| -             video_channel));
 | 
| +        Bind(&ChannelManager::DestroyVoiceChannel_w, this, voice_channel));
 | 
|    }
 | 
|  }
 | 
|  
 | 
| -void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel,
 | 
| -                                           VideoChannel* video_channel) {
 | 
| +void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel) {
 | 
|    // Destroy voice channel.
 | 
|    ASSERT(initialized_);
 | 
|    ASSERT(worker_thread_ == rtc::Thread::Current());
 | 
| @@ -367,10 +369,6 @@ void ChannelManager::DestroyVoiceChannel_w(VoiceChannel* voice_channel,
 | 
|    ASSERT(it != voice_channels_.end());
 | 
|    if (it == voice_channels_.end())
 | 
|      return;
 | 
| -
 | 
| -  if (video_channel) {
 | 
| -    video_channel->media_channel()->DetachVoiceChannel();
 | 
| -  }
 | 
|    voice_channels_.erase(it);
 | 
|    delete voice_channel;
 | 
|  }
 | 
| @@ -379,45 +377,29 @@ VideoChannel* ChannelManager::CreateVideoChannel(
 | 
|      BaseSession* session,
 | 
|      const std::string& content_name,
 | 
|      bool rtcp,
 | 
| -    VoiceChannel* voice_channel) {
 | 
| -  return worker_thread_->Invoke<VideoChannel*>(
 | 
| -      Bind(&ChannelManager::CreateVideoChannel_w,
 | 
| -           this,
 | 
| -           session,
 | 
| -           content_name,
 | 
| -           rtcp,
 | 
| -           VideoOptions(),
 | 
| -           voice_channel));
 | 
| -}
 | 
| -
 | 
| -VideoChannel* ChannelManager::CreateVideoChannel(
 | 
| -    BaseSession* session,
 | 
| -    const std::string& content_name,
 | 
| -    bool rtcp,
 | 
| -    const VideoOptions& options,
 | 
| -    VoiceChannel* voice_channel) {
 | 
| +    webrtc::MediaController* media_controller,
 | 
| +    const VideoOptions& options) {
 | 
|    return worker_thread_->Invoke<VideoChannel*>(
 | 
|        Bind(&ChannelManager::CreateVideoChannel_w,
 | 
|             this,
 | 
|             session,
 | 
|             content_name,
 | 
|             rtcp,
 | 
| -           options,
 | 
| -           voice_channel));
 | 
| +           media_controller,
 | 
| +           options));
 | 
|  }
 | 
|  
 | 
|  VideoChannel* ChannelManager::CreateVideoChannel_w(
 | 
|      BaseSession* session,
 | 
|      const std::string& content_name,
 | 
|      bool rtcp,
 | 
| -    const VideoOptions& options,
 | 
| -    VoiceChannel* voice_channel) {
 | 
| +    webrtc::MediaController* media_controller,
 | 
| +    const VideoOptions& options) {
 | 
|    ASSERT(initialized_);
 | 
|    ASSERT(worker_thread_ == rtc::Thread::Current());
 | 
| +  ASSERT(nullptr != media_controller);
 | 
|    VideoMediaChannel* media_channel =
 | 
| -      // voice_channel can be NULL in case of NullVoiceEngine.
 | 
| -      media_engine_->CreateVideoChannel(
 | 
| -          options, voice_channel ? voice_channel->media_channel() : NULL);
 | 
| +      media_engine_->CreateVideoChannel(media_controller->call_w(), options);
 | 
|    if (media_channel == NULL)
 | 
|      return NULL;
 | 
|  
 | 
| 
 |