From 701da03ff945b53e0bfa9af79dd5d7e548099e59 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 8 Jun 2012 15:58:13 +0200 Subject: [PATCH] elements: Use gst_pad_set_caps() instead of manual event fiddling --- gst/audiovisualizers/gstbaseaudiovisualizer.c | 2 +- gst/hls/gsthlsdemux.c | 1 - tests/check/elements/curlfilesink.c | 92 +++++++++++---------------- win32/common/config.h | 4 +- 4 files changed, 40 insertions(+), 59 deletions(-) diff --git a/gst/audiovisualizers/gstbaseaudiovisualizer.c b/gst/audiovisualizers/gstbaseaudiovisualizer.c index 9d68ca8..ade18a0 100644 --- a/gst/audiovisualizers/gstbaseaudiovisualizer.c +++ b/gst/audiovisualizers/gstbaseaudiovisualizer.c @@ -649,7 +649,7 @@ gst_base_audio_visualizer_src_setcaps (GstBaseAudioVisualizer * scope, GST_DEBUG_OBJECT (scope, "blocks: spf %u, req_spf %u", scope->spf, scope->req_spf); - res = gst_pad_push_event (scope->srcpad, gst_event_new_caps (caps)); + res = gst_pad_set_caps (scope->srcpad, caps); return res; diff --git a/gst/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c index 8de5b41..8e054b9 100644 --- a/gst/hls/gsthlsdemux.c +++ b/gst/hls/gsthlsdemux.c @@ -616,7 +616,6 @@ switch_pads (GstHLSDemux * demux, GstCaps * newcaps) gst_pad_set_active (demux->srcpad, TRUE); gst_pad_push_event (demux->srcpad, gst_event_new_stream_start ()); gst_pad_set_caps (demux->srcpad, newcaps); - gst_pad_push_event (demux->srcpad, gst_event_new_caps (newcaps)); gst_element_add_pad (GST_ELEMENT (demux), demux->srcpad); gst_element_no_more_pads (GST_ELEMENT (demux)); diff --git a/tests/check/elements/curlfilesink.c b/tests/check/elements/curlfilesink.c index 088ac40..a7985e2 100644 --- a/tests/check/elements/curlfilesink.c +++ b/tests/check/elements/curlfilesink.c @@ -37,8 +37,8 @@ cleanup_curlfilesink (GstElement * sink) } static void -test_verify_file_data (const gchar *dir, gchar *file_name, - const gchar *expected_file_content) +test_verify_file_data (const gchar * dir, gchar * file_name, + const gchar * expected_file_content) { GError *err = NULL; gchar *res_file_content = NULL; @@ -55,7 +55,7 @@ test_verify_file_data (const gchar *dir, gchar *file_name, fail_unless (res_file_content != NULL); fail_unless (strncmp (res_file_content, expected_file_content, - strlen (expected_file_content)) == 0); + strlen (expected_file_content)) == 0); g_free (res_file_content); g_unlink (path); g_free (path); @@ -71,7 +71,7 @@ test_set_and_play_buffer (const gchar * _data) num_bytes = strlen (data); buffer = gst_buffer_new (); gst_buffer_insert_memory (buffer, 0, - gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, + gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, data, num_bytes, 0, num_bytes, data, NULL)); fail_unless (gst_pad_push (srcpad, buffer) == GST_FLOW_OK); @@ -87,7 +87,7 @@ test_set_and_fail_to_play_buffer (const gchar * _data) num_bytes = strlen (data); buffer = gst_buffer_new (); gst_buffer_insert_memory (buffer, 0, - gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, + gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, data, num_bytes, 0, num_bytes, data, NULL)); fail_unless (gst_pad_push (srcpad, buffer) == GST_FLOW_ERROR); @@ -96,37 +96,27 @@ test_set_and_fail_to_play_buffer (const gchar * _data) static gboolean sebras_gst_pad_set_caps (GstPad * pad, GstCaps * caps) { - GstEvent *event; - gboolean res = TRUE; - - GST_WARNING ("sebraz: a %p %p", pad, caps); - g_return_val_if_fail (GST_IS_PAD (pad), FALSE); - GST_WARNING ("sebraz: b"); - g_return_val_if_fail (caps != NULL && gst_caps_is_fixed (caps), FALSE); - GST_WARNING ("sebraz: c"); - - GST_WARNING ("sebraz: d"); - event = gst_event_new_caps (caps); - GST_WARNING ("sebraz: e"); - - if (GST_PAD_IS_SRC (pad)) { - GST_WARNING ("sebraz: f1"); - res = gst_pad_push_event (pad, event); - } else { - GST_WARNING ("sebraz: f2"); - res = gst_pad_send_event (pad, event); - } - - GST_WARNING ("sebraz: g"); - - return res; + GstEvent *event; + gboolean res = TRUE; + + GST_WARNING ("sebraz: a %p %p", pad, caps); + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); + GST_WARNING ("sebraz: b"); + g_return_val_if_fail (caps != NULL && gst_caps_is_fixed (caps), FALSE); + GST_WARNING ("sebraz: c"); + + GST_WARNING ("sebraz: d"); + res = gst_pad_set_caps (pad, caps); + GST_WARNING ("sebraz: e"); + + return res; } GST_START_TEST (test_properties) { GstElement *sink; GstCaps *caps; - const gchar *location= "file:///tmp/"; + const gchar *location = "file:///tmp/"; const gchar *file_contents = "line 1\r\n"; gchar *file_name = g_strdup_printf ("curlfilesink_%d", g_random_int ()); gchar *res_location = NULL; @@ -146,9 +136,7 @@ GST_START_TEST (test_properties) g_object_get (sink, "location", &res_location, - "file-name", &res_file_name, - "create-dirs", &res_create_dirs, - NULL); + "file-name", &res_file_name, "create-dirs", &res_create_dirs, NULL); GST_WARNING ("sebras: d"); fail_unless (strncmp (res_location, "mylocation", strlen ("mylocation")) @@ -171,9 +159,7 @@ GST_START_TEST (test_properties) g_object_get (sink, "location", &res_location, - "file-name", &res_file_name, - "create-dirs", &res_create_dirs, - NULL); + "file-name", &res_file_name, "create-dirs", &res_create_dirs, NULL); GST_WARNING ("sebras: j"); fail_unless (strncmp (res_location, location, strlen (location)) @@ -222,13 +208,14 @@ GST_START_TEST (test_properties) g_free (file_name); g_free (path); } + GST_END_TEST; GST_START_TEST (test_one_file) { GstElement *sink; GstCaps *caps; - const gchar *location= "file:///tmp/"; + const gchar *location = "file:///tmp/"; gchar *file_name = g_strdup_printf ("curlfilesink_%d", g_random_int ()); const gchar *file_content = "line 1\r\n"; gchar *res_location = NULL; @@ -240,9 +227,7 @@ GST_START_TEST (test_one_file) g_object_set (G_OBJECT (sink), "file-name", file_name, NULL); g_object_get (sink, - "location", &res_location, - "file-name", &res_file_name, - NULL); + "location", &res_location, "file-name", &res_file_name, NULL); fail_unless (strncmp (res_location, location, strlen (location)) == 0); @@ -270,20 +255,19 @@ GST_START_TEST (test_one_file) /* verify file content */ test_verify_file_data ("/tmp", file_name, file_content); } + GST_END_TEST; GST_START_TEST (test_one_big_file) { GstElement *sink; GstCaps *caps; - const gchar *location= "file:///tmp/"; + const gchar *location = "file:///tmp/"; gchar *file_name = g_strdup_printf ("curlfilesink_%d", g_random_int ()); const gchar *file_line1 = "line 1\r\n"; const gchar *file_line2 = "line 2\r\n"; const gchar *file_line3 = "line 3\r\n"; - const gchar *expected_file_content = "line 1\r\n" \ - "line 2\r\n" \ - "line 3\r\n"; + const gchar *expected_file_content = "line 1\r\n" "line 2\r\n" "line 3\r\n"; gchar *res_location = NULL; gchar *res_file_name = NULL; @@ -293,9 +277,7 @@ GST_START_TEST (test_one_big_file) g_object_set (G_OBJECT (sink), "file-name", file_name, NULL); g_object_get (sink, - "location", &res_location, - "file-name", &res_file_name, - NULL); + "location", &res_location, "file-name", &res_file_name, NULL); fail_unless (strncmp (res_location, location, strlen (location)) == 0); @@ -329,13 +311,14 @@ GST_START_TEST (test_one_big_file) /* verify file content */ test_verify_file_data ("/tmp", file_name, expected_file_content); } + GST_END_TEST; GST_START_TEST (test_two_files) { GstElement *sink; GstCaps *caps; - const gchar *location= "file:///tmp/"; + const gchar *location = "file:///tmp/"; gchar *file_name1 = g_strdup_printf ("curlfilesink_%d", g_random_int ()); gchar *file_name2 = g_strdup_printf ("curlfilesink_%d", g_random_int ()); const gchar *file_content1 = "file content 1\r\n"; @@ -349,9 +332,7 @@ GST_START_TEST (test_two_files) g_object_set (G_OBJECT (sink), "file-name", file_name1, NULL); g_object_get (sink, - "location", &res_location, - "file-name", &res_file_name, - NULL); + "location", &res_location, "file-name", &res_file_name, NULL); fail_unless (strncmp (res_location, location, strlen (location)) == 0); @@ -389,6 +370,7 @@ GST_START_TEST (test_two_files) test_verify_file_data ("/tmp", file_name1, file_content1); test_verify_file_data ("/tmp", file_name2, file_content2); } + GST_END_TEST; GST_START_TEST (test_create_dirs) @@ -442,13 +424,14 @@ GST_START_TEST (test_create_dirs) g_free (sub_dir); g_free (tmp_dir); } + GST_END_TEST; GST_START_TEST (test_missing_path) { GstElement *sink; GstCaps *caps; - const gchar *location= "file:///missing/path/"; + const gchar *location = "file:///missing/path/"; gchar *file_name = g_strdup_printf ("curlfilesink_%d", g_random_int ()); const gchar *file_content = "line 1\r\n"; gchar *res_location = NULL; @@ -460,9 +443,7 @@ GST_START_TEST (test_missing_path) g_object_set (G_OBJECT (sink), "file-name", file_name, NULL); g_object_get (sink, - "location", &res_location, - "file-name", &res_file_name, - NULL); + "location", &res_location, "file-name", &res_file_name, NULL); fail_unless (strncmp (res_location, location, strlen (location)) == 0); @@ -487,6 +468,7 @@ GST_START_TEST (test_missing_path) gst_caps_unref (caps); cleanup_curlfilesink (sink); } + GST_END_TEST; static Suite * diff --git a/win32/common/config.h b/win32/common/config.h index 44c76af..45ad42d 100644 --- a/win32/common/config.h +++ b/win32/common/config.h @@ -24,7 +24,7 @@ #define GST_LICENSE "LGPL" /* package name in plugins */ -#define GST_PACKAGE_NAME "GStreamer Bad Plug-ins source release" +#define GST_PACKAGE_NAME "GStreamer Bad Plug-ins git" /* package origin */ #define GST_PACKAGE_ORIGIN "Unknown package origin" @@ -199,7 +199,7 @@ #undef USE_POISONING /* Version number of package */ -#define VERSION "0.11.92" +#define VERSION "0.11.92.1" /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ -- 2.7.4