(Auto)update libjingle 73072800 -> 73215194

git-svn-id: http://webrtc.googlecode.com/svn/trunk/talk@6887 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/media/base/videoengine_unittest.h b/media/base/videoengine_unittest.h
index 502cf47..40881eb 100644
--- a/media/base/videoengine_unittest.h
+++ b/media/base/videoengine_unittest.h
@@ -1720,7 +1720,6 @@
     EXPECT_FALSE(channel_->RemoveSendStream(kSsrcs4[kSsrcsSize - 1]));
   }
 
-
   // Two streams one channel tests.
 
   // Tests that we can send and receive frames.
@@ -1742,18 +1741,18 @@
   void TwoStreamsReUseFirstStream(const cricket::VideoCodec& codec) {
     SetUpSecondStream();
     // Default channel used by the first stream.
-    EXPECT_EQ(kSsrc, channel_->GetDefaultChannelSsrc());
+    EXPECT_EQ(kSsrc, channel_->GetDefaultSendChannelSsrc());
     EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc));
     EXPECT_FALSE(channel_->RemoveRecvStream(kSsrc));
     EXPECT_TRUE(channel_->RemoveSendStream(kSsrc));
     EXPECT_FALSE(channel_->RemoveSendStream(kSsrc));
     // Default channel is no longer used by a stream.
-    EXPECT_EQ(0u, channel_->GetDefaultChannelSsrc());
+    EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
     uint32 new_ssrc = kSsrc + 100;
     EXPECT_TRUE(channel_->AddSendStream(
         cricket::StreamParams::CreateLegacy(new_ssrc)));
     // Re-use default channel.
-    EXPECT_EQ(new_ssrc, channel_->GetDefaultChannelSsrc());
+    EXPECT_EQ(new_ssrc, channel_->GetDefaultSendChannelSsrc());
     EXPECT_FALSE(channel_->AddSendStream(
         cricket::StreamParams::CreateLegacy(new_ssrc)));
     EXPECT_TRUE(channel_->AddRecvStream(
@@ -1766,7 +1765,7 @@
 
     SendAndReceive(codec);
     EXPECT_TRUE(channel_->RemoveSendStream(new_ssrc));
-    EXPECT_EQ(0u, channel_->GetDefaultChannelSsrc());
+    EXPECT_EQ(0u, channel_->GetDefaultSendChannelSsrc());
   }
 
   // Tests that we can send and receive frames with early receive.
diff --git a/media/webrtc/fakewebrtcvideoengine.h b/media/webrtc/fakewebrtcvideoengine.h
index 3a619bd..da5cd89 100644
--- a/media/webrtc/fakewebrtcvideoengine.h
+++ b/media/webrtc/fakewebrtcvideoengine.h
@@ -548,13 +548,21 @@
     WEBRTC_ASSERT_CHANNEL(channel);
     return channels_.find(channel)->second->overuse_options_;
   }
-  int GetRtxSsrc(int channel, int simulcast_idx) const {
+  int GetSsrc(int channel, int idx) const {
     WEBRTC_ASSERT_CHANNEL(channel);
-    if (channels_.find(channel)->second->rtx_ssrcs_.find(simulcast_idx) ==
+    if (channels_.find(channel)->second->ssrcs_.find(idx) ==
+        channels_.find(channel)->second->ssrcs_.end()) {
+      return -1;
+    }
+    return channels_.find(channel)->second->ssrcs_[idx];
+  }
+  int GetRtxSsrc(int channel, int idx) const {
+    WEBRTC_ASSERT_CHANNEL(channel);
+    if (channels_.find(channel)->second->rtx_ssrcs_.find(idx) ==
         channels_.find(channel)->second->rtx_ssrcs_.end()) {
       return -1;
     }
-    return channels_.find(channel)->second->rtx_ssrcs_[simulcast_idx];
+    return channels_.find(channel)->second->rtx_ssrcs_[idx];
   }
   bool ReceiveCodecRegistered(int channel,
                               const webrtc::VideoCodec& codec) const {
diff --git a/media/webrtc/webrtcvideoengine.cc b/media/webrtc/webrtcvideoengine.cc
index 7afe5de..3e42b7c 100644
--- a/media/webrtc/webrtcvideoengine.cc
+++ b/media/webrtc/webrtcvideoengine.cc
@@ -88,6 +88,10 @@
 
 static const int kExternalVideoPayloadTypeBase = 120;
 
+static const int kChannelIdUnset = -1;
+static const uint32 kDefaultChannelSsrcKey = 0;
+static const uint32 kSsrcUnset = 0;
+
 static bool BitrateIsSet(int value) {
   return value > kAutoBandwidth;
 }
@@ -177,7 +181,7 @@
     // TODO(ronghuawu): Add unit test for this case. Didn't do it now
     // because the WebRtcRenderAdapter is currently hiding in cc file. No
     // good way to get access to it from the unit test.
-    if (width_ > 0 && height_ > 0 && renderer_ != NULL) {
+    if (width_ > 0 && height_ > 0 && renderer_) {
       if (!renderer_->SetSize(width_, height_, 0)) {
         LOG(LS_ERROR)
             << "WebRtcRenderAdapter (channel " << channel_id_
@@ -196,7 +200,7 @@
     LOG(LS_INFO) << "WebRtcRenderAdapter (channel " << channel_id_
                  << ") frame size changed to: "
                  << width << "x" << height;
-    if (renderer_ == NULL) {
+    if (!renderer_) {
       LOG(LS_VERBOSE) << "WebRtcRenderAdapter (channel " << channel_id_
                       << ") the renderer has not been set. "
                       << "SetSize will be called later in SetRenderer.";
@@ -225,7 +229,7 @@
       capture_start_ntp_time_ms_ = ntp_time_ms - elapsed_time_ms;
     }
     frame_rate_tracker_.Update(1);
-    if (renderer_ == NULL) {
+    if (!renderer_) {
       return 0;
     }
     // Convert elapsed_time_ms to ns timestamp.
@@ -237,7 +241,7 @@
     // Note that here we send the |elapsed_time_ns| to renderer as the
     // cricket::VideoFrame's elapsed_time_ and the |render_time_ns| as the
     // cricket::VideoFrame's time_stamp_.
-    if (handle == NULL) {
+    if (!handle) {
       return DeliverBufferFrame(buffer, buffer_size, render_time_ns,
                                 elapsed_time_ns);
     } else {
@@ -311,8 +315,8 @@
 
 class WebRtcDecoderObserver : public webrtc::ViEDecoderObserver {
  public:
-  explicit WebRtcDecoderObserver(int video_channel)
-       : video_channel_(video_channel),
+  explicit WebRtcDecoderObserver(int video_channel_id)
+       : video_channel_id_(video_channel_id),
          framerate_(0),
          bitrate_(0),
          decode_ms_(0),
@@ -325,13 +329,13 @@
   }
 
   // virtual functions from VieDecoderObserver.
-  virtual void IncomingCodecChanged(const int videoChannel,
+  virtual void IncomingCodecChanged(const int video_channel_id,
                                     const webrtc::VideoCodec& videoCodec) {}
-  virtual void IncomingRate(const int videoChannel,
+  virtual void IncomingRate(const int video_channel_id,
                             const unsigned int framerate,
                             const unsigned int bitrate) {
     rtc::CritScope cs(&crit_);
-    ASSERT(video_channel_ == videoChannel);
+    ASSERT(video_channel_id_ == video_channel_id);
     framerate_ = framerate;
     bitrate_ = bitrate;
   }
@@ -353,7 +357,7 @@
     render_delay_ms_ = render_delay_ms;
   }
 
-  virtual void RequestNewKeyFrame(const int videoChannel) {}
+  virtual void RequestNewKeyFrame(const int video_channel_id) {}
 
   // Populate |rinfo| based on previously-set data in |*this|.
   void ExportTo(VideoReceiverInfo* rinfo) {
@@ -370,7 +374,7 @@
 
  private:
   mutable rtc::CriticalSection crit_;
-  int video_channel_;
+  int video_channel_id_;
   int framerate_;
   int bitrate_;
   int decode_ms_;
@@ -384,26 +388,26 @@
 
 class WebRtcEncoderObserver : public webrtc::ViEEncoderObserver {
  public:
-  explicit WebRtcEncoderObserver(int video_channel)
-      : video_channel_(video_channel),
+  explicit WebRtcEncoderObserver(int video_channel_id)
+      : video_channel_id_(video_channel_id),
         framerate_(0),
         bitrate_(0),
         suspended_(false) {
   }
 
   // virtual functions from VieEncoderObserver.
-  virtual void OutgoingRate(const int videoChannel,
+  virtual void OutgoingRate(const int video_channel_id,
                             const unsigned int framerate,
                             const unsigned int bitrate) {
     rtc::CritScope cs(&crit_);
-    ASSERT(video_channel_ == videoChannel);
+    ASSERT(video_channel_id_ == video_channel_id);
     framerate_ = framerate;
     bitrate_ = bitrate;
   }
 
-  virtual void SuspendChange(int video_channel, bool is_suspended) {
+  virtual void SuspendChange(int video_channel_id, bool is_suspended) {
     rtc::CritScope cs(&crit_);
-    ASSERT(video_channel_ == video_channel);
+    ASSERT(video_channel_id_ == video_channel_id);
     suspended_ = is_suspended;
   }
 
@@ -422,7 +426,7 @@
 
  private:
   mutable rtc::CriticalSection crit_;
-  int video_channel_;
+  int video_channel_id_;
   int framerate_;
   int bitrate_;
   bool suspended_;
@@ -840,7 +844,7 @@
 
 static void UpdateVideoCodec(const cricket::VideoFormat& video_format,
                              webrtc::VideoCodec* target_codec) {
-  if ((target_codec == NULL) || (video_format == cricket::VideoFormat())) {
+  if ((!target_codec) || (video_format == cricket::VideoFormat())) {
     return;
   }
   target_codec->width = video_format.width;
@@ -1473,7 +1477,7 @@
 
 webrtc::VideoDecoder* WebRtcVideoEngine::CreateExternalDecoder(
     webrtc::VideoCodecType type) {
-  if (decoder_factory_ == NULL) {
+  if (!decoder_factory_) {
     return NULL;
   }
   return decoder_factory_->CreateVideoDecoder(type);
@@ -1481,14 +1485,14 @@
 
 void WebRtcVideoEngine::DestroyExternalDecoder(webrtc::VideoDecoder* decoder) {
   ASSERT(decoder_factory_ != NULL);
-  if (decoder_factory_ == NULL)
+  if (!decoder_factory_)
     return;
   decoder_factory_->DestroyVideoDecoder(decoder);
 }
 
 webrtc::VideoEncoder* WebRtcVideoEngine::CreateExternalEncoder(
     webrtc::VideoCodecType type) {
-  if (encoder_factory_ == NULL) {
+  if (!encoder_factory_) {
     return NULL;
   }
   return encoder_factory_->CreateVideoEncoder(type);
@@ -1496,7 +1500,7 @@
 
 void WebRtcVideoEngine::DestroyExternalEncoder(webrtc::VideoEncoder* encoder) {
   ASSERT(encoder_factory_ != NULL);
-  if (encoder_factory_ == NULL)
+  if (!encoder_factory_)
     return;
   encoder_factory_->DestroyVideoEncoder(encoder);
 }
@@ -1559,11 +1563,11 @@
     VoiceMediaChannel* channel)
     : engine_(engine),
       voice_channel_(channel),
-      vie_channel_(-1),
+      default_channel_id_(kChannelIdUnset),
       nack_enabled_(true),
       remb_enabled_(false),
       render_started_(false),
-      first_receive_ssrc_(0),
+      first_receive_ssrc_(kSsrcUnset),
       num_unsignalled_recv_channels_(0),
       send_rtx_type_(-1),
       send_red_type_(-1),
@@ -1576,7 +1580,7 @@
 
 bool WebRtcVideoMediaChannel::Init() {
   const uint32 ssrc_key = 0;
-  return CreateChannel(ssrc_key, MD_SENDRECV, &vie_channel_);
+  return CreateChannel(ssrc_key, MD_SENDRECV, &default_channel_id_);
 }
 
 WebRtcVideoMediaChannel::~WebRtcVideoMediaChannel() {
@@ -1758,7 +1762,7 @@
 
 bool WebRtcVideoMediaChannel::SetSendStreamFormat(uint32 ssrc,
                                                   const VideoFormat& format) {
-  WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(ssrc);
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     LOG(LS_ERROR) << "The specified ssrc " << ssrc << " is not in use.";
     return false;
@@ -1840,22 +1844,23 @@
   }
 
   uint32 ssrc_key;
-  if (!CreateSendChannelKey(sp.first_ssrc(), &ssrc_key)) {
+  if (!CreateSendChannelSsrcKey(sp.first_ssrc(), &ssrc_key)) {
     LOG(LS_ERROR) << "Trying to register duplicate ssrc: " << sp.first_ssrc();
     return false;
   }
   // If the default channel is already used for sending create a new channel
   // otherwise use the default channel for sending.
-  int channel_id = -1;
-  if (send_channels_[0]->stream_params() == NULL) {
-    channel_id = vie_channel_;
+  int channel_id = kChannelIdUnset;
+  if (!DefaultSendChannelInUse()) {
+    channel_id = default_channel_id_;
   } else {
     if (!CreateChannel(ssrc_key, MD_SEND, &channel_id)) {
       LOG(LS_ERROR) << "AddSendStream: unable to create channel";
       return false;
     }
   }
-  WebRtcVideoChannelSendInfo* send_channel = send_channels_[ssrc_key];
+
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key);
   // Set the send (local) SSRC.
   // If there are multiple send SSRCs, we can only set the first one here, and
   // the rest of the SSRC(s) need to be set after SetSendCodec has been called
@@ -1882,7 +1887,7 @@
   // the default channel make sure that all the receive channels are updated as
   // well. Receive channels have to have the same SSRC as the default channel in
   // order to send receiver reports with this SSRC.
-  if (IsDefaultChannel(channel_id)) {
+  if (IsDefaultChannelId(channel_id)) {
     for (RecvChannelMap::const_iterator it = recv_channels_.begin();
          it != recv_channels_.end(); ++it) {
       WebRtcVideoChannelRecvInfo* info = it->second;
@@ -1918,14 +1923,14 @@
   }
 
   uint32 ssrc_key;
-  if (!GetSendChannelKey(ssrc, &ssrc_key)) {
+  if (!GetSendChannelSsrcKey(ssrc, &ssrc_key)) {
     LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
                     << " which doesn't exist.";
     return false;
   }
-  WebRtcVideoChannelSendInfo* send_channel = send_channels_[ssrc_key];
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key);
   int channel_id = send_channel->channel_id();
-  if (IsDefaultChannel(channel_id) && (send_channel->stream_params() == NULL)) {
+  if (IsDefaultChannelId(channel_id) && !send_channel->stream_params()) {
     // Default channel will still exist. However, if stream_params() is NULL
     // there is no stream to remove.
     return false;
@@ -1947,8 +1952,8 @@
   send_channel->ClearRegisteredEncoders();
 
   // The receive channels depend on the default channel, recycle it instead.
-  if (IsDefaultChannel(channel_id)) {
-    SetCapturer(GetDefaultChannelSsrc(), NULL);
+  if (IsDefaultChannelId(channel_id)) {
+    SetCapturer(GetDefaultSendChannelSsrc(), NULL);
     send_channel->ClearStreamParams();
   } else {
     return DeleteSendChannel(ssrc_key);
@@ -1965,27 +1970,26 @@
   // TODO(zhurunz) Remove this once BWE works properly across different send
   // and receive channels.
   // Reuse default channel for recv stream in 1:1 call.
-  if (!InConferenceMode() && first_receive_ssrc_ == 0) {
+  if (!InConferenceMode() && first_receive_ssrc_ == kSsrcUnset) {
     LOG(LS_INFO) << "Recv stream " << sp.first_ssrc()
                  << " reuse default channel #"
-                 << vie_channel_;
+                 << default_channel_id_;
     first_receive_ssrc_ = sp.first_ssrc();
-    if (!MaybeSetRtxSsrc(sp, vie_channel_)) {
+    if (!MaybeSetRtxSsrc(sp, default_channel_id_)) {
       return false;
     }
     if (render_started_) {
-      if (engine()->vie()->render()->StartRender(vie_channel_) !=0) {
-        LOG_RTCERR1(StartRender, vie_channel_);
+      if (engine()->vie()->render()->StartRender(default_channel_id_) !=0) {
+        LOG_RTCERR1(StartRender, default_channel_id_);
       }
     }
     return true;
   }
 
-  int channel_id = -1;
-  RecvChannelMap::iterator channel_iterator =
-      recv_channels_.find(sp.first_ssrc());
-  if (channel_iterator == recv_channels_.end() &&
-      first_receive_ssrc_ != sp.first_ssrc()) {
+  int channel_id = kChannelIdUnset;
+  uint32 ssrc = sp.first_ssrc();
+  WebRtcVideoChannelRecvInfo* recv_channel = GetRecvChannelBySsrc(ssrc);
+  if (!recv_channel && first_receive_ssrc_ != ssrc) {
     // TODO(perkj): Implement recv media from multiple media SSRCs per stream.
     // NOTE: We have two SSRCs per stream when RTX is enabled.
     if (!IsOneSsrcStream(sp)) {
@@ -2003,13 +2007,12 @@
     }
   } else {
     // Already exists.
-    if (first_receive_ssrc_ == sp.first_ssrc()) {
+    if (first_receive_ssrc_ == ssrc) {
       return false;
     }
     // Early receive added channel.
-    channel_id = (*channel_iterator).second->channel_id();
+    channel_id = recv_channel->channel_id();
   }
-  channel_iterator = recv_channels_.find(sp.first_ssrc());
 
   if (!MaybeSetRtxSsrc(sp, channel_id)) {
     return false;
@@ -2018,13 +2021,13 @@
   // Get the default renderer.
   VideoRenderer* default_renderer = NULL;
   if (InConferenceMode()) {
-    // The recv_channels_ size start out being 1, so if it is two here this
-    // is the first receive channel created (vie_channel_ is not used for
-    // receiving in a conference call). This means that the renderer stored
-    // inside vie_channel_ should be used for the just created channel.
-    if (recv_channels_.size() == 2 &&
-        recv_channels_.find(0) != recv_channels_.end()) {
-      GetRenderer(0, &default_renderer);
+    // The recv_channels_ size start out being 1, so if it is two here
+    // this is the first receive channel created (default_channel_id_
+    // is not used for receiving in a conference call). This means
+    // that the renderer stored inside default_channel_id_ should be
+    // used for the just created channel.
+    if (recv_channels_.size() == 2 && GetDefaultRecvChannel()) {
+      GetDefaultRenderer(&default_renderer);
     }
   }
 
@@ -2036,8 +2039,8 @@
 
   LOG(LS_INFO) << "New video stream " << sp.first_ssrc()
                << " registered to VideoEngine channel #"
-               << channel_id << " and connected to channel #" << vie_channel_;
-
+               << channel_id << " and connected to channel #"
+               << default_channel_id_;
   return true;
 }
 
@@ -2068,26 +2071,25 @@
 }
 
 bool WebRtcVideoMediaChannel::RemoveRecvStreamInternal(uint32 ssrc) {
-  RecvChannelMap::iterator it = recv_channels_.find(ssrc);
-  if (it == recv_channels_.end()) {
+  WebRtcVideoChannelRecvInfo* recv_channel = GetRecvChannelBySsrc(ssrc);
+  if (!recv_channel) {
     // TODO(perkj): Remove this once BWE works properly across different send
     // and receive channels.
     // The default channel is reused for recv stream in 1:1 call.
     if (first_receive_ssrc_ == ssrc) {
-      first_receive_ssrc_ = 0;
+      first_receive_ssrc_ = kSsrcUnset;
       // Need to stop the renderer and remove it since the render window can be
       // deleted after this.
       if (render_started_) {
-        if (engine()->vie()->render()->StopRender(vie_channel_) !=0) {
-          LOG_RTCERR1(StopRender, it->second->channel_id());
+        if (engine()->vie()->render()->StopRender(default_channel_id_) !=0) {
+          LOG_RTCERR1(StopRender, recv_channel->channel_id());
         }
       }
-      recv_channels_[0]->SetRenderer(NULL);
+      GetDefaultRecvChannel()->SetRenderer(NULL);
       return true;
     }
     return false;
   }
-  WebRtcVideoChannelRecvInfo* info = it->second;
 
   // Remove any RTX SSRC mappings to this stream.
   SsrcMap::iterator rtx_it = rtx_to_primary_ssrc_.begin();
@@ -2099,7 +2101,7 @@
     }
   }
 
-  int channel_id = info->channel_id();
+  int channel_id = recv_channel->channel_id();
   if (engine()->vie()->render()->RemoveRenderer(channel_id) != 0) {
     LOG_RTCERR1(RemoveRenderer, channel_id);
   }
@@ -2114,7 +2116,7 @@
   }
 
   const WebRtcVideoChannelRecvInfo::DecoderMap& decoder_map =
-      info->registered_decoders();
+      recv_channel->registered_decoders();
   for (WebRtcVideoChannelRecvInfo::DecoderMap::const_iterator it =
        decoder_map.begin(); it != decoder_map.end(); ++it) {
     if (engine()->vie()->ext_codec()->DeRegisterExternalReceiveCodec(
@@ -2123,7 +2125,7 @@
     }
     engine()->DestroyExternalDecoder(it->second);
   }
-  info->ClearRegisteredDecoders();
+  recv_channel->ClearRegisteredDecoders();
 
   LOG(LS_INFO) << "Removing video stream " << ssrc
                << " with VideoEngine channel #"
@@ -2134,8 +2136,8 @@
     ret = false;
   }
   // Delete the WebRtcVideoChannelRecvInfo pointed to by it->second.
-  delete info;
-  recv_channels_.erase(it);
+  delete recv_channel;
+  recv_channels_.erase(ssrc);
   return ret;
 }
 
@@ -2203,67 +2205,86 @@
 
 bool WebRtcVideoMediaChannel::HasReadySendChannels() {
   return !send_channels_.empty() &&
-      ((send_channels_.size() > 1) ||
-       (send_channels_[0]->stream_params() != NULL));
+      ((send_channels_.size() > 1) || DefaultSendChannelInUse());
 }
 
-bool WebRtcVideoMediaChannel::GetSendChannelKey(uint32 local_ssrc,
-                                                uint32* key) {
-  *key = 0;
+bool WebRtcVideoMediaChannel::DefaultSendChannelInUse() {
+  return GetDefaultSendChannel() && GetDefaultSendChannel()->stream_params();
+}
+
+bool WebRtcVideoMediaChannel::GetSendChannelSsrcKey(uint32 local_ssrc,
+                                                    uint32* ssrc_key) {
+  *ssrc_key = kDefaultChannelSsrcKey;
   // If a send channel is not ready to send it will not have local_ssrc
   // registered to it.
   if (!HasReadySendChannels()) {
     return false;
   }
-  // The default channel is stored with key 0. The key therefore does not match
-  // the SSRC associated with the default channel. Check if the SSRC provided
-  // corresponds to the default channel's SSRC.
-  if (local_ssrc == GetDefaultChannelSsrc()) {
+  // The default channel is stored with ssrc key
+  // kDefaultChannelSsrcKey. The ssrc key therefore does not match the
+  // SSRC associated with the default channel. Check if the SSRC
+  // provided corresponds to the default channel's SSRC.
+  if (local_ssrc == GetDefaultSendChannelSsrc()) {
     return true;
   }
-  if (send_channels_.find(local_ssrc) == send_channels_.end()) {
+  if (!GetSendChannelBySsrcKey(local_ssrc)) {
     for (SendChannelMap::iterator iter = send_channels_.begin();
          iter != send_channels_.end(); ++iter) {
       WebRtcVideoChannelSendInfo* send_channel = iter->second;
       if (send_channel->has_ssrc(local_ssrc)) {
-        *key = iter->first;
+        *ssrc_key = iter->first;
         return true;
       }
     }
     return false;
   }
-  // The key was found in the above std::map::find call. This means that the
-  // ssrc is the key.
-  *key = local_ssrc;
+  // The ssrc key was found in the above std::map::find call. This
+  // means that the ssrc is the ssrc key.
+  *ssrc_key = local_ssrc;
   return true;
 }
 
-WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannel(
-    uint32 local_ssrc) {
-  uint32 key;
-  if (!GetSendChannelKey(local_ssrc, &key)) {
-    return NULL;
-  }
-  return send_channels_[key];
+WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetDefaultSendChannel() {
+  return GetSendChannelBySsrcKey(kDefaultChannelSsrcKey);
 }
 
-bool WebRtcVideoMediaChannel::CreateSendChannelKey(uint32 local_ssrc,
-                                                   uint32* key) {
-  if (GetSendChannelKey(local_ssrc, key)) {
-    // If there is a key corresponding to |local_ssrc|, the SSRC is already in
-    // use. SSRCs need to be unique in a session and at this point a duplicate
-    // SSRC has been detected.
+WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannelBySsrcKey(
+    uint32 ssrc_key) {
+  std::map<uint32, WebRtcVideoChannelSendInfo *>::iterator iter =
+      send_channels_.find(ssrc_key);
+  if (iter == send_channels_.end()) {
+    return NULL;
+  }
+  return iter->second;
+}
+
+WebRtcVideoChannelSendInfo* WebRtcVideoMediaChannel::GetSendChannelBySsrc(
+    uint32 local_ssrc) {
+  uint32 ssrc_key;
+  if (!GetSendChannelSsrcKey(local_ssrc, &ssrc_key)) {
+    return NULL;
+  }
+  return send_channels_[ssrc_key];
+}
+
+bool WebRtcVideoMediaChannel::CreateSendChannelSsrcKey(uint32 local_ssrc,
+                                                       uint32* ssrc_key) {
+  if (GetSendChannelSsrcKey(local_ssrc, ssrc_key)) {
+    // If there is an ssrc key corresponding to |local_ssrc|, the SSRC
+    // is already in use. SSRCs need to be unique in a session and at
+    // this point a duplicate SSRC has been detected.
     return false;
   }
-  if (send_channels_[0]->stream_params() == NULL) {
-    // key should be 0 here as the default channel should be re-used whenever it
-    // is not used.
-    *key = 0;
+  if (!DefaultSendChannelInUse()) {
+    // |ssrc_key| should be kDefaultChannelSsrcKey here as the default
+    // channel should be re-used whenever it is not used.
+    *ssrc_key = kDefaultChannelSsrcKey;
     return true;
   }
-  // SSRC is currently not in use and the default channel is already in use. Use
-  // the SSRC as key since it is supposed to be unique in a session.
-  *key = local_ssrc;
+  // SSRC is currently not in use and the default channel is already
+  // in use. Use the SSRC as ssrc_key since it is supposed to be
+  // unique in a session.
+  *ssrc_key = local_ssrc;
   return true;
 }
 
@@ -2279,21 +2300,18 @@
   return num;
 }
 
-uint32 WebRtcVideoMediaChannel::GetDefaultChannelSsrc() {
-  WebRtcVideoChannelSendInfo* send_channel = send_channels_[0];
-  const StreamParams* sp = send_channel->stream_params();
-  if (sp == NULL) {
-    // This happens if no send stream is currently registered.
+uint32 WebRtcVideoMediaChannel::GetDefaultSendChannelSsrc() {
+  if (!DefaultSendChannelInUse()) {
     return 0;
   }
-  return sp->first_ssrc();
+  return GetDefaultSendChannel()->stream_params()->first_ssrc();
 }
 
 bool WebRtcVideoMediaChannel::DeleteSendChannel(uint32 ssrc_key) {
-  if (send_channels_.find(ssrc_key) == send_channels_.end()) {
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrcKey(ssrc_key);
+  if (!send_channel) {
     return false;
   }
-  WebRtcVideoChannelSendInfo* send_channel = send_channels_[ssrc_key];
   MaybeDisconnectCapturer(send_channel->video_capturer());
   send_channel->set_video_capturer(NULL, engine()->vie());
 
@@ -2317,7 +2335,7 @@
   // The default channel is stored in both |send_channels_| and
   // |recv_channels_|. To make sure it is only deleted once from vie let the
   // delete call happen when tearing down |recv_channels_| and not here.
-  if (!IsDefaultChannel(channel_id)) {
+  if (!IsDefaultChannelId(channel_id)) {
     engine_->vie()->base()->DeleteChannel(channel_id);
   }
   delete send_channel;
@@ -2325,13 +2343,25 @@
   return true;
 }
 
+WebRtcVideoChannelRecvInfo* WebRtcVideoMediaChannel::GetDefaultRecvChannel() {
+  return GetRecvChannelBySsrc(kDefaultChannelSsrcKey);
+}
+
+WebRtcVideoChannelRecvInfo* WebRtcVideoMediaChannel::GetRecvChannelBySsrc(
+    uint32 ssrc) {
+  if (recv_channels_.find(ssrc) == recv_channels_.end()) {
+    return NULL;
+  }
+  return recv_channels_[ssrc];
+}
+
 bool WebRtcVideoMediaChannel::RemoveCapturer(uint32 ssrc) {
-  WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(ssrc);
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     return false;
   }
   VideoCapturer* capturer = send_channel->video_capturer();
-  if (capturer == NULL) {
+  if (!capturer) {
     return false;
   }
   MaybeDisconnectCapturer(capturer);
@@ -2345,22 +2375,22 @@
 
 bool WebRtcVideoMediaChannel::SetRenderer(uint32 ssrc,
                                           VideoRenderer* renderer) {
-  if (recv_channels_.find(ssrc) == recv_channels_.end()) {
+  WebRtcVideoChannelRecvInfo* recv_channel = GetRecvChannelBySsrc(ssrc);
+  if (!recv_channel) {
     // TODO(perkj): Remove this once BWE works properly across different send
     // and receive channels.
     // The default channel is reused for recv stream in 1:1 call.
-    if (first_receive_ssrc_ == ssrc &&
-        recv_channels_.find(0) != recv_channels_.end()) {
+    if (first_receive_ssrc_ == ssrc && GetDefaultRecvChannel()) {
       LOG(LS_INFO) << "SetRenderer " << ssrc
                    << " reuse default channel #"
-                   << vie_channel_;
-      recv_channels_[0]->SetRenderer(renderer);
+                   << default_channel_id_;
+      GetDefaultRecvChannel()->SetRenderer(renderer);
       return true;
     }
     return false;
   }
 
-  recv_channels_[ssrc]->SetRenderer(renderer);
+  recv_channel->SetRenderer(renderer);
   return true;
 }
 
@@ -2380,21 +2410,21 @@
       const int channel_id = send_channel->channel_id();
       VideoSenderInfo sinfo;
       const StreamParams* send_params = send_channel->stream_params();
-      if (send_params == NULL) {
+      if (!send_params) {
         // This should only happen if the default vie channel is not in use.
         // This can happen if no streams have ever been added or the stream
         // corresponding to the default channel has been removed. Note that
         // there may be non-default vie channels in use when this happen so
         // asserting send_channels_.size() == 1 is not correct and neither is
         // breaking out of the loop.
-        ASSERT(channel_id == vie_channel_);
+        ASSERT(channel_id == default_channel_id_);
         continue;
       }
       unsigned int bytes_sent, packets_sent, bytes_recv, packets_recv;
       if (engine_->vie()->rtp()->GetRTPStatistics(channel_id, bytes_sent,
                                                   packets_sent, bytes_recv,
                                                   packets_recv) != 0) {
-        LOG_RTCERR1(GetRTPStatistics, vie_channel_);
+        LOG_RTCERR1(GetRTPStatistics, default_channel_id_);
         continue;
       }
       WebRtcLocalStreamInfo* channel_stream_info =
@@ -2638,7 +2668,7 @@
     // Only call for the default channel because the returned stats are
     // collected for all the channels using the same estimator.
     if (engine_->vie()->rtp()->GetReceiveBandwidthEstimatorStats(
-        recv_channels_[0]->channel_id(), &additional_stats) == 0) {
+        GetDefaultRecvChannel()->channel_id(), &additional_stats) == 0) {
       bwe.total_received_propagation_delta_ms =
           additional_stats.total_propagation_time_delta_ms;
       bwe.recent_received_propagation_delta_ms.swap(
@@ -2649,7 +2679,7 @@
   }
 
   engine_->vie()->rtp()->GetPacerQueuingDelayMs(
-      recv_channels_[0]->channel_id(), &bwe.bucket_delay);
+      GetDefaultRecvChannel()->channel_id(), &bwe.bucket_delay);
 
   // Calculations done above per send/receive stream.
   bwe.actual_enc_bitrate = video_bitrate_sent;
@@ -2670,7 +2700,7 @@
   if (!capturer) {
     return RemoveCapturer(ssrc);
   }
-  WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(ssrc);
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     return false;
   }
@@ -2703,13 +2733,13 @@
   uint32 ssrc = 0;
   if (!GetRtpSsrc(packet->data(), packet->length(), &ssrc))
     return;
-  int processing_channel = GetRecvChannelNum(ssrc);
-  if (processing_channel == -1) {
+  int processing_channel_id = GetRecvChannelId(ssrc);
+  if (processing_channel_id == kChannelIdUnset) {
     // Allocate an unsignalled recv channel for processing in conference mode.
     if (!InConferenceMode()) {
       // If we can't find or allocate one, use the default.
-      processing_channel = video_channel();
-    } else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel)) {
+      processing_channel_id = default_channel_id_;
+    } else if (!CreateUnsignalledRecvChannel(ssrc, &processing_channel_id)) {
       // If we can't create an unsignalled recv channel, drop the packet in
       // conference mode.
       return;
@@ -2717,7 +2747,7 @@
   }
 
   engine()->vie()->network()->ReceivedRTPPacket(
-      processing_channel,
+      processing_channel_id,
       packet->data(),
       static_cast<int>(packet->length()),
       webrtc::PacketTime(packet_time.timestamp, packet_time.not_before));
@@ -2743,10 +2773,10 @@
 
   // If it is a sender report, find the channel that is listening.
   if (type == kRtcpTypeSR) {
-    int which_channel = GetRecvChannelNum(ssrc);
-    if (which_channel != -1 && !IsDefaultChannel(which_channel)) {
+    int recv_channel_id = GetRecvChannelId(ssrc);
+    if (recv_channel_id != kChannelIdUnset && !IsDefaultChannelId(recv_channel_id)) {
       engine_->vie()->network()->ReceivedRTCPPacket(
-          which_channel,
+          recv_channel_id,
           packet->data(),
           static_cast<int>(packet->length()));
     }
@@ -2770,7 +2800,7 @@
 }
 
 bool WebRtcVideoMediaChannel::MuteStream(uint32 ssrc, bool muted) {
-  WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(ssrc);
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     LOG(LS_ERROR) << "The specified ssrc " << ssrc << " is not in use.";
     return false;
@@ -3110,30 +3140,33 @@
 
 bool WebRtcVideoMediaChannel::GetRenderer(uint32 ssrc,
                                           VideoRenderer** renderer) {
-  RecvChannelMap::const_iterator it = recv_channels_.find(ssrc);
-  if (it == recv_channels_.end()) {
-    if (first_receive_ssrc_ == ssrc &&
-        recv_channels_.find(0) != recv_channels_.end()) {
+  WebRtcVideoChannelRecvInfo* recv_channel = GetRecvChannelBySsrc(ssrc);
+  if (!recv_channel) {
+    if (first_receive_ssrc_ == ssrc && GetDefaultRecvChannel()) {
       LOG(LS_INFO) << " GetRenderer " << ssrc
                    << " reuse default renderer #"
-                   << vie_channel_;
-      *renderer = recv_channels_[0]->render_adapter()->renderer();
+                   << default_channel_id_;
+      *renderer = GetDefaultRecvChannel()->render_adapter()->renderer();
       return true;
     }
     return false;
   }
 
-  *renderer = it->second->render_adapter()->renderer();
+  *renderer = recv_channel->render_adapter()->renderer();
   return true;
 }
 
+bool WebRtcVideoMediaChannel::GetDefaultRenderer(VideoRenderer** renderer) {
+  return GetRenderer(kDefaultChannelSsrcKey, renderer);
+}
+
 bool WebRtcVideoMediaChannel::GetVideoAdapter(
     uint32 ssrc, CoordinatedVideoAdapter** video_adapter) {
-  SendChannelMap::iterator it = send_channels_.find(ssrc);
-  if (it == send_channels_.end()) {
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
+  if (!send_channel) {
     return false;
   }
-  *video_adapter = it->second->video_adapter();
+  *video_adapter = send_channel->video_adapter();
   return true;
 }
 
@@ -3159,7 +3192,7 @@
   for (SendChannelMap::iterator iter = send_channels_.begin();
        iter != send_channels_.end(); ++iter) {
     WebRtcVideoChannelSendInfo* send_channel = iter->second;
-    if (send_channel->video_capturer() == NULL) {
+    if (!send_channel->video_capturer()) {
       SendFrame(send_channel, frame, capturer->IsScreencast());
     }
   }
@@ -3244,32 +3277,33 @@
                                             int* channel_id) {
   // There are 3 types of channels. Sending only, receiving only and
   // sending and receiving. The sending and receiving channel is the
-  // default channel and there is only one. All other channels that are created
-  // are associated with the default channel which must exist. The default
-  // channel id is stored in |vie_channel_|. All channels need to know about
-  // the default channel to properly handle remb which is why there are
-  // different ViE create channel calls.
-  // For this channel the local and remote ssrc key is 0. However, it may
-  // have a non-zero local and/or remote ssrc depending on if it is currently
-  // sending and/or receiving.
-  if ((vie_channel_ == -1 || direction == MD_SENDRECV) &&
+  // default channel and there is only one. All other channels that
+  // are created are associated with the default channel which must
+  // exist. The default channel id is stored in
+  // |default_channel_id_|. All channels need to know about the
+  // default channel to properly handle remb which is why there are
+  // different ViE create channel calls.  For this channel the local
+  // and remote ssrc_key is kDefaultChannelSsrcKey. However, it may
+  // have a non-zero local and/or remote ssrc depending on if it is
+  // currently sending and/or receiving.
+  if ((default_channel_id_ == kChannelIdUnset || direction == MD_SENDRECV) &&
       (!send_channels_.empty() || !recv_channels_.empty())) {
     ASSERT(false);
     return false;
   }
 
-  *channel_id = -1;
+  *channel_id = kChannelIdUnset;
   if (direction == MD_RECV) {
-    // All rec channels are associated with the default channel |vie_channel_|
+    // All rec channels are associated with default_channel_id_.
     if (engine_->vie()->base()->CreateReceiveChannel(*channel_id,
-                                                     vie_channel_) != 0) {
-      LOG_RTCERR2(CreateReceiveChannel, *channel_id, vie_channel_);
+                                                     default_channel_id_) != 0) {
+      LOG_RTCERR2(CreateReceiveChannel, *channel_id, default_channel_id_);
       return false;
     }
   } else if (direction == MD_SEND) {
     if (engine_->vie()->base()->CreateChannel(*channel_id,
-                                              vie_channel_) != 0) {
-      LOG_RTCERR2(CreateChannel, *channel_id, vie_channel_);
+                                              default_channel_id_) != 0) {
+      LOG_RTCERR2(CreateChannel, *channel_id, default_channel_id_);
       return false;
     }
   } else {
@@ -3281,7 +3315,7 @@
   }
   if (!ConfigureChannel(*channel_id, direction, ssrc_key)) {
     engine_->vie()->base()->DeleteChannel(*channel_id);
-    *channel_id = -1;
+    *channel_id = kChannelIdUnset;
     return false;
   }
 
@@ -3363,9 +3397,9 @@
 }
 
 bool WebRtcVideoMediaChannel::ConfigureReceiving(int channel_id,
-                                                 uint32 remote_ssrc_key) {
-  // Make sure that an SSRC/key isn't registered more than once.
-  if (recv_channels_.find(remote_ssrc_key) != recv_channels_.end()) {
+                                                 uint32 remote_ssrc) {
+  // Make sure that an SSRC isn't registered more than once.
+  if (GetRecvChannelBySsrc(remote_ssrc)) {
     return false;
   }
   // Connect the voice channel, if there is one.
@@ -3373,11 +3407,11 @@
   // know the SSRC of the remote audio channel in order to fetch the correct
   // webrtc VoiceEngine channel. For now- only sync the default channel used
   // in 1-1 calls.
-  if (remote_ssrc_key == 0 && voice_channel_) {
+  if (remote_ssrc == kDefaultChannelSsrcKey && voice_channel_) {
     WebRtcVoiceMediaChannel* voice_channel =
         static_cast<WebRtcVoiceMediaChannel*>(voice_channel_);
     if (engine_->vie()->base()->ConnectAudioChannel(
-        vie_channel_, voice_channel->voe_channel()) != 0) {
+        default_channel_id_, voice_channel->voe_channel()) != 0) {
       LOG_RTCERR2(ConnectAudioChannel, channel_id,
                   voice_channel->voe_channel());
       LOG(LS_WARNING) << "A/V not synchronized";
@@ -3414,13 +3448,13 @@
     return false;
   }
 
-  if (remote_ssrc_key != 0) {
+  if (remote_ssrc != kDefaultChannelSsrcKey) {
     // Use the same SSRC as our default channel
     // (so the RTCP reports are correct).
     unsigned int send_ssrc = 0;
     webrtc::ViERTP_RTCP* rtp = engine()->vie()->rtp();
-    if (rtp->GetLocalSSRC(vie_channel_, send_ssrc) == -1) {
-      LOG_RTCERR2(GetLocalSSRC, vie_channel_, send_ssrc);
+    if (rtp->GetLocalSSRC(default_channel_id_, send_ssrc) == -1) {
+      LOG_RTCERR2(GetLocalSSRC, default_channel_id_, send_ssrc);
       return false;
     }
     if (rtp->SetLocalSSRC(channel_id, send_ssrc) == -1) {
@@ -3464,7 +3498,7 @@
     return false;
   }
 
-  recv_channels_[remote_ssrc_key] = channel_info.release();
+  recv_channels_[remote_ssrc] = channel_info.release();
   return true;
 }
 
@@ -3472,12 +3506,12 @@
                                                uint32 local_ssrc_key) {
   // The ssrc key can be zero or correspond to an SSRC.
   // Make sure the default channel isn't configured more than once.
-  if (local_ssrc_key == 0 && send_channels_.find(0) != send_channels_.end()) {
+  if (local_ssrc_key == kDefaultChannelSsrcKey && GetDefaultSendChannel()) {
     return false;
   }
   // Make sure that the SSRC is not already in use.
   uint32 dummy_key;
-  if (GetSendChannelKey(local_ssrc_key, &dummy_key)) {
+  if (GetSendChannelSsrcKey(local_ssrc_key, &dummy_key)) {
     return false;
   }
   int vie_capture = 0;
@@ -3731,8 +3765,8 @@
 
 void WebRtcVideoMediaChannel::LogSendCodecChange(const std::string& reason) {
   webrtc::VideoCodec vie_codec;
-  if (engine()->vie()->codec()->GetSendCodec(vie_channel_, vie_codec) != 0) {
-    LOG_RTCERR1(GetSendCodec, vie_channel_);
+  if (engine()->vie()->codec()->GetSendCodec(default_channel_id_, vie_codec) != 0) {
+    LOG_RTCERR1(GetSendCodec, default_channel_id_);
     return;
   }
 
@@ -3846,28 +3880,28 @@
   return true;
 }
 
-int WebRtcVideoMediaChannel::GetRecvChannelNum(uint32 ssrc) {
+int WebRtcVideoMediaChannel::GetRecvChannelId(uint32 ssrc) {
   if (ssrc == first_receive_ssrc_) {
-    return vie_channel_;
+    return default_channel_id_;
   }
-  int recv_channel = -1;
-  RecvChannelMap::iterator it = recv_channels_.find(ssrc);
-  if (it == recv_channels_.end()) {
+  int recv_channel_id = kChannelIdUnset;
+  WebRtcVideoChannelRecvInfo* recv_channel = GetRecvChannelBySsrc(ssrc);
+  if (!recv_channel) {
     // Check if we have an RTX stream registered on this SSRC.
     SsrcMap::iterator rtx_it = rtx_to_primary_ssrc_.find(ssrc);
     if (rtx_it != rtx_to_primary_ssrc_.end()) {
       if (rtx_it->second == first_receive_ssrc_) {
-        recv_channel = vie_channel_;
+        recv_channel_id = default_channel_id_;
       } else {
-        it = recv_channels_.find(rtx_it->second);
-        assert(it != recv_channels_.end());
-        recv_channel = it->second->channel_id();
+        recv_channel = GetRecvChannelBySsrc(rtx_it->second);
+        ASSERT(recv_channel != NULL);
+        recv_channel_id = recv_channel->channel_id();
       }
     }
   } else {
-    recv_channel = it->second->channel_id();
+    recv_channel_id = recv_channel->channel_id();
   }
-  return recv_channel;
+  return recv_channel_id;
 }
 
 // If the new frame size is different from the send codec size we set on vie,
@@ -4057,7 +4091,7 @@
 }
 
 void WebRtcVideoMediaChannel::FlushBlackFrame(uint32 ssrc, int64 timestamp) {
-  WebRtcVideoChannelSendInfo* send_channel = GetSendChannel(ssrc);
+  WebRtcVideoChannelSendInfo* send_channel = GetSendChannelBySsrc(ssrc);
   if (!send_channel) {
     return;
   }
@@ -4145,14 +4179,14 @@
 }
 
 void WebRtcVideoMediaChannel::MaybeConnectCapturer(VideoCapturer* capturer) {
-  if (capturer != NULL && GetSendChannelNum(capturer) == 1) {
+  if (capturer && GetSendChannelNum(capturer) == 1) {
     capturer->SignalVideoFrame.connect(this,
                                        &WebRtcVideoMediaChannel::SendFrame);
   }
 }
 
 void WebRtcVideoMediaChannel::MaybeDisconnectCapturer(VideoCapturer* capturer) {
-  if (capturer != NULL && GetSendChannelNum(capturer) == 1) {
+  if (capturer && GetSendChannelNum(capturer) == 1) {
     capturer->SignalVideoFrame.disconnect(this);
   }
 }
diff --git a/media/webrtc/webrtcvideoengine.h b/media/webrtc/webrtcvideoengine.h
index f467b97..90f8d0c 100644
--- a/media/webrtc/webrtcvideoengine.h
+++ b/media/webrtc/webrtcvideoengine.h
@@ -243,11 +243,11 @@
 
   WebRtcVideoEngine* engine() { return engine_; }
   VoiceMediaChannel* voice_channel() { return voice_channel_; }
-  int video_channel() const { return vie_channel_; }
   bool sending() const { return sending_; }
 
   // Public for testing purpose.
-  uint32 GetDefaultChannelSsrc();
+  uint32 GetDefaultSendChannelSsrc();
+  int GetDefaultChannelId() const { return default_channel_id_; }
 
   // VideoMediaChannel implementation
   virtual bool SetRecvCodecs(const std::vector<VideoCodec> &codecs);
@@ -318,14 +318,15 @@
 
   enum MediaDirection { MD_RECV, MD_SEND, MD_SENDRECV };
 
-  // Creates and initializes a ViE channel. When successful |channel_id| will
-  // contain the new channel's ID. If |receiving| is true |ssrc| is the
-  // remote ssrc. If |sending| is true the ssrc is local ssrc. If both
-  // |receiving| and |sending| is true the ssrc must be 0 and the channel will
-  // be created as a default channel. The ssrc must be different for receive
-  // channels and it must be different for send channels. If the same SSRC is
-  // being used for creating channel more than once, this function will fail
-  // returning false.
+  // Creates and initializes a ViE channel. When successful
+  // |channel_id| will contain the new channel's ID. If |receiving| is
+  // true |ssrc| is the remote ssrc. If |sending| is true the ssrc is
+  // local ssrc. If both |receiving| and |sending| is true the ssrc
+  // must be kDefaultChannelSsrcKey and the channel will be created as
+  // a default channel. The ssrc must be different for receive
+  // channels and it must be different for send channels. If the same
+  // SSRC is being used for creating channel more than once, this
+  // function will fail returning false.
   bool CreateChannel(uint32 ssrc_key, MediaDirection direction,
                      int* channel_id);
   bool CreateUnsignalledRecvChannel(uint32 ssrc_key, int* channel_id);
@@ -342,8 +343,8 @@
   // Prepares the channel with channel id |info->channel_id()| to receive all
   // codecs in |receive_codecs_| and start receive packets.
   bool SetReceiveCodecs(WebRtcVideoChannelRecvInfo* info);
-  // Returns the channel number that receives the stream with SSRC |ssrc|.
-  int GetRecvChannelNum(uint32 ssrc);
+  // Returns the channel ID that receives the stream with SSRC |ssrc|.
+  int GetRecvChannelId(uint32 ssrc);
   bool MaybeSetRtxSsrc(const StreamParams& sp, int channel_id);
   // Given captured video frame size, checks if we need to reset vie send codec.
   // |reset| is set to whether resetting has happened on vie or not.
@@ -365,25 +366,34 @@
   bool SendIntraFrame(int channel_id);
 
   bool HasReadySendChannels();
+  bool DefaultSendChannelInUse();
 
-  // Send channel key returns the key corresponding to the provided local SSRC
-  // in |key|. The return value is true upon success.
-  // If the local ssrc correspond to that of the default channel the key is 0.
-  // For all other channels the returned key will be the same as the local ssrc.
-  bool GetSendChannelKey(uint32 local_ssrc, uint32* key);
-  WebRtcVideoChannelSendInfo* GetSendChannel(uint32 local_ssrc);
-  // Creates a new unique key that can be used for inserting a new send channel
-  // into |send_channels_|
-  bool CreateSendChannelKey(uint32 local_ssrc, uint32* key);
+  // Returns the ssrc key corresponding to the provided local SSRC in
+  // |ssrc_key|. The return value is true upon success.  If the local
+  // ssrc correspond to that of the default channel the key is
+  // kDefaultChannelSsrcKey.
+  // For all other channels the returned ssrc key will be the same as
+  // the local ssrc.
+  bool GetSendChannelSsrcKey(uint32 local_ssrc, uint32* ssrc_key);
+  WebRtcVideoChannelSendInfo* GetDefaultSendChannel();
+  WebRtcVideoChannelSendInfo* GetSendChannelBySsrcKey(uint32 ssrc_key);
+  WebRtcVideoChannelSendInfo* GetSendChannelBySsrc(uint32 local_ssrc);
+  // Creates a new unique ssrc key that can be used for inserting a
+  // new send channel into |send_channels_|
+  bool CreateSendChannelSsrcKey(uint32 local_ssrc, uint32* ssrc_key);
   // Get the number of the send channels |capturer| registered with.
   int GetSendChannelNum(VideoCapturer* capturer);
 
-  bool IsDefaultChannel(int channel_id) const {
-    return channel_id == vie_channel_;
+  bool IsDefaultChannelId(int channel_id) const {
+    return channel_id == default_channel_id_;
   }
+  bool GetDefaultRenderer(VideoRenderer** renderer);
 
   bool DeleteSendChannel(uint32 ssrc_key);
 
+  WebRtcVideoChannelRecvInfo* GetDefaultRecvChannel();
+  WebRtcVideoChannelRecvInfo* GetRecvChannelBySsrc(uint32 ssrc);
+
   bool InConferenceMode() const {
     return options_.conference_mode.GetWithDefaultIfUnset(false);
   }
@@ -420,17 +430,17 @@
   // Global state.
   WebRtcVideoEngine* engine_;
   VoiceMediaChannel* voice_channel_;
-  int vie_channel_;
+  int default_channel_id_;
   bool nack_enabled_;
   // Receiver Estimated Max Bitrate
   bool remb_enabled_;
   VideoOptions options_;
 
   // Global recv side state.
-  // Note the default channel (vie_channel_), i.e. the send channel
+  // Note the default channel (default_channel_id_), i.e. the send channel
   // corresponding to all the receive channels (this must be done for REMB to
   // work properly), resides in both recv_channels_ and send_channels_ with the
-  // ssrc key 0.
+  // ssrc key kDefaultChannelSsrcKey.
   RecvChannelMap recv_channels_;  // Contains all receive channels.
   // A map from the SSRCs on which RTX packets are received to the media SSRCs
   // the RTX packets are associated with. RTX packets will be delivered to the