[svn r398] gmyth_transcode renamed to gmyth_transcoder. Besides, gmyth_transcoder_start/pause/resume/cancel methods were created trunk
authormelunko
Wed Mar 07 00:59:36 2007 +0000 (2007-03-07)
branchtrunk
changeset 3930dd110388c6f
parent 392 d6f7ca70f3c2
child 394 da672300b1ab
[svn r398] gmyth_transcode renamed to gmyth_transcoder. Besides, gmyth_transcoder_start/pause/resume/cancel methods were created
gmyth/src/Makefile.am
gmyth/src/gmyth.h
gmyth/src/gmyth_jobqueue.h
gmyth/src/gmyth_transcode.c
gmyth/src/gmyth_transcode.h
     1.1 --- a/gmyth/src/Makefile.am	Tue Mar 06 20:33:02 2007 +0000
     1.2 +++ b/gmyth/src/Makefile.am	Wed Mar 07 00:59:36 2007 +0000
     1.3 @@ -27,7 +27,7 @@
     1.4  	gmyth_http.c				\
     1.5  	gmyth_vlc.c					\
     1.6  	gmyth_jobqueue.c			\
     1.7 -	gmyth_transcode.c			\
     1.8 +	gmyth_transcoder.c			\
     1.9  	gmyth_recprofile.c			\
    1.10  	$(BUILT_SOURCES)
    1.11  
    1.12 @@ -87,7 +87,7 @@
    1.13  	gmyth_http.h				\
    1.14  	gmyth_vlc.h					\
    1.15  	gmyth_jobqueue.h			\
    1.16 -	gmyth_transcode.h			\
    1.17 +	gmyth_transcoder.h			\
    1.18  	gmyth_recprofile.h
    1.19  
    1.20  CLEANFILES = $(BUILT_SOURCES)
     2.1 --- a/gmyth/src/gmyth.h	Tue Mar 06 20:33:02 2007 +0000
     2.2 +++ b/gmyth/src/gmyth.h	Wed Mar 07 00:59:36 2007 +0000
     2.3 @@ -49,7 +49,7 @@
     2.4  #include <gmyth_http.h>
     2.5  #include <gmyth_vlc.h>
     2.6  #include <gmyth_jobqueue.h>
     2.7 -#include <gmyth_transcode.h>
     2.8 +#include <gmyth_transcoder.h>
     2.9  #include <gmyth_recprofile.h>
    2.10  
    2.11  #endif /* _GMYTH_H_ */
     3.1 --- a/gmyth/src/gmyth_jobqueue.h	Tue Mar 06 20:33:02 2007 +0000
     3.2 +++ b/gmyth/src/gmyth_jobqueue.h	Wed Mar 07 00:59:36 2007 +0000
     3.3 @@ -38,14 +38,14 @@
     3.4  
     3.5  #include "gmyth_stringlist.h"
     3.6  #include "gmyth_backendinfo.h"
     3.7 -#include "gmyth_transcode.h"
     3.8 +#include "gmyth_transcoder.h"
     3.9  #include "gmyth_socket.h"
    3.10  #include "gmyth_util.h"
    3.11  
    3.12  G_BEGIN_DECLS
    3.13  
    3.14 -gint gmyth_jobqueue_add_job (GMythTranscoder* transcode, gchar* job);
    3.15 -gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcode, gchar* action,
    3.16 +gint gmyth_jobqueue_add_job (GMythTranscoder* transcoder, gchar* job);
    3.17 +gint gmyth_jobqueue_change_cmd (GMythTranscoder* transcoder, gchar* action,
    3.18                                  gchar* job);
    3.19  
    3.20  G_END_DECLS
     4.1 --- a/gmyth/src/gmyth_transcode.c	Tue Mar 06 20:33:02 2007 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,261 +0,0 @@
     4.4 -/**
     4.5 - * GMyth Library
     4.6 - * 
     4.7 - * @file gmyth/gmyth_transcoder.c
     4.8 - * 
     4.9 - * @brief <p> This file contains the transcoder class.
    4.10 - *
    4.11 - * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
    4.12 - * @author Artur Duque de Souza <artur.souza@indt.org.br>
    4.13 - *
    4.14 - */
    4.15 -/*
    4.16 - * 
    4.17 - * This program is free software; you can redistribute it and/or modify
    4.18 - * it under the terms of the GNU Lesser General Public License as published by
    4.19 - * the Free Software Foundation; either version 2 of the License, or
    4.20 - * (at your option) any later version.
    4.21 - *
    4.22 - * This program is distributed in the hope that it will be useful,
    4.23 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.24 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    4.25 - * GNU General Public License for more details.
    4.26 - *
    4.27 - * You should have received a copy of the GNU Lesser General Public License
    4.28 - * along with this program; if not, write to the Free Software
    4.29 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.30 - */
    4.31 -
    4.32 - 
    4.33 -#ifdef HAVE_CONFIG_H
    4.34 -#include "config.h"
    4.35 -#endif
    4.36 -
    4.37 -#include <stdlib.h>
    4.38 -#include <string.h>
    4.39 -#include <assert.h>
    4.40 -
    4.41 -#include "gmyth_util.h"
    4.42 -#include "gmyth_debug.h"
    4.43 -
    4.44 -#include "gmyth_jobqueue.h"
    4.45 -#include "gmyth_transcode.h"
    4.46 -
    4.47 -static void gmyth_transcoder_class_init          (GMythTranscoderClass *klass);
    4.48 -static void gmyth_transcoder_init                (GMythTranscoder *object);
    4.49 -
    4.50 -static void gmyth_transcoder_dispose  (GObject *object);
    4.51 -static void gmyth_transcoder_finalize (GObject *object);
    4.52 -
    4.53 -G_DEFINE_TYPE(GMythTranscoder, gmyth_transcoder, G_TYPE_OBJECT)
    4.54 -
    4.55 -static void
    4.56 -gmyth_transcoder_class_init (GMythTranscoderClass *klass)
    4.57 -{
    4.58 -    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
    4.59 -    gobject_class->dispose  = gmyth_transcoder_dispose;
    4.60 -    gobject_class->finalize = gmyth_transcoder_finalize;
    4.61 -}
    4.62 -
    4.63 -static void
    4.64 -gmyth_transcoder_init (GMythTranscoder *transcoder)
    4.65 -{
    4.66 -    transcoder->started = FALSE;
    4.67 -}
    4.68 -
    4.69 -static void
    4.70 -gmyth_transcoder_dispose  (GObject *object)
    4.71 -{
    4.72 -    GMythTranscoder *transcoder = GMYTH_TRANSCODER(object);
    4.73 -
    4.74 -    g_free (transcoder->output_filename);
    4.75 -    g_free (transcoder->filename);
    4.76 -    g_free (transcoder->profile);
    4.77 -    g_free (transcoder->starttime);
    4.78 -
    4.79 -    if (transcoder->backend_info)
    4.80 -	g_object_unref (transcoder->backend_info);
    4.81 -
    4.82 -    G_OBJECT_CLASS (gmyth_transcoder_parent_class)->dispose (object);
    4.83 -}
    4.84 -
    4.85 -static void
    4.86 -gmyth_transcoder_finalize (GObject *object)
    4.87 -{
    4.88 -    g_signal_handlers_destroy (object);
    4.89 -    G_OBJECT_CLASS (gmyth_transcoder_parent_class)->finalize (object);
    4.90 -}
    4.91 -
    4.92 -/**
    4.93 - * Creates a new instance of GMythTranscoder.
    4.94 - * 
    4.95 - * @return a new instance of GMythTranscoder.
    4.96 - **/
    4.97 -GMythTranscoder*
    4.98 -gmyth_transcoder_new (GMythBackendInfo *backend_info)
    4.99 -{
   4.100 -    GMythTranscoder *transcoder = GMYTH_TRANSCODER\
   4.101 -                                 (g_object_new(GMYTH_TRANSCODER_TYPE, NULL));
   4.102 -
   4.103 -    g_object_ref (backend_info);
   4.104 -    transcoder->backend_info = backend_info;
   4.105 -
   4.106 -    return transcoder;
   4.107 -}
   4.108 -
   4.109 -/**
   4.110 - *
   4.111 - * gmyth_transcoder_date_change_format
   4.112 - * @brief converts a string like YYYY-MM-DDTHH:MM:SS into YYYYMMDDHHMMSS (vice versa)
   4.113 - * @param date_s gchar*
   4.114 - * @return gchar* with file or iso format
   4.115 - *
   4.116 - **/
   4.117 -static gchar* 
   4.118 -gmyth_transcoder_date_change_format (gchar* date_s, int format)
   4.119 -{
   4.120 -    if (date_s != NULL)
   4.121 -    {
   4.122 -        gint length = strlen(date_s);
   4.123 -
   4.124 -        //create the right date format
   4.125 -        gchar* src = (gchar*)g_malloc0(sizeof(gchar) * length);
   4.126 -        strncpy(src, date_s, length);
   4.127 -
   4.128 -        gchar* dst;
   4.129 -
   4.130 -        if (format == DATE_FILE)
   4.131 -        {
   4.132 -            dst = (gchar*)g_malloc0(sizeof(gchar) * 16);
   4.133 -            snprintf(dst, 16, "%.4s%.2s%.2s%.2s%.2s%.2s", src, src+5,\
   4.134 -                    src+7, src+9, src+11, src+13);
   4.135 -            dst[15] = '\0';
   4.136 -        } else if (format == DATE_ISO) {
   4.137 -            dst = (gchar*)g_malloc0(sizeof(gchar) * 20);
   4.138 -            snprintf(dst, 20, "%.4s-%.2s-%.2sT%.2s:%.2s:%.2s", src, src+4,\
   4.139 -                    src+6, src+8, src+10, src+12);
   4.140 -            dst[19] = '\0';
   4.141 -        }
   4.142 -
   4.143 -        gchar* ret = g_strdup(dst);
   4.144 -
   4.145 -        g_free(src);
   4.146 -        g_free(dst);
   4.147 -
   4.148 -        return ret;
   4.149 -    }
   4.150 -    else return NULL;
   4.151 -}
   4.152 -
   4.153 -/**
   4.154 - *
   4.155 - * gmyth_transcoder_set_output
   4.156 - * @brief set transcoder to use output
   4.157 - * @param value gboolean
   4.158 - * @param outfile filename of output
   4.159 - * @return void set's up the var to value
   4.160 - *
   4.161 - **/
   4.162 -void gmyth_transcoder_set_output (GMythTranscoder* transcoder,
   4.163 -                                 gboolean value, gchar* outputfile)
   4.164 -{
   4.165 -    transcoder->output = value;
   4.166 -    transcoder->output_filename = g_strdup(outputfile);
   4.167 -}
   4.168 -
   4.169 -/**
   4.170 - *
   4.171 - * gmyth_transcoder_set_file
   4.172 - * @brief set the file to transcoder
   4.173 - * @param file filename
   4.174 - * @return void set's up the var to value
   4.175 - *
   4.176 - **/
   4.177 -void gmyth_transcoder_set_filename (GMythTranscoder* transcoder, gchar* file)
   4.178 -{
   4.179 -    // fixme: if this method is called twice, memory will not be dealocated
   4.180 -    // one transcoder can be used only for one file request?
   4.181 -    if (file != NULL)
   4.182 -    {
   4.183 -        gchar** splited = g_strsplit(file, "_", 2);
   4.184 -
   4.185 -        // Get chanid
   4.186 -        sscanf (splited[0],"%d", &(transcoder->chanid));
   4.187 -
   4.188 -        // Get starttime
   4.189 -        gchar** date = g_strsplit(splited[1], ".", 2);
   4.190 -        transcoder->starttime = gmyth_transcoder_date_change_format(date[0], DATE_ISO);
   4.191 -
   4.192 -        transcoder->filename = g_strdup(file);
   4.193 -    }
   4.194 -}
   4.195 -
   4.196 -
   4.197 -/**
   4.198 - *
   4.199 - * gmyth_transcoder_set_profile
   4.200 - * @brief set transcoder's profile
   4.201 - * @param rec GMythTranscoder*
   4.202 - * @param value the value
   4.203 - * @return gint representing the result
   4.204 - *
   4.205 - **/
   4.206 -gint
   4.207 -gmyth_transcoder_set_profile (GMythTranscoder* trans,
   4.208 -                                  gchar* value)
   4.209 -{
   4.210 -    g_return_val_if_fail (value != NULL, -1);
   4.211 -
   4.212 -    trans->profile = g_strndup(value, strlen(value));
   4.213 -
   4.214 -    return 0;
   4.215 -}
   4.216 -
   4.217 -gboolean
   4.218 -gmyth_transcoder_start (GMythTranscoder* trans)
   4.219 -{
   4.220 -    g_return_val_if_fail (trans != NULL, FALSE);
   4.221 -
   4.222 -    if (trans->started == FALSE) { // not started yet
   4.223 -        trans->started = gmyth_jobqueue_add_job(trans, "JOB_TRANSCODE");
   4.224 -	if (trans->started == FALSE)
   4.225 -	    g_debug ("Error while starting GMythTranscoder to file: %s", trans->output_filename);
   4.226 -    } else {
   4.227 -	g_debug ("GMythTransfer already started!");
   4.228 -    }
   4.229 -
   4.230 -    return trans->started;
   4.231 -}
   4.232 -
   4.233 -gboolean
   4.234 -gmyth_transcoder_pause (GMythTranscoder* trans)
   4.235 -{
   4.236 -    g_return_val_if_fail (trans != NULL, FALSE);
   4.237 -
   4.238 -    return gmyth_jobqueue_change_cmd (trans, "PAUSE", "JOB_TRANSCODE");
   4.239 -}
   4.240 -
   4.241 -gboolean
   4.242 -gmyth_transcoder_resume (GMythTranscoder* trans)
   4.243 -{
   4.244 -    g_return_val_if_fail (trans != NULL, FALSE);
   4.245 -
   4.246 -    return gmyth_jobqueue_change_cmd (trans, "RESUME", "JOB_TRANSCODE");
   4.247 -}
   4.248 -
   4.249 -gboolean
   4.250 -gmyth_transcoder_cancel (GMythTranscoder* trans)
   4.251 -{
   4.252 -    g_return_val_if_fail (trans != NULL, FALSE);
   4.253 -
   4.254 -    return gmyth_jobqueue_change_cmd (trans, "STOP", "JOB_TRANSCODE");
   4.255 -}
   4.256 -
   4.257 -//fixme: implement this method
   4.258 -gint
   4.259 -gmyth_transcoder_get_progress (GMythTranscoder* trans)
   4.260 -{
   4.261 -    static int fixme = 0;
   4.262 -    
   4.263 -    return (fixme++)%101;
   4.264 -}
     5.1 --- a/gmyth/src/gmyth_transcode.h	Tue Mar 06 20:33:02 2007 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,101 +0,0 @@
     5.4 -/**
     5.5 - * GMyth Library
     5.6 - * 
     5.7 - * @file gmyth/gmyth_transcoder.h
     5.8 - * 
     5.9 - * @brief <p> This file contains the transcoder class.
    5.10 - *
    5.11 - * Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
    5.12 - * @author Artur Duque de Souza <artur.souza@indt.org.br>
    5.13 - *
    5.14 - */
    5.15 -/*
    5.16 - * 
    5.17 - * This program is free software; you can redistribute it and/or modify
    5.18 - * it under the terms of the GNU Lesser General Public License as published by
    5.19 - * the Free Software Foundation; either version 2 of the License, or
    5.20 - * (at your option) any later version.
    5.21 - *
    5.22 - * This program is distributed in the hope that it will be useful,
    5.23 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.24 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    5.25 - * GNU General Public License for more details.
    5.26 - *
    5.27 - * You should have received a copy of the GNU Lesser General Public License
    5.28 - * along with this program; if not, write to the Free Software
    5.29 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.30 - */
    5.31 -
    5.32 -#ifndef _GMYTH_TRANSCODER_H
    5.33 -#define _GMYTH_TRANSCODER_H
    5.34 -
    5.35 -#include <glib.h>
    5.36 -#include <glib-object.h>
    5.37 -
    5.38 -#include "gmyth_stringlist.h"
    5.39 -#include "gmyth_backendinfo.h"
    5.40 -#include "gmyth_socket.h"
    5.41 -#include "gmyth_http.h"
    5.42 -#include "gmyth_recprofile.h"
    5.43 -
    5.44 -G_BEGIN_DECLS
    5.45 -
    5.46 -#define GMYTH_TRANSCODER_TYPE               (gmyth_transcoder_get_type ())
    5.47 -#define GMYTH_TRANSCODER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoder))
    5.48 -#define GMYTH_TRANSCODER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass))
    5.49 -#define IS_GMYTH_TRANSCODER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_TRANSCODER_TYPE))
    5.50 -#define IS_GMYTH_TRANSCODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_TRANSCODER_TYPE))
    5.51 -#define GMYTH_TRANSCODER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_TRANSCODER_TYPE, GMythTranscoderClass))
    5.52 -
    5.53 -#define DATE_ISO 0
    5.54 -#define DATE_FILE 1
    5.55 -
    5.56 -typedef struct _GMythTranscoder         GMythTranscoder;
    5.57 -typedef struct _GMythTranscoderClass    GMythTranscoderClass;
    5.58 -
    5.59 -struct _GMythTranscoderClass
    5.60 -{
    5.61 -  GObjectClass parent_class;
    5.62 -
    5.63 -  /* callbacks */
    5.64 -};
    5.65 -
    5.66 -/**
    5.67 - * The GMythTranscoder structure is a class to implement functions
    5.68 - * related to transcoding.
    5.69 - */
    5.70 -struct _GMythTranscoder
    5.71 -{
    5.72 -    GObject parent;
    5.73 -
    5.74 -    gboolean cutlist;
    5.75 -    gboolean output;
    5.76 -    gboolean started;
    5.77 -
    5.78 -    /* private begin */
    5.79 -    gchar* output_filename;
    5.80 -    gchar* filename;
    5.81 -    gchar* profile;
    5.82 -    /* private end */
    5.83 -
    5.84 -    gchar* starttime;
    5.85 -
    5.86 -    gint chanid;
    5.87 -
    5.88 -    GMythBackendInfo* backend_info;
    5.89 -};
    5.90 -
    5.91 -GType gmyth_transcoder_type (void);
    5.92 -
    5.93 -GMythTranscoder* gmyth_transcoder_new (GMythBackendInfo* backend_info);
    5.94 -
    5.95 -void gmyth_transcoder_set_output (GMythTranscoder* transcode,
    5.96 -                                 gboolean value, gchar* outputfile);
    5.97 -
    5.98 -void gmyth_transcoder_set_filename (GMythTranscoder* transcode, gchar* file);
    5.99 -
   5.100 -gint gmyth_transcoder_set_profile (GMythTranscoder* trans, gchar* value);
   5.101 -
   5.102 -G_END_DECLS
   5.103 -
   5.104 -#endif /*_GMYTH_TRANSCODER_H*/