diff --git a/BUGS b/BUGS index ee41393..61ee0c5 100644 --- a/BUGS +++ b/BUGS @@ -1,8 +1,5 @@ LibreMapping known bugs ======================= -* segfaults if OSC receiving port is busy -* should ask for confirmation when we quit if the project has not been saved. -* cannot load state saving * cannot delete mappings * cannot delete paints * cannot remove points in meshes diff --git a/INSTALL b/INSTALL index 25e8b44..01e2cf1 100644 --- a/INSTALL +++ b/INSTALL @@ -11,6 +11,7 @@ Dependencies: * qt4-default * qt4-qmake * liblo + * gstreamer-0.10 Build it:: @@ -45,9 +46,9 @@ Build on Mac OS X * Install the Apple Developer Tools. You need to register with a credit card in the Apple Store in order to download it. * Install Qt5. You can get it from http://qt-project.org/downloads and choose the default location. +* Install the GStreamer SDK development files. Do this:: - ~/Qt5.2.1/5.2.1/clang_64/bin/qmake - make + ./build.sh diff --git a/MainWindow.cpp b/MainWindow.cpp index ffca3f9..2357244 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -23,6 +23,7 @@ #include "ProjectReader.h" #include "Facade.h" #include +#include MainWindow::MainWindow() { @@ -1524,59 +1525,86 @@ void MainWindow::pollOscInterface() #endif } -void MainWindow::applyOscCommand(const QVariantList& command) +// void MainWindow::applyOscCommand(const QVariantList& command) +// { +// bool VERBOSE = true; +// if (VERBOSE) +// { +// std::cout << "Receive OSC: "; +// for (int i = 0; i < command.size(); ++i) +// { +// if (command.at(i).type() == QVariant::Int) +// { +// std::cout << command.at(i).toInt() << " "; +// } +// else if (command.at(i).type() == QVariant::Double) +// { +// std::cout << command.at(i).toDouble() << " "; +// } +// else if (command.at(i).type() == QVariant::String) +// { +// std::cout << command.at(i).toString().toStdString() << " "; +// } +// else +// { +// std::cout << "??? "; +// } +// } +// std::cout << std::endl; +// std::cout.flush(); +// } +// +// if (command.size() < 2) +// return; +// if (command.at(0).type() != QVariant::String) +// return; +// if (command.at(1).type() != QVariant::String) +// return; +// std::string path = command.at(0).toString().toStdString(); +// std::string typetags = command.at(1).toString().toStdString(); +// +// // Handle all OSC messages here +// if (path == "/image/uri" && typetags == "s") +// { +// std::string image_uri = command.at(2).toString().toStdString(); +// std::cout << "TODO load /image/uri " << image_uri << std::endl; +// } +// else if (path == "/add/quad") +// addMesh(); +// else if (path == "/add/triangle") +// addTriangle(); +// else if (path == "/add/ellipse") +// addEllipse(); +// else if (path == "/project/save") +// save(); +// else if (path == "/project/open") +// open(); +// } + +bool MainWindow::setTextureUri(int texture_id, const std::string &uri) { - bool VERBOSE = true; - if (VERBOSE) - { - std::cout << "Receive OSC: "; - for (int i = 0; i < command.size(); ++i) + // TODO: const QString & + + bool success = false; + Paint::ptr paint = this->mappingManager->getPaintById(texture_id); + if (paint.get() == NULL) { - if (command.at(i).type() == QVariant::Int) - { - std::cout << command.at(i).toInt() << " "; - } - else if (command.at(i).type() == QVariant::Double) - { - std::cout << command.at(i).toDouble() << " "; - } - else if (command.at(i).type() == QVariant::String) - { - std::cout << command.at(i).toString().toStdString() << " "; - } - else - { - std::cout << "??? "; - } + std::cout << "No such texture paint id " << texture_id << std::endl; + success = false; } - std::cout << std::endl; - std::cout.flush(); - } - - if (command.size() < 2) - return; - if (command.at(0).type() != QVariant::String) - return; - if (command.at(1).type() != QVariant::String) - return; - std::string path = command.at(0).toString().toStdString(); - std::string typetags = command.at(1).toString().toStdString(); - - // Handle all OSC messages here - if (path == "/image/uri" && typetags == "s") - { - std::string image_uri = command.at(2).toString().toStdString(); - std::cout << "TODO load /image/uri " << image_uri << std::endl; - } - else if (path == "/add/quad") - addMesh(); - else if (path == "/add/triangle") - addTriangle(); - else if (path == "/add/ellipse") - addEllipse(); - else if (path == "/project/save") - save(); - else if (path == "/project/open") - open(); + else + { + if (paint->getType() == "media") + { + Media *media = (Media *) paint.get(); // FIXME: use sharedptr cast + success = media->setUri(QString(uri.c_str())); + } + else + { + std::cout << "Paint id " << texture_id << " is not a media texture." << std::endl; + return false; + } + } + return success; } diff --git a/MainWindow.h b/MainWindow.h index fe8f9a1..3044a24 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -58,7 +58,7 @@ public: ~MainWindow(); // XXX Unused. - void applyOscCommand(const QVariantList& command); + //void applyOscCommand(const QVariantList& command); protected: // Events /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -147,6 +147,9 @@ public slots: /// Updates all canvases. void updateCanvases(); +public: + bool setTextureUri(int texture_id, const std::string &uri); + private: // Internal methods. ////////////////////////////////////////////////////////////////////////////////////// diff --git a/MediaImpl.h b/MediaImpl.h index e673e72..13739b0 100644 --- a/MediaImpl.h +++ b/MediaImpl.h @@ -56,9 +56,9 @@ public: /// Returns true if the image has changed. bool runVideo(); // void runAudio(); + bool loadMovie(QString filename); protected: - bool loadMovie(QString filename); void unloadMovie(); void freeResources(); void resetMovie(); diff --git a/OSC b/OSC new file mode 100644 index 0000000..09d1b15 --- /dev/null +++ b/OSC @@ -0,0 +1,31 @@ +MapMap OSC Interface +==================== + +API Reference +------------- + +/texture/uri +~~~~~~~~~~~~ +Change a media URI:: + + /texture/uri ,is + +URI: Path to a file. (WARNING: we will change this API soon. +paintID: A number. Usually 0, or 1 or 2... depending on how many paints you have in your project. + +Examples +-------- + +Change a media URI:: + + osc-send osc.udp://localhost:12345 /texture/uri ,is 0 ~/Videos/clips_finaux_ok/lys_flou_net.mov + +See also +-------- + +You might consider using: + +* The txosc library for python. It contains osc-send +* The oscsend utility +* The liblo C library + diff --git a/OscInterface.cpp b/OscInterface.cpp index 54ad6e1..96955dc 100644 --- a/OscInterface.cpp +++ b/OscInterface.cpp @@ -211,13 +211,13 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma std::string typetags = command.at(1).toString().toStdString(); // Handle all OSC messages here - if (path == "/image/uri" && typetags == "ss") + if (path == "/texture/uri" && typetags == "is") { - std::string paint_id = command.at(2).toString().toStdString(); + int paint_id = command.at(2).toInt(); std::string image_uri = command.at(3).toString().toStdString(); //std::cout << "TODO load /image/uri " << image_id << " " << image_uri << std::endl; // TODO: - //main_window.updateImagePaintUri(paint_id.c_str(), image_uri.c_str()); + main_window.setTextureUri(paint_id, image_uri); } //else if (path == "/add/quad") diff --git a/Paint.cpp b/Paint.cpp index 04ae499..b201781 100644 --- a/Paint.cpp +++ b/Paint.cpp @@ -90,3 +90,13 @@ bool Media::hasVideoSupport() return MediaImpl::hasVideoSupport(); } +bool Media::setUri(const QString &uri) +{ + bool success = false; + this->uri = uri; + success = this->impl_->loadMovie(uri); + if (! success) + qDebug() << "Cannot load movie " << uri << "." << endl; + return success; +} + diff --git a/Paint.h b/Paint.h index fc7633f..19579cb 100644 --- a/Paint.h +++ b/Paint.h @@ -189,6 +189,7 @@ public: { return uri; } + bool setUri(const QString &uri); virtual void build(); virtual void update(); virtual QString getType() const diff --git a/build.sh b/build.sh index 949c782..8d6f10a 100755 --- a/build.sh +++ b/build.sh @@ -11,8 +11,8 @@ if [[ $unamestr == "Darwin" ]]; then export QMAKE_CFLAGS_PPC_64 export QMAKESPEC=macx-g++ #export QMAKESPEC=macx-xcode - PATH=$PATH:/Users/aalex/Qt5.2.1/5.2.1/clang_64/bin - qmake5=/Users/aalex/Qt5.2.1/5.2.1/clang_64/bin/qmake + PATH=$PATH:~/Qt5.2.1/5.2.1/clang_64/bin + qmake5=~/Qt5.2.1/5.2.1/clang_64/bin/qmake $qmake5 -spec macx-llvm elif [[ $unamestr == "Linux" ]]; then qmake-qt4