# HG changeset patch # User melunko # Date 1173142535 0 # Node ID dbf952e956b528655c35e64d4a451b7fe4fedc4a # Parent 7c2dde09dc8a12762bbd9f8ee9066909be705607 [svn r394] gmyth version incremented to 0.2. gmyth_transcoder start/pause/cancel/resume methods added. diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/configure.ac --- a/gmyth/configure.ac Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/configure.ac Tue Mar 06 00:55:35 2007 +0000 @@ -3,14 +3,14 @@ AC_PREREQ(2.50) -AC_INIT([gmyth],[0.1]) +AC_INIT([gmyth],[0.2]) dnl AC_CONFIG_SRCDIR([src/mmyth_main.c]) AC_CONFIG_HEADER(config.h) dnl when going to/from release please set the nano (fourth number) right ! dnl releases only do Wall, SVN and prerelease does Werror too -AS_VERSION(gmyth, GMYTH, 0, 1, 0, 8, GMYTH_SVN="no", GMYTH_SVN="yes") +AS_VERSION(gmyth, GMYTH, 0, 2, 0, 0, GMYTH_SVN="no", GMYTH_SVN="yes") GMYTH_MAJORMINOR=$GMYTH_MAJOR_VERSION.$GMYTH_MINOR_VERSION AC_SUBST(GMYTH_MAJORMINOR) diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/debian/changelog --- a/gmyth/debian/changelog Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/debian/changelog Tue Mar 06 00:55:35 2007 +0000 @@ -1,4 +1,12 @@ -gmyth (0.1-indt1) unstable; urgency=low +gmyth (0.2) unstable; urgency=low + + * Included remote file transcoding + * Included recording profile management + * Several bug fixes + + -- Hallyson Melo Mon, 5 Mar 2007 14:46:08 -0300 + +gmyth (0.1) unstable; urgency=low * Initial Maemo Package. diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/m4/configure.ac --- a/gmyth/m4/configure.ac Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/m4/configure.ac Tue Mar 06 00:55:35 2007 +0000 @@ -3,7 +3,7 @@ AC_PREREQ(2.50) -AC_INIT([gmyth],[0.1]) +AC_INIT([gmyth],[0.2]) dnl AC_CONFIG_SRCDIR([src/mmyth_main.c]) AC_CONFIG_HEADER(config.h) @@ -213,11 +213,11 @@ ## Check for gmyth-0.1 -PKG_CHECK_MODULES(LIBGMYTH, gmyth-0.1, HAVE_LIBGMYTH=yes,HAVE_LIBGMYTH=no) +PKG_CHECK_MODULES(LIBGMYTH, gmyth-0.2, HAVE_LIBGMYTH=yes,HAVE_LIBGMYTH=no) -# Give error and exit if we don't have gmyth-0.1 +# Give error and exit if we don't have gmyth-0.2 if test "x$HAVE_LIBGMYTH" = "xno"; then - AC_MSG_ERROR(you need gmyth-0.1 installed) + AC_MSG_ERROR(you need gmyth-0.2 installed) fi # make LIBXML_CFLAGS and LIBXML_LIBS available diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/src/gmyth_jobqueue.c --- a/gmyth/src/gmyth_jobqueue.c Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/src/gmyth_jobqueue.c Tue Mar 06 00:55:35 2007 +0000 @@ -39,7 +39,7 @@ * @return gboolean - result of connection * */ -GMythSocket* +static GMythSocket* backend_connect (GMythBackendInfo *backend_info) { GMythSocket *socket = gmyth_socket_new (); @@ -66,7 +66,7 @@ * @return the value returned by the backend * */ -GString* send_command(GMythSocket *socket, gchar* action, +static GString* send_command(GMythSocket *socket, gchar* action, gchar* job, gint chanid, gchar* starttime, gchar* options) { @@ -94,28 +94,27 @@ * @return 0 if success and -1 if error * */ -gint test_result(gchar* ret, gchar* value) +static gboolean test_result(gchar* ret, gchar* value) { - if (g_ascii_strcasecmp(ret, value) == 0) - return 0; - else - { - g_debug("JobQueue Error: %s", ret); - return -1; - } - + if (g_ascii_strcasecmp(ret, value) == 0) + return TRUE; + else { + g_debug("JobQueue Error: %s", ret); + return FALSE; + } } /** Function to add a job inside JOBQUEUE * * @param transcode object holding all the info about the transcoding * @param job the job you want to add the action - * @return the value of the key + * @return TRUE if the job was added, FALSE if not * */ -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job) +gint gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job) { - GMythSocket *socket = backend_connect(transcode->backend_info); + //fixme: disconnect this socket + GMythSocket *socket = backend_connect (transcode->backend_info); if (socket != NULL) { GString* options = g_string_new (""); @@ -133,6 +132,7 @@ g_string_append_printf(options, " %s", transcode->profile); } + //fixme: allocation GString* ret = send_command(socket, "ADD", job, transcode->chanid, transcode->starttime, options->str); @@ -142,9 +142,7 @@ g_free(ret); return res; - } - else - { + } else { g_debug("JobQueue Connection Failed"); return -1; } @@ -158,7 +156,7 @@ * @return the value of the key * */ -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action, +gboolean gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action, gchar* job) { GMythSocket *socket = backend_connect(transcode->backend_info); @@ -173,9 +171,7 @@ g_free(ret); return res; - } - else - { + } else { g_debug("JobQueue Connection Failed"); return -1; } diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/src/gmyth_jobqueue.h --- a/gmyth/src/gmyth_jobqueue.h Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/src/gmyth_jobqueue.h Tue Mar 06 00:55:35 2007 +0000 @@ -44,8 +44,8 @@ G_BEGIN_DECLS -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job); -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action, +gint gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job); +gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action, gchar* job); G_END_DECLS diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/src/gmyth_transcode.c --- a/gmyth/src/gmyth_transcode.c Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/src/gmyth_transcode.c Tue Mar 06 00:55:35 2007 +0000 @@ -1,9 +1,9 @@ /** * GMyth Library * - * @file gmyth/gmyth_transcode.c + * @file gmyth/gmyth_transcoder.c * - * @brief

This file contains the transcode class. + * @brief

This file contains the transcoder class. * * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza @@ -35,81 +35,83 @@ #include #include -#include "gmyth_transcode.h" #include "gmyth_util.h" #include "gmyth_debug.h" -static void gmyth_transcode_class_init (GMythTranscodeClass *klass); -static void gmyth_transcode_init (GMythTranscode *object); +#include "gmyth_jobqueue.h" +#include "gmyth_transcode.h" -static void gmyth_transcode_dispose (GObject *object); -static void gmyth_transcode_finalize (GObject *object); +static void gmyth_transcoder_class_init (GMythTranscoderClass *klass); +static void gmyth_transcoder_init (GMythTranscoder *object); -G_DEFINE_TYPE(GMythTranscode, gmyth_transcode, G_TYPE_OBJECT) +static void gmyth_transcoder_dispose (GObject *object); +static void gmyth_transcoder_finalize (GObject *object); + +G_DEFINE_TYPE(GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT) static void -gmyth_transcode_class_init (GMythTranscodeClass *klass) +gmyth_transcoder_class_init (GMythTranscoderClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->dispose = gmyth_transcode_dispose; - gobject_class->finalize = gmyth_transcode_finalize; + gobject_class->dispose = gmyth_transcoder_dispose; + gobject_class->finalize = gmyth_transcoder_finalize; } static void -gmyth_transcode_init (GMythTranscode *transcode) +gmyth_transcoder_init (GMythTranscoder *transcoder) { + transcoder->started = FALSE; } static void -gmyth_transcode_dispose (GObject *object) +gmyth_transcoder_dispose (GObject *object) { - GMythTranscode *transcode = GMYTH_TRANSCODE(object); + GMythTranscoder *transcoder = GMYTH_TRANSCODER(object); - if (transcode->output_filename) - g_free(transcode->output_filename); + g_free (transcoder->output_filename); + g_free (transcoder->filename); + g_free (transcoder->profile); + g_free (transcoder->starttime); - if (transcode->filename) - g_free(transcode->filename); + if (transcoder->backend_info) + g_object_unref (transcoder->backend_info); - if (transcode->profile) - g_free(transcode->profile); - - if (transcode->starttime) - g_free(transcode->starttime); - - G_OBJECT_CLASS (gmyth_transcode_parent_class)->dispose (object); + G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object); } static void -gmyth_transcode_finalize (GObject *object) +gmyth_transcoder_finalize (GObject *object) { g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_transcode_parent_class)->finalize (object); + G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object); } /** - * Creates a new instance of GMythTranscode. + * Creates a new instance of GMythTranscoder. * - * @return a new instance of GMythTranscode. + * @return a new instance of GMythTranscoder. **/ -GMythTranscode* -gmyth_transcode_new (void) +GMythTranscoder* +gmyth_transcoder_new (GMythBackendInfo *backend_info) { - GMythTranscode *transcode = GMYTH_TRANSCODE\ - (g_object_new(GMYTH_TRANSCODE_TYPE, NULL)); + GMythTranscoder *transcoder = GMYTH_TRANSCODER\ + (g_object_new(GMYTH_TRANSCODER_TYPE, NULL)); - return transcode; + g_object_ref (backend_info); + transcoder->backend_info = backend_info; + + return transcoder; } /** * - * gmyth_transcode_date_change_format + * gmyth_transcoder_date_change_format * @brief converts a string like YYYY-MM-DDTHH:MM:SS into YYYYMMDDHHMMSS (vice versa) * @param date_s gchar* * @return gchar* with file or iso format * **/ -gchar* gmyth_transcode_date_change_format (gchar* date_s, int format) +static gchar* gmyth_transcoder_date_change_format (gchar* date_s, int format) { if (date_s != NULL) { @@ -127,10 +129,7 @@ snprintf(dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src+5,\ src+7, src+9, src+11, src+13); dst[15] = '\0'; - } - else - if (format == DATE_ISO) - { + } else if (format == DATE_ISO) { dst = (gchar*)g_malloc0(sizeof(gchar) * 20); snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src+4,\ src+6, src+8, src+10, src+12); @@ -149,62 +148,113 @@ /** * - * gmyth_transcode_set_output - * @brief set transcode to use output + * gmyth_transcoder_set_output + * @brief set transcoder to use output * @param value gboolean * @param outfile filename of output * @return void set's up the var to value * **/ -void gmyth_transcode_set_output (GMythTranscode* transcode, +void gmyth_transcoder_set_output (GMythTranscoder* transcoder, gboolean value, gchar* outputfile) { - transcode->output = value; - transcode->output_filename = g_strdup(outputfile); + transcoder->output = value; + transcoder->output_filename = g_strdup(outputfile); } /** * - * gmyth_transcode_set_file - * @brief set the file to transcode + * gmyth_transcoder_set_file + * @brief set the file to transcoder * @param file filename * @return void set's up the var to value * **/ -void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file) +void gmyth_transcoder_set_filename (GMythTranscoder* transcoder, gchar* file) { + // fixme: if this method is called twice, memory will not be dealocated + // one transcoder can be used only for one file request? if (file != NULL) { gchar** splited = g_strsplit(file, "_", 2); // Get chanid - sscanf (splited[0],"%d", &(transcode->chanid)); + sscanf (splited[0],"%d", &(transcoder->chanid)); // Get starttime gchar** date = g_strsplit(splited[1], ".", 2); - transcode->starttime = gmyth_transcode_date_change_format(date[0], DATE_ISO); + transcoder->starttime = gmyth_transcode_date_change_format(date[0], DATE_ISO); - transcode->filename = g_strdup(file); + transcoder->filename = g_strdup(file); } } /** * - * gmyth_transcode_set_profile - * @brief set transcode's profile - * @param rec GMythTranscode* + * gmyth_transcoder_set_profile + * @brief set transcoder's profile + * @param rec GMythTranscoder* * @param value the value * @return gint representing the result * **/ -gint gmyth_transcode_set_profile (GMythTranscode* trans, +gint +gmyth_transcoder_set_profile (GMythTranscoder* trans, gchar* value) { - if (value != NULL) - trans->profile = g_strndup(value, strlen(value)); - else - return -1; + g_return_val_if_fail (value != NULL, -1); + + trans->profile = g_strndup(value, strlen(value)); return 0; } + +gboolean +gmyth_transcoder_start (GMythTranscoder* trans) +{ + g_return_val_if_fail (trans != NULL, FALSE); + + if (trans->started == FALSE) { // not started yet + trans->started = gmyth_jobqueue_add_job(trans, "JOB_TRANSCODE"); + if (trans->started == FALSE) + g_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename); + } else { + g_debug ("GMythTransfer already started!"); + } + + return trans->started; +} + +gboolean +gmyth_transcoder_pause (GMythTranscoder* trans) +{ + g_return_val_if_fail (trans != NULL, FALSE); + + return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE"); +} + +gboolean +gmyth_transcoder_resume (GMythTranscoder* trans) +{ + g_return_val_if_fail (trans != NULL, FALSE); + + return gmyth_jobqueue_change_cmd (trans, "RESUME", "JOB_TRANSCODE"); +} + +gboolean +gmyth_transcoder_cancel (GMythTranscoder* trans) +{ + g_return_val_if_fail (trans != NULL, FALSE); + + return gmyth_jobqueue_change_cmd (trans, "STOP", "JOB_TRANSCODE"); +} + +//fixme: implement this method +gint +gmyth_transcoder_get_progress (GMythTranscoder* trans) +{ + static int fixme = 0; + + return (fixme++)%101; +} diff -r 7c2dde09dc8a -r dbf952e956b5 gmyth/src/gmyth_transcode.h --- a/gmyth/src/gmyth_transcode.h Mon Mar 05 23:34:43 2007 +0000 +++ b/gmyth/src/gmyth_transcode.h Tue Mar 06 00:55:35 2007 +0000 @@ -1,9 +1,9 @@ /** * GMyth Library * - * @file gmyth/gmyth_transcode.h + * @file gmyth/gmyth_transcoder.h * - * @brief

This file contains the transcode class. + * @brief

This file contains the transcoder class. * * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. * @author Artur Duque de Souza @@ -26,8 +26,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef _GMYTH_TRANSCODE_H -#define _GMYTH_TRANSCODE_H +#ifndef _GMYTH_TRANSCODER_H +#define _GMYTH_TRANSCODER_H #include #include @@ -40,20 +40,20 @@ G_BEGIN_DECLS -#define GMYTH_TRANSCODE_TYPE (gmyth_transcode_get_type ()) -#define GMYTH_TRANSCODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODE_TYPE, GMythTranscode)) -#define GMYTH_TRANSCODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODE_TYPE, GMythTranscodeClass)) -#define IS_GMYTH_TRANSCODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODE_TYPE)) -#define IS_GMYTH_TRANSCODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODE_TYPE)) -#define GMYTH_TRANSCODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_TRANSCODE_TYPE, GMythTranscodeClass)) +#define GMYTH_TRANSCODER_TYPE (gmyth_transcoder_get_type ()) +#define GMYTH_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoder)) +#define GMYTH_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass)) +#define IS_GMYTH_TRANSCODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODER_TYPE)) +#define IS_GMYTH_TRANSCODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE)) +#define GMYTH_TRANSCODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass)) #define DATE_ISO 0 #define DATE_FILE 1 -typedef struct _GMythTranscode GMythTranscode; -typedef struct _GMythTranscodeClass GMythTranscodeClass; +typedef struct _GMythTranscoder GMythTranscoder; +typedef struct _GMythTranscoderClass GMythTranscoderClass; -struct _GMythTranscodeClass +struct _GMythTranscoderClass { GObjectClass parent_class; @@ -61,15 +61,16 @@ }; /** - * The GMythTranscode structure is a class to implement functions + * The GMythTranscoder structure is a class to implement functions * related to transcoding. */ -struct _GMythTranscode +struct _GMythTranscoder { GObject parent; gboolean cutlist; gboolean output; + gboolean started; /* private begin */ gchar* output_filename; @@ -84,17 +85,17 @@ GMythBackendInfo* backend_info; }; -GType gmyth_transcode_type (void); +GType gmyth_transcoder_type (void); -GMythTranscode* gmyth_transcode_new (void); +GMythTranscoder* gmyth_transcoder_new (GMythBackendInfo* backend_info); -void gmyth_transcode_set_output (GMythTranscode* transcode, +void gmyth_transcoder_set_output (GMythTranscoder* transcode, gboolean value, gchar* outputfile); -void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file); +void gmyth_transcoder_set_filename (GMythTranscoder* transcode, gchar* file); -gint gmyth_transcode_set_profile (GMythTranscode* trans, gchar* value); +gint gmyth_transcoder_set_profile (GMythTranscoder* trans, gchar* value); G_END_DECLS -#endif /*_GMYTH_TRANSCODE_H*/ +#endif /*_GMYTH_TRANSCODER_H*/