#include <glib.h>
#include "gmyth-stream-client.h"

int main (int argc, char** argv)
{
    GMythStreamClient *cli = NULL;
    gint ret = -1;

    g_type_init ();

    cli = gmyth_stream_client_new ();
    if (!gmyth_stream_client_connect (cli, "127.0.0.1", 50000)) {
        g_warning ("Fail to connect");
        return -1;
    }

    ret = gmyth_stream_client_open_stream (cli, "file:///tmp/dvb.mpg",
                                          "mpeg", "mpeg1video", 400, 25,
                                          "mp2", 192, 320, 240, "format=mpeg1");

    //myth:///tmp/mpg/bad_day.mpg mpeg mpeg1video 400 25 mp2 192 320 240 format=mpeg1

    if (ret < 0) {
        g_printerr ("Fail to open stream");
        return -1;
    }

    g_debug ("Stream created");
    g_debug ("Going to PLAY now...");

    gint fd = gmyth_stream_client_play_stream (cli);

    if (fd == -1) {
        g_printerr ("Fail to play stream");
        return -1;
    }

    g_debug ("started");

    gmyth_stream_client_close_stream(cli);
    gmyth_stream_client_disconnect(cli);

    g_debug ("finished");

    return 0;
}