branches/gmyth-0.1b/src/gmyth_file_transfer.h
author rosfran
Wed Feb 07 20:38:39 2007 +0000 (2007-02-07)
branchtrunk
changeset 333 f9d778bb88a2
permissions -rwxr-xr-x
[svn r335] Some fixes to the do_get_file_info.
     1 /* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */
     2 /**
     3  * GMyth Library
     4  *
     5  * @file gmyth/gmyth_file_transfer.h
     6  * 
     7  * @brief <p> GMythFileTransfer deals with the file streaming media remote/local
     8  * transfering to the MythTV frontend.
     9  *
    10  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    11  * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
    12  *
    13  *//*
    14  * 
    15  * This program is free software; you can redistribute it and/or modify
    16  * it under the terms of the GNU Lesser General Public License as published by
    17  * the Free Software Foundation; either version 2 of the License, or
    18  * (at your option) any later version.
    19  *
    20  * This program is distributed in the hope that it will be useful,
    21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    23  * GNU General Public License for more details.
    24  *
    25  * You should have received a copy of the GNU Lesser General Public License
    26  * along with this program; if not, write to the Free Software
    27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    28  */
    29  
    30 #ifndef __GMYTH_FILE_TRANSFER_H__
    31 #define __GMYTH_FILE_TRANSFER_H__
    32 
    33 #include <glib-object.h>
    34 #include <glib.h>
    35 
    36 #include "gmyth_socket.h"
    37 #include "gmyth_uri.h"
    38 #include "gmyth_backendinfo.h"
    39 
    40 #include <stdio.h>
    41 #include <stdlib.h>
    42 #include <string.h>
    43 #include <netdb.h>
    44 #include <sys/socket.h>
    45 #include <unistd.h>
    46 
    47 G_BEGIN_DECLS
    48 
    49 #define GMYTH_FILE_TRANSFER_TYPE               (gmyth_file_transfer_get_type ())
    50 #define GMYTH_FILE_TRANSFER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransfer))
    51 #define GMYTH_FILE_TRANSFER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferClass))
    52 #define IS_GMYTH_FILE_TRANSFER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_TRANSFER_TYPE))
    53 #define IS_GMYTH_FILE_TRANSFER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_TRANSFER_TYPE))
    54 #define GMYTH_FILE_TRANSFER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_TRANSFER_TYPE, GMythFileTransferClass))
    55 
    56 #define GMYTHTV_FILE_TRANSFER_READ_ERROR					-314
    57 #define GMYTHTV_FILE_TRANSFER_NEXT_PROG_CHAIN			-315
    58 
    59 typedef struct _GMythFileTransfer         GMythFileTransfer;
    60 typedef struct _GMythFileTransferClass    GMythFileTransferClass;
    61 typedef struct _GMythFileTransferPrivate  GMythFileTransferPrivate;
    62 
    63 struct _GMythFileTransferClass
    64 {
    65 	GObjectClass parent_class;
    66 
    67 	/* callbacks */
    68 	guint program_info_changed_handler_signal_id;
    69 
    70   /* signal default handlers */
    71   void (*program_info_changed_handler) ( GMythFileTransfer *transfer, 
    72 										gint msg_code, gpointer livetv_transfer );
    73 };
    74 
    75 struct _GMythFileTransfer
    76 {
    77 	GObject 					parent;
    78 	
    79 	/* Myth URI structure */
    80 	gchar 					 *filename;
    81 	GMythBackendInfo *backend_info;
    82 	
    83 	/* MythTV version number */	
    84 	gint 							mythtv_version;
    85 
    86 	/* socket descriptors */
    87 	GMythSocket 			*control_sock;
    88 	GMythSocket 			*sock;
    89 	
    90 	GMutex 						*mutex;
    91 
    92 	gint64 						readposition;
    93 	guint64 					filesize;
    94 	gint 							file_id;
    95 	
    96 	GMythFileTransferPrivate 	*priv;
    97 
    98 };
    99 
   100 GType          			gmyth_file_transfer_get_type        (void);
   101 GMythFileTransfer  *gmyth_file_transfer_new             (const GMythBackendInfo *backend_info);
   102 gboolean 						gmyth_file_transfer_open            (GMythFileTransfer *transfer, 
   103                                 					     						const gchar* filename);
   104 void                gmyth_file_transfer_close           (GMythFileTransfer *transfer);
   105 gboolean            gmyth_file_transfer_is_open         (GMythFileTransfer *transfer);
   106 gint                gmyth_file_transfer_read            (GMythFileTransfer *transfer, 
   107                                                          GByteArray *data, 
   108                                                          gint size, 
   109                                                          gboolean read_unlimited);
   110 gint64              gmyth_file_transfer_seek            (GMythFileTransfer *transfer, 
   111                                                          guint64 pos, 
   112                                                          gint whence);
   113 gboolean            gmyth_file_transfer_settimeout      (GMythFileTransfer *transfer, gboolean fast);
   114 guint64             gmyth_file_transfer_get_filesize    (GMythFileTransfer *transfer);
   115 
   116 void								gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, 
   117 																																					 gint msg_code,
   118 																																					 gpointer live_tv );
   119 
   120 G_END_DECLS
   121 
   122 #endif /* __GMYTH_FILE_TRANSFER_H__ */