static gboolean gst_rtp_amr_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) { GstRtpAMRPay *rtpamrpay; gboolean res; const GstStructure *s; const gchar *str; rtpamrpay = GST_RTP_AMR_PAY (basepayload); /* figure out the mode Narrow or Wideband */ s = gst_caps_get_structure (caps, 0); if ((str = gst_structure_get_name (s))) { if (strcmp (str, "audio/AMR") == 0) rtpamrpay->mode = GST_RTP_AMR_P_MODE_NB; else if (strcmp (str, "audio/AMR-WB") == 0) rtpamrpay->mode = GST_RTP_AMR_P_MODE_WB; else goto wrong_type; } else goto wrong_type; if (rtpamrpay->mode == GST_RTP_AMR_P_MODE_NB) gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "AMR", 8000); else gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "AMR-WB", 16000); res = gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params", G_TYPE_STRING, "1", "octet-align", G_TYPE_STRING, "1", /* don't set the defaults * * "crc", G_TYPE_STRING, "0", * "robust-sorting", G_TYPE_STRING, "0", * "interleaving", G_TYPE_STRING, "0", */ NULL); return res; /* ERRORS */ wrong_type: { GST_ERROR_OBJECT (rtpamrpay, "unsupported media type '%s'", GST_STR_NULL (str)); return FALSE; } }
static gboolean gst_rtp_gsm_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { const char *stname; GstStructure *structure; gboolean res; structure = gst_caps_get_structure (caps, 0); stname = gst_structure_get_name (structure); if (strcmp ("audio/x-gsm", stname)) goto invalid_type; gst_rtp_base_payload_set_options (payload, "audio", payload->pt != GST_RTP_PAYLOAD_GSM, "GSM", 8000); res = gst_rtp_base_payload_set_outcaps (payload, NULL); return res; /* ERRORS */ invalid_type: { GST_WARNING_OBJECT (payload, "invalid media type received"); return FALSE; } }
static gboolean gst_rtp_h263p_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; GstCaps *peercaps; gchar *encoding_name = NULL; g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); peercaps = gst_pad_peer_query_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload), NULL); if (peercaps) { GstCaps *intersect = gst_caps_intersect (peercaps, gst_pad_get_pad_template_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload))); gst_caps_unref (peercaps); if (!gst_caps_is_empty (intersect)) { GstStructure *s = gst_caps_get_structure (intersect, 0); encoding_name = g_strdup (gst_structure_get_string (s, "encoding-name")); } gst_caps_unref (intersect); } if (!encoding_name) encoding_name = g_strdup ("H263-1998"); gst_rtp_base_payload_set_options (payload, "video", TRUE, (gchar *) encoding_name, 90000); res = gst_rtp_base_payload_set_outcaps (payload, NULL); g_free (encoding_name); return res; }
static gboolean gst_rtp_mpv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gst_rtp_base_payload_set_options (payload, "video", payload->pt != GST_RTP_PAYLOAD_MPV, "MPV", 90000); return gst_rtp_base_payload_set_outcaps (payload, NULL); }
static gboolean gst_rtp_asf_pay_set_caps (GstRTPBasePayload * rtppay, GstCaps * caps) { /* FIXME change application for the actual content */ gst_rtp_base_payload_set_options (rtppay, "application", TRUE, "X-ASF-PF", 1000); return TRUE; }
static gboolean gst_rtp_klv_pay_setcaps (GstRTPBasePayload * pay, GstCaps * caps) { /* FIXME: allow other clock rates */ gst_rtp_base_payload_set_options (pay, "application", TRUE, "SMPTE336M", 90000); return gst_rtp_base_payload_set_outcaps (pay, NULL); }
static void gst_rtp_g723_pay_init (GstRTPG723Pay * pay) { GstRTPBasePayload *payload = GST_RTP_BASE_PAYLOAD (pay); pay->adapter = gst_adapter_new (); payload->pt = GST_RTP_PAYLOAD_G723; gst_rtp_base_payload_set_options (payload, "audio", FALSE, "G723", 8000); }
static gboolean gst_rtp_L16_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) { GstRtpL16Pay *rtpL16pay; gboolean res; gchar *params; GstAudioInfo *info; const GstRTPChannelOrder *order; GstRTPBaseAudioPayload *rtpbaseaudiopayload; rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (basepayload); rtpL16pay = GST_RTP_L16_PAY (basepayload); info = &rtpL16pay->info; gst_audio_info_init (info); if (!gst_audio_info_from_caps (info, caps)) goto invalid_caps; order = gst_rtp_channels_get_by_pos (info->channels, info->position); rtpL16pay->order = order; gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "L16", info->rate); params = g_strdup_printf ("%d", info->channels); if (!order && info->channels > 2) { GST_ELEMENT_WARNING (rtpL16pay, STREAM, DECODE, (NULL), ("Unknown channel order for %d channels", info->channels)); } if (order && order->name) { res = gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT, info->channels, "channel-order", G_TYPE_STRING, order->name, NULL); } else { res = gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT, info->channels, NULL); } g_free (params); /* octet-per-sample is 2 * channels for L16 */ gst_rtp_base_audio_payload_set_sample_options (rtpbaseaudiopayload, 2 * info->channels); return res; /* ERRORS */ invalid_caps: { GST_DEBUG_OBJECT (rtpL16pay, "invalid caps"); return FALSE; } }
static gboolean gst_rtp_g723_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; gst_rtp_base_payload_set_options (payload, "audio", payload->pt != GST_RTP_PAYLOAD_G723, "G723", 8000); res = gst_rtp_base_payload_set_outcaps (payload, NULL); return res; }
static gboolean gst_rtp_mpa_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; gst_rtp_base_payload_set_options (payload, "audio", payload->pt != GST_RTP_PAYLOAD_MPA, "MPA", 90000); res = gst_rtp_base_payload_set_outcaps (payload, NULL); return res; }
static gboolean gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, gsize size) { const gchar *encode, *media; gboolean audio_bundled, res; if ((data[3] & 0x80) == 0) { /* DSF flag */ /* it's an NTSC format */ if ((data[80 * 5 + 48 + 3] & 0x4) && (data[80 * 5 + 48] == 0x60)) { /* 4:2:2 sampling */ /* NTSC 50Mbps */ encode = "314M-25/525-60"; } else { /* 4:1:1 sampling */ /* NTSC 25Mbps */ encode = "SD-VCR/525-60"; } } else { /* it's a PAL format */ if ((data[80 * 5 + 48 + 3] & 0x4) && (data[80 * 5 + 48] == 0x60)) { /* 4:2:2 sampling */ /* PAL 50Mbps */ encode = "314M-50/625-50"; } else if ((data[5] & 0x07) == 0) { /* APT flag */ /* PAL 25Mbps 4:2:0 */ encode = "SD-VCR/625-50"; } else /* PAL 25Mbps 4:1:1 */ encode = "314M-25/625-50"; } media = "video"; audio_bundled = FALSE; switch (rtpdvpay->mode) { case GST_DV_PAY_MODE_AUDIO: media = "audio"; break; case GST_DV_PAY_MODE_BUNDLED: audio_bundled = TRUE; break; default: break; } gst_rtp_base_payload_set_options (GST_RTP_BASE_PAYLOAD (rtpdvpay), media, TRUE, "DV", 90000); if (audio_bundled) { res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay), "encode", G_TYPE_STRING, encode, "audio", G_TYPE_STRING, "bundled", NULL); } else { res = gst_rtp_base_payload_set_outcaps (GST_RTP_BASE_PAYLOAD (rtpdvpay), "encode", G_TYPE_STRING, encode, NULL); } return res; }
static gboolean gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; payload->pt = GST_RTP_PAYLOAD_PCMU; gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMU", 8000); res = gst_rtp_base_payload_set_outcaps (payload, NULL); return res; }
static gboolean gst_rtp_ac3_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; gint rate; GstStructure *structure; structure = gst_caps_get_structure (caps, 0); if (!gst_structure_get_int (structure, "rate", &rate)) rate = 90000; /* default */ gst_rtp_base_payload_set_options (payload, "audio", TRUE, "AC3", rate); res = gst_rtp_base_payload_set_outcaps (payload, NULL); return res; }
static gboolean gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; gchar *capsstr; capsstr = gst_caps_to_string (caps); gst_rtp_base_payload_set_options (payload, "audio", FALSE, "X-GST-OPUS-DRAFT-SPITTKA-00", 48000); res = gst_rtp_base_payload_set_outcaps (payload, "caps", G_TYPE_STRING, capsstr, NULL); g_free (capsstr); return res; }
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_sbc_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps) { GstRtpSBCPay *sbcpay; gint rate, subbands, channels, blocks, bitpool; gint frame_len; const gchar *channel_mode; GstStructure *structure; sbcpay = GST_RTP_SBC_PAY (payload); structure = gst_caps_get_structure (caps, 0); if (!gst_structure_get_int (structure, "rate", &rate)) return FALSE; if (!gst_structure_get_int (structure, "channels", &channels)) return FALSE; if (!gst_structure_get_int (structure, "blocks", &blocks)) return FALSE; if (!gst_structure_get_int (structure, "bitpool", &bitpool)) return FALSE; if (!gst_structure_get_int (structure, "subbands", &subbands)) return FALSE; channel_mode = gst_structure_get_string (structure, "channel-mode"); if (!channel_mode) return FALSE; frame_len = gst_rtp_sbc_pay_get_frame_len (subbands, channels, blocks, bitpool, channel_mode); sbcpay->frame_length = frame_len; gst_rtp_base_payload_set_options (payload, "audio", TRUE, "SBC", rate); GST_DEBUG_OBJECT (payload, "calculated frame length: %d ", frame_len); return gst_rtp_base_payload_set_outcaps (payload, NULL); }
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; } }
static gboolean gst_rtp_mp4g_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { GstRtpMP4GPay *rtpmp4gpay; GstStructure *structure; const GValue *codec_data; const gchar *media_type = NULL; gboolean res; rtpmp4gpay = GST_RTP_MP4G_PAY (payload); structure = gst_caps_get_structure (caps, 0); codec_data = gst_structure_get_value (structure, "codec_data"); if (codec_data) { GST_LOG_OBJECT (rtpmp4gpay, "got codec_data"); if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) { GstBuffer *buffer; const gchar *name; buffer = gst_value_get_buffer (codec_data); GST_LOG_OBJECT (rtpmp4gpay, "configuring codec_data"); name = gst_structure_get_name (structure); /* parse buffer */ if (!strcmp (name, "audio/mpeg")) { res = gst_rtp_mp4g_pay_parse_audio_config (rtpmp4gpay, buffer); media_type = "audio"; } else if (!strcmp (name, "video/mpeg")) { res = gst_rtp_mp4g_pay_parse_video_config (rtpmp4gpay, buffer); media_type = "video"; } else { res = FALSE; } if (!res) goto config_failed; /* now we can configure the buffer */ if (rtpmp4gpay->config) gst_buffer_unref (rtpmp4gpay->config); rtpmp4gpay->config = gst_buffer_copy (buffer); } } if (media_type == NULL) goto config_failed; gst_rtp_base_payload_set_options (payload, media_type, TRUE, "MPEG4-GENERIC", rtpmp4gpay->rate); res = gst_rtp_mp4g_pay_new_caps (rtpmp4gpay); return res; /* ERRORS */ config_failed: { GST_DEBUG_OBJECT (rtpmp4gpay, "failed to parse config"); return FALSE; } }
static gboolean gst_rtp_vraw_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { GstRtpVRawPay *rtpvrawpay; gboolean res; gint pgroup, xinc, yinc; const gchar *depthstr, *samplingstr, *colorimetrystr; gchar *wstr, *hstr; GstVideoInfo info; rtpvrawpay = GST_RTP_VRAW_PAY (payload); if (!gst_video_info_from_caps (&info, caps)) goto invalid_caps; rtpvrawpay->vinfo = info; if (gst_video_colorimetry_matches (&info.colorimetry, GST_VIDEO_COLORIMETRY_BT601)) { colorimetrystr = "BT601-5"; } else if (gst_video_colorimetry_matches (&info.colorimetry, GST_VIDEO_COLORIMETRY_BT709)) { colorimetrystr = "BT709-2"; } else if (gst_video_colorimetry_matches (&info.colorimetry, GST_VIDEO_COLORIMETRY_SMPTE240M)) { colorimetrystr = "SMPTE240M"; } else { colorimetrystr = "SMPTE240M"; } xinc = yinc = 1; /* these values are the only thing we can do */ depthstr = "8"; switch (GST_VIDEO_INFO_FORMAT (&info)) { case GST_VIDEO_FORMAT_RGBA: samplingstr = "RGBA"; pgroup = 4; break; case GST_VIDEO_FORMAT_BGRA: samplingstr = "BGRA"; pgroup = 4; break; case GST_VIDEO_FORMAT_RGB: samplingstr = "RGB"; pgroup = 3; break; case GST_VIDEO_FORMAT_BGR: samplingstr = "BGR"; pgroup = 3; break; case GST_VIDEO_FORMAT_AYUV: samplingstr = "YCbCr-4:4:4"; pgroup = 3; break; case GST_VIDEO_FORMAT_UYVY: samplingstr = "YCbCr-4:2:2"; pgroup = 4; xinc = 2; break; case GST_VIDEO_FORMAT_Y41B: samplingstr = "YCbCr-4:1:1"; pgroup = 6; xinc = 4; break; case GST_VIDEO_FORMAT_I420: samplingstr = "YCbCr-4:2:0"; pgroup = 6; xinc = yinc = 2; break; case GST_VIDEO_FORMAT_UYVP: samplingstr = "YCbCr-4:2:2"; pgroup = 5; xinc = 2; depthstr = "10"; break; default: goto unknown_format; break; } if (GST_VIDEO_INFO_IS_INTERLACED (&info)) { yinc *= 2; } rtpvrawpay->pgroup = pgroup; rtpvrawpay->xinc = xinc; rtpvrawpay->yinc = yinc; GST_DEBUG_OBJECT (payload, "width %d, height %d, sampling %s", GST_VIDEO_INFO_WIDTH (&info), GST_VIDEO_INFO_HEIGHT (&info), samplingstr); GST_DEBUG_OBJECT (payload, "xinc %d, yinc %d, pgroup %d", xinc, yinc, pgroup); wstr = g_strdup_printf ("%d", GST_VIDEO_INFO_WIDTH (&info)); hstr = g_strdup_printf ("%d", GST_VIDEO_INFO_HEIGHT (&info)); gst_rtp_base_payload_set_options (payload, "video", TRUE, "RAW", 90000); if (GST_VIDEO_INFO_IS_INTERLACED (&info)) { res = gst_rtp_base_payload_set_outcaps (payload, "sampling", G_TYPE_STRING, samplingstr, "depth", G_TYPE_STRING, depthstr, "width", G_TYPE_STRING, wstr, "height", G_TYPE_STRING, hstr, "colorimetry", G_TYPE_STRING, colorimetrystr, "interlace", G_TYPE_STRING, "true", NULL); } else { res = gst_rtp_base_payload_set_outcaps (payload, "sampling", G_TYPE_STRING, samplingstr, "depth", G_TYPE_STRING, depthstr, "width", G_TYPE_STRING, wstr, "height", G_TYPE_STRING, hstr, "colorimetry", G_TYPE_STRING, colorimetrystr, NULL); } g_free (wstr); g_free (hstr); return res; /* ERRORS */ invalid_caps: { GST_ERROR_OBJECT (payload, "could not parse caps"); return FALSE; } unknown_format: { GST_ERROR_OBJECT (payload, "unknown caps format"); return FALSE; } }
static gboolean gst_rtp_opus_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gboolean res; GstCaps *src_caps; GstStructure *s; char *encoding_name; gint channels, rate; const char *sprop_stereo = NULL; char *sprop_maxcapturerate = NULL; src_caps = gst_pad_get_allowed_caps (GST_RTP_BASE_PAYLOAD_SRCPAD (payload)); if (src_caps) { src_caps = gst_caps_make_writable (src_caps); src_caps = gst_caps_truncate (src_caps); s = gst_caps_get_structure (src_caps, 0); gst_structure_fixate_field_string (s, "encoding-name", "OPUS"); encoding_name = g_strdup (gst_structure_get_string (s, "encoding-name")); gst_caps_unref (src_caps); } else { encoding_name = g_strdup ("X-GST-OPUS-DRAFT-SPITTKA-00"); } s = gst_caps_get_structure (caps, 0); if (gst_structure_get_int (s, "channels", &channels)) { if (channels > 2) { GST_ERROR_OBJECT (payload, "More than 2 channels with channel-mapping-family=0 is invalid"); return FALSE; } else if (channels == 2) { sprop_stereo = "1"; } else { sprop_stereo = "0"; } } if (gst_structure_get_int (s, "rate", &rate)) { sprop_maxcapturerate = g_strdup_printf ("%d", rate); } gst_rtp_base_payload_set_options (payload, "audio", FALSE, encoding_name, 48000); g_free (encoding_name); if (sprop_maxcapturerate && sprop_stereo) { res = gst_rtp_base_payload_set_outcaps (payload, "sprop-maxcapturerate", G_TYPE_STRING, sprop_maxcapturerate, "sprop-stereo", G_TYPE_STRING, sprop_stereo, NULL); } else if (sprop_maxcapturerate) { res = gst_rtp_base_payload_set_outcaps (payload, "sprop-maxcapturerate", G_TYPE_STRING, sprop_maxcapturerate, NULL); } else if (sprop_stereo) { res = gst_rtp_base_payload_set_outcaps (payload, "sprop-stereo", G_TYPE_STRING, sprop_stereo, NULL); } else { res = gst_rtp_base_payload_set_outcaps (payload, NULL); } g_free (sprop_maxcapturerate); return res; }
static gboolean gst_rtp_celt_pay_parse_ident (GstRtpCELTPay * rtpceltpay, const guint8 * data, guint size) { guint32 version, header_size, rate, nb_channels, frame_size, overlap; guint32 bytes_per_packet; GstRTPBasePayload *payload; gchar *cstr, *fsstr; gboolean res; /* we need the header string (8), the version string (20), the version * and the header length. */ if (size < 36) goto too_small; if (!g_str_has_prefix ((const gchar *) data, "CELT ")) goto wrong_header; /* skip header and version string */ data += 28; version = GST_READ_UINT32_LE (data); GST_DEBUG_OBJECT (rtpceltpay, "version %08x", version); #if 0 if (version != 1) goto wrong_version; #endif data += 4; /* ensure sizes */ header_size = GST_READ_UINT32_LE (data); if (header_size < 56) goto header_too_small; if (size < header_size) goto payload_too_small; data += 4; rate = GST_READ_UINT32_LE (data); data += 4; nb_channels = GST_READ_UINT32_LE (data); data += 4; frame_size = GST_READ_UINT32_LE (data); data += 4; overlap = GST_READ_UINT32_LE (data); data += 4; bytes_per_packet = GST_READ_UINT32_LE (data); GST_DEBUG_OBJECT (rtpceltpay, "rate %d, nb_channels %d, frame_size %d", rate, nb_channels, frame_size); GST_DEBUG_OBJECT (rtpceltpay, "overlap %d, bytes_per_packet %d", overlap, bytes_per_packet); payload = GST_RTP_BASE_PAYLOAD (rtpceltpay); gst_rtp_base_payload_set_options (payload, "audio", FALSE, "CELT", rate); cstr = g_strdup_printf ("%d", nb_channels); fsstr = g_strdup_printf ("%d", frame_size); res = gst_rtp_base_payload_set_outcaps (payload, "encoding-params", G_TYPE_STRING, cstr, "frame-size", G_TYPE_STRING, fsstr, NULL); g_free (cstr); g_free (fsstr); return res; /* ERRORS */ too_small: { GST_DEBUG_OBJECT (rtpceltpay, "ident packet too small, need at least 32 bytes"); return FALSE; } wrong_header: { GST_DEBUG_OBJECT (rtpceltpay, "ident packet does not start with \"CELT \""); return FALSE; } #if 0 wrong_version: { GST_DEBUG_OBJECT (rtpceltpay, "can only handle version 1, have version %d", version); return FALSE; } #endif header_too_small: { GST_DEBUG_OBJECT (rtpceltpay, "header size too small, need at least 80 bytes, " "got only %d", header_size); return FALSE; } payload_too_small: { GST_DEBUG_OBJECT (rtpceltpay, "payload too small, need at least %d bytes, got only %d", header_size, size); 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_mpv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps) { gst_rtp_base_payload_set_options (payload, "video", FALSE, "MPV", 90000); return gst_rtp_base_payload_set_outcaps (payload, NULL); }
static gboolean gst_rtp_g722_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps) { GstRtpG722Pay *rtpg722pay; GstStructure *structure; gint rate, channels, clock_rate; gboolean res; gchar *params; #if 0 GstAudioChannelPosition *pos; const GstRTPChannelOrder *order; #endif GstRTPBaseAudioPayload *rtpbaseaudiopayload; rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (basepayload); rtpg722pay = GST_RTP_G722_PAY (basepayload); structure = gst_caps_get_structure (caps, 0); /* first parse input caps */ if (!gst_structure_get_int (structure, "rate", &rate)) goto no_rate; if (!gst_structure_get_int (structure, "channels", &channels)) goto no_channels; /* FIXME: Do something with the channel positions */ #if 0 /* get the channel order */ pos = gst_audio_get_channel_positions (structure); if (pos) order = gst_rtp_channels_get_by_pos (channels, pos); else order = NULL; #endif /* Clock rate is always 8000 Hz for G722 according to * RFC 3551 although the sampling rate is 16000 Hz */ clock_rate = 8000; gst_rtp_base_payload_set_options (basepayload, "audio", basepayload->pt != GST_RTP_PAYLOAD_G722, "G722", clock_rate); params = g_strdup_printf ("%d", channels); #if 0 if (!order && channels > 2) { GST_ELEMENT_WARNING (rtpg722pay, STREAM, DECODE, (NULL), ("Unknown channel order for %d channels", channels)); } if (order && order->name) { res = gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT, channels, "channel-order", G_TYPE_STRING, order->name, NULL); } else { #endif res = gst_rtp_base_payload_set_outcaps (basepayload, "encoding-params", G_TYPE_STRING, params, "channels", G_TYPE_INT, channels, NULL); #if 0 } #endif g_free (params); #if 0 g_free (pos); #endif rtpg722pay->rate = rate; rtpg722pay->channels = channels; /* bits-per-sample is 4 * channels for G722, but as the RTP clock runs at * half speed (8 instead of 16 khz), pretend it's 8 bits per sample * channels. */ gst_rtp_base_audio_payload_set_samplebits_options (rtpbaseaudiopayload, 8 * rtpg722pay->channels); return res; /* ERRORS */ no_rate: { GST_DEBUG_OBJECT (rtpg722pay, "no rate given"); return FALSE; } no_channels: { GST_DEBUG_OBJECT (rtpg722pay, "no channels given"); return FALSE; } }