summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-05-07 16:14:40 (UTC)
committer mickeyl <mickeyl>2003-05-07 16:14:40 (UTC)
commit1e9e3371d61cfc404329a8bad51f8b061c1ad73d (patch) (side-by-side diff)
treeede98f5b571543cef4047c3a33e314ffee91a94c
parent7c8110d568ac60517916114ac5fc4e850156d4e5 (diff)
downloadopie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.zip
opie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.tar.gz
opie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.tar.bz2
reenable sounds now that they work on the Z again
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp
index 49c7cbf..0854f0d 100644
--- a/noncore/multimedia/camera/gui/mainwindow.cpp
+++ b/noncore/multimedia/camera/gui/mainwindow.cpp
@@ -367,235 +367,235 @@ void CameraMainWindow::outputToMenuItemClicked( QAction* a )
}
odebug << "Output to now: " << outputTo << oendl;
}
void CameraMainWindow::outputMenuItemClicked( QAction* a )
{
captureFormat = a->text();
odebug << "Output format now: " << captureFormat << oendl;
updateCaption();
}
void CameraMainWindow::prefixItemChoosen()
{
QDialog* d = new QDialog( this, "dialog", true );
d->setCaption( "Enter Prefix..." );
QVBoxLayout* v = new QVBoxLayout( d );
QLineEdit* le = new QLineEdit( prefix, d );
v->addWidget( le );
le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty
if ( d->exec() == QDialog::Accepted )
prefix = le->text();
odebug << "Prefix now: " << prefix << oendl;
}
void CameraMainWindow::appendSettingsChoosen()
{
appendSettings = !appendSettings;
odebug << "appendSettings now: " << appendSettings << oendl;
}
void CameraMainWindow::shutterClicked()
{
if ( captureFormat != "AVI" ) // capture one photo per shutterClick
{
Global::statusMessage( "CAPTURING..." );
qApp->processEvents();
odebug << "Shutter has been pressed" << oendl;
ODevice::inst()->touchSound();
performCapture( captureFormat );
}
else // capture video! start with one shutter click and stop with the next
{
!_capturing ? startVideoCapture() : stopVideoCapture();
}
}
void CameraMainWindow::performCapture( const QString& format )
{
QString name;
if ( outputTo == "Documents Folder" )
{
name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
if ( !QDir( name ).exists() )
{
odebug << "creating directory " << name << oendl;
QString msg = "mkdir -p " + name;
system( msg.latin1() );
}
}
else
name = outputTo;
name.append( prefix );
if ( appendSettings )
{
name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) );
}
name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) );
QImage i;
ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i );
QImage im = i.convertDepth( 32 );
bool result = im.save( name, format, quality );
if ( !result )
{
oerr << "imageio-Problem while writing." << oendl;
Global::statusMessage( "Error!" );
}
else
{
odebug << captureFormat << "-image has been successfully captured" << oendl;
Global::statusMessage( "Ok." );
}
}
void CameraMainWindow::startVideoCapture()
{
- //ODevice::inst()->touchSound();
+ ODevice::inst()->touchSound();
ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow );
_capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC );
if ( _capturefd == -1 )
{
owarn << "can't open capture file: " << strerror(errno) << oendl;
return;
}
_capturebuf = new unsigned char[captureX*captureY*2];
_capturing = true;
_videopics = 0;
_framerate = 0;
updateCaption();
_time.start();
preview->setRefreshingRate( 1000 );
startTimer( 100 ); // too fast but that is ok
}
void CameraMainWindow::timerEvent( QTimerEvent* )
{
if ( !_capturing )
{
odebug << "timer event in CameraMainWindow without capturing video ?" << oendl;
return;
}
odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl;
ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf );
_videopics++;
::write( _capturefd, _capturebuf, captureX*captureY*2 );
setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d",
captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) );
}
void CameraMainWindow::stopVideoCapture()
{
killTimers();
- //ODevice::inst()->touchSound();
+ ODevice::inst()->touchSound();
ODevice::inst()->setLedState( Led_Mail, Led_Off );
_capturing = false;
updateCaption();
::close( _capturefd );
_framerate = 1000.0 / (_time.elapsed()/_videopics);
QString name;
if ( outputTo == "Documents Folder" )
{
name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
if ( !QDir( name ).exists() )
{
odebug << "creating directory " << name << oendl;
QString msg = "mkdir -p " + name;
system( msg.latin1() );
}
}
else
name = outputTo;
name.append( "/" ); // sure is sure and safe is safe ;-)
name.append( prefix );
if ( appendSettings )
name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) );
name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) );
postProcessVideo( CAPTUREFILE, name );
#ifndef QT_NO_DEBUG
preview->setRefreshingRate( 1500 );
#else
preview->setRefreshingRate( 200 );
#endif
//delete[] _capturebuf; //FIXME: close memory leak
}
void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile )
{
odebug << "post processing " << infile << " --> " << outfile << oendl;
preview->setRefreshingRate( 0 );
/*
unsigned char buf[153600];
int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY );
::read( fd, &buf, 153600 );
QImage i;
bufferToImage( 240, 320, (unsigned char*) &buf, &i );
QPixmap p;
p.convertFromImage( i );
preview->setPixmap( p );
imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 );
return;
*/
QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize );
fr->setCaption( "Please wait..." );
QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 );
QProgressBar* bar = new QProgressBar( fr );
bar->setCenterIndicator( true );
bar->setTotalSteps( _videopics-1 );
QLabel* label = new QLabel( "Post processing frame bla/bla", fr );
box->addWidget( bar );
box->addWidget( label );
fr->show();
label->show();
bar->show();
fr->repaint();
qApp->processEvents();
// open files
int infd = ::open( (const char*) infile, O_RDONLY );
if ( infd == -1 )
{
owarn << "couldn't open capture file: " << strerror(errno) << oendl;
return;
}
int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 );
if ( outfd == -1 )
{
owarn << "couldn't open output file: " << strerror(errno) << oendl;
return;
}
int framesize = captureX*captureY*2;
unsigned char* inbuffer = new unsigned char[ framesize ];
QImage image;
avi_start( outfd, _videopics ); // write preambel
// post process