+#include <stdio.h>\r
#include <gst/gst.h>\r
\r
/* Structure to contain all our information, so we can pass it around */\r
typedef struct _CustomData {\r
- GstElement *playbin2; /* Our one and only element */\r
+ GstElement *playbin; /* Our one and only element */\r
\r
gint n_video; /* Number of embedded video streams */\r
gint n_audio; /* Number of embedded audio streams */\r
GMainLoop *main_loop; /* GLib's Main Loop */\r
} CustomData;\r
\r
-/* playbin2 flags */\r
+/* playbin flags */\r
typedef enum {\r
GST_PLAY_FLAG_VIDEO = (1 << 0), /* We want video output */\r
GST_PLAY_FLAG_AUDIO = (1 << 1), /* We want audio output */\r
gst_init (&argc, &argv);\r
\r
/* Create the elements */\r
- data.playbin2 = gst_element_factory_make ("playbin2", "playbin2");\r
+ data.playbin = gst_element_factory_make ("playbin", "playbin");\r
\r
- if (!data.playbin2) {\r
+ if (!data.playbin) {\r
g_printerr ("Not all elements could be created.\n");\r
return -1;\r
}\r
\r
/* Set the URI to play */\r
- g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_cropped_multilingual.webm", NULL);\r
+ g_object_set (data.playbin, "uri", "http://docs.gstreamer.com/media/sintel_cropped_multilingual.webm", NULL);\r
\r
/* Set flags to show Audio and Video but ignore Subtitles */\r
- g_object_get (data.playbin2, "flags", &flags, NULL);\r
+ g_object_get (data.playbin, "flags", &flags, NULL);\r
flags |= GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO;\r
flags &= ~GST_PLAY_FLAG_TEXT;\r
- g_object_set (data.playbin2, "flags", flags, NULL);\r
+ g_object_set (data.playbin, "flags", flags, NULL);\r
\r
- /* Set connection speed. This will affect some internal decisions of playbin2 */\r
- g_object_set (data.playbin2, "connection-speed", 56, NULL);\r
+ /* Set connection speed. This will affect some internal decisions of playbin */\r
+ g_object_set (data.playbin, "connection-speed", 56, NULL);\r
\r
/* Add a bus watch, so we get notified when a message arrives */\r
- bus = gst_element_get_bus (data.playbin2);\r
+ bus = gst_element_get_bus (data.playbin);\r
gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data);\r
\r
/* Add a keyboard watch so we get notified of keystrokes */\r
-#ifdef _WIN32\r
+#ifdef G_OS_WIN32\r
io_stdin = g_io_channel_win32_new_fd (fileno (stdin));\r
#else\r
io_stdin = g_io_channel_unix_new (fileno (stdin));\r
g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc)handle_keyboard, &data);\r
\r
/* Start playing */\r
- ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING);\r
+ ret = gst_element_set_state (data.playbin, GST_STATE_PLAYING);\r
if (ret == GST_STATE_CHANGE_FAILURE) {\r
g_printerr ("Unable to set the pipeline to the playing state.\n");\r
- gst_object_unref (data.playbin2);\r
+ gst_object_unref (data.playbin);\r
return -1;\r
}\r
\r
g_main_loop_unref (data.main_loop);\r
g_io_channel_unref (io_stdin);\r
gst_object_unref (bus);\r
- gst_element_set_state (data.playbin2, GST_STATE_NULL);\r
- gst_object_unref (data.playbin2);\r
+ gst_element_set_state (data.playbin, GST_STATE_NULL);\r
+ gst_object_unref (data.playbin);\r
return 0;\r
}\r
\r
guint rate;\r
\r
/* Read some properties */\r
- g_object_get (data->playbin2, "n-video", &data->n_video, NULL);\r
- g_object_get (data->playbin2, "n-audio", &data->n_audio, NULL);\r
- g_object_get (data->playbin2, "n-text", &data->n_text, NULL);\r
+ g_object_get (data->playbin, "n-video", &data->n_video, NULL);\r
+ g_object_get (data->playbin, "n-audio", &data->n_audio, NULL);\r
+ g_object_get (data->playbin, "n-text", &data->n_text, NULL);\r
\r
g_print ("%d video stream(s), %d audio stream(s), %d text stream(s)\n",\r
data->n_video, data->n_audio, data->n_text);\r
for (i = 0; i < data->n_video; i++) {\r
tags = NULL;\r
/* Retrieve the stream's video tags */\r
- g_signal_emit_by_name (data->playbin2, "get-video-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-video-tags", i, &tags);\r
if (tags) {\r
g_print ("video stream %d:\n", i);\r
gst_tag_list_get_string (tags, GST_TAG_VIDEO_CODEC, &str);\r
g_print (" codec: %s\n", str ? str : "unknown");\r
g_free (str);\r
- gst_tag_list_free (tags);\r
+ gst_tag_list_unref (tags);\r
}\r
}\r
\r
for (i = 0; i < data->n_audio; i++) {\r
tags = NULL;\r
/* Retrieve the stream's audio tags */\r
- g_signal_emit_by_name (data->playbin2, "get-audio-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-audio-tags", i, &tags);\r
if (tags) {\r
g_print ("audio stream %d:\n", i);\r
if (gst_tag_list_get_string (tags, GST_TAG_AUDIO_CODEC, &str)) {\r
if (gst_tag_list_get_uint (tags, GST_TAG_BITRATE, &rate)) {\r
g_print (" bitrate: %d\n", rate);\r
}\r
- gst_tag_list_free (tags);\r
+ gst_tag_list_unref (tags);\r
}\r
}\r
\r
for (i = 0; i < data->n_text; i++) {\r
tags = NULL;\r
/* Retrieve the stream's subtitle tags */\r
- g_signal_emit_by_name (data->playbin2, "get-text-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-text-tags", i, &tags);\r
if (tags) {\r
g_print ("subtitle stream %d:\n", i);\r
if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {\r
g_print (" language: %s\n", str);\r
g_free (str);\r
}\r
- gst_tag_list_free (tags);\r
+ gst_tag_list_unref (tags);\r
}\r
}\r
\r
- g_object_get (data->playbin2, "current-video", &data->current_video, NULL);\r
- g_object_get (data->playbin2, "current-audio", &data->current_audio, NULL);\r
- g_object_get (data->playbin2, "current-text", &data->current_text, NULL);\r
+ g_object_get (data->playbin, "current-video", &data->current_video, NULL);\r
+ g_object_get (data->playbin, "current-audio", &data->current_audio, NULL);\r
+ g_object_get (data->playbin, "current-text", &data->current_text, NULL);\r
\r
g_print ("\n");\r
g_print ("Currently playing video stream %d, audio stream %d and text stream %d\n",\r
case GST_MESSAGE_STATE_CHANGED: {\r
GstState old_state, new_state, pending_state;\r
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);\r
- if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) {\r
+ if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin)) {\r
if (new_state == GST_STATE_PLAYING) {\r
/* Once we are in the playing state, analyze the streams */\r
analyze_streams (data);\r
gchar *str = NULL;\r
\r
if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {\r
- int index = atoi (str);\r
+ int index = g_ascii_strtoull (str, NULL, 0);\r
if (index < 0 || index >= data->n_audio) {\r
g_printerr ("Index out of bounds\n");\r
} else {\r
/* If the input was a valid audio stream index, set the current audio stream */\r
g_print ("Setting current audio stream to %d\n", index);\r
- g_object_set (data->playbin2, "current-audio", index, NULL);\r
+ g_object_set (data->playbin, "current-audio", index, NULL);\r
}\r
}\r
g_free (str);\r
+#include <stdio.h>\r
#include <gst/gst.h>\r
\r
/* Structure to contain all our information, so we can pass it around */\r
typedef struct _CustomData {\r
- GstElement *playbin2; /* Our one and only element */\r
+ GstElement *playbin; /* Our one and only element */\r
\r
gint n_video; /* Number of embedded video streams */\r
gint n_audio; /* Number of embedded audio streams */\r
GMainLoop *main_loop; /* GLib's Main Loop */\r
} CustomData;\r
\r
-/* playbin2 flags */\r
+/* playbin flags */\r
typedef enum {\r
GST_PLAY_FLAG_VIDEO = (1 << 0), /* We want video output */\r
GST_PLAY_FLAG_AUDIO = (1 << 1), /* We want audio output */\r
gst_init (&argc, &argv);\r
\r
/* Create the elements */\r
- data.playbin2 = gst_element_factory_make ("playbin2", "playbin2");\r
+ data.playbin = gst_element_factory_make ("playbin", "playbin");\r
\r
- if (!data.playbin2) {\r
+ if (!data.playbin) {\r
g_printerr ("Not all elements could be created.\n");\r
return -1;\r
}\r
\r
/* Set the URI to play */\r
- g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.ogv", NULL);\r
+ g_object_set (data.playbin, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.ogv", NULL);\r
\r
/* Set the subtitle URI to play and some font description */\r
- g_object_set (data.playbin2, "suburi", "http://docs.gstreamer.com/media/sintel_trailer_gr.srt", NULL);\r
- g_object_set (data.playbin2, "subtitle-font-desc", "Sans, 18", NULL);\r
+ g_object_set (data.playbin, "suburi", "http://docs.gstreamer.com/media/sintel_trailer_gr.srt", NULL);\r
+ g_object_set (data.playbin, "subtitle-font-desc", "Sans, 18", NULL);\r
\r
/* Set flags to show Audio, Video and Subtitles */\r
- g_object_get (data.playbin2, "flags", &flags, NULL);\r
+ g_object_get (data.playbin, "flags", &flags, NULL);\r
flags |= GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_TEXT;\r
- g_object_set (data.playbin2, "flags", flags, NULL);\r
+ g_object_set (data.playbin, "flags", flags, NULL);\r
\r
/* Add a bus watch, so we get notified when a message arrives */\r
- bus = gst_element_get_bus (data.playbin2);\r
+ bus = gst_element_get_bus (data.playbin);\r
gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data);\r
\r
/* Add a keyboard watch so we get notified of keystrokes */\r
-#ifdef _WIN32\r
+#ifdef G_OS_WIN32\r
io_stdin = g_io_channel_win32_new_fd (fileno (stdin));\r
#else\r
io_stdin = g_io_channel_unix_new (fileno (stdin));\r
g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc)handle_keyboard, &data);\r
\r
/* Start playing */\r
- ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING);\r
+ ret = gst_element_set_state (data.playbin, GST_STATE_PLAYING);\r
if (ret == GST_STATE_CHANGE_FAILURE) {\r
g_printerr ("Unable to set the pipeline to the playing state.\n");\r
- gst_object_unref (data.playbin2);\r
+ gst_object_unref (data.playbin);\r
return -1;\r
}\r
\r
g_main_loop_unref (data.main_loop);\r
g_io_channel_unref (io_stdin);\r
gst_object_unref (bus);\r
- gst_element_set_state (data.playbin2, GST_STATE_NULL);\r
- gst_object_unref (data.playbin2);\r
+ gst_element_set_state (data.playbin, GST_STATE_NULL);\r
+ gst_object_unref (data.playbin);\r
return 0;\r
}\r
\r
guint rate;\r
\r
/* Read some properties */\r
- g_object_get (data->playbin2, "n-video", &data->n_video, NULL);\r
- g_object_get (data->playbin2, "n-audio", &data->n_audio, NULL);\r
- g_object_get (data->playbin2, "n-text", &data->n_text, NULL);\r
+ g_object_get (data->playbin, "n-video", &data->n_video, NULL);\r
+ g_object_get (data->playbin, "n-audio", &data->n_audio, NULL);\r
+ g_object_get (data->playbin, "n-text", &data->n_text, NULL);\r
\r
g_print ("%d video stream(s), %d audio stream(s), %d text stream(s)\n",\r
data->n_video, data->n_audio, data->n_text);\r
for (i = 0; i < data->n_video; i++) {\r
tags = NULL;\r
/* Retrieve the stream's video tags */\r
- g_signal_emit_by_name (data->playbin2, "get-video-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-video-tags", i, &tags);\r
if (tags) {\r
g_print ("video stream %d:\n", i);\r
gst_tag_list_get_string (tags, GST_TAG_VIDEO_CODEC, &str);\r
for (i = 0; i < data->n_audio; i++) {\r
tags = NULL;\r
/* Retrieve the stream's audio tags */\r
- g_signal_emit_by_name (data->playbin2, "get-audio-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-audio-tags", i, &tags);\r
if (tags) {\r
g_print ("audio stream %d:\n", i);\r
if (gst_tag_list_get_string (tags, GST_TAG_AUDIO_CODEC, &str)) {\r
tags = NULL;\r
/* Retrieve the stream's subtitle tags */\r
g_print ("subtitle stream %d:\n", i);\r
- g_signal_emit_by_name (data->playbin2, "get-text-tags", i, &tags);\r
+ g_signal_emit_by_name (data->playbin, "get-text-tags", i, &tags);\r
if (tags) {\r
if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {\r
g_print (" language: %s\n", str);\r
}\r
}\r
\r
- g_object_get (data->playbin2, "current-video", &data->current_video, NULL);\r
- g_object_get (data->playbin2, "current-audio", &data->current_audio, NULL);\r
- g_object_get (data->playbin2, "current-text", &data->current_text, NULL);\r
+ g_object_get (data->playbin, "current-video", &data->current_video, NULL);\r
+ g_object_get (data->playbin, "current-audio", &data->current_audio, NULL);\r
+ g_object_get (data->playbin, "current-text", &data->current_text, NULL);\r
\r
g_print ("\n");\r
g_print ("Currently playing video stream %d, audio stream %d and subtitle stream %d\n",\r
case GST_MESSAGE_STATE_CHANGED: {\r
GstState old_state, new_state, pending_state;\r
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);\r
- if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) {\r
+ if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin)) {\r
if (new_state == GST_STATE_PLAYING) {\r
/* Once we are in the playing state, analyze the streams */\r
analyze_streams (data);\r
gchar *str = NULL;\r
\r
if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {\r
- int index = atoi (str);\r
+ int index = g_ascii_strtoull (str, NULL, 0);\r
if (index < 0 || index >= data->n_text) {\r
g_printerr ("Index out of bounds\n");\r
} else {\r
/* If the input was a valid subtitle stream index, set the current subtitle stream */\r
g_print ("Setting current subtitle stream to %d\n", index);\r
- g_object_set (data->playbin2, "current-text", index, NULL);\r
+ g_object_set (data->playbin, "current-text", index, NULL);\r
}\r
}\r
g_free (str);\r
#include <gst/gst.h>
+#include <gst/audio/audio.h>
#include <string.h>
#define CHUNK_SIZE 1024 /* Amount of bytes we are sending in each buffer */
#define SAMPLE_RATE 44100 /* Samples per second we are sending */
-#define AUDIO_CAPS "audio/x-raw-int,channels=1,rate=%d,signed=(boolean)true,width=16,depth=16,endianness=BYTE_ORDER"
/* Structure to contain all our information, so we can pass it to callbacks */
typedef struct _CustomData {
GstBuffer *buffer;
GstFlowReturn ret;
int i;
+ GstMapInfo map;
gint16 *raw;
gint num_samples = CHUNK_SIZE / 2; /* Because each sample is 16 bits */
gfloat freq;
GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale (CHUNK_SIZE, GST_SECOND, SAMPLE_RATE);
/* Generate some psychodelic waveforms */
- raw = (gint16 *)GST_BUFFER_DATA (buffer);
+ gst_buffer_map (buffer, &map, GST_MAP_WRITE);
+ raw = (gint16 *)map.data;
data->c += data->d;
data->d -= data->c / 1000;
freq = 1100 + 1000 * data->d;
data->b -= data->a / freq;
raw[i] = (gint16)(500 * data->a);
}
+ gst_buffer_unmap (buffer, &map);
data->num_samples += num_samples;
/* Push the buffer into the appsrc */
g_main_loop_quit (data->main_loop);
}
-/* This function is called when playbin2 has created the appsrc element, so we have
+/* This function is called when playbin has created the appsrc element, so we have
* a chance to configure it. */
static void source_setup (GstElement *pipeline, GstElement *source, CustomData *data) {
- gchar *audio_caps_text;
+ GstAudioInfo info;
GstCaps *audio_caps;
g_print ("Source has been created. Configuring.\n");
data->app_source = source;
/* Configure appsrc */
- audio_caps_text = g_strdup_printf (AUDIO_CAPS, SAMPLE_RATE);
- audio_caps = gst_caps_from_string (audio_caps_text);
- g_object_set (source, "caps", audio_caps, NULL);
+ gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16, SAMPLE_RATE, 1, NULL);
+ audio_caps = gst_audio_info_to_caps (&info);
+ g_object_set (source, "caps", audio_caps, "format", GST_FORMAT_TIME, NULL);
g_signal_connect (source, "need-data", G_CALLBACK (start_feed), data);
g_signal_connect (source, "enough-data", G_CALLBACK (stop_feed), data);
gst_caps_unref (audio_caps);
- g_free (audio_caps_text);
}
int main(int argc, char *argv[]) {
/* Initialize GStreamer */
gst_init (&argc, &argv);
- /* Create the playbin2 element */
- data.pipeline = gst_parse_launch ("playbin2 uri=appsrc://", NULL);
+ /* Create the playbin element */
+ data.pipeline = gst_parse_launch ("playbin uri=appsrc://", NULL);
g_signal_connect (data.pipeline, "source-setup", G_CALLBACK (source_setup), &data);
/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
#include <gst/gst.h>
#include <string.h>
-#define GRAPH_LENGTH 80
+#define GRAPH_LENGTH 78
-/* playbin2 flags */
+/* playbin flags */
typedef enum {
GST_PLAY_FLAG_DOWNLOAD = (1 << 7) /* Enable progressive download (on selected formats) */
} GstPlayFlags;
gchar *location;
g_object_get (G_OBJECT (prop_object), "temp-location", &location, NULL);
g_print ("Temporary file: %s\n", location);
+ g_free (location);
/* Uncomment this line to keep the temporary file after the program exits */
/* g_object_set (G_OBJECT (prop_object), "temp-remove", FALSE, NULL); */
}
if (result) {
gint n_ranges, range, i;
gchar graph[GRAPH_LENGTH + 1];
- GstFormat format = GST_FORMAT_TIME;
gint64 position = 0, duration = 0;
memset (graph, ' ', GRAPH_LENGTH);
for (range = 0; range < n_ranges; range++) {
gint64 start, stop;
gst_query_parse_nth_buffering_range (query, range, &start, &stop);
- start = start * GRAPH_LENGTH / 100;
- stop = stop * GRAPH_LENGTH / 100;
+ start = start * GRAPH_LENGTH / (stop - start);
+ stop = stop * GRAPH_LENGTH / (stop - start);
for (i = (gint)start; i < stop; i++)
graph [i] = '-';
}
- if (gst_element_query_position (data->pipeline, &format, &position) &&
+ if (gst_element_query_position (data->pipeline, GST_FORMAT_TIME, &position) &&
GST_CLOCK_TIME_IS_VALID (position) &&
- gst_element_query_duration (data->pipeline, &format, &duration) &&
+ gst_element_query_duration (data->pipeline, GST_FORMAT_TIME, &duration) &&
GST_CLOCK_TIME_IS_VALID (duration)) {
i = (gint)(GRAPH_LENGTH * (double)position / (double)(duration + 1));
graph [i] = data->buffering_level < 100 ? 'X' : '>';
data.buffering_level = 100;
/* Build the pipeline */
- pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
+ pipeline = gst_parse_launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
bus = gst_element_get_bus (pipeline);
/* Set the download flag */
g_print ("\n");
return 0;
-}
\ No newline at end of file
+}
#include <string.h>
+#include <stdio.h>
#include <gst/gst.h>
-#include <gst/interfaces/colorbalance.h>
+#include <gst/video/colorbalance.h>
typedef struct _CustomData {
GstElement *pipeline;
" 'Q' to quit\n");
/* Build the pipeline */
- data.pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
+ data.pipeline = gst_parse_launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);
/* Add a keyboard watch so we get notified of keystrokes */
-#ifdef _WIN32
+#ifdef G_OS_WIN32
io_stdin = g_io_channel_win32_new_fd (fileno (stdin));
#else
io_stdin = g_io_channel_unix_new (fileno (stdin));
gst_init (&argc, &argv);
/* Get a list of all visualization plugins */
- list = gst_registry_feature_filter (gst_registry_get_default (), filter_vis_features, FALSE, NULL);
+ list = gst_registry_feature_filter (gst_registry_get (), filter_vis_features, FALSE, NULL);
/* Print their names */
g_print("Available visualization plugins:\n");
return -1;
/* Build the pipeline */
- pipeline = gst_parse_launch ("playbin2 uri=http://radio.hbr1.com:19800/ambient.ogg", NULL);
+ pipeline = gst_parse_launch ("playbin uri=http://radio.hbr1.com:19800/ambient.ogg", NULL);
/* Set the visualization flag */
g_object_get (pipeline, "flags", &flags, NULL);
gst_init (&argc, &argv);\r
\r
/* Build the pipeline */\r
- pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);\r
+ pipeline = gst_parse_launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);\r
\r
/* Create the elements inside the sink bin */\r
equalizer = gst_element_factory_make ("equalizer-3bands", "equalizer");\r
gst_element_set_state (pipeline, GST_STATE_NULL);\r
gst_object_unref (pipeline);\r
return 0;\r
-}
\ No newline at end of file
+}\r