00001 /* 00002 * Copyright (C) 2009, Edmundo Albuquerque de Souza e Silva. 00003 * 00004 * This file may be distributed under the terms of the Q Public License 00005 * as defined by Trolltech AS of Norway and appearing in the file 00006 * LICENSE.QPL included in the packaging of this file. 00007 * 00008 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 00009 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00010 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 00011 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 00012 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00013 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00014 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00015 * 00016 */ 00017 00018 #ifndef _FILEOBJECT_H 00019 00020 #define _FILEOBJECT_H 00021 00022 #include "Parser.h" 00023 #include "RioInterface.h" 00024 #include "RioMutex.h" 00025 #include "RioSemaphore.h" 00026 00027 /////////////////////////////////////////////////////////////////////////////// 00028 class FileObject 00029 { 00030 public: 00031 virtual ~FileObject() { }; 00032 virtual int Close() = 0; 00033 virtual RioObjectSize getSize() = 0; 00034 virtual int Read(char *buf, int size) = 0; 00035 virtual int Write(char *buf, int size, 00036 char* = NULL) = 0; 00037 00038 virtual bool Open( unsigned int, char* = NULL )= 0; 00039 00040 // Novas funcoes para ler e alterar as taxaw de transmissao dos videos 00041 // (usadas pela funcao copyFile da classe RioExplorer). Nas classes a 00042 // seguir descrevemos cada uma destas funcoes. 00043 virtual bool getVideoRate( unsigned int *VideoRate ) = 0; 00044 virtual bool setVideoRate( unsigned int VideoRate ) = 0; 00045 00046 private: 00047 bool opened; 00048 }; 00049 00050 /////////////////////////////////////////////////////////////////////////////// 00051 class LocalFileObject : public FileObject 00052 { 00053 public: 00054 LocalFileObject( char *name ); 00055 00056 bool Open( unsigned int mode, char *md5sum = NULL ); 00057 int Close(); 00058 int Read( char *buf, int size ); 00059 int Write( char *buf, int size, char* md5sum ); 00060 RioObjectSize getSize(); 00061 00062 static const unsigned int DEFAULT_PERM = 0666; 00063 00064 // Novas funcoes para ler e alterar a taxa de transmissao do video 00065 // (usadas pela funcao copyFile da classe RioExplorer). 00066 00067 /** 00068 * GetVideoRate retorna a taxa de transmissao (em Kbps) de video default 00069 * (pois os arquivos locais nao possuem uma taxa de video). 00070 * @param VideoRate ponteiro para o inteiro nao sinalizado que 00071 * armazenara a taxa de transmissao do video. 00072 * @return sempre sera true. 00073 */ 00074 bool getVideoRate( unsigned int *VideoRate ); 00075 00076 /** 00077 * SetVideoRate Esta funcao nao faz nada e somente e definida porque 00078 * precisamos definir todas as funcoes abstratas. 00079 * @param VideoRate nao usado. 00080 * @return sempre true. 00081 */ 00082 bool setVideoRate( unsigned int VideoRate ); 00083 00084 private: 00085 char filename[MAXNAMELEN]; 00086 int fd; 00087 }; 00088 00089 /////////////////////////////////////////////////////////////////////////////// 00090 class RioFileObject : public FileObject 00091 { 00092 public: 00093 RioFileObject( CRioStream *stream, char *objectName ); 00094 ~RioFileObject(); 00095 00096 bool Open( RioAccess access, char *md5sum ); 00097 00098 int Close(); 00099 RioObjectSize getSize(); 00100 int Read( char *buf, int size ); 00101 int Write( char *buf, int size, char *md5sum ); 00102 00103 CSemaphore *Semaphore; 00104 // Novas funcoes para ler e alterar a taxa de transmissao do video 00105 // (usadas pela funcao copyFile da classe RioExplorer). 00106 00107 /** 00108 * GetVideoRate retorna a taxa de transmissao (em Kbps) do video. 00109 * @param VideoRate ponteiro para o inteiro nao sinalizado que 00110 * armazenara a taxa de transmissao do video. 00111 * @return true se a taxa foi obtida com successo e false, se algum erro 00112 * ocorreu ou se a funcionalidade nao esta disponivel no servidor. 00113 */ 00114 bool getVideoRate( unsigned int *VideoRate ); 00115 00116 /** 00117 * SetVideoRate altera a taxa de transmissao (em Kbps) do video. 00118 * @param VideoRate nova taxa de transmissao do video. 00119 * @return true se a taxa foi obtida com successo e false, se algum erro 00120 * ocorreu ou se a funcionalidade nao esta disponivel no servidor. 00121 */ 00122 bool setVideoRate( unsigned int VideoRate ); 00123 00124 private: 00125 CRioStream *stream; 00126 CRioObject *object; 00127 int curBlock; 00128 int curPos; 00129 RioObjectSize size; 00130 unsigned int blockSize; 00131 char objectName[MAXNAMELEN]; 00132 }; 00133 #endif