#include <ieee1394io.h>
Collaboration diagram for IEEE1394Reader:

Public Member Functions | |
| IEEE1394Reader (int chn=63, int frames=50) | |
| Initializes the IEEE1394Reader object. | |
| virtual | ~IEEE1394Reader () |
| Destroys the IEEE1394Reader object. | |
| virtual bool | StartThread (int port=0)=0 |
| virtual void | StopThread (void)=0 |
| Frame * | GetFrame (void) |
| Fetches the next frame from the output queue. | |
| void | DoneWithFrame (Frame *) |
| Put back a frame to the queue of available frames. | |
| int | GetDroppedFrames (void) |
| Return the number of dropped frames since last call. | |
| int | GetOutQueueSize (void) |
| int | GetInQueueSize (void) |
| void | ResetDroppedFrames (void) |
| virtual bool | Open (int port=0)=0 |
| virtual void | Close (void)=0 |
| bool | WaitForAction (int seconds=0) |
| void | TriggerAction () |
| virtual bool | StartReceive (void)=0 |
| virtual void | StopReceive (void)=0 |
Protected Member Functions | |
| void | Flush (void) |
| Throw away all currently available frames. | |
Protected Attributes | |
| int | droppedFrames |
| the number of frames that had to be thrown away because our inFrames queue did not contain available frames | |
| Frame * | currentFrame |
| a pointer to the frame which is currently been transmitted | |
| deque< Frame * > | inFrames |
| a list of empty frames | |
| deque< Frame * > | outFrames |
| a list of already received frames | |
| int | channel |
| the iso channel we listen to (typically == 63) | |
| pthread_t | thread |
| contains information about our thread after calling StartThread | |
| pthread_mutex_t | mutex |
| this mutex protects capture related variables that could possibly accessed from two threads at the same time | |
| pthread_mutex_t | condition_mutex |
| pthread_cond_t | condition |
| bool | isRunning |
| A state variable for starting and stopping thread. | |
|
||||||||||||
|
Initializes the IEEE1394Reader object. The object is initialized with port and channel number. These parameters define the interface card and the iso channel on which the camcorder sends its data. The object contains a list of empty frames, which are allocated here. 50 frames (2 seconds) should be enough in most cases.
Definition at line 96 of file ieee1394io.cc. References condition, condition_mutex, GetFramePool(), inFrames, and mutex. 00096 : 00097 droppedFrames( 0 ), 00098 currentFrame( NULL ), 00099 channel( c ), 00100 isRunning( false ) 00101 { 00102 Frame * frame; 00103 00104 /* Create empty frames and put them in our inFrames queue */ 00105 for ( int i = 0; i < bufSize; ++i ) 00106 { 00107 frame = GetFramePool( ) ->GetFrame( ); 00108 inFrames.push_back( frame ); 00109 } 00110 00111 /* Initialize mutexes */ 00112 pthread_mutex_init( &mutex, NULL ); 00113 00114 /* Initialise mutex and condition for action triggerring */ 00115 pthread_mutex_init( &condition_mutex, NULL ); 00116 pthread_cond_init( &condition, NULL ); 00117 }
|
|
|
Destroys the IEEE1394Reader object. In particular, it deletes all frames in the inFrames and outFrames queues, as well as the one currently in use. Note that one or more frames may have been taken out of the queues by a user of the IEEE1394Reader class. Definition at line 129 of file ieee1394io.cc. References condition, condition_mutex, currentFrame, GetFramePool(), inFrames, and outFrames. 00130 {
00131 Frame * frame;
00132
00133 for ( int i = inFrames.size(); i > 0; --i )
00134 {
00135 frame = inFrames[ 0 ];
00136 inFrames.pop_front();
00137 GetFramePool( ) ->DoneWithFrame( frame );
00138 }
00139 for ( int i = outFrames.size(); i > 0; --i )
00140 {
00141 frame = outFrames[ 0 ];
00142 outFrames.pop_front();
00143 GetFramePool( ) ->DoneWithFrame( frame );
00144 }
00145 if ( currentFrame != NULL )
00146 {
00147 GetFramePool( ) ->DoneWithFrame( currentFrame );
00148 currentFrame = NULL;
00149 }
00150 pthread_mutex_destroy( &condition_mutex );
00151 pthread_cond_destroy( &condition );
00152 }
|
|
|
|
|
|
Put back a frame to the queue of available frames.
Definition at line 191 of file ieee1394io.cc. References inFrames, and mutex. Referenced by captureThread(). 00192 {
00193 pthread_mutex_lock( &mutex );
00194 inFrames.push_back( frame );
00195 pthread_mutex_unlock( &mutex );
00196 }
|
|
|
Throw away all currently available frames. All frames in the outFrames queue are put back to the inFrames queue. Also the currentFrame is put back too. Definition at line 218 of file ieee1394io.cc. References currentFrame, inFrames, mutex, and outFrames. 00219 {
00220 Frame * frame = NULL;
00221
00222 pthread_mutex_lock( &mutex );
00223 for ( int i = outFrames.size(); i > 0; --i )
00224 {
00225 frame = outFrames[ 0 ];
00226 outFrames.pop_front();
00227 inFrames.push_back( frame );
00228 }
00229 if ( currentFrame != NULL )
00230 {
00231 inFrames.push_back( currentFrame );
00232 currentFrame = NULL;
00233 }
00234 pthread_mutex_unlock( &mutex );
00235 }
|
|
|
Return the number of dropped frames since last call.
Definition at line 202 of file ieee1394io.cc. References droppedFrames, and mutex. Referenced by PageCapture::showFrameInfo(). 00203 {
00204 pthread_mutex_lock( &mutex );
00205 int n = droppedFrames;
00206 droppedFrames = 0;
00207 pthread_mutex_unlock( &mutex );
00208 return n;
00209 }
|
|
|
Fetches the next frame from the output queue. The outFrames contains a list of frames to be processed (saved, displayed) by the user of this class. Copy the first frame (actually only a pointer to it) and remove it from the queue.
Definition at line 169 of file ieee1394io.cc. References mutex, and outFrames. Referenced by captureThread(). 00170 {
00171 Frame * frame = NULL;
00172
00173 pthread_mutex_lock( &mutex );
00174
00175 if ( outFrames.size() > 0 )
00176 {
00177 frame = outFrames[ 0 ];
00178 outFrames.pop_front();
00179 }
00180 pthread_mutex_unlock( &mutex );
00181 if ( frame != NULL )
00182 frame->ExtractHeader();
00183
00184 return frame;
00185 }
|
|
|
Definition at line 71 of file ieee1394io.h. References inFrames. Referenced by captureThread(). 00072 {
00073 return inFrames.size();
00074 }
|
|
|
Definition at line 67 of file ieee1394io.h. References outFrames. Referenced by captureThread(). 00068 {
00069 return outFrames.size();
00070 }
|
|
|
|
|
|
Definition at line 75 of file ieee1394io.h. References droppedFrames. Referenced by PageCapture::startCapture(). 00076 {
00077 droppedFrames = 0;
00078 }
|
|
|
|
|
|
Referenced by PageCapture::CheckDevices(). |
|
|
|
|
|
Referenced by PageCapture::CheckDevices(), and PageCapture::clean(). |
|
|
Definition at line 279 of file ieee1394io.cc. References condition, and condition_mutex. Referenced by PageCapture::clean(). 00280 {
00281 pthread_mutex_lock( &condition_mutex );
00282 pthread_cond_signal( &condition );
00283 pthread_mutex_unlock( &condition_mutex );
00284 }
|
|
|
Definition at line 237 of file ieee1394io.cc. References condition, condition_mutex, mutex, and outFrames. Referenced by captureThread(). 00238 {
00239 pthread_mutex_lock( &mutex );
00240 int size = outFrames.size( );
00241 pthread_mutex_unlock( &mutex );
00242
00243 if ( size == 0 )
00244 {
00245 pthread_mutex_lock( &condition_mutex );
00246 if ( seconds == 0 )
00247 {
00248 pthread_cond_wait( &condition, &condition_mutex );
00249 pthread_mutex_unlock( &condition_mutex );
00250 pthread_mutex_lock( &mutex );
00251 size = outFrames.size( );
00252 }
00253 else
00254 {
00255 struct timeval tp;
00256 struct timespec ts;
00257 int result;
00258
00259 gettimeofday( &tp, NULL );
00260 ts.tv_sec = tp.tv_sec + seconds;
00261 ts.tv_nsec = tp.tv_usec * 1000;
00262
00263 result = pthread_cond_timedwait( &condition, &condition_mutex, &ts );
00264 pthread_mutex_unlock( &condition_mutex );
00265 pthread_mutex_lock( &mutex );
00266
00267 if ( result == ETIMEDOUT )
00268 size = 0;
00269 else
00270 size = outFrames.size();
00271 }
00272 pthread_mutex_unlock( &mutex );
00273 }
00274
00275 return size != 0;
00276 }
|
|
|
the iso channel we listen to (typically == 63)
Definition at line 92 of file ieee1394io.h. |
|
|
Definition at line 104 of file ieee1394io.h. Referenced by IEEE1394Reader(), TriggerAction(), WaitForAction(), and ~IEEE1394Reader(). |
|
|
Definition at line 103 of file ieee1394io.h. Referenced by IEEE1394Reader(), TriggerAction(), WaitForAction(), and ~IEEE1394Reader(). |
|
|
a pointer to the frame which is currently been transmitted
Definition at line 48 of file ieee1394io.h. Referenced by Flush(), and ~IEEE1394Reader(). |
|
|
the number of frames that had to be thrown away because our inFrames queue did not contain available frames
Definition at line 45 of file ieee1394io.h. Referenced by GetDroppedFrames(), and ResetDroppedFrames(). |
|
|
a list of empty frames
Definition at line 51 of file ieee1394io.h. Referenced by DoneWithFrame(), Flush(), GetInQueueSize(), IEEE1394Reader(), and ~IEEE1394Reader(). |
|
|
A state variable for starting and stopping thread.
Definition at line 107 of file ieee1394io.h. |
|
|
this mutex protects capture related variables that could possibly accessed from two threads at the same time
Definition at line 99 of file ieee1394io.h. Referenced by DoneWithFrame(), Flush(), GetDroppedFrames(), GetFrame(), IEEE1394Reader(), and WaitForAction(). |
|
|
a list of already received frames
Definition at line 54 of file ieee1394io.h. Referenced by Flush(), GetFrame(), GetOutQueueSize(), WaitForAction(), and ~IEEE1394Reader(). |
|
|
contains information about our thread after calling StartThread
Definition at line 95 of file ieee1394io.h. |
1.4.2