diff --git a/ChangeLog b/ChangeLog index b55bd3c699..f5995ce562 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-11-14 Thomas Vander Stichele + + * gst/videotestsrc/gstvideotestsrc.c: + (gst_videotestsrc_class_init), (gst_videotestsrc_init), + (gst_videotestsrc_src_fixate): + move fixation to a fixate function + remove negotiate function, basesrc's is good enough + fixes a bug for check when using the element alone + 2005-11-13 Edward Hervey * examples/seeking/seek.c: (do_seek), (accurate_toggle_cb), diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 2be54b34ad..36907ff6d5 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -77,7 +77,8 @@ static void gst_videotestsrc_get_property (GObject * object, guint prop_id, static GstCaps *gst_videotestsrc_getcaps (GstBaseSrc * bsrc); static gboolean gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps); -static gboolean gst_videotestsrc_negotiate (GstBaseSrc * bsrc); +static void gst_videotestsrc_src_fixate (GstPad * pad, GstCaps * caps); + static gboolean gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event); static void gst_videotestsrc_get_times (GstBaseSrc * basesrc, @@ -146,7 +147,6 @@ gst_videotestsrc_class_init (GstVideoTestSrcClass * klass) gstbasesrc_class->get_caps = gst_videotestsrc_getcaps; gstbasesrc_class->set_caps = gst_videotestsrc_setcaps; - gstbasesrc_class->negotiate = gst_videotestsrc_negotiate; gstbasesrc_class->event = gst_videotestsrc_event; gstbasesrc_class->get_times = gst_videotestsrc_get_times; @@ -156,6 +156,10 @@ gst_videotestsrc_class_init (GstVideoTestSrcClass * klass) static void gst_videotestsrc_init (GstVideoTestSrc * src, GstVideoTestSrcClass * g_class) { + GstPad *pad = GST_BASE_SRC_PAD (src); + + gst_pad_set_fixatecaps_function (pad, gst_videotestsrc_src_fixate); + gst_videotestsrc_set_pattern (src, GST_VIDEOTESTSRC_SMPTE); src->segment_start_frame = -1; @@ -165,6 +169,18 @@ gst_videotestsrc_init (GstVideoTestSrc * src, GstVideoTestSrcClass * g_class) gst_base_src_set_live (GST_BASE_SRC (src), FALSE); } +static void +gst_videotestsrc_src_fixate (GstPad * pad, GstCaps * caps) +{ + GstStructure *structure; + + structure = gst_caps_get_structure (caps, 0); + + gst_caps_structure_fixate_field_nearest_int (structure, "width", 320); + gst_caps_structure_fixate_field_nearest_int (structure, "height", 240); + gst_caps_structure_fixate_field_nearest_double (structure, "framerate", 30.0); +} + static void gst_videotestsrc_set_pattern (GstVideoTestSrc * videotestsrc, int pattern_type) { @@ -311,39 +327,6 @@ gst_videotestsrc_setcaps (GstBaseSrc * bsrc, GstCaps * caps) return res; } -static gboolean -gst_videotestsrc_negotiate (GstBaseSrc * bsrc) -{ - GstCaps *caps; - GstCaps *temp; - gboolean result = FALSE; - - /* get all possible caps on this link */ - caps = gst_pad_get_allowed_caps (GST_BASE_SRC_PAD (bsrc)); - temp = gst_caps_normalize (caps); - gst_caps_unref (caps); - caps = temp; - - if (gst_caps_get_size (caps) > 0) { - GstStructure *structure; - - /* pick the first one */ - gst_caps_truncate (caps); - - structure = gst_caps_get_structure (caps, 0); - - gst_caps_structure_fixate_field_nearest_int (structure, "width", 320); - gst_caps_structure_fixate_field_nearest_int (structure, "height", 240); - gst_caps_structure_fixate_field_nearest_double (structure, "framerate", - 30.0); - - result = gst_pad_set_caps (GST_BASE_SRC_PAD (bsrc), caps); - gst_caps_unref (caps); - } - - return result; -} - static gboolean gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event) {