static gboolean gst_rtp_siren_pay_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps) { GstRTPSirenPay *rtpsirenpay; GstRTPBaseAudioPayload *rtpbaseaudiopayload; gint dct_length; GstStructure *structure; const char *payload_name; rtpsirenpay = GST_RTP_SIREN_PAY (rtpbasepayload); rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload); structure = gst_caps_get_structure (caps, 0); gst_structure_get_int (structure, "dct-length", &dct_length); if (dct_length != 320) goto wrong_dct; payload_name = gst_structure_get_name (structure); if (g_ascii_strcasecmp ("audio/x-siren", payload_name)) goto wrong_caps; gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "SIREN", 16000); /* set options for this frame based audio codec */ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload, 20, 40); return gst_rtp_base_payload_set_outcaps (rtpbasepayload, NULL); /* ERRORS */ wrong_dct: { GST_ERROR_OBJECT (rtpsirenpay, "dct-length must be 320, received %d", dct_length); return FALSE; } wrong_caps: { GST_ERROR_OBJECT (rtpsirenpay, "expected audio/x-siren, received %s", payload_name); return FALSE; } }
static gboolean gst_rtp_bv_pay_sink_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps) { GstRTPBVPay *rtpbvpay; GstRTPBaseAudioPayload *rtpbaseaudiopayload; gint mode; GstStructure *structure; const char *payload_name; rtpbvpay = GST_RTP_BV_PAY (rtpbasepayload); rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload); structure = gst_caps_get_structure (caps, 0); payload_name = gst_structure_get_name (structure); if (g_ascii_strcasecmp ("audio/x-bv", payload_name)) goto wrong_caps; if (!gst_structure_get_int (structure, "mode", &mode)) goto no_mode; if (mode != 16 && mode != 32) goto wrong_mode; if (mode == 16) { gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "BV16", 8000); rtpbasepayload->clock_rate = 8000; } else { gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "BV32", 16000); rtpbasepayload->clock_rate = 16000; } /* set options for this frame based audio codec */ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload, mode, mode == 16 ? 10 : 20); if (mode != rtpbvpay->mode && rtpbvpay->mode != -1) goto mode_changed; rtpbvpay->mode = mode; return TRUE; /* ERRORS */ wrong_caps: { GST_ERROR_OBJECT (rtpbvpay, "expected audio/x-bv, received %s", payload_name); return FALSE; } no_mode: { GST_ERROR_OBJECT (rtpbvpay, "did not receive a mode"); return FALSE; } wrong_mode: { GST_ERROR_OBJECT (rtpbvpay, "mode must be 16 or 32, received %d", mode); return FALSE; } mode_changed: { GST_ERROR_OBJECT (rtpbvpay, "Mode has changed from %d to %d! " "Mode cannot change while streaming", rtpbvpay->mode, mode); return FALSE; } }
static gboolean gst_rtp_ilbc_pay_sink_setcaps (GstRTPBasePayload * rtpbasepayload, GstCaps * caps) { GstRTPILBCPay *rtpilbcpay; GstRTPBaseAudioPayload *rtpbaseaudiopayload; gboolean ret; gint mode; gchar *mode_str; GstStructure *structure; const char *payload_name; rtpilbcpay = GST_RTP_ILBC_PAY (rtpbasepayload); rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpbasepayload); structure = gst_caps_get_structure (caps, 0); payload_name = gst_structure_get_name (structure); if (g_ascii_strcasecmp ("audio/x-iLBC", payload_name)) goto wrong_caps; if (!gst_structure_get_int (structure, "mode", &mode)) goto no_mode; if (mode != 20 && mode != 30) goto wrong_mode; gst_rtp_base_payload_set_options (rtpbasepayload, "audio", TRUE, "ILBC", 8000); /* set options for this frame based audio codec */ gst_rtp_base_audio_payload_set_frame_options (rtpbaseaudiopayload, mode, mode == 30 ? 50 : 38); mode_str = g_strdup_printf ("%d", mode); ret = gst_rtp_base_payload_set_outcaps (rtpbasepayload, "mode", G_TYPE_STRING, mode_str, NULL); g_free (mode_str); if (mode != rtpilbcpay->mode && rtpilbcpay->mode != -1) goto mode_changed; rtpilbcpay->mode = mode; return ret; /* ERRORS */ wrong_caps: { GST_ERROR_OBJECT (rtpilbcpay, "expected audio/x-iLBC, received %s", payload_name); return FALSE; } no_mode: { GST_ERROR_OBJECT (rtpilbcpay, "did not receive a mode"); return FALSE; } wrong_mode: { GST_ERROR_OBJECT (rtpilbcpay, "mode must be 20 or 30, received %d", mode); return FALSE; } mode_changed: { GST_ERROR_OBJECT (rtpilbcpay, "Mode has changed from %d to %d! " "Mode cannot change while streaming", rtpilbcpay->mode, mode); return FALSE; } }