bool VlcMediaWidget::init() { const char *arguments[] = { "--no-video-title-show" }; vlcInstance = libvlc_new(sizeof(arguments) / sizeof(arguments[0]), arguments); if (vlcInstance == NULL) { Log("VlcMediaWidget::init: cannot create vlc instance") << QLatin1String(libvlc_errmsg()); return false; } vlcMediaPlayer = libvlc_media_player_new(vlcInstance); if (vlcMediaPlayer == NULL) { Log("VlcMediaWidget::init: cannot create vlc media player") << QLatin1String(libvlc_errmsg()); return false; } libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(vlcMediaPlayer); libvlc_event_e eventTypes[] = { libvlc_MediaPlayerEncounteredError, libvlc_MediaPlayerEndReached, libvlc_MediaPlayerLengthChanged, libvlc_MediaPlayerSeekableChanged, libvlc_MediaPlayerStopped, libvlc_MediaPlayerTimeChanged }; for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) { if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHandler, this) != 0) { Log("VlcMediaWidget::init: cannot attach event handler") << eventTypes[i]; return false; } } libvlc_media_player_set_xwindow(vlcMediaPlayer, quint32(winId())); setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_PaintOnScreen); return true; }
void VlcLib::print_error() { // Outputs libvlc error message if there is any if(libvlc_errmsg()) { Debug::error() << "[libvlc] " << "Error:" << libvlc_errmsg(); libvlc_clearerr(); } }
int LibvlcCamera::PrimeCapture() { Info("Priming capture from %s", mPath.c_str()); StringVector opVect = split(Options(), ","); // Set transport method as specified by method field, rtpUni is default if ( Method() == "rtpMulti" ) opVect.push_back("--rtsp-mcast"); else if ( Method() == "rtpRtsp" ) opVect.push_back("--rtsp-tcp"); else if ( Method() == "rtpRtspHttp" ) opVect.push_back("--rtsp-http"); opVect.push_back("--no-audio"); if ( opVect.size() > 0 ) { mOptArgV = new char*[opVect.size()]; Debug(2, "Number of Options: %d",opVect.size()); for (size_t i=0; i< opVect.size(); i++) { opVect[i] = trimSpaces(opVect[i]); mOptArgV[i] = (char *)opVect[i].c_str(); Debug(2, "set option %d to '%s'", i, opVect[i].c_str()); } } mLibvlcInstance = libvlc_new(opVect.size(), (const char* const*)mOptArgV); if ( mLibvlcInstance == NULL ) { Error("Unable to create libvlc instance due to: %s", libvlc_errmsg()); return -1; } mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str()); if ( mLibvlcMedia == NULL ) { Error("Unable to open input %s due to: %s", mPath.c_str(), libvlc_errmsg()); return -1; } mLibvlcMediaPlayer = libvlc_media_player_new_from_media(mLibvlcMedia); if ( mLibvlcMediaPlayer == NULL ) { Error("Unable to create player for %s due to: %s", mPath.c_str(), libvlc_errmsg()); return -1; } libvlc_video_set_format(mLibvlcMediaPlayer, mTargetChroma.c_str(), width, height, width * mBpp); libvlc_video_set_callbacks(mLibvlcMediaPlayer, &LibvlcLockBuffer, &LibvlcUnlockBuffer, NULL, &mLibvlcData); mLibvlcData.bufferSize = width * height * mBpp; // Libvlc wants 32 byte alignment for images (should in theory do this for all image lines) mLibvlcData.buffer = (uint8_t*)zm_mallocaligned(64, mLibvlcData.bufferSize); mLibvlcData.prevBuffer = (uint8_t*)zm_mallocaligned(64, mLibvlcData.bufferSize); mLibvlcData.newImage.setValueImmediate(false); libvlc_media_player_play(mLibvlcMediaPlayer); return 0; }
bool VlcLib::isError() { if(libvlc_errmsg()) return true; return false; }
Audio::Audio() : vlcInstance(NULL) { QSettings settings; if(!settings.contains(QStringLiteral("audio_init")) || settings.value(QStringLiteral("audio_init")).toInt()==2) { settings.setValue(QStringLiteral("audio_init"),1); settings.sync(); /* Initialize libVLC */ /*const char * const vlc_args[] = { "-vvv" }; vlcInstance = libvlc_new(1,vlc_args);*/ vlcInstance = libvlc_new(0,NULL); /* Complain in case of broken installation */ if (vlcInstance == NULL) qDebug() << "Qt libVLC player, Could not init libVLC"; const char * string=libvlc_errmsg(); if(string!=NULL) qDebug() << string; settings.setValue(QStringLiteral("audio_init"),2); } else qDebug() << "Audio disabled due to previous crash"; }
VlcError *VlcError::create() noexcept { VlcError *e = nullptr; if (libvlc_errmsg()) e = new VlcError(); libvlc_clearerr(); return e; }
// Method for checking VLC exceptions bool VLCVideoWrapper::checkVLCError (const std::string& message) { bool error(false); // check if there was an error if (libvlc_errmsg() != NULL) { // printing out what/where the exception happend (message should contain this info!) SWARNING << "VLC error occured while : " << message << ". Error: " << libvlc_errmsg() << std::endl; error = true; } libvlc_clearerr(); return error; }
VLCEventBridge::VLCEventBridge( VLCMediaPlayer* mediaplayer ) { Q_ASSERT( mediaplayer != 0 ); Q_ASSERT( mediaplayer->_mediaPlayer != 0 ); _mediaPlayer = mediaplayer; _eventManager = libvlc_media_player_event_manager( _mediaPlayer->_mediaPlayer ); if ( !_eventManager ) throw libvlc_errmsg(); }
static bool catchVLCException( libvlc_exception_t *ex ) { if ( libvlc_exception_raised( ex ) ) { qDebug() << libvlc_errmsg(); libvlc_exception_clear( ex ); return (true); } return (false); }
void VLCEventBridge::attachEvent( libvlc_event_type_t event_type ) { int ret = libvlc_event_attach( _eventManager, event_type, onVLCEvent, _mediaPlayer ); if ( ret != 0 ) { throw libvlc_errmsg(); } }
void libvlc_exception_raise( libvlc_exception_t *p_exception ) { /* Does caller care about exceptions ? */ if( p_exception == NULL ) { /* Print something, so that lazy third-parties can easily * notice that something may have gone unnoticedly wrong */ libvlc_exception_not_handled( libvlc_errmsg() ); return; } p_exception->b_raised = 1; }
void VideoWidget::load(QString file) { qDebug() << "Loading media:" << file; m = libvlc_media_new_path(inst,file.toAscii());//libvlc_media_new_location (inst, file.toAscii()); if (!m) { qDebug() << "Error loading media location:" << libvlc_errmsg(); } mp = libvlc_media_player_new_from_media (m); if (!mp) { qDebug() << "Error loading media player" << libvlc_errmsg(); } libvlc_media_release (m); //libvlc_media_player_set_xwindow(mp, this->winId()); //Old code for loading to a winId libvlc_video_set_callbacks(mp, lock, unlock, display, this); libvlc_video_set_format(mp, "RV32", pix->width(), pix->height(), pix->width()*4); mediaLoaded = true; }
void VlcTagger::handleException() { #if LIBVLC_VERSION_INT < 0x110 if (libvlc_exception_raised(_pException)) { LOGNS(Omm::Av, upnpav, error, "vlc tagger: " + std::string(libvlc_exception_get_message(_pException))); } libvlc_exception_init(_pException); #else const char* errMsg = libvlc_errmsg(); if (errMsg) { LOGNS(Omm::Av, upnpav, error, "vlc tagger: " + std::string(errMsg)); } #endif }
static gboolean player_event_poll(XmrPlayer *player) { PlayerEvent *event = g_async_queue_try_pop(player->priv->event_queue); if (event == NULL) return TRUE; switch(event->type) { case libvlc_MediaPlayerEncounteredError: { GError error = { 0 }; error.message = (gchar *)libvlc_errmsg(); g_signal_emit(player, signals[ERROR], 0, &error); } break; case libvlc_MediaPlayerBuffering: { g_signal_emit(player, signals[BUFFERING], 0, (guint)event->buffering); } break; case libvlc_MediaPlayerPlaying: case libvlc_MediaPlayerPaused: case libvlc_MediaPlayerStopped: g_signal_emit(player, signals[STATE_CHANGED], 0); break; case libvlc_MediaPlayerTimeChanged: { g_signal_emit(player, signals[TICK], 0, event->position, xmr_player_get_duration(player)); } break; case libvlc_MediaPlayerEndReached: g_signal_emit(player, signals[EOS], 0, FALSE); break; default: break; } g_free(event); return TRUE; }
bool VlcLib::init() { //Debug::warning() << "[PLAYER] -> VlcLib::init"; //! init args for vlc libs QList<QByteArray> args; /* NOTE 1: warning from vlc doc : There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to libvlc_new() arguments. We recommend that you do not use them, other than when debugging. */ /* NOTE 2: --no-plugins-cache CRASH on ubuntu 15.10 frash install */ args << "--no-media-library" << "--no-one-instance" << "--no-stats" << "--no-osd" << "--no-loop" << "--no-xlib" << "--no-video-title-show" << "--drop-late-frames" << "--no-video"; // Convert arguments to required format QVarLengthArray<const char *, 64> vlcArgs(args.size()); for (int i = 0; i < args.size(); ++i) { vlcArgs[i] = args.at(i).constData(); } // Create new libvlc instance m_vlcInstance = libvlc_new(vlcArgs.size(), vlcArgs.constData()); // Check if instance is running if(m_vlcInstance) { Debug::debug() << "[EngineVlc] vlc initialised"; Debug::debug() << "[EngineVlc] using libvlc version:" << QString(libvlc_get_version()); } else { Debug::error() << "vlc initialization error :" << libvlc_errmsg(); return false; } return true; }
void MainWindow::vlcevent(const libvlc_event_t *event, void *ptr) { qDebug() << "vlc event"; Q_UNUSED(ptr); switch(event->type) { case libvlc_MediaPlayerEncounteredError: { const char * string=libvlc_errmsg(); if(string==NULL) qDebug() << "vlc error"; else qDebug() << string; } break; default: break; } }
const char *LibVLC::errorMessage() { return libvlc_errmsg(); }
bool VlcVideoWidget::OpenSource(const QString &videoUrl) { if (!Initialized()) return false; // We need to prepend file:// if this is a path on disk. QString source = videoUrl; AssetAPI::AssetRefType sourceType = AssetAPI::ParseAssetRef(source); if ((sourceType == AssetAPI::AssetRefLocalPath || sourceType == AssetAPI::AssetRefLocalUrl)) { if (source.startsWith("file://", Qt::CaseInsensitive)) source = source.mid(7); vlcMedia_ = libvlc_media_new_path(vlcInstance_, source.toUtf8().constData()); } else vlcMedia_ = libvlc_media_new_location(vlcInstance_, source.toUtf8().constData()); if (vlcMedia_ == 0) { LogError("VlcVideoWidget: Could not load media from '" + videoUrl + "'"); return false; } libvlc_event_manager_t *em = libvlc_media_event_manager(vlcMedia_); libvlc_event_attach(em, libvlc_MediaMetaChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaSubItemAdded, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaDurationChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaParsedChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaFreed, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaStateChanged, &VlcEventHandler, this); libvlc_state_t state = libvlc_media_get_state(vlcMedia_); if (state != libvlc_Error) { // Reset playback Stop(); hasVideoOut_ = false; libvlc_media_player_set_media(vlcPlayer_, vlcMedia_); statusAccess.lock(); status.Reset(); status.source = videoUrl; status.change = PlayerStatus::MediaSource; statusAccess.unlock(); return true; } else { std::string err = "Unknown error"; if (libvlc_errmsg()) { err = libvlc_errmsg(); libvlc_clearerr(); } LogError("VlcVideoWidget: " + err); } return false; }
/***************************************************************************** * main: parse command line, start interface and spawn threads. *****************************************************************************/ int main( int i_argc, const char *ppsz_argv[] ) { #ifdef __APPLE__ /* The so-called POSIX-compliant MacOS X is not. * SIGPIPE fires even when it is blocked in all threads! */ signal (SIGPIPE, SIG_IGN); #endif #ifndef ALLOW_RUN_AS_ROOT if (geteuid () == 0) { fprintf (stderr, "VLC is not supposed to be run as root. Sorry.\n" "If you need to use real-time priorities and/or privileged TCP ports\n" "you can use %s-wrapper (make sure it is Set-UID root and\n" "cannot be run by non-trusted users first).\n", ppsz_argv[0]); return 1; } #endif setlocale (LC_ALL, ""); #ifndef __APPLE__ /* This clutters OSX GUI error logs */ fprintf( stderr, "VLC media player %s\n", libvlc_get_version() ); #endif #ifdef HAVE_PUTENV # ifndef NDEBUG /* Activate malloc checking routines to detect heap corruptions. */ putenv( (char*)"MALLOC_CHECK_=2" ); /* Disable the ugly Gnome crash dialog so that we properly segfault */ putenv( (char *)"GNOME_DISABLE_CRASH_DIALOG=1" ); # endif #endif /* Synchronously intercepted POSIX signals. * * In a threaded program such as VLC, the only sane way to handle signals * is to block them in all thread but one - this is the only way to * predict which thread will receive them. If any piece of code depends * on delivery of one of this signal it is intrinsically not thread-safe * and MUST NOT be used in VLC, whether we like it or not. * There is only one exception: if the signal is raised with * pthread_kill() - we do not use this in LibVLC but some pthread * implementations use them internally. You should really use conditions * for thread synchronization anyway. * * Signal that request a clean shutdown, and force an unclean shutdown * if they are triggered again 2+ seconds later. * We have to handle SIGTERM cleanly because of daemon mode. * Note that we set the signals after the vlc_create call. */ static const int sigs[] = { SIGINT, SIGHUP, SIGQUIT, SIGTERM, /* Signals that cause a no-op: * - SIGPIPE might happen with sockets and would crash VLC. It MUST be * blocked by any LibVLC-dependent application, not just VLC. * - SIGCHLD comes after exec*() (such as httpd CGI support) and must * be dequeued to cleanup zombie processes. */ SIGPIPE, SIGCHLD }; sigset_t set; sigemptyset (&set); for (unsigned i = 0; i < sizeof (sigs) / sizeof (sigs[0]); i++) sigaddset (&set, sigs[i]); /* Block all these signals */ pthread_sigmask (SIG_BLOCK, &set, NULL); sigdelset (&set, SIGPIPE); sigdelset (&set, SIGCHLD); /* Note that FromLocale() can be used before libvlc is initialized */ const char *argv[i_argc + 3]; int argc = 0; argv[argc++] = "--no-ignore-config"; #ifdef TOP_BUILDDIR argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules"); #endif #ifdef TOP_SRCDIR # ifdef ENABLE_HTTPD argv[argc++] = FromLocale ("--http-src="TOP_SRCDIR"/share/http"); # endif #endif for (int i = 1; i < i_argc; i++) if ((argv[argc++] = FromLocale (ppsz_argv[i])) == NULL) return 1; // BOOM! argv[argc] = NULL; libvlc_exception_t ex, dummy; libvlc_exception_init (&ex); libvlc_exception_init (&dummy); /* Initialize libvlc */ libvlc_instance_t *vlc = libvlc_new (argc, argv, &ex); if (vlc != NULL) { libvlc_add_intf (vlc, "signals", &ex); if (libvlc_exception_raised (&ex)) { libvlc_exception_clear (&ex); pthread_sigmask (SIG_UNBLOCK, &set, NULL); } #if !defined (HAVE_MAEMO) libvlc_add_intf (vlc, "globalhotkeys,none", &ex); #endif libvlc_exception_clear (&ex); libvlc_add_intf (vlc, NULL, &ex); libvlc_playlist_play (vlc, -1, 0, NULL, &dummy); libvlc_wait (vlc); if (libvlc_exception_raised (&ex)) fprintf( stderr, "%s\n", libvlc_errmsg() ); libvlc_release (vlc); } for (int i = 1; i < argc; i++) LocaleFree (argv[i]); return vlc == NULL || libvlc_exception_raised (&ex); }
void VlcVideoWidget::VlcEventHandler(const libvlc_event_t *event, void *widget) { // Return on certain events switch (event->type) { case libvlc_MediaPlayerTitleChanged: case libvlc_MediaMetaChanged: case libvlc_MediaSubItemAdded: case libvlc_MediaDurationChanged: case libvlc_MediaParsedChanged: case libvlc_MediaFreed: return; default: break; } VlcVideoWidget* w = reinterpret_cast<VlcVideoWidget*>(widget); w->statusAccess.lock(); switch (event->type) { // Media player events case libvlc_MediaPlayerMediaChanged: { w->DetermineVideoSize(); break; } case libvlc_MediaPlayerOpening: { w->DetermineVideoSize(); break; } case libvlc_MediaPlayerBuffering: { w->DetermineVideoSize(); w->status.buffering = true; w->status.playing = false; w->status.paused = false; w->status.stopped = false; w->status.change = PlayerStatus::MediaState; break; } case libvlc_MediaPlayerPlaying: { w->DetermineVideoSize(); w->status.buffering = false; w->status.playing = true; w->status.paused = false; w->status.stopped = false; w->status.change = PlayerStatus::MediaState; break; } case libvlc_MediaPlayerPaused: { w->status.buffering = false; w->status.playing = false; w->status.paused = true; w->status.stopped = false; w->status.change = PlayerStatus::MediaState; break; } case libvlc_MediaPlayerStopped: { w->status.buffering = false; w->status.playing = false; w->status.paused = false; w->status.stopped = true; w->status.time = 0.0; w->status.change = PlayerStatus::MediaState; break; } case libvlc_MediaPlayerEncounteredError: { std::string err = "Unknown error"; if (libvlc_errmsg()) { err = libvlc_errmsg(); libvlc_clearerr(); } w->status.error = QString("Media player encountered error: ") + err.c_str(); w->status.change = PlayerStatus::PlayerError; break; } case libvlc_MediaPlayerTimeChanged: { w->DetermineVideoSize(); w->status.time = event->u.media_player_time_changed.new_time; w->status.change = PlayerStatus::MediaTime; break; } case libvlc_MediaPlayerPositionChanged: { w->DetermineVideoSize(); w->status.position = event->u.media_player_position_changed.new_position; w->status.change = PlayerStatus::MediaTime; break; } case libvlc_MediaPlayerSeekableChanged: { w->DetermineVideoSize(); w->status.isSeekable = (event->u.media_player_seekable_changed.new_seekable > 0 ? true : false); w->status.change = PlayerStatus::MediaProperty; break; } case libvlc_MediaPlayerPausableChanged: { w->DetermineVideoSize(); w->status.isPausable = (event->u.media_player_pausable_changed.new_pausable > 0 ? true : false); w->status.change = PlayerStatus::MediaProperty; break; } case libvlc_MediaPlayerLengthChanged: { w->DetermineVideoSize(); w->status.lenght = event->u.media_player_length_changed.new_length; w->status.change = PlayerStatus::MediaTime; break; } // Media events case libvlc_MediaStateChanged: { if (event->u.media_state_changed.new_state == libvlc_Buffering) { w->DetermineVideoSize(); w->status.buffering = true; w->status.playing = false; w->status.paused = false; w->status.stopped = false; w->status.change = PlayerStatus::MediaState; } if (event->u.media_state_changed.new_state == libvlc_Ended) { w->status.doStop = true; w->status.doNotPlayAfterRestart = true; w->status.doRestart = true; w->status.buffering = false; w->status.playing = false; w->status.paused = false; w->status.stopped = true; w->status.time = 0.0; w->status.change = PlayerStatus::MediaState; } break; } // Default default: break; } w->statusAccess.unlock(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); qRegisterMetaType<CatchChallenger::Chat_type>("CatchChallenger::Chat_type"); qRegisterMetaType<CatchChallenger::Player_type>("CatchChallenger::Player_type"); qRegisterMetaType<QList<RssNews::RssEntry> >("QList<RssNews::RssEntry>"); realSslSocket=new QSslSocket(); haveFirstHeader=false; socket=NULL; realSslSocket=NULL; CatchChallenger::Api_client_real::client=NULL; ui->setupUi(this); ui->update->setVisible(false); ui->news->setVisible(false); server_name=SERVER_NAME; server_dns_or_ip=SERVER_DNS_OR_IP; server_port=SERVER_PORT; QString settingsServerPath=QCoreApplication::applicationDirPath()+QStringLiteral("/server.conf"); if(QFile(settingsServerPath).exists()) { QSettings settingsServer(settingsServerPath,QSettings::IniFormat); if(settingsServer.contains(QStringLiteral("server_dns_or_ip")) && settingsServer.contains(QStringLiteral("server_port")) && settingsServer.contains(QStringLiteral("proxy_port"))) { bool ok,ok2; quint16 server_port_temp=settingsServer.value(QStringLiteral("server_port")).toString().toUShort(&ok); quint16 proxy_port_temp=settingsServer.value(QStringLiteral("proxy_port")).toString().toUShort(&ok2); if(settingsServer.value(QStringLiteral("server_dns_or_ip")).toString().contains(QRegularExpression(QStringLiteral("^([a-zA-Z0-9]{8}\\.onion|.*\\.i2p)$"))) && ok && ok2 && server_port_temp>0 && proxy_port_temp>0) { server_name=tr("Hidden server"); if(settingsServer.contains(QStringLiteral("server_name"))) server_name=settingsServer.value(QStringLiteral("server_name")).toString(); server_dns_or_ip=settingsServer.value(QStringLiteral("server_dns_or_ip")).toString(); proxy_dns_or_ip=QStringLiteral("localhost"); server_port=server_port_temp; proxy_port=proxy_port_temp; if(settingsServer.contains(QStringLiteral("proxy_dns_or_ip"))) proxy_dns_or_ip=settingsServer.value(QStringLiteral("proxy_dns_or_ip")).toString(); ui->label_login_register->setStyleSheet(ui->label_login_register->styleSheet()+QStringLiteral("text-decoration:line-through;")); ui->label_login_website->setStyleSheet(ui->label_login_website->styleSheet()+QStringLiteral("text-decoration:line-through;")); ui->label_login_register->setText(tr("Register")); ui->label_login_website->setText(tr("Web site")); } } } InternetUpdater::internetUpdater=new InternetUpdater(); connect(InternetUpdater::internetUpdater,&InternetUpdater::newUpdate,this,&MainWindow::newUpdate); RssNews::rssNews=new RssNews(); connect(RssNews::rssNews,&RssNews::rssEntryList,this,&MainWindow::rssEntryList); CatchChallenger::BaseWindow::baseWindow=new CatchChallenger::BaseWindow(); ui->stackedWidget->addWidget(CatchChallenger::BaseWindow::baseWindow); { serverLoginList.clear(); if(settings.contains(QStringLiteral("login"))) { const QStringList &loginList=settings.value("login").toStringList(); int index=0; while(index<loginList.size()) { if(settings.contains(loginList.at(index))) serverLoginList[loginList.at(index)]=settings.value(loginList.at(index)).toString(); else serverLoginList[loginList.at(index)]=QString(); index++; } if(!loginList.isEmpty()) ui->lineEditLogin->setText(loginList.first()); else ui->lineEditLogin->setText(QString()); } else ui->lineEditLogin->setText(QString()); if(serverLoginList.contains(ui->lineEditLogin->text())) ui->lineEditPass->setText(serverLoginList.value(ui->lineEditLogin->text())); else ui->lineEditPass->setText(QString()); ui->checkBoxRememberPassword->setChecked(!ui->lineEditPass->text().isEmpty()); } connect(&updateTheOkButtonTimer,&QTimer::timeout,this,&MainWindow::updateTheOkButton); stopFlood.setSingleShot(false); stopFlood.start(1500); updateTheOkButtonTimer.setSingleShot(false); updateTheOkButtonTimer.start(1000); numberForFlood=0; haveShowDisconnectionReason=false; ui->stackedWidget->addWidget(CatchChallenger::BaseWindow::baseWindow); connect(CatchChallenger::BaseWindow::baseWindow,&CatchChallenger::BaseWindow::newError,this,&MainWindow::newError,Qt::QueuedConnection); stateChanged(QAbstractSocket::UnconnectedState); setWindowTitle(QStringLiteral("CatchChallenger - ")+server_name); vlcPlayer=NULL; if(Audio::audio.vlcInstance!=NULL) { if(QFile(QCoreApplication::applicationDirPath()+QStringLiteral("/music/loading.ogg")).exists()) { // Create a new Media const QString &musicPath=QDir::toNativeSeparators(QCoreApplication::applicationDirPath()+QStringLiteral("/music/loading.ogg")); libvlc_media_t *vlcMedia = libvlc_media_new_path(Audio::audio.vlcInstance, musicPath.toUtf8().constData()); if(vlcMedia!=NULL) { // Create a new libvlc player vlcPlayer = libvlc_media_player_new_from_media(vlcMedia); if(vlcPlayer!=NULL) { // Get event manager for the player instance libvlc_event_manager_t *manager = libvlc_media_player_event_manager(vlcPlayer); // Attach the event handler to the media player error's events libvlc_event_attach(manager,libvlc_MediaPlayerEncounteredError,MainWindow::vlcevent,this); // Release the media libvlc_media_release(vlcMedia); libvlc_media_add_option(vlcMedia, "input-repeat=-1"); // And start playback libvlc_media_player_play(vlcPlayer); } else { qDebug() << "problem with vlc media player"; const char * string=libvlc_errmsg(); if(string!=NULL) qDebug() << string; } } else { qDebug() << "problem with vlc media" << musicPath; const char * string=libvlc_errmsg(); if(string!=NULL) qDebug() << string; } } } else { qDebug() << "no vlc instance"; const char * string=libvlc_errmsg(); if(string!=NULL) qDebug() << string; } connect(CatchChallenger::BaseWindow::baseWindow,&CatchChallenger::BaseWindow::gameIsLoaded,this,&MainWindow::gameIsLoaded); }
VlcError *VlcError::createNoClear() noexcept { if (libvlc_errmsg()) return new VlcError(); return nullptr; }
VlcError::VlcError() noexcept : std::exception() { reason = strdup(libvlc_errmsg()); }
VlcVideoWidget::VlcVideoWidget(const QList<QByteArray> &args) : QFrame(0), vlcInstance_(0), vlcPlayer_(0), vlcMedia_(0), hasVideoOut_(false) { /// Convert the arguments into a proper form QVarLengthArray<const char*, 64> vlcArgs(args.size()); for (int i = 0; i < args.size(); ++i) vlcArgs[i] = args.at(i).constData(); // Create new libvlc instance vlcInstance_ = libvlc_new(vlcArgs.size(), vlcArgs.constData()); // Check if instance is running if (!vlcInstance_) { std::string errorMsg; if (libvlc_errmsg()) errorMsg = std::string("VlcVideoWidget: Failed to create VLC instance: ") + libvlc_errmsg(); else errorMsg = "VlcVideoWidget: Failed to create VLC instance"; LogError(errorMsg); return; } libvlc_set_user_agent(vlcInstance_, "realXtend Tundra Media Player 1.0", "Tundra/1.0"); /// Create the vlc player and set event callbacks vlcPlayer_ = libvlc_media_player_new(vlcInstance_); libvlc_event_manager_t *em = libvlc_media_player_event_manager(vlcPlayer_); libvlc_event_attach(em, libvlc_MediaPlayerMediaChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerOpening, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerBuffering, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPlaying, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPaused, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerStopped, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerEncounteredError, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerTimeChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPositionChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerSeekableChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerPausableChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerTitleChanged, &VlcEventHandler, this); libvlc_event_attach(em, libvlc_MediaPlayerLengthChanged, &VlcEventHandler, this); /// register callbacks so that we can implement custom drawing of video frames libvlc_video_set_callbacks( vlcPlayer_, &CallBackLock, &CallBackUnlock, &CallBackDisplay, this); // Initialize rendering //idleLogo_ = QImage(":/images/vlc-cone.png"); idleLogo_ = QImage(":/images/play-video.png"); idleLogo_ = idleLogo_.convertToFormat(QImage::Format_ARGB32); //audioLogo_ = QImage(":/images/audio.png"); audioLogo_ = QImage(":/images/play-audio.png"); audioLogo_ = audioLogo_.convertToFormat(QImage::Format_ARGB32); pausePixmap_ = QPixmap(":/images/pause-big.png"); bufferingPixmap_ = QPixmap(":/images/buffering.png"); QSize startSize(600, 360); renderPixmap_ = QImage(startSize.width(), startSize.height(), QImage::Format_RGB32); libvlc_video_set_format(vlcPlayer_, "RV32", renderPixmap_.width(), renderPixmap_.height(), renderPixmap_.bytesPerLine()); // Initialize widget properties setMinimumSize(startSize); resize(startSize); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setStyleSheet("background-color: black;"); // Connect and start status poller connect(&pollTimer_, SIGNAL(timeout()), SLOT(StatusPoller())); pollTimer_.start(10); }
int LibvlcCamera::PrimeCapture() { Info("Priming capture from %s", mPath.c_str()); mLibvlcInstance = libvlc_new (0, NULL); if(mLibvlcInstance == NULL) Fatal("Unable to create libvlc instance due to: %s", libvlc_errmsg()); mLibvlcMedia = libvlc_media_new_location(mLibvlcInstance, mPath.c_str()); if(mLibvlcMedia == NULL) Fatal("Unable to open input %s due to: %s", mPath.c_str(), libvlc_errmsg()); mLibvlcMediaPlayer = libvlc_media_player_new_from_media(mLibvlcMedia); if(mLibvlcMediaPlayer == NULL) Fatal("Unable to create player for %s due to: %s", mPath.c_str(), libvlc_errmsg()); libvlc_video_set_format(mLibvlcMediaPlayer, mTargetChroma.c_str(), width, height, width * mBpp); libvlc_video_set_callbacks(mLibvlcMediaPlayer, &LibvlcLockBuffer, &LibvlcUnlockBuffer, NULL, &mLibvlcData); mLibvlcData.bufferSize = width * height * mBpp; // Libvlc wants 32 byte alignment for images (should in theory do this for all image lines) mLibvlcData.buffer = (uint8_t*)zm_mallocaligned(32, mLibvlcData.bufferSize); mLibvlcData.prevBuffer = (uint8_t*)zm_mallocaligned(32, mLibvlcData.bufferSize); mLibvlcData.newImage.setValueImmediate(false); libvlc_media_player_play(mLibvlcMediaPlayer); return(0); }