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