# HG changeset patch # User morphbr # Date 1172771862 0 # Node ID e0dfe4bd83a20c38d2b5158ee58f2feae6eccf3f # Parent 9f82d680cfe1b10caadf01c9a0976f688fcdc9bc [svn r385] - Added gthread support inside "compile" script - Updated jobqueue.* and transcode.* - Updated gmyth_test_transcode.c diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/src/gmyth_jobqueue.c --- a/gmyth/src/gmyth_jobqueue.c Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/src/gmyth_jobqueue.c Thu Mar 01 17:57:42 2007 +0000 @@ -94,7 +94,7 @@ */ gint test_result(gchar* ret, gchar* value) { - if (g_ascii_strcasecmp(ret, value)) + if (g_ascii_strcasecmp(ret, value) == 0) return 0; else { @@ -111,14 +111,14 @@ * @return the value of the key * */ -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, GString* job) +gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job) { GMythSocket *socket = backend_connect(transcode->backend_info); if (socket != NULL) { GString* options = g_string_new (""); - if (g_ascii_strcasecmp(job->str, "JOB_TRANSCODE")) + if (g_ascii_strcasecmp(job, "JOB_TRANSCODE") == 0) { if (transcode->cutlist) g_string_append(options, " JOB_USE_CUTLIST"); @@ -131,7 +131,7 @@ g_string_append_printf(options, " %s", transcode->profile->str); } - GString* ret = send_command(socket, "ADD", job->str, transcode->chanid, + GString* ret = send_command(socket, "ADD", job, transcode->chanid, transcode->starttime->str, options->str); return test_result(ret->str, "JOBQUEUE_OK"); @@ -151,13 +151,13 @@ * @return the value of the key * */ -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, GString* action, - GString* job) +gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action, + gchar* job) { GMythSocket *socket = backend_connect(transcode->backend_info); if (socket != NULL) { - GString* ret = send_command(socket, action->str, job->str, + GString* ret = send_command(socket, action, job, transcode->chanid, transcode->starttime->str, ""); diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/src/gmyth_jobqueue.h --- a/gmyth/src/gmyth_jobqueue.h Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/src/gmyth_jobqueue.h Thu Mar 01 17:57:42 2007 +0000 @@ -44,9 +44,9 @@ G_BEGIN_DECLS -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, GString* job); -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, GString* action, - GString* job); +gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job); +gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action, + gchar* job); G_END_DECLS diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/src/gmyth_transcode.c --- a/gmyth/src/gmyth_transcode.c Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/src/gmyth_transcode.c Thu Mar 01 17:57:42 2007 +0000 @@ -52,13 +52,20 @@ { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->dispose = gmyth_transcode_dispose; - gobject_class->finalize = gmyth_transcode_finalize; + gobject_class->finalize = gmyth_transcode_finalize; } static void -gmyth_transcode_init (GMythTranscode *gmyth_transcode) +gmyth_transcode_init (GMythTranscode *transcode) { + transcode->backend_info = NULL; + transcode->output_filename = NULL; + transcode->filename = NULL; + transcode->profile = NULL; + transcode->starttime = NULL; + transcode->cutlist = FALSE; + transcode->output = FALSE; } static void @@ -109,30 +116,30 @@ * @return gchar* with file or iso format * **/ -GString* gmyth_transcode_date_change_format (GString* date_s, int format) +GString* gmyth_transcode_date_change_format (gchar* date_s, int format) { - if (date_s->str != NULL) + if (date_s != NULL) { - gint length = date_s->len; + gint length = strlen(date_s); //create the right date format gchar* src = (gchar*)g_malloc0(sizeof(gchar) * length); - strncpy(src, date_s->str, length); + strncpy(src, date_s, length); gchar* dst; if (format == DATE_FILE) { dst = (gchar*)g_malloc0(sizeof(gchar) * 16); - g_snprintf(dst, 20, "%.4s%.2s%.2s%.2s%.2s%.2s\n", src, src+5,\ + snprintf(dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src+5,\ src+7, src+9, src+11, src+13); - dst[14] = '\0'; + dst[15] = '\0'; } else if (format == DATE_ISO) { - gchar* dst = (gchar*)g_malloc0(sizeof(gchar) * 20); - g_snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s\n", src, src+4,\ + 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); dst[19] = '\0'; } @@ -149,20 +156,6 @@ /** * - * gmyth_transcode_set_cutlist - * @brief set transcode to use cutlist - * @param value gboolean - * @return void set's up the var to value - * - **/ -void gmyth_transcode_set_cutlist (GMythTranscode* transcode, - gboolean value) -{ - transcode->cutlist = value; -} - -/** - * * gmyth_transcode_set_output * @brief set transcode to use output * @param value gboolean @@ -171,10 +164,10 @@ * **/ void gmyth_transcode_set_output (GMythTranscode* transcode, - gboolean value, GString* outputfile) + gboolean value, gchar* outputfile) { transcode->output = value; - transcode->output_filename = outputfile; + transcode->output_filename = g_string_new(outputfile); } /** @@ -185,28 +178,23 @@ * @return void set's up the var to value * **/ -void gmyth_transcode_set_filename (GMythTranscode* transcode, - GString* file) +void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file) { - transcode->filename = file; + if (file != NULL) + { + gchar** splited = g_strsplit(file, "_", 2); + + // Get chanid + sscanf (splited[0],"%d", &(transcode->chanid)); + + // Get starttime + gchar** date = g_strsplit(splited[1], ".", 2); + transcode->starttime = gmyth_transcode_date_change_format(date[0], DATE_ISO); + + transcode->filename = g_string_new(file); + } } - -/** - * - * gmyth_transcode_set_backendinfo - * @brief set transcode's backendinfo - * @param backendinfo GMythBackendInfo - * @return void set's up the var to value - * - **/ -void gmyth_transcode_set_backend (GMythTranscode* transcode, - GMythBackendInfo *backend) -{ - transcode->backend_info = backend; -} - - /** * * gmyth_transcode_get_profile_list diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/src/gmyth_transcode.h --- a/gmyth/src/gmyth_transcode.h Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/src/gmyth_transcode.h Thu Mar 01 17:57:42 2007 +0000 @@ -64,15 +64,17 @@ */ struct _GMythTranscode { - /* all private members */ - GObject parent; + GObject parent; gboolean cutlist; gboolean output; + /* private begin */ GString* output_filename; GString* filename; GString* profile; + /* private end */ + GString* starttime; gint chanid; @@ -84,6 +86,11 @@ GMythTranscode* gmyth_transcode_new (void); +void gmyth_transcode_set_output (GMythTranscode* transcode, + gboolean value, gchar* outputfile); + +void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file); + G_END_DECLS #endif /*_GMYTH_TRANSCODE_H*/ diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/tests/compile --- a/gmyth/tests/compile Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/tests/compile Thu Mar 01 17:57:42 2007 +0000 @@ -1,4 +1,3 @@ #!/bin/bash +gcc -g $1 -o $2 `pkg-config --cflags --libs gmyth-0.1 glib-2.0 gthread-2.0` -gcc -g $1 -o $2 `pkg-config --cflags --libs gmyth-0.1` - diff -r 9f82d680cfe1 -r e0dfe4bd83a2 gmyth/tests/gmyth_test_transcode.c --- a/gmyth/tests/gmyth_test_transcode.c Wed Feb 28 14:22:25 2007 +0000 +++ b/gmyth/tests/gmyth_test_transcode.c Thu Mar 01 17:57:42 2007 +0000 @@ -1,83 +1,34 @@ -#include - +#include "gmyth_transcode.h" #include "gmyth_uri.h" #include "gmyth_backendinfo.h" #include "gmyth_socket.h" #include "gmyth_query.h" -static gboolean -backend_connect (GMythBackendInfo *backend_info) -{ - GMythSocket *socket = gmyth_socket_new (); - if (gmyth_socket_connect_to_backend (socket, - gmyth_backend_info_get_hostname (backend_info), - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { - - - g_debug ("Backend socket connection success"); - return TRUE; - } else { - g_debug ("Connection failed"); - return FALSE; - } -} - -static gboolean -test_mysql_connection1 (GMythBackendInfo *backend_info) -{ - GMythQuery *query = gmyth_query_new (); - - if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) { - g_debug ("Mysql connection success"); - return TRUE; - } else { - g_debug ("Mysql connection failed"); - return FALSE; - } - -} - - int main (int args, const char **argv) { GMythBackendInfo *backend_info; + GMythTranscode *transcode; g_type_init (); - //g_thread_init (NULL); + g_thread_init (NULL); - backend_info = gmyth_backend_info_new (); gmyth_backend_info_set_hostname (backend_info, "192.168.3.165"); gmyth_backend_info_set_port (backend_info, 6543); gmyth_backend_info_set_status_port (backend_info, 6544); + transcode = gmyth_transcode_new(); - GMythSocket *socket = gmyth_socket_new (); - if (gmyth_socket_connect_to_backend (socket, - gmyth_backend_info_get_hostname (backend_info), - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) { + transcode->backend_info = backend_info; + transcode->cutlist = TRUE; + gmyth_transcode_set_output (transcode, TRUE, "/tmp/teste.mp4"); + gmyth_transcode_set_filename (transcode, "1000_20061207123000.nuv"); - g_debug ("Backend socket connection success"); - } else { - g_debug ("Connection failed"); - } + int teste = gmyth_jobqueue_add_job(transcode, "JOB_TRANSCODE"); + teste = gmyth_jobqueue_change_cmd(transcode, "STOP", "JOB_TRANSCODE"); - GString *base_str = g_string_new (""); - GMythStringList *strlist = gmyth_string_list_new(); - - g_string_printf( base_str, "JOBQUEUE ADD JOB_TRANSCODE 1000 2006-12-07T12:30:00 JOB_USE_CUTLIST High Quality"); - gmyth_string_list_append_string (strlist, base_str ); - gmyth_socket_write_stringlist (socket, strlist ); - - gmyth_socket_read_stringlist (socket, strlist ); - - g_string_printf( base_str, "JOBQUEUE STOP JOB_TRANSCODE 1000 2006-12-07T12:30:00"); - gmyth_string_list_append_string (strlist, base_str ); - gmyth_socket_write_stringlist (socket, strlist ); - - gmyth_socket_read_stringlist (socket, strlist ); }