# HG changeset patch # User melunko # Date 1173229176 0 # Node ID 0dd110388c6f5ca583c0a0ee0eadf14bf735c907 # Parent d6f7ca70f3c249f96b1ee8fdbea803c9a32c2278 [svn r398] gmyth_transcode renamed to gmyth_transcoder. Besides, gmyth_transcoder_start/pause/resume/cancel methods were created diff -r d6f7ca70f3c2 -r 0dd110388c6f gmyth/src/Makefile.am --- a/gmyth/src/Makefile.am Tue Mar 06 20:33:02 2007 +0000 +++ b/gmyth/src/Makefile.am Wed Mar 07 00:59:36 2007 +0000 @@ -27,7 +27,7 @@ gmyth_http.c \ gmyth_vlc.c \ gmyth_jobqueue.c \ - gmyth_transcode.c \ + gmyth_transcoder.c \ gmyth_recprofile.c \ $(BUILT_SOURCES) @@ -87,7 +87,7 @@ gmyth_http.h \ gmyth_vlc.h \ gmyth_jobqueue.h \ - gmyth_transcode.h \ + gmyth_transcoder.h \ gmyth_recprofile.h CLEANFILES = $(BUILT_SOURCES) diff -r d6f7ca70f3c2 -r 0dd110388c6f gmyth/src/gmyth.h --- a/gmyth/src/gmyth.h Tue Mar 06 20:33:02 2007 +0000 +++ b/gmyth/src/gmyth.h Wed Mar 07 00:59:36 2007 +0000 @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #endif /* _GMYTH_H_ */ diff -r d6f7ca70f3c2 -r 0dd110388c6f gmyth/src/gmyth_jobqueue.h --- a/gmyth/src/gmyth_jobqueue.h Tue Mar 06 20:33:02 2007 +0000 +++ b/gmyth/src/gmyth_jobqueue.h Wed Mar 07 00:59:36 2007 +0000 @@ -38,14 +38,14 @@ #include "gmyth_stringlist.h" #include "gmyth_backendinfo.h" -#include "gmyth_transcode.h" +#include "gmyth_transcoder.h" #include "gmyth_socket.h" #include "gmyth_util.h" G_BEGIN_DECLS -gint gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job); -gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action, +gint gmyth_jobqueue_add_job (GMythTranscoder* transcoder, gchar* job); +gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcoder, gchar* action, gchar* job); G_END_DECLS diff -r d6f7ca70f3c2 -r 0dd110388c6f gmyth/src/gmyth_transcode.c --- a/gmyth/src/gmyth_transcode.c Tue Mar 06 20:33:02 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,261 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_transcoder.c - * - * @brief

This file contains the transcoder class. - * - * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. - * @author Artur Duque de Souza - * - */ -/* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include "gmyth_util.h" -#include "gmyth_debug.h" - -#include "gmyth_jobqueue.h" -#include "gmyth_transcode.h" - -static void gmyth_transcoder_class_init (GMythTranscoderClass *klass); -static void gmyth_transcoder_init (GMythTranscoder *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_transcoder_class_init (GMythTranscoderClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - gobject_class->dispose = gmyth_transcoder_dispose; - gobject_class->finalize = gmyth_transcoder_finalize; -} - -static void -gmyth_transcoder_init (GMythTranscoder *transcoder) -{ - transcoder->started = FALSE; -} - -static void -gmyth_transcoder_dispose (GObject *object) -{ - GMythTranscoder *transcoder = GMYTH_TRANSCODER(object); - - g_free (transcoder->output_filename); - g_free (transcoder->filename); - g_free (transcoder->profile); - g_free (transcoder->starttime); - - if (transcoder->backend_info) - g_object_unref (transcoder->backend_info); - - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object); -} - -static void -gmyth_transcoder_finalize (GObject *object) -{ - g_signal_handlers_destroy (object); - G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object); -} - -/** - * Creates a new instance of GMythTranscoder. - * - * @return a new instance of GMythTranscoder. - **/ -GMythTranscoder* -gmyth_transcoder_new (GMythBackendInfo *backend_info) -{ - GMythTranscoder *transcoder = GMYTH_TRANSCODER\ - (g_object_new(GMYTH_TRANSCODER_TYPE, NULL)); - - g_object_ref (backend_info); - transcoder->backend_info = backend_info; - - return transcoder; -} - -/** - * - * 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 - * - **/ -static gchar* -gmyth_transcoder_date_change_format (gchar* date_s, int format) -{ - if (date_s != NULL) - { - gint length = strlen(date_s); - - //create the right date format - gchar* src = (gchar*)g_malloc0(sizeof(gchar) * length); - strncpy(src, date_s, length); - - gchar* dst; - - if (format == DATE_FILE) - { - dst = (gchar*)g_malloc0(sizeof(gchar) * 16); - 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) { - 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'; - } - - gchar* ret = g_strdup(dst); - - g_free(src); - g_free(dst); - - return ret; - } - else return NULL; -} - -/** - * - * 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_transcoder_set_output (GMythTranscoder* transcoder, - gboolean value, gchar* outputfile) -{ - transcoder->output = value; - transcoder->output_filename = g_strdup(outputfile); -} - -/** - * - * gmyth_transcoder_set_file - * @brief set the file to transcoder - * @param file filename - * @return void set's up the var to value - * - **/ -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", &(transcoder->chanid)); - - // Get starttime - gchar** date = g_strsplit(splited[1], ".", 2); - transcoder->starttime = gmyth_transcoder_date_change_format(date[0], DATE_ISO); - - transcoder->filename = g_strdup(file); - } -} - - -/** - * - * gmyth_transcoder_set_profile - * @brief set transcoder's profile - * @param rec GMythTranscoder* - * @param value the value - * @return gint representing the result - * - **/ -gint -gmyth_transcoder_set_profile (GMythTranscoder* trans, - gchar* value) -{ - 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 d6f7ca70f3c2 -r 0dd110388c6f gmyth/src/gmyth_transcode.h --- a/gmyth/src/gmyth_transcode.h Tue Mar 06 20:33:02 2007 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +0,0 @@ -/** - * GMyth Library - * - * @file gmyth/gmyth_transcoder.h - * - * @brief

This file contains the transcoder class. - * - * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia. - * @author Artur Duque de Souza - * - */ -/* - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GMYTH_TRANSCODER_H -#define _GMYTH_TRANSCODER_H - -#include -#include - -#include "gmyth_stringlist.h" -#include "gmyth_backendinfo.h" -#include "gmyth_socket.h" -#include "gmyth_http.h" -#include "gmyth_recprofile.h" - -G_BEGIN_DECLS - -#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 _GMythTranscoder GMythTranscoder; -typedef struct _GMythTranscoderClass GMythTranscoderClass; - -struct _GMythTranscoderClass -{ - GObjectClass parent_class; - - /* callbacks */ -}; - -/** - * The GMythTranscoder structure is a class to implement functions - * related to transcoding. - */ -struct _GMythTranscoder -{ - GObject parent; - - gboolean cutlist; - gboolean output; - gboolean started; - - /* private begin */ - gchar* output_filename; - gchar* filename; - gchar* profile; - /* private end */ - - gchar* starttime; - - gint chanid; - - GMythBackendInfo* backend_info; -}; - -GType gmyth_transcoder_type (void); - -GMythTranscoder* gmyth_transcoder_new (GMythBackendInfo* backend_info); - -void gmyth_transcoder_set_output (GMythTranscoder* transcode, - gboolean value, gchar* outputfile); - -void gmyth_transcoder_set_filename (GMythTranscoder* transcode, gchar* file); - -gint gmyth_transcoder_set_profile (GMythTranscoder* trans, gchar* value); - -G_END_DECLS - -#endif /*_GMYTH_TRANSCODER_H*/