player: Import GstPlayer playback convenience API

Based on https://github.com/sdroege/gst-player
commit 9ce6ae0dbb8eeeefaf794cfae80e279a03cc598d
This commit is contained in:
Sebastian Dröge 2015-12-22 14:24:00 +01:00
parent c4e5423f3b
commit 0b2d698b1e
23 changed files with 6375 additions and 3 deletions

View file

@ -3550,6 +3550,7 @@ gst-libs/gst/mpegts/Makefile
gst-libs/gst/uridownloader/Makefile
gst-libs/gst/wayland/Makefile
gst-libs/gst/base/Makefile
gst-libs/gst/player/Makefile
gst-libs/gst/video/Makefile
sys/Makefile
sys/dshowdecwrapper/Makefile

View file

@ -11,11 +11,11 @@ WAYLAND_DIR=wayland
endif
SUBDIRS = uridownloader adaptivedemux interfaces basecamerabinsrc codecparsers \
insertbin mpegts base video $(GL_DIR) $(WAYLAND_DIR)
insertbin mpegts base video player $(GL_DIR) $(WAYLAND_DIR)
noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
DIST_SUBDIRS = uridownloader adaptivedemux interfaces gl basecamerabinsrc \
codecparsers insertbin mpegts wayland base video
codecparsers insertbin mpegts wayland base video player
#dependencies
video: base
@ -24,7 +24,7 @@ adaptivedemux: uridownloader
INDEPENDENT_SUBDIRS = \
interfaces basecamerabinsrc codecparsers insertbin uridownloader \
mpegts base $(GL_DIR) $(WAYLAND_DIR)
mpegts base player $(GL_DIR) $(WAYLAND_DIR)
.PHONY: independent-subdirs $(INDEPENDENT_SUBDIRS)

View file

@ -0,0 +1,101 @@
lib_LTLIBRARIES = libgstplayer-@GST_API_VERSION@.la
libgstplayer_@GST_API_VERSION@_la_SOURCES = \
gstplayer.c \
gstplayer-signal-dispatcher.c \
gstplayer-video-renderer.c \
gstplayer-media-info.c \
gstplayer-g-main-context-signal-dispatcher.c \
gstplayer-video-overlay-video-renderer.c \
gstplayer-visualization.c
libgstplayer_@GST_API_VERSION@_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
-I$(top_builddir)/gst-libs \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS)
libgstplayer_@GST_API_VERSION@_la_LDFLAGS = \
$(GST_LIB_LDFLAGS) \
$(GST_ALL_LDFLAGS) \
$(GST_LT_LDFLAGS)
libgstplayer_@GST_API_VERSION@_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-$(GST_API_VERSION) \
-lgstaudio-$(GST_API_VERSION) \
-lgsttag-$(GST_API_VERSION) \
-lgstpbutils-$(GST_API_VERSION) \
$(GST_LIBS) \
$(LIBM)
libgstplayerdir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/player
noinst_HEADERS = \
gstplayer-signal-dispatcher-private.h \
gstplayer-video-renderer-private.h \
gstplayer-media-info-private.h
libgstplayer_HEADERS = \
player.h \
gstplayer.h \
gstplayer-types.h \
gstplayer-signal-dispatcher.h \
gstplayer-video-renderer.h \
gstplayer-media-info.h \
gstplayer-g-main-context-signal-dispatcher.h \
gstplayer-video-overlay-video-renderer.h \
gstplayer-visualization.h
CLEANFILES =
if HAVE_INTROSPECTION
BUILT_GIRSOURCES = GstPlayer-@GST_API_VERSION@.gir
gir_headers=$(patsubst %,$(srcdir)/%, $(libgstplayer_HEADERS))
gir_sources=$(patsubst %,$(srcdir)/%, $(libgstplayer_@GST_API_VERSION@_la_SOURCES))
GstPlayer-@GST_API_VERSION@.gir: $(INTROSPECTION_SCANNER) libgstplayer-@GST_API_VERSION@.la
$(AM_V_GEN)$(INTROSPECTION_SCANNER) -v --namespace GstPlayer \
--nsversion=@GST_API_VERSION@ \
--warn-all \
--strip-prefix=Gst \
-I$(top_srcdir)/gst-libs \
-I$(top_builddir)/gst-libs \
--c-include "gst/player/player.h" \
--add-include-path=$(top_builddir)/gst-libs \
--add-include-path=`$(PKG_CONFIG) --variable=girdir gstreamer-1.0` \
--library-path=$(top_builddir)/gst-libs \
--library=libgstplayer-@GST_API_VERSION@.la \
--include=Gst-@GST_API_VERSION@ \
--libtool="${LIBTOOL}" \
--pkg gstreamer-@GST_API_VERSION@ \
--pkg gstreamer-audio-@GST_API_VERSION@ \
--pkg gstreamer-video-@GST_API_VERSION@ \
--pkg gstreamer-tag-@GST_API_VERSION@ \
--pkg gstreamer-pbutils-@GST_API_VERSION@ \
--pkg-export gstreamer-player-@GST_API_VERSION@ \
--add-init-section="gst_init(NULL,NULL);" \
--output $@ \
$(gir_headers) \
$(gir_sources)
# INTROSPECTION_GIRDIR/INTROSPECTION_TYPELIBDIR aren't the right place to
# install anything - we need to install inside our prefix.
girdir = $(datadir)/gir-1.0
gir_DATA = $(BUILT_GIRSOURCES)
typelibsdir = $(libdir)/girepository-1.0/
typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
%.typelib: %.gir $(INTROSPECTION_COMPILER)
$(AM_V_GEN)$(INTROSPECTION_COMPILER) \
--includedir=$(srcdir)/gst-libs \
--includedir=$(builddir)/gst-libs \
--includedir=`$(PKG_CONFIG) --variable=girdir gstreamer-1.0` \
$(INTROSPECTION_COMPILER_OPTS) $< -o $(@F)
CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
endif

View file

@ -0,0 +1,212 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstplayer-gmaincontextsignaldispatcher
* @short_description: Player GLib MainContext dispatcher
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-g-main-context-signal-dispatcher.h"
struct _GstPlayerGMainContextSignalDispatcher
{
GObject parent;
GMainContext *application_context;
};
struct _GstPlayerGMainContextSignalDispatcherClass
{
GObjectClass parent_class;
};
static void
gst_player_g_main_context_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface);
enum
{
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_0,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayerGMainContextSignalDispatcher,
gst_player_g_main_context_signal_dispatcher, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_SIGNAL_DISPATCHER,
gst_player_g_main_context_signal_dispatcher_interface_init));
static GParamSpec
* g_main_context_signal_dispatcher_param_specs
[G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST] = { NULL, };
static void
gst_player_g_main_context_signal_dispatcher_finalize (GObject * object)
{
GstPlayerGMainContextSignalDispatcher *self =
GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
if (self->application_context)
g_main_context_unref (self->application_context);
G_OBJECT_CLASS
(gst_player_g_main_context_signal_dispatcher_parent_class)->finalize
(object);
}
static void
gst_player_g_main_context_signal_dispatcher_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerGMainContextSignalDispatcher *self =
GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT:
self->application_context = g_value_dup_boxed (value);
if (!self->application_context)
self->application_context = g_main_context_ref_thread_default ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_g_main_context_signal_dispatcher_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerGMainContextSignalDispatcher *self =
GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT:
g_value_set_boxed (value, self->application_context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_g_main_context_signal_dispatcher_class_init
(GstPlayerGMainContextSignalDispatcherClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize =
gst_player_g_main_context_signal_dispatcher_finalize;
gobject_class->set_property =
gst_player_g_main_context_signal_dispatcher_set_property;
gobject_class->get_property =
gst_player_g_main_context_signal_dispatcher_get_property;
g_main_context_signal_dispatcher_param_specs
[G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT] =
g_param_spec_boxed ("application-context", "Application Context",
"Application GMainContext to dispatch signals to", G_TYPE_MAIN_CONTEXT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST,
g_main_context_signal_dispatcher_param_specs);
}
static void
gst_player_g_main_context_signal_dispatcher_init
(G_GNUC_UNUSED GstPlayerGMainContextSignalDispatcher * self)
{
}
typedef struct
{
void (*emitter) (gpointer data);
gpointer data;
GDestroyNotify destroy;
} GMainContextSignalDispatcherData;
static gboolean
g_main_context_signal_dispatcher_dispatch_gsourcefunc (gpointer user_data)
{
GMainContextSignalDispatcherData *data = user_data;
data->emitter (data->data);
return G_SOURCE_REMOVE;
}
static void
g_main_context_signal_dispatcher_dispatch_destroy (gpointer user_data)
{
GMainContextSignalDispatcherData *data = user_data;
if (data->destroy)
data->destroy (data->data);
g_free (data);
}
static void
gst_player_g_main_context_signal_dispatcher_dispatch (GstPlayerSignalDispatcher
* iface, G_GNUC_UNUSED GstPlayer * player, void (*emitter) (gpointer data),
gpointer data, GDestroyNotify destroy)
{
GstPlayerGMainContextSignalDispatcher *self =
GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (iface);
GMainContextSignalDispatcherData *gsourcefunc_data =
g_new (GMainContextSignalDispatcherData, 1);
gsourcefunc_data->emitter = emitter;
gsourcefunc_data->data = data;
gsourcefunc_data->destroy = destroy;
g_main_context_invoke_full (self->application_context,
G_PRIORITY_DEFAULT, g_main_context_signal_dispatcher_dispatch_gsourcefunc,
gsourcefunc_data, g_main_context_signal_dispatcher_dispatch_destroy);
}
static void
gst_player_g_main_context_signal_dispatcher_interface_init
(GstPlayerSignalDispatcherInterface * iface)
{
iface->dispatch = gst_player_g_main_context_signal_dispatcher_dispatch;
}
/**
* gst_player_g_main_context_signal_dispatcher_new:
* @application_context: (allow-none): GMainContext to use or %NULL
*
* Creates a new GstPlayerSignalDispatcher that uses @application_context,
* or the thread default one if %NULL is used. See gst_player_new_full().
*
* Returns: (transfer full): the new GstPlayerSignalDispatcher
*/
GstPlayerSignalDispatcher *
gst_player_g_main_context_signal_dispatcher_new (GMainContext *
application_context)
{
return g_object_new (GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER,
"application-context", application_context, NULL);
}

View file

@ -0,0 +1,48 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__
#define __GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__
#include <gst/player/gstplayer-types.h>
#include <gst/player/gstplayer-signal-dispatcher.h>
G_BEGIN_DECLS
typedef struct _GstPlayerGMainContextSignalDispatcher
GstPlayerGMainContextSignalDispatcher;
typedef struct _GstPlayerGMainContextSignalDispatcherClass
GstPlayerGMainContextSignalDispatcherClass;
#define GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (gst_player_g_main_context_signal_dispatcher_get_type ())
#define GST_IS_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER))
#define GST_IS_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER))
#define GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstPlayerGMainContextSignalDispatcherClass))
#define GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstPlayerGMainContextSignalDispatcher))
#define GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstPlayerGMainContextSignalDispatcherClass))
#define GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CAST(obj) ((GstPlayerGMainContextSignalDispatcher*)(obj))
GType gst_player_g_main_context_signal_dispatcher_get_type (void);
GstPlayerSignalDispatcher * gst_player_g_main_context_signal_dispatcher_new (GMainContext * application_context);
G_END_DECLS
#endif /* __GST_PLAYER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__ */

View file

@ -0,0 +1,125 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "gstplayer-media-info.h"
#ifndef __GST_PLAYER_MEDIA_INFO_PRIVATE_H__
#define __GST_PLAYER_MEDIA_INFO_PRIVATE_H__
struct _GstPlayerStreamInfo
{
GObject parent;
gchar *codec;
GstCaps *caps;
gint stream_index;
GstTagList *tags;
};
struct _GstPlayerStreamInfoClass
{
GObjectClass parent_class;
};
struct _GstPlayerSubtitleInfo
{
GstPlayerStreamInfo parent;
gchar *language;
};
struct _GstPlayerSubtitleInfoClass
{
GstPlayerStreamInfoClass parent_class;
};
struct _GstPlayerAudioInfo
{
GstPlayerStreamInfo parent;
gint channels;
gint sample_rate;
guint bitrate;
guint max_bitrate;
gchar *language;
};
struct _GstPlayerAudioInfoClass
{
GstPlayerStreamInfoClass parent_class;
};
struct _GstPlayerVideoInfo
{
GstPlayerStreamInfo parent;
gint width;
gint height;
gint framerate_num;
gint framerate_denom;
gint par_num;
gint par_denom;
guint bitrate;
guint max_bitrate;
};
struct _GstPlayerVideoInfoClass
{
GstPlayerStreamInfoClass parent_class;
};
struct _GstPlayerMediaInfo
{
GObject parent;
gchar *uri;
gchar *title;
gchar *container;
gboolean seekable;
GstTagList *tags;
GstSample *image_sample;
GList *stream_list;
GList *audio_stream_list;
GList *video_stream_list;
GList *subtitle_stream_list;
GstClockTime duration;
};
struct _GstPlayerMediaInfoClass
{
GObjectClass parent_class;
};
G_GNUC_INTERNAL GstPlayerMediaInfo* gst_player_media_info_new
(const gchar *uri);
G_GNUC_INTERNAL GstPlayerMediaInfo* gst_player_media_info_copy
(GstPlayerMediaInfo *ref);
G_GNUC_INTERNAL GstPlayerStreamInfo* gst_player_stream_info_new
(gint stream_index, GType type);
G_GNUC_INTERNAL GstPlayerStreamInfo* gst_player_stream_info_copy
(GstPlayerStreamInfo *ref);
#endif /* __GST_PLAYER_MEDIA_INFO_PRIVATE_H__ */

View file

@ -0,0 +1,775 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstplayer-mediainfo
* @short_description: Player Media Information
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-media-info.h"
#include "gstplayer-media-info-private.h"
/* Per-stream information */
G_DEFINE_ABSTRACT_TYPE (GstPlayerStreamInfo, gst_player_stream_info,
G_TYPE_OBJECT);
static void
gst_player_stream_info_init (GstPlayerStreamInfo * sinfo)
{
sinfo->stream_index = -1;
}
static void
gst_player_stream_info_finalize (GObject * object)
{
GstPlayerStreamInfo *sinfo = GST_PLAYER_STREAM_INFO (object);
g_free (sinfo->codec);
if (sinfo->caps)
gst_caps_unref (sinfo->caps);
if (sinfo->tags)
gst_tag_list_unref (sinfo->tags);
G_OBJECT_CLASS (gst_player_stream_info_parent_class)->finalize (object);
}
static void
gst_player_stream_info_class_init (GstPlayerStreamInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_player_stream_info_finalize;
}
/**
* gst_player_stream_info_get_index:
* @info: a #GstPlayerStreamInfo
*
* Function to get stream index from #GstPlayerStreamInfo instance.
*
* Returns: the stream index of this stream.
*/
gint
gst_player_stream_info_get_index (const GstPlayerStreamInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), -1);
return info->stream_index;
}
/**
* gst_player_stream_info_get_stream_type:
* @info: a #GstPlayerStreamInfo
*
* Function to return human readable name for the stream type
* of the given @info (ex: "audio", "video", "subtitle")
*
* Returns: a human readable name
*/
const gchar *
gst_player_stream_info_get_stream_type (const GstPlayerStreamInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
if (GST_IS_PLAYER_VIDEO_INFO (info))
return "video";
else if (GST_IS_PLAYER_AUDIO_INFO (info))
return "audio";
else
return "subtitle";
}
/**
* gst_player_stream_info_get_tags:
* @info: a #GstPlayerStreamInfo
*
* Returns: (transfer none): the tags contained in this stream.
*/
GstTagList *
gst_player_stream_info_get_tags (const GstPlayerStreamInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
return info->tags;
}
/**
* gst_player_stream_info_get_codec:
* @info: a #GstPlayerStreamInfo
*
* A string describing codec used in #GstPlayerStreamInfo.
*
* Returns: codec string or NULL on unknown.
*/
const gchar *
gst_player_stream_info_get_codec (const GstPlayerStreamInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
return info->codec;
}
/**
* gst_player_stream_info_get_caps:
* @info: a #GstPlayerStreamInfo
*
* Returns: (transfer none): the #GstCaps of the stream.
*/
GstCaps *
gst_player_stream_info_get_caps (const GstPlayerStreamInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
return info->caps;
}
/* Video information */
G_DEFINE_TYPE (GstPlayerVideoInfo, gst_player_video_info,
GST_TYPE_PLAYER_STREAM_INFO);
static void
gst_player_video_info_init (GstPlayerVideoInfo * info)
{
info->width = -1;
info->height = -1;
info->framerate_num = 0;
info->framerate_denom = 1;
info->par_num = 1;
info->par_denom = 1;
}
static void
gst_player_video_info_class_init (G_GNUC_UNUSED GstPlayerVideoInfoClass * klass)
{
/* nothing to do here */
}
/**
* gst_player_video_info_get_width:
* @info: a #GstPlayerVideoInfo
*
* Returns: the width of video in #GstPlayerVideoInfo.
*/
gint
gst_player_video_info_get_width (const GstPlayerVideoInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
return info->width;
}
/**
* gst_player_video_info_get_height:
* @info: a #GstPlayerVideoInfo
*
* Returns: the height of video in #GstPlayerVideoInfo.
*/
gint
gst_player_video_info_get_height (const GstPlayerVideoInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
return info->height;
}
/**
* gst_player_video_info_get_framerate_num:
* @info: a #GstPlayerVideoInfo
*
*/
void
gst_player_video_info_get_framerate (const GstPlayerVideoInfo * info,
gint * fps_n, gint * fps_d)
{
g_return_if_fail (GST_IS_PLAYER_VIDEO_INFO (info));
*fps_n = info->framerate_num;
*fps_d = info->framerate_denom;
}
/**
* gst_player_video_info_get_pixel_aspect_ratio:
* @info: a #GstPlayerVideoInfo
* @par_n: (out): numerator
* @par_d: (out): denominator
*
* Returns the pixel aspect ratio in @par_n and @par_d
*
*/
void
gst_player_video_info_get_pixel_aspect_ratio (const GstPlayerVideoInfo * info,
guint * par_n, guint * par_d)
{
g_return_if_fail (GST_IS_PLAYER_VIDEO_INFO (info));
*par_n = info->par_num;
*par_d = info->par_denom;
}
/**
* gst_player_video_info_get_bitrate:
* @info: a #GstPlayerVideoInfo
*
* Returns: the current bitrate of video in #GstPlayerVideoInfo.
*/
gint
gst_player_video_info_get_bitrate (const GstPlayerVideoInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
return info->bitrate;
}
/**
* gst_player_video_info_get_max_bitrate:
* @info: a #GstPlayerVideoInfo
*
* Returns: the maximum bitrate of video in #GstPlayerVideoInfo.
*/
gint
gst_player_video_info_get_max_bitrate (const GstPlayerVideoInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
return info->max_bitrate;
}
/* Audio information */
G_DEFINE_TYPE (GstPlayerAudioInfo, gst_player_audio_info,
GST_TYPE_PLAYER_STREAM_INFO);
static void
gst_player_audio_info_init (GstPlayerAudioInfo * info)
{
info->channels = 0;
info->sample_rate = 0;
info->bitrate = -1;
info->max_bitrate = -1;
}
static void
gst_player_audio_info_finalize (GObject * object)
{
GstPlayerAudioInfo *info = GST_PLAYER_AUDIO_INFO (object);
g_free (info->language);
G_OBJECT_CLASS (gst_player_audio_info_parent_class)->finalize (object);
}
static void
gst_player_audio_info_class_init (GstPlayerAudioInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_player_audio_info_finalize;
}
/**
* gst_player_audio_info_get_language:
* @info: a #GstPlayerAudioInfo
*
* Returns: the language of the stream, or NULL if unknown.
*/
const gchar *
gst_player_audio_info_get_language (const GstPlayerAudioInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), NULL);
return info->language;
}
/**
* gst_player_audio_info_get_channels:
* @info: a #GstPlayerAudioInfo
*
* Returns: the number of audio channels in #GstPlayerAudioInfo.
*/
gint
gst_player_audio_info_get_channels (const GstPlayerAudioInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), 0);
return info->channels;
}
/**
* gst_player_audio_info_get_sample_rate:
* @info: a #GstPlayerAudioInfo
*
* Returns: the audio sample rate in #GstPlayerAudioInfo.
*/
gint
gst_player_audio_info_get_sample_rate (const GstPlayerAudioInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), 0);
return info->sample_rate;
}
/**
* gst_player_audio_info_get_bitrate:
* @info: a #GstPlayerAudioInfo
*
* Returns: the audio bitrate in #GstPlayerAudioInfo.
*/
gint
gst_player_audio_info_get_bitrate (const GstPlayerAudioInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), -1);
return info->bitrate;
}
/**
* gst_player_audio_info_get_max_bitrate:
* @info: a #GstPlayerAudioInfo
*
* Returns: the audio maximum bitrate in #GstPlayerAudioInfo.
*/
gint
gst_player_audio_info_get_max_bitrate (const GstPlayerAudioInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), -1);
return info->max_bitrate;
}
/* Subtitle information */
G_DEFINE_TYPE (GstPlayerSubtitleInfo, gst_player_subtitle_info,
GST_TYPE_PLAYER_STREAM_INFO);
static void
gst_player_subtitle_info_init (G_GNUC_UNUSED GstPlayerSubtitleInfo * info)
{
/* nothing to do */
}
static void
gst_player_subtitle_info_finalize (GObject * object)
{
GstPlayerSubtitleInfo *info = GST_PLAYER_SUBTITLE_INFO (object);
g_free (info->language);
G_OBJECT_CLASS (gst_player_subtitle_info_parent_class)->finalize (object);
}
static void
gst_player_subtitle_info_class_init (GstPlayerSubtitleInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_player_subtitle_info_finalize;
}
/**
* gst_player_subtitle_info_get_language:
* @info: a #GstPlayerSubtitleInfo
*
* Returns: the language of the stream, or NULL if unknown.
*/
const gchar *
gst_player_subtitle_info_get_language (const GstPlayerSubtitleInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_SUBTITLE_INFO (info), NULL);
return info->language;
}
/* Global media information */
G_DEFINE_TYPE (GstPlayerMediaInfo, gst_player_media_info, G_TYPE_OBJECT);
static void
gst_player_media_info_init (GstPlayerMediaInfo * info)
{
info->duration = -1;
info->seekable = FALSE;
}
static void
gst_player_media_info_finalize (GObject * object)
{
GstPlayerMediaInfo *info = GST_PLAYER_MEDIA_INFO (object);
g_free (info->uri);
if (info->tags)
gst_tag_list_unref (info->tags);
g_free (info->title);
g_free (info->container);
if (info->image_sample)
gst_sample_unref (info->image_sample);
if (info->audio_stream_list)
g_list_free (info->audio_stream_list);
if (info->video_stream_list)
g_list_free (info->video_stream_list);
if (info->subtitle_stream_list)
g_list_free (info->subtitle_stream_list);
if (info->stream_list)
g_list_free_full (info->stream_list, g_object_unref);
G_OBJECT_CLASS (gst_player_media_info_parent_class)->finalize (object);
}
static void
gst_player_media_info_class_init (GstPlayerMediaInfoClass * klass)
{
GObjectClass *oclass = (GObjectClass *) klass;
oclass->finalize = gst_player_media_info_finalize;
}
static GstPlayerVideoInfo *
gst_player_video_info_new (void)
{
return g_object_new (GST_TYPE_PLAYER_VIDEO_INFO, NULL);
}
static GstPlayerAudioInfo *
gst_player_audio_info_new (void)
{
return g_object_new (GST_TYPE_PLAYER_AUDIO_INFO, NULL);
}
static GstPlayerSubtitleInfo *
gst_player_subtitle_info_new (void)
{
return g_object_new (GST_TYPE_PLAYER_SUBTITLE_INFO, NULL);
}
static GstPlayerStreamInfo *
gst_player_video_info_copy (GstPlayerVideoInfo * ref)
{
GstPlayerVideoInfo *ret;
ret = gst_player_video_info_new ();
ret->width = ref->width;
ret->height = ref->height;
ret->framerate_num = ref->framerate_num;
ret->framerate_denom = ref->framerate_denom;
ret->par_num = ref->par_num;
ret->par_denom = ref->par_denom;
ret->bitrate = ref->bitrate;
ret->max_bitrate = ref->max_bitrate;
return (GstPlayerStreamInfo *) ret;
}
static GstPlayerStreamInfo *
gst_player_audio_info_copy (GstPlayerAudioInfo * ref)
{
GstPlayerAudioInfo *ret;
ret = gst_player_audio_info_new ();
ret->sample_rate = ref->sample_rate;
ret->channels = ref->channels;
ret->bitrate = ref->bitrate;
ret->max_bitrate = ref->max_bitrate;
if (ref->language)
ret->language = g_strdup (ref->language);
return (GstPlayerStreamInfo *) ret;
}
static GstPlayerStreamInfo *
gst_player_subtitle_info_copy (GstPlayerSubtitleInfo * ref)
{
GstPlayerSubtitleInfo *ret;
ret = gst_player_subtitle_info_new ();
if (ref->language)
ret->language = g_strdup (ref->language);
return (GstPlayerStreamInfo *) ret;
}
GstPlayerStreamInfo *
gst_player_stream_info_copy (GstPlayerStreamInfo * ref)
{
GstPlayerStreamInfo *info = NULL;
if (!ref)
return NULL;
if (GST_IS_PLAYER_VIDEO_INFO (ref))
info = gst_player_video_info_copy ((GstPlayerVideoInfo *) ref);
else if (GST_IS_PLAYER_AUDIO_INFO (ref))
info = gst_player_audio_info_copy ((GstPlayerAudioInfo *) ref);
else
info = gst_player_subtitle_info_copy ((GstPlayerSubtitleInfo *) ref);
info->stream_index = ref->stream_index;
if (ref->tags)
info->tags = gst_tag_list_ref (ref->tags);
if (ref->caps)
info->caps = gst_caps_copy (ref->caps);
if (ref->codec)
info->codec = g_strdup (ref->codec);
return info;
}
GstPlayerMediaInfo *
gst_player_media_info_copy (GstPlayerMediaInfo * ref)
{
GList *l;
GstPlayerMediaInfo *info;
if (!ref)
return NULL;
info = gst_player_media_info_new (ref->uri);
info->duration = ref->duration;
info->seekable = ref->seekable;
if (ref->tags)
info->tags = gst_tag_list_ref (ref->tags);
if (ref->title)
info->title = g_strdup (ref->title);
if (ref->container)
info->container = g_strdup (ref->container);
if (ref->image_sample)
info->image_sample = gst_sample_ref (ref->image_sample);
for (l = ref->stream_list; l != NULL; l = l->next) {
GstPlayerStreamInfo *s;
s = gst_player_stream_info_copy ((GstPlayerStreamInfo *) l->data);
info->stream_list = g_list_append (info->stream_list, s);
if (GST_IS_PLAYER_AUDIO_INFO (s))
info->audio_stream_list = g_list_append (info->audio_stream_list, s);
else if (GST_IS_PLAYER_VIDEO_INFO (s))
info->video_stream_list = g_list_append (info->video_stream_list, s);
else
info->subtitle_stream_list =
g_list_append (info->subtitle_stream_list, s);
}
return info;
}
GstPlayerStreamInfo *
gst_player_stream_info_new (gint stream_index, GType type)
{
GstPlayerStreamInfo *info = NULL;
if (type == GST_TYPE_PLAYER_AUDIO_INFO)
info = (GstPlayerStreamInfo *) gst_player_audio_info_new ();
else if (type == GST_TYPE_PLAYER_VIDEO_INFO)
info = (GstPlayerStreamInfo *) gst_player_video_info_new ();
else
info = (GstPlayerStreamInfo *) gst_player_subtitle_info_new ();
info->stream_index = stream_index;
return info;
}
GstPlayerMediaInfo *
gst_player_media_info_new (const gchar * uri)
{
GstPlayerMediaInfo *info;
g_return_val_if_fail (uri != NULL, NULL);
info = g_object_new (GST_TYPE_PLAYER_MEDIA_INFO, NULL);
info->uri = g_strdup (uri);
return info;
}
/**
* gst_player_media_info_get_uri:
* @info: a #GstPlayerMediaInfo
*
* Returns: the URI associated with #GstPlayerMediaInfo.
*/
const gchar *
gst_player_media_info_get_uri (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->uri;
}
/**
* gst_player_media_info_is_seekable:
* @info: a #GstPlayerMediaInfo
*
* Returns: %TRUE if the media is seekable.
*/
gboolean
gst_player_media_info_is_seekable (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), FALSE);
return info->seekable;
}
/**
* gst_player_media_info_get_stream_list:
* @info: a #GstPlayerMediaInfo
*
* Returns: (transfer none) (element-type GstPlayerStreamInfo): A #GList of
* matching #GstPlayerStreamInfo.
*/
GList *
gst_player_media_info_get_stream_list (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->stream_list;
}
/**
* gst_player_get_video_streams:
* @info: a #GstPlayerMediaInfo
*
* Returns: (transfer none) (element-type GstPlayerVideoInfo): A #GList of
* matching #GstPlayerVideoInfo.
*/
GList *
gst_player_get_video_streams (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->video_stream_list;
}
/**
* gst_player_get_subtitle_streams:
* @info: a #GstPlayerMediaInfo
*
* Returns: (transfer none) (element-type GstPlayerSubtitleInfo): A #GList of
* matching #GstPlayerSubtitleInfo.
*/
GList *
gst_player_get_subtitle_streams (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->subtitle_stream_list;
}
/**
* gst_player_get_audio_streams:
* @info: a #GstPlayerMediaInfo
*
* Returns: (transfer none) (element-type GstPlayerAudioInfo): A #GList of
* matching #GstPlayerAudioInfo.
*/
GList *
gst_player_get_audio_streams (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->audio_stream_list;
}
/**
* gst_player_media_info_get_duration:
* @info: a #GstPlayerMediaInfo
*
* Returns: duration of the media.
*/
GstClockTime
gst_player_media_info_get_duration (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), -1);
return info->duration;
}
/**
* gst_player_media_info_get_tags:
* @info: a #GstPlayerMediaInfo
*
* Returns: (transfer none): the tags contained in media info.
*/
GstTagList *
gst_player_media_info_get_tags (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->tags;
}
/**
* gst_player_media_info_get_title:
* @info: a #GstPlayerMediaInfo
*
* Returns: the media title.
*/
const gchar *
gst_player_media_info_get_title (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->title;
}
/**
* gst_player_media_info_get_container_format:
* @info: a #GstPlayerMediaInfo
*
* Returns: the container format.
*/
const gchar *
gst_player_media_info_get_container_format (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->container;
}
/**
* gst_player_media_info_get_image_sample:
* @info: a #GstPlayerMediaInfo
*
* Function to get the image (or preview-image) stored in taglist.
* Application can use gst_sample_*_() API's to get caps, buffer etc.
*
* Returns: (transfer none): GstSample or NULL.
*/
GstSample *
gst_player_media_info_get_image_sample (const GstPlayerMediaInfo * info)
{
g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
return info->image_sample;
}

View file

@ -0,0 +1,192 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_MEDIA_INFO_H__
#define __GST_PLAYER_MEDIA_INFO_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_PLAYER_STREAM_INFO \
(gst_player_stream_info_get_type ())
#define GST_PLAYER_STREAM_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAYER_STREAM_INFO,GstPlayerStreamInfo))
#define GST_PLAYER_STREAM_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAYER_STREAM_INFO,GstPlayerStreamInfo))
#define GST_IS_PLAYER_STREAM_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYER_STREAM_INFO))
#define GST_IS_PLAYER_STREAM_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAYER_STREAM_INFO))
/**
* GstPlayerStreamInfo:
*
* Base structure for information concering a media stream. Depending on
* the stream type, one can find more media-specific information in
* #GstPlayerVideoInfo, #GstPlayerAudioInfo, #GstPlayerSubtitleInfo.
*/
typedef struct _GstPlayerStreamInfo GstPlayerStreamInfo;
typedef struct _GstPlayerStreamInfoClass GstPlayerStreamInfoClass;
GType gst_player_stream_info_get_type (void);
gint gst_player_stream_info_get_index
(const GstPlayerStreamInfo *info);
const gchar* gst_player_stream_info_get_stream_type
(const GstPlayerStreamInfo *info);
GstTagList* gst_player_stream_info_get_tags
(const GstPlayerStreamInfo *info);
GstCaps* gst_player_stream_info_get_caps
(const GstPlayerStreamInfo *info);
const gchar* gst_player_stream_info_get_codec
(const GstPlayerStreamInfo *info);
#define GST_TYPE_PLAYER_VIDEO_INFO \
(gst_player_video_info_get_type ())
#define GST_PLAYER_VIDEO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAYER_VIDEO_INFO, GstPlayerVideoInfo))
#define GST_PLAYER_VIDEO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((obj),GST_TYPE_PLAYER_VIDEO_INFO, GstPlayerVideoInfoClass))
#define GST_IS_PLAYER_VIDEO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYER_VIDEO_INFO))
#define GST_IS_PLAYER_VIDEO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((obj),GST_TYPE_PLAYER_VIDEO_INFO))
/**
* GstPlayerVideoInfo:
*
* #GstPlayerStreamInfo specific to video streams.
*/
typedef struct _GstPlayerVideoInfo GstPlayerVideoInfo;
typedef struct _GstPlayerVideoInfoClass GstPlayerVideoInfoClass;
GType gst_player_video_info_get_type (void);
gint gst_player_video_info_get_bitrate
(const GstPlayerVideoInfo* info);
gint gst_player_video_info_get_max_bitrate
(const GstPlayerVideoInfo* info);
gint gst_player_video_info_get_width
(const GstPlayerVideoInfo* info);
gint gst_player_video_info_get_height
(const GstPlayerVideoInfo* info);
void gst_player_video_info_get_framerate
(const GstPlayerVideoInfo* info, gint *fps_n, gint *fps_d);
void gst_player_video_info_get_pixel_aspect_ratio
(const GstPlayerVideoInfo* info, guint *par_n, guint *par_d);
#define GST_TYPE_PLAYER_AUDIO_INFO \
(gst_player_audio_info_get_type ())
#define GST_PLAYER_AUDIO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAYER_AUDIO_INFO, GstPlayerAudioInfo))
#define GST_PLAYER_AUDIO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAYER_AUDIO_INFO, GstPlayerAudioInfoClass))
#define GST_IS_PLAYER_AUDIO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYER_AUDIO_INFO))
#define GST_IS_PLAYER_AUDIO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAYER_AUDIO_INFO))
/**
* GstPlayerAudioInfo:
*
* #GstPlayerStreamInfo specific to audio streams.
*/
typedef struct _GstPlayerAudioInfo GstPlayerAudioInfo;
typedef struct _GstPlayerAudioInfoClass GstPlayerAudioInfoClass;
GType gst_player_audio_info_get_type (void);
gint gst_player_audio_info_get_channels
(const GstPlayerAudioInfo* info);
gint gst_player_audio_info_get_sample_rate
(const GstPlayerAudioInfo* info);
gint gst_player_audio_info_get_bitrate
(const GstPlayerAudioInfo* info);
gint gst_player_audio_info_get_max_bitrate
(const GstPlayerAudioInfo* info);
const gchar* gst_player_audio_info_get_language
(const GstPlayerAudioInfo* info);
#define GST_TYPE_PLAYER_SUBTITLE_INFO \
(gst_player_subtitle_info_get_type ())
#define GST_PLAYER_SUBTITLE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAYER_SUBTITLE_INFO, GstPlayerSubtitleInfo))
#define GST_PLAYER_SUBTITLE_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAYER_SUBTITLE_INFO,GstPlayerSubtitleInfoClass))
#define GST_IS_PLAYER_SUBTITLE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYER_SUBTITLE_INFO))
#define GST_IS_PLAYER_SUBTITLE_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAYER_SUBTITLE_INFO))
/**
* GstPlayerSubtitleInfo:
*
* #GstPlayerStreamInfo specific to subtitle streams.
*/
typedef struct _GstPlayerSubtitleInfo GstPlayerSubtitleInfo;
typedef struct _GstPlayerSubtitleInfoClass GstPlayerSubtitleInfoClass;
GType gst_player_subtitle_info_get_type (void);
const gchar* gst_player_subtitle_info_get_language
(const GstPlayerSubtitleInfo* info);
#define GST_TYPE_PLAYER_MEDIA_INFO \
(gst_player_media_info_get_type())
#define GST_PLAYER_MEDIA_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PLAYER_MEDIA_INFO,GstPlayerMediaInfo))
#define GST_PLAYER_MEDIA_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PLAYER_MEDIA_INFO,GstPlayerMediaInfoClass))
#define GST_IS_PLAYER_MEDIA_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PLAYER_MEDIA_INFO))
#define GST_IS_PLAYER_MEDIA_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PLAYER_MEDIA_INFO))
/**
* GstPlayerMediaInfo:
*
* Structure containing the media information of a URI.
*/
typedef struct _GstPlayerMediaInfo GstPlayerMediaInfo;
typedef struct _GstPlayerMediaInfoClass GstPlayerMediaInfoClass;
GType gst_player_media_info_get_type (void);
const gchar* gst_player_media_info_get_uri
(const GstPlayerMediaInfo *info);
gboolean gst_player_media_info_is_seekable
(const GstPlayerMediaInfo *info);
GstClockTime gst_player_media_info_get_duration
(const GstPlayerMediaInfo *info);
GList* gst_player_media_info_get_stream_list
(const GstPlayerMediaInfo *info);
GList* gst_player_get_video_streams
(const GstPlayerMediaInfo *info);
GList* gst_player_get_audio_streams
(const GstPlayerMediaInfo *info);
GList* gst_player_get_subtitle_streams
(const GstPlayerMediaInfo *info);
GstTagList* gst_player_media_info_get_tags
(const GstPlayerMediaInfo *info);
const gchar* gst_player_media_info_get_title
(const GstPlayerMediaInfo *info);
const gchar* gst_player_media_info_get_container_format
(const GstPlayerMediaInfo *info);
GstSample* gst_player_media_info_get_image_sample
(const GstPlayerMediaInfo *info);
G_END_DECLS
#endif /* __GST_PLAYER_MEDIA_INFO_H */

View file

@ -0,0 +1,34 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_SIGNAL_DISPATCHER_PRIVATE_H__
#define __GST_PLAYER_SIGNAL_DISPATCHER_PRIVATE_H__
#include <gst/player/gstplayer-signal-dispatcher.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL void gst_player_signal_dispatcher_dispatch (GstPlayerSignalDispatcher * self,
GstPlayer * player, GstPlayerSignalDispatcherFunc emitter, gpointer data,
GDestroyNotify destroy);
G_END_DECLS
#endif /* __GST_PLAYER_SIGNAL_DISPATCHER_PRIVATE_H__ */

View file

@ -0,0 +1,57 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-signal-dispatcher.h"
#include "gstplayer-signal-dispatcher-private.h"
G_DEFINE_INTERFACE (GstPlayerSignalDispatcher, gst_player_signal_dispatcher,
G_TYPE_OBJECT);
static void
gst_player_signal_dispatcher_default_init (G_GNUC_UNUSED
GstPlayerSignalDispatcherInterface * iface)
{
}
void
gst_player_signal_dispatcher_dispatch (GstPlayerSignalDispatcher * self,
GstPlayer * player, GstPlayerSignalDispatcherFunc emitter, gpointer data,
GDestroyNotify destroy)
{
GstPlayerSignalDispatcherInterface *iface;
if (!self) {
emitter (data);
if (destroy)
destroy (data);
return;
}
g_return_if_fail (GST_IS_PLAYER_SIGNAL_DISPATCHER (self));
iface = GST_PLAYER_SIGNAL_DISPATCHER_GET_INTERFACE (self);
g_return_if_fail (iface->dispatch != NULL);
iface->dispatch (self, player, emitter, data, destroy);
}

View file

@ -0,0 +1,53 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_SIGNAL_DISPATCHER_H__
#define __GST_PLAYER_SIGNAL_DISPATCHER_H__
#include <gst/gst.h>
#include <gst/player/gstplayer-types.h>
G_BEGIN_DECLS
typedef struct _GstPlayerSignalDispatcher GstPlayerSignalDispatcher;
typedef struct _GstPlayerSignalDispatcherInterface GstPlayerSignalDispatcherInterface;
#define GST_TYPE_PLAYER_SIGNAL_DISPATCHER (gst_player_signal_dispatcher_get_type ())
#define GST_PLAYER_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_SIGNAL_DISPATCHER, GstPlayerSignalDispatcher))
#define GST_IS_PLAYER_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_SIGNAL_DISPATCHER))
#define GST_PLAYER_SIGNAL_DISPATCHER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_PLAYER_SIGNAL_DISPATCHER, GstPlayerSignalDispatcherInterface))
typedef void (*GstPlayerSignalDispatcherFunc) (gpointer data);
struct _GstPlayerSignalDispatcherInterface {
GTypeInterface parent_iface;
void (*dispatch) (GstPlayerSignalDispatcher * self,
GstPlayer * player,
GstPlayerSignalDispatcherFunc emitter,
gpointer data,
GDestroyNotify destroy);
};
GType gst_player_signal_dispatcher_get_type (void);
G_END_DECLS
#endif /* __GST_PLAYER_SIGNAL_DISPATCHER_H__ */

View file

@ -0,0 +1,35 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_TYPES_H__
#define __GST_PLAYER_TYPES_H__
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstPlayer GstPlayer;
typedef struct _GstPlayerClass GstPlayerClass;
G_END_DECLS
#endif /* __GST_PLAYER_TYPES_H__ */

View file

@ -0,0 +1,224 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstplayer-videooverlayvideorenderer
* @short_description: Player Video Overlay Video Renderer
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-video-overlay-video-renderer.h"
#include "gstplayer.h"
#include <gst/video/video.h>
struct _GstPlayerVideoOverlayVideoRenderer
{
GObject parent;
GstVideoOverlay *video_overlay;
gpointer window_handle;
};
struct _GstPlayerVideoOverlayVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_player_video_overlay_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface);
enum
{
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_0,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstPlayerVideoOverlayVideoRenderer,
gst_player_video_overlay_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_PLAYER_VIDEO_RENDERER,
gst_player_video_overlay_video_renderer_interface_init));
static GParamSpec
* video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_player_video_overlay_video_renderer_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstPlayerVideoOverlayVideoRenderer *self =
GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
switch (prop_id) {
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE:
self->window_handle = g_value_get_pointer (value);
if (self->video_overlay)
gst_video_overlay_set_window_handle (self->video_overlay,
(guintptr) self->window_handle);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_video_overlay_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstPlayerVideoOverlayVideoRenderer *self =
GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
switch (prop_id) {
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE:
g_value_set_pointer (value, self->window_handle);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_player_video_overlay_video_renderer_finalize (GObject * object)
{
GstPlayerVideoOverlayVideoRenderer *self =
GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
if (self->video_overlay)
gst_object_unref (self->video_overlay);
G_OBJECT_CLASS
(gst_player_video_overlay_video_renderer_parent_class)->finalize (object);
}
static void
gst_player_video_overlay_video_renderer_class_init
(GstPlayerVideoOverlayVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property =
gst_player_video_overlay_video_renderer_set_property;
gobject_class->get_property =
gst_player_video_overlay_video_renderer_get_property;
gobject_class->finalize = gst_player_video_overlay_video_renderer_finalize;
video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE] =
g_param_spec_pointer ("window-handle", "Window Handle",
"Window handle to embed the video into",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST,
video_overlay_video_renderer_param_specs);
}
static void
gst_player_video_overlay_video_renderer_init
(G_GNUC_UNUSED GstPlayerVideoOverlayVideoRenderer * self)
{
}
static GstElement *gst_player_video_overlay_video_renderer_create_video_sink
(GstPlayerVideoRenderer * iface, GstPlayer * player)
{
GstElement *video_overlay;
GstPlayerVideoOverlayVideoRenderer *self =
GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (iface);
if (self->video_overlay)
gst_object_unref (self->video_overlay);
video_overlay = gst_player_get_pipeline (player);
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY (video_overlay), NULL);
self->video_overlay = GST_VIDEO_OVERLAY (video_overlay);
gst_video_overlay_set_window_handle (self->video_overlay,
(guintptr) self->window_handle);
return NULL;
}
static void
gst_player_video_overlay_video_renderer_interface_init
(GstPlayerVideoRendererInterface * iface)
{
iface->create_video_sink =
gst_player_video_overlay_video_renderer_create_video_sink;
}
/**
* gst_player_video_overlay_video_renderer_new:
* @window_handle: (allow-none): Window handle to use or %NULL
*
* Returns: (transfer full):
*/
GstPlayerVideoRenderer *
gst_player_video_overlay_video_renderer_new (gpointer window_handle)
{
return g_object_new (GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER,
"window-handle", window_handle, NULL);
}
/**
* gst_player_video_overlay_video_renderer_set_window_handle:
* @self: #GstPlayerVideoRenderer instance
* @window_handle: handle referencing to the platform specific window
*
* Sets the platform specific window handle into which the video
* should be rendered
**/
void gst_player_video_overlay_video_renderer_set_window_handle
(GstPlayerVideoOverlayVideoRenderer * self, gpointer window_handle)
{
g_return_if_fail (GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (self));
g_object_set (self, "window-handle", window_handle, NULL);
}
/**
* gst_player_video_overlay_video_renderer_get_window_handle:
* @self: #GstPlayerVideoRenderer instance
*
* Returns: (transfer none): The currently set, platform specific window
* handle
*/
gpointer
gst_player_video_overlay_video_renderer_get_window_handle
(GstPlayerVideoOverlayVideoRenderer * self) {
gpointer window_handle;
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (self),
NULL);
g_object_get (self, "window-handle", &window_handle, NULL);
return window_handle;
}

View file

@ -0,0 +1,49 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_H__
#define __GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_H__
#include <gst/player/gstplayer-types.h>
#include <gst/player/gstplayer-video-renderer.h>
G_BEGIN_DECLS
typedef struct _GstPlayerVideoOverlayVideoRenderer
GstPlayerVideoOverlayVideoRenderer;
typedef struct _GstPlayerVideoOverlayVideoRendererClass
GstPlayerVideoOverlayVideoRendererClass;
#define GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER (gst_player_video_overlay_video_renderer_get_type ())
#define GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER))
#define GST_IS_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER))
#define GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER, GstPlayerVideoOverlayVideoRendererClass))
#define GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER, GstPlayerVideoOverlayVideoRenderer))
#define GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER, GstPlayerVideoOverlayVideoRendererClass))
#define GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_CAST(obj) ((GstPlayerVideoOverlayVideoRenderer*)(obj))
GType gst_player_video_overlay_video_renderer_get_type (void);
GstPlayerVideoRenderer * gst_player_video_overlay_video_renderer_new (gpointer window_handle);
void gst_player_video_overlay_video_renderer_set_window_handle (GstPlayerVideoOverlayVideoRenderer * self, gpointer window_handle);
gpointer gst_player_video_overlay_video_renderer_get_window_handle (GstPlayerVideoOverlayVideoRenderer * self);
G_END_DECLS
#endif /* __GST_PLAYER_VIDEO_OVERLAY_VIDEO_RENDERER_H__ */

View file

@ -0,0 +1,33 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_VIDEO_RENDERER_PRIVATE_H__
#define __GST_PLAYER_VIDEO_RENDERER_PRIVATE_H__
#include <gst/player/gstplayer-video-renderer.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL GstElement * gst_player_video_renderer_create_video_sink (GstPlayerVideoRenderer *
self, GstPlayer * player);
G_END_DECLS
#endif /* __GST_PLAYER_VIDEO_RENDERER_PRIVATE_H__ */

View file

@ -0,0 +1,49 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-video-renderer.h"
#include "gstplayer-video-renderer-private.h"
G_DEFINE_INTERFACE (GstPlayerVideoRenderer, gst_player_video_renderer,
G_TYPE_OBJECT);
static void
gst_player_video_renderer_default_init (G_GNUC_UNUSED
GstPlayerVideoRendererInterface * iface)
{
}
GstElement *
gst_player_video_renderer_create_video_sink (GstPlayerVideoRenderer * self,
GstPlayer * player)
{
GstPlayerVideoRendererInterface *iface;
g_return_val_if_fail (GST_IS_PLAYER_VIDEO_RENDERER (self), NULL);
iface = GST_PLAYER_VIDEO_RENDERER_GET_INTERFACE (self);
g_return_val_if_fail (iface->create_video_sink != NULL, NULL);
return iface->create_video_sink (self, player);
}

View file

@ -0,0 +1,47 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_VIDEO_RENDERER_H__
#define __GST_PLAYER_VIDEO_RENDERER_H__
#include <gst/gst.h>
#include <gst/player/gstplayer-types.h>
G_BEGIN_DECLS
typedef struct _GstPlayerVideoRenderer GstPlayerVideoRenderer;
typedef struct _GstPlayerVideoRendererInterface GstPlayerVideoRendererInterface;
#define GST_TYPE_PLAYER_VIDEO_RENDERER (gst_player_video_renderer_get_type ())
#define GST_PLAYER_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER_VIDEO_RENDERER, GstPlayerVideoRenderer))
#define GST_IS_PLAYER_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER_VIDEO_RENDERER))
#define GST_PLAYER_VIDEO_RENDERER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_PLAYER_VIDEO_RENDERER, GstPlayerVideoRendererInterface))
struct _GstPlayerVideoRendererInterface {
GTypeInterface parent_iface;
GstElement * (*create_video_sink) (GstPlayerVideoRenderer * self, GstPlayer * player);
};
GType gst_player_video_renderer_get_type (void);
G_END_DECLS
#endif /* __GST_PLAYER_VIDEO_RENDERER_H__ */

View file

@ -0,0 +1,178 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstplayer-visualization
* @short_description: Player Visualization
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstplayer-visualization.h"
#include <string.h>
static GMutex vis_lock;
static GQueue vis_list = G_QUEUE_INIT;
static guint32 vis_cookie;
G_DEFINE_BOXED_TYPE (GstPlayerVisualization, gst_player_visualization,
(GBoxedCopyFunc) gst_player_visualization_copy,
(GBoxedFreeFunc) gst_player_visualization_free);
/**
* gst_player_visualization_free:
* @vis: #GstPlayerVisualization instance
*
* Frees a #GstPlayerVisualization.
*/
void
gst_player_visualization_free (GstPlayerVisualization * vis)
{
g_return_if_fail (vis != NULL);
g_free (vis->name);
g_free (vis->description);
g_free (vis);
}
/**
* gst_player_visualization_copy:
* @vis: #GstPlayerVisualization instance
*
* Makes a copy of the #GstPlayerVisualization. The result must be
* freed using gst_player_visualization_free().
*
* Returns: (transfer full): an allocated copy of @vis.
*/
GstPlayerVisualization *
gst_player_visualization_copy (const GstPlayerVisualization * vis)
{
GstPlayerVisualization *ret;
g_return_val_if_fail (vis != NULL, NULL);
ret = g_new0 (GstPlayerVisualization, 1);
ret->name = vis->name ? g_strdup (vis->name) : NULL;
ret->description = vis->description ? g_strdup (vis->description) : NULL;
return ret;
}
/**
* gst_player_visualizations_free:
* @viss: a %NULL terminated array of #GstPlayerVisualization to free
*
* Frees a %NULL terminated array of #GstPlayerVisualization.
*/
void
gst_player_visualizations_free (GstPlayerVisualization ** viss)
{
GstPlayerVisualization **p;
g_return_if_fail (viss != NULL);
p = viss;
while (*p) {
g_free ((*p)->name);
g_free ((*p)->description);
g_free (*p);
p++;
}
g_free (viss);
}
static void
gst_player_update_visualization_list (void)
{
GList *features;
GList *l;
guint32 cookie;
GstPlayerVisualization *vis;
g_mutex_lock (&vis_lock);
/* check if we need to update the list */
cookie = gst_registry_get_feature_list_cookie (gst_registry_get ());
if (vis_cookie == cookie) {
g_mutex_unlock (&vis_lock);
return;
}
/* if update is needed then first free the existing list */
while ((vis = g_queue_pop_head (&vis_list)))
gst_player_visualization_free (vis);
features = gst_registry_get_feature_list (gst_registry_get (),
GST_TYPE_ELEMENT_FACTORY);
for (l = features; l; l = l->next) {
GstPluginFeature *feature = l->data;
const gchar *klass;
klass = gst_element_factory_get_metadata (GST_ELEMENT_FACTORY (feature),
GST_ELEMENT_METADATA_KLASS);
if (strstr (klass, "Visualization")) {
vis = g_new0 (GstPlayerVisualization, 1);
vis->name = g_strdup (gst_plugin_feature_get_name (feature));
vis->description =
g_strdup (gst_element_factory_get_metadata (GST_ELEMENT_FACTORY
(feature), GST_ELEMENT_METADATA_DESCRIPTION));
g_queue_push_tail (&vis_list, vis);
}
}
gst_plugin_feature_list_free (features);
vis_cookie = cookie;
g_mutex_unlock (&vis_lock);
}
/**
* gst_player_visualizations_get:
*
* Returns: (transfer full) (array zero-terminated=1) (element-type GstPlayerVisualization):
* a %NULL terminated array containing all available
* visualizations. Use gst_player_visualizations_free() after
* usage.
*/
GstPlayerVisualization **
gst_player_visualizations_get (void)
{
gint i = 0;
GList *l;
GstPlayerVisualization **ret;
gst_player_update_visualization_list ();
g_mutex_lock (&vis_lock);
ret = g_new0 (GstPlayerVisualization *, g_queue_get_length (&vis_list) + 1);
for (l = vis_list.head; l; l = l->next)
ret[i++] = gst_player_visualization_copy (l->data);
g_mutex_unlock (&vis_lock);
return ret;
}

View file

@ -0,0 +1,52 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_VISUALIZATION_H__
#define __GST_PLAYER_VISUALIZATION_H__
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstPlayerVisualization GstPlayerVisualization;
/**
* GstPlayerVisualization:
* @name: name of the visualization.
* @description: description of the visualization.
*
* A #GstPlayerVisualization descriptor.
*/
struct _GstPlayerVisualization {
gchar *name;
gchar *description;
};
GType gst_player_visualization_get_type (void);
GstPlayerVisualization * gst_player_visualization_copy (const GstPlayerVisualization *vis);
void gst_player_visualization_free (GstPlayerVisualization *vis);
GstPlayerVisualization ** gst_player_visualizations_get (void);
void gst_player_visualizations_free (GstPlayerVisualization **viss);
G_END_DECLS
#endif /* __GST_PLAYER_VISUALIZATION_H__ */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,184 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_PLAYER_H__
#define __GST_PLAYER_H__
#include <gst/gst.h>
#include <gst/player/gstplayer-types.h>
#include <gst/player/gstplayer-signal-dispatcher.h>
#include <gst/player/gstplayer-video-renderer.h>
#include <gst/player/gstplayer-media-info.h>
G_BEGIN_DECLS
GType gst_player_state_get_type (void);
#define GST_TYPE_PLAYER_STATE (gst_player_state_get_type ())
/**
* GstPlayerState:
* @GST_PLAYER_STATE_STOPPED: the player is stopped.
* @GST_PLAYER_STATE_BUFFERING: the player is buffering.
* @GST_PLAYER_STATE_PAUSED: the player is paused.
* @GST_PLAYER_STATE_PLAYING: the player is currently playing a
* stream.
*/
typedef enum
{
GST_PLAYER_STATE_STOPPED,
GST_PLAYER_STATE_BUFFERING,
GST_PLAYER_STATE_PAUSED,
GST_PLAYER_STATE_PLAYING
} GstPlayerState;
const gchar *gst_player_state_get_name (GstPlayerState state);
GQuark gst_player_error_quark (void);
GType gst_player_error_get_type (void);
#define GST_PLAYER_ERROR (gst_player_error_quark ())
#define GST_TYPE_PLAYER_ERROR (gst_player_error_get_type ())
/**
* GstPlayerError:
* @GST_PLAYER_ERROR_FAILED: generic error.
*/
typedef enum {
GST_PLAYER_ERROR_FAILED = 0
} GstPlayerError;
const gchar *gst_player_error_get_name (GstPlayerError error);
GType gst_player_color_balance_type_get_type (void);
#define GST_TYPE_PLAYER_COLOR_BALANCE_TYPE (gst_player_color_balance_type_get_type ())
/**
* GstPlayerColorBalanceType:
* @GST_PLAYER_COLOR_BALANCE_BRIGHTNESS: brightness or black level.
* @GST_PLAYER_COLOR_BALANCE_CONTRAST: contrast or luma gain.
* @GST_PLAYER_COLOR_BALANCE_SATURATION: color saturation or chroma
* gain.
* @GST_PLAYER_COLOR_BALANCE_HUE: hue or color balance.
*/
typedef enum
{
GST_PLAYER_COLOR_BALANCE_BRIGHTNESS,
GST_PLAYER_COLOR_BALANCE_CONTRAST,
GST_PLAYER_COLOR_BALANCE_SATURATION,
GST_PLAYER_COLOR_BALANCE_HUE,
} GstPlayerColorBalanceType;
const gchar *gst_player_color_balance_type_get_name (GstPlayerColorBalanceType type);
#define GST_TYPE_PLAYER (gst_player_get_type ())
#define GST_IS_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLAYER))
#define GST_IS_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLAYER))
#define GST_PLAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLAYER, GstPlayerClass))
#define GST_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAYER, GstPlayer))
#define GST_PLAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAYER, GstPlayerClass))
#define GST_PLAYER_CAST(obj) ((GstPlayer*)(obj))
GType gst_player_get_type (void);
GstPlayer * gst_player_new (void);
GstPlayer * gst_player_new_full (GstPlayerVideoRenderer * video_renderer, GstPlayerSignalDispatcher * signal_dispatcher);
void gst_player_play (GstPlayer * player);
void gst_player_pause (GstPlayer * player);
void gst_player_stop (GstPlayer * player);
void gst_player_seek (GstPlayer * player,
GstClockTime position);
void gst_player_set_rate (GstPlayer * player,
gdouble rate);
gdouble gst_player_get_rate (GstPlayer * player);
void gst_player_set_position_update_interval (GstPlayer * player,
guint interval);
guint gst_player_get_position_update_interval (GstPlayer * player);
gchar * gst_player_get_uri (GstPlayer * player);
void gst_player_set_uri (GstPlayer * player,
const gchar * uri);
GstClockTime gst_player_get_position (GstPlayer * player);
GstClockTime gst_player_get_duration (GstPlayer * player);
gdouble gst_player_get_volume (GstPlayer * player);
void gst_player_set_volume (GstPlayer * player,
gdouble val);
gboolean gst_player_get_mute (GstPlayer * player);
void gst_player_set_mute (GstPlayer * player,
gboolean val);
GstElement * gst_player_get_pipeline (GstPlayer * player);
void gst_player_set_video_track_enabled (GstPlayer * player,
gboolean enabled);
void gst_player_set_audio_track_enabled (GstPlayer * player,
gboolean enabled);
void gst_player_set_subtitle_track_enabled (GstPlayer * player,
gboolean enabled);
gboolean gst_player_set_audio_track (GstPlayer *player,
gint stream_index);
gboolean gst_player_set_video_track (GstPlayer *player,
gint stream_index);
gboolean gst_player_set_subtitle_track (GstPlayer *player,
gint stream_index);
GstPlayerMediaInfo * gst_player_get_media_info (GstPlayer * player);
GstPlayerAudioInfo * gst_player_get_current_audio_track
(GstPlayer * player);
GstPlayerVideoInfo * gst_player_get_current_video_track
(GstPlayer * player);
GstPlayerSubtitleInfo * gst_player_get_current_subtitle_track
(GstPlayer * player);
gboolean gst_player_set_subtitle_uri (GstPlayer * player,
const gchar *uri);
gchar * gst_player_get_subtitle_uri (GstPlayer * player);
gboolean gst_player_set_visualization (GstPlayer * player,
const gchar *name);
void gst_player_set_visualization_enabled (GstPlayer * player,
gboolean enabled);
gchar * gst_player_get_current_visualization (GstPlayer * player);
gboolean gst_player_has_color_balance (GstPlayer * player);
void gst_player_set_color_balance (GstPlayer * player,
GstPlayerColorBalanceType type,
gdouble value);
gdouble gst_player_get_color_balance (GstPlayer * player,
GstPlayerColorBalanceType type);
G_END_DECLS
#endif /* __GST_PLAYER_H__ */

View file

@ -0,0 +1,30 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PLAYER_H__
#define __PLAYER_H__
#include <gst/player/gstplayer.h>
#include <gst/player/gstplayer-media-info.h>
#include <gst/player/gstplayer-g-main-context-signal-dispatcher.h>
#include <gst/player/gstplayer-video-overlay-video-renderer.h>
#include <gst/player/gstplayer-visualization.h>
#endif /* __PLAYER_H__ */

View file

@ -0,0 +1,92 @@
EXPORTS
gst_player_audio_info_get_bitrate
gst_player_audio_info_get_channels
gst_player_audio_info_get_language
gst_player_audio_info_get_max_bitrate
gst_player_audio_info_get_sample_rate
gst_player_audio_info_get_type
gst_player_color_balance_type_get_name
gst_player_color_balance_type_get_type
gst_player_error_get_name
gst_player_error_get_type
gst_player_error_quark
gst_player_g_main_context_signal_dispatcher_get_type
gst_player_g_main_context_signal_dispatcher_new
gst_player_get_audio_streams
gst_player_get_color_balance
gst_player_get_current_audio_track
gst_player_get_current_subtitle_track
gst_player_get_current_video_track
gst_player_get_current_visualization
gst_player_get_duration
gst_player_get_media_info
gst_player_get_mute
gst_player_get_pipeline
gst_player_get_position
gst_player_get_position_update_interval
gst_player_get_rate
gst_player_get_subtitle_streams
gst_player_get_subtitle_uri
gst_player_get_type
gst_player_get_uri
gst_player_get_video_streams
gst_player_get_volume
gst_player_has_color_balance
gst_player_media_info_get_container_format
gst_player_media_info_get_duration
gst_player_media_info_get_image_sample
gst_player_media_info_get_stream_list
gst_player_media_info_get_tags
gst_player_media_info_get_title
gst_player_media_info_get_type
gst_player_media_info_get_uri
gst_player_media_info_is_seekable
gst_player_new
gst_player_new_full
gst_player_pause
gst_player_play
gst_player_seek
gst_player_set_audio_track
gst_player_set_audio_track_enabled
gst_player_set_color_balance
gst_player_set_mute
gst_player_set_position_update_interval
gst_player_set_rate
gst_player_set_subtitle_track
gst_player_set_subtitle_track_enabled
gst_player_set_subtitle_uri
gst_player_set_uri
gst_player_set_video_track
gst_player_set_video_track_enabled
gst_player_set_visualization
gst_player_set_visualization_enabled
gst_player_set_volume
gst_player_signal_dispatcher_get_type
gst_player_state_get_name
gst_player_state_get_type
gst_player_stop
gst_player_stream_info_get_caps
gst_player_stream_info_get_codec
gst_player_stream_info_get_index
gst_player_stream_info_get_stream_type
gst_player_stream_info_get_tags
gst_player_stream_info_get_type
gst_player_subtitle_info_get_language
gst_player_subtitle_info_get_type
gst_player_video_info_get_bitrate
gst_player_video_info_get_framerate
gst_player_video_info_get_height
gst_player_video_info_get_max_bitrate
gst_player_video_info_get_pixel_aspect_ratio
gst_player_video_info_get_type
gst_player_video_info_get_width
gst_player_video_overlay_video_renderer_get_type
gst_player_video_overlay_video_renderer_get_window_handle
gst_player_video_overlay_video_renderer_new
gst_player_video_overlay_video_renderer_set_window_handle
gst_player_video_renderer_get_type
gst_player_visualization_copy
gst_player_visualization_free
gst_player_visualization_get_type
gst_player_visualizations_free
gst_player_visualizations_get