00001 /* Copyright (C) 2002 Carsten Griwodz 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, this code may be used in unmodified form 00006 * provided that this copyright notice and this permission notice appear 00007 * in supporting documentation. 00008 * 00009 * The code may be made subject to the terms of the GNU General Public 00010 * License, Version 2, and re-distributed under the terms of this license. 00011 * 00012 * Commercial use other than under the terms of the GNU General Public 00013 * License is allowed only after negotiation of conditions with the authors. 00014 */ 00015 #ifndef DUMMY_LAYER_SOURCE_STREAM_HANDLER_H 00016 #define DUMMY_LAYER_SOURCE_STREAM_HANDLER_H 00017 00018 #include <sys/types.h> 00019 #include <stdio.h> 00020 #include <list> 00021 00022 #include "MNTimeval.h" 00023 #include "MNValid.h" 00024 #include "SH.h" 00025 #include "SHEndpoint.h" 00026 #include "SHEndpointSpec.h" 00027 #include "var_type.h" 00028 00029 class MNRope; 00030 00031 namespace SH 00032 { 00033 00034 class DummyLayerSourceSH; 00035 class DummyListBase; 00036 00041 /**********************************************************************/ 00042 /* DummyLayerSourceEndpoint */ 00043 /**********************************************************************/ 00044 00045 class DummyLayerSourceEndpoint 00046 : public SourceEndpoint 00047 { 00048 DECLARE_VALID 00049 00050 public: 00051 DummyLayerSourceEndpoint( DummyLayerSourceSH* mySH ); 00052 virtual ~DummyLayerSourceEndpoint( ); 00053 00054 virtual SH_RC pull( DataPtr& item, 00055 SourceUnit su, 00056 size_t amount ); 00057 00058 DummyLayerSourceSH* fsh(); 00059 }; 00060 00061 /**********************************************************************/ 00062 /* DummyLayerSourceSH */ 00063 /**********************************************************************/ 00064 00065 class DummyLayerSourceSH 00066 : public Base 00067 { 00068 DECLARE_VALID 00069 00070 public: 00071 DummyLayerSourceSH( SHGraphManager* mgr, 00072 u_int32_t runtimeId, 00073 MNSelector& sel); 00074 00075 virtual ~DummyLayerSourceSH(); 00076 00081 struct DummyHeader 00082 { 00083 u_int32_t sequence_number; 00084 u_int32_t priority; 00085 00089 DummyHeader( u_int32_t seq, u_int32_t pri ); 00090 }; 00091 00092 SH_RC getPos ( long &pos ); 00093 00094 private: 00095 00100 DummyLayerSourceSH( const DummyLayerSourceSH& ); 00101 00106 DummyLayerSourceSH& operator=( const DummyLayerSourceSH& ); 00107 00108 public: 00109 virtual SH_RC initSH(); 00110 virtual SH_RC uninitSH(); 00111 00114 virtual SH_RC startStreaming(); 00115 00116 SH_RC pull_from_file( DataPtr& item, 00117 SourceUnit su, 00118 size_t amount ); 00119 00120 /******************************************************************/ 00121 /* additional attributes for the set() functions */ 00122 /******************************************************************/ 00123 public: 00124 SA_FILE_NAME _filename; 00125 SA_FILESRC_START_POS _start_pos; 00126 SA_FILESRC_STOP_POS _stop_pos; 00127 SA_PUSH_PULL_INITIAL_FILL _initial_fill; 00128 00129 // Attributes haved been moved to SH.h 00130 00131 /******************************************************************/ 00132 /* functions required for SH::Spec */ 00133 /******************************************************************/ 00134 protected: 00135 friend class DummyLayerSourceEndpoint; 00136 00137 SourceEndpoint* _out_ep_a[1]; 00138 DummyLayerSourceEndpoint _outEP; 00139 00140 public: 00141 virtual SinkEndpoint** getSinkSpecs(); 00142 virtual SourceEndpoint** getSourceSpecs(); 00143 00144 /******************************************************************/ 00145 /* functions required for SHStatus */ 00146 /******************************************************************/ 00156 virtual bool isConnected() const; 00157 00158 private: 00159 bool _initialized; 00160 u_int64_t _bytes_read; 00161 u_int64_t _bytes_sent; 00162 u_int32_t _cnt; 00163 u_int32_t _null_cnt; 00164 00165 u_int32_t _duration; 00166 u_int32_t _blk_sz; 00167 u_int32_t _bw; 00168 00169 DummyListBase* _entries; 00170 00171 private: 00175 void compress_queue( ); 00176 00180 bool refill_queue( ); 00181 00185 void inc_cnt( ); 00186 00191 #ifndef NDEBUG 00192 void inc_null_cnt( ); 00193 #else 00194 inline void inc_null_cnt( ) const { } 00195 #endif 00196 }; 00197 00199 00200 }; // namespace SH 00201 00202 #endif /* DUMMY_LAYER_SOURCE_STREAM_HANDLER_H */ 00203