[Matroska-cvs] [matroska] r1283 - in trunk/DvdMenuXtractor: .
dmxconsole
smssms at matroska.org
smssms at matroska.org
Sat Mar 10 22:17:23 CET 2007
Author: smssms
Date: 2007-03-11 00:17:10 +0300 (Sun, 11 Mar 2007)
New Revision: 1283
Added:
trunk/DvdMenuXtractor/dmxconsole/
trunk/DvdMenuXtractor/dmxconsole/dmxconsole.cpp
trunk/DvdMenuXtractor/dmxconsole/dmxconsole.h
trunk/DvdMenuXtractor/dmxconsole/dmxconsole.proj
trunk/DvdMenuXtractor/dmxconsole/main.cpp
Log:
Separate projects for CLI and GUI modes
Added: trunk/DvdMenuXtractor/dmxconsole/dmxconsole.cpp
===================================================================
--- trunk/DvdMenuXtractor/dmxconsole/dmxconsole.cpp 2007-03-10 21:15:45 UTC (rev 1282)
+++ trunk/DvdMenuXtractor/dmxconsole/dmxconsole.cpp 2007-03-10 21:17:10 UTC (rev 1283)
@@ -0,0 +1,121 @@
+#include <iostream>
+
+#include "utilities.h"
+#include "dmxconsole.h"
+
+DMXConsole::~DMXConsole()
+{
+}
+
+DMXConsole::DMXConsole(char *arguments[], int argumentCount)
+{
+ ready_ = true;
+
+ if ((argumentCount != 7) && (argumentCount != 9))
+ {
+ ShowUsage();
+ ready_ = false;
+ return;
+ }
+
+ QString argument;
+
+ for (int i = 1; i < argumentCount; ++i)
+ {
+ argument = arguments[i];
+
+ if (argument == "-h")
+ {
+ ShowUsage();
+ ready_ = false;
+ return;
+ }
+ else if (argument == "-i")
+ sourcePath_ = arguments[++i];
+ else if (argument == "-o")
+ destinationPath_ = arguments[++i];
+ else if (argument == "-t")
+ toolsPath_ = arguments[++i];
+ else if (argument == "-s")
+ selectionItems_ = generateSelectionItems(QString(arguments[++i]));
+ else
+ {
+ std::cout << "ERROR: Unknown option was specified" << std::endl;
+ DMXConsole::ShowUsage();
+ ready_ = false;
+ return;
+ }
+ }
+}
+
+DMX::SelectionType DMXConsole::generateSelectionItems(const QString& selectionString)
+{
+ QString item;
+ QStringList subItems;
+ DMX::SelectionType selectionItems;
+
+ // split string using ";" as delimeter into selection item string
+ QStringList items = selectionString.split(";");
+
+ // procfess each substring
+ for (int index = 0; index < items.size(); ++index)
+ {
+ item = items.at(index);
+
+ // split subitems into smaller parts using "," as delimeter
+ subItems = item.split(",");
+
+ // now check if we have all the components
+ if (subItems.size() == ITEM_COUNT)
+ {
+ DMXSelectionItem item(subItems.at(TITLE_INDEX).toInt(),
+ subItems.at(MENU_INDEX).toInt(),
+ subItems.at(VIDEO_INDEX).toInt());
+
+ // add audio tracks
+ int index = 0;
+ QStringList trackList = extractTrackNumbers(subItems.at(1));
+ for (index = 0; index < trackList.size(); ++index)
+ item.addAudioTrack(trackList.at(index).toUInt());
+
+ // add subtitle tracks
+ trackList = extractTrackNumbers(subItems.at(2));
+ for (index = 0; index < trackList.size(); ++index)
+ item.addSubtitleTrack(trackList.at(index).toUInt());
+
+ selectionItems.push_back(item);
+ }
+ else
+ fprintf(stderr, "WARNING: Incorrect selection item at index %d was found\n", index);
+ }
+
+ return selectionItems;
+}
+
+QStringList DMXConsole::extractTrackNumbers(const QString& trackNumberString)
+{
+ if ( trackNumberString.size() <= 2 )
+ return QStringList();
+
+ return trackNumberString.mid(1, trackNumberString.size() - 1).split(",");
+}
+
+void DMXConsole::extract()
+{
+ if (ready_)
+ {
+ DMX extractor (true);
+ extractor.setExtractionParameters(sourcePath_, destinationPath_, toolsPath_, selectionItems_);
+ extractor.start();
+ extractor.wait();
+ }
+}
+
+void DMXConsole::ShowUsage()
+{
+ std::cout << "USAGE: DvdMenuExtractor [<options>]\n\n"
+ << " Show usage: -h\n"
+ << " Specify folders: -i <dir> -o <dir> -t <dir>\n"
+ << " Specify selection: -s title, extractMenu, extractVideo, {audioTracks}, {subTracks};..."
+ << std::endl;
+}
Added: trunk/DvdMenuXtractor/dmxconsole/dmxconsole.h
===================================================================
--- trunk/DvdMenuXtractor/dmxconsole/dmxconsole.h 2007-03-10 21:15:45 UTC (rev 1282)
+++ trunk/DvdMenuXtractor/dmxconsole/dmxconsole.h 2007-03-10 21:17:10 UTC (rev 1283)
@@ -0,0 +1,30 @@
+#ifndef DMXCONSOLE_H
+#define DMXCONSOLE_H
+
+#include "dmx.h"
+
+class DMXConsole
+{
+public:
+ DMXConsole(char *arguments[], int argumentCount);
+ ~DMXConsole();
+
+ void extract();
+
+ static void ShowUsage();
+
+private:
+ bool ready_;
+ QString toolsPath_;
+ QString sourcePath_;
+ QString destinationPath_;
+ DMX::SelectionType selectionItems_;
+
+ enum {TITLE_INDEX = 0, MENU_INDEX, VIDEO_INDEX,
+ AUDIO_TRACKS_INDEX, SUBTITLE_TRACKS_INDEX, ITEM_COUNT};
+
+ QStringList extractTrackNumbers(const QString& trackNumberString);
+ DMX::SelectionType generateSelectionItems(const QString& selectionString);
+};
+
+#endif // DMXCONSOLE_H
Added: trunk/DvdMenuXtractor/dmxconsole/dmxconsole.proj
===================================================================
--- trunk/DvdMenuXtractor/dmxconsole/dmxconsole.proj 2007-03-10 21:15:45 UTC (rev 1282)
+++ trunk/DvdMenuXtractor/dmxconsole/dmxconsole.proj 2007-03-10 21:17:10 UTC (rev 1283)
@@ -0,0 +1,46 @@
+CON dmxconsole
+{
+ USE dmx
+
+ DEFINE __STDC_LIMIT_MACROS
+ DEFINE(QT_NO_DEBUG) QT_NO_DEBUG_STREAM
+
+ INCLUDE(COMPILER_MSVC) ../dmx/libdvdread/win32
+ INCLUDE(COMPILER_MSVC) "$(QTDIR)/include"
+ INCLUDE(COMPILER_MSVC) "$(QTDIR)/include/QtCore"
+
+ INCLUDE(COMPILER_GCC) "$(QTDIR)/include/qt4"
+ INCLUDE(COMPILER_GCC) "$(QTDIR)/include/qt4/QtCore"
+
+ INCLUDE ../dmx
+ INCLUDE ../dmx/vobparser
+ INCLUDE ../dmx/libdvdread
+
+ LIBS_RELEASE(COMPILER_MSVC) qtmain.lib
+ LIBS_RELEASE(COMPILER_MSVC && CONFIG_STATIC) QtXml.lib
+ LIBS_RELEASE(COMPILER_MSVC && CONFIG_STATIC) QtCore.lib
+ LIBS_RELEASE(COMPILER_MSVC && !CONFIG_STATIC) QtXml4.lib
+ LIBS_RELEASE(COMPILER_MSVC && !CONFIG_STATIC) QtCore4.lib
+
+ LIBS_DEBUG(COMPILER_MSVC) qtmaind.lib
+ LIBS_DEBUG(COMPILER_MSVC && CONFIG_STATIC) QtXmld.lib
+ LIBS_DEBUG(COMPILER_MSVC && CONFIG_STATIC) QtCored.lib
+ LIBS_DEBUG(COMPILER_MSVC && !CONFIG_STATIC) QtXmld4.lib
+ LIBS_DEBUG(COMPILER_MSVC && !CONFIG_STATIC) QtCored4.lib
+
+ LIBS(COMPILER_GCC && CONFIG_STATIC) QtXml
+ LIBS(COMPILER_GCC && CONFIG_STATIC) QtCore
+ LIBS(COMPILER_GCC && !CONFIG_STATIC) QtXml4
+ LIBS(COMPILER_GCC && !CONFIG_STATIC) QtCore4
+
+ LIBS(TARGET_WIN) imm32.lib
+ LIBS(TARGET_WIN) winmm.lib
+ LIBS(TARGET_WIN) ws2_32.lib
+
+ LIBINCLUDE "$(QTDIR)/lib"
+
+ SOURCE main.cpp
+ SOURCE dmxconsole.cpp
+
+ HEADER dmxconsole.h
+}
Added: trunk/DvdMenuXtractor/dmxconsole/main.cpp
===================================================================
--- trunk/DvdMenuXtractor/dmxconsole/main.cpp 2007-03-10 21:15:45 UTC (rev 1282)
+++ trunk/DvdMenuXtractor/dmxconsole/main.cpp 2007-03-10 21:17:10 UTC (rev 1283)
@@ -0,0 +1,9 @@
+#include "dmxconsole.h"
+
+int main(int argc, char *argv[])
+{
+ DMXConsole console(argv, argc);
+ console.extract();
+
+ return 0;
+}
More information about the Matroska-cvs
mailing list