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

PageCapture Class Reference

This class controls the firewire capture notebook page. More...

#include <page_capture.h>

Inheritance diagram for PageCapture:

Inheritance graph
[legend]
Collaboration diagram for PageCapture:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PageCapture (KinoCommon *common)
 Constructor for page.
virtual ~PageCapture ()
 Destructor for page.
gulong activate ()
 Define active widgets.
void newFile ()
 Called when a new file operation is selected by the user.
void start ()
 Start of page.
void clean ()
 Leaving the page.
gboolean processKeyboard (GdkEventKey *event)
 Process a keyboard event.
gboolean processCommand (char *cmd)
 Internal method for handling a complete keyboard scene.
void videoStartOfMovie ()
 Start of movie.
void videoPreviousScene ()
 Start of previous scene.
void videoStartOfScene ()
 Start of current scene.
void videoRewind ()
 Rewind.
void videoBack ()
 Frame back.
void videoPlay ()
 Play.
void videoForward ()
 Forward.
void videoFastForward ()
 Fast Forward.
void videoNextScene ()
 Start of next scene.
void videoEndOfScene ()
 End of current scene.
void videoEndOfMovie ()
 End of movie.
void videoPause ()
 Pause.
void videoStop ()
 Stop.
void videoShuttle (int)
 Shuttle.
void applyAVCState (quadlet_t)
 Reflect the the AV/C status in the transport buttons.
quadlet_t getAVCState ()
void startCapture ()
 Start capturing video to the disk.
void stopCapture ()
 Stop capturing video to the disk.
void saveFrame ()
 Save a single still frame of video to the disk.
void windowMoved ()
void showFrameInfo (int)
 Show the AV/C timecode.
FramegetFrame ()
 Fetch the currently showing frame.
void CheckDevices ()
 Check devices and status.
void collectFiles ()
std::string getHelpPage ()

Public Attributes

bool driver_available
bool avc_enabled
bool audio_enabled
bool check_phyid
bool driver_locked

Private Attributes

KinoCommoncommon
quadlet_t avcState
bool isCapturing
bool captureMutex
gulong validComponents
int gui_state_was
GtkDrawingArea * frameArea
GtkToggleButton * avcButton
GtkToggleButton * recordButton
GtkToggleButton * stopButton
GtkToggleButton * playrecordButton
GtkToggleButton * muteButton
GtkButton * snapshotButton
GtkEntry * fileEntry
GtkLabel * timecodeLabel

Detailed Description

This class controls the firewire capture notebook page.

Definition at line 35 of file page_capture.h.


Constructor & Destructor Documentation

PageCapture::PageCapture KinoCommon common  ) 
 

Constructor for page.

Parameters:
common common object to which this page belongs

Definition at line 98 of file page_capture.cc.

References avcButton, fileEntry, frameArea, KinoCommon::getWidget(), lastPreferenceFilename, lookup_widget(), muteButton, recordButton, snapshotButton, stopButton, timecode, and timecodeLabel.

00098                                              : isCapturing( false ), captureMutex( false ),
00099         avc_enabled( false ), driver_locked( false )
00100 {
00101     std::cerr << "> Creating Capture Page" << std::endl;
00102     this->common = common;
00103     this->frameArea = GTK_DRAWING_AREA( lookup_widget( common->getWidget(), "capture_drawingarea" ) );
00104     gtk_widget_set_double_buffered( GTK_WIDGET( frameArea ), FALSE );
00105     this->avcButton = GTK_TOGGLE_BUTTON( lookup_widget( common->getWidget(), "capture_page_avc_button" ) );
00106     this->recordButton = GTK_TOGGLE_BUTTON( lookup_widget( common->getWidget(), "capture_page_record_button" ) );
00107     this->stopButton = GTK_TOGGLE_BUTTON( lookup_widget( common->getWidget(), "capture_page_stop_button" ) );
00108     this->muteButton = GTK_TOGGLE_BUTTON( lookup_widget( common->getWidget(), "capture_page_mute_button" ) );
00109     this->snapshotButton = GTK_BUTTON( lookup_widget( common->getWidget(), "capture_page_snapshot_button" ) );
00110     this->fileEntry = GTK_ENTRY( lookup_widget( common->getWidget(), "entry_capture_file" ) );
00111     this->timecodeLabel = GTK_LABEL( lookup_widget( common->getWidget(), "position_label_current" ) );
00112     lastPreferenceFilename[ 0 ] = 0;
00113     memset( timecode, 0, sizeof( timecode ) );
00114 }

PageCapture::~PageCapture  )  [virtual]
 

Destructor for page.

Definition at line 119 of file page_capture.cc.

References reader.

00120 {
00121     std::cerr << "> Destroying Capture Page" << std::endl;
00122     delete reader;
00123     reader = NULL;
00124 }


Member Function Documentation

gulong PageCapture::activate  )  [virtual]
 

Define active widgets.

Reimplemented from Page.

Definition at line 453 of file page_capture.cc.

References SCENE_LIST, and validComponents.

00454 {
00455     return this->validComponents | SCENE_LIST;
00456 }

void PageCapture::applyAVCState quadlet_t   ) 
 

Reflect the the AV/C status in the transport buttons.

Definition at line 282 of file page_capture.cc.

References KinoCommon::activateWidgets(), navigate_control::active, avc_enabled, avcButton, avcState, check_phyid, KinoCommon::commitComponentState(), common, driver_available, g_nav_ctl, KinoCommon::getComponentState(), Preferences::getInstance(), gui_state_was, INFO_FRAME, isCapturing, muteButton, recordButton, KinoCommon::setStatusBar(), snapshotButton, stopButton, stopCapture(), KinoCommon::toggleComponents(), validComponents, VIDEO_BACK, VIDEO_END_OF_MOVIE, VIDEO_FAST_FORWARD, VIDEO_FORWARD, VIDEO_NEXT_SCENE, VIDEO_PLAY, VIDEO_REWIND, VIDEO_SHUTTLE, VIDEO_START_OF_MOVIE, VIDEO_START_OF_SCENE, and VIDEO_STOP.

00283 {
00284     if ( driver_available == false )
00285     {
00286         if ( gui_state_was != 0 )
00287         {
00288             gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), false );
00289             gtk_widget_set_sensitive( GTK_WIDGET( recordButton ), false );
00290             gtk_widget_set_sensitive( GTK_WIDGET( stopButton ), false );
00291             gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), false );
00292             gtk_widget_set_sensitive( GTK_WIDGET( muteButton ), false );
00293             validComponents = 0;
00294             common->activateWidgets( );
00295             common->commitComponentState();
00296 #ifdef HAVE_IEC61883
00297             common->setStatusBar( _( "WARNING: raw1394 kernel module not loaded or failure to read/write /dev/raw1394!" ) );
00298 #else
00299             common->setStatusBar( _( "WARNING: dv1394 kernel module not loaded or failure to read/write %s" ),
00300                 Preferences::getInstance().dvCaptureDevice );
00301 #endif
00302         }
00303         gui_state_was = 0;
00304     }
00305     else if ( check_phyid == true )
00306     {
00307         if ( gui_state_was != 1 )
00308         {
00309             gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), false );
00310             gtk_widget_set_sensitive( GTK_WIDGET( recordButton ), true );
00311             gtk_widget_set_sensitive( GTK_WIDGET( stopButton ), true );
00312             gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), true );
00313             gtk_widget_set_sensitive( GTK_WIDGET( muteButton ), true );
00314             validComponents = 0;
00315             common->activateWidgets( );
00316             common->commitComponentState();
00317             common->setStatusBar( _( "No AV/C compliant cam connected or not switched on?" ) );
00318         }
00319         gui_state_was = 1;
00320     }
00321     else if ( avc_enabled )
00322     {
00323         if ( gui_state_was != 2 )
00324         {
00325             gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), true );
00326             gtk_widget_set_sensitive( GTK_WIDGET( recordButton ), true );
00327             gtk_widget_set_sensitive( GTK_WIDGET( stopButton ), true );
00328             gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), true );
00329             gtk_widget_set_sensitive( GTK_WIDGET( muteButton ), true );
00330 
00331             validComponents = VIDEO_REWIND |
00332                               VIDEO_PLAY |
00333                               VIDEO_STOP |
00334                               VIDEO_FAST_FORWARD |
00335                               VIDEO_FORWARD |
00336                               VIDEO_BACK |
00337                               VIDEO_NEXT_SCENE |
00338                               VIDEO_START_OF_SCENE |
00339                               VIDEO_START_OF_MOVIE |
00340                               VIDEO_SHUTTLE |
00341                               VIDEO_END_OF_MOVIE |
00342                               INFO_FRAME;
00343 
00344             common->activateWidgets( );
00345 
00346             gui_state_was = 2;
00347 
00348             common->setStatusBar( "AV/C Controls Enabled" );
00349             cerr << ">>> AVC enabled " << std::endl;
00350 
00351             // Ensure that we reflect the current avc state when changing gui states
00352             avcState = true;
00353         }
00354 
00355         if ( avcState != newAVCState )
00356         {
00357             quadlet_t resp2 = AVC1394_MASK_RESPONSE_OPERAND( newAVCState, 2 );
00358             quadlet_t resp3 = AVC1394_MASK_RESPONSE_OPERAND( newAVCState, 3 );
00359             this->avcState = newAVCState;
00360 
00361             common->toggleComponents( common->getComponentState(), false );
00362             g_nav_ctl.active = FALSE;
00363 
00364             if ( resp2 == AVC1394_VCR_RESPONSE_TRANSPORT_STATE_PLAY )
00365             {
00366                 if ( resp3 >= AVC1394_VCR_OPERAND_PLAY_FAST_FORWARD_1
00367                         && resp3 <= AVC1394_VCR_OPERAND_PLAY_FASTEST_FORWARD )
00368                 {
00369                     common->toggleComponents( VIDEO_FAST_FORWARD, true );
00370                     g_nav_ctl.active = TRUE;
00371                 }
00372                 else if ( resp3 >= AVC1394_VCR_OPERAND_PLAY_FAST_REVERSE_1
00373                           && resp3 <= AVC1394_VCR_OPERAND_PLAY_FASTEST_REVERSE )
00374                 {
00375                     common->toggleComponents( VIDEO_REWIND, true );
00376                     g_nav_ctl.active = TRUE;
00377                 }
00378                 else if ( resp3 == AVC1394_VCR_OPERAND_PLAY_FORWARD_PAUSE )
00379                 {
00380                     common->toggleComponents( VIDEO_PLAY, false );
00381                 }
00382                 else
00383                 {
00384                     common->toggleComponents( VIDEO_PLAY, true );
00385                     g_nav_ctl.active = TRUE;
00386                 }
00387             }
00388             else if ( resp2 == AVC1394_VCR_RESPONSE_TRANSPORT_STATE_WIND )
00389             {
00390                 if ( resp3 == AVC1394_VCR_OPERAND_WIND_HIGH_SPEED_REWIND )
00391                 {
00392                     common->toggleComponents( VIDEO_START_OF_MOVIE, true );
00393                 }
00394                 else if ( resp3 == AVC1394_VCR_OPERAND_WIND_STOP )
00395                 {
00396                     stopCapture();
00397                     common->toggleComponents( VIDEO_STOP, true );
00398                 }
00399                 else if ( resp3 == AVC1394_VCR_OPERAND_WIND_REWIND )
00400                 {
00401                     common->toggleComponents( VIDEO_START_OF_MOVIE, true );
00402                 }
00403                 else if ( resp3 == AVC1394_VCR_OPERAND_WIND_FAST_FORWARD )
00404                 {
00405                     common->toggleComponents( VIDEO_END_OF_MOVIE, true );
00406                 }
00407                 else
00408                 {
00409                     std::cerr << "AVC Status: Unkown winding" << std::endl;
00410                 }
00411             }
00412             else if ( resp2 == AVC1394_VCR_RESPONSE_TRANSPORT_STATE_RECORD )
00413             {
00414                 if ( resp3 == AVC1394_VCR_OPERAND_RECORD_PAUSE )
00415                 {
00416                     common->toggleComponents( VIDEO_PLAY, false );
00417                 }
00418                 else
00419                 {
00420                     common->toggleComponents( VIDEO_PLAY, true );
00421                     g_nav_ctl.active = TRUE;
00422                 }
00423             }
00424             else
00425             {
00426                 std::cerr << "AVC Status: Unknown state" << std::endl;
00427             }
00428             common->commitComponentState();
00429         }
00430     }
00431     else
00432     {
00433         if ( gui_state_was != 3 )
00434         {
00435             gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), true );
00436             gtk_widget_set_sensitive( GTK_WIDGET( recordButton ), true );
00437             gtk_widget_set_sensitive( GTK_WIDGET( stopButton ), true );
00438             gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), true );
00439             gtk_widget_set_sensitive( GTK_WIDGET( muteButton ), true );
00440             validComponents = 0;
00441             common->activateWidgets( );
00442             common->commitComponentState();
00443             if ( !isCapturing )
00444                 common->setStatusBar( _( "AV/C Controls Not Enabled." ) );
00445             gui_state_was = 3;
00446         }
00447     }
00448 }

void PageCapture::CheckDevices  ) 
 

Check devices and status.

Definition at line 205 of file page_capture.cc.

References avc, avc_enabled, avcStatus, check_phyid, driver_available, driver_locked, Preferences::getInstance(), AVC::getNodeId(), AVC::getPort(), isCapturing, AVC::isPhyIDValid(), AVC::Noop(), reader, IEEE1394Reader::StartThread(), IEEE1394Reader::StopThread(), timecode, AVC::Timecode(), AVC::TransportStatus(), and TriggerAction().

00206 {
00207     static int avcRetry = 0;
00208 
00209     if ( driver_locked == true )
00210     {
00211         std::cerr << "Stopping thread" << std::endl;
00212         reader->StopThread( );
00213         driver_locked = false;
00214         driver_available = false;
00215         avc_enabled = false;
00216         check_phyid = true;
00217         TriggerAction( );
00218     }
00219     else if ( driver_available == false )
00220     {
00221         // Check if the id of the device is valid
00222         Preferences::getInstance( ).phyID = avc->getNodeId( Preferences::getInstance( ).avcGUID );
00223         Preferences::getInstance( ).phyID = avc->isPhyIDValid( Preferences::getInstance( ).phyID );
00224         check_phyid = Preferences::getInstance( ).phyID < 0;
00225 
00226         // Start the reader thread
00227         //std::cerr << "Starting thread" << std::endl;
00228         if ( reader->StartThread( ( avc->getPort() < 0 ) ? 0 : avc->getPort() ) )
00229         {
00230             // The drivers are installed
00231             driver_available = true;
00232             avc_enabled = false;
00233         }
00234         TriggerAction( );
00235     }
00236     else if ( check_phyid )
00237     {
00238         // Check that we're still valid.
00239         Preferences::getInstance( ).phyID = avc->isPhyIDValid( Preferences::getInstance( ).phyID );
00240         check_phyid = Preferences::getInstance( ).phyID < 0;
00241         avc_enabled = false;
00242         TriggerAction( );
00243     }
00244     else if ( avc_enabled )
00245     {
00246         quadlet_t status = avc->TransportStatus( Preferences::getInstance().phyID );
00247 
00248         if ( ( int ) status < 0 )
00249         {
00250             cerr << ">>> AVC status error" << std::endl;
00251             if ( ++avcRetry > 2 )
00252             {
00253                 avcRetry = 0;
00254                 avc_enabled = false;
00255                 check_phyid = true;
00256             }
00257         }
00258         else
00259         {
00260             char t[ 12 ];
00261 
00262             avcStatus = status;
00263             avcRetry = 0;
00264 
00265             if ( !isCapturing && avc->Timecode( Preferences::getInstance().phyID, t ) )
00266             {
00267                 strncpy( timecode, t, 12 );
00268             }
00269             TriggerAction();
00270         }
00271     }
00272     else
00273     {
00274         avc_enabled = Preferences::getInstance().enableAVC;
00275         gtk_toggle_button_set_active( this->avcButton, avc_enabled );
00276         avc->Noop();
00277     }
00278 }

void PageCapture::clean  )  [virtual]
 

Leaving the page.

Reimplemented from Page.

Definition at line 461 of file page_capture.cc.

References navigate_control::active, avc, avc_enabled, avcthread, navigate_control::capture_active, capturethread, common, g_nav_ctl, Preferences::getInstance(), reader, KinoCommon::setStatusBar(), stopCapture(), IEEE1394Reader::StopThread(), IEEE1394Reader::TriggerAction(), videoStop(), and videothread.

00462 {
00463     std::cerr << ">> Leaving Capture" << std::endl;
00464     
00465     if ( g_nav_ctl.capture_active == TRUE )
00466     {
00467         // Stop the capture
00468         stopCapture();
00469 
00470         // Stop the video
00471         if ( avc_enabled && Preferences::getInstance( ).phyID >= 0 )
00472             videoStop();
00473 
00474         // Start the deactivation process for the backround processes
00475         g_nav_ctl.active = FALSE;
00476         g_nav_ctl.capture_active = FALSE;
00477 
00478         // Join with the capture thread to make sure we're definitely finished
00479         reader->TriggerAction();
00480         pthread_join( capturethread, NULL );
00481         pthread_join( avcthread, NULL );
00482 
00483         // Stop the video thread
00484         gdk_threads_leave();
00485         pthread_join( videothread, NULL );
00486         gdk_threads_enter();
00487 
00488         // Stop the reading thread
00489         reader->StopThread();
00490     }
00491 
00492     common->setStatusBar( "" );
00493 
00494     // Clean up objects created in start
00495     delete displayer;
00496     displayer = NULL;
00497     delete reader;
00498     reader = NULL;
00499     delete avc;
00500     avc = NULL;
00501 }

void PageCapture::collectFiles  ) 
 

Definition at line 1403 of file page_capture.cc.

References CAPTURE_FRAME_APPEND, CAPTURE_FRAME_INSERT, CAPTURE_IGNORE, CAPTURE_MOVIE_APPEND, common, KinoCommon::g_currentFrame, FileTracker::GetInstance(), KinoCommon::getPageEditor(), KinoCommon::getPlayList(), KinoCommon::hasListChanged, and KinoCommon::loadMediaObject().

01404 {
01405         string file;
01406         
01407         // Pick up any captured files
01408         for ( unsigned int index = 0; index < FileTracker::GetInstance().Size(); index ++ )
01409         {
01410             file = FileTracker::GetInstance().Get( ( int ) index );
01411             if ( index == FileTracker::GetInstance().Size() - 1 )
01412                 break;
01413             cerr << ">>> File " << file << " returned from tracker" << endl;
01414             switch ( FileTracker::GetInstance().GetMode() )
01415             {
01416                 case CAPTURE_IGNORE:
01417                     // Do nothing
01418                     break;
01419                 case CAPTURE_FRAME_INSERT:
01420                     common->loadMediaObject( const_cast< char* >( file.c_str() ), common->g_currentFrame == -1 ? 0 : common->g_currentFrame );
01421                     break;
01422                 case CAPTURE_FRAME_APPEND:
01423                     common->loadMediaObject( const_cast< char* >( file.c_str() ), common->g_currentFrame + 1 );
01424                     break;
01425                 case CAPTURE_MOVIE_APPEND:
01426                     common->loadMediaObject( const_cast< char* >( file.c_str() ), common->getPlayList() ->GetNumFrames() );
01427                     break;
01428             }
01429             common->hasListChanged = TRUE;
01430         }
01431         
01432         // Clear the list to avoid reloading on a subsequent re-entry
01433         FileTracker::GetInstance().Clear();
01434 
01435         if ( file.length() )
01436             FileTracker::GetInstance().Add( file.c_str() );
01437 
01438         // Just to make sure we refresh what needs to be refreshed
01439         if ( common->hasListChanged )
01440         {
01441             gdk_threads_enter();
01442             common->getPageEditor()->DrawBar( common->g_currentFrame );
01443             gdk_threads_leave();
01444         }
01445 }

quadlet_t PageCapture::getAVCState  )  [inline]
 

Definition at line 90 of file page_capture.h.

References avcState.

00091     {
00092         return this->avcState;
00093     }

Frame * PageCapture::getFrame  ) 
 

Fetch the currently showing frame.

Definition at line 1397 of file page_capture.cc.

References frameBuffer, and framePosition.

Referenced by showFrameInfo().

01398 {
01399     return frameBuffer[ framePosition ];
01400 }

std::string PageCapture::getHelpPage  )  [inline, virtual]
 

Reimplemented from Page.

Definition at line 103 of file page_capture.h.

00104     {
00105         return "capture";
00106     }

void PageCapture::newFile  )  [virtual]
 

Called when a new file operation is selected by the user.

Reimplemented from Page.

Definition at line 129 of file page_capture.cc.

References lastPreferenceFilename.

00130 {
00131     strcpy( lastPreferenceFilename, "" );
00132 }

gboolean PageCapture::processCommand char *  command  )  [virtual]
 

Internal method for handling a complete keyboard scene.

Parameters:
cmd command to be processed;

Reimplemented from Page.

Definition at line 825 of file page_capture.cc.

References navigate_control::active, avc_enabled, KinoCommon::changePageRequest(), cmd, common, count, KinoCommon::g_currentFrame, g_nav_ctl, Preferences::getInstance(), isCapturing, KinoCommon::keyboardFeedback(), kinoDeactivate(), lastcmd, PAGE_EDITOR, PAGE_EXPORT, PAGE_MAGICK, PAGE_TIMELINE, PAGE_TRIM, KinoCommon::savePlayList(), startCapture(), stopCapture(), validComponents, KinoCommon::videoBack(), KinoCommon::videoEndOfMovie(), videoEndOfScene(), KinoCommon::videoEndOfScene(), KinoCommon::videoFastForward(), KinoCommon::videoForward(), KinoCommon::videoNextScene(), KinoCommon::videoPause(), KinoCommon::videoPlay(), KinoCommon::videoPreviousScene(), KinoCommon::videoRewind(), KinoCommon::videoStartOfMovie(), videoStartOfScene(), KinoCommon::videoStartOfScene(), and KinoCommon::videoStop().

Referenced by processKeyboard().

00826 {
00827     int count = 1;
00828     char real[ 256 ] = "";
00829 
00830     strcpy( cmd, command );
00831 
00832     switch ( sscanf( cmd, "%d%s", &count, real ) )
00833     {
00834     case 1:
00835         // Numeric value only - return immediately if the cmd is not "0"
00836         if ( strcmp( cmd, "0" ) )
00837         {
00838             common->keyboardFeedback( cmd, "" );
00839             return FALSE;
00840         }
00841         break;
00842     case 0:
00843         sscanf( cmd, "%s", real );
00844         count = 1;
00845         break;
00846     }
00847 
00848     strcpy( lastcmd, cmd );
00849 
00850     /* mode switching */
00851     
00852     if ( strcmp( cmd, "t" ) == 0 )
00853     {
00854         common->keyboardFeedback( cmd, _( "Trim" ) );
00855         common->changePageRequest( PAGE_TRIM );
00856         cmd[ 0 ] = 0;
00857     }
00858 
00859     else if ( strcmp( cmd, "v" ) == 0 )
00860     {
00861         common->keyboardFeedback( cmd, _( "Timeline" ) );
00862         common->changePageRequest( PAGE_TIMELINE );
00863         cmd[ 0 ] = 0;
00864     }
00865 
00866     else if ( strcmp( cmd, "C" ) == 0 )
00867     {
00868         common->keyboardFeedback( cmd, _( "FX" ) );
00869         common->changePageRequest( PAGE_MAGICK );
00870         cmd[ 0 ] = 0;
00871     }
00872 
00873     /* switch to export mode */
00874 
00875     else if ( strcmp( cmd, ":W" ) == 0 )
00876     {
00877         common->keyboardFeedback( cmd, _( "Export" ) );
00878         common->changePageRequest( PAGE_EXPORT );
00879         cmd[ 0 ] = 0;
00880     }
00881 
00882     else if ( strcmp( cmd, "F2" ) == 0 )
00883     {
00884         common->keyboardFeedback( cmd, _( "Edit" ) );
00885         common->changePageRequest( PAGE_EDITOR );
00886         cmd[ 0 ] = 0;
00887     }
00888 
00889     /* write PlayList */
00890 
00891     else if ( strcmp( cmd, ":w" ) == 0 )
00892     {
00893         common->keyboardFeedback( cmd, _( "Write playlist" ) );
00894         common->savePlayList( );
00895         cmd[ 0 ] = 0;
00896     }
00897 
00898     /* quit */
00899 
00900     else if ( strcmp( cmd, ":q" ) == 0 )
00901     {
00902         common->keyboardFeedback( cmd, _( "quit" ) );
00903         kinoDeactivate();
00904         cmd[ 0 ] = 0;
00905     }
00906     
00907     else if ( strcmp( real, "Enter" ) == 0 && ! isCapturing )
00908     {
00909         common->keyboardFeedback( cmd, _( "Start Capture" ) );
00910         startCapture();
00911         cmd[ 0 ] = 0;
00912     }
00913 
00914     else if ( strcmp( real, "Esc" ) == 0 )
00915     {
00916         if ( this->isCapturing )
00917         {
00918             common->keyboardFeedback( "Esc", _( "Stop Capture" ) );
00919             stopCapture();
00920         }
00921         else if ( avc_enabled && Preferences::getInstance( ).phyID >= 0 )
00922         {
00923             common->keyboardFeedback( "Esc", _( "Stop" ) );
00924             common->videoStop( );
00925         }
00926         cmd[ 0 ] = 0;
00927     }
00928 
00929     /* Navigation */
00930 
00931     if ( validComponents == 0 || Preferences::getInstance( ).phyID < 0 )
00932         return FALSE;
00933 
00934     /* play, pause */
00935 
00936     if ( strcmp( cmd, " " ) == 0 )
00937     {
00938         if ( g_nav_ctl.active == FALSE )
00939         {
00940             common->keyboardFeedback( cmd, _( "Play" ) );
00941             common->videoPlay( );
00942         }
00943         else
00944         {
00945             common->keyboardFeedback( cmd, _( "Pause" ) );
00946             common->videoPause( );
00947         }
00948         cmd[ 0 ] = 0;
00949     }
00950 
00951     /* advance one frame */
00952 
00953     else if ( strcmp( real, "l" ) == 0 )
00954     {
00955         common->keyboardFeedback( cmd, _( "Move forward" ) );
00956         common->videoForward();
00957         cmd[ 0 ] = 0;
00958     }
00959 
00960     /* backspace one frame */
00961 
00962     else if ( strcmp( real, "h" ) == 0 )
00963     {
00964         common->keyboardFeedback( cmd, _( "Move backward" ) );
00965         common->videoBack();
00966         cmd[ 0 ] = 0;
00967     }
00968 
00969     /* advance one second */
00970 
00971     else if ( ( strcmp( real, "w" ) == 0 || strcmp( real, "W" ) == 0 ||
00972                 strcmp( real, "e" ) == 0 || strcmp( real, "E" ) == 0 ) )
00973     {
00974         common->keyboardFeedback( cmd, _( "Fast Forward" ) );
00975         common->videoFastForward();
00976         cmd[ 0 ] = 0;
00977     }
00978 
00979     /* backspace one second */
00980 
00981     else if ( ( strcmp( real, "b" ) == 0 || strcmp( real, "B" ) == 0 ) )
00982     {
00983         common->keyboardFeedback( cmd, _( "Rewind" ) );
00984         common->videoRewind();
00985         cmd[ 0 ] = 0;
00986     }
00987 
00988     /* start of scene */
00989 
00990     else if ( ( strcmp( cmd, "0" ) == 0 || strcmp( real, "^" ) == 0 ) )
00991     {
00992         common->videoStartOfScene( );
00993         for ( ; count > 1; count -- )
00994         {
00995             common->g_currentFrame --;
00996             videoStartOfScene( );
00997         }
00998         common->keyboardFeedback( cmd, _( "Move to start of scene" ) );
00999         cmd[ 0 ] = 0;
01000     }
01001 
01002     /* end of scene */
01003 
01004     else if ( strcmp( real, "$" ) == 0 )
01005     {
01006         common->videoEndOfScene( );
01007         for ( ; count > 1; count -- )
01008         {
01009             common->g_currentFrame ++;
01010             videoEndOfScene( );
01011         }
01012         common->keyboardFeedback( cmd, _( "Move to end of scene" ) );
01013         cmd[ 0 ] = 0;
01014     }
01015 
01016     /* start of next scene */
01017 
01018     else if ( ( strcmp( real, "j" ) == 0 || strcmp( real, "+" ) == 0 ) )
01019     {
01020         for ( ; count >= 1; count -- )
01021             common->videoNextScene( );
01022         common->keyboardFeedback( cmd, _( "Move to start of next scene" ) );
01023         cmd[ 0 ] = 0;
01024     }
01025 
01026     /* start of previous scene */
01027 
01028     else if ( ( strcmp( real, "k" ) == 0 || strcmp( real, "-" ) == 0 ) )
01029     {
01030         for ( ; count >= 1; count -- )
01031             common->videoPreviousScene( );
01032         common->keyboardFeedback( cmd, _( "Move to start of previous scene" ) );
01033         cmd[ 0 ] = 0;
01034     }
01035 
01036     /* first frame */
01037 
01038     else if ( strcmp( cmd, "gg" ) == 0 )
01039     {
01040         common->videoStartOfMovie( );
01041         common->keyboardFeedback( cmd, _( "Move to first frame" ) );
01042         cmd[ 0 ] = 0;
01043     }
01044 
01045     /* last frame */
01046 
01047     else if ( strcmp( cmd, "G" ) == 0 )
01048     {
01049         common->videoEndOfMovie( );
01050         common->keyboardFeedback( cmd, _( "Move to last frame" ) );
01051         cmd[ 0 ] = 0;
01052     }
01053 
01054     else
01055     {
01056         // Check for invalid commands
01057         if ( strlen( real ) > 3 )
01058             cmd[ 0 ] = 0;
01059         else if ( strchr( "dgy ", real[ strlen( real ) - 1 ] ) == NULL )
01060             cmd[ 0 ] = 0;
01061 
01062         common->keyboardFeedback( cmd, "" );
01063 
01064 #if 0
01065 
01066         printf( "send_event: %2.2x\n", event->send_event );
01067         printf( "time  : %8.8x\n", event->time );
01068         printf( "state : %8.8x\n", event->state );
01069         printf( "keyval: %8.8x\n", event->keyval );
01070         printf( "length: %8.8x\n", event->length );
01071         printf( "string: %s\n", event->string );
01072         printf( "(hex) : %2.2x\n", event->string[ 0 ] );
01073         printf( "cmd   : %s\n", cmd );
01074 #endif
01075 
01076     }
01077 
01078     return FALSE;
01079 }

gboolean PageCapture::processKeyboard GdkEventKey *  event  )  [virtual]
 

Process a keyboard event.

Parameters:
event keyboard event

Reimplemented from Page.

Definition at line 730 of file page_capture.cc.

References avc_enabled, KinoCommon::changePageRequest(), cmd, common, navigate_control::escaped, fileEntry, g_nav_ctl, KinoCommon::getComponentState(), Preferences::getInstance(), KinoCommon::getWidget(), KinoCommon::keyboardFeedback(), lastcmd, PAGE_EDITOR, processCommand(), startCapture(), stopCapture(), VIDEO_STOP, and KinoCommon::videoStop().

00731 {
00732     gboolean ret = FALSE;
00733 
00734     // Only process while not escape mode
00735     if ( g_nav_ctl.escaped == FALSE )
00736     {
00737         if ( strcmp( lastcmd, "alt" ) == 0 )
00738         {
00739             strcpy( lastcmd, "" );
00740             return ret;
00741         }
00742 
00743         // Translate special keys to equivalent command
00744         switch ( event->keyval )
00745         {
00746         case GDK_Home:
00747             strcat( cmd, "gg");
00748             ret = TRUE;
00749             break;
00750         case GDK_End:
00751             strcat( cmd, "G");
00752             ret = TRUE;
00753             break;
00754         case GDK_BackSpace:
00755         case GDK_Left:
00756             strcat( cmd, "h" );
00757             ret = TRUE;
00758             break;
00759         case GDK_Up:
00760             strcat( cmd, "k" );
00761             ret = TRUE;
00762             break;
00763         case GDK_Right:
00764             strcat( cmd, "l" );
00765             ret = TRUE;
00766             break;
00767         case GDK_Return:
00768             startCapture();
00769             cmd[ 0 ] = 0;
00770             break;
00771         case GDK_Down:
00772             strcat( cmd, "j" );
00773             ret = TRUE;
00774             break;
00775         case GDK_Escape:
00776             if ( this->isCapturing )
00777             {
00778                 common->keyboardFeedback( "Esc", _( "Stop Capture" ) );
00779                 stopCapture();
00780             }
00781             else if ( common->getComponentState() & VIDEO_STOP )
00782             {
00783                 common->changePageRequest( PAGE_EDITOR );
00784             }
00785             else if ( avc_enabled && Preferences::getInstance( ).phyID >= 0 )
00786             {
00787                 common->keyboardFeedback( "Esc", _( "Stop" ) );
00788                 common->videoStop( );
00789             }
00790             else
00791             {
00792                 common->changePageRequest( PAGE_EDITOR );
00793             }
00794             cmd[ 0 ] = 0;
00795             return TRUE;
00796         case GDK_Alt_L:
00797         case GDK_Alt_R:
00798             strcpy( lastcmd, "alt" );
00799             return ret;
00800         default:
00801             strcat( cmd, event->string );
00802             break;
00803         }
00804 
00805         if ( !strcmp( cmd, "." ) )
00806             strcpy( cmd, lastcmd );
00807 
00808         processCommand( cmd );
00809 
00810     }
00811     else if ( event->keyval == GDK_Return || event->keyval == GDK_Escape )
00812     {
00813         g_nav_ctl.escaped = FALSE;
00814         gtk_entry_set_editable( fileEntry, FALSE );
00815         gtk_widget_grab_focus( common->getWidget() );
00816     }
00817     return ret;
00818 }

void PageCapture::saveFrame  )  [virtual]
 

Save a single still frame of video to the disk.

Reimplemented from Page.

Definition at line 1311 of file page_capture.cc.

References common, FRAME_MAX_HEIGHT, FRAME_MAX_WIDTH, frameBuffer, framePosition, KinoCommon::getFileToSave(), AspectRatioCalculator::height, Frame::IsPAL(), modal_message(), pixels, and AspectRatioCalculator::width.

01312 {
01313     Frame * frame = frameBuffer[ framePosition ];
01314 
01315     if ( frame != NULL )
01316     {
01317         unsigned char pixels[ FRAME_MAX_WIDTH * FRAME_MAX_HEIGHT * 4 ];
01318         GError *gerror = NULL;
01319 
01320         frame->ExtractPreviewRGB( pixels );
01321         GdkPixbuf *im = gdk_pixbuf_new_from_data
01322                         ( pixels, GDK_COLORSPACE_RGB, FALSE, 8,
01323                           frame->GetWidth(), frame->GetHeight(),
01324                           frame->GetWidth() * 3, NULL, NULL );
01325 
01326         // resample pixel aspect
01327         {
01328             int width = frame->GetWidth();
01329             if ( frame->IsWide() )
01330                 width = frame->IsPAL() ? 1024 : 854;
01331             AspectRatioCalculator calc( width, frame->GetHeight(),
01332                                     frame->GetWidth(), frame->GetHeight(),
01333                                     frame->IsPAL(), frame->IsWide() );
01334             GdkPixbuf *scaled = gdk_pixbuf_scale_simple( im, calc.width, calc.height, GDK_INTERP_HYPER );
01335             g_object_unref( im );
01336             im = scaled;
01337         }
01338 
01339         char *filename = common->getFileToSave( _( "Save Still Frame" ) );
01340         if ( strcmp( filename, "" ) )
01341         {
01342             const std::string FileName( filename );
01343             const std::string suffix( FileName.begin() + FileName.rfind( "." ), FileName.end() );
01344             if ( suffix == ".png" )
01345                 gdk_pixbuf_save( im, filename, "png", &gerror, NULL );
01346             else
01347                 gdk_pixbuf_save( im, filename, "jpeg", &gerror, "quality", "80", NULL );
01348             if ( gerror != NULL )
01349             {
01350                 modal_message( gerror->message );
01351                 g_error_free( gerror );
01352             }
01353         }
01354 
01355         g_object_unref( im );
01356     }
01357 }

void PageCapture::showFrameInfo int   )  [virtual]
 

Show the AV/C timecode.

Reimplemented from Page.

Definition at line 1370 of file page_capture.cc.

References avc_enabled, common, IEEE1394Reader::GetDroppedFrames(), getFrame(), Frame::GetFrameRate(), KinoCommon::getTime(), KinoCommon::getTimeFormat(), KinoCommon::getWidget(), isCapturing, lookup_widget(), reader, SMIL::Time::TIME_FORMAT_NONE, timecode, and timecodeLabel.

01371 {
01372     GtkLabel *total = GTK_LABEL( lookup_widget( common->getWidget(), "position_label_total" ) );
01373     string tc;
01374     char msg[ 128 ] = "";
01375     Frame *frame = getFrame();
01376     
01377     if ( isCapturing && frame )
01378     {
01379         common->getTime().setFramerate( frame->GetFrameRate() );
01380         string tc = "<span size=\"x-large\">" + common->getTime().parseFramesToString( i, common->getTimeFormat() ) + "</span>";
01381         gtk_label_set_markup( timecodeLabel, tc.c_str() );
01382         gtk_widget_set_redraw_on_allocate( GTK_WIDGET( timecodeLabel ), FALSE );
01383         snprintf( msg, 128, "%s %d", _("Dropped:"), reader->GetDroppedFrames() );
01384         gtk_label_set_markup( total, msg );
01385     }
01386     else if ( avc_enabled && common->getTimeFormat() != SMIL::Time::TIME_FORMAT_NONE )
01387     {
01388         snprintf( msg, 128, "<span size=\"x-large\">%s</span>", timecode );
01389         gtk_label_set_markup( timecodeLabel, msg );
01390         gtk_widget_set_redraw_on_allocate( GTK_WIDGET( timecodeLabel ), FALSE );
01391         gtk_label_set_markup( total, "" );
01392     }
01393 }

void PageCapture::start  )  [virtual]
 

Start of page.

Reimplemented from Page.

Definition at line 137 of file page_capture.cc.

References KinoCommon::activateWidgets(), audioOn, avc, avc_enabled, avcButton, avcThread(), avcthread, navigate_control::capture_active, captureThread(), capturethread, check_phyid, KinoCommon::commitComponentState(), common, driver_available, fileEntry, g_nav_ctl, Preferences::getInstance(), KinoCommon::getPlayList(), KinoCommon::getWidget(), gui_state_was, lastPreferenceFilename, lookup_widget(), KinoCommon::packIt(), reader, timecodeLabel, KinoCommon::toggleComponents(), validComponents, VIDEO_STOP, videoThread, and videothread.

00138 {
00139     std::cerr << ">> Starting Capture" << std::endl;
00140 
00141     // By default, AVC is always disabled
00142     driver_available = false;
00143     check_phyid = true;
00144     avc_enabled = false;
00145     validComponents = 0;
00146     gui_state_was = -1;
00147 
00148     gtk_toggle_button_set_active( avcButton, Preferences::getInstance().enableAVC );
00149     GtkLabel *label = GTK_LABEL( lookup_widget( common->getWidget(), "position_label_total" ) );
00150     gtk_label_set_text( label, "" );
00151 
00152     // Create the reader object
00153 #ifdef HAVE_IEC61883
00154     reader = new iec61883Reader( Preferences::getInstance().channel,
00155                                  Preferences::getInstance().dvCaptureBuffers );
00156 #else
00157     reader = new dv1394Reader( Preferences::getInstance().channel,
00158                                Preferences::getInstance().dvCaptureBuffers );
00159 #endif
00160 
00161     // Create the AV/C object
00162     avc = new AVC();
00163 
00164     // Determine the capture directory and file - rules are:
00165     // 1) if a full path is specified in the preferences, then use that
00166     // 2) if a non-full path is specified, then pick up the project directory and attach preference
00167 
00168     string capture_file_name = Preferences::getInstance().file;
00169     if ( capture_file_name[ 0 ] != '/' )
00170         capture_file_name = common->getPlayList( ) ->GetProjectDirectory( ) + "/" + capture_file_name;
00171 
00172     // If the preferences have changed, then update the filename
00173 
00174     if ( capture_file_name != lastPreferenceFilename )
00175     {
00176         strcpy( lastPreferenceFilename, capture_file_name.c_str( ) );
00177         gtk_entry_set_text( fileEntry, capture_file_name.c_str( ) );
00178     }
00179 
00180     // Have the GUI reflect the mute status
00181     gtk_toggle_button_set_active( this->muteButton, !audioOn );
00182 
00183     // Create the FrameDisplayer
00184     displayer = new FrameDisplayer;
00185 
00186     // Set up the preview rendering
00187     g_nav_ctl.capture_active = TRUE;
00188     pthread_create( &capturethread, NULL, captureThread, this );
00189     pthread_create( &avcthread, NULL, avcThread, this );
00190     pthread_create( &videothread, NULL, videoThread, lookup_widget( common->getWidget(), "capture_drawingarea" ) );
00191 
00192     common->activateWidgets();
00193     gtk_label_set_text( timecodeLabel, "" );
00194     common->packIt( "packer_capture", "packer_capture_outer" );
00195     common->toggleComponents( VIDEO_STOP, false );
00196     common->commitComponentState();
00197 
00198     gtk_notebook_set_page( GTK_NOTEBOOK( lookup_widget( common->getWidget(), "notebook_keyhelp" ) ), 1 );
00199     gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( lookup_widget( common->getWidget(), "menuitem_capture" ) ), TRUE );
00200 }

void PageCapture::startCapture  ) 
 

Start capturing video to the disk.

If AV/C is enabled, tell the device to play and temporarily disable AV/C and shutdown the AV/C status/timecode monitor.

Definition at line 1086 of file page_capture.cc.

References KinoCommon::activateWidgets(), navigate_control::active, avc_enabled, avcButton, AVI_DV1_FORMAT, AVI_DV2_FORMAT, captureMutex, KinoCommon::commitComponentState(), common, fileEntry, frameBuffer, framePosition, g_nav_ctl, FileHandler::GetFilename(), Preferences::getInstance(), gui_state_was, isCapturing, Frame::IsNormalSpeed(), modal_message(), muteButton, QT_FORMAT, RAW_FORMAT, reader, recordButton, IEEE1394Reader::ResetDroppedFrames(), FileHandler::SetAutoSplit(), FileHandler::SetBaseName(), FileHandler::SetEveryNthFrame(), FileHandler::SetMaxFileSize(), FileHandler::SetMaxFrameCount(), AVIHandler::SetOpenDML(), KinoCommon::setStatusBar(), FileHandler::SetTimeStamp(), snapshotButton, stopButton, stopCapture(), validComponents, videoPlay(), FileHandler::WriteFrame(), writer, and writerlock.

Referenced by processCommand(), and processKeyboard().

01087 {
01088     if ( !captureMutex && !isCapturing )
01089     {
01090         captureMutex = true;
01091         isCapturing = true;
01092         gtk_toggle_button_set_active( recordButton, true );
01093         gtk_toggle_button_set_active( stopButton, false );
01094         gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), false );
01095         gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), false );
01096         captureMutex = false;
01097 
01098         char filename[ 512 ];
01099         strcpy( filename, gtk_entry_get_text( fileEntry ) );
01100 
01101         if ( !strcmp( filename, "" ) )
01102         {
01103             common->setStatusBar( _( "You must enter a filename to capture." ) );
01104             captureMutex = true;
01105             gtk_toggle_button_set_active( recordButton, false );
01106             gtk_toggle_button_set_active( stopButton, true );
01107             gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), true );
01108             gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), true );
01109             captureMutex = false;
01110             isCapturing = false;
01111 
01112         }
01113         else
01114         {
01115             Frame *frame = NULL;
01116             int retry;
01117             const int MAX_RETRIES = 10;
01118             struct timespec t =
01119                 {
01120                     1, 0UL
01121                 };
01122 
01123             if ( avc_enabled )
01124             {
01125                 g_nav_ctl.active = FALSE;
01126                 videoPlay();
01127                 g_nav_ctl.active = TRUE;
01128                 gui_state_was = 2;
01129                 validComponents = 0;
01130                 common->activateWidgets( );
01131                 common->commitComponentState();
01132                 gtk_widget_set_sensitive( GTK_WIDGET( recordButton ), true );
01133                 gtk_widget_set_sensitive( GTK_WIDGET( stopButton ), true );
01134                 gtk_widget_set_sensitive( GTK_WIDGET( muteButton ), true );
01135                 gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), false );
01136                 gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), false );
01137             }
01138 
01139             FileHandler *handler = NULL;
01140 
01141             switch ( Preferences::getInstance().fileFormat )
01142             {
01143             case RAW_FORMAT:
01144                 handler = new RawHandler();
01145                 break;
01146 #ifdef HAVE_LIBQUICKTIME
01147 
01148             case QT_FORMAT:
01149                 handler = new QtHandler();
01150                 break;
01151 #endif
01152 
01153             case AVI_DV1_FORMAT:
01154             case AVI_DV2_FORMAT:
01155                 AVIHandler *aviWriter = new AVIHandler( Preferences::getInstance().fileFormat );
01156                 handler = aviWriter;
01157                 aviWriter->SetOpenDML( Preferences::getInstance().isOpenDML ||
01158                                        Preferences::getInstance().maxFileSize == 0 ||
01159                                        Preferences::getInstance().maxFileSize > 1000 );
01160                 break;
01161             }
01162 
01163             /* set command line parameters to the handler object */
01164 
01165             handler->SetMaxFrameCount( Preferences::getInstance().frames );
01166             handler->SetAutoSplit( Preferences::getInstance().autoSplit );
01167             handler->SetTimeStamp( Preferences::getInstance().timeStamp );
01168             handler->SetEveryNthFrame( Preferences::getInstance().every );
01169             handler->SetMaxFileSize( ( off_t ) Preferences::getInstance().maxFileSize * ( off_t ) ( 1024 * 1024 ) );
01170             handler->SetBaseName( filename );
01171 
01172             // without this, if no video has yet played, then frameBuffer is
01173             // likely to be empty due to latency of avcPlay above
01174             for ( retry = MAX_RETRIES; retry > 0 && isCapturing; --retry )
01175             {
01176                 frame = frameBuffer[ framePosition ];
01177 
01178                 if ( frame != NULL )
01179                 {
01180                     // frame must be normal speed to get correct audio stream params for type2 AVI
01181                     if ( frame->IsNormalSpeed() )
01182                     {
01183                         reader->ResetDroppedFrames();
01184                         if ( handler->WriteFrame( *frame ) == false )
01185                         {
01186                             delete handler;
01187                             captureMutex = false;
01188                             stopCapture();
01189                             modal_message( _( "Failed to write to file. Is file name OK?" ) );
01190                         }
01191                         else
01192                         {
01193                             pthread_mutex_lock( &writerlock );
01194                             writer = handler;
01195                             pthread_mutex_unlock( &writerlock );
01196                             common->setStatusBar( ( string( _( "Capturing " ) ) + handler->GetFilename() ).c_str() );
01197                         }
01198                         break;
01199                     }
01200                 }
01201                 common->setStatusBar( _( "Waiting for DV %s%d ..." ),
01202                                       ( avc_enabled ? "" : _( "(press play on camera) " ) ), retry );
01203                 while ( gtk_events_pending() )
01204                     gtk_main_iteration();
01205                 nanosleep( &t, NULL );
01206             }
01207             if ( retry == 0 && isCapturing )
01208             {
01209                 // timed out waiting for iso stream, stop capture
01210                 this->stopCapture();
01211                 common->setStatusBar( _( "Capture failed." ) );
01212             }
01213             else if ( !isCapturing )
01214                 common->setStatusBar( _( "Capture stopped." ) );
01215         }
01216     }
01217     else if ( !captureMutex )
01218     {
01219         captureMutex = true;
01220         gtk_toggle_button_set_active( recordButton, true );
01221         captureMutex = false;
01222     }
01223 }

void PageCapture::stopCapture  ) 
 

Stop capturing video to the disk.

If AV/C was previously enabled, then re-enable it, pause the device and restart the AV/C status/timecode monitor.

Definition at line 1230 of file page_capture.cc.

References audioOn, avc_enabled, avcButton, CAPTURE_FRAME_APPEND, CAPTURE_FRAME_INSERT, CAPTURE_IGNORE, CAPTURE_MOVIE_APPEND, captureMutex, FileHandler::Close(), common, KinoCommon::g_currentFrame, GetEditorBackup(), FileTracker::GetInstance(), KinoCommon::getPageEditor(), KinoCommon::getPlayList(), gui_state_was, KinoCommon::hasListChanged, isCapturing, KinoCommon::loadMediaObject(), recordButton, KinoCommon::setStatusBar(), KinoCommon::setWindowTitle(), snapshotButton, stopButton, videoPause(), writer, and writerlock.

Referenced by applyAVCState(), clean(), processCommand(), processKeyboard(), and startCapture().

01231 {
01232 
01233     if ( !captureMutex && isCapturing )
01234     {
01235         captureMutex = true;
01236 
01237         pthread_mutex_lock( &writerlock );
01238         if ( writer != NULL )
01239         {
01240             writer->Close();
01241             delete writer;
01242             writer = NULL;
01243         }
01244         pthread_mutex_unlock( &writerlock );
01245 
01246         gtk_toggle_button_set_active( recordButton, false );
01247         gtk_toggle_button_set_active( stopButton, true );
01248         gtk_widget_set_sensitive( GTK_WIDGET( snapshotButton ), true );
01249         gtk_widget_set_sensitive( GTK_WIDGET( avcButton ), true );
01250 
01251         audioOn = FALSE;
01252         gtk_toggle_button_set_active( this->muteButton, !audioOn );
01253 
01254         if ( avc_enabled )
01255         {
01256             gtk_toggle_button_set_active( avcButton, avc_enabled );
01257             gui_state_was = -1;
01258             videoPause( );
01259         }
01260         common->setStatusBar( "" );
01261         isCapturing = false;
01262         captureMutex = false;
01263     }
01264     else if ( !captureMutex )
01265     {
01266         captureMutex = true;
01267         gtk_toggle_button_set_active( stopButton, true );
01268         captureMutex = false;
01269     }
01270     
01271     // Pick up any captured files
01272     for ( unsigned int index = 0; index < FileTracker::GetInstance().Size(); index ++ )
01273     {
01274         char *file = FileTracker::GetInstance().Get( ( int ) index );
01275         switch ( FileTracker::GetInstance().GetMode() )
01276         {
01277         case CAPTURE_IGNORE:
01278             // Do nothing
01279             break;
01280         case CAPTURE_FRAME_INSERT:
01281             common->loadMediaObject( file, common->g_currentFrame == -1 ? 0 : common->g_currentFrame );
01282             break;
01283         case CAPTURE_FRAME_APPEND:
01284             common->loadMediaObject( file, common->g_currentFrame + 1 );
01285             break;
01286         case CAPTURE_MOVIE_APPEND:
01287             common->loadMediaObject( file, common->getPlayList() ->GetNumFrames() );
01288             break;
01289         }
01290         common->hasListChanged = TRUE;
01291     }
01292 
01293     // Clear the list to avoid reloading on a subsequent re-entry
01294     FileTracker::GetInstance().Clear();
01295 
01296     // Just to make sure we refresh what needs to be refreshed
01297     if ( common->hasListChanged )
01298     {
01299         GetEditorBackup()->Store( common->getPlayList() );
01300         common->setWindowTitle( );
01301         common->getPageEditor()->DrawBar( common->g_currentFrame );
01302         if ( common->g_currentFrame == -1 )
01303             common->g_currentFrame = 0;
01304     }
01305     
01306 }

void PageCapture::videoBack  ) 
 

Frame back.

Definition at line 567 of file page_capture.cc.

References audioOn, avc, avc_enabled, AVC::Back(), common, Preferences::getInstance(), AVC::Pause(), KinoCommon::toggleComponents(), and VIDEO_BACK.

00568 {
00569     if ( avc_enabled )
00570     {
00571         audioOn = FALSE;
00572         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00573         common->toggleComponents( VIDEO_BACK, avc_enabled );
00574         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00575             avc->Back( Preferences::getInstance().phyID );
00576     }
00577 }

void PageCapture::videoEndOfMovie  )  [virtual]
 

End of movie.

Reimplemented from Page.

Definition at line 693 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, AVC::FastForward(), Preferences::getInstance(), AVC::Stop(), KinoCommon::toggleComponents(), and VIDEO_END_OF_MOVIE.

00694 {
00695     if ( avc_enabled )
00696     {
00697         audioOn = FALSE;
00698         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00699         common->toggleComponents( VIDEO_END_OF_MOVIE, avc_enabled );
00700         if ( avc->Stop( Preferences::getInstance().phyID ) >= 0 )
00701             avc->FastForward( Preferences::getInstance().phyID );
00702     }
00703 }

void PageCapture::videoEndOfScene  )  [virtual]
 

End of current scene.

Reimplemented from Page.

Definition at line 678 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::NextScene(), AVC::Pause(), KinoCommon::toggleComponents(), and VIDEO_NEXT_SCENE.

Referenced by processCommand().

00679 {
00680     if ( avc_enabled )
00681     {
00682         audioOn = FALSE;
00683         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00684         common->toggleComponents( VIDEO_NEXT_SCENE, avc_enabled );
00685         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00686             avc->NextScene( Preferences::getInstance().phyID );
00687     }
00688 }

void PageCapture::videoFastForward  )  [virtual]
 

Fast Forward.

Reimplemented from Page.

Definition at line 648 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, AVC::FastForward(), Preferences::getInstance(), AVC::Pause(), KinoCommon::toggleComponents(), and VIDEO_FAST_FORWARD.

00649 {
00650     if ( avc_enabled )
00651     {
00652         audioOn = FALSE;
00653         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00654         common->toggleComponents( VIDEO_FAST_FORWARD, avc_enabled );
00655         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00656             avc->FastForward( Preferences::getInstance().phyID );
00657     }
00658 }

void PageCapture::videoForward  ) 
 

Forward.

Definition at line 633 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, AVC::Forward(), Preferences::getInstance(), AVC::Pause(), KinoCommon::toggleComponents(), and VIDEO_FORWARD.

00634 {
00635     if ( avc_enabled )
00636     {
00637         audioOn = FALSE;
00638         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00639         common->toggleComponents( VIDEO_FORWARD, avc_enabled );
00640         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00641             avc->Forward( Preferences::getInstance().phyID );
00642     }
00643 }

void PageCapture::videoNextScene  )  [virtual]
 

Start of next scene.

Reimplemented from Page.

Definition at line 663 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::NextScene(), AVC::Pause(), KinoCommon::toggleComponents(), and VIDEO_NEXT_SCENE.

00664 {
00665     if ( avc_enabled )
00666     {
00667         audioOn = FALSE;
00668         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00669         common->toggleComponents( VIDEO_NEXT_SCENE, avc_enabled );
00670         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00671             avc->NextScene( Preferences::getInstance().phyID );
00672     }
00673 }

void PageCapture::videoPause  )  [virtual]
 

Pause.

Reimplemented from Page.

Definition at line 606 of file page_capture.cc.

References audioOn, avc, avc_enabled, Preferences::getInstance(), and AVC::Pause().

Referenced by stopCapture().

00607 {
00608     if ( avc_enabled )
00609     {
00610         audioOn = FALSE;
00611         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00612         avc->Pause( Preferences::getInstance().phyID );
00613     }
00614 }

void PageCapture::videoPlay  )  [virtual]
 

Play.

Reimplemented from Page.

Definition at line 582 of file page_capture.cc.

References navigate_control::active, audioOn, avc, avc_enabled, common, g_nav_ctl, Preferences::getInstance(), AVC::Pause(), AVC::Play(), KinoCommon::toggleComponents(), and VIDEO_PLAY.

Referenced by startCapture().

00583 {
00584     if ( avc_enabled )
00585     {
00586         if ( g_nav_ctl.active == TRUE )
00587         {
00588             audioOn = FALSE;
00589             gtk_toggle_button_set_active( this->muteButton, TRUE );
00590             common->toggleComponents( VIDEO_PLAY, false );
00591             avc->Pause( Preferences::getInstance().phyID );
00592         }
00593         else
00594         {
00595             audioOn = TRUE;
00596             gtk_toggle_button_set_active( this->muteButton, FALSE );
00597             common->toggleComponents( VIDEO_PLAY, true );
00598             avc->Play( Preferences::getInstance().phyID );
00599         }
00600     }
00601 }

void PageCapture::videoPreviousScene  )  [virtual]
 

Start of previous scene.

Reimplemented from Page.

Definition at line 522 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::Pause(), AVC::PreviousScene(), KinoCommon::toggleComponents(), and VIDEO_START_OF_SCENE.

00523 {
00524     if ( avc_enabled )
00525     {
00526         audioOn = FALSE;
00527         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00528         common->toggleComponents( VIDEO_START_OF_SCENE, avc_enabled );
00529         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00530             avc->PreviousScene( Preferences::getInstance().phyID );
00531     }
00532 }

void PageCapture::videoRewind  )  [virtual]
 

Rewind.

Reimplemented from Page.

Definition at line 552 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::Pause(), AVC::Rewind(), KinoCommon::toggleComponents(), and VIDEO_REWIND.

00553 {
00554     if ( avc_enabled )
00555     {
00556         audioOn = FALSE;
00557         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00558         common->toggleComponents( VIDEO_REWIND, avc_enabled );
00559         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00560             avc->Rewind( Preferences::getInstance().phyID );
00561     }
00562 }

void PageCapture::videoShuttle int  angle  )  [virtual]
 

Shuttle.

Bi-directional variable-speed playback.

Parameters:
angle The relative speed.

Reimplemented from Page.

Definition at line 712 of file page_capture.cc.

References audioOn, avc, avc_enabled, Preferences::getInstance(), AVC::Pause(), and AVC::Shuttle().

00713 {
00714     if ( avc_enabled )
00715     {
00716         audioOn = FALSE;
00717         if ( angle != 0 )
00718             avc->Shuttle( Preferences::getInstance().phyID, angle * 2 );
00719         else
00720             avc->Pause( Preferences::getInstance().phyID );
00721     }
00722 }

void PageCapture::videoStartOfMovie  )  [virtual]
 

Start of movie.

Reimplemented from Page.

Definition at line 507 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::Rewind(), AVC::Stop(), KinoCommon::toggleComponents(), and VIDEO_START_OF_MOVIE.

00508 {
00509     if ( avc_enabled )
00510     {
00511         audioOn = FALSE;
00512         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00513         common->toggleComponents( VIDEO_START_OF_MOVIE, avc_enabled );
00514         if ( avc->Stop( Preferences::getInstance().phyID ) >= 0 )
00515             avc->Rewind( Preferences::getInstance().phyID );
00516     }
00517 }

void PageCapture::videoStartOfScene  )  [virtual]
 

Start of current scene.

Reimplemented from Page.

Definition at line 537 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::Pause(), AVC::PreviousScene(), KinoCommon::toggleComponents(), and VIDEO_START_OF_SCENE.

Referenced by processCommand().

00538 {
00539     if ( avc_enabled )
00540     {
00541         audioOn = FALSE;
00542         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00543         common->toggleComponents( VIDEO_START_OF_SCENE, avc_enabled );
00544         if ( avc->Pause( Preferences::getInstance().phyID ) >= 0 )
00545             avc->PreviousScene( Preferences::getInstance().phyID );
00546     }
00547 }

void PageCapture::videoStop  )  [virtual]
 

Stop.

Reimplemented from Page.

Definition at line 619 of file page_capture.cc.

References audioOn, avc, avc_enabled, common, Preferences::getInstance(), AVC::Stop(), KinoCommon::toggleComponents(), and VIDEO_STOP.

Referenced by clean().

00620 {
00621     if ( avc_enabled )
00622     {
00623         audioOn = FALSE;
00624         gtk_toggle_button_set_active( this->muteButton, !audioOn );
00625         common->toggleComponents( VIDEO_STOP, avc_enabled );
00626         avc->Stop( Preferences::getInstance().phyID );
00627     }
00628 }

void PageCapture::windowMoved  )  [virtual]
 

Reimplemented from Page.

Definition at line 1359 of file page_capture.cc.

References KinoCommon::clearPreview(), common, frameArea, frameBuffer, framePosition, and FrameDisplayer::Put().

01360 {
01361     if ( frameBuffer[ framePosition ] == NULL )
01362         common->clearPreview( frameArea );
01363     else
01364         displayer->Put( *frameBuffer[ framePosition ], GTK_WIDGET( frameArea ), TRUE );
01365 }


Member Data Documentation

bool PageCapture::audio_enabled
 

Definition at line 61 of file page_capture.h.

bool PageCapture::avc_enabled
 

Definition at line 60 of file page_capture.h.

Referenced by applyAVCState(), CheckDevices(), clean(), processCommand(), processKeyboard(), showFrameInfo(), start(), startCapture(), stopCapture(), videoBack(), videoEndOfMovie(), videoEndOfScene(), videoFastForward(), videoForward(), videoNextScene(), videoPause(), videoPlay(), videoPreviousScene(), videoRewind(), videoShuttle(), videoStartOfMovie(), videoStartOfScene(), and videoStop().

GtkToggleButton* PageCapture::avcButton [private]
 

Definition at line 49 of file page_capture.h.

Referenced by applyAVCState(), PageCapture(), start(), startCapture(), and stopCapture().

quadlet_t PageCapture::avcState [private]
 

Definition at line 41 of file page_capture.h.

Referenced by applyAVCState(), and getAVCState().

bool PageCapture::captureMutex [private]
 

Definition at line 43 of file page_capture.h.

Referenced by startCapture(), and stopCapture().

bool PageCapture::check_phyid
 

Definition at line 62 of file page_capture.h.

Referenced by applyAVCState(), CheckDevices(), and start().

KinoCommon* PageCapture::common [private]
 

Definition at line 38 of file page_capture.h.

Referenced by applyAVCState(), clean(), collectFiles(), processCommand(), processKeyboard(), saveFrame(), showFrameInfo(), start(), startCapture(), stopCapture(), videoBack(), videoEndOfMovie(), videoEndOfScene(), videoFastForward(), videoForward(), videoNextScene(), videoPlay(), videoPreviousScene(), videoRewind(), videoStartOfMovie(), videoStartOfScene(), videoStop(), and windowMoved().

bool PageCapture::driver_available
 

Definition at line 59 of file page_capture.h.

Referenced by applyAVCState(), CheckDevices(), and start().

bool PageCapture::driver_locked
 

Definition at line 63 of file page_capture.h.

Referenced by CheckDevices().

GtkEntry* PageCapture::fileEntry [private]
 

Definition at line 55 of file page_capture.h.

Referenced by PageCapture(), processKeyboard(), start(), and startCapture().

GtkDrawingArea* PageCapture::frameArea [private]
 

Definition at line 48 of file page_capture.h.

Referenced by PageCapture(), and windowMoved().

int PageCapture::gui_state_was [private]
 

Definition at line 45 of file page_capture.h.

Referenced by applyAVCState(), start(), startCapture(), and stopCapture().

bool PageCapture::isCapturing [private]
 

Definition at line 42 of file page_capture.h.

Referenced by applyAVCState(), CheckDevices(), processCommand(), showFrameInfo(), startCapture(), and stopCapture().

GtkToggleButton* PageCapture::muteButton [private]
 

Definition at line 53 of file page_capture.h.

Referenced by applyAVCState(), PageCapture(), and startCapture().

GtkToggleButton* PageCapture::playrecordButton [private]
 

Definition at line 52 of file page_capture.h.

GtkToggleButton* PageCapture::recordButton [private]
 

Definition at line 50 of file page_capture.h.

Referenced by applyAVCState(), PageCapture(), startCapture(), and stopCapture().

GtkButton* PageCapture::snapshotButton [private]
 

Definition at line 54 of file page_capture.h.

Referenced by applyAVCState(), PageCapture(), startCapture(), and stopCapture().

GtkToggleButton* PageCapture::stopButton [private]
 

Definition at line 51 of file page_capture.h.

Referenced by applyAVCState(), PageCapture(), startCapture(), and stopCapture().

GtkLabel* PageCapture::timecodeLabel [private]
 

Definition at line 56 of file page_capture.h.

Referenced by PageCapture(), showFrameInfo(), and start().

gulong PageCapture::validComponents [private]
 

Definition at line 44 of file page_capture.h.

Referenced by activate(), applyAVCState(), processCommand(), start(), and startCapture().


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