1.1 --- a/gmyth/src/gmyth_jobqueue.c Wed Feb 28 14:22:25 2007 +0000
1.2 +++ b/gmyth/src/gmyth_jobqueue.c Thu Mar 01 17:57:42 2007 +0000
1.3 @@ -94,7 +94,7 @@
1.4 */
1.5 gint test_result(gchar* ret, gchar* value)
1.6 {
1.7 - if (g_ascii_strcasecmp(ret, value))
1.8 + if (g_ascii_strcasecmp(ret, value) == 0)
1.9 return 0;
1.10 else
1.11 {
1.12 @@ -111,14 +111,14 @@
1.13 * @return the value of the key
1.14 *
1.15 */
1.16 -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, GString* job)
1.17 +gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job)
1.18 {
1.19 GMythSocket *socket = backend_connect(transcode->backend_info);
1.20 if (socket != NULL)
1.21 {
1.22 GString* options = g_string_new ("");
1.23
1.24 - if (g_ascii_strcasecmp(job->str, "JOB_TRANSCODE"))
1.25 + if (g_ascii_strcasecmp(job, "JOB_TRANSCODE") == 0)
1.26 {
1.27 if (transcode->cutlist)
1.28 g_string_append(options, " JOB_USE_CUTLIST");
1.29 @@ -131,7 +131,7 @@
1.30 g_string_append_printf(options, " %s", transcode->profile->str);
1.31 }
1.32
1.33 - GString* ret = send_command(socket, "ADD", job->str, transcode->chanid,
1.34 + GString* ret = send_command(socket, "ADD", job, transcode->chanid,
1.35 transcode->starttime->str, options->str);
1.36
1.37 return test_result(ret->str, "JOBQUEUE_OK");
1.38 @@ -151,13 +151,13 @@
1.39 * @return the value of the key
1.40 *
1.41 */
1.42 -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, GString* action,
1.43 - GString* job)
1.44 +gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action,
1.45 + gchar* job)
1.46 {
1.47 GMythSocket *socket = backend_connect(transcode->backend_info);
1.48 if (socket != NULL)
1.49 {
1.50 - GString* ret = send_command(socket, action->str, job->str,
1.51 + GString* ret = send_command(socket, action, job,
1.52 transcode->chanid,
1.53 transcode->starttime->str, "");
1.54
2.1 --- a/gmyth/src/gmyth_jobqueue.h Wed Feb 28 14:22:25 2007 +0000
2.2 +++ b/gmyth/src/gmyth_jobqueue.h Thu Mar 01 17:57:42 2007 +0000
2.3 @@ -44,9 +44,9 @@
2.4
2.5 G_BEGIN_DECLS
2.6
2.7 -gint gmyth_jobqueue_add_job (GMythTranscode* transcode, GString* job);
2.8 -gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, GString* action,
2.9 - GString* job);
2.10 +gint gmyth_jobqueue_add_job (GMythTranscode* transcode, gchar* job);
2.11 +gint gmyth_jobqueue_change_cmd (GMythTranscode* transcode, gchar* action,
2.12 + gchar* job);
2.13
2.14 G_END_DECLS
2.15
3.1 --- a/gmyth/src/gmyth_transcode.c Wed Feb 28 14:22:25 2007 +0000
3.2 +++ b/gmyth/src/gmyth_transcode.c Thu Mar 01 17:57:42 2007 +0000
3.3 @@ -52,13 +52,20 @@
3.4 {
3.5 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
3.6 gobject_class->dispose = gmyth_transcode_dispose;
3.7 - gobject_class->finalize = gmyth_transcode_finalize;
3.8 + gobject_class->finalize = gmyth_transcode_finalize;
3.9 }
3.10
3.11 static void
3.12 -gmyth_transcode_init (GMythTranscode *gmyth_transcode)
3.13 +gmyth_transcode_init (GMythTranscode *transcode)
3.14 {
3.15 + transcode->backend_info = NULL;
3.16 + transcode->output_filename = NULL;
3.17 + transcode->filename = NULL;
3.18 + transcode->profile = NULL;
3.19 + transcode->starttime = NULL;
3.20
3.21 + transcode->cutlist = FALSE;
3.22 + transcode->output = FALSE;
3.23 }
3.24
3.25 static void
3.26 @@ -109,30 +116,30 @@
3.27 * @return gchar* with file or iso format
3.28 *
3.29 **/
3.30 -GString* gmyth_transcode_date_change_format (GString* date_s, int format)
3.31 +GString* gmyth_transcode_date_change_format (gchar* date_s, int format)
3.32 {
3.33 - if (date_s->str != NULL)
3.34 + if (date_s != NULL)
3.35 {
3.36 - gint length = date_s->len;
3.37 + gint length = strlen(date_s);
3.38
3.39 //create the right date format
3.40 gchar* src = (gchar*)g_malloc0(sizeof(gchar) * length);
3.41 - strncpy(src, date_s->str, length);
3.42 + strncpy(src, date_s, length);
3.43
3.44 gchar* dst;
3.45
3.46 if (format == DATE_FILE)
3.47 {
3.48 dst = (gchar*)g_malloc0(sizeof(gchar) * 16);
3.49 - g_snprintf(dst, 20, "%.4s%.2s%.2s%.2s%.2s%.2s\n", src, src+5,\
3.50 + snprintf(dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src+5,\
3.51 src+7, src+9, src+11, src+13);
3.52 - dst[14] = '\0';
3.53 + dst[15] = '\0';
3.54 }
3.55 else
3.56 if (format == DATE_ISO)
3.57 {
3.58 - gchar* dst = (gchar*)g_malloc0(sizeof(gchar) * 20);
3.59 - g_snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s\n", src, src+4,\
3.60 + dst = (gchar*)g_malloc0(sizeof(gchar) * 20);
3.61 + snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src+4,\
3.62 src+6, src+8, src+10, src+12);
3.63 dst[19] = '\0';
3.64 }
3.65 @@ -149,20 +156,6 @@
3.66
3.67 /**
3.68 *
3.69 - * gmyth_transcode_set_cutlist
3.70 - * @brief set transcode to use cutlist
3.71 - * @param value gboolean
3.72 - * @return void set's up the var to value
3.73 - *
3.74 - **/
3.75 -void gmyth_transcode_set_cutlist (GMythTranscode* transcode,
3.76 - gboolean value)
3.77 -{
3.78 - transcode->cutlist = value;
3.79 -}
3.80 -
3.81 -/**
3.82 - *
3.83 * gmyth_transcode_set_output
3.84 * @brief set transcode to use output
3.85 * @param value gboolean
3.86 @@ -171,10 +164,10 @@
3.87 *
3.88 **/
3.89 void gmyth_transcode_set_output (GMythTranscode* transcode,
3.90 - gboolean value, GString* outputfile)
3.91 + gboolean value, gchar* outputfile)
3.92 {
3.93 transcode->output = value;
3.94 - transcode->output_filename = outputfile;
3.95 + transcode->output_filename = g_string_new(outputfile);
3.96 }
3.97
3.98 /**
3.99 @@ -185,28 +178,23 @@
3.100 * @return void set's up the var to value
3.101 *
3.102 **/
3.103 -void gmyth_transcode_set_filename (GMythTranscode* transcode,
3.104 - GString* file)
3.105 +void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file)
3.106 {
3.107 - transcode->filename = file;
3.108 + if (file != NULL)
3.109 + {
3.110 + gchar** splited = g_strsplit(file, "_", 2);
3.111 +
3.112 + // Get chanid
3.113 + sscanf (splited[0],"%d", &(transcode->chanid));
3.114 +
3.115 + // Get starttime
3.116 + gchar** date = g_strsplit(splited[1], ".", 2);
3.117 + transcode->starttime = gmyth_transcode_date_change_format(date[0], DATE_ISO);
3.118 +
3.119 + transcode->filename = g_string_new(file);
3.120 + }
3.121 }
3.122
3.123 -
3.124 -/**
3.125 - *
3.126 - * gmyth_transcode_set_backendinfo
3.127 - * @brief set transcode's backendinfo
3.128 - * @param backendinfo GMythBackendInfo
3.129 - * @return void set's up the var to value
3.130 - *
3.131 - **/
3.132 -void gmyth_transcode_set_backend (GMythTranscode* transcode,
3.133 - GMythBackendInfo *backend)
3.134 -{
3.135 - transcode->backend_info = backend;
3.136 -}
3.137 -
3.138 -
3.139 /**
3.140 *
3.141 * gmyth_transcode_get_profile_list
4.1 --- a/gmyth/src/gmyth_transcode.h Wed Feb 28 14:22:25 2007 +0000
4.2 +++ b/gmyth/src/gmyth_transcode.h Thu Mar 01 17:57:42 2007 +0000
4.3 @@ -64,15 +64,17 @@
4.4 */
4.5 struct _GMythTranscode
4.6 {
4.7 - /* all private members */
4.8 - GObject parent;
4.9 + GObject parent;
4.10
4.11 gboolean cutlist;
4.12 gboolean output;
4.13
4.14 + /* private begin */
4.15 GString* output_filename;
4.16 GString* filename;
4.17 GString* profile;
4.18 + /* private end */
4.19 +
4.20 GString* starttime;
4.21
4.22 gint chanid;
4.23 @@ -84,6 +86,11 @@
4.24
4.25 GMythTranscode* gmyth_transcode_new (void);
4.26
4.27 +void gmyth_transcode_set_output (GMythTranscode* transcode,
4.28 + gboolean value, gchar* outputfile);
4.29 +
4.30 +void gmyth_transcode_set_filename (GMythTranscode* transcode, gchar* file);
4.31 +
4.32 G_END_DECLS
4.33
4.34 #endif /*_GMYTH_TRANSCODE_H*/
5.1 --- a/gmyth/tests/compile Wed Feb 28 14:22:25 2007 +0000
5.2 +++ b/gmyth/tests/compile Thu Mar 01 17:57:42 2007 +0000
5.3 @@ -1,4 +1,3 @@
5.4 #!/bin/bash
5.5 +gcc -g $1 -o $2 `pkg-config --cflags --libs gmyth-0.1 glib-2.0 gthread-2.0`
5.6
5.7 -gcc -g $1 -o $2 `pkg-config --cflags --libs gmyth-0.1`
5.8 -
6.1 --- a/gmyth/tests/gmyth_test_transcode.c Wed Feb 28 14:22:25 2007 +0000
6.2 +++ b/gmyth/tests/gmyth_test_transcode.c Thu Mar 01 17:57:42 2007 +0000
6.3 @@ -1,83 +1,34 @@
6.4 -#include <glib-object.h>
6.5 -
6.6 +#include "gmyth_transcode.h"
6.7 #include "gmyth_uri.h"
6.8 #include "gmyth_backendinfo.h"
6.9 #include "gmyth_socket.h"
6.10 #include "gmyth_query.h"
6.11
6.12 -static gboolean
6.13 -backend_connect (GMythBackendInfo *backend_info)
6.14 -{
6.15 - GMythSocket *socket = gmyth_socket_new ();
6.16 - if (gmyth_socket_connect_to_backend (socket,
6.17 - gmyth_backend_info_get_hostname (backend_info),
6.18 - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
6.19 -
6.20 -
6.21 - g_debug ("Backend socket connection success");
6.22 - return TRUE;
6.23 - } else {
6.24 - g_debug ("Connection failed");
6.25 - return FALSE;
6.26 - }
6.27 -}
6.28 -
6.29 -static gboolean
6.30 -test_mysql_connection1 (GMythBackendInfo *backend_info)
6.31 -{
6.32 - GMythQuery *query = gmyth_query_new ();
6.33 -
6.34 - if (gmyth_query_connect_with_timeout (query, backend_info, 3) == TRUE) {
6.35 - g_debug ("Mysql connection success");
6.36 - return TRUE;
6.37 - } else {
6.38 - g_debug ("Mysql connection failed");
6.39 - return FALSE;
6.40 - }
6.41 -
6.42 -}
6.43 -
6.44 -
6.45 int
6.46 main (int args, const char **argv)
6.47 {
6.48 GMythBackendInfo *backend_info;
6.49 + GMythTranscode *transcode;
6.50 g_type_init ();
6.51 - //g_thread_init (NULL);
6.52 + g_thread_init (NULL);
6.53
6.54 -
6.55 backend_info = gmyth_backend_info_new ();
6.56 gmyth_backend_info_set_hostname (backend_info, "192.168.3.165");
6.57 gmyth_backend_info_set_port (backend_info, 6543);
6.58 gmyth_backend_info_set_status_port (backend_info, 6544);
6.59
6.60 + transcode = gmyth_transcode_new();
6.61
6.62 - GMythSocket *socket = gmyth_socket_new ();
6.63 - if (gmyth_socket_connect_to_backend (socket,
6.64 - gmyth_backend_info_get_hostname (backend_info),
6.65 - gmyth_backend_info_get_port (backend_info), TRUE) == TRUE) {
6.66 + transcode->backend_info = backend_info;
6.67 + transcode->cutlist = TRUE;
6.68
6.69 + gmyth_transcode_set_output (transcode, TRUE, "/tmp/teste.mp4");
6.70 + gmyth_transcode_set_filename (transcode, "1000_20061207123000.nuv");
6.71
6.72 - g_debug ("Backend socket connection success");
6.73 - } else {
6.74 - g_debug ("Connection failed");
6.75 - }
6.76 + int teste = gmyth_jobqueue_add_job(transcode, "JOB_TRANSCODE");
6.77
6.78 + teste = gmyth_jobqueue_change_cmd(transcode, "STOP", "JOB_TRANSCODE");
6.79
6.80 - GString *base_str = g_string_new ("");
6.81 - GMythStringList *strlist = gmyth_string_list_new();
6.82 -
6.83 - g_string_printf( base_str, "JOBQUEUE ADD JOB_TRANSCODE 1000 2006-12-07T12:30:00 JOB_USE_CUTLIST High Quality");
6.84 - gmyth_string_list_append_string (strlist, base_str );
6.85 - gmyth_socket_write_stringlist (socket, strlist );
6.86 -
6.87 - gmyth_socket_read_stringlist (socket, strlist );
6.88 -
6.89 - g_string_printf( base_str, "JOBQUEUE STOP JOB_TRANSCODE 1000 2006-12-07T12:30:00");
6.90 - gmyth_string_list_append_string (strlist, base_str );
6.91 - gmyth_socket_write_stringlist (socket, strlist );
6.92 -
6.93 - gmyth_socket_read_stringlist (socket, strlist );
6.94
6.95 }
6.96