Bug 1210660 - Change vp8 threshold for static images in screensharing mode. r=jesup, a=gchang
authorDan Minor <dminor@mozilla.com>
Thu, 09 Jun 2016 13:38:43 -0400
changeset 325586 ad0fd95d483125bbbf02538854e692bde5c4a09d
parent 325585 5e62247fa0438d7c5218fc8437849c16dd3ffde5
child 325587 822a68704ed4ab149303597be3a8b2870a9a9f77
push id9843
push userryanvm@gmail.com
push dateFri, 29 Jul 2016 20:53:22 +0000
treeherdermozilla-aurora@42c3abe40b3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, gchang
bugs1210660
milestone49.0a2
Bug 1210660 - Change vp8 threshold for static images in screensharing mode. r=jesup, a=gchang This changes the static threshold in screensharing mode and ensures that the screensharing mode is in fact passed to the codec. This also causes the peer connection to update the media pipelines when a track is replaced to cause the codec to be notified that the source has changed and to change settings appropriately. It seems to be a common use case to have a camera track be replaced by a screenshare track during a call. MozReview-Commit-ID: HbV14uL4kIL
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/trunk/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -708,16 +708,17 @@ WebrtcVideoConduit::ConfigureSendMediaCo
 
   if(codecFound == false)
   {
     CSFLogError(logTag, "%s Codec Mismatch ", __FUNCTION__);
     return kMediaConduitInvalidSendCodec;
   }
   // Note: only for overriding parameters from GetCodec()!
   CodecConfigToWebRTCCodec(codecConfig, video_codec);
+  video_codec.mode = mCodecMode;
 
   if(mPtrViECodec->SetSendCodec(mChannel, video_codec) == -1)
   {
     error = mPtrViEBase->LastError();
     if(error == kViECodecInvalidCodec)
     {
       CSFLogError(logTag, "%s Invalid Send Codec", __FUNCTION__);
       return kMediaConduitInvalidSendCodec;
@@ -1340,16 +1341,17 @@ WebrtcVideoConduit::ReconfigureSendCodec
   }
   if (vie_codec.numberOfSimulcastStreams != 0) {
     vie_codec.minBitrate = std::max(minMinBitrate, vie_codec.minBitrate);
     vie_codec.maxBitrate = std::min(totalMaxBitrate, vie_codec.maxBitrate);
     vie_codec.startBitrate = std::max(vie_codec.minBitrate,
                                       std::min(minStartBitrate,
                                                vie_codec.maxBitrate));
   }
+  vie_codec.mode = mCodecMode;
   if ((err = mPtrViECodec->SetSendCodec(mChannel, vie_codec)) != 0)
   {
     CSFLogError(logTag, "%s: SetSendCodec(%ux%u) failed, err %d",
                 __FUNCTION__, width, height, err);
     return NS_ERROR_FAILURE;
   }
   if (mMinBitrateEstimate != 0) {
     mPtrViENetwork->SetBitrateConfig(mChannel,
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -2511,16 +2511,21 @@ PeerConnectionImpl::ReplaceTrack(MediaSt
     return NS_OK;
   }
   aThisTrack.RemovePrincipalChangeObserver(this);
   aWithTrack.AddPrincipalChangeObserver(this);
 #if !defined(MOZILLA_EXTERNAL_LINKAGE)
   PrincipalChanged(&aWithTrack);
 #endif
 
+  // We update the media pipelines here so we can apply different codec
+  // settings for different sources (e.g. screensharing as opposed to camera.)
+  // TODO: We should probably only do this if the source has in fact changed.
+  mMedia->UpdateMediaPipelines(*mJsepSession);
+
   pco->OnReplaceTrackSuccess(jrv);
   if (jrv.Failed()) {
     CSFLogError(logTag, "Error firing replaceTrack success callback");
     return NS_ERROR_UNEXPECTED;
   }
 
   return NS_OK;
 }
--- a/media/webrtc/trunk/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
+++ b/media/webrtc/trunk/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
@@ -680,17 +680,18 @@ int VP8EncoderImpl::InitAndSetControlSet
                     codec_.codecSpecific.VP8.denoisingOn ?
                     denoiser_state : kDenoiserOff);
   if (encoders_.size() > 2) {
     vpx_codec_control(&encoders_[1], VP8E_SET_NOISE_SENSITIVITY,
                       codec_.codecSpecific.VP8.denoisingOn ?
                       denoiser_state : kDenoiserOff);
   }
   for (size_t i = 0; i < encoders_.size(); ++i) {
-    vpx_codec_control(&(encoders_[i]), VP8E_SET_STATIC_THRESHOLD, 1);
+    vpx_codec_control(&(encoders_[i]), VP8E_SET_STATIC_THRESHOLD,
+                      codec_.mode == kScreensharing ? 300 : 1);
     vpx_codec_control(&(encoders_[i]), VP8E_SET_CPUUSED, cpu_speed_[i]);
     vpx_codec_control(&(encoders_[i]), VP8E_SET_TOKEN_PARTITIONS,
                       static_cast<vp8e_token_partitions>(token_partitions_));
     vpx_codec_control(&(encoders_[i]), VP8E_SET_MAX_INTRA_BITRATE_PCT,
                       rc_max_intra_target_);
     vpx_codec_control(&(encoders_[i]), VP8E_SET_SCREEN_CONTENT_MODE,
                       codec_.mode == kScreensharing);
   }