Bug 816112: Configure webrtc video/RTCP parameters for better defaults r=jesup
authorEKR <ekr@rtfm.com>
Wed, 28 Nov 2012 08:34:10 -0800
changeset 124538 2bd521c3118f4337500f879c6a67dd64d2edc4f7
parent 124537 93cac86bdd9547c3a165b82af1cc1a5dcd90a228
child 124539 cc3df492214453772ebccc3d4f86e45a353d6dbb
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs816112
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 816112: Configure webrtc video/RTCP parameters for better defaults r=jesup
media/webrtc/signaling/src/media-conduit/MediaConduitErrors.h
media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
media/webrtc/signaling/src/media-conduit/VideoConduit.h
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitErrors.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitErrors.h
@@ -27,15 +27,19 @@ kMediaConduitInvalidTransport,         /
 kMediaConduitChannelError,             // Configuration Error
 kMediaConduitSocketError,              // Media Engine transport socket error
 kMediaConduitRTPRTCPModuleError,       // Couldn't start RTP/RTCP processing
 kMediaConduitRTPProcessingFailed,      // Processing incoming RTP frame failed
 kMediaConduitUnknownError,             // More information can be found in logs
 kMediaConduitExternalRecordingError,   // Couldn't start external recording
 kMediaConduitRecordingError,           // Runtime recording error
 kMediaConduitExternalPlayoutError,     // Couldn't start external playout
-kMediaConduitPlayoutError              // Runtime playout error
+kMediaConduitPlayoutError,             // Runtime playout error
+kMediaConduitMTUError,                 // Can't set MTU
+kMediaConduitRTCPStatusError,          // Can't set RTCP mode
+kMediaConduitKeyFrameRequestError,     // Can't set KeyFrameRequest mode
+kMediaConduitNACKStatusError           // Can't set NACK mode
 };
 
 }
 
 #endif
 
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
@@ -205,17 +205,16 @@ public:
    * @param sendSessionConfig: CodecConfiguration
    * NOTE: This API can be invoked multiple time. Invoking this API may involve restarting
    *        reception sub-system on the engine
    *
    */
   virtual MediaConduitErrorCode ConfigureRecvMediaCodecs(
                                 const std::vector<VideoCodecConfig* >& recvCodecConfigList) = 0;
 
-
 };
 
 /**
  * MediaSessionConduit for audio
  * Refer to the comments on MediaSessionConduit above for overall
  * information
  */
 class AudioSessionConduit : public MediaSessionConduit
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -71,16 +71,21 @@ WebrtcVideoConduit::~WebrtcVideoConduit(
   if(mPtrViEBase)
   {
     mPtrViEBase->StopSend(mChannel);
     mPtrViEBase->StopReceive(mChannel);
     mPtrViEBase->DeleteChannel(mChannel);
     mPtrViEBase->Release();
   }
 
+  if (mPtrRTP)
+  {
+    mPtrRTP->Release();
+  }
+
   if(mVideoEngine)
   {
     webrtc::VideoEngine::Delete(mVideoEngine);
   }
 }
 
 /**
  * Peforms intialization of the MANDATORY components of the Video Engine
@@ -99,44 +104,49 @@ MediaConduitErrorCode WebrtcVideoConduit
 #if 0
   // TRACING
   mVideoEngine->SetTraceFilter(webrtc::kTraceAll);
   mVideoEngine->SetTraceFile( "Vievideotrace.out" );
 #endif
 
   if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine)))
   {
-    CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
+    CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
   if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine)))
   {
-    CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
+    CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
   if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine)))
   {
-    CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
+    CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
   if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine)))
   {
-    CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
+    CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
   if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine)))
   {
-    CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__);
+    CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__);
     return kMediaConduitSessionNotInited;
   }
 
+  if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine)))
+  {
+    CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__);
+    return kMediaConduitSessionNotInited;
+  }
 
   CSFLogDebug(logTag, "%s Engine Created: Init'ng the interfaces ",__FUNCTION__);
 
   if(mPtrViEBase->Init() == -1)
   {
     CSFLogError(logTag, " %s Video Engine Init Failed %d ",__FUNCTION__,
                                                mPtrViEBase->LastError());
     return kMediaConduitSessionNotInited;
@@ -177,18 +187,45 @@ MediaConduitErrorCode WebrtcVideoConduit
 
   if(mPtrViERender->AddRenderer(mChannel,
                                 webrtc::kVideoI420,
                                 (webrtc::ExternalRenderer*) this) == -1)
   {
     CSFLogError(logTag, "%s Failed to added external renderer ", __FUNCTION__);
     return kMediaConduitInvalidRenderer;
   }
-
-
+  // Set up some parameters, per juberti. Set MTU.
+  if(mPtrViENetwork->SetMTU(mChannel, 1200) != 0)
+  {
+    CSFLogError(logTag,  "%s MTU Failed %d ", __FUNCTION__,
+                mPtrViEBase->LastError());
+    return kMediaConduitMTUError;
+  }
+  // Turn on RTCP and loss feedback reporting.
+  if(mPtrRTP->SetRTCPStatus(mChannel, webrtc::kRtcpCompound_RFC4585) != 0)
+  {
+    CSFLogError(logTag,  "%s RTCPStatus Failed %d ", __FUNCTION__,
+                mPtrViEBase->LastError());
+    return kMediaConduitRTCPStatusError;
+  }
+  // Enable pli as key frame request method.
+  if(mPtrRTP->SetKeyFrameRequestMethod(mChannel,
+                                    webrtc::kViEKeyFrameRequestPliRtcp) != 0)
+  {
+    CSFLogError(logTag,  "%s KeyFrameRequest Failed %d ", __FUNCTION__,
+                mPtrViEBase->LastError());
+    return kMediaConduitKeyFrameRequestError;
+  }
+  // Enable lossless transport
+  if (mPtrRTP->SetNACKStatus(mChannel, true) != 0)
+  {
+    CSFLogError(logTag,  "%s NACKStatus Failed %d ", __FUNCTION__,
+                mPtrViEBase->LastError());
+    return kMediaConduitNACKStatusError;
+  }
   CSFLogError(logTag, "%s Initialization Done", __FUNCTION__);
   return kMediaConduitNoError;
 }
 
 
 MediaConduitErrorCode
 WebrtcVideoConduit::AttachRenderer(mozilla::RefPtr<VideoRenderer> aVideoRenderer)
 {
@@ -321,16 +358,18 @@ WebrtcVideoConduit::ConfigureSendMediaCo
   //Copy the applied codec for future reference
   delete mCurSendCodecConfig;
 
   mCurSendCodecConfig = new VideoCodecConfig(codecConfig->mType,
                                               codecConfig->mName,
                                               codecConfig->mWidth,
                                               codecConfig->mHeight);
 
+  mPtrRTP->SetRembStatus(mChannel, true, false);
+
   // by now we should be successfully started the transmission
   mEngineTransmitting = true;
   return kMediaConduitNoError;
 }
 
 MediaConduitErrorCode
 WebrtcVideoConduit::ConfigureRecvMediaCodecs(
                     const std::vector<VideoCodecConfig* >& codecConfigList)
@@ -421,16 +460,17 @@ WebrtcVideoConduit::ConfigureRecvMediaCo
   {
     error = mPtrViEBase->LastError();
     CSFLogError(logTag, "%s Start Receive Error %d ", __FUNCTION__, error);
 
     return kMediaConduitUnknownError;
   }
 
   // by now we should be successfully started the reception
+  mPtrRTP->SetRembStatus(mChannel, false, true);
   mEngineReceiving = true;
   DumpCodecDB();
   return kMediaConduitNoError;
 }
 
 
 MediaConduitErrorCode
 WebrtcVideoConduit::SendVideoFrame(unsigned char* video_frame,
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h
@@ -12,16 +12,17 @@
 // Video Engine Includes
 #include "common_types.h"
 #include "video_engine/include/vie_base.h"
 #include "video_engine/include/vie_capture.h"
 #include "video_engine/include/vie_codec.h"
 #include "video_engine/include/vie_render.h"
 #include "video_engine/include/vie_network.h"
 #include "video_engine/include/vie_file.h"
+#include "video_engine/include/vie_rtp_rtcp.h"
 
 /** This file hosts several structures identifying different aspects
  * of a RTP Session.
  */
 
  using  webrtc::ViEBase;
  using  webrtc::ViENetwork;
  using  webrtc::ViECodec;
@@ -178,28 +179,28 @@ private:
   bool CheckCodecsForMatch(const VideoCodecConfig* curCodecConfig,
                            const VideoCodecConfig* codecInfo) const;
 
   //Checks the codec to be applied
   MediaConduitErrorCode ValidateCodecConfig(const VideoCodecConfig* codecInfo, bool send) const;
 
   //Utility function to dump recv codec database
   void DumpCodecDB() const;
-
   webrtc::VideoEngine* mVideoEngine;
 
   mozilla::RefPtr<TransportInterface> mTransport;
   mozilla::RefPtr<VideoRenderer> mRenderer;
 
   webrtc::ViEBase* mPtrViEBase;
   webrtc::ViECapture* mPtrViECapture;
   webrtc::ViECodec* mPtrViECodec;
   webrtc::ViENetwork* mPtrViENetwork;
   webrtc::ViERender* mPtrViERender;
   webrtc::ViEExternalCapture*  mPtrExtCapture;
+  webrtc::ViERTP_RTCP* mPtrRTP;
 
   // Engine state we are concerned with.
   bool mEngineTransmitting; //If true ==> Transmit Sub-system is up and running
   bool mEngineReceiving;    // if true ==> Receive Sus-sysmtem up and running
   bool mEngineRendererStarted; // If true ==> Rendering Sub-system is up and running
 
   int mChannel; // Video Channel for this conduit
   int mCapId;   // Capturer for this conduit