/* * sip_config_local_supported_codecs_get() * * Get the locally supported codec list. */ uint16_t 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); if ( isOffer ) { codec_mask = vcmGetVideoCodecList(VCM_DSP_FULLDUPLEX); } else { /* we are trying to match the answer then we already have the rx stream open */ //codec_mask = vcmGetVideoCodecList(DSP_ENCODEONLY); codec_mask = vcmGetVideoCodecList(VCM_DSP_IGNORE); } // prefer HW codecs over SW count = sip_config_video_add_codecs(aSupportedCodecs, supportedCodecsLen, hw_codec_mask); // Now add any codecs that weren't in the initial list codec_mask &= ~hw_codec_mask; count += sip_config_video_add_codecs(&aSupportedCodecs[count], supportedCodecsLen, codec_mask); // Now add any GMP codecs that aren't already in gmp_codec_mask &= ~(hw_codec_mask | codec_mask); 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; }
/** * sip_config_local_supported_codecs_get() * Get the locally supported codec list. The returned list * of codecs will be in the ordered of preference. If there is * preferred condec configured and it is available, the * preferred codec will be put on the first entry of the * returned list. * * @param[in,out] aSupportedCodecs - pointer to arrary fo the * rtp_ptype to store the result of * currenlty available codecs. * @param[in] supportedCodecsLen - indicates the number of entry * of the aSupportedCodecs. * * @return number of current codecs available. * * @pre (aSupportedCodecs != NULL) * @pre (supportedCodecsLen != 0) */ uint16_t sip_config_local_supported_codecs_get (rtp_ptype aSupportedCodecs[], uint16_t supportedCodecsLen) { rtp_ptype current_codec_table[MAX_CODEC_ENTRIES+1]; rtp_ptype *codec; rtp_ptype pref_codec; uint16_t count = 0; int codec_mask; boolean preferred_codec_available = FALSE; codec_mask = vcmGetAudioCodecList(VCM_DSP_FULLDUPLEX); if (!codec_mask) { codec_mask = VCM_CODEC_RESOURCE_G711 | VCM_CODEC_RESOURCE_OPUS; } /* * convert the current available codec into the enumerated * preferred list. */ current_codec_table[0] = RTP_NONE; current_codec_table[MAX_CODEC_ENTRIES] = RTP_NONE; config_set_current_codec_table(codec_mask, ¤t_codec_table[0]); /* * Get the configured preferred codec. If one is configured, * check it to see if currently it can be supported by the * platform. If it is configured and is availble to support, * put the preferred codec in the first one of the list. */ pref_codec = sip_config_preferred_codec(); if (pref_codec != RTP_NONE) { /* * There is a configured preferred codec, check to see if * the codec is currently avaible or not. */ codec = ¤t_codec_table[0]; while (*codec != RTP_NONE) { if (pref_codec == *codec) { preferred_codec_available = TRUE; break; } codec++; } } if (preferred_codec_available) { /* * The preferred codec is configured and the platform * currently can support the preferred codec, put it in * the first entry. */ aSupportedCodecs[count] = pref_codec; count++; } else { /* * Must init or comparison will be made to uninitialized memory. * Do not increment count here since we are not adding RTP_NONE * as a supported codec. We are only initializing memory to a * known value. */ aSupportedCodecs[count] = RTP_NONE; } codec = ¤t_codec_table[0]; while (*codec != RTP_NONE) { if (count < supportedCodecsLen) { if (*codec != aSupportedCodecs[0]) { aSupportedCodecs[count] = *codec; count++; } } codec++; } return count; }