I just know the Gstreamer.
Sample code attached.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Stylianou, Costas
Sent: Wednesday, July 27, 2011 6:35 AM
To: [email protected]
Subject: [MeeGo-dev] playing .ogg audio files in meego

Hi,

Can someone tell me the correct API's to use to playback an .ogg audio files 
within my applications, should I be using Qtmultimedia or Gstreamer (which 
plugin?), any sample code or docs that you can point me too?

Many thanks
Costas
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#include <gst/gst.h>
#include <glib.h>
#include <glib/giochannel.h>
#include <stdio.h>

enum {
    Play,
    Stop,
    Pause,
    N_CONTROL
};


char *control_name[N_CONTROL] = {
    "Play",
    "Stop",
    "Pause"
};

static void shell_help ()
{
    int i;
    for (i=0; i<N_CONTROL; i++) {
        g_print ("'%d': to '%s'\n", i, control_name[i]);
    }
    g_print ("'?': to display this help info\n");
    g_print ("'h': to display this help info\n");
    g_print ("'q': to quit\n");
}

static GstElement *player;
static GMainLoop *loop;

gboolean method_call (gpointer control_id_p)
{

    gint control_id = *((gint *)control_id_p);
    switch  (control_id)
    {
        case Play:
            gst_element_set_state (player, GST_STATE_PLAYING);
            break;
        case Stop:
            gst_element_set_state (player, GST_STATE_NULL);
            break;
        case Pause:
            gst_element_set_state (player, GST_STATE_PAUSED);
            break;
        default:
            g_print ("Unknown control id = %d\n", control_id);
            break;
    }
    return FALSE;
}


static gboolean 
channel_cb(GIOChannel *source, GIOCondition condition, gpointer data)
{
    gchar buf[1024];
    GstElement *player;
    gint rc;

    player = (GstElement *)data;

    if (condition != G_IO_IN) {
        return TRUE;
    }

    /* we've received something on stdin.    */
    rc = fscanf(stdin, "%s", buf);
    if (rc <= 0) {
        g_print("NULL\n");
        return TRUE;
    }

    if (!strcmp(buf, "h")) {
        shell_help();
    } else if (!strcmp(buf, "?")) {
        shell_help();
    } else if (!strcmp(buf, "q")) {
        g_main_loop_quit(loop);
    } else if ('0' <= buf[0] && buf[0] <= (N_CONTROL + 48)){
        gint control_id = buf[0] - 48;
        g_idle_add (method_call, &control_id);
    } else {
        g_print("Unknown command '%s'\n", buf);
    }
    return TRUE;
}


int main (int argc, char **argv)
{

    GIOChannel *chan;
        gchar *uri;

    if (argc == 1){
        g_print ("Usage: player.x uri_to_playbin2");
        g_print ("Example: player.x file:///root/720p.m4v");
        return 0;
    }

        uri = argv[1];

        /* Initialisation */
        gst_init (&argc, &argv);

        player = gst_element_factory_make ("playbin2", NULL);

        g_object_set (G_OBJECT(player), "uri", uri, NULL);
        gst_element_set_state (player, GST_STATE_PLAYING);

    chan = g_io_channel_unix_new(0);
    g_io_add_watch(chan, G_IO_IN, channel_cb, player);

        loop = g_main_loop_new (NULL, FALSE);
        g_main_loop_run (loop);

        gst_element_set_state (player, GST_STATE_NULL);
        gst_object_unref (player);
    g_print ("Quit....\n");
        return 0;
}
_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev
http://wiki.meego.com/Mailing_list_guidelines

Reply via email to