All pastes #146292 Raw Edit

Something

public c v1 · immutable
#146292 ·published 2006-08-23 14:00 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <gst/gst.h>GstElement *pipeline = NULL;GMainLoop *loop = NULL;char *filename = "test.mp3";int *p_argc = NULL;char ***p_argv = NULL;static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data) {    switch(GST_MESSAGE_TYPE(msg)) {        case GST_MESSAGE_EOS:            printf("End of stream\n");            g_main_loop_quit(loop);            break;        case GST_MESSAGE_ERROR: {            gchar *debug;            GError *err;            gst_message_parse_error (msg, &err, &debug);            g_free(debug);            printf("Error: %s\n", err->message);            g_error_free(err);            g_main_loop_quit(loop);            break;        }        default:            break;    }    return TRUE;}static void handoff(GstElement *src, GstBuffer *buffer, GstPad *pad, gpointer user_data) {    int buffer_size = GST_BUFFER_SIZE (buffer);    // Copy data from an actual source.}int main (int argc, char **argv) {    GstBus *bus;    GstElement *element;    GstCaps *caps;    GstPad *pad;    char *str = "fakesrc name=sorsa ! queue ! audioconvert ! alsasink";    GError *error = NULL;    gst_init(p_argc, p_argv);    pipeline = gst_parse_launch(str, &error);    if (!pipeline) {        printf("Error: Could not construct pipeline");        if (error) {            printf(": %s", GST_STR_NULL(error->message));            g_error_free(error);        }        printf("\n");        return;    }    else if(error) {        printf("Error: Erroneus pipeline: %s\n", GST_STR_NULL(error->message));        return;    }    printf("Pipeline created.\n");    bus = gst_pipeline_get_bus (GST_PIPELINE(pipeline));    gst_bus_add_watch(bus, bus_call, loop);    gst_object_unref(bus);    printf("futzing around with the fake source\n");    element = gst_bin_get_by_name(GST_BIN(pipeline), "sorsa");    g_signal_connect(element, "handoff", G_CALLBACK(handoff), NULL);    pad = gst_element_get_pad(element, "src");    gst_pad_use_fixed_caps(pad);    caps = gst_caps_new_simple("audio/x-raw-int", NULL);    gst_pad_set_caps(pad, caps);    printf("done futzing\n");    gst_caps_unref(caps);    gst_object_unref(GST_OBJECT(pad));    gst_object_unref(GST_OBJECT(element));    printf("Setting pipeline state to PLAYING\n");    gst_element_set_state(pipeline, GST_STATE_PLAYING);    printf("Entering main loop\n");    loop = g_main_loop_new(NULL, FALSE);    g_main_loop_run(loop);    printf("Main loop returned, stopping playback\n");    gst_element_set_state(pipeline, GST_STATE_NULL);    gst_object_unref(GST_OBJECT(pipeline));    return 0;}