static void gst_vdp_vpp_init (GstVdpVideoPostProcess * vpp, GstVdpVideoPostProcessClass * gclass) { vpp->device = NULL; vpp->force_aspect_ratio = FALSE; vpp->mode = GST_VDP_DEINTERLACE_MODE_AUTO; vpp->method = GST_VDP_DEINTERLACE_METHOD_BOB; vpp->noise_reduction = 0.0; vpp->sharpening = 0.0; /* SRC PAD */ vpp->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_element_add_pad (GST_ELEMENT (vpp), vpp->srcpad); /* SINK PAD */ vpp->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_element_add_pad (GST_ELEMENT (vpp), vpp->sinkpad); gst_pad_set_getcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_getcaps); gst_pad_set_setcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_setcaps); gst_pad_set_chain_function (vpp->sinkpad, GST_DEBUG_FUNCPTR (gst_vdp_vpp_chain)); gst_pad_set_event_function (vpp->sinkpad, GST_DEBUG_FUNCPTR (gst_vdp_vpp_sink_event)); gst_pad_set_bufferalloc_function (vpp->sinkpad, gst_vdp_vpp_sink_bufferalloc); }
static GstPad * fs_funnel_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name) { GstPad *sinkpad; FsFunnelPadPrivate *priv = g_slice_alloc0 (sizeof(FsFunnelPadPrivate)); GST_DEBUG_OBJECT (element, "requesting pad"); sinkpad = gst_pad_new_from_template (templ, name); gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (fs_funnel_chain)); gst_pad_set_event_function (sinkpad, GST_DEBUG_FUNCPTR (fs_funnel_event)); gst_pad_set_getcaps_function (sinkpad, GST_DEBUG_FUNCPTR (fs_funnel_getcaps)); gst_pad_set_bufferalloc_function (sinkpad, GST_DEBUG_FUNCPTR (fs_funnel_buffer_alloc)); gst_segment_init (&priv->segment, GST_FORMAT_UNDEFINED); gst_pad_set_element_private (sinkpad, priv); gst_pad_set_active (sinkpad, TRUE); gst_element_add_pad (element, sinkpad); return sinkpad; }
static void gst_caps_debug_init (GstCapsDebug * capsdebug) { capsdebug->srcpad = gst_pad_new_from_static_template (&gst_caps_debug_src_template, "src"); gst_pad_set_getcaps_function (capsdebug->srcpad, GST_DEBUG_FUNCPTR (gst_caps_debug_getcaps)); gst_pad_set_acceptcaps_function (capsdebug->srcpad, GST_DEBUG_FUNCPTR (gst_caps_debug_acceptcaps)); gst_element_add_pad (GST_ELEMENT (capsdebug), capsdebug->srcpad); capsdebug->sinkpad = gst_pad_new_from_static_template (&gst_caps_debug_sink_template, "sink"); gst_pad_set_chain_function (capsdebug->sinkpad, GST_DEBUG_FUNCPTR (gst_caps_debug_sink_chain)); gst_pad_set_bufferalloc_function (capsdebug->sinkpad, GST_DEBUG_FUNCPTR (gst_caps_debug_bufferalloc)); gst_pad_set_getcaps_function (capsdebug->sinkpad, GST_DEBUG_FUNCPTR (gst_caps_debug_getcaps)); gst_pad_set_acceptcaps_function (capsdebug->sinkpad, GST_DEBUG_FUNCPTR (gst_caps_debug_acceptcaps)); gst_element_add_pad (GST_ELEMENT (capsdebug), capsdebug->sinkpad); }
static GstPad * rsn_stream_selector_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * unused) { RsnStreamSelector *sel; gchar *name = NULL; GstPad *sinkpad = NULL; sel = RSN_STREAM_SELECTOR (element); g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL); GST_LOG_OBJECT (sel, "Creating new pad %d", sel->padcount); GST_OBJECT_LOCK (sel); name = g_strdup_printf ("sink%d", sel->padcount++); sinkpad = g_object_new (RSN_TYPE_SELECTOR_PAD, "name", name, "direction", templ->direction, "template", templ, NULL); g_free (name); sel->n_pads++; GST_OBJECT_UNLOCK (sel); gst_pad_set_event_function (sinkpad, GST_DEBUG_FUNCPTR (gst_selector_pad_event)); gst_pad_set_getcaps_function (sinkpad, GST_DEBUG_FUNCPTR (gst_selector_pad_getcaps)); gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_selector_pad_chain)); gst_pad_set_iterate_internal_links_function (sinkpad, GST_DEBUG_FUNCPTR (rsn_stream_selector_iterate_linked_pads)); gst_pad_set_bufferalloc_function (sinkpad, GST_DEBUG_FUNCPTR (gst_selector_pad_bufferalloc)); gst_pad_set_active (sinkpad, TRUE); gst_element_add_pad (GST_ELEMENT (sel), sinkpad); return sinkpad; }
static void gst_vdp_video_yuv_init (GstVdpVideoYUV * video_yuv, GstVdpVideoYUVClass * klass) { video_yuv->display = NULL; gst_pad_set_bufferalloc_function (GST_BASE_TRANSFORM_SINK_PAD (video_yuv), gst_vdp_video_yuv_buffer_alloc); }
static void gst_ffmpegaudioresample_init (GstFFMpegAudioResample * resample, GstFFMpegAudioResampleClass * klass) { GstBaseTransform *trans = GST_BASE_TRANSFORM (resample); gst_pad_set_bufferalloc_function (trans->sinkpad, NULL); resample->res = NULL; }
static void gst_audio_ringbuffer_init (GstAudioRingbuffer * ringbuffer, GstAudioRingbufferClass * g_class) { ringbuffer->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); gst_pad_set_chain_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_chain)); gst_pad_set_activatepush_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_sink_activate_push)); gst_pad_set_event_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_handle_sink_event)); gst_pad_set_getcaps_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_getcaps)); gst_pad_set_setcaps_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_setcaps)); gst_pad_set_bufferalloc_function (ringbuffer->sinkpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_bufferalloc)); gst_element_add_pad (GST_ELEMENT (ringbuffer), ringbuffer->sinkpad); ringbuffer->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); gst_pad_set_activatepull_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_src_activate_pull)); gst_pad_set_activatepush_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_src_activate_push)); gst_pad_set_getrange_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_get_range)); gst_pad_set_checkgetrange_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_src_checkgetrange_function)); gst_pad_set_getcaps_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_getcaps)); gst_pad_set_event_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_handle_src_event)); gst_pad_set_query_function (ringbuffer->srcpad, GST_DEBUG_FUNCPTR (gst_audio_ringbuffer_handle_src_query)); gst_element_add_pad (GST_ELEMENT (ringbuffer), ringbuffer->srcpad); gst_segment_init (&ringbuffer->sink_segment, GST_FORMAT_TIME); ringbuffer->cond = g_cond_new (); ringbuffer->is_eos = FALSE; ringbuffer->buffer_time = DEFAULT_BUFFER_TIME; ringbuffer->segment_time = DEFAULT_SEGMENT_TIME; GST_DEBUG_OBJECT (ringbuffer, "initialized ringbuffer's not_empty & not_full conditions"); }
static void gst_shape_wipe_init (GstShapeWipe * self, GstShapeWipeClass * g_class) { self->video_sinkpad = gst_pad_new_from_static_template (&video_sink_pad_template, "video_sink"); gst_pad_set_chain_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_chain)); gst_pad_set_event_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_event)); gst_pad_set_setcaps_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_setcaps)); gst_pad_set_getcaps_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_getcaps)); gst_pad_set_bufferalloc_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_bufferalloc)); gst_pad_set_query_function (self->video_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_video_sink_query)); gst_element_add_pad (GST_ELEMENT (self), self->video_sinkpad); self->mask_sinkpad = gst_pad_new_from_static_template (&mask_sink_pad_template, "mask_sink"); gst_pad_set_chain_function (self->mask_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_chain)); gst_pad_set_event_function (self->mask_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_event)); gst_pad_set_setcaps_function (self->mask_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_setcaps)); gst_pad_set_getcaps_function (self->mask_sinkpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_mask_sink_getcaps)); gst_element_add_pad (GST_ELEMENT (self), self->mask_sinkpad); self->srcpad = gst_pad_new_from_static_template (&src_pad_template, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_src_event)); gst_pad_set_getcaps_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_src_getcaps)); gst_pad_set_query_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_shape_wipe_src_query)); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); self->mask_mutex = g_mutex_new (); self->mask_cond = g_cond_new (); gst_shape_wipe_reset (self); }
static void setup_test_objects (struct TestData *td, GstPadChainFunction chain_func, GstPadBufferAllocFunction alloc_func) { td->mycaps = gst_caps_new_simple ("test/test", NULL); td->funnel = gst_element_factory_make ("fsfunnel", NULL); td->funnelsrc = gst_element_get_static_pad (td->funnel, "src"); fail_unless (td->funnelsrc != NULL); td->funnelsink11 = gst_element_get_request_pad (td->funnel, "sink11"); fail_unless (td->funnelsink11 != NULL); fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink11), "sink11")); td->funnelsink22 = gst_element_get_request_pad (td->funnel, "sink22"); fail_unless (td->funnelsink22 != NULL); fail_unless (!strcmp (GST_OBJECT_NAME (td->funnelsink22), "sink22")); fail_unless (gst_element_set_state (td->funnel, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS); td->mysink = gst_pad_new ("sink", GST_PAD_SINK); gst_pad_set_chain_function (td->mysink, chain_func); gst_pad_set_bufferalloc_function (td->mysink, alloc_func); gst_pad_set_active (td->mysink, TRUE); gst_pad_set_caps (td->mysink, td->mycaps); td->mysrc1 = gst_pad_new ("src1", GST_PAD_SRC); gst_pad_set_active (td->mysrc1, TRUE); gst_pad_set_caps (td->mysrc1, td->mycaps); td->mysrc2 = gst_pad_new ("src2", GST_PAD_SRC); gst_pad_set_active (td->mysrc2, TRUE); gst_pad_set_caps (td->mysrc2, td->mycaps); fail_unless (GST_PAD_LINK_SUCCESSFUL( gst_pad_link (td->funnelsrc, td->mysink))); fail_unless (GST_PAD_LINK_SUCCESSFUL( gst_pad_link (td->mysrc1, td->funnelsink11))); fail_unless (GST_PAD_LINK_SUCCESSFUL( gst_pad_link (td->mysrc2, td->funnelsink22))); }
static void gst_segment_clip_init (GstSegmentClip * self, GstSegmentClipClass * g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstPadTemplate *templ; templ = gst_element_class_get_pad_template (element_class, "sink"); g_assert (templ); self->sinkpad = gst_pad_new_from_template (templ, "sink"); gst_pad_set_chain_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_sink_chain)); gst_pad_set_event_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_event)); gst_pad_set_setcaps_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_sink_setcaps)); gst_pad_set_getcaps_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_getcaps)); gst_pad_set_bufferalloc_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_sink_bufferalloc)); gst_pad_set_query_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_query)); gst_pad_set_query_type_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_segment_clip_query_type)); gst_element_add_pad (GST_ELEMENT (self), self->sinkpad); gst_object_unref (templ); templ = gst_element_class_get_pad_template (element_class, "src"); g_assert (templ); self->srcpad = gst_pad_new_from_template (templ, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_segment_clip_event)); gst_pad_set_getcaps_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_segment_clip_getcaps)); gst_pad_set_query_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_segment_clip_query)); gst_pad_set_query_type_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_segment_clip_query_type)); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); gst_segment_clip_reset (self); }
void test_live_switch() { GstElement *audioresample; GstEvent *newseg; GstCaps *caps; xmlfile = "test_live_switch"; std_log(LOG_FILENAME_LINE, "Test Started test_live_switch"); audioresample = setup_audioresample (4, 48000, 48000, 16, FALSE); /* Let the sinkpad act like something that can only handle things of * rate 48000- and can only allocate buffers for that rate, but if someone * tries to get a buffer with a rate higher then 48000 tries to renegotiate * */ gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000); gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps); gst_pad_use_fixed_caps (mysrcpad); caps = gst_pad_get_negotiated_caps (mysrcpad); fail_unless (gst_caps_is_fixed (caps)); fail_unless (gst_element_set_state (audioresample, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing"); newseg = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0); fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE); /* downstream can provide the requested rate, a buffer alloc will be passed * on */ live_switch_push (48000, caps); /* Downstream can never accept this rate, buffer alloc isn't passed on */ live_switch_push (40000, caps); /* Downstream can provide the requested rate but will re-negotiate */ live_switch_push (50000, caps); cleanup_audioresample (audioresample); gst_caps_unref (caps); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
static void gst_audioresample_init (GstAudioresample * audioresample, GstAudioresampleClass * klass) { GstBaseTransform *trans; trans = GST_BASE_TRANSFORM (audioresample); /* buffer alloc passthrough is too impossible. FIXME, it * is trivial in the passthrough case. */ gst_pad_set_bufferalloc_function (trans->sinkpad, NULL); audioresample->filter_length = DEFAULT_FILTERLEN; audioresample->need_discont = FALSE; gst_pad_set_query_function (trans->srcpad, audioresample_query); gst_pad_set_query_type_function (trans->srcpad, audioresample_query_type); }
static void gst_valve_init (GstValve * valve, GstValveClass * klass) { valve->drop = FALSE; valve->discont = FALSE; valve->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); gst_pad_set_getcaps_function (valve->srcpad, GST_DEBUG_FUNCPTR (gst_valve_getcaps)); gst_element_add_pad (GST_ELEMENT (valve), valve->srcpad); valve->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); gst_pad_set_chain_function (valve->sinkpad, GST_DEBUG_FUNCPTR (gst_valve_chain)); gst_pad_set_event_function (valve->sinkpad, GST_DEBUG_FUNCPTR (gst_valve_event)); gst_pad_set_bufferalloc_function (valve->sinkpad, GST_DEBUG_FUNCPTR (gst_valve_buffer_alloc)); gst_pad_set_getcaps_function (valve->sinkpad, GST_DEBUG_FUNCPTR (gst_valve_getcaps)); gst_element_add_pad (GST_ELEMENT (valve), valve->sinkpad); }
void buffer_alloc_harness_setup (BufferAllocHarness * h, gint countdown) { h->tee = gst_check_setup_element ("tee"); fail_if (h->tee == NULL); h->countdown = countdown; fail_unless_equals_int (gst_element_set_state (h->tee, GST_STATE_PLAYING), TRUE); h->caps = gst_caps_new_simple ("video/x-raw-yuv", NULL); h->start_srcpad = gst_pad_new ("src", GST_PAD_SRC); fail_if (h->start_srcpad == NULL); fail_unless (gst_pad_set_caps (h->start_srcpad, h->caps) == TRUE); fail_unless (gst_pad_set_active (h->start_srcpad, TRUE) == TRUE); h->tee_sinkpad = gst_element_get_static_pad (h->tee, "sink"); fail_if (h->tee_sinkpad == NULL); h->tee_srcpad = gst_element_get_request_pad (h->tee, "src%d"); fail_if (h->tee_srcpad == NULL); h->final_sinkpad = gst_pad_new ("sink", GST_PAD_SINK); fail_if (h->final_sinkpad == NULL); gst_pad_set_bufferalloc_function (h->final_sinkpad, final_sinkpad_bufferalloc); fail_unless (gst_pad_set_caps (h->final_sinkpad, h->caps) == TRUE); fail_unless (gst_pad_set_active (h->final_sinkpad, TRUE) == TRUE); g_object_set_qdata (G_OBJECT (h->final_sinkpad), g_quark_from_static_string ("buffer-alloc-harness"), h); fail_unless_equals_int (gst_pad_link (h->start_srcpad, h->tee_sinkpad), GST_PAD_LINK_OK); fail_unless_equals_int (gst_pad_link (h->tee_srcpad, h->final_sinkpad), GST_PAD_LINK_OK); }
static void rsn_parsetter_init (RsnParSetter * parset, RsnParSetterClass * gclass) { parset->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); gst_pad_set_getcaps_function (parset->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); gst_pad_set_chain_function (parset->sinkpad, GST_DEBUG_FUNCPTR (rsn_parsetter_chain)); gst_pad_set_event_function (parset->sinkpad, GST_DEBUG_FUNCPTR (rsn_parsetter_sink_event)); gst_pad_set_setcaps_function (parset->sinkpad, GST_DEBUG_FUNCPTR (rsn_parsetter_sink_setcaps)); gst_pad_set_bufferalloc_function (parset->sinkpad, GST_DEBUG_FUNCPTR (rsn_parsetter_sink_bufferalloc)); gst_element_add_pad (GST_ELEMENT (parset), parset->sinkpad); parset->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); gst_pad_set_getcaps_function (parset->srcpad, GST_DEBUG_FUNCPTR (rsn_parsetter_src_getcaps)); gst_element_add_pad (GST_ELEMENT (parset), parset->srcpad); parset->caps_lock = g_mutex_new (); }
static void gst_auto_convert_init (GstAutoConvert * autoconvert, GstAutoConvertClass * klass) { autoconvert->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); autoconvert->srcpad = gst_pad_new_from_static_template (&srctemplate, "src"); gst_pad_set_setcaps_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_setcaps)); gst_pad_set_getcaps_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_getcaps)); gst_pad_set_chain_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_chain)); gst_pad_set_event_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_event)); gst_pad_set_query_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_query)); gst_pad_set_query_type_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_query_type)); gst_pad_set_bufferalloc_function (autoconvert->sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_sink_buffer_alloc)); gst_pad_set_event_function (autoconvert->srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_src_event)); gst_pad_set_query_function (autoconvert->srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_src_query)); gst_pad_set_query_type_function (autoconvert->srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_src_query_type)); gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->sinkpad); gst_element_add_pad (GST_ELEMENT (autoconvert), autoconvert->srcpad); gst_segment_init (&autoconvert->sink_segment, GST_FORMAT_UNDEFINED); autoconvert->initial_identity = DEFAULT_INITIAL_IDENTITY; }
static void gst_decklink_sink_init (GstDecklinkSink * decklinksink, GstDecklinkSinkClass * decklinksink_class) { decklinksink->videosinkpad = gst_pad_new_from_static_template (&gst_decklink_sink_videosink_template, "sink"); gst_pad_set_getcaps_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_getcaps)); gst_pad_set_setcaps_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_setcaps)); gst_pad_set_acceptcaps_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_acceptcaps)); gst_pad_set_activate_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_activate)); gst_pad_set_activatepush_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_activatepush)); gst_pad_set_activatepull_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_activatepull)); gst_pad_set_link_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_link)); gst_pad_set_chain_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_chain)); gst_pad_set_chain_list_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_chainlist)); gst_pad_set_event_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_event)); gst_pad_set_query_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_query)); gst_pad_set_bufferalloc_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_bufferalloc)); gst_pad_set_iterate_internal_links_function (decklinksink->videosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_videosink_iterintlink)); gst_element_add_pad (GST_ELEMENT (decklinksink), decklinksink->videosinkpad); decklinksink->audiosinkpad = gst_pad_new_from_static_template (&gst_decklink_sink_audiosink_template, "audiosink"); gst_pad_set_getcaps_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_getcaps)); gst_pad_set_setcaps_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_setcaps)); gst_pad_set_acceptcaps_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_acceptcaps)); gst_pad_set_activate_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_activate)); gst_pad_set_activatepush_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_activatepush)); gst_pad_set_activatepull_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_activatepull)); gst_pad_set_link_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_link)); gst_pad_set_chain_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_chain)); gst_pad_set_chain_list_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_chainlist)); gst_pad_set_event_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_event)); gst_pad_set_query_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_query)); gst_pad_set_bufferalloc_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_bufferalloc)); gst_pad_set_iterate_internal_links_function (decklinksink->audiosinkpad, GST_DEBUG_FUNCPTR (gst_decklink_sink_audiosink_iterintlink)); gst_element_add_pad (GST_ELEMENT (decklinksink), decklinksink->audiosinkpad); decklinksink->cond = g_cond_new (); decklinksink->mutex = g_mutex_new (); decklinksink->audio_mutex = g_mutex_new (); decklinksink->mode = GST_DECKLINK_MODE_NTSC; decklinksink->callback = new Output; decklinksink->callback->decklinksink = decklinksink; #ifdef _MSC_VER decklinksink->com_init_lock = g_mutex_new(); decklinksink->com_deinit_lock = g_mutex_new(); decklinksink->com_initialized = g_cond_new(); decklinksink->com_uninitialize = g_cond_new(); decklinksink->com_uninitialized = g_cond_new(); g_mutex_lock (decklinksink->com_init_lock); /* create the COM initialization thread */ g_thread_create ((GThreadFunc)gst_decklink_sink_com_thread, decklinksink, FALSE, NULL); /* wait until the COM thread signals that COM has been initialized */ g_cond_wait (decklinksink->com_initialized, decklinksink->com_init_lock); g_mutex_unlock (decklinksink->com_init_lock); #endif /* _MSC_VER */ }
static HRESULT Gstreamer_transform_ConnectInput(GstTfImpl *This, const AM_MEDIA_TYPE *amt, GstCaps *capsin, GstCaps *capsout) { GstIterator *it; int done = 0, found = 0, ret; This->filter = gst_element_factory_make(This->gstreamer_name, NULL); if (!This->filter) { FIXME("Could not make %s filter\n", This->gstreamer_name); return E_FAIL; } This->my_src = gst_pad_new(NULL, GST_PAD_SRC); gst_pad_set_element_private (This->my_src, This); This->my_sink = gst_pad_new(NULL, GST_PAD_SINK); gst_pad_set_chain_function(This->my_sink, got_data); gst_pad_set_bufferalloc_function(This->my_sink, request_buffer); gst_pad_set_element_private (This->my_sink, This); ret = gst_pad_set_caps(This->my_src, capsin); if (ret < 0) { WARN("Failed to set caps on own source with %i\n", ret); return E_FAIL; } ret = gst_pad_set_caps(This->my_sink, capsout); if (ret < 0) { WARN("Failed to set caps on own sink with %i\n", ret); return E_FAIL; } it = gst_element_iterate_sink_pads(This->filter); while (!done) { gpointer item; switch (gst_iterator_next(it, &item)) { case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_OK: This->their_sink = item; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: done = 1; break; } } gst_iterator_free(it); if (!This->their_sink) { ERR("Could not find sink on filter %s\n", This->gstreamer_name); return E_FAIL; } it = gst_element_iterate_src_pads(This->filter); gst_iterator_resync(it); done = 0; while (!done) { gpointer item; switch (gst_iterator_next(it, &item)) { case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_OK: This->their_src = item; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: done = 1; break; } } gst_iterator_free(it); found = !!This->their_src; if (!found) g_signal_connect(This->filter, "pad-added", G_CALLBACK(Gstreamer_transform_pad_added), This); ret = gst_pad_link(This->my_src, This->their_sink); if (ret < 0) { WARN("Failed to link with %i\n", ret); return E_FAIL; } if (found) Gstreamer_transform_pad_added(This->filter, This->their_src, This); if (!gst_pad_is_linked(This->my_sink)) return E_FAIL; TRACE("Connected\n"); return S_OK; }
static GstElement * gst_auto_convert_add_element (GstAutoConvert * autoconvert, GstElementFactory * factory) { GstElement *element = NULL; GstPad *internal_sinkpad = NULL; GstPad *internal_srcpad = NULL; GstPad *sinkpad; GstPad *srcpad; GstPadLinkReturn padlinkret; GST_DEBUG_OBJECT (autoconvert, "Adding element %s to the autoconvert bin", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); element = gst_element_factory_create (factory, NULL); if (!element) return NULL; if (!gst_bin_add (GST_BIN (autoconvert), element)) { GST_ERROR_OBJECT (autoconvert, "Could not add element %s to the bin", GST_OBJECT_NAME (element)); gst_object_unref (element); return NULL; } srcpad = get_pad_by_direction (element, GST_PAD_SRC); if (!srcpad) { GST_ERROR_OBJECT (autoconvert, "Could not find source in %s", GST_OBJECT_NAME (element)); goto error; } sinkpad = get_pad_by_direction (element, GST_PAD_SINK); if (!sinkpad) { GST_ERROR_OBJECT (autoconvert, "Could not find sink in %s", GST_OBJECT_NAME (element)); goto error; } internal_sinkpad = gst_pad_new_from_static_template (&sink_internal_template, "sink_internal"); internal_srcpad = gst_pad_new_from_static_template (&src_internal_template, "src_internal"); if (!internal_sinkpad || !internal_srcpad) { GST_ERROR_OBJECT (autoconvert, "Could not create internal pads"); goto error; } g_object_weak_ref (G_OBJECT (element), (GWeakNotify) gst_object_unref, internal_sinkpad); g_object_weak_ref (G_OBJECT (element), (GWeakNotify) gst_object_unref, internal_srcpad); gst_pad_set_active (internal_sinkpad, TRUE); gst_pad_set_active (internal_srcpad, TRUE); g_object_set_qdata (G_OBJECT (internal_srcpad), parent_quark, autoconvert); g_object_set_qdata (G_OBJECT (internal_sinkpad), parent_quark, autoconvert); gst_pad_set_chain_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_chain)); gst_pad_set_event_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_event)); gst_pad_set_query_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_query)); gst_pad_set_query_type_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_query_type)); gst_pad_set_getcaps_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_getcaps)); gst_pad_set_bufferalloc_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_buffer_alloc)); gst_pad_set_fixatecaps_function (internal_sinkpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_sink_fixatecaps)); gst_pad_set_event_function (internal_srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_src_event)); gst_pad_set_query_function (internal_srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_src_query)); gst_pad_set_query_type_function (internal_srcpad, GST_DEBUG_FUNCPTR (gst_auto_convert_internal_src_query_type)); padlinkret = gst_pad_link (internal_srcpad, sinkpad); if (GST_PAD_LINK_FAILED (padlinkret)) { GST_WARNING_OBJECT (autoconvert, "Could not links pad %s:%s to %s:%s" " for reason %d", GST_DEBUG_PAD_NAME (internal_srcpad), GST_DEBUG_PAD_NAME (sinkpad), padlinkret); goto error; } padlinkret = gst_pad_link (srcpad, internal_sinkpad); if (GST_PAD_LINK_FAILED (padlinkret)) { GST_WARNING_OBJECT (autoconvert, "Could not links pad %s:%s to %s:%s" " for reason %d", GST_DEBUG_PAD_NAME (internal_srcpad), GST_DEBUG_PAD_NAME (sinkpad), padlinkret); goto error; } g_object_set_qdata (G_OBJECT (element), internal_srcpad_quark, internal_srcpad); g_object_set_qdata (G_OBJECT (element), internal_sinkpad_quark, internal_sinkpad); /* Iffy */ gst_element_sync_state_with_parent (element); /* Increment the reference count we will return to the caller */ gst_object_ref (element); return element; error: gst_bin_remove (GST_BIN (autoconvert), element); return NULL; }
static GstPad * gst_ghost_pad_new_full (const gchar * name, GstPadDirection dir, GstPadTemplate * templ) { GstPad *ret; GstPad *internal; GstPadDirection otherdir; g_return_val_if_fail (dir != GST_PAD_UNKNOWN, NULL); /* OBJECT CREATION */ if (templ) { ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "direction", dir, "template", templ, NULL); } else { ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "direction", dir, NULL); } /* Set directional padfunctions for ghostpad */ if (dir == GST_PAD_SINK) { gst_pad_set_bufferalloc_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_bufferalloc)); gst_pad_set_chain_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_chain)); } else { gst_pad_set_getrange_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_getrange)); gst_pad_set_checkgetrange_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_checkgetrange)); } /* link/unlink functions */ gst_pad_set_link_function (ret, GST_DEBUG_FUNCPTR (gst_ghost_pad_do_link)); gst_pad_set_unlink_function (ret, GST_DEBUG_FUNCPTR (gst_ghost_pad_do_unlink)); /* INTERNAL PAD, it always exists and is child of the ghostpad */ otherdir = (dir == GST_PAD_SRC) ? GST_PAD_SINK : GST_PAD_SRC; if (templ) { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, "template", templ, NULL); } else { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, NULL); } GST_PAD_UNSET_FLUSHING (internal); /* Set directional padfunctions for internal pad */ if (dir == GST_PAD_SRC) { gst_pad_set_bufferalloc_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_bufferalloc)); gst_pad_set_chain_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_chain)); } else { gst_pad_set_getrange_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_getrange)); gst_pad_set_checkgetrange_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_checkgetrange)); } GST_PROXY_LOCK (ret); /* now make the ghostpad a parent of the internal pad */ if (!gst_object_set_parent (GST_OBJECT_CAST (internal), GST_OBJECT_CAST (ret))) goto parent_failed; /* The ghostpad is the parent of the internal pad and is the only object that * can have a refcount on the internal pad. * At this point, the GstGhostPad has a refcount of 1, and the internal pad has * a refcount of 1. * When the refcount of the GstGhostPad drops to 0, the ghostpad will dispose * it's refcount on the internal pad in the dispose method by un-parenting it. * This is why we don't take extra refcounts in the assignments below */ GST_PROXY_PAD_INTERNAL (ret) = internal; GST_PROXY_PAD_INTERNAL (internal) = ret; /* could be more general here, iterating over all writable properties... * taking the short road for now tho */ GST_GHOST_PAD_CAST (ret)->notify_id = g_signal_connect (internal, "notify::caps", G_CALLBACK (on_int_notify), ret); /* call function to init values of the pad caps */ on_int_notify (internal, NULL, GST_GHOST_PAD_CAST (ret)); /* special activation functions for the internal pad */ gst_pad_set_activatepull_function (internal, GST_DEBUG_FUNCPTR (gst_ghost_pad_internal_do_activate_pull)); gst_pad_set_activatepush_function (internal, GST_DEBUG_FUNCPTR (gst_ghost_pad_internal_do_activate_push)); GST_PROXY_UNLOCK (ret); return ret; /* ERRORS */ parent_failed: { GST_WARNING_OBJECT (ret, "Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); g_critical ("Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); GST_PROXY_UNLOCK (ret); gst_object_unref (ret); gst_object_unref (internal); return NULL; } }