mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
Port playback tutorials to 1.0
This commit is contained in:
parent
8440e137d9
commit
5ad1810d8b
7 changed files with 88 additions and 83 deletions
|
@ -1,8 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* Structure to contain all our information, so we can pass it around */
|
||||
typedef struct _CustomData {
|
||||
GstElement *playbin2; /* Our one and only element */
|
||||
GstElement *playbin; /* Our one and only element */
|
||||
|
||||
gint n_video; /* Number of embedded video streams */
|
||||
gint n_audio; /* Number of embedded audio streams */
|
||||
|
@ -15,7 +16,7 @@ typedef struct _CustomData {
|
|||
GMainLoop *main_loop; /* GLib's Main Loop */
|
||||
} CustomData;
|
||||
|
||||
/* playbin2 flags */
|
||||
/* playbin flags */
|
||||
typedef enum {
|
||||
GST_PLAY_FLAG_VIDEO = (1 << 0), /* We want video output */
|
||||
GST_PLAY_FLAG_AUDIO = (1 << 1), /* We want audio output */
|
||||
|
@ -37,31 +38,31 @@ int main(int argc, char *argv[]) {
|
|||
gst_init (&argc, &argv);
|
||||
|
||||
/* Create the elements */
|
||||
data.playbin2 = gst_element_factory_make ("playbin2", "playbin2");
|
||||
data.playbin = gst_element_factory_make ("playbin", "playbin");
|
||||
|
||||
if (!data.playbin2) {
|
||||
if (!data.playbin) {
|
||||
g_printerr ("Not all elements could be created.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set the URI to play */
|
||||
g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_cropped_multilingual.webm", NULL);
|
||||
g_object_set (data.playbin, "uri", "http://docs.gstreamer.com/media/sintel_cropped_multilingual.webm", NULL);
|
||||
|
||||
/* Set flags to show Audio and Video but ignore Subtitles */
|
||||
g_object_get (data.playbin2, "flags", &flags, NULL);
|
||||
g_object_get (data.playbin, "flags", &flags, NULL);
|
||||
flags |= GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO;
|
||||
flags &= ~GST_PLAY_FLAG_TEXT;
|
||||
g_object_set (data.playbin2, "flags", flags, NULL);
|
||||
g_object_set (data.playbin, "flags", flags, NULL);
|
||||
|
||||
/* Set connection speed. This will affect some internal decisions of playbin2 */
|
||||
g_object_set (data.playbin2, "connection-speed", 56, NULL);
|
||||
/* Set connection speed. This will affect some internal decisions of playbin */
|
||||
g_object_set (data.playbin, "connection-speed", 56, NULL);
|
||||
|
||||
/* Add a bus watch, so we get notified when a message arrives */
|
||||
bus = gst_element_get_bus (data.playbin2);
|
||||
bus = gst_element_get_bus (data.playbin);
|
||||
gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data);
|
||||
|
||||
/* 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));
|
||||
|
@ -69,10 +70,10 @@ int main(int argc, char *argv[]) {
|
|||
g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc)handle_keyboard, &data);
|
||||
|
||||
/* Start playing */
|
||||
ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING);
|
||||
ret = gst_element_set_state (data.playbin, GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
g_printerr ("Unable to set the pipeline to the playing state.\n");
|
||||
gst_object_unref (data.playbin2);
|
||||
gst_object_unref (data.playbin);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -84,8 +85,8 @@ int main(int argc, char *argv[]) {
|
|||
g_main_loop_unref (data.main_loop);
|
||||
g_io_channel_unref (io_stdin);
|
||||
gst_object_unref (bus);
|
||||
gst_element_set_state (data.playbin2, GST_STATE_NULL);
|
||||
gst_object_unref (data.playbin2);
|
||||
gst_element_set_state (data.playbin, GST_STATE_NULL);
|
||||
gst_object_unref (data.playbin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,9 +98,9 @@ static void analyze_streams (CustomData *data) {
|
|||
guint rate;
|
||||
|
||||
/* Read some properties */
|
||||
g_object_get (data->playbin2, "n-video", &data->n_video, NULL);
|
||||
g_object_get (data->playbin2, "n-audio", &data->n_audio, NULL);
|
||||
g_object_get (data->playbin2, "n-text", &data->n_text, NULL);
|
||||
g_object_get (data->playbin, "n-video", &data->n_video, NULL);
|
||||
g_object_get (data->playbin, "n-audio", &data->n_audio, NULL);
|
||||
g_object_get (data->playbin, "n-text", &data->n_text, NULL);
|
||||
|
||||
g_print ("%d video stream(s), %d audio stream(s), %d text stream(s)\n",
|
||||
data->n_video, data->n_audio, data->n_text);
|
||||
|
@ -108,13 +109,13 @@ static void analyze_streams (CustomData *data) {
|
|||
for (i = 0; i < data->n_video; i++) {
|
||||
tags = NULL;
|
||||
/* Retrieve the stream's video tags */
|
||||
g_signal_emit_by_name (data->playbin2, "get-video-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-video-tags", i, &tags);
|
||||
if (tags) {
|
||||
g_print ("video stream %d:\n", i);
|
||||
gst_tag_list_get_string (tags, GST_TAG_VIDEO_CODEC, &str);
|
||||
g_print (" codec: %s\n", str ? str : "unknown");
|
||||
g_free (str);
|
||||
gst_tag_list_free (tags);
|
||||
gst_tag_list_unref (tags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +123,7 @@ static void analyze_streams (CustomData *data) {
|
|||
for (i = 0; i < data->n_audio; i++) {
|
||||
tags = NULL;
|
||||
/* Retrieve the stream's audio tags */
|
||||
g_signal_emit_by_name (data->playbin2, "get-audio-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-audio-tags", i, &tags);
|
||||
if (tags) {
|
||||
g_print ("audio stream %d:\n", i);
|
||||
if (gst_tag_list_get_string (tags, GST_TAG_AUDIO_CODEC, &str)) {
|
||||
|
@ -136,7 +137,7 @@ static void analyze_streams (CustomData *data) {
|
|||
if (gst_tag_list_get_uint (tags, GST_TAG_BITRATE, &rate)) {
|
||||
g_print (" bitrate: %d\n", rate);
|
||||
}
|
||||
gst_tag_list_free (tags);
|
||||
gst_tag_list_unref (tags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,20 +145,20 @@ static void analyze_streams (CustomData *data) {
|
|||
for (i = 0; i < data->n_text; i++) {
|
||||
tags = NULL;
|
||||
/* Retrieve the stream's subtitle tags */
|
||||
g_signal_emit_by_name (data->playbin2, "get-text-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-text-tags", i, &tags);
|
||||
if (tags) {
|
||||
g_print ("subtitle stream %d:\n", i);
|
||||
if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {
|
||||
g_print (" language: %s\n", str);
|
||||
g_free (str);
|
||||
}
|
||||
gst_tag_list_free (tags);
|
||||
gst_tag_list_unref (tags);
|
||||
}
|
||||
}
|
||||
|
||||
g_object_get (data->playbin2, "current-video", &data->current_video, NULL);
|
||||
g_object_get (data->playbin2, "current-audio", &data->current_audio, NULL);
|
||||
g_object_get (data->playbin2, "current-text", &data->current_text, NULL);
|
||||
g_object_get (data->playbin, "current-video", &data->current_video, NULL);
|
||||
g_object_get (data->playbin, "current-audio", &data->current_audio, NULL);
|
||||
g_object_get (data->playbin, "current-text", &data->current_text, NULL);
|
||||
|
||||
g_print ("\n");
|
||||
g_print ("Currently playing video stream %d, audio stream %d and text stream %d\n",
|
||||
|
@ -186,7 +187,7 @@ static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data)
|
|||
case GST_MESSAGE_STATE_CHANGED: {
|
||||
GstState old_state, new_state, pending_state;
|
||||
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);
|
||||
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) {
|
||||
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin)) {
|
||||
if (new_state == GST_STATE_PLAYING) {
|
||||
/* Once we are in the playing state, analyze the streams */
|
||||
analyze_streams (data);
|
||||
|
@ -206,13 +207,13 @@ static gboolean handle_keyboard (GIOChannel *source, GIOCondition cond, CustomDa
|
|||
gchar *str = NULL;
|
||||
|
||||
if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
|
||||
int index = atoi (str);
|
||||
int index = g_ascii_strtoull (str, NULL, 0);
|
||||
if (index < 0 || index >= data->n_audio) {
|
||||
g_printerr ("Index out of bounds\n");
|
||||
} else {
|
||||
/* If the input was a valid audio stream index, set the current audio stream */
|
||||
g_print ("Setting current audio stream to %d\n", index);
|
||||
g_object_set (data->playbin2, "current-audio", index, NULL);
|
||||
g_object_set (data->playbin, "current-audio", index, NULL);
|
||||
}
|
||||
}
|
||||
g_free (str);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* Structure to contain all our information, so we can pass it around */
|
||||
typedef struct _CustomData {
|
||||
GstElement *playbin2; /* Our one and only element */
|
||||
GstElement *playbin; /* Our one and only element */
|
||||
|
||||
gint n_video; /* Number of embedded video streams */
|
||||
gint n_audio; /* Number of embedded audio streams */
|
||||
|
@ -15,7 +16,7 @@ typedef struct _CustomData {
|
|||
GMainLoop *main_loop; /* GLib's Main Loop */
|
||||
} CustomData;
|
||||
|
||||
/* playbin2 flags */
|
||||
/* playbin flags */
|
||||
typedef enum {
|
||||
GST_PLAY_FLAG_VIDEO = (1 << 0), /* We want video output */
|
||||
GST_PLAY_FLAG_AUDIO = (1 << 1), /* We want audio output */
|
||||
|
@ -37,31 +38,31 @@ int main(int argc, char *argv[]) {
|
|||
gst_init (&argc, &argv);
|
||||
|
||||
/* Create the elements */
|
||||
data.playbin2 = gst_element_factory_make ("playbin2", "playbin2");
|
||||
data.playbin = gst_element_factory_make ("playbin", "playbin");
|
||||
|
||||
if (!data.playbin2) {
|
||||
if (!data.playbin) {
|
||||
g_printerr ("Not all elements could be created.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set the URI to play */
|
||||
g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.ogv", NULL);
|
||||
g_object_set (data.playbin, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.ogv", NULL);
|
||||
|
||||
/* Set the subtitle URI to play and some font description */
|
||||
g_object_set (data.playbin2, "suburi", "http://docs.gstreamer.com/media/sintel_trailer_gr.srt", NULL);
|
||||
g_object_set (data.playbin2, "subtitle-font-desc", "Sans, 18", NULL);
|
||||
g_object_set (data.playbin, "suburi", "http://docs.gstreamer.com/media/sintel_trailer_gr.srt", NULL);
|
||||
g_object_set (data.playbin, "subtitle-font-desc", "Sans, 18", NULL);
|
||||
|
||||
/* Set flags to show Audio, Video and Subtitles */
|
||||
g_object_get (data.playbin2, "flags", &flags, NULL);
|
||||
g_object_get (data.playbin, "flags", &flags, NULL);
|
||||
flags |= GST_PLAY_FLAG_VIDEO | GST_PLAY_FLAG_AUDIO | GST_PLAY_FLAG_TEXT;
|
||||
g_object_set (data.playbin2, "flags", flags, NULL);
|
||||
g_object_set (data.playbin, "flags", flags, NULL);
|
||||
|
||||
/* Add a bus watch, so we get notified when a message arrives */
|
||||
bus = gst_element_get_bus (data.playbin2);
|
||||
bus = gst_element_get_bus (data.playbin);
|
||||
gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data);
|
||||
|
||||
/* 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));
|
||||
|
@ -69,10 +70,10 @@ int main(int argc, char *argv[]) {
|
|||
g_io_add_watch (io_stdin, G_IO_IN, (GIOFunc)handle_keyboard, &data);
|
||||
|
||||
/* Start playing */
|
||||
ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING);
|
||||
ret = gst_element_set_state (data.playbin, GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
g_printerr ("Unable to set the pipeline to the playing state.\n");
|
||||
gst_object_unref (data.playbin2);
|
||||
gst_object_unref (data.playbin);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -84,8 +85,8 @@ int main(int argc, char *argv[]) {
|
|||
g_main_loop_unref (data.main_loop);
|
||||
g_io_channel_unref (io_stdin);
|
||||
gst_object_unref (bus);
|
||||
gst_element_set_state (data.playbin2, GST_STATE_NULL);
|
||||
gst_object_unref (data.playbin2);
|
||||
gst_element_set_state (data.playbin, GST_STATE_NULL);
|
||||
gst_object_unref (data.playbin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,9 +98,9 @@ static void analyze_streams (CustomData *data) {
|
|||
guint rate;
|
||||
|
||||
/* Read some properties */
|
||||
g_object_get (data->playbin2, "n-video", &data->n_video, NULL);
|
||||
g_object_get (data->playbin2, "n-audio", &data->n_audio, NULL);
|
||||
g_object_get (data->playbin2, "n-text", &data->n_text, NULL);
|
||||
g_object_get (data->playbin, "n-video", &data->n_video, NULL);
|
||||
g_object_get (data->playbin, "n-audio", &data->n_audio, NULL);
|
||||
g_object_get (data->playbin, "n-text", &data->n_text, NULL);
|
||||
|
||||
g_print ("%d video stream(s), %d audio stream(s), %d text stream(s)\n",
|
||||
data->n_video, data->n_audio, data->n_text);
|
||||
|
@ -108,7 +109,7 @@ static void analyze_streams (CustomData *data) {
|
|||
for (i = 0; i < data->n_video; i++) {
|
||||
tags = NULL;
|
||||
/* Retrieve the stream's video tags */
|
||||
g_signal_emit_by_name (data->playbin2, "get-video-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-video-tags", i, &tags);
|
||||
if (tags) {
|
||||
g_print ("video stream %d:\n", i);
|
||||
gst_tag_list_get_string (tags, GST_TAG_VIDEO_CODEC, &str);
|
||||
|
@ -122,7 +123,7 @@ static void analyze_streams (CustomData *data) {
|
|||
for (i = 0; i < data->n_audio; i++) {
|
||||
tags = NULL;
|
||||
/* Retrieve the stream's audio tags */
|
||||
g_signal_emit_by_name (data->playbin2, "get-audio-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-audio-tags", i, &tags);
|
||||
if (tags) {
|
||||
g_print ("audio stream %d:\n", i);
|
||||
if (gst_tag_list_get_string (tags, GST_TAG_AUDIO_CODEC, &str)) {
|
||||
|
@ -145,7 +146,7 @@ static void analyze_streams (CustomData *data) {
|
|||
tags = NULL;
|
||||
/* Retrieve the stream's subtitle tags */
|
||||
g_print ("subtitle stream %d:\n", i);
|
||||
g_signal_emit_by_name (data->playbin2, "get-text-tags", i, &tags);
|
||||
g_signal_emit_by_name (data->playbin, "get-text-tags", i, &tags);
|
||||
if (tags) {
|
||||
if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str)) {
|
||||
g_print (" language: %s\n", str);
|
||||
|
@ -157,9 +158,9 @@ static void analyze_streams (CustomData *data) {
|
|||
}
|
||||
}
|
||||
|
||||
g_object_get (data->playbin2, "current-video", &data->current_video, NULL);
|
||||
g_object_get (data->playbin2, "current-audio", &data->current_audio, NULL);
|
||||
g_object_get (data->playbin2, "current-text", &data->current_text, NULL);
|
||||
g_object_get (data->playbin, "current-video", &data->current_video, NULL);
|
||||
g_object_get (data->playbin, "current-audio", &data->current_audio, NULL);
|
||||
g_object_get (data->playbin, "current-text", &data->current_text, NULL);
|
||||
|
||||
g_print ("\n");
|
||||
g_print ("Currently playing video stream %d, audio stream %d and subtitle stream %d\n",
|
||||
|
@ -188,7 +189,7 @@ static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data)
|
|||
case GST_MESSAGE_STATE_CHANGED: {
|
||||
GstState old_state, new_state, pending_state;
|
||||
gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);
|
||||
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) {
|
||||
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin)) {
|
||||
if (new_state == GST_STATE_PLAYING) {
|
||||
/* Once we are in the playing state, analyze the streams */
|
||||
analyze_streams (data);
|
||||
|
@ -208,13 +209,13 @@ static gboolean handle_keyboard (GIOChannel *source, GIOCondition cond, CustomDa
|
|||
gchar *str = NULL;
|
||||
|
||||
if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
|
||||
int index = atoi (str);
|
||||
int index = g_ascii_strtoull (str, NULL, 0);
|
||||
if (index < 0 || index >= data->n_text) {
|
||||
g_printerr ("Index out of bounds\n");
|
||||
} else {
|
||||
/* If the input was a valid subtitle stream index, set the current subtitle stream */
|
||||
g_print ("Setting current subtitle stream to %d\n", index);
|
||||
g_object_set (data->playbin2, "current-text", index, NULL);
|
||||
g_object_set (data->playbin, "current-text", index, NULL);
|
||||
}
|
||||
}
|
||||
g_free (str);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#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 {
|
||||
|
@ -26,6 +26,7 @@ static gboolean push_data (CustomData *data) {
|
|||
GstBuffer *buffer;
|
||||
GstFlowReturn ret;
|
||||
int i;
|
||||
GstMapInfo map;
|
||||
gint16 *raw;
|
||||
gint num_samples = CHUNK_SIZE / 2; /* Because each sample is 16 bits */
|
||||
gfloat freq;
|
||||
|
@ -38,7 +39,8 @@ static gboolean push_data (CustomData *data) {
|
|||
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;
|
||||
|
@ -47,6 +49,7 @@ static gboolean push_data (CustomData *data) {
|
|||
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 */
|
||||
|
@ -97,23 +100,22 @@ static void error_cb (GstBus *bus, GstMessage *msg, CustomData *data) {
|
|||
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[]) {
|
||||
|
@ -128,8 +130,8 @@ 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 */
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#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;
|
||||
|
@ -19,6 +19,7 @@ static void got_location (GstObject *gstobject, GstObject *prop_object, GParamSp
|
|||
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); */
|
||||
}
|
||||
|
@ -76,7 +77,6 @@ static gboolean refresh_ui (CustomData *data) {
|
|||
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);
|
||||
|
@ -86,14 +86,14 @@ static gboolean refresh_ui (CustomData *data) {
|
|||
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' : '>';
|
||||
|
@ -127,7 +127,7 @@ int main(int argc, char *argv[]) {
|
|||
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 */
|
||||
|
@ -169,4 +169,4 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
g_print ("\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#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;
|
||||
|
@ -113,10 +114,10 @@ int main(int argc, char *argv[]) {
|
|||
" '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));
|
||||
|
|
|
@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
|
|||
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");
|
||||
|
@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
|
|||
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);
|
||||
|
|
|
@ -10,7 +10,7 @@ int main(int argc, char *argv[]) {
|
|||
gst_init (&argc, &argv);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Create the elements inside the sink bin */
|
||||
equalizer = gst_element_factory_make ("equalizer-3bands", "equalizer");
|
||||
|
@ -52,4 +52,4 @@ int main(int argc, char *argv[]) {
|
|||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
gst_object_unref (pipeline);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue