static void on_new_decoded_pad(GstElement *introdec, GstPad *srcpad, gpointer data) { GstPadLinkReturn result; GstPad *sinkpad; GstCaps *new_pad_caps; CustomData *cdata=(CustomData*)data; GstElement *introbin=cdata->introbin; new_pad_caps=gst_pad_query_caps(srcpad,NULL); g_print("Caps:%s\n",gst_caps_to_string(new_pad_caps)); /* Setup src pad offset, sync with pipeline. */ gint64 pos2; pos2=gst_element_get_base_time(cdata->pipeline); GstClock *clock; clock=gst_pipeline_get_clock(GST_PIPELINE(cdata->pipeline)); GstClockTime clock_time; clock_time=gst_clock_get_time(clock); gst_object_unref(clock); // g_print("Pipeline times: base_time=%lld\n clock_time=%lld\n", // pos2,clock_time); gst_pad_set_offset(srcpad,clock_time-pos2); cdata->introbin_offset=clock_time-pos2; if(strncmp(gst_caps_to_string(new_pad_caps),"video",5)==0) { GstElement *vqueue; vqueue=gst_bin_get_by_name(GST_BIN(introbin),"introscale"); sinkpad=gst_element_get_static_pad(vqueue,"sink"); result=gst_pad_link(srcpad,sinkpad); if(result!=GST_PAD_LINK_OK) { g_printerr("Couldn't link introbin decodebin video pad...\n"); } gst_object_unref(vqueue); } if(strncmp(gst_caps_to_string(new_pad_caps),"audio",5)==0) { GstElement *arate; arate=gst_bin_get_by_name(GST_BIN(introbin),"introaudiorate"); sinkpad=gst_element_get_static_pad(arate,"sink"); result=gst_pad_link(srcpad,sinkpad); if(result!=GST_PAD_LINK_OK) { GstCaps *peer_caps; peer_caps=gst_pad_query_caps(sinkpad,NULL); g_print("SinkCaps:%s\n",gst_caps_to_string(peer_caps)); g_printerr("Couldn't link introbin decodebin audio pad...\n"); gst_caps_unref(peer_caps); } gst_object_unref(arate); } }
gboolean gst_media_descriptor_parser_add_stream (GstMediaDescriptorParser * parser, GstPad * pad) { GList *tmp; gboolean ret = FALSE; GstCaps *caps; g_return_val_if_fail (GST_IS_MEDIA_DESCRIPTOR_PARSER (parser), FALSE); g_return_val_if_fail (((GstMediaDescriptor *) parser)->filenode, FALSE); caps = gst_pad_query_caps (pad, NULL); for (tmp = ((GstMediaDescriptor *) parser)->filenode->streams; tmp; tmp = tmp->next) { StreamNode *streamnode = (StreamNode *) tmp->data; if (streamnode->pad == NULL && gst_caps_is_equal (streamnode->caps, caps)) { ret = TRUE; streamnode->pad = gst_object_ref (pad); goto done; } } done: if (caps != NULL) gst_caps_unref (caps); return ret; }
/** * Link a pad internally * * @self: The #KmsAgnosticBin2 owner of the pad * @pad: (transfer full): The pad to be linked * @peer: (transfer full): The peer pad */ static void kms_agnostic_bin2_link_pad (KmsAgnosticBin2 * self, GstPad * pad, GstPad * peer) { GstCaps *caps; GstBin *bin; GST_INFO_OBJECT (self, "Linking: %" GST_PTR_FORMAT, pad); caps = gst_pad_query_caps (peer, NULL); if (caps == NULL) { goto end; } GST_DEBUG ("Query caps are: %" GST_PTR_FORMAT, caps); bin = kms_agnostic_bin2_find_bin_for_caps (self, caps); if (bin == NULL) { bin = kms_agnostic_bin2_create_bin_for_caps (self, caps); GST_DEBUG_OBJECT (self, "Created bin: %" GST_PTR_FORMAT, bin); } if (bin != NULL) { GstElement *tee = kms_tree_bin_get_output_tee (KMS_TREE_BIN (bin)); kms_utils_drop_until_keyframe (pad, TRUE); kms_agnostic_bin2_link_to_tee (self, pad, tee, caps); } gst_caps_unref (caps); end: g_object_unref (peer); }
static GstBin * kms_agnostic_bin2_create_rtp_pay_bin (KmsAgnosticBin2 * self, GstCaps * caps) { KmsRtpPayTreeBin *bin; GstBin *enc_bin; GstElement *output_tee, *input_element; GstCaps *input_caps; GstPad *sink; bin = kms_rtp_pay_tree_bin_new (caps); if (bin == NULL) { return NULL; } gst_bin_add (GST_BIN (self), GST_ELEMENT (bin)); gst_element_sync_state_with_parent (GST_ELEMENT (bin)); input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (bin)); sink = gst_element_get_static_pad (input_element, "sink"); input_caps = gst_pad_query_caps (sink, NULL); g_object_unref (sink); enc_bin = kms_agnostic_bin2_find_or_create_bin_for_caps (self, input_caps); kms_agnostic_bin2_insert_bin (self, GST_BIN (bin)); gst_caps_unref (input_caps); output_tee = kms_tree_bin_get_output_tee (KMS_TREE_BIN (enc_bin)); gst_element_link (output_tee, input_element); return GST_BIN (bin); }
static void pad_added_cb (GstElement * uridecodebin, GstPad * pad, GstElement * encodebin) { GstPad *sinkpad; sinkpad = gst_element_get_compatible_pad (encodebin, pad, NULL); if (sinkpad == NULL) { GstCaps *caps; /* Ask encodebin for a compatible pad */ caps = gst_pad_query_caps (pad, NULL); g_signal_emit_by_name (encodebin, "request-pad", caps, &sinkpad); if (caps) gst_caps_unref (caps); } if (sinkpad == NULL) { g_print ("Couldn't get an encoding channel for pad %s:%s\n", GST_DEBUG_PAD_NAME (pad)); return; } if (G_UNLIKELY (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)) { g_print ("Couldn't link pads\n"); } return; }
/* two tasks to do here: set the streamheader on the caps, and use libtheora to parse the headers */ static void theora_parse_set_streamheader (GstTheoraParse * parse) { GstCaps *caps; gint i; guint32 bitstream_version; th_setup_info *setup = NULL; g_assert (!parse->streamheader_received); caps = gst_caps_make_writable (gst_pad_query_caps (parse->srcpad, NULL)); theora_parse_set_header_on_caps (parse, caps); GST_DEBUG_OBJECT (parse, "here are the caps: %" GST_PTR_FORMAT, caps); gst_pad_set_caps (parse->srcpad, caps); gst_caps_unref (caps); for (i = 0; i < 3; i++) { ogg_packet packet; GstBuffer *buf; int ret; GstMapInfo map; buf = parse->streamheader[i]; if (buf == NULL) continue; gst_buffer_map (buf, &map, GST_MAP_READ); packet.packet = map.data; packet.bytes = map.size; packet.granulepos = GST_BUFFER_OFFSET_END (buf); packet.packetno = i + 1; packet.e_o_s = 0; packet.b_o_s = (i == 0); ret = th_decode_headerin (&parse->info, &parse->comment, &setup, &packet); gst_buffer_unmap (buf, &map); if (ret < 0) { GST_WARNING_OBJECT (parse, "Failed to decode Theora header %d: %d\n", i + 1, ret); } } if (setup) { th_setup_free (setup); } parse->fps_n = parse->info.fps_numerator; parse->fps_d = parse->info.fps_denominator; parse->shift = parse->info.keyframe_granule_shift; /* With libtheora-1.0beta1 the granulepos scheme was changed: * where earlier the granulepos referred to the index/beginning * of a frame, it now refers to the end, which matches the use * in vorbis/speex. We check the bitstream version from the header so * we know which way to interpret the incoming granuepos */ bitstream_version = (parse->info.version_major << 16) | (parse->info.version_minor << 8) | parse->info.version_subminor; parse->is_old_bitstream = (bitstream_version <= 0x00030200); parse->streamheader_received = TRUE; }
static void cb_newpad (GstElement *decodebin, GstPad *pad, gpointer data) { GstCaps *caps; GstStructure *str; GstPad *audiopad; /* only link once */ audiopad = gst_element_get_static_pad (audio, "sink"); if (GST_PAD_IS_LINKED (audiopad)) { g_object_unref (audiopad); return; } /* check media type */ caps = gst_pad_query_caps (pad, NULL); str = gst_caps_get_structure (caps, 0); if (!g_strrstr (gst_structure_get_name (str), "audio")) { gst_caps_unref (caps); gst_object_unref (audiopad); return; } gst_caps_unref (caps); /* link'n'play */ gst_pad_link (pad, audiopad); g_object_unref (audiopad); }
void gst_play_sink_convert_bin_cache_converter_caps (GstPlaySinkConvertBin * self) { GstElement *head; GstPad *pad; if (self->converter_caps) { gst_caps_unref (self->converter_caps); self->converter_caps = NULL; } if (!self->conversion_elements) { GST_INFO_OBJECT (self, "No conversion elements"); return; } head = GST_ELEMENT (g_list_first (self->conversion_elements)->data); pad = gst_element_get_static_pad (head, "sink"); if (!pad) { GST_WARNING_OBJECT (self, "No sink pad found"); return; } self->converter_caps = gst_pad_query_caps (pad, NULL); GST_INFO_OBJECT (self, "Converter caps: %" GST_PTR_FORMAT, self->converter_caps); gst_object_unref (pad); }
static void bbd_new_decoded_pad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data) { GstCaps *caps; GstStructure *str; GstPad *audiopad; BansheeBpmDetector *detector = (BansheeBpmDetector *)data; g_return_if_fail(detector != NULL); audiopad = gst_element_get_static_pad(detector->audioconvert, "sink"); if(GST_PAD_IS_LINKED(audiopad)) { g_object_unref(audiopad); return; } caps = gst_pad_query_caps(pad, NULL); str = gst_caps_get_structure(caps, 0); if(!g_strrstr(gst_structure_get_name(str), "audio")) { gst_caps_unref(caps); gst_object_unref(audiopad); return; } gst_caps_unref(caps); gst_pad_link(pad, audiopad); }
void pad_added_cb (GstElement *src, GstPad *new_pad, MbMedia *media) { GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; GstPad *peer = NULL; const gchar *new_pad_type = NULL; gboolean success = FALSE; g_assert (media); g_debug ("Received new pad '%s' from '%s'\n", GST_PAD_NAME(new_pad), media->name); new_pad_caps = gst_pad_query_caps (new_pad, NULL); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); g_debug ("New pad type: %s\n", new_pad_type); g_mutex_lock(&(media->mutex)); media->valid_pads++; if (g_str_has_prefix(new_pad_type, "video")) { success = set_video_bin (media->bin, media, new_pad); if (success) peer = gst_element_get_static_pad(_mb_global_data.video_mixer, media->video_pad_name); } else if (g_str_has_prefix(new_pad_type, "audio")) { success = set_audio_bin (media->bin, media, new_pad); if (success) peer = gst_element_get_static_pad(_mb_global_data.audio_mixer, media->audio_pad_name); } if (success) { gst_pad_set_offset (new_pad, media->start_offset); if (peer != NULL) { gst_pad_add_probe (peer, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, eos_event_cb, media, NULL); gst_object_unref(peer); } } g_mutex_unlock(&(media->mutex)); if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); }
/* Fetches a compatible pad on the target element which isn't already * linked */ static GstPad * get_compatible_unlinked_pad (GstElement * element, GESTrack * track) { GstPad *res = NULL; GstIterator *pads; gboolean done = FALSE; const GstCaps *srccaps; GValue paditem = { 0, }; if (G_UNLIKELY (track == NULL)) goto no_track; GST_DEBUG_OBJECT (element, " track %" GST_PTR_FORMAT, track); pads = gst_element_iterate_sink_pads (element); srccaps = ges_track_get_caps (track); GST_DEBUG ("srccaps %" GST_PTR_FORMAT, srccaps); while (!done) { switch (gst_iterator_next (pads, &paditem)) { case GST_ITERATOR_OK: { GstPad *testpad = g_value_get_object (&paditem); if (!gst_pad_is_linked (testpad)) { GstCaps *sinkcaps = gst_pad_query_caps (testpad, NULL); GST_DEBUG ("sinkccaps %" GST_PTR_FORMAT, sinkcaps); if (gst_caps_can_intersect (srccaps, sinkcaps)) { res = gst_object_ref (testpad); done = TRUE; } gst_caps_unref (sinkcaps); } g_value_reset (&paditem); } break; case GST_ITERATOR_DONE: case GST_ITERATOR_ERROR: done = TRUE; break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pads); break; } } g_value_reset (&paditem); gst_iterator_free (pads); return res; no_track: { GST_ERROR ("No track to check against"); return NULL; } }
static GstPadProbeReturn pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstPlaySinkConvertBin *self = user_data; GstPad *peer; GstCaps *caps; gboolean raw; if (GST_IS_EVENT (info->data) && !GST_EVENT_IS_SERIALIZED (info->data)) { GST_DEBUG_OBJECT (self, "Letting non-serialized event %s pass", GST_EVENT_TYPE_NAME (info->data)); return GST_PAD_PROBE_PASS; } GST_PLAY_SINK_CONVERT_BIN_LOCK (self); GST_DEBUG_OBJECT (self, "Pad blocked"); /* There must be a peer at this point */ peer = gst_pad_get_peer (self->sinkpad); caps = gst_pad_get_current_caps (peer); if (!caps) caps = gst_pad_query_caps (peer, NULL); gst_object_unref (peer); raw = is_raw_caps (caps, self->audio); GST_DEBUG_OBJECT (self, "Caps %" GST_PTR_FORMAT " are raw: %d", caps, raw); gst_caps_unref (caps); if (raw == self->raw) goto unblock; self->raw = raw; gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->sinkpad), NULL); gst_ghost_pad_set_target (GST_GHOST_PAD_CAST (self->srcpad), NULL); if (raw) { GST_DEBUG_OBJECT (self, "Switching to raw conversion pipeline"); if (self->conversion_elements) g_list_foreach (self->conversion_elements, (GFunc) gst_play_sink_convert_bin_on_element_added, self); } else { GST_DEBUG_OBJECT (self, "Switch to passthrough pipeline"); gst_play_sink_convert_bin_on_element_added (self->identity, self); } gst_play_sink_convert_bin_set_targets (self, !raw); unblock: self->sink_proxypad_block_id = 0; GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); return GST_PAD_PROBE_REMOVE; }
static void new_decoded_pad (GstElement * dec, GstPad * new_pad, AppInfo * info) { const gchar *sname; GstElement *csp, *scale, *filter; GstStructure *s; GstCaps *caps; GstPad *sinkpad; /* already found a video stream? */ if (info->got_video) return; /* FIXME: is this racy or does decodebin make sure caps are always * negotiated at this point? */ caps = gst_pad_query_caps (new_pad, NULL); g_return_if_fail (caps != NULL); s = gst_caps_get_structure (caps, 0); sname = gst_structure_get_name (s); if (!g_str_has_prefix (sname, "video/x-raw")) goto not_video; csp = create_element ("videoconvert"); scale = create_element ("videoscale"); filter = create_element ("capsfilter"); info->sink = create_element ("gdkpixbufsink"); g_object_set (info->sink, "qos", FALSE, "max-lateness", (gint64) - 1, NULL); gst_bin_add_many (GST_BIN (info->pipe), csp, scale, filter, info->sink, NULL); sinkpad = gst_element_get_static_pad (csp, "sink"); if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, sinkpad))) g_error ("Can't link new decoded pad to videoconvert's sink pad"); gst_object_unref (sinkpad); if (!gst_element_link (csp, scale)) g_error ("Can't link videoconvert to videoscale"); if (!gst_element_link (scale, filter)) g_error ("Can't link videoscale to capsfilter"); if (!gst_element_link (filter, info->sink)) g_error ("Can't link capsfilter to gdkpixbufsink"); gst_element_set_state (info->sink, GST_STATE_PAUSED); gst_element_set_state (filter, GST_STATE_PAUSED); gst_element_set_state (scale, GST_STATE_PAUSED); gst_element_set_state (csp, GST_STATE_PAUSED); info->got_video = TRUE; return; not_video: return; }
GstCaps* get_caps_from_element (GstElement* element, const char* padname) { if (!element || !padname) { return nullptr; } GstCaps* ret = gst_pad_query_caps(gst_element_get_static_pad(element, padname), NULL); return ret; }
static void pad_added (GstElement *src, GstPad *new_pad, ServerData *app) { GstElement *parent_pad = NULL; GstPad *sink_pad = NULL; GstPadLinkReturn ret; GstCaps *caps = NULL; GstStructure *pad_struct = NULL; gchar *src_pad_name = NULL, *sink_pad_name = NULL; const gchar *struct_name = NULL; caps = gst_pad_query_caps (new_pad, NULL); pad_struct = gst_caps_get_structure (caps, 0); struct_name = gst_structure_get_name (pad_struct); g_debug ("Pad structure: %s\n", struct_name); if (strcmp (struct_name, "video/x-raw") == 0) sink_pad = gst_element_get_static_pad (app->v_enc_buffer, "sink"); else if (strcmp (struct_name, "audio/x-raw") == 0) sink_pad = gst_element_get_static_pad (app->a_filter, "sink"); else fprintf (stderr, "Cannot handle this stream: %s\n", struct_name); gst_caps_unref (caps); if (sink_pad == NULL) g_debug ("Could not get a pad from the encoder/muxer\n"); else { src_pad_name = gst_pad_get_name (new_pad); sink_pad_name = gst_pad_get_name (sink_pad); parent_pad = gst_pad_get_parent_element (sink_pad); g_debug ("Trying to link pads: %s[%s] --> %s[%s]: ", GST_ELEMENT_NAME (src), src_pad_name, GST_ELEMENT_NAME (parent_pad), sink_pad_name); gst_object_unref (parent_pad); g_free (src_pad_name); g_free (sink_pad_name); ret = gst_pad_link (new_pad, sink_pad); if (ret != GST_PAD_LINK_OK) { g_debug ("Could not link pads (return = %d)\n", ret); fprintf (stderr, "Internal pipeline error\n"); } else g_debug ("Pads linked\n"); gst_object_unref (sink_pad); } }
static gboolean gst_play_sink_convert_bin_acceptcaps (GstPad * pad, GstCaps * caps) { GstCaps *allowed_caps; gboolean ret; allowed_caps = gst_pad_query_caps (pad, NULL); ret = gst_caps_is_subset (caps, allowed_caps); gst_caps_unref (allowed_caps); return ret; }
static gboolean gst_alsasink_acceptcaps (GstAlsaSink * alsa, GstCaps * caps) { GstPad *pad = GST_BASE_SINK (alsa)->sinkpad; GstCaps *pad_caps; GstStructure *st; gboolean ret = FALSE; GstAudioRingBufferSpec spec = { 0 }; pad_caps = gst_pad_query_caps (pad, caps); if (!pad_caps || gst_caps_is_empty (pad_caps)) { if (pad_caps) gst_caps_unref (pad_caps); ret = FALSE; goto done; } gst_caps_unref (pad_caps); /* If we've not got fixed caps, creating a stream might fail, so let's just * return from here with default acceptcaps behaviour */ if (!gst_caps_is_fixed (caps)) goto done; /* parse helper expects this set, so avoid nasty warning * will be set properly later on anyway */ spec.latency_time = GST_SECOND; if (!gst_audio_ring_buffer_parse_caps (&spec, caps)) goto done; /* Make sure input is framed (one frame per buffer) and can be payloaded */ switch (spec.type) { case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3: case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3: case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS: case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG: { gboolean framed = FALSE, parsed = FALSE; st = gst_caps_get_structure (caps, 0); gst_structure_get_boolean (st, "framed", &framed); gst_structure_get_boolean (st, "parsed", &parsed); if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0) goto done; } default:{ } } ret = TRUE; done: gst_caps_replace (&spec.caps, NULL); return ret; }
static gboolean gst_play_sink_convert_bin_acceptcaps (GstPad * pad, GstCaps * caps) { GstCaps *allowed_caps; gboolean ret; allowed_caps = gst_pad_query_caps (pad, NULL); /* FIXME 0.11: Should be a subset check now */ ret = gst_caps_can_intersect (caps, allowed_caps); gst_caps_unref (allowed_caps); return ret; }
GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad* pad) { if (!pad) return 0; #ifdef GST_API_VERSION_1 GstCaps* caps = gst_pad_get_current_caps(pad); if (!caps) caps = gst_pad_query_caps(pad, 0); return adoptGRef(caps); // gst_pad_query_caps and gst_pad_get_current_caps return a new reference. #else return GST_PAD_CAPS(pad); #endif }
/* FIXME: copied from libdmapsharing: */ gboolean pads_compatible (GstPad *pad1, GstPad *pad2) { gboolean fnval = FALSE; GstCaps *res, *caps1, *caps2; caps1 = gst_pad_query_caps (pad1, NULL); caps2 = gst_pad_query_caps (pad2, NULL); if (NULL == caps1 || NULL == caps2) { g_warning ("Could not get caps from pad"); goto done; } res = gst_caps_intersect (caps1, caps2); if (NULL == res) { g_warning ("Could not get res from caps"); goto done; } fnval = res && ! gst_caps_is_empty (res); done: if (NULL != res) { gst_caps_unref (res); } if (NULL != caps1) { gst_caps_unref (caps1); } if (NULL != caps2) { gst_caps_unref (caps2); } return fnval; }
/* This function will be called by the pad-added signal */ void pad_added_handler(GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = gst_element_get_static_pad(data->buffer, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; GPlayerDEBUG("Received new pad '%s' from '%s':\n", GST_PAD_NAME(new_pad), GST_ELEMENT_NAME(src)); /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked(sink_pad)) { GPlayerDEBUG(" We are already linked. Ignoring.\n"); goto exit; } /* Check the new pad's type */ new_pad_caps = gst_pad_query_caps(new_pad, NULL); new_pad_struct = gst_caps_get_structure(new_pad_caps, 0); new_pad_type = gst_structure_get_name(new_pad_struct); if (!g_str_has_prefix(new_pad_type, "audio/x-raw")) { GPlayerDEBUG(" It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); goto exit; } /* Attempt the link */ ret = gst_pad_link(new_pad, sink_pad); if (GST_PAD_LINK_FAILED(ret)) { GPlayerDEBUG(" Type is '%s' but link failed.\n", new_pad_type); gplayer_error(-1, data); data->target_state = GST_STATE_NULL; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } else { GPlayerDEBUG(" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref(new_pad_caps); /* Unreference the sink pad */ kill_object(sink_pad); }
/** * 链接元素. */ void SoundSystem::LinkElement(GData **eltset, GstPad *pad) { GstElement *volume; GstCaps *caps; GstStructure *str; GstPad *spad; caps = gst_pad_query_caps(pad, NULL); str = gst_caps_get_structure(caps, 0); volume = GST_ELEMENT(g_datalist_get_data(eltset, "volume-element")); if(strcasestr(gst_structure_get_name(str), "audio") &&(spad = gst_element_get_compatible_pad(volume, pad, caps))) gst_pad_link(pad, spad); gst_caps_unref(caps); }
GstCaps* webkitGstGetPadCaps(GstPad* pad) { if (!pad) return 0; GstCaps* caps; #ifdef GST_API_VERSION_1 caps = gst_pad_get_current_caps(pad); if (!caps) caps = gst_pad_query_caps(pad, 0); #else caps = GST_PAD_CAPS(pad); #endif return caps; }
static void _caps_match (GstPad * sinkpad, const gchar * capsname) { GstCaps *caps, *sinkcaps; gchar *name; caps = gst_caps_from_string (capsname); sinkcaps = gst_pad_query_caps (sinkpad, NULL); fail_unless (sinkcaps != NULL); name = gst_caps_to_string (sinkcaps); fail_unless (gst_caps_is_subset (sinkcaps, caps), "caps ('%s') are not a subset of ('%s')", name, capsname); g_free (name); gst_caps_unref (sinkcaps); gst_caps_unref (caps); }
static gboolean _append_accept_caps_failure_details (GstValidatePadMonitor * monitor, GString * str) { gint i, j; GstCaps *refused_caps = gst_caps_copy (monitor->last_refused_caps); GstCaps *possible_caps = gst_pad_query_caps (monitor->pad, NULL); gchar *caps_str = gst_caps_to_string (monitor->last_refused_caps); StructureIncompatibleFieldsInfo info = { .str = str, .found = FALSE }; g_string_append_printf (str, "\n Caps negotiation failed at pad '%s' as it refused caps: %s", gst_validate_reporter_get_name (GST_VALIDATE_REPORTER (monitor)), caps_str); g_free (caps_str); for (i = 0; i < gst_caps_get_size (refused_caps); i++) { GstStructure *refused_struct = gst_caps_get_structure (refused_caps, i); const gchar *filter_name; const gchar *refused_name = gst_structure_get_name (refused_struct); for (j = 0; j < gst_caps_get_size (possible_caps); j++) { info.caps_struct_num = i, info.filter_caps_struct_num = j, info.filter = gst_caps_get_structure (possible_caps, j); filter_name = gst_structure_get_name (info.filter); if (g_strcmp0 (refused_name, filter_name)) { g_string_append_printf (str, "\n -> Downstream caps struct %d name '%s' differs from " "filter caps struct %d name '%s'", i, refused_name, j, filter_name); continue; } gst_structure_foreach (refused_struct, (GstStructureForeachFunc) _find_structure_incompatible_fields, &info); } } gst_caps_unref (possible_caps); return TRUE; }
static gboolean can_sink_caps (GstElement * e, GstCaps * caps) { gboolean res = FALSE; GstPad *sink = gst_element_get_static_pad (e, "sink"); if (sink) { GstCaps *sink_caps = gst_pad_query_caps (sink, caps); if (sink_caps) { res = !gst_caps_is_empty (sink_caps); gst_caps_unref (sink_caps); } gst_object_unref (sink); } return res; }
/* Check if downstream forces variable framerate (0/1) and if * it is the case, use variable framerate ourself * Otherwise compute the framerate from the 2 buffers that we * have already received and make use of it as wanted framerate */ static void gst_video_rate_check_variable_rate (GstVideoRate * videorate, GstBuffer * buffer) { GstStructure *st; gint fps_d, fps_n; GstCaps *srcpadcaps, *tmpcaps, *downstream_caps; GstPad *pad = NULL; srcpadcaps = gst_pad_get_current_caps (GST_BASE_TRANSFORM_SRC_PAD (videorate)); gst_video_guess_framerate (GST_BUFFER_PTS (buffer) - GST_BUFFER_PTS (videorate->prevbuf), &fps_n, &fps_d); tmpcaps = gst_caps_copy (srcpadcaps); st = gst_caps_get_structure (tmpcaps, 0); gst_structure_set (st, "framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL); gst_caps_unref (srcpadcaps); pad = gst_pad_get_peer (GST_BASE_TRANSFORM_SRC_PAD (videorate)); downstream_caps = gst_pad_query_caps (pad, NULL); if (pad && !gst_caps_can_intersect (tmpcaps, downstream_caps)) { videorate->force_variable_rate = TRUE; gst_caps_unref (downstream_caps); GST_DEBUG_OBJECT (videorate, "Downstream forces variable framerate" " respecting it"); goto done; } gst_caps_unref (downstream_caps); videorate->to_rate_numerator = fps_n; videorate->to_rate_denominator = fps_d; GST_INFO_OBJECT (videorate, "Computed framerate to %d/%d", videorate->to_rate_numerator, videorate->to_rate_denominator); videorate->updating_caps = TRUE; gst_base_transform_update_src_caps (GST_BASE_TRANSFORM (videorate), tmpcaps); done: gst_caps_unref (tmpcaps); if (pad) gst_object_unref (pad); }
static void gst_wrapper_camera_bin_src_caps_cb (GObject * gobject, GParamSpec * pspec, gpointer user_data) { GstBaseCameraSrc *bcamsrc = GST_BASE_CAMERA_SRC (user_data); GstWrapperCameraBinSrc *self = GST_WRAPPER_CAMERA_BIN_SRC (user_data); GstPad *src_caps_src_pad; GstCaps *caps = NULL; GstStructure *in_st = NULL; /* get the new caps that were set on the capsfilter that configures the * source */ src_caps_src_pad = gst_element_get_static_pad (self->src_filter, "src"); caps = gst_pad_query_caps (src_caps_src_pad, NULL); gst_object_unref (src_caps_src_pad); GST_DEBUG_OBJECT (self, "src-filter caps changed to %s", gst_caps_to_string (caps)); if (gst_caps_get_size (caps)) { in_st = gst_caps_get_structure (caps, 0); if (in_st) { gst_structure_get_int (in_st, "width", &bcamsrc->width); gst_structure_get_int (in_st, "height", &bcamsrc->height); GST_DEBUG_OBJECT (self, "Source dimensions now: %dx%d", bcamsrc->width, bcamsrc->height); } } /* Update zoom */ gst_base_camera_src_setup_zoom (bcamsrc); /* Update post-zoom capsfilter */ if (self->src_zoom_filter) { GstCaps *filtercaps; g_object_get (G_OBJECT (self->src_zoom_filter), "caps", &filtercaps, NULL); if (!gst_caps_is_equal (filtercaps, caps)) g_object_set (G_OBJECT (self->src_zoom_filter), "caps", caps, NULL); gst_caps_unref (filtercaps); } /* drop our ref on the caps */ gst_caps_unref (caps); };
static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = gst_element_get_static_pad (data->audioconvert, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" We are already linked. Ignoring.\n"); goto exit; } /* Check the new pad's type */ #if GST_VERSION_MAJOR == (0) new_pad_caps = gst_pad_get_caps (new_pad); #else new_pad_caps = gst_pad_query_caps (new_pad, NULL); #endif new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) { g_print (" It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); goto exit; } /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); }
static GstCaps * gst_play_sink_convert_bin_getcaps (GstPad * pad, GstCaps * filter) { GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN (gst_pad_get_parent (pad)); GstCaps *ret; GstPad *otherpad, *peer; GST_PLAY_SINK_CONVERT_BIN_LOCK (self); if (pad == self->srcpad) { otherpad = self->sinkpad; } else if (pad == self->sinkpad) { otherpad = self->srcpad; } else { GST_ERROR_OBJECT (pad, "Not one of our pads"); otherpad = NULL; } if (otherpad) { peer = gst_pad_get_peer (otherpad); if (peer) { GstCaps *peer_caps = gst_pad_query_caps (peer, filter); gst_object_unref (peer); if (self->converter_caps && is_raw_caps (peer_caps, self->audio)) { ret = gst_caps_merge (peer_caps, gst_caps_ref (self->converter_caps)); } else { ret = peer_caps; } } else { ret = gst_caps_ref (self->converter_caps); } } else { ret = gst_caps_new_any (); } GST_PLAY_SINK_CONVERT_BIN_UNLOCK (self); gst_object_unref (self); GST_DEBUG_OBJECT (pad, "Returning caps %" GST_PTR_FORMAT, ret); return ret; }