diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-03 02:15:56 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-03 02:15:56 +0000 |
commit | 50b48aec6ddd451a6d1709c0942477b503457663 (patch) | |
tree | a9ece53ec06fd0a2819de7a2a6de997193566626 /libk3b/projects/videodvd | |
download | k3b-50b48aec6ddd451a6d1709c0942477b503457663.tar.gz k3b-50b48aec6ddd451a6d1709c0942477b503457663.zip |
Added abandoned KDE3 version of K3B
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k3b@1084400 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libk3b/projects/videodvd')
-rw-r--r-- | libk3b/projects/videodvd/Makefile.am | 20 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvddoc.cpp | 71 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvddoc.h | 46 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvdimager.cpp | 221 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvdimager.h | 61 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvdjob.cpp | 101 | ||||
-rw-r--r-- | libk3b/projects/videodvd/k3bvideodvdjob.h | 46 |
7 files changed, 566 insertions, 0 deletions
diff --git a/libk3b/projects/videodvd/Makefile.am b/libk3b/projects/videodvd/Makefile.am new file mode 100644 index 0000000..1b3e92b --- /dev/null +++ b/libk3b/projects/videodvd/Makefile.am @@ -0,0 +1,20 @@ +# we need the ../datacd for the uic generated header files +AM_CPPFLAGS= -I$(srcdir)/../../core \ + -I$(srcdir)/../../../libk3bdevice \ + -I$(srcdir)/../../../src \ + -I$(srcdir)/../../tools \ + -I$(srcdir)/../datadvd \ + -I$(srcdir)/../datacd \ + -I$(srcdir)/.. \ + -I../datacd \ + $(all_includes) + +METASOURCES = AUTO + +noinst_LTLIBRARIES = libvideodvd.la + +libvideodvd_la_SOURCES = k3bvideodvddoc.cpp \ + k3bvideodvdjob.cpp \ + k3bvideodvdimager.cpp + +include_HEADERS = k3bvideodvddoc.h k3bvideodvdjob.h diff --git a/libk3b/projects/videodvd/k3bvideodvddoc.cpp b/libk3b/projects/videodvd/k3bvideodvddoc.cpp new file mode 100644 index 0000000..2f02ac6 --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvddoc.cpp @@ -0,0 +1,71 @@ +/* + * + * $Id: k3bvideodvddoc.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#include "k3bvideodvddoc.h" +#include "k3bvideodvdjob.h" + +#include <k3bdiritem.h> + +#include <k3bisooptions.h> + +#include <kconfig.h> + + +K3bVideoDvdDoc::K3bVideoDvdDoc( QObject* parent ) + : K3bDvdDoc( parent ) +{ +} + + +K3bVideoDvdDoc::~K3bVideoDvdDoc() +{ +} + + +bool K3bVideoDvdDoc::newDocument() +{ + if( K3bDataDoc::newDocument() ) { + + // K3bDataDoc::newDocument already deleted m_videoTsDir (again: bad design!) + m_videoTsDir = new K3bDirItem( "VIDEO_TS", this, root() ); + m_videoTsDir->setRemoveable(false); + m_videoTsDir->setRenameable(false); + m_videoTsDir->setMoveable(false); + m_videoTsDir->setHideable(false); + + K3bDirItem* audioTsDir = new K3bDirItem( "AUDIO_TS", this, root() ); + audioTsDir->setRemoveable(false); + audioTsDir->setRenameable(false); + audioTsDir->setMoveable(false); + audioTsDir->setHideable(false); + + setMultiSessionMode( NONE ); + + setModified( false ); + + return true; + } + else + return false; +} + + +K3bBurnJob* K3bVideoDvdDoc::newBurnJob( K3bJobHandler* hdl, QObject* parent ) +{ + return new K3bVideoDvdJob( this, hdl, parent ); +} + +//#include "k3bdvddoc.moc" diff --git a/libk3b/projects/videodvd/k3bvideodvddoc.h b/libk3b/projects/videodvd/k3bvideodvddoc.h new file mode 100644 index 0000000..034ae4d --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvddoc.h @@ -0,0 +1,46 @@ +/* + * + * $Id: k3bvideodvddoc.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#ifndef _K3B_VIDEODVD_DOC_H_ +#define _K3B_VIDEODVD_DOC_H_ + +#include <k3bdvddoc.h> +#include "k3b_export.h" +class KConfig; + +class LIBK3B_EXPORT K3bVideoDvdDoc : public K3bDvdDoc +{ + public: + K3bVideoDvdDoc( QObject* parent = 0 ); + virtual ~K3bVideoDvdDoc(); + + virtual int type() const { return VIDEODVD; } + + virtual K3bBurnJob* newBurnJob( K3bJobHandler* hdl, QObject* parent ); + + virtual bool newDocument(); + + K3bDirItem* videoTsDir() const { return m_videoTsDir; } + + // TODO: implement load- and saveDocumentData since we do not need all those options + + protected: + virtual QString typeString() const { return "video_dvd"; } + + private: + K3bDirItem* m_videoTsDir; +}; + +#endif diff --git a/libk3b/projects/videodvd/k3bvideodvdimager.cpp b/libk3b/projects/videodvd/k3bvideodvdimager.cpp new file mode 100644 index 0000000..7362aa0 --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvdimager.cpp @@ -0,0 +1,221 @@ +/* + * + * $Id: k3bvideodvdimager.cpp 633751 2007-02-15 08:22:49Z trueg $ + * Copyright (C) 2004-2007 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + +#include "k3bvideodvdimager.h" +#include "k3bvideodvddoc.h" +#include <k3bdiritem.h> +#include <k3bfileitem.h> +#include <k3bprocess.h> +#include <k3bglobals.h> + +#include <ktempfile.h> +#include <kglobal.h> +#include <kstandarddirs.h> +#include <kdebug.h> +#include <klocale.h> + +#include <qtextstream.h> +#include <qdir.h> +#include <qfile.h> +#include <qptrlist.h> + + + +class K3bVideoDvdImager::Private +{ +public: + K3bVideoDvdDoc* doc; + + QString tempPath; +}; + + +K3bVideoDvdImager::K3bVideoDvdImager( K3bVideoDvdDoc* doc, K3bJobHandler* jh, QObject* parent, const char* name ) + : K3bIsoImager( doc, jh, parent, name ) +{ + d = new Private; + d->doc = doc; +} + + +K3bVideoDvdImager::~K3bVideoDvdImager() +{ + delete d; +} + + +void K3bVideoDvdImager::start() +{ + fixVideoDVDSettings(); + K3bIsoImager::start(); +} + + +void K3bVideoDvdImager::init() +{ + fixVideoDVDSettings(); + K3bIsoImager::init(); +} + + +void K3bVideoDvdImager::fixVideoDVDSettings() +{ + // Video DVD defaults, we cannot set these in K3bVideoDvdDoc since they + // will be overwritten in the burn dialog unless we create some K3bVideoDVDIsoOptions + // class with different defaults. But since the whole Video DVD project is a hack we + // go the easy road. + K3bIsoOptions o = d->doc->isoOptions(); + o.setISOLevel(1); + o.setISOallow31charFilenames(false); + o.setCreateJoliet(false); + o.setJolietLong(false); + o.setCreateRockRidge(false); + o.setCreateUdf(true); + d->doc->setIsoOptions( o ); +} + + +void K3bVideoDvdImager::calculateSize() +{ + fixVideoDVDSettings(); + K3bIsoImager::calculateSize(); +} + + +int K3bVideoDvdImager::writePathSpec() +{ + // + // Create a temp dir and link all contents of the VIDEO_TS dir to make mkisofs + // able to handle the VideoDVD stuff. + // + // mkisofs is not able to create VideoDVDs from graft-points. + // + // We do this here since K3bIsoImager::start calls cleanup which deletes the temp files + // + QDir dir( KGlobal::dirs()->resourceDirs( "tmp" ).first() ); + d->tempPath = K3b::findUniqueFilePrefix( "k3bVideoDvd", dir.path() ); + kdDebug() << "(K3bVideoDvdImager) creating temp dir: " << d->tempPath << endl; + if( !dir.mkdir( d->tempPath, true ) ) { + emit infoMessage( i18n("Unable to create temporary directory '%1'.").arg(d->tempPath), ERROR ); + return -1; + } + + dir.cd( d->tempPath ); + if( !dir.mkdir( "VIDEO_TS" ) ) { + emit infoMessage( i18n("Unable to create temporary directory '%1'.").arg(d->tempPath + "/VIDEO_TS"), ERROR ); + return -1; + } + + for( QPtrListIterator<K3bDataItem> it( d->doc->videoTsDir()->children() ); *it; ++it ) { + if( (*it)->isDir() ) { + emit infoMessage( i18n("Found invalid entry in the VIDEO_TS folder (%1).").arg((*it)->k3bName()), ERROR ); + return -1; + } + + // convert to upper case names + if( ::symlink( QFile::encodeName( (*it)->localPath() ), + QFile::encodeName( d->tempPath + "/VIDEO_TS/" + (*it)->k3bName().upper() ) ) == -1 ) { + emit infoMessage( i18n("Unable to link temporary file in folder %1.").arg( d->tempPath ), ERROR ); + return -1; + } + } + + + return K3bIsoImager::writePathSpec(); +} + + +int K3bVideoDvdImager::writePathSpecForDir( K3bDirItem* dirItem, QTextStream& stream ) +{ + // + // We handle the VIDEO_TS dir differently since otherwise mkisofs is not able to + // open the VideoDVD structures (see addMkisofsParameters) + // + if( dirItem == d->doc->videoTsDir() ) { + return 0; + } + + int num = 0; + for( QPtrListIterator<K3bDataItem> it( dirItem->children() ); it.current(); ++it ) { + K3bDataItem* item = it.current(); + num++; + + if( item->isDir() ) { + // we cannot add the video_ts dir twice + if( item != d->doc->videoTsDir() ) { + stream << escapeGraftPoint( item->writtenPath() ) + << "=" + << escapeGraftPoint( dummyDir( static_cast<K3bDirItem*>(item) ) ) << "\n"; + } + + int x = writePathSpecForDir( dynamic_cast<K3bDirItem*>(item), stream ); + if( x >= 0 ) + num += x; + else + return -1; + } + else { + writePathSpecForFile( static_cast<K3bFileItem*>(item), stream ); + } + } + + return num; +} + + +bool K3bVideoDvdImager::addMkisofsParameters( bool printSize ) +{ + // Here is another bad design: we assume that K3bIsoImager::start does not add additional + // parameters to the process. :( + if( K3bIsoImager::addMkisofsParameters( printSize ) ) { + *m_process << "-dvd-video"; + *m_process << "-f"; // follow symlinks + *m_process << d->tempPath; + return true; + } + else + return false; +} + + +void K3bVideoDvdImager::cleanup() +{ + if( QFile::exists( d->tempPath ) ) { + QDir dir( d->tempPath ); + dir.cd( "VIDEO_TS" ); + for( QPtrListIterator<K3bDataItem> it( d->doc->videoTsDir()->children() ); *it; ++it ) + dir.remove( (*it)->k3bName().upper() ); + dir.cdUp(); + dir.rmdir( "VIDEO_TS" ); + dir.cdUp(); + dir.rmdir( d->tempPath ); + } + d->tempPath = QString::null; + + K3bIsoImager::cleanup(); +} + + +void K3bVideoDvdImager::slotReceivedStderr( const QString& line ) +{ + if( line.contains( "Unable to make a DVD-Video image" ) ) { + emit infoMessage( i18n("The project does not contain all necessary VideoDVD files."), WARNING ); + emit infoMessage( i18n("The resulting DVD will most likely not be playable on a Hifi DVD player."), WARNING ); + } + else + K3bIsoImager::slotReceivedStderr( line ); +} + +#include "k3bvideodvdimager.moc" diff --git a/libk3b/projects/videodvd/k3bvideodvdimager.h b/libk3b/projects/videodvd/k3bvideodvdimager.h new file mode 100644 index 0000000..0062d55 --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvdimager.h @@ -0,0 +1,61 @@ +/* + * + * $Id: k3bvideodvdimager.h 633751 2007-02-15 08:22:49Z trueg $ + * Copyright (C) 2004 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#ifndef _K3B_VIDEODVD_IMAGER_H_ +#define _K3B_VIDEODVD_IMAGER_H_ + + +#include <k3bisoimager.h> + +class K3bVideoDvdDoc; + + +/** + * Create VideoDVD images with mkisofs. The difference + * to the IsoImager is the -dvd-video option and the fact + * that all VIDEO_TS files need to be in one local folder since + * otherwise mkisofs is not able to find the dvd structures. + */ +class K3bVideoDvdImager : public K3bIsoImager +{ + Q_OBJECT + + public: + K3bVideoDvdImager( K3bVideoDvdDoc* doc, K3bJobHandler*, QObject* parent = 0, const char* name = 0 ); + virtual ~K3bVideoDvdImager(); + + public slots: + virtual void start(); + virtual void init(); + virtual void calculateSize(); + + protected: + bool addMkisofsParameters( bool printSize = false ); + int writePathSpec(); + void cleanup(); + int writePathSpecForDir( K3bDirItem* dirItem, QTextStream& stream ); + + protected slots: + virtual void slotReceivedStderr( const QString& ); + + private: + void fixVideoDVDSettings(); + + class Private; + Private* d; +}; + +#endif diff --git a/libk3b/projects/videodvd/k3bvideodvdjob.cpp b/libk3b/projects/videodvd/k3bvideodvdjob.cpp new file mode 100644 index 0000000..f4e6129 --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvdjob.cpp @@ -0,0 +1,101 @@ +/* + * + * $Id: k3bvideodvdjob.cpp 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#include "k3bvideodvdjob.h" +#include "k3bvideodvddoc.h" +#include "k3bvideodvdimager.h" + +#include <k3bcore.h> +#include <k3bisoimager.h> +#include <k3bgrowisofswriter.h> +#include <k3bglobals.h> + +#include <klocale.h> +#include <kmessagebox.h> +#include <kapplication.h> +#include <kconfig.h> + + + +K3bVideoDvdJob::K3bVideoDvdJob( K3bVideoDvdDoc* doc, K3bJobHandler* jh, QObject* parent ) + : K3bDvdJob( doc, jh, parent ), + m_doc(doc) +{ +} + + +K3bVideoDvdJob::~K3bVideoDvdJob() +{ +} + + +void K3bVideoDvdJob::prepareImager() +{ + setImager( new K3bVideoDvdImager( m_doc, this ) ); +} + + +bool K3bVideoDvdJob::prepareWriterJob() +{ + K3bGrowisofsWriter* writer = new K3bGrowisofsWriter( m_doc->burner(), this, this ); + + // these do only make sense with DVD-R(W) + writer->setSimulate( m_doc->dummy() ); + writer->setBurnSpeed( m_doc->speed() ); + + // DAO seems to be the better default for Video DVD... !? + if( m_doc->writingMode() == K3b::DAO || m_doc->writingMode() == K3b::WRITING_MODE_AUTO ) + writer->setWritingMode( K3b::DAO ); + + writer->setMultiSession( false ); + writer->setCloseDvd( true ); + + if( m_doc->onTheFly() ) { + writer->setImageToWrite( QString::null ); // read from stdin + writer->setTrackSize( m_isoImager->size() ); + } + else + writer->setImageToWrite( m_doc->tempDir() ); + + setWriterJob( writer ); + + return true; +} + + +QString K3bVideoDvdJob::jobDescription() const +{ + if( m_doc->onlyCreateImages() ) { + return i18n("Creating Video DVD Image File"); + } + else { + return i18n("Writing Video DVD") + + ( m_doc->isoOptions().volumeID().isEmpty() + ? QString::null + : QString( " (%1)" ).arg(m_doc->isoOptions().volumeID()) ); + } +} + + +QString K3bVideoDvdJob::jobDetails() const +{ + return ( i18n("ISO9660/Udf Filesystem (Size: %1)").arg(KIO::convertSize( doc()->size() )) + + ( m_doc->copies() > 1 + ? i18n(" - %n copy", " - %n copies", m_doc->copies()) + : QString::null ) ); +} + +#include "k3bvideodvdjob.moc" diff --git a/libk3b/projects/videodvd/k3bvideodvdjob.h b/libk3b/projects/videodvd/k3bvideodvdjob.h new file mode 100644 index 0000000..3f03cea --- /dev/null +++ b/libk3b/projects/videodvd/k3bvideodvdjob.h @@ -0,0 +1,46 @@ +/* + * + * $Id: k3bvideodvdjob.h 619556 2007-01-03 17:38:12Z trueg $ + * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org> + * + * This file is part of the K3b project. + * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * See the file "COPYING" for the exact licensing terms. + */ + + +#ifndef _K3B_VIDEO_DVD_JOB_H_ +#define _K3B_VIDEO_DVD_JOB_H_ + +#include <k3bdvdjob.h> + + +class K3bVideoDvdDoc; + +/** + * This class heavily depends on K3bDvdJob and uses some of it's internals. + */ +class K3bVideoDvdJob : public K3bDvdJob +{ + Q_OBJECT + + public: + K3bVideoDvdJob( K3bVideoDvdDoc*, K3bJobHandler*, QObject* parent = 0 ); + virtual ~K3bVideoDvdJob(); + + virtual QString jobDescription() const; + virtual QString jobDetails() const; + + private: + bool prepareWriterJob(); + void prepareImager(); + + K3bVideoDvdDoc* m_doc; +}; + +#endif |