QWidget* PythonTool::settingsWidget() { if (!m_script) return 0; // nothing we can do -- we don't have any real scripts PythonThread pt; if(!m_settingsWidget) { m_settingsWidget = new QWidget(); m_settingsWidget->setLayout( new QVBoxLayout() ); if (PyObject_HasAttrString(m_instance.ptr(), "settingsWidget")) { try { prepareToCatchError(); QWidget *widget = extract<QWidget*>(m_instance.attr("settingsWidget")()); if (widget) m_settingsWidget->layout()->addWidget(widget); } catch (error_already_set const &) { catchError(); } } connect(m_settingsWidget, SIGNAL(destroyed()), this, SLOT(settingsWidgetDestroyed())); } return m_settingsWidget; }
void opShader::linkProgram() { glLinkProgram(_program); /* verification du succes du 'linkage' */ GLint link_status = GL_TRUE; glGetProgramiv(_program, GL_LINK_STATUS, &link_status); if(link_status != GL_TRUE) { GLsizei logsize = 0; char *log = NULL; /* erreur a la compilation recuperation du log d'erreur */ /* on recupere la taille du message d'erreur */ glGetProgramiv(_program, GL_INFO_LOG_LENGTH, &logsize); /* on alloue un espace memoire dans lequel OpenGL ecrira le message */ log = new char[logsize + 1]; assert (log != NULL); /* initialisation du contenu */ memset(log, '\0', logsize + 1); glGetProgramInfoLog(_program, logsize, &logsize, log); std::cerr << "\nImpossible de linker le program : " << log; /* ne pas oublier de liberer la memoire et notre shader */ delete log; assert(false); } catchError("link du shader"); std::cout << "\nLink du shader reussi\n"; }
bool KnockerThread::knockPort(int port) { QTcpSocket socket(this); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchError(QAbstractSocket::SocketError))); connect(&socket, SIGNAL(connected()), this, SLOT(catchConnected())); connect(&socket, SIGNAL(disconnected()), this, SLOT(catchDisconnected())); connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(catchState(QAbstractSocket::SocketState))); this->result = false; this->wait = true; socket.connectToHost(this->host, (quint16)port); /*while(wait) { QThread::yieldCurrentThread(); }*/ bool res = socket.waitForConnected(100); //socket.close(); // Close Immediately! step(); return result; }
inline void CreateVertexBuffer( GLuint& vboID ) { // Make sure we don't loose the reference to the previous VBO if there is one DeleteVertexBuffer( vboID ); glGenBuffers( 1, &vboID ); catchError("generation d\'un buffer."); }
void PythonEngine::loadScript(const QString &filename) { QFileInfo info(filename); initializePython(info.canonicalPath()); PythonThread pt; PythonScript *script = new PythonScript(filename); m_identifier = script->identifier(); if(script->module()) { // make sure there is an Engine class defined if (PyObject_HasAttrString(script->module().ptr(), "Engine")) { try { prepareToCatchError(); // instatiate the new Engine m_instance = script->module().attr("Engine")(); } catch (error_already_set const &) { catchError(); return; } m_script = script; } else { delete script; PythonError::instance()->append(tr("PythonEngine: checking ") + filename + "..."); PythonError::instance()->append(tr(" - script has no 'Engine' class defined")); } } else { delete script; PythonError::instance()->append(tr("PythonEngine: checking ") + filename + "..."); PythonError::instance()->append(tr(" - no module")); } }
void opShader::loadProgram(const char* vsFile, const char* fsFile) { _vs = glCreateShader(GL_VERTEX_SHADER); catchError("creation d'un vertex shader"); assert(_vs != 0); _fs = glCreateShader(GL_FRAGMENT_SHADER); catchError("creation d'un fragment shader"); assert(_fs != 0); _program = glCreateProgram(); catchError("creation du program"); loadVs(vsFile); loadFs(fsFile); glAttachShader(_program, _vs); catchError("attachvsShader"); glAttachShader(_program, _fs); catchError("attachfsShader"); }
SectionSetupForm::~SectionSetupForm() { delete section_number_validator; try { WareSystem::finishInstance(); } catch (const Error & err ) { catchError(err); } }
void DeleteVertexBuffer( GLuint& vboID ) { if ( vboID != 0 ) { glDeleteBuffers( 1, &vboID ); catchError("delete buffer."); vboID = 0; } }
void SectionSetupForm::addSection() { Section * new_section; try { new_section = section_catalog->createSectionByDefault(); showAddedSection(new_section); } catch(const Error& err) { errorMessage("Не удалось добавить новую секцию"); catchError(err); return; } }
void TTInstView::createStatus() { statusLabel = new QLabel; statusLabel->setText("Status:"); statusState = new QLabel; showStatusState(is_connected); QObject::connect(this, SIGNAL(warning(QString)), this, SLOT(catchWarning(QString))); QObject::connect(this, SIGNAL(error(QString)), this, SLOT(catchError(QString))); }
void Guitest::init(){ gui = new clientGUI; QObject::connect(gui, SIGNAL(sendConnectInfo(QString,int,QString)), this, SLOT(login(QString,int,QString))); QObject::connect(this, SIGNAL(connected()), gui, SLOT(wasConnected())); QObject::connect(gui, SIGNAL(sendMsg(QString)), this, SLOT(sendMsg(QString))); QObject::connect(this, SIGNAL(newMessage(QString,QString)), gui, SLOT(gotMessage(QString,QString))); QObject::connect(gui, SIGNAL(updateStatus(QString)), this, SLOT(status(QString))); QObject::connect(this, SIGNAL(listUpdate(QMap<QString,QString>&)), gui, SLOT(updateList(QMap<QString,QString>&))); QObject::connect(this, SIGNAL(sendError(QString)), gui, SLOT(catchError(QString))); QObject::connect(this, SIGNAL(sendServerDisconnect()), gui, SLOT(onServerDisconnect())); }
std::vector<GLuint> opShader::getUniformLocations(std::vector<char*> uniformNames) { std::vector<GLuint> locations; glUseProgram(_program); for(unsigned int i = 0; i < uniformNames.size(); i++) { locations.push_back(glGetUniformLocation(_program, uniformNames[i])); std::cout << uniformNames[i] << " ID : " << locations[i]<<std::endl; std::string operation = "recherche de la location de l\'uniform : " ; operation+= uniformNames[i]; catchError(operation.c_str()); } return locations; }
QString PythonTool::description() const { PythonThread pt; if (!PyObject_HasAttrString(m_instance.ptr(), "description")) return tr("N/A"); try { prepareToCatchError(); const char *desc = extract<const char*>(m_instance.attr("description")()); return QString(desc); } catch(error_already_set const &) { catchError(); return tr("N/A"); } }
QString PythonTool::name() const { PythonThread pt; if (!PyObject_HasAttrString(m_instance.ptr(), "name")) return tr("Unknown Python Tool"); try { prepareToCatchError(); const char *name = extract<const char*>(m_instance.attr("name")()); return QString(name); } catch(error_already_set const &) { catchError(); return tr("Unknown Python Tool"); } }
void SectionSetupForm::changeSectionInfo() { try { Section * select_section = getCurrentSection(); Section * section_new_data = new Section(); setToSectionFromWidgets(section_new_data); section_catalog->editSection(select_section, section_new_data); showChangedSection(select_section, widget.sectionsTableWidget->currentRow()); } catch (const Error &err) { //errorMessage("Не удалось обновить информацию о текущей секции"); catchError(err); selectSection(); } catch(const char* err_text) { errorMessage(err_text); return; } }
void SectionSetupForm::dropSection() { //-----(+)-----Zuskin-----18/10/2011----- int select_row = widget.sectionsTableWidget->currentRow(); //cout << "select row = " << select_row << endl; if ( select_row < 0 ) { errorMessage("Нет выделенной секции"); return; } Section * tmpsection = section_catalog->getSectionByNumber(getSelectSectionNumber()); if (tmpsection->isFiscal()) { vector<Section*> sections = section_catalog->getAllSections(); if (sections.size() == 1) { QMessageBox msgBox((QWidget *)this); msgBox.setWindowTitle(toForm("ВНИМАНИЕ!")); msgBox.setText(toForm("Это фискальная секция!")); msgBox.setInformativeText(toForm("Вы точно хотите удалить эту секцию?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setIcon(QMessageBox::Question); msgBox.setDefaultButton(QMessageBox::No); int state = msgBox.exec(); if (state == QMessageBox::No) return; } else { QMessageBox msgBox((QWidget *)this); msgBox.setWindowTitle(toForm("ВНИМАНИЕ!")); msgBox.setText(toForm("Запрещено удалять фискальную секцию, если есть хотя бы одна нефискальная!")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Warning); int state = msgBox.exec(); return; } } //--------------------------------------- try { section_catalog->dropSection(getSelectSectionNumber()); } catch (const Error & err) { //errorMessage("Не удалось удалить текущюю секцию"); catchError(err); return; } catch(const char* err_text) { errorMessage(err_text); return; } removeSelectRow(); }
void SectionSetupForm::setFiscalSection(int index) { int new_fiscal_section_number = widget.sectionsTableWidget->item(index, 0)->text().toInt(); int old_fiscal_section_number = widget.sectionsTableWidget->item(current_fiscal_section_index, 0)->text().toInt(); try { section_catalog->setFiscalSection( new_fiscal_section_number ); showSectionInTable(section_catalog->getSectionByNumber(new_fiscal_section_number), index); showSectionInTable(section_catalog->getSectionByNumber(old_fiscal_section_number), current_fiscal_section_index); selectSection(); } catch (const Error & err ) { catchError(err); widget.fiscalsectionComboBox->setCurrentIndex( current_fiscal_section_index ); } catch ( const char * err_text ) { errorMessage(err_text); widget.fiscalsectionComboBox->setCurrentIndex( current_fiscal_section_index ); } }
SectionSetupForm::SectionSetupForm() { widget.setupUi(this); widget.sectionsTableWidget->setColumnWidth(0, 110); widget.sectionsTableWidget->setColumnWidth(1, 200); widget.sectionsTableWidget->setColumnWidth(2, 110); connect(widget.addsectionPushButton, SIGNAL(clicked()), SLOT(addSection())); connect(widget.addsectionPushButton, SIGNAL(clicked()), SLOT(saveFiscalIndex())); connect(widget.changesectionPushButton, SIGNAL(clicked()), SLOT(changeSectionInfo())); connect(widget.dropsectionPushButton, SIGNAL(clicked()), SLOT(dropSection())); connect(widget.dropsectionPushButton, SIGNAL(clicked()), SLOT(saveFiscalIndex())); connect(widget.sectionsTableWidget, SIGNAL(itemSelectionChanged()), SLOT(selectSection())); connect(widget.fiscalsectionComboBox, SIGNAL(activated(int)), SLOT(setFiscalSection(int))); connect(widget.fiscalsectionComboBox, SIGNAL(activated(int)), SLOT(saveFiscalIndex())); connect(widget.sectionheadtextTextEdit, SIGNAL(textChanged()), SLOT(headTextChanged())); connect(widget.sectionbottomtextTextEdit, SIGNAL(textChanged()), SLOT(bottomTextChanged())); section_number_validator = new QIntValidator(0, 999, this); widget.sectionnumberLineEdit->setValidator(section_number_validator); //---(+)---Zuskin---15/02/2012--- setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), qApp->desktop()->availableGeometry())); //------------------------------- try { WareSystem::startInstance(); section_catalog = WareSystem::getInstance()->getSectionCatalog(); loadSections(); } catch (const Error & err) { //cout << "err.code - " << err.getErrorCode() << endl; if ( err.getErrorCode() == ERROR_OBJECT_NOT_FOUND ) { //---(-)---Zuskin---15/02/2012--- //errorMessage("Не удалось загрузить список секций"); //------------------------------- } else catchError(err); } }
double PythonEngine::transparencyDepth() const { if (!m_script) return 0.0; // nothing we can do PythonThread pt; try { prepareToCatchError(); // return transparencyDepth from python script if the function is defined if (PyObject_HasAttrString(m_instance.ptr(), "transparencyDepth")) return extract<double>(m_instance.attr("transparencyDepth")()); } catch(error_already_set const &) { catchError(); } return 0.0; }
void VideoPlayer::closePlayer() { #ifdef HAS_LIBVLC if(ctxPtr != NULL && ctxPtr->libvlc != NULL) { // // Stop stream and clean up libVLC // #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) libvlc_media_player_stop(ctxPtr->mp,&ex); catchError(&ex); #else libvlc_media_player_stop(ctxPtr->mp); #endif if(ctxPtr->mlp != NULL) { libvlc_media_list_player_release(ctxPtr->mlp); ctxPtr->mlp = NULL; } libvlc_media_player_release(ctxPtr->mp); ctxPtr->mp = NULL; libvlc_release(ctxPtr->libvlc); } #endif // // Close window and clean up libSDL // if(ctxPtr != NULL) { if(ctxPtr->mutex != NULL) { SDL_DestroyMutex(ctxPtr->mutex); } if(ctxPtr->surf != NULL) { SDL_FreeSurface(ctxPtr->surf); } if(ctxPtr->empty != NULL) { SDL_FreeSurface(ctxPtr->empty); } glDeleteTextures(1, &ctxPtr->textureId); if(ctxPtr->needToQuit == true) { SDL_Event quit_event = {SDL_QUIT}; SDL_PushEvent(&quit_event); } } }
bool PythonEngine::renderOpaque(PainterDevice *pd) { PythonThread pt; if (!m_script) return false; // nothing we can do try { prepareToCatchError(); boost::python::reference_existing_object::apply<PainterDevice*>::type converter; PyObject *obj = converter(pd); object real_obj = object(handle<>(obj)); m_instance.attr("renderOpaque")(real_obj); } catch(error_already_set const &) { catchError(); } return true; }
Engine::Layers PythonEngine::layers() const { if (!m_script) return Engine::Opaque; // nothing we can do PythonThread pt; try { prepareToCatchError(); // return layers from python script if the function is defined if (PyObject_HasAttrString(m_instance.ptr(), "layers")) return extract<Engine::Layers>(m_instance.attr("layers")()); } catch(error_already_set const &) { catchError(); } // return NoFlags, don't print an error, don't want to overwhelm new users with errors return Engine::Opaque; }
PythonTool::PythonTool(QObject *parent, const QString &filename) : Tool(parent), m_script(0), m_settingsWidget(0) { loadScript(filename); QAction *action = activateAction(); action->setIcon(QIcon(QString::fromUtf8(":/python/python.png"))); PythonThread pt; if (PyObject_HasAttrString(m_instance.ptr(), "toolTip")) { try { prepareToCatchError(); const char *toolTip = extract<const char*>(m_instance.attr("toolTip")()); action->setToolTip(QString(toolTip)); } catch(error_already_set const &) { catchError(); } } }
void PythonTool::loadScript(const QString &filename) { QFileInfo info(filename); initializePython(info.canonicalPath()); PythonThread pt; PythonScript *script = new PythonScript(filename); m_identifier = script->identifier(); if(script->module()) { // make sure there is a Tool class defined if (PyObject_HasAttrString(script->module().ptr(), "Tool")) { try { prepareToCatchError(); // instantiate the new tool m_instance = script->module().attr("Tool")(); // if we have a settings widget already, add the python content... if (m_settingsWidget) { if (PyObject_HasAttrString(m_instance.ptr(), "settingsWidget")) { QWidget *widget = extract<QWidget*>(m_instance.attr("settingsWidget")()); if (widget) m_settingsWidget->layout()->addWidget(widget); } } } catch (error_already_set const &) { catchError(); return; } m_script = script; } else { delete script; PythonError::instance()->append(tr("PythonTool: checking ") + filename + "..."); PythonError::instance()->append(tr(" - script has no 'Tool' class defined")); } } else { delete script; PythonError::instance()->append(tr("PythonTool: checking ") + filename + "..."); PythonError::instance()->append(tr(" - no module")); } }
bool PythonTool::paint(GLWidget *widget) { PythonThread pt; if (!PyObject_HasAttrString(m_instance.ptr(), "paint")) return false; try { prepareToCatchError(); boost::python::reference_existing_object::apply<GLWidget*>::type converter; PyObject *obj = converter(widget); object real_obj = object(handle<>(obj)); m_instance.attr("paint")(real_obj); } catch(error_already_set const &) { catchError(); } return true; }
object PythonScript::module() const { QFileInfo fileInfo(m_fileName); if(fileInfo.lastModified() > m_lastModified) { try { prepareToCatchError(); m_module = object(handle<>(PyImport_ReloadModule(m_module.ptr()))); } catch(error_already_set const &) { catchError(); } m_lastModified = fileInfo.lastModified(); } return m_module; }
PythonScript::PythonScript(const QString &fileName) { m_fileName = fileName; QFileInfo info(fileName); m_moduleName = info.baseName(); m_lastModified = info.lastModified(); try { prepareToCatchError(); // try to import the module m_module = import(m_moduleName.toAscii().data()); // import doesn't really reload the module if it was already loaded // to be save, we always reload it m_module = object(handle<>(PyImport_ReloadModule(m_module.ptr()))); } catch(error_already_set const &) { catchError(); } }
void PythonEngine::readSettings(QSettings &settings) { Engine::readSettings(settings); if (!m_script) return; if (!PyObject_HasAttrString(m_instance.ptr(), "readSettings")) return; try { prepareToCatchError(); boost::python::return_by_value::apply<QSettings*>::type qconverter; PyObject *qobj = qconverter(&settings); object real_qobj = object(handle<>(qobj)); m_instance.attr("readSettings")(real_qobj); } catch(error_already_set const &) { catchError(); } }
QUndoCommand* PythonTool::wheelEvent(GLWidget *widget, QWheelEvent *event) { PythonThread pt; if (!PyObject_HasAttrString(m_instance.ptr(), "wheelEvent")) return 0; try { prepareToCatchError(); boost::python::reference_existing_object::apply<GLWidget*>::type converter; PyObject *obj = converter(widget); object real_obj = object(handle<>(obj)); boost::python::return_by_value::apply<QWheelEvent*>::type qconverter; PyObject *qobj = qconverter(event); object real_qobj = object(handle<>(qobj)); return extract<QUndoCommand*>(m_instance.attr("wheelEvent")(real_obj, real_qobj)); } catch(error_already_set const &) { catchError(); } return 0; }
bool VideoPlayer::initPlayer(string mediaURL) { if(VideoPlayer::disabled == true) { return true; } #ifdef HAS_LIBVLC ctxPtr->libvlc = NULL; ctxPtr->m = NULL; ctxPtr->mp = NULL; ctxPtr->vlc_argv.clear(); ctxPtr->vlc_argv.push_back("--intf=dummy"); //ctxPtr->vlc_argv.push_back("--intf=http"); //ctxPtr->vlc_argv.push_back("--no-media-library"); ctxPtr->vlc_argv.push_back("--ignore-config"); /* Don't use VLC's config */ ctxPtr->vlc_argv.push_back("--no-xlib"); /* tell VLC to not use Xlib */ ctxPtr->vlc_argv.push_back("--no-video-title-show"); //ctxPtr->vlc_argv.push_back("--network-caching=10000"); if(loop == true) { ctxPtr->vlc_argv.push_back("--loop"); ctxPtr->vlc_argv.push_back("--repeat"); } #if defined(LIBVLC_VERSION_PRE_2) ctxPtr->vlc_argv_str.push_back("--plugin-path=" + pluginsPath); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); #endif #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) char clock[64], cunlock[64], cdata[64]; char cwidth[32], cheight[32], cpitch[32]; /* * Initialise libVLC */ sprintf(clock, "%lld", (long long int)(intptr_t)lock); sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock); sprintf(cdata, "%lld", (long long int)(intptr_t)ctxPtr); sprintf(cwidth, "%i", width); sprintf(cheight, "%i", height); sprintf(cpitch, "%i", colorBits); vlc_argv.push_back("--vout"); vlc_argv.push_back("vmem"); vlc_argv.push_back("--vmem-width"); ctxPtr->vlc_argv_str.push_back(cwidth); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-height"); ctxPtr->vlc_argv_str.push_back(cheight); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-pitch"); ctxPtr->vlc_argv_str.push_back(cpitch); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-chroma"); vlc_argv.push_back("RV16"); vlc_argv.push_back("--vmem-lock"); ctxPtr->vlc_argv_str.push_back(clock); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-unlock"); ctxPtr->vlc_argv_str.push_back(cunlock); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-data"); ctxPtr->vlc_argv_str.push_back(cdata); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); #endif if(verboseEnabled) ctxPtr->vlc_argv.push_back("--verbose=2"); if(verboseEnabled) ctxPtr->vlc_argv.push_back("--extraintf=logger"); //log anything #if defined(WIN32) if(verboseEnabled) _putenv("VLC_VERBOSE=2"); #endif int vlc_argc = ctxPtr->vlc_argv.size(); // char const *vlc_argv[] = // { // //"--no-audio", /* skip any audio track */ // "--no-xlib", /* tell VLC to not use Xlib */ // "--no-video-title-show", // pluginParam.c_str(), // }; // int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); #endif ctxPtr->empty = NULL; glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); // Init Texture glGenTextures(1, &ctxPtr->textureId); glBindTexture(GL_TEXTURE_2D, ctxPtr->textureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ctxPtr->empty = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, colorBits, 0, 0, 0, 0); ctxPtr->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, colorBits, 0x001f, 0x07e0, 0xf800, 0); ctxPtr->mutex = SDL_CreateMutex(); #ifdef HAS_LIBVLC /* * Initialize libVLC */ if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) libvlc_exception_t ex; libvlc_exception_init(&ex); ctxPtr->libvlc = libvlc_new(ctxPtr->vlc_argc, &ctxPtr->vlc_argv[0],&ex); catchError(&ex); #else ctxPtr->libvlc = libvlc_new(vlc_argc, &ctxPtr->vlc_argv[0]); #endif if(verboseEnabled) printf("In [%s] Line: %d, libvlc [%p]\n",__FUNCTION__,__LINE__,ctxPtr->libvlc); /* It is meaningless to try all this because we have to restart mg to pickup new env vars #if defined(WIN32) if(libvlc == NULL) { // For windows check registry for install path std::string strValue = getRegKey("Software\\VideoLAN\\VLC", "InstallDir"); if(strValue != "") { if(strValue.length() >= 2) { if(strValue[0] == '"') { strValue = strValue.erase(0); } if(strValue[strValue.length()-1] == '"') { strValue = strValue.erase(strValue.length()-1); } } strValue = "VLC_PLUGIN_PATH=" + strValue; _putenv(strValue.c_str()); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } } #endif */ if(ctxPtr->libvlc != NULL) { #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) ctxPtr->m = libvlc_media_new(ctxPtr->libvlc, mediaURL.c_str(), &ex); if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m); catchError(&ex); ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m); if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp); libvlc_media_release(ctxPtr->m); #else if(mediaURL.find(HTTP_PREFIX) == 0) { ctxPtr->mlp = libvlc_media_list_player_new(ctxPtr->libvlc); ctxPtr->ml = libvlc_media_list_new(ctxPtr->libvlc); ctxPtr->m = libvlc_media_new_location(ctxPtr->libvlc, mediaURL.c_str()); libvlc_media_list_add_media(ctxPtr->ml, ctxPtr->m); } else { ctxPtr->m = libvlc_media_new_path(ctxPtr->libvlc, mediaURL.c_str()); } /* Create a new item */ if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m); if(loop == true) { libvlc_media_add_option(ctxPtr->m, "input-repeat=-1"); } if(mediaURL.find(HTTP_PREFIX) == 0) { ctxPtr->mp = libvlc_media_player_new(ctxPtr->libvlc); } else { ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m); } if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp); libvlc_media_player_set_media(ctxPtr->mp, ctxPtr->m); libvlc_media_release(ctxPtr->m); if(mediaURL.find(HTTP_PREFIX) == 0) { // Use our media list libvlc_media_list_player_set_media_list(ctxPtr->mlp, ctxPtr->ml); // Use a given media player libvlc_media_list_player_set_media_player(ctxPtr->mlp, ctxPtr->mp); } // Get an event manager for the media player. if(mediaURL.find(HTTP_PREFIX) == 0) { libvlc_event_manager_t *eventManager = libvlc_media_list_player_event_manager(ctxPtr->mlp); if(eventManager) { // libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex); int event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerNextItemSet, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerNextItemSet]\n"); } } } //else { //libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex); libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(ctxPtr->mp); if(eventManager) { int event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerSnapshotTaken, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerSnapshotTaken]\n"); } // event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerTimeChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerTimeChanged]\n"); // } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPlaying, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPlaying]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPaused, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPaused]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerStopped, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerStopped]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerEndReached, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerEndReached]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPositionChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPositionChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerLengthChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerLengthChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerEncounteredError,callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerEncounteredError]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPausableChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPausableChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerSeekableChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerSeekableChanged]\n"); } // event_added = libvlc_event_attach( eventManager, libvlc_MediaStateChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaStateChanged]\n"); // } // event_added = libvlc_event_attach( eventManager, libvlc_MediaParsedChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaParsedChanged]\n"); // } #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerVout, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerVout]\n"); } #endif // event_added = libvlc_event_attach( eventManager, libvlc_MediaListItemAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListItemAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListWillAddItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListWillAddItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListItemDeleted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListItemDeleted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListWillDeleteItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListWillDeleteItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewItemAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewItemAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewWillAddItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewWillAddItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewItemDeleted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewItemDeleted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewWillDeleteItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewWillDeleteItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerPlayed, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerPlayed]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerNextItemSet, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerNextItemSet]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerStopped, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerStopped]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaDiscovererStarted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaDiscovererStarted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaDiscovererEnded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaDiscovererEnded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaRemoved, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaRemoved]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaChanged]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStarted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStarted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStopped, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStopped]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusInit, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusInit]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusOpening, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusOpening]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusPlaying, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusPlaying]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusPause, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusPause]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusEnd, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusEnd]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusError, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusError]\n"); // } } //} //libvlc_media_release(ctxPtr->m); #endif #if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0) libvlc_video_set_callbacks(ctxPtr->mp, lock, unlock, display, ctxPtr); libvlc_video_set_format(ctxPtr->mp, "RV16", width, height, this->surface->pitch); #endif ctxPtr->isPlaying = true; #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) int play_result = libvlc_media_player_play(ctxPtr->mp,&ex); #else int play_result = 0; if(mediaURL.find(HTTP_PREFIX) == 0) { libvlc_media_list_player_play(ctxPtr->mlp); } else { play_result = libvlc_media_player_play(ctxPtr->mp); } // Play //int play_result = 0; //libvlc_media_list_player_play(ctxPtr->mlp); #endif //SDL_Delay(5); if(verboseEnabled) printf("In [%s] Line: %d, play_result [%d]\n",__FUNCTION__,__LINE__,play_result); successLoadingLib = (play_result == 0); } #endif return successLoadingLib; }