Commit b75b5525 authored by Wim Taymans's avatar Wim Taymans

gst/playback/: Add playbin2.

Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstplayback.c: (plugin_init):
* gst/playback/test7.c: (update_scale), (warning_cb), (error_cb),
(eos_cb), (about_to_finish_cb), (main):
Add playbin2.
Added gapless playback example.
* gst/playback/gstplaybasebin.c:
* gst/playback/gstplaybasebin.h:
* gst/playback/gstplaybin.c: (gst_play_bin_plugin_init):
* gst/playback/gstqueue2.c:
* gst/playback/test.c:
* gst/playback/gsturidecodebin.c: (gst_uri_decode_bin_class_init),
(pad_removed_cb):
* gst/playback/gststreaminfo.h:
Change email.
* gst/playback/gstplaybin2.c: (gst_play_bin_get_type),
(gst_play_bin_class_init), (init_group), (gst_play_bin_init),
(gst_play_bin_dispose), (gst_play_bin_set_uri),
(gst_play_bin_set_suburi), (gst_play_bin_set_property),
(gst_play_bin_get_property), (gst_play_bin_handle_message),
(pad_added_cb), (pad_removed_cb), (no_more_pads_cb), (perform_eos),
(drained_cb), (unlink_group), (activate_group),
(setup_next_source), (gst_play_bin_change_state),
(gst_play_bin2_plugin_init):
Added raw first version of playbin2. Does chained oggs and gapless
playback fine. No support for raw sinks yet. No visualisations or
subtitles yet.
* gst/playback/gstplaysink.c: (gst_play_sink_get_type),
(gst_play_sink_class_init), (gst_play_sink_init),
(gst_play_sink_dispose), (gst_play_sink_vis_unblocked),
(gst_play_sink_vis_blocked), (gst_play_sink_set_video_sink),
(gst_play_sink_set_audio_sink), (gst_play_sink_set_vis_plugin),
(gst_play_sink_set_property), (gst_play_sink_get_property),
(post_missing_element_message), (free_chain), (add_chain),
(activate_chain), (gen_video_chain), (gen_text_element),
(gen_audio_chain), (gen_vis_element), (gst_play_sink_get_mode),
(gst_play_sink_set_mode), (gst_play_sink_request_pad),
(gst_play_sink_release_pad), (gst_play_sink_send_event_to_sink),
(gst_play_sink_send_event), (gst_play_sink_change_state):
* gst/playback/gstplaysink.h:
Added Element that abstracts the sinks and their pipelines for playbin2.
parent 3f43bfac
2007-11-16 Wim Taymans <wim.taymans@gmail.com>
* gst/playback/Makefile.am:
* gst/playback/gstplayback.c: (plugin_init):
* gst/playback/test7.c: (update_scale), (warning_cb), (error_cb),
(eos_cb), (about_to_finish_cb), (main):
Add playbin2.
Added gapless playback example.
* gst/playback/gstplaybasebin.c:
* gst/playback/gstplaybasebin.h:
* gst/playback/gstplaybin.c: (gst_play_bin_plugin_init):
* gst/playback/gstqueue2.c:
* gst/playback/test.c:
* gst/playback/gsturidecodebin.c: (gst_uri_decode_bin_class_init),
(pad_removed_cb):
* gst/playback/gststreaminfo.h:
Change email.
* gst/playback/gstplaybin2.c: (gst_play_bin_get_type),
(gst_play_bin_class_init), (init_group), (gst_play_bin_init),
(gst_play_bin_dispose), (gst_play_bin_set_uri),
(gst_play_bin_set_suburi), (gst_play_bin_set_property),
(gst_play_bin_get_property), (gst_play_bin_handle_message),
(pad_added_cb), (pad_removed_cb), (no_more_pads_cb), (perform_eos),
(drained_cb), (unlink_group), (activate_group),
(setup_next_source), (gst_play_bin_change_state),
(gst_play_bin2_plugin_init):
Added raw first version of playbin2. Does chained oggs and gapless
playback fine. No support for raw sinks yet. No visualisations or
subtitles yet.
* gst/playback/gstplaysink.c: (gst_play_sink_get_type),
(gst_play_sink_class_init), (gst_play_sink_init),
(gst_play_sink_dispose), (gst_play_sink_vis_unblocked),
(gst_play_sink_vis_blocked), (gst_play_sink_set_video_sink),
(gst_play_sink_set_audio_sink), (gst_play_sink_set_vis_plugin),
(gst_play_sink_set_property), (gst_play_sink_get_property),
(post_missing_element_message), (free_chain), (add_chain),
(activate_chain), (gen_video_chain), (gen_text_element),
(gen_audio_chain), (gen_vis_element), (gst_play_sink_get_mode),
(gst_play_sink_set_mode), (gst_play_sink_request_pad),
(gst_play_sink_release_pad), (gst_play_sink_send_event_to_sink),
(gst_play_sink_send_event), (gst_play_sink_change_state):
* gst/playback/gstplaysink.h:
Added Element that abstracts the sinks and their pipelines for playbin2.
2007-11-16 Wim Taymans <wim.taymans@gmail.com>
* gst/playback/gststreamselector.c: (gst_selector_pad_get_type),
......@@ -8,10 +8,13 @@ built_headers = gstplay-marshal.h
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@
plugin_LTLIBRARIES = libgstplaybin.la libgstdecodebin.la libgstdecodebin2.la libgstqueue2.la \
libgsturidecodebin.la
libgsturidecodebin.la
libgstplaybin_la_SOURCES = \
gstplayback.c \
gstplaybin.c \
gstplaybin2.c \
gstplaysink.c \
gstplaybasebin.c \
gststreaminfo.c \
gststreamselector.c
......@@ -55,10 +58,11 @@ libgsturidecodebin_la_LIBADD = \
noinst_HEADERS = \
gstplaybasebin.h \
gstplaysink.h \
gststreaminfo.h \
gststreamselector.h
noinst_PROGRAMS = test decodetest test2 test3 test4 test5 test6
noinst_PROGRAMS = test decodetest test2 test3 test4 test5 test6 test7
test_LDADD = $(GST_LIBS)
test_CFLAGS = $(GST_CFLAGS)
......@@ -78,6 +82,9 @@ test5_CFLAGS = $(GST_CFLAGS)
test6_LDADD = $(GST_LIBS)
test6_CFLAGS = $(GST_CFLAGS)
test7_LDADD = $(GST_LIBS)
test7_CFLAGS = $(GST_CFLAGS)
decodetest_LDADD = $(GST_LIBS)
decodetest_CFLAGS = $(GST_CFLAGS)
......
/* GStreamer
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <gst/gst.h>
#include <gst/gst-i18n-plugin.h>
#include <gst/pbutils/pbutils.h>
gboolean gst_play_bin_plugin_init (GstPlugin * plugin);
gboolean gst_play_bin2_plugin_init (GstPlugin * plugin);
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean res;
gst_pb_utils_init ();
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif /* ENABLE_NLS */
res = gst_play_bin_plugin_init (plugin);
res &= gst_play_bin2_plugin_init (plugin);
return res;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"playback",
"various playback elements", plugin_init, VERSION, GST_LICENSE,
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
......@@ -1829,25 +1829,11 @@ gst_play_bin_change_state (GstElement * element, GstStateChange transition)
return ret;
}
static gboolean
plugin_init (GstPlugin * plugin)
gboolean
gst_play_bin_plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin");
gst_pb_utils_init ();
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif /* ENABLE_NLS */
return gst_element_register (plugin, "playbin", GST_RANK_NONE,
GST_TYPE_PLAY_BIN);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"playbin",
"player bin", plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME,
GST_PACKAGE_ORIGIN)
This diff is collapsed.
This diff is collapsed.
/* GStreamer
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_PLAY_SINK_H__
#define __GST_PLAY_SINK_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PLAY_SINK \
(gst_play_sink_get_type())
#define GST_PLAY_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAY_SINK, GstPlaySink))
#define GST_PLAY_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY_SINK, GstPlaySinkClass))
#define GST_IS_PLAY_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAY_SINK))
#define GST_IS_PLAY_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAY_SINK))
/**
* GstPlaySinkMode:
* @GST_PLAY_SINK_MODE_VIDEO:
* @GST_PLAY_SINK_MODE_AUDIO:
* @GST_PLAY_SINK_MODE_TEXT:
* @GST_PLAY_SINK_MODE_VIS:
*
* Features to enable in the sink.
*/
typedef enum {
GST_PLAY_SINK_MODE_VIDEO = (1 << 0),
GST_PLAY_SINK_MODE_AUDIO = (1 << 1),
GST_PLAY_SINK_MODE_TEXT = (1 << 2),
GST_PLAY_SINK_MODE_VIS = (1 << 3)
} GstPlaySinkMode;
typedef enum {
GST_PLAY_SINK_TYPE_AUDIO = 0,
GST_PLAY_SINK_TYPE_VIDEO = 1,
GST_PLAY_SINK_TYPE_TEXT = 2,
GST_PLAY_SINK_TYPE_LAST = 3
} GstPlaySinkType;
typedef struct _GstPlaySink GstPlaySink;
typedef struct _GstPlaySinkClass GstPlaySinkClass;
GType gst_play_sink_get_type (void);
GstPad * gst_play_sink_request_pad (GstPlaySink *playsink, GstPlaySinkType type);
void gst_play_sink_release_pad (GstPlaySink *playsink, GstPad *pad);
GstPlaySinkMode gst_play_sink_get_mode (GstPlaySink *playsink);
gboolean gst_play_sink_set_mode (GstPlaySink *playsink, GstPlaySinkMode mode);
G_END_DECLS
#endif /* __GST_PLAY_SINK_H__ */
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2003 Colin Walters <cwalters@gnome.org>
* 2000,2005,2007 Wim Taymans <wim@fluendo.com>
* 2000,2005,2007 Wim Taymans <wim.taymans@gmail.com>
* 2007 Thiago Sousa Santos <thiagoss@lcc.ufcg.edu.br>
*
* gstqueue2.c:
......
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
/* GStreamer
* Copyright (C) <2007> Wim Taymans <wim@fluendo.com>
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2006> Wim Taymans <wim@fluendo.com>
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......
/* GStreamer
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#define UPDATE_INTERVAL 500
static int arg_count;
static int max_count;
static gboolean
update_scale (GstElement * element)
{
gint64 duration = -1;
gint64 position = -1;
GstFormat format = GST_FORMAT_TIME;
gchar dur_str[32], pos_str[32];
if (gst_element_query_position (element, &format, &position) &&
position != -1) {
g_snprintf (pos_str, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (position));
} else {
g_snprintf (pos_str, 32, "-:--:--.---------");
}
if (gst_element_query_duration (element, &format, &duration) &&
duration != -1) {
g_snprintf (dur_str, 32, "%" GST_TIME_FORMAT, GST_TIME_ARGS (duration));
} else {
g_snprintf (dur_str, 32, "-:--:--.---------");
}
g_print ("%s / %s\n", pos_str, dur_str);
return TRUE;
}
static void
warning_cb (GstBus * bus, GstMessage * msg, gpointer foo)
{
GError *err = NULL;
gchar *dbg = NULL;
gst_message_parse_warning (msg, &err, &dbg);
g_printerr ("WARNING: %s (%s)\n", err->message, (dbg) ? dbg : "no details");
g_error_free (err);
g_free (dbg);
}
static void
error_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop)
{
GError *err = NULL;
gchar *dbg = NULL;
gst_message_parse_error (msg, &err, &dbg);
g_printerr ("ERROR: %s (%s)\n", err->message, (dbg) ? dbg : "no details");
g_main_loop_quit (main_loop);
g_error_free (err);
g_free (dbg);
}
static void
eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop)
{
g_print ("EOS\n");
g_main_loop_quit (main_loop);
}
static void
about_to_finish_cb (GstElement * element, gchar * uri[])
{
if (arg_count < max_count) {
g_object_set (G_OBJECT (element), "next-uri", uri[arg_count], NULL);
arg_count++;
}
}
gint
main (gint argc, gchar * argv[])
{
GstStateChangeReturn res;
GstElement *player;
GMainLoop *loop;
GstBus *bus;
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, TRUE);
if (argc < 2) {
g_print ("usage: %s <uri> [<uri> ... ]\n", argv[0]);
exit (-1);
}
player = gst_element_factory_make ("playbin2", "player");
g_assert (player);
bus = gst_pipeline_get_bus (GST_PIPELINE (player));
gst_bus_add_signal_watch (bus);
g_signal_connect (bus, "message::eos", G_CALLBACK (eos_cb), loop);
g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), loop);
g_signal_connect (bus, "message::warning", G_CALLBACK (warning_cb), NULL);
g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
arg_count = 2;
max_count = argc;
g_signal_connect (player, "about-to-finish", G_CALLBACK (about_to_finish_cb),
argv);
res = gst_element_set_state (player, GST_STATE_PLAYING);
if (res == GST_STATE_CHANGE_FAILURE) {
g_print ("could not play\n");
return -1;
}
g_timeout_add (UPDATE_INTERVAL, (GSourceFunc) update_scale, player);
g_main_loop_run (loop);
/* tidy up */
gst_element_set_state (player, GST_STATE_NULL);
gst_object_unref (player);
gst_object_unref (bus);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment