diff --git a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp index 82b4cef1e251..89ab5b4ea5b3 100644 --- a/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp +++ b/media/webrtc/signaling/src/media/VcmSIPCCBinding.cpp @@ -3443,3 +3443,15 @@ short vcmGetVideoMaxMbps(uint16_t codec, } return ret; } + +short vcmGetVideoPreferredCodec(int32_t *preferred_codec) { + short ret; + + mozilla::SyncRunnable::DispatchToThread(VcmSIPCCBinding::getMainThread(), + WrapRunnableNMRet(&vcmGetVideoPref_m, + (uint16_t)0, + "media.navigator.video.preferred_codec", + preferred_codec, + &ret)); + 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 cf3b2028382e..32ff6005c38e 100755 --- a/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c +++ b/media/webrtc/signaling/src/sipcc/core/common/prot_configmgr.c @@ -461,6 +461,13 @@ sip_config_get_display_name (line_t line, char *buffer, int buffer_len) rtp_ptype sip_config_preferred_codec (void) { +#if 1 + uint32_t codec; + + if(vcmGetVideoPreferredCodec((int32_t *) &codec) == 0) { + return (rtp_ptype) codec; + } +#else key_table_entry_t cfg_preferred_codec; config_get_value(CFGID_PREFERRED_CODEC, &cfg_preferred_codec, @@ -470,6 +477,7 @@ sip_config_preferred_codec (void) /* The configuration has preferred codec configured */ return (cfg_preferred_codec.value); } +#endif /* No preferred codec configured */ return (RTP_NONE); } @@ -656,6 +664,7 @@ sip_config_video_supported_codecs_get (rtp_ptype aSupportedCodecs[], uint16_t supportedCodecsLen, boolean isOffer) { uint16_t count = 0; + rtp_ptype pref_codec; int codec_mask; int hw_codec_mask = vcmGetVideoCodecList(VCM_DSP_FULLDUPLEX_HW); int gmp_codec_mask = vcmGetVideoCodecList(VCM_DSP_FULLDUPLEX_GMP); @@ -680,6 +689,22 @@ sip_config_video_supported_codecs_get (rtp_ptype aSupportedCodecs[], count += sip_config_video_add_codecs(&aSupportedCodecs[count], supportedCodecsLen, gmp_codec_mask); + // Now promote the preferred codec if any + pref_codec = sip_config_preferred_codec(); + if (pref_codec != RTP_NONE) { + int i,j; + for (i = 1; i < count; i++) { + if (aSupportedCodecs[i] == pref_codec) { + // bump it to the front; bump all the rest down + for (j = i; j > 0; j--) { + aSupportedCodecs[j] = aSupportedCodecs[j-1]; + } + aSupportedCodecs[0] = pref_codec; + return count; + } + } + // preferred not found, oh well + } return count; } diff --git a/media/webrtc/signaling/src/sipcc/include/vcm.h b/media/webrtc/signaling/src/sipcc/include/vcm.h index ba63badb9396..4b498e22a963 100755 --- a/media/webrtc/signaling/src/sipcc/include/vcm.h +++ b/media/webrtc/signaling/src/sipcc/include/vcm.h @@ -1091,6 +1091,8 @@ 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 }