1 /* GStreamer unit tests for playbin2
3 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include <gst/check/gstcheck.h>
26 #include <gst/base/gstpushsrc.h>
29 #ifndef GST_DISABLE_REGISTRY
31 static GType gst_red_video_src_get_type (void);
32 static GType gst_codec_src_get_type (void);
34 /* make sure the audio sink is not touched for video-only streams */
35 GST_START_TEST (test_sink_usage_video_only_stream)
37 GstElement *playbin, *fakevideosink, *fakeaudiosink;
38 GstState cur_state, pending_state;
40 GstBuffer *last_frame;
43 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
44 gst_red_video_src_get_type ()));
46 playbin = gst_element_factory_make ("playbin2", "playbin2");
47 fail_unless (playbin != NULL, "Failed to create playbin element");
49 fakevideosink = gst_element_factory_make ("fakesink", "fakevideosink");
50 fail_unless (fakevideosink != NULL, "Failed to create fakevideosink element");
52 fakeaudiosink = gst_element_factory_make ("fakesink", "fakeaudiosink");
53 fail_unless (fakeaudiosink != NULL, "Failed to create fakeaudiosink element");
55 /* video-only stream, audiosink will error out in null => ready if used */
56 g_object_set (fakeaudiosink, "state-error", 1, NULL);
58 g_object_set (playbin, "video-sink", fakevideosink, NULL);
59 g_object_set (playbin, "audio-sink", fakeaudiosink, NULL);
61 g_object_set (playbin, "uri", "redvideo://", NULL);
63 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
64 GST_STATE_CHANGE_SUCCESS);
65 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
66 GST_STATE_CHANGE_ASYNC);
67 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
68 GST_STATE_CHANGE_SUCCESS);
70 fail_unless_equals_int (gst_element_get_state (fakeaudiosink, &cur_state,
71 &pending_state, 0), GST_STATE_CHANGE_SUCCESS);
72 fail_unless_equals_int (cur_state, GST_STATE_NULL);
73 fail_unless_equals_int (pending_state, GST_STATE_VOID_PENDING);
75 g_object_get (playbin, "n-video", &nstreams, NULL);
76 fail_unless_equals_int (nstreams, 1);
78 g_object_get (playbin, "n-audio", &nstreams, NULL);
79 fail_unless_equals_int (nstreams, 0);
81 g_object_get (playbin, "n-text", &nstreams, NULL);
82 fail_unless_equals_int (nstreams, 0);
84 g_object_get (playbin, "source", &source, NULL);
85 fail_unless (G_TYPE_FROM_INSTANCE (source) == gst_red_video_src_get_type ());
86 gst_object_unref (source);
88 g_object_get (playbin, "frame", &last_frame, NULL);
89 fail_unless (GST_IS_BUFFER (last_frame));
90 gst_buffer_unref (last_frame);
92 gst_element_set_state (playbin, GST_STATE_NULL);
93 gst_object_unref (playbin);
98 /* this tests async error handling when setting up the subbin */
99 GST_START_TEST (test_suburi_error_unknowntype)
101 GstElement *playbin, *fakesink;
103 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
104 gst_red_video_src_get_type ()));
106 playbin = gst_element_factory_make ("playbin2", "playbin2");
107 fail_unless (playbin != NULL, "Failed to create playbin element");
109 fakesink = gst_element_factory_make ("fakesink", "fakesink");
110 fail_unless (fakesink != NULL, "Failed to create fakesink element");
111 ASSERT_OBJECT_REFCOUNT (fakesink, "fakesink after creation", 1);
113 g_object_set (playbin, "video-sink", fakesink, NULL);
115 /* suburi file format unknown: playbin should just ignore the suburi and
116 * preroll normally (if /dev/zero does not exist, this test should behave
117 * the same as test_suburi_error_invalidfile() */
118 g_object_set (playbin, "uri", "redvideo://", NULL);
119 g_object_set (playbin, "suburi", "file:///dev/zero", NULL);
120 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
121 GST_STATE_CHANGE_SUCCESS);
122 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
123 GST_STATE_CHANGE_ASYNC);
124 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
125 GST_STATE_CHANGE_SUCCESS);
127 gst_element_set_state (playbin, GST_STATE_NULL);
128 gst_object_unref (playbin);
133 GST_START_TEST (test_suburi_error_invalidfile)
135 GstElement *playbin, *fakesink;
137 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
138 gst_red_video_src_get_type ()));
140 playbin = gst_element_factory_make ("playbin2", "playbin2");
141 fail_unless (playbin != NULL, "Failed to create playbin element");
143 fakesink = gst_element_factory_make ("fakesink", "fakesink");
144 fail_unless (fakesink != NULL, "Failed to create fakesink element");
145 ASSERT_OBJECT_REFCOUNT (fakesink, "fakesink after creation", 1);
147 g_object_set (playbin, "video-sink", fakesink, NULL);
149 /* suburi file does not exist: playbin should just ignore the suburi and
150 * preroll normally */
151 g_object_set (playbin, "uri", "redvideo://", NULL);
152 g_object_set (playbin, "suburi", "file:///foo/bar/803129999/32x9ax1", NULL);
153 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
154 GST_STATE_CHANGE_SUCCESS);
155 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
156 GST_STATE_CHANGE_ASYNC);
157 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
158 GST_STATE_CHANGE_SUCCESS);
160 gst_element_set_state (playbin, GST_STATE_NULL);
161 gst_object_unref (playbin);
166 GST_START_TEST (test_suburi_error_wrongproto)
168 GstElement *playbin, *fakesink;
170 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
171 gst_red_video_src_get_type ()));
173 playbin = gst_element_factory_make ("playbin2", "playbin2");
174 fail_unless (playbin != NULL, "Failed to create playbin element");
176 fakesink = gst_element_factory_make ("fakesink", "fakesink");
177 fail_unless (fakesink != NULL, "Failed to create fakesink element");
178 ASSERT_OBJECT_REFCOUNT (fakesink, "fakesink after creation", 1);
180 g_object_set (playbin, "video-sink", fakesink, NULL);
182 /* wrong protocol for suburi: playbin should just ignore the suburi and
183 * preroll normally */
184 g_object_set (playbin, "uri", "redvideo://", NULL);
185 g_object_set (playbin, "suburi", "nosuchproto://foo.bar:80", NULL);
186 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
187 GST_STATE_CHANGE_SUCCESS);
188 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
189 GST_STATE_CHANGE_ASYNC);
190 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL, -1),
191 GST_STATE_CHANGE_SUCCESS);
193 gst_element_set_state (playbin, GST_STATE_NULL);
194 gst_object_unref (playbin);
200 create_playbin (const gchar * uri)
202 GstElement *playbin, *fakesink1, *fakesink2;
204 playbin = gst_element_factory_make ("playbin2", "playbin2");
205 fail_unless (playbin != NULL, "Failed to create playbin element");
207 fakesink1 = gst_element_factory_make ("fakesink", NULL);
208 fail_unless (fakesink1 != NULL, "Failed to create fakesink element #1");
210 fakesink2 = gst_element_factory_make ("fakesink", NULL);
211 fail_unless (fakesink2 != NULL, "Failed to create fakesink element #2");
213 /* make them behave like normal sinks, even if not needed for the test */
214 g_object_set (fakesink1, "sync", TRUE, NULL);
215 g_object_set (fakesink2, "sync", TRUE, NULL);
217 g_object_set (playbin, "video-sink", fakesink1, NULL);
218 g_object_set (playbin, "audio-sink", fakesink2, NULL);
220 g_object_set (playbin, "uri", uri, NULL);
225 GST_START_TEST (test_missing_urisource_handler)
233 playbin = create_playbin ("chocchipcookie://withahint.of/cinnamon");
235 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
236 GST_STATE_CHANGE_SUCCESS);
237 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
238 GST_STATE_CHANGE_FAILURE);
240 /* there should be at least a missing-plugin message on the bus now and an
241 * error message; the missing-plugin message should be first */
242 bus = gst_element_get_bus (playbin);
244 msg = gst_bus_poll (bus, GST_MESSAGE_ELEMENT | GST_MESSAGE_ERROR, -1);
245 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
246 fail_unless (msg->structure != NULL);
248 fail_unless (gst_structure_has_name (s, "missing-plugin"));
249 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
250 fail_unless_equals_string (gst_structure_get_string (s, "detail"),
252 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
253 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
254 gst_message_unref (msg);
256 msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, -1);
257 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
259 /* make sure the error is a CORE MISSING_PLUGIN one */
260 gst_message_parse_error (msg, &err, NULL);
261 fail_unless (err != NULL);
262 fail_unless (err->domain == GST_CORE_ERROR, "error has wrong error domain "
263 "%s instead of core-error-quark", g_quark_to_string (err->domain));
264 fail_unless (err->code == GST_CORE_ERROR_MISSING_PLUGIN, "error has wrong "
265 "code %u instead of GST_CORE_ERROR_MISSING_PLUGIN", err->code);
267 gst_message_unref (msg);
268 gst_object_unref (bus);
270 gst_element_set_state (playbin, GST_STATE_NULL);
271 gst_object_unref (playbin);
276 GST_START_TEST (test_missing_suburisource_handler)
284 playbin = create_playbin ("file:///does/not/exis.t");
286 g_object_set (playbin, "suburi", "cookie://withahint.of/cinnamon", NULL);
288 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
289 GST_STATE_CHANGE_SUCCESS);
290 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
291 GST_STATE_CHANGE_FAILURE);
293 /* there should be at least a missing-plugin message on the bus now and an
294 * error message; the missing-plugin message should be first */
295 bus = gst_element_get_bus (playbin);
297 msg = gst_bus_poll (bus, GST_MESSAGE_ELEMENT | GST_MESSAGE_ERROR, -1);
298 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
299 fail_unless (msg->structure != NULL);
301 fail_unless (gst_structure_has_name (s, "missing-plugin"));
302 fail_unless (gst_structure_has_field_typed (s, "detail", G_TYPE_STRING));
303 fail_unless_equals_string (gst_structure_get_string (s, "detail"), "cookie");
304 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
305 fail_unless_equals_string (gst_structure_get_string (s, "type"), "urisource");
306 gst_message_unref (msg);
308 msg = gst_bus_poll (bus, GST_MESSAGE_WARNING, -1);
309 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_WARNING);
311 /* make sure the *warning* is a CORE MISSING_PLUGIN one */
312 gst_message_parse_warning (msg, &err, NULL);
313 fail_unless (err != NULL);
314 fail_unless (err->domain == GST_CORE_ERROR, "error has wrong error domain "
315 "%s instead of core-error-quark", g_quark_to_string (err->domain));
316 fail_unless (err->code == GST_CORE_ERROR_MISSING_PLUGIN, "error has wrong "
317 "code %u instead of GST_CORE_ERROR_MISSING_PLUGIN", err->code);
319 gst_message_unref (msg);
321 msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, -1);
322 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
324 /* make sure the error is a RESOURCE NOT_FOUND one */
325 gst_message_parse_error (msg, &err, NULL);
326 fail_unless (err != NULL);
327 fail_unless (err->domain == GST_RESOURCE_ERROR,
328 "error has wrong error domain " "%s instead of resource-error-quark",
329 g_quark_to_string (err->domain));
330 fail_unless (err->code == GST_RESOURCE_ERROR_NOT_FOUND,
331 "error has wrong " "code %u instead of GST_RESOURCE_ERROR_NOT_FOUND",
334 gst_message_unref (msg);
336 gst_object_unref (bus);
338 gst_element_set_state (playbin, GST_STATE_NULL);
339 gst_object_unref (playbin);
344 GST_START_TEST (test_missing_primary_decoder)
352 fail_unless (gst_element_register (NULL, "codecsrc", GST_RANK_PRIMARY,
353 gst_codec_src_get_type ()));
355 playbin = create_playbin ("codec://");
357 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_READY),
358 GST_STATE_CHANGE_SUCCESS);
359 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
360 GST_STATE_CHANGE_ASYNC);
362 /* there should soon be at least a missing-plugin message on the bus and an
363 * error message; the missing-plugin message should be first */
364 bus = gst_element_get_bus (playbin);
366 msg = gst_bus_poll (bus, GST_MESSAGE_ELEMENT | GST_MESSAGE_ERROR, -1);
367 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ELEMENT);
368 fail_unless (msg->structure != NULL);
370 fail_unless (gst_structure_has_name (s, "missing-plugin"));
371 fail_unless (gst_structure_has_field_typed (s, "type", G_TYPE_STRING));
372 fail_unless_equals_string (gst_structure_get_string (s, "type"), "decoder");
373 fail_unless (gst_structure_has_field_typed (s, "detail", GST_TYPE_CAPS));
374 gst_message_unref (msg);
376 msg = gst_bus_poll (bus, GST_MESSAGE_WARNING, -1);
377 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_WARNING);
379 /* make sure the *warning* is a STREAM CODEC_NOT_FOUND one */
380 gst_message_parse_warning (msg, &err, NULL);
381 fail_unless (err != NULL);
382 fail_unless (err->domain == GST_STREAM_ERROR, "error has wrong error domain "
383 "%s instead of stream-error-quark", g_quark_to_string (err->domain));
384 fail_unless (err->code == GST_STREAM_ERROR_CODEC_NOT_FOUND, "error has wrong "
385 "code %u instead of GST_STREAM_ERROR_CODEC_NOT_FOUND", err->code);
387 gst_message_unref (msg);
389 msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, -1);
390 fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
392 /* make sure the error is a CORE MISSING_PLUGIN one */
393 gst_message_parse_error (msg, &err, NULL);
394 fail_unless (err != NULL);
395 fail_unless (err->domain == GST_CORE_ERROR, "error has wrong error domain "
396 "%s instead of core-error-quark", g_quark_to_string (err->domain));
397 fail_unless (err->code == GST_CORE_ERROR_MISSING_PLUGIN, "error has wrong "
398 "code %u instead of GST_CORE_ERROR_MISSING_PLUGIN", err->code);
400 gst_message_unref (msg);
402 gst_object_unref (bus);
404 gst_element_set_state (playbin, GST_STATE_NULL);
405 gst_object_unref (playbin);
410 GST_START_TEST (test_refcount)
412 GstElement *playbin, *audiosink, *videosink, *vis;
414 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
415 gst_red_video_src_get_type ()));
417 playbin = gst_element_factory_make ("playbin2", NULL);
418 audiosink = gst_element_factory_make ("fakesink", "myaudiosink");
419 videosink = gst_element_factory_make ("fakesink", "myvideosink");
420 vis = gst_element_factory_make ("identity", "myvis");
422 /* ref because we need them after we unref playbin2 */
423 gst_object_ref (audiosink);
424 gst_object_ref (videosink);
425 gst_object_ref (vis);
427 /* Sinks have floating ref only, setting the properties takes ownership. */
428 g_object_set (playbin,
429 "audio-sink", audiosink,
430 "video-sink", videosink,
431 "vis-plugin", vis, "flags", 0x01 | 0x02 | 0x08, NULL);
433 g_object_set (playbin, "uri", "redvideo://", NULL);
434 //"uri", "file:///home/wim/data/cdda.ogg", NULL);
436 ASSERT_OBJECT_REFCOUNT (playbin, "playbin", 1);
438 /* we have two refs now, one from ourselves and one from playbin2 */
439 ASSERT_OBJECT_REFCOUNT (audiosink, "myaudiosink", 2);
440 ASSERT_OBJECT_REFCOUNT (videosink, "myvideosink", 2);
441 ASSERT_OBJECT_REFCOUNT (vis, "myvis", 2);
443 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
444 GST_STATE_CHANGE_ASYNC);
445 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL,
446 GST_CLOCK_TIME_NONE), GST_STATE_CHANGE_SUCCESS);
447 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_NULL),
448 GST_STATE_CHANGE_SUCCESS);
450 ASSERT_OBJECT_REFCOUNT (playbin, "playbin", 1);
451 /* refcount of our elements is undefined, playbin2 might keep additional refs
452 * because it cached the elements in bins */
453 gst_object_unref (playbin);
455 /* now we are back to our refs */
456 ASSERT_OBJECT_REFCOUNT (audiosink, "myaudiosink", 1);
457 ASSERT_OBJECT_REFCOUNT (videosink, "myvideosink", 1);
458 ASSERT_OBJECT_REFCOUNT (vis, "myvis", 1);
460 gst_object_unref (audiosink);
461 gst_object_unref (videosink);
462 gst_object_unref (vis);
468 source_setup (GstElement * playbin, GstElement * source, GstElement ** p_src)
470 GST_LOG ("source-setup called, source = %s", G_OBJECT_TYPE_NAME (source));
471 *p_src = gst_object_ref (source);
475 GST_START_TEST (test_source_setup)
477 GstElement *playbin, *videosink;
478 GstElement *src = NULL;
480 if (!gst_default_registry_check_feature_version ("redvideosrc", 0, 10, 0)) {
481 fail_unless (gst_element_register (NULL, "redvideosrc", GST_RANK_PRIMARY,
482 gst_red_video_src_get_type ()));
485 playbin = gst_element_factory_make ("playbin2", NULL);
486 g_object_set (playbin, "uri", "redvideo://", NULL);
488 videosink = gst_element_factory_make ("fakesink", "myvideosink");
489 g_object_set (playbin, "video-sink", videosink, NULL);
491 g_signal_connect (playbin, "source-setup", G_CALLBACK (source_setup), &src);
493 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_PAUSED),
494 GST_STATE_CHANGE_ASYNC);
495 fail_unless_equals_int (gst_element_get_state (playbin, NULL, NULL,
496 GST_CLOCK_TIME_NONE), GST_STATE_CHANGE_SUCCESS);
498 fail_unless (src != NULL);
499 fail_unless (G_OBJECT_TYPE (src) == gst_red_video_src_get_type ());
501 fail_unless_equals_int (gst_element_set_state (playbin, GST_STATE_NULL),
502 GST_STATE_CHANGE_SUCCESS);
504 gst_object_unref (playbin);
505 gst_object_unref (src);
510 /*** redvideo:// source ***/
513 gst_red_video_src_uri_get_type (void)
519 gst_red_video_src_uri_get_protocols (void)
521 static gchar *protocols[] = { (char *) "redvideo", NULL };
527 gst_red_video_src_uri_get_uri (GstURIHandler * handler)
529 return "redvideo://";
533 gst_red_video_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
535 return (uri != NULL && g_str_has_prefix (uri, "redvideo:"));
539 gst_red_video_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
541 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
543 iface->get_type = gst_red_video_src_uri_get_type;
544 iface->get_protocols = gst_red_video_src_uri_get_protocols;
545 iface->get_uri = gst_red_video_src_uri_get_uri;
546 iface->set_uri = gst_red_video_src_uri_set_uri;
550 gst_red_video_src_init_type (GType type)
552 static const GInterfaceInfo uri_hdlr_info = {
553 gst_red_video_src_uri_handler_init, NULL, NULL
556 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_hdlr_info);
559 typedef GstPushSrc GstRedVideoSrc;
560 typedef GstPushSrcClass GstRedVideoSrcClass;
562 GST_BOILERPLATE_FULL (GstRedVideoSrc, gst_red_video_src, GstPushSrc,
563 GST_TYPE_PUSH_SRC, gst_red_video_src_init_type);
566 gst_red_video_src_base_init (gpointer klass)
568 static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
569 GST_PAD_SRC, GST_PAD_ALWAYS,
570 GST_STATIC_CAPS ("video/x-raw-yuv, format=(fourcc)I420")
572 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
574 gst_element_class_add_static_pad_template (element_class, &src_templ);
575 gst_element_class_set_details_simple (element_class,
576 "Red Video Src", "Source/Video", "yep", "me");
580 gst_red_video_src_create (GstPushSrc * src, GstBuffer ** p_buf)
585 guint w = 64, h = 64;
588 size = w * h * 3 / 2;
589 buf = gst_buffer_new_and_alloc (size);
590 data = GST_BUFFER_DATA (buf);
591 memset (data, 76, w * h);
592 memset (data + (w * h), 85, (w * h) / 4);
593 memset (data + (w * h) + ((w * h) / 4), 255, (w * h) / 4);
595 caps = gst_caps_new_simple ("video/x-raw-yuv", "format", GST_TYPE_FOURCC,
596 GST_MAKE_FOURCC ('I', '4', '2', '0'), "width", G_TYPE_INT, w, "height",
597 G_TYPE_INT, h, "framerate", GST_TYPE_FRACTION, 1, 1, NULL);
598 gst_buffer_set_caps (buf, caps);
599 gst_caps_unref (caps);
606 gst_red_video_src_class_init (GstRedVideoSrcClass * klass)
608 GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass);
610 pushsrc_class->create = gst_red_video_src_create;
614 gst_red_video_src_init (GstRedVideoSrc * src, GstRedVideoSrcClass * klass)
618 /*** codec:// source ***/
621 gst_codec_src_uri_get_type (void)
627 gst_codec_src_uri_get_protocols (void)
629 static gchar *protocols[] = { (char *) "codec", NULL };
635 gst_codec_src_uri_get_uri (GstURIHandler * handler)
641 gst_codec_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
643 return (uri != NULL && g_str_has_prefix (uri, "codec:"));
647 gst_codec_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
649 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
651 iface->get_type = gst_codec_src_uri_get_type;
652 iface->get_protocols = gst_codec_src_uri_get_protocols;
653 iface->get_uri = gst_codec_src_uri_get_uri;
654 iface->set_uri = gst_codec_src_uri_set_uri;
658 gst_codec_src_init_type (GType type)
660 static const GInterfaceInfo uri_hdlr_info = {
661 gst_codec_src_uri_handler_init, NULL, NULL
664 g_type_add_interface_static (type, GST_TYPE_URI_HANDLER, &uri_hdlr_info);
668 #define parent_class codec_src_parent_class
670 typedef GstPushSrc GstCodecSrc;
671 typedef GstPushSrcClass GstCodecSrcClass;
673 GST_BOILERPLATE_FULL (GstCodecSrc, gst_codec_src, GstPushSrc,
674 GST_TYPE_PUSH_SRC, gst_codec_src_init_type);
677 gst_codec_src_base_init (gpointer klass)
679 static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
680 GST_PAD_SRC, GST_PAD_ALWAYS,
681 GST_STATIC_CAPS ("application/x-codec")
683 GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
685 gst_element_class_add_static_pad_template (element_class, &src_templ);
686 gst_element_class_set_details_simple (element_class,
687 "Codec Src", "Source/Video", "yep", "me");
691 gst_codec_src_create (GstPushSrc * src, GstBuffer ** p_buf)
696 buf = gst_buffer_new_and_alloc (20);
697 memset (GST_BUFFER_DATA (buf), 0, GST_BUFFER_SIZE (buf));
699 caps = gst_caps_new_simple ("application/x-codec", NULL);
700 gst_buffer_set_caps (buf, caps);
701 gst_caps_unref (caps);
708 gst_codec_src_class_init (GstCodecSrcClass * klass)
710 GstPushSrcClass *pushsrc_class = GST_PUSH_SRC_CLASS (klass);
712 pushsrc_class->create = gst_codec_src_create;
716 gst_codec_src_init (GstCodecSrc * src, GstCodecSrcClass * klass)
720 #endif /* GST_DISABLE_REGISTRY */
724 playbin2_suite (void)
726 Suite *s = suite_create ("playbin2");
727 TCase *tc_chain = tcase_create ("general");
729 suite_add_tcase (s, tc_chain);
731 #ifndef GST_DISABLE_REGISTRY
732 tcase_add_test (tc_chain, test_sink_usage_video_only_stream);
733 tcase_add_test (tc_chain, test_suburi_error_wrongproto);
734 tcase_add_test (tc_chain, test_suburi_error_invalidfile);
735 tcase_add_test (tc_chain, test_suburi_error_unknowntype);
736 tcase_add_test (tc_chain, test_missing_urisource_handler);
737 tcase_add_test (tc_chain, test_missing_suburisource_handler);
738 tcase_add_test (tc_chain, test_missing_primary_decoder);
739 tcase_add_test (tc_chain, test_refcount);
740 tcase_add_test (tc_chain, test_source_setup);
742 /* one day we might also want to have the following checks:
743 * tcase_add_test (tc_chain, test_missing_secondary_decoder_one_fatal);
744 * tcase_add_test (tc_chain, test_missing_secondary_decoder_two_fatal);
745 * tcase_add_test (tc_chain, test_missing_secondary_decoder_two_with_preroll);
752 GST_CHECK_MAIN (playbin2);