Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AVC Class Reference

#include <ieee1394io.h>

List of all members.

Public Member Functions

 AVC (void)
 Initializes the AVC object.
 ~AVC ()
 Destroys the AVC object.
int isPhyIDValid (int id)
 See if a node_id is still valid and pointing to an AV/C Recorder.
void Noop (void)
 Do not do anything but let raw1394 make necessary callbacks (bus reset).
int Play (int id)
int Pause (int id)
int Stop (int id)
int FastForward (int id)
int Rewind (int id)
int Forward (int id)
int Back (int id)
int NextScene (int id)
int PreviousScene (int id)
int Record (int id)
int Shuttle (int id, int speed)
unsigned int TransportStatus (int id)
bool Timecode (int id, char *timecode)
int getNodeId (const char *guid)
int getPort () const

Static Private Member Functions

static int ResetHandler (raw1394handle_t handle, unsigned int generation)

Private Attributes

int port
 the interface card to use (typically == 0)
int totalPorts
pthread_mutex_t avc_mutex
 this mutex protects avc related variables that could possibly accessed from two threads at the same time
raw1394handle_t avc_handle
 the handle to the ieee1394 subsystem


Constructor & Destructor Documentation

AVC::AVC void   ) 
 

Initializes the AVC object.

Parameters:
p the number of the interface card to use (port)

Definition at line 807 of file ieee1394io.cc.

References avc_handle, avc_mutex, fail_neg, and totalPorts.

00807                : port( -1 ), totalPorts( 0 )
00808 {
00809     pthread_mutex_init( &avc_mutex, NULL );
00810     avc_handle = NULL;
00811     struct raw1394_portinfo pinf[ 16 ];
00812 
00813     try
00814     {
00815         avc_handle = raw1394_new_handle();
00816         if ( avc_handle == 0 )
00817             return;
00818         fail_neg( totalPorts = raw1394_get_port_info( avc_handle, pinf, 16 ) );
00819         raw1394_destroy_handle( avc_handle );
00820         avc_handle = NULL;
00821     }
00822     catch ( string exc )
00823     {
00824         if ( avc_handle != NULL )
00825             raw1394_destroy_handle( avc_handle );
00826         avc_handle = NULL;
00827         cerr << exc << endl;
00828     }
00829     return;
00830 }

AVC::~AVC  ) 
 

Destroys the AVC object.

Definition at line 837 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

00838 {
00839     if ( avc_handle != NULL )
00840     {
00841         pthread_mutex_lock( &avc_mutex );
00842         raw1394_destroy_handle( avc_handle );
00843         avc_handle = NULL;
00844         pthread_mutex_unlock( &avc_mutex );
00845     }
00846 }


Member Function Documentation

int AVC::Back int  id  ) 
 

Definition at line 1054 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoBack().

01055 {
01056     pthread_mutex_lock( &avc_mutex );
01057     if ( avc_handle != NULL )
01058     {
01059         if ( phyID >= 0 )
01060             avc1394_vcr_previous( avc_handle, phyID );
01061     }
01062     pthread_mutex_unlock( &avc_mutex );
01063     return 0;
01064 }

int AVC::FastForward int  id  ) 
 

Definition at line 1030 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoEndOfMovie(), and PageCapture::videoFastForward().

01031 {
01032     pthread_mutex_lock( &avc_mutex );
01033     if ( avc_handle != NULL )
01034     {
01035         if ( phyID >= 0 )
01036             avc1394_vcr_forward( avc_handle, phyID );
01037     }
01038     pthread_mutex_unlock( &avc_mutex );
01039     return 0;
01040 }

int AVC::Forward int  id  ) 
 

Definition at line 1042 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoForward().

01043 {
01044     pthread_mutex_lock( &avc_mutex );
01045     if ( avc_handle != NULL )
01046     {
01047         if ( phyID >= 0 )
01048             avc1394_vcr_next( avc_handle, phyID );
01049     }
01050     pthread_mutex_unlock( &avc_mutex );
01051     return 0;
01052 }

int AVC::getNodeId const char *  guid  ) 
 

Definition at line 1161 of file ieee1394io.cc.

References avc_handle, avc_mutex, and totalPorts.

Referenced by PageCapture::CheckDevices(), PageTrim::start(), Export1394::start(), and PageEditor::start().

01162 {
01163     int value = -1;
01164     pthread_mutex_lock( &avc_mutex );
01165     if ( avc_handle != NULL )
01166     {
01167         raw1394_destroy_handle( avc_handle );
01168         avc_handle = NULL;
01169     }
01170     port = 0;
01171     for ( int p = 0; value == -1 && p < totalPorts; p++ )
01172     {
01173         rom1394_directory rom1394_dir;
01174         
01175         if ( ( avc_handle = raw1394_new_handle_on_port( p ) ) )
01176         {
01177             int nodeCount = raw1394_get_nodecount( avc_handle );
01178 
01179             port = p;
01180             raw1394_set_bus_reset_handler( avc_handle, this->ResetHandler );
01181 
01182             for ( int currentNode = 0; value == -1 && currentNode < nodeCount; currentNode++ )
01183             {
01184                 if ( rom1394_get_directory( avc_handle, currentNode, &rom1394_dir ) >= 0 )
01185                 {
01186                     octlet_t currentGUID = rom1394_get_guid( avc_handle, currentNode );
01187                     char currentGUIDStr[ 65 ];
01188                     snprintf( currentGUIDStr, 64, "%08x%08x", ( quadlet_t ) ( currentGUID >> 32 ),
01189                         ( quadlet_t ) ( currentGUID & 0xffffffff ) );
01190                     if ( strncmp( currentGUIDStr, guid, 64 ) == 0 )
01191                         value = currentNode;
01192                     rom1394_free_directory( &rom1394_dir );
01193                 }
01194             }
01195             if ( value == -1 )
01196             {
01197                 raw1394_destroy_handle( avc_handle );
01198                 avc_handle = NULL;
01199             }
01200         }
01201     }
01202     if ( value == -1 )
01203         port = -1;
01204     pthread_mutex_unlock( &avc_mutex );
01205     return value;
01206 }

int AVC::getPort  )  const [inline]
 

Definition at line 209 of file ieee1394io.h.

References port.

Referenced by PageCapture::CheckDevices(), PageTrim::start(), Export1394::start(), and PageEditor::start().

00210     {
00211         return port;
00212     }

int AVC::isPhyIDValid int  phyID  ) 
 

See if a node_id is still valid and pointing to an AV/C Recorder.

If the node_id is not valid, then look for the first AV/C device on the bus;

Parameters:
phyID The node_id to check.
Returns:
The same node_id if valid, a new node_id if not valid and a another AV/C recorder exists, or -1 if not valid and no AV/C recorders exist.

Definition at line 872 of file ieee1394io.cc.

References avc_handle, avc_mutex, Preferences::getInstance(), and totalPorts.

Referenced by PageCapture::CheckDevices(), PageTrim::start(), Export1394::start(), and PageEditor::start().

00873 {
00874     int value = -1;
00875     int currentNode, nodeCount;
00876     rom1394_directory rom1394_dir;
00877 
00878     pthread_mutex_lock( &avc_mutex );
00879     if ( avc_handle != NULL )
00880     {
00881         nodeCount = raw1394_get_nodecount( avc_handle );
00882         if ( phyID >= 0 && phyID < nodeCount )
00883         {
00884             if ( rom1394_get_directory( avc_handle, phyID, &rom1394_dir ) >= 0 )
00885             {
00886                 if ( rom1394_get_node_type( &rom1394_dir ) == ROM1394_NODE_TYPE_AVC )
00887                 {
00888                     if ( avc1394_check_subunit_type( avc_handle, phyID, AVC1394_SUBUNIT_TYPE_VCR ) )
00889                         value = phyID;
00890                 }
00891                 rom1394_free_directory( &rom1394_dir );
00892             }
00893         }
00894 
00895         if ( value == -1 )
00896         {
00897             raw1394_destroy_handle( avc_handle );
00898             avc_handle = NULL;
00899             port = -1;
00900         }
00901     }
00902     for ( int p = 0; value == -1 && p < totalPorts; p++ )
00903     {
00904         if ( ( avc_handle = raw1394_new_handle_on_port( p ) ) )
00905         {
00906             port = p;
00907             raw1394_set_bus_reset_handler( avc_handle, this->ResetHandler );
00908 
00909             // look for a new AVC recorder
00910             nodeCount = raw1394_get_nodecount( avc_handle );
00911             for ( currentNode = 0; value == -1 && currentNode < nodeCount; currentNode++ )
00912             {
00913                 if ( rom1394_get_directory( avc_handle, currentNode, &rom1394_dir ) >= 0 )
00914                 {
00915                     if ( rom1394_get_node_type( &rom1394_dir ) == ROM1394_NODE_TYPE_AVC )
00916                     {
00917                         if ( avc1394_check_subunit_type( avc_handle, currentNode, AVC1394_SUBUNIT_TYPE_VCR ) )
00918                         {
00919                             // set Preferences to the newly found AVC node and return
00920                             octlet_t guid = rom1394_get_guid( avc_handle, currentNode );
00921                             snprintf( Preferences::getInstance().avcGUID, 64, "%08x%08x",
00922                                 ( quadlet_t ) ( guid >> 32 ), ( quadlet_t ) ( guid & 0xffffffff ) );
00923                             value = currentNode;
00924                         }
00925                     }
00926                     rom1394_free_directory( &rom1394_dir );
00927                 }
00928             }
00929             if ( value == -1 )
00930             {
00931                 raw1394_destroy_handle( avc_handle );
00932                 avc_handle = NULL;
00933             }
00934         }
00935     }
00936     if ( value == -1 )
00937         port = -1;
00938     pthread_mutex_unlock( &avc_mutex );
00939     return value;
00940 }

int AVC::NextScene int  id  ) 
 

Definition at line 1066 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoEndOfScene(), and PageCapture::videoNextScene().

01067 {
01068     pthread_mutex_lock( &avc_mutex );
01069     if ( avc_handle != NULL )
01070     {
01071         if ( phyID >= 0 )
01072             avc1394_vcr_next_index( avc_handle, phyID );
01073     }
01074     pthread_mutex_unlock( &avc_mutex );
01075     return 0;
01076 }

void AVC::Noop void   ) 
 

Do not do anything but let raw1394 make necessary callbacks (bus reset).

Definition at line 945 of file ieee1394io.cc.

References avc_handle.

Referenced by PageCapture::CheckDevices().

00946 {
00947     struct pollfd raw1394_poll;
00948     raw1394_poll.fd = raw1394_get_fd( avc_handle );
00949     raw1394_poll.events = POLLIN | POLLPRI;
00950     raw1394_poll.revents = 0;
00951     if ( poll( &raw1394_poll, 1, 100 ) > 0 )
00952     {
00953         if ( ( raw1394_poll.revents & POLLIN )
00954                 || ( raw1394_poll.revents & POLLPRI ) )
00955             raw1394_loop_iterate( avc_handle );
00956     }
00957 }

int AVC::Pause int  id  ) 
 

Definition at line 977 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoBack(), PageCapture::videoEndOfScene(), PageCapture::videoFastForward(), PageCapture::videoForward(), PageCapture::videoNextScene(), PageCapture::videoPause(), PageCapture::videoPlay(), PageCapture::videoPreviousScene(), PageCapture::videoRewind(), PageCapture::videoShuttle(), and PageCapture::videoStartOfScene().

00978 {
00979     pthread_mutex_lock( &avc_mutex );
00980     if ( avc_handle != NULL )
00981     {
00982         if ( phyID >= 0 )
00983         {
00984             if ( !avc1394_vcr_is_recording( avc_handle, phyID ) &&
00985                 avc1394_vcr_is_playing( avc_handle, phyID ) != AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE )
00986                     avc1394_vcr_pause( avc_handle, phyID );
00987         }
00988     }
00989     struct timespec t =
00990         {
00991             0, 250000000
00992         };
00993     nanosleep( &t, NULL );
00994     pthread_mutex_unlock( &avc_mutex );
00995     return 0;
00996 }

int AVC::Play int  id  ) 
 

Definition at line 960 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoPlay().

00961 {
00962     pthread_mutex_lock( &avc_mutex );
00963     if ( avc_handle != NULL )
00964     {
00965         if ( phyID >= 0 )
00966         {
00967             if ( !avc1394_vcr_is_recording( avc_handle, phyID ) &&
00968                 avc1394_vcr_is_playing( avc_handle, phyID ) != AVC1394_VCR_OPERAND_PLAY_FORWARD )
00969                     avc1394_vcr_play( avc_handle, phyID );
00970         }
00971     }
00972     pthread_mutex_unlock( &avc_mutex );
00973     return 0;
00974 }

int AVC::PreviousScene int  id  ) 
 

Definition at line 1078 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoPreviousScene(), and PageCapture::videoStartOfScene().

01079 {
01080     pthread_mutex_lock( &avc_mutex );
01081     if ( avc_handle != NULL )
01082     {
01083         if ( phyID >= 0 )
01084             avc1394_vcr_previous_index( avc_handle, phyID );
01085     }
01086     pthread_mutex_unlock( &avc_mutex );
01087     return 0;
01088 }

int AVC::Record int  id  ) 
 

Definition at line 1090 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by Export1394::doExport().

01091 {
01092     pthread_mutex_lock( &avc_mutex );
01093     if ( avc_handle != NULL )
01094     {
01095         if ( phyID >= 0 )
01096             avc1394_vcr_record( avc_handle, phyID );
01097     }
01098     pthread_mutex_unlock( &avc_mutex );
01099     return 0;
01100 }

int AVC::ResetHandler raw1394handle_t  handle,
unsigned int  generation
[static, private]
 

Definition at line 852 of file ieee1394io.cc.

References common, and KinoCommon::getPageCapture().

00853 {
00854     cerr << "Reset Handler received" << endl;
00855     raw1394_update_generation( handle, generation );
00856     common->getPageCapture()->driver_locked = true;
00857     return 0;
00858 }

int AVC::Rewind int  id  ) 
 

Definition at line 1017 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoRewind(), and PageCapture::videoStartOfMovie().

01018 {
01019     pthread_mutex_lock( &avc_mutex );
01020     if ( avc_handle != NULL )
01021     {
01022         if ( phyID >= 0 )
01023             avc1394_vcr_rewind( avc_handle, phyID );
01024     }
01025     pthread_mutex_unlock( &avc_mutex );
01026     return 0;
01027 }

int AVC::Shuttle int  id,
int  speed
 

Definition at line 1102 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::videoShuttle().

01103 {
01104     pthread_mutex_lock( &avc_mutex );
01105     if ( avc_handle != NULL )
01106     {
01107         if ( phyID >= 0 )
01108             avc1394_vcr_trick_play( avc_handle, phyID, speed );
01109     }
01110     pthread_mutex_unlock( &avc_mutex );
01111     return 0;
01112 }

int AVC::Stop int  id  ) 
 

Definition at line 999 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by Export1394::doExport(), PageCapture::videoEndOfMovie(), PageCapture::videoStartOfMovie(), and PageCapture::videoStop().

01000 {
01001     pthread_mutex_lock( &avc_mutex );
01002     if ( avc_handle != NULL )
01003     {
01004         if ( phyID >= 0 )
01005             avc1394_vcr_stop( avc_handle, phyID );
01006     }
01007     struct timespec t =
01008         {
01009             0, 250000000
01010         };
01011     nanosleep( &t, NULL );
01012     pthread_mutex_unlock( &avc_mutex );
01013     return 0;
01014 }

bool AVC::Timecode int  id,
char *  timecode
 

Definition at line 1127 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::CheckDevices().

01128 {
01129     pthread_mutex_lock( &avc_mutex );
01130     if ( avc_handle != NULL )
01131     {
01132         if ( phyID >= 0 )
01133         {
01134             quadlet_t request[ 2 ];
01135             quadlet_t *response;
01136 
01137             request[ 0 ] = AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_TAPE_RECORDER | AVC1394_SUBUNIT_ID_0 |
01138                            AVC1394_VCR_COMMAND_TIME_CODE | AVC1394_VCR_OPERAND_TIME_CODE_STATUS;
01139             request[ 1 ] = 0xFFFFFFFF;
01140             response = avc1394_transaction_block( avc_handle, phyID, request, 2, 1 );
01141             if ( response == NULL )
01142             {
01143                 pthread_mutex_unlock( &avc_mutex );
01144                 return false;
01145             }
01146             if ( response[1] == 0xffffffff )
01147                 strcpy( timecode, "--:--:--:--" );
01148             else
01149                 sprintf( timecode, "%2.2x:%2.2x:%2.2x:%2.2x",
01150                      response[ 1 ] & 0x000000ff,
01151                      ( response[ 1 ] >> 8 ) & 0x000000ff,
01152                      ( response[ 1 ] >> 16 ) & 0x000000ff,
01153                      ( response[ 1 ] >> 24 ) & 0x000000ff );
01154         }
01155 
01156     }
01157     pthread_mutex_unlock( &avc_mutex );
01158     return true;
01159 }

unsigned int AVC::TransportStatus int  id  ) 
 

Definition at line 1114 of file ieee1394io.cc.

References avc_handle, and avc_mutex.

Referenced by PageCapture::CheckDevices().

01115 {
01116     quadlet_t val = 0;
01117     pthread_mutex_lock( &avc_mutex );
01118     if ( avc_handle != NULL )
01119     {
01120         if ( phyID >= 0 )
01121             val = avc1394_vcr_status( avc_handle, phyID );
01122     }
01123     pthread_mutex_unlock( &avc_mutex );
01124     return val;
01125 }


Member Data Documentation

raw1394handle_t AVC::avc_handle [private]
 

the handle to the ieee1394 subsystem

Definition at line 187 of file ieee1394io.h.

Referenced by AVC(), Back(), FastForward(), Forward(), getNodeId(), isPhyIDValid(), NextScene(), Noop(), Pause(), Play(), PreviousScene(), Record(), Rewind(), Shuttle(), Stop(), Timecode(), TransportStatus(), and ~AVC().

pthread_mutex_t AVC::avc_mutex [private]
 

this mutex protects avc related variables that could possibly accessed from two threads at the same time

Definition at line 184 of file ieee1394io.h.

Referenced by AVC(), Back(), FastForward(), Forward(), getNodeId(), isPhyIDValid(), NextScene(), Pause(), Play(), PreviousScene(), Record(), Rewind(), Shuttle(), Stop(), Timecode(), TransportStatus(), and ~AVC().

int AVC::port [private]
 

the interface card to use (typically == 0)

Definition at line 179 of file ieee1394io.h.

Referenced by getPort().

int AVC::totalPorts [private]
 

Definition at line 180 of file ieee1394io.h.

Referenced by AVC(), getNodeId(), and isPhyIDValid().


The documentation for this class was generated from the following files:
Generated on Sun Mar 11 22:12:46 2007 for Kino by  doxygen 1.4.2