Bug 1056350: Make H.264 Level configurable and change OpenH264 default to 3.1 r=bwc
authorRandell Jesup <rjesup@jesup.org>
Fri, 29 Aug 2014 21:29:18 -0400
changeset 202569 899bffa59af5a65f8d0e78a0ddaeab0264790be0
parent 202568 d07a9cabc185cf3d16f9ba527127f813fcec8123
child 202570 e9a97ae0e909798b9e2a5168fb624e4975f806e1
push id27402
push userryanvm@gmail.com
push dateSat, 30 Aug 2014 16:25:31 +0000
treeherdermozilla-central@983cf2175495 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1056350
milestone34.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 1056350: Make H.264 Level configurable and change OpenH264 default to 3.1 r=bwc
media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
media/webrtc/signaling/src/sipcc/include/vcm.h
modules/libpref/init/all.js
--- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
+++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp
@@ -1714,22 +1714,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;
@@ -2306,26 +2305,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
@@ -2781,16 +2779,23 @@ static short vcmGetVideoPref(uint16_t co
                              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) {
+  return vcmGetVideoPref(codec,
+                         "media.navigator.video.h264.level",
+                         level);
+}
+
 short vcmGetVideoMaxFs(uint16_t codec,
                        int32_t *max_fs) {
   return vcmGetVideoPref(codec,
                          "media.navigator.video.max_fs",
                          max_fs);
 }
 
 short vcmGetVideoMaxFr(uint16_t codec,
--- 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/init/all.js
+++ b/modules/libpref/init/all.js
@@ -298,27 +298,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);