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