/**
 * get_telephone_sound_codec:
 * @codecs: a #GList of #FsCodec
 *
 * Find the first occurence of PCMA or PCMU codecs
 *
 * Returns: The #FsCodec of type PCMA/U from the list or %NULL
 */
static FsCodec *
get_pcm_law_sound_codec (GList *codecs,
                         gchar **encoder_name,
                         gchar **payloader_name)
{
    CodecAssociation *ca = NULL;

    ca = lookup_codec_association_custom (codecs, _is_law_codec, NULL);

    if (!ca)
        return NULL;

    if (ca->codec->id == 0)
    {
        if (encoder_name)
            *encoder_name = "mulawenc";
        if (payloader_name)
            *payloader_name = "rtppcmupay";
    }
    else if (ca->codec->id == 8)
    {
        if (encoder_name)
            *encoder_name = "alawenc";
        if (payloader_name)
            *payloader_name = "rtppcmapay";
    }

    return ca->codec;
}
/**
 * fs_rtp_dtmf_event_source_get_codec:
 * @negotiated_codec_associations: a #GList of currently negotiated
 *   #CodecAssociation
 * @selected_codec: The current #FsCodec
 *
 * Find the telephone-event codec with the proper clock rate in the list
 *
 * Returns: The #FsCodec of type "telephone-event" with the requested clock-rate
 *   from the list, or %NULL
 */
static  FsCodec *
fs_rtp_dtmf_event_source_get_codec (FsRtpSpecialSourceClass *klass,
                                    GList *negotiated_codec_associations, FsCodec *selected_codec)
{
    CodecAssociation *ca = NULL;

    if (selected_codec->media_type != FS_MEDIA_TYPE_AUDIO)
        return NULL;

    ca = lookup_codec_association_custom (negotiated_codec_associations,
                                          _is_telephony_codec, GUINT_TO_POINTER (selected_codec->clock_rate));

    if (ca)
        return ca->send_codec;
    else
        return NULL;
}
static GList *
fs_rtp_dtmf_event_source_negotiation_filter (FsRtpSpecialSourceClass *klass,
        GList *codec_associations)
{
    GList *tmp;

    for (tmp = codec_associations; tmp; tmp = g_list_next (tmp))
    {
        CodecAssociation *ca = tmp->data;

        /* Ignore disabled or non telephone-event codecs*/
        if (ca->disable || ca->reserved || ca->recv_only ||
                g_ascii_strcasecmp (ca->codec->encoding_name, "telephone-event"))
            continue;

        /* Lets disable telephone-event codecs where we don't find */
        if (!lookup_codec_association_custom (codec_associations, has_rate,
                                              GUINT_TO_POINTER (ca->codec->clock_rate)))
            ca->disable = TRUE;
    }

    return codec_associations;
}