Bug 1056350: Make H.264 Level configurable and change OpenH264 default to 3.1 r=bwc a=sylvestre
authorRandell Jesup <rjesup@jesup.org>
Fri, 29 Aug 2014 21:29:18 -0400
changeset 217748 8c42c04e31a72f6c4ed4786532e9956057afa6a9
parent 217747 2ec53377f6b4e9cee6590e8cf0ac1942875320b5
child 217749 4422793dc9f5d17c271f14336c462fde4c9ef794
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, sylvestre
bugs1056350
milestone33.0a2
Bug 1056350: Make H.264 Level configurable and change OpenH264 default to 3.1 r=bwc a=sylvestre
media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
media/webrtc/signaling/src/sipcc/include/vcm.h
modules/libpref/src/init/all.js
--- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
+++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
@@ -2227,22 +2227,21 @@ static int vcmEnsureExternalCodec(
   } else if (config->mName == "H264_P0" || config->mName == "H264_P1") {
     // Here we use "I420" to register H.264 because WebRTC.org code has a
     // whitelist of supported video codec in |webrtc::ViECodecImpl::CodecValid()|
     // and will reject registration of those not in it.
     // TODO: bug 995884 to support H.264 in WebRTC.org code.
 
     // Register H.264 codec.
     if (send) {
-	VideoEncoder* encoder = nullptr;
+      VideoEncoder* encoder = nullptr;
 #ifdef MOZ_WEBRTC_OMX
-	encoder = OMXVideoCodec::CreateEncoder(
-	    OMXVideoCodec::CodecType::CODEC_H264);
+      encoder = OMXVideoCodec::CreateEncoder(OMXVideoCodec::CodecType::CODEC_H264);
 #else
-	encoder = mozilla::GmpVideoCodec::CreateEncoder();
+      encoder = mozilla::GmpVideoCodec::CreateEncoder();
 #endif
       if (encoder) {
         return conduit->SetExternalSendCodec(config, encoder);
       } else {
         return kMediaConduitInvalidSendCodec;
       }
     } else {
       VideoDecoder* decoder;
@@ -2869,26 +2868,25 @@ int vcmGetH264SupportedPacketizationMode
 }
 
 /**
  * Get supported H.264 profile-level-id
  * @return supported profile-level-id value
  */
 uint32_t vcmGetVideoH264ProfileLevelID()
 {
-  // constrained baseline level 1.2
-  // XXX make variable based on openh264 and OMX support
-#ifdef MOZ_WEBRTC_OMX
+  // For OMX, constrained baseline level 1.2 (via a pref)
   // Max resolution CIF; we should include max-mbps
-  return 0x42E00C;
-#else
-  // XXX See bug 1043515 - we may want to support a higher profile than
-  // 1.3, depending on hardware(?)
-  return 0x42E00D;
-#endif
+  int32_t level = 13; // minimum suggested for WebRTC spec
+
+  vcmGetVideoLevel(0, &level);
+  level &= 0xFF;
+  level |= 0x42E000;
+
+  return (uint32_t) level;
 }
 
 /**
  *  MEDIA control received from far end on signaling path
  *
  *  @param call_handle - call_handle of the call
  *  @param to_encoder - the control request received
  *        Only FAST_PICTURE_UPDATE is supported
@@ -3383,16 +3381,29 @@ static short vcmGetVideoPref_m(uint16_t 
                                int32_t *ret) {
   nsCOMPtr<nsIPrefBranch> branch = VcmSIPCCBinding::getPrefBranch();
   if (branch && NS_SUCCEEDED(branch->GetIntPref(pref, ret))) {
     return 0;
   }
   return VCM_ERROR;
 }
 
+short vcmGetVideoLevel(uint16_t codec,
+                       int32_t *level) {
+  short ret;
+
+  mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(),
+      WrapRunnableNMRet(&vcmGetVideoPref_m,
+                        codec,
+                        "media.navigator.video.h264.level",
+                        level,
+                        &ret));
+  return ret;
+}
+
 short vcmGetVideoMaxFs(uint16_t codec,
                        int32_t *max_fs) {
   short ret;
 
   mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(),
       WrapRunnableNMRet(&vcmGetVideoPref_m,
                         codec,
                         "media.navigator.video.max_fs",
--- a/media/webrtc/signaling/src/sipcc/include/vcm.h
+++ b/media/webrtc/signaling/src/sipcc/include/vcm.h
@@ -1078,24 +1078,21 @@ int vcmOnSdpParseError(const char *peerc
 /**
  * vcmDisableRtcpComponent
  *
  * If we are doing rtcp-mux we need to disable component number 2 in the ICE
  * layer.  Otherwise we will wait for it to connect when it is unused
  */
 int vcmDisableRtcpComponent(const char *peerconnection, int level);
 
+short vcmGetVideoLevel(uint16_t codec, int32_t *level);
 short vcmGetVideoMaxFs(uint16_t codec, int32_t *max_fs);
-
 short vcmGetVideoMaxFr(uint16_t codec, int32_t *max_fr);
-
 short vcmGetVideoMaxBr(uint16_t codec, int32_t *max_br);
-
 short vcmGetVideoMaxMbps(uint16_t codec, int32_t *max_mbps);
-
 short vcmGetVideoPreferredCodec(int32_t *preferred_codec);
 
 //Using C++ for gips. This is the end of extern "C" above.
 #ifdef __cplusplus
 }
 #endif
 
 
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -292,27 +292,29 @@ pref("media.webrtc.debug.aec_dump_max_si
 
 #ifdef MOZ_WIDGET_GONK
 pref("media.navigator.video.default_width",320);
 pref("media.navigator.video.default_height",240);
 pref("media.peerconnection.enabled", true);
 pref("media.peerconnection.video.enabled", true);
 pref("media.navigator.video.max_fs", 1200); // 640x480 == 1200mb
 pref("media.navigator.video.max_fr", 30);
+pref("media.navigator.video.h264.level", 12); // 0x42E00C - level 1.2
 pref("media.navigator.video.h264.max_br", 700); // 8x10
 pref("media.navigator.video.h264.max_mbps", 11880); // CIF@30fps
 pref("media.peerconnection.video.h264_enabled", false);
 pref("media.getusermedia.aec", 4);
 #else
 pref("media.navigator.video.default_width",0);  // adaptive default
 pref("media.navigator.video.default_height",0); // adaptive default
 pref("media.peerconnection.enabled", true);
 pref("media.peerconnection.video.enabled", true);
 pref("media.navigator.video.max_fs", 0); // unrestricted
 pref("media.navigator.video.max_fr", 0); // unrestricted
+pref("media.navigator.video.h264.level", 31); // 0x42E01f - level 3.1
 pref("media.navigator.video.h264.max_br", 0);
 pref("media.navigator.video.h264.max_mbps", 0);
 pref("media.peerconnection.video.h264_enabled", false);
 pref("media.getusermedia.aec", 1);
 pref("media.getusermedia.browser.enabled", true);
 #endif
 pref("media.peerconnection.video.min_bitrate", 200);
 pref("media.peerconnection.video.start_bitrate", 300);