From 6f46d0a0df131b18d21003f72f89c060bafdd6f2 Mon Sep 17 00:00:00 2001 From: Randell Jesup Date: Sun, 27 Jul 2014 19:59:46 -0400 Subject: [PATCH] Bug 1043515: Add max-br and max-mbps H.264 SDP fmtp parameters; update supported h264 level r=ehugg --- .../signaling/src/media/VcmSIPCCBinding.cpp | 64 ++++++++++++++----- .../src/sipcc/core/common/prot_configmgr.c | 22 +++++++ .../src/sipcc/core/common/prot_configmgr.h | 2 + .../signaling/src/sipcc/core/gsm/gsm_sdp.c | 16 ++++- .../webrtc/signaling/src/sipcc/include/vcm.h | 6 +- modules/libpref/src/init/all.js | 4 ++ 6 files changed, 95 insertions(+), 19 deletions(-) diff --git a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp index 78b2630d2820..82b4cef1e251 100644 --- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp +++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp @@ -2873,7 +2873,14 @@ uint32_t vcmGetVideoH264ProfileLevelID() { // constrained baseline level 1.2 // XXX make variable based on openh264 and OMX support +#ifdef MOZ_WEBRTC_OMX + // 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 } /** @@ -3368,11 +3375,11 @@ int vcmDisableRtcpComponent(const char *peerconnection, int level) { return ret; } -static short vcmGetVideoMaxFs_m(uint16_t codec, - int32_t *max_fs) { +static short vcmGetVideoPref_m(uint16_t codec, + const char *pref, + int32_t *ret) { nsCOMPtr branch = VcmSIPCCBinding::getPrefBranch(); - if (branch && NS_SUCCEEDED(branch->GetIntPref("media.navigator.video.max_fs", - max_fs))) { + if (branch && NS_SUCCEEDED(branch->GetIntPref(pref, ret))) { return 0; } return VCM_ERROR; @@ -3383,31 +3390,56 @@ short vcmGetVideoMaxFs(uint16_t codec, short ret; mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(), - WrapRunnableNMRet(&vcmGetVideoMaxFs_m, + WrapRunnableNMRet(&vcmGetVideoPref_m, codec, + "media.navigator.video.max_fs", max_fs, &ret)); return ret; } -static short vcmGetVideoMaxFr_m(uint16_t codec, - int32_t *max_fr) { - nsCOMPtr branch = VcmSIPCCBinding::getPrefBranch(); - if (branch && NS_SUCCEEDED(branch->GetIntPref("media.navigator.video.max_fr", - max_fr))) { - return 0; - } - return VCM_ERROR; -} - short vcmGetVideoMaxFr(uint16_t codec, int32_t *max_fr) { short ret; mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(), - WrapRunnableNMRet(&vcmGetVideoMaxFr_m, + WrapRunnableNMRet(&vcmGetVideoPref_m, codec, + "media.navigator.video.max_fr", max_fr, &ret)); return ret; } + +short vcmGetVideoMaxBr(uint16_t codec, + int32_t *max_br) { + short ret; + + mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(), + WrapRunnableNMRet(&vcmGetVideoPref_m, + codec, + "media.navigator.video.h264.max_br", + max_br, + &ret)); + return ret; +} + +short vcmGetVideoMaxMbps(uint16_t codec, + int32_t *max_mbps) { + short ret; + + mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(), + WrapRunnableNMRet(&vcmGetVideoPref_m, + codec, + "media.navigator.video.h264.max_mbps", + max_mbps, + &ret)); + if (ret == VCM_ERROR) { +#ifdef MOZ_WEBRTC_OMX + // Level 1.2; but let's allow CIF@30 or QVGA@30+ by default + *max_mbps = 11880; + ret = 0; +#endif + } + return ret; +} diff --git a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c index 8c0727756c7a..cf3b2028382e 100755 --- a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c +++ b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c @@ -593,6 +593,28 @@ config_get_video_max_fr(const rtp_ptype codec) return 0; } +uint32_t +config_get_video_max_mbps(const rtp_ptype codec) +{ + uint32_t max_mbps; + + if(vcmGetVideoMaxMbps(codec, (int32_t *) &max_mbps) == 0) { + return max_mbps; + } + return 0; +} + +uint32_t +config_get_video_max_br(const rtp_ptype codec) +{ + uint32_t max_br; + + if(vcmGetVideoMaxBr(codec, (int32_t *) &max_br) == 0) { + return max_br; + } + return 0; +} + uint16_t sip_config_video_add_codecs (rtp_ptype aSupportedCodecs[], uint16_t supportedCodecsLen, diff --git a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.h b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.h index 0aa6dc3c7423..dd4310e14fc2 100755 --- a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.h +++ b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.h @@ -294,5 +294,7 @@ int sip_config_get_keepalive_expires(); rtp_ptype sip_config_preferred_codec(void); uint32_t config_get_video_max_fs(const rtp_ptype codec); uint32_t config_get_video_max_fr(const rtp_ptype codec); +uint32_t config_get_video_max_mbps(const rtp_ptype codec); +uint32_t config_get_video_max_br(const rtp_ptype codec); #endif /* PROT_CONFIGMGR_H_ */ diff --git a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c index 5c0015e7af71..77a01c4b353a 100644 --- a/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c +++ b/media/webrtc/signaling/src/sipcc/core/gsm/gsm_sdp.c @@ -1141,6 +1141,8 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t void *sdp_p = ((cc_sdp_t*)cc_sdp_p)->src_sdp; int max_fs = 0; int max_fr = 0; + int max_br = 0; + int max_mbps = 0; switch (media_type) { case RTP_H263: @@ -1211,11 +1213,14 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t switch (media_type) { case RTP_H264_P0: case RTP_H264_P1: + max_br = config_get_video_max_br((rtp_ptype) media_type); // H264 only + max_mbps = config_get_video_max_mbps((rtp_ptype) media_type); // H264 only + // fall through case RTP_VP8: max_fs = config_get_video_max_fs((rtp_ptype) media_type); max_fr = config_get_video_max_fr((rtp_ptype) media_type); - if (max_fs || max_fr) { + if (max_fs || max_fr || max_br || max_mbps) { if (!added_fmtp) { if (sdp_add_new_attr(sdp_p, level, 0, SDP_ATTR_FMTP, &a_inst) != SDP_SUCCESS) { @@ -1232,11 +1237,18 @@ gsmsdp_set_video_media_attributes (uint32_t media_type, void *cc_sdp_p, uint16_t (void) sdp_attr_set_fmtp_max_fs(sdp_p, level, 0, a_inst, max_fs); } - if (max_fr) { (void) sdp_attr_set_fmtp_max_fr(sdp_p, level, 0, a_inst, max_fr); } + if (max_br) { + (void) sdp_attr_set_fmtp_max_br(sdp_p, level, 0, a_inst, + max_br); + } + if (max_mbps) { + (void) sdp_attr_set_fmtp_max_mbps(sdp_p, level, 0, a_inst, + max_mbps); + } } break; } diff --git a/media/webrtc/signaling/src/sipcc/include/vcm.h b/media/webrtc/signaling/src/sipcc/include/vcm.h index a499e13e585b..ba63badb9396 100755 --- a/media/webrtc/signaling/src/sipcc/include/vcm.h +++ b/media/webrtc/signaling/src/sipcc/include/vcm.h @@ -1085,7 +1085,11 @@ int vcmDisableRtcpComponent(const char *peerconnection, int level); short vcmGetVideoMaxFs(uint16_t codec, int32_t *max_fs); -short vcmGetVideoMaxFr(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); //Using C++ for gips. This is the end of extern "C" above. #ifdef __cplusplus diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index cc1c526b8987..909fa63fef6d 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -295,6 +295,8 @@ 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.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 @@ -304,6 +306,8 @@ 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.max_br", 0); +pref("media.navigator.video.h264.max_mbps", 0); pref("media.peerconnection.video.h264_enabled", false); pref("media.getusermedia.aec", 1); #endif