VlcTagger::VlcTagger() { #if LIBVLC_VERSION_INT < 0x110 _pException = new libvlc_exception_t; libvlc_exception_init(_pException); #endif int argc = 1; const char* argv[1] = {"ommtagger"}; #if LIBVLC_VERSION_INT < 0x110 _pVlcInstance = libvlc_new(argc, argv, _pException); #else _pVlcInstance = libvlc_new(argc, argv); #endif }
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; }
int libvlc_load(const char *path) { int nameId = lastElem; if (g_file_test(path, G_FILE_TEST_EXISTS) == 0) { DPRINT_ERR("%s doesn't exist", path); goto error; } soundInst[nameId] = libvlc_new(0, NULL); soundMedia[nameId] = libvlc_media_new_path(soundInst[nameId], path); soundPlay[nameId] = libvlc_media_player_new_from_media(soundMedia[nameId]); if (soundInst[nameId] == NULL || soundMedia[nameId] == NULL || soundPlay[nameId] == NULL) { DPRINT_ERR("fail to load %s", path); goto error; } /* if (loop != 0) { */ /* libvlc_media_add_option(media, "input-repeat=-1"); */ /* } */ is_used[nameId] = 1; ++lastElem; return nameId; error: libvlc_stop(nameId); return -1; }
VlcInstance::VlcInstance(const QStringList &args, QObject *parent) : QObject(parent), _vlcInstance(0), _status(false) { // Convert arguments to required format #if defined(Q_OS_WIN32) // Will be removed on Windows if confirmed working char **argv = (char **)malloc(sizeof(char **) * args.count()); for (int i = 0; i < args.count(); ++i) argv[i] = (char *)qstrdup(args.at(i).toUtf8().data()); #else char *argv[args.count()]; for (int i = 0; i < args.count(); ++i) argv[i] = (char *)qstrdup(args.at(i).toUtf8().data()); #endif // Create new libvlc instance _vlcInstance = libvlc_new(args.count(), argv); qRegisterMetaType<Vlc::Meta>("Vlc::Meta"); qRegisterMetaType<Vlc::State>("Vlc::State"); VlcError::showErrmsg(); // Check if instance is running if(_vlcInstance) { _status = true; qDebug() << "VLC-Qt" << libVersion() << "initialised"; qDebug() << "Using libvlc version:" << version(); } else { qCritical() << "VLC-Qt Error: libvlc failed to load!"; } }
VLCWrapper::VLCWrapper (QObject *parent) : QObject (parent) , CurrentItem_ (-1) , IsPlayedFromQueue_ (false) { Instance_ = libvlc_instance_ptr (libvlc_new (sizeof (vlc_args) / sizeof (vlc_args[0]), vlc_args), libvlc_release); LPlayer_ = libvlc_media_list_player_ptr (libvlc_media_list_player_new (Instance_.get ()), libvlc_media_list_player_release); Player_ = libvlc_media_player_ptr (libvlc_media_player_new (Instance_.get ()), libvlc_media_player_release); List_ = libvlc_media_list_ptr (libvlc_media_list_new (Instance_.get ()), libvlc_media_list_release); libvlc_media_list_player_set_media_player (LPlayer_.get (), Player_.get ()); libvlc_media_list_player_set_media_list (LPlayer_.get (), List_.get ()); auto listEventManager = libvlc_media_list_player_event_manager (LPlayer_.get ()); libvlc_event_attach (listEventManager, libvlc_MediaListPlayerNextItemSet, ListEventCallback, this); auto playerEventManager = libvlc_media_player_event_manager (Player_.get ()); libvlc_event_attach (playerEventManager, libvlc_MediaPlayerPlaying, ListEventCallback, this); libvlc_event_attach (playerEventManager, libvlc_MediaPlayerStopped, ListEventCallback, this); libvlc_event_attach (playerEventManager, libvlc_MediaPlayerPaused, ListEventCallback, this); libvlc_event_attach (playerEventManager, libvlc_MediaPlayerEndReached, ListEventCallback, this); }
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"; }
CVlcRtspSDK::CVlcRtspSDK() { screenNo=-1; CapturePath=""; hWnd=NULL; m_nBitCount = 24; m_pLibvlc_Inst = NULL; m_pLibvlc_Mp = NULL; m_pLibvlc_m=NULL; Width=0; Height=0; RGBdata=(unsigned char*)calloc(VIDEO_WIDTH*VIDEO_HEIGHT*3,sizeof(unsigned char)); YUVdata=(unsigned char*)calloc(VIDEO_WIDTH*VIDEO_HEIGHT*3,sizeof(unsigned char)); // 创建备份缓存 //m_DC_Cache.CreateCache(Width, Height, m_nBitCount); InitializeCriticalSection(&lockflag); m_pLibvlc_Inst = libvlc_new(0,NULL); }
CPlayer::CPlayer() : mVideoWidget(0), mMediaPlayer(NULL), mPlaybackStartedCallback(NULL) { LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__); PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties")); mMutex = new CRWMutex(); const char * const argv[] = { "--no-video-title-show", "-vvv", "--packetizer-mpegvideo-sync-iframe" }; mInst = libvlc_new(sizeof(argv) / sizeof(*argv), argv); assert(mInst); mVolume = VOLUME_INIT; hasPlayerInstance = false; //for process show and hide in qt-threads if (connect(this, SIGNAL(playerPlaySig(QString, QString)), this, SLOT(playerPlaySlot(QString, QString)), Qt::QueuedConnection) == false) { LOG4CPLUS_INFO(msLogger, "qt - connect play failed!"); killProcess(1); } if (connect(this, SIGNAL(playerStopSig()), this, SLOT(playerStopSlot()), Qt::QueuedConnection) == false) { LOG4CPLUS_INFO(msLogger, "qt - connect stop failed!"); killProcess(1); } }
PlayerEngine_vlc::PlayerEngine_vlc(){ vlcPlayer = NULL; /* Initialize libVLC */ vlcInstance = libvlc_new(0, NULL); /* Complain in case of broken installation */ if (vlcInstance == NULL) { // Report that libVLC could not be initialized message = "Error : libVLC failed to Init"; exit(1); } //Shows the window and returns when it is closed. // now create the signal ID // Here is where we call up the Display window for viewwing the full Video // I will USE SDL for my final Video Out put. //libvlc_video_set_callbacks(vlcPlayer, lock, unlock, display, &ctx); //libvlc_video_set_format(vlcPlayer, "RV16", VIDEOWIDTH, VIDEOHEIGHT, VIDEOWIDTH*2); }
VlcInstance::VlcInstance(const QStringList &args, QObject *parent) : QObject(parent), _vlcInstance(0) { #if defined(Q_OS_WIN32) char **argv = (char **)malloc(sizeof(char **) * args.count()); for (int i = 0; i < args.count(); ++i) argv[i] = (char *)qstrdup(args.at(i).toUtf8().data()); #else char *argv[args.count()]; for (int i = 0; i < args.count(); ++i) argv[i] = (char *)qstrdup(args.at(i).toUtf8().data()); #endif _vlcInstance = libvlc_new(args.count(), argv); qRegisterMetaType<Vlc::Meta>("Vlc::Meta"); qRegisterMetaType<Vlc::State>("Vlc::State"); VlcError::errmsg(); if(!_vlcInstance) { qDebug() << "vlc failed to load!"; abort(); } }
SMActionVideoVLC::SMActionVideoVLC(QWidget *parent): SMAction(parent) { poller = new QTimer(0); connect(poller, SIGNAL(timeout()), SLOT(slotTimeout())); //preparation of the vlc command const char * const vlc_args[] = { "--verbose=2", //be much more verbose then normal for debugging purpose }; _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); // Create a media player playing environement _mp = libvlc_media_player_new (_vlcinstance); _m = NULL; setRepeat(0); setVolume(1.0); getContextMenu()->addSeparator(); QAction* setRepeatAction = getContextMenu()->addAction("set repeat"); connect(setRepeatAction, SIGNAL(triggered(bool)), SLOT(slotSetRepeat())); QAction* setVolumeAction = getContextMenu()->addAction("set volume"); connect(setVolumeAction, SIGNAL(triggered(bool)), SLOT(slotSetVolume())); }
MediaPlayer::MediaPlayer(QObject *parent) : QObject(parent) { seeknext = false; vlcInstance = libvlc_new(0,NULL); vlcMediaPlayer = 0; vlcMedia = 0; }
static inline libvlc_instance_t * create_vlc_instance(void) { gchar **vlc_argv; gint vlc_argc = 0; libvlc_instance_t *ret; vlc_argv = g_malloc_n(2, sizeof(vlc_argv[0])); vlc_argv[vlc_argc++] = g_strdup(g_get_prgname()); #if LIBVLC_VERSION_INT < LIBVLC_VERSION(2,0,0,0) if (g_getenv("VLC_PLUGIN_PATH") != NULL) { vlc_argv = g_realloc_n(vlc_argv, vlc_argc + 2 + 1, sizeof(vlc_argv[0])); vlc_argv[vlc_argc++] = g_strdup("--plugin-path"); vlc_argv[vlc_argc++] = g_strdup(g_getenv("VLC_PLUGIN_PATH")); } #endif vlc_argv[vlc_argc] = NULL; ret = libvlc_new((int)vlc_argc, (const char *const *)vlc_argv); g_strfreev(vlc_argv); return ret; }
player::player() { inst = libvlc_new(0, NULL); //constructor dataObject ob; ob.object = "file_selector_open"; ob.msg = "/home/rukshan/Oblivion.mp4"; // Notify(ob); }
void CAVPlayer::Init() { if (! m_pVLC_Inst) { m_pVLC_Inst = libvlc_new(0, NULL); } }
void NPlaybackEngineVlc::init() { int argc; const char **argv; NCore::cArgs(&argc, &argv); QVector<const char *> argVector; for (int i = 0; i < argc; ++i) argVector << argv[i]; argVector << "-I" << "dummy" << "--ignore-config" << "--no-xlib"; m_vlcInstance = libvlc_new(argVector.size(), &argVector[0]); m_mediaPlayer = libvlc_media_player_new(m_vlcInstance); m_eventManager = libvlc_media_player_event_manager(m_mediaPlayer); libvlc_event_attach(m_eventManager, libvlc_MediaPlayerEndReached, _eventHandler, this); m_oldVolume = -1; m_oldPosition = -1; m_oldState = N::PlaybackStopped; m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(checkStatus())); m_timer->start(100); m_init = true; }
VLC::VLC() { libvlcInstance = libvlc_new(0, NULL); vector<string> outputNames; vector<deviceoutput> outputs = getDeviceOutputs(outputNames); tryConfig(outputs); while (phoneDevice.empty() || speakerDevice.empty() || phoneOutput.empty() || speakerOutput.empty()) { if (!config->nextAudioDevices()) { break; } gui->printlevel(LDEBUG, "\nNo output combination found, retrying...\n"); tryConfig(outputs); } if (phoneDevice.empty() || phoneOutput.empty()) { gui->printlevel(LINFO, "\n"); gui->printlevel(LWARNING, "Phone device not found, which to use?\n"); int i = gui->selection(outputNames); phoneOutput = outputs[i].output; phoneDevice = outputs[i].device; gui->printlevel(LINFO, "\n"); } if (speakerDevice.empty() || speakerOutput.empty()) { gui->printlevel(LINFO, "\n"); gui->printlevel(LWARNING, "Speaker device not found, which to use?\n"); int i = gui->selection(outputNames); speakerOutput = outputs[i].output; speakerDevice = outputs[i].device; gui->printlevel(LINFO, "\n"); } }
void SoundPlay::inputFile(char* input_name) { libvlc_instance_t *inst; libvlc_media_player_t *mp; libvlc_media_t *m; // load the vlc engine inst = libvlc_new(0, NULL); // create a new item m = libvlc_media_new_path(inst, input_name); // create a media play playing environment mp = libvlc_media_player_new_from_media(m); // no need to keep the media now libvlc_media_release(m); // play the media_player libvlc_media_player_play(mp); sleep(2); // stop playing libvlc_media_player_stop(mp); // free the media_player libvlc_media_player_release(mp); libvlc_release(inst); }
CameraWnd::CameraWnd() : QWidget() { setMinimumSize( 160, 120 ); //preparation of the vlc command const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--extraintf=logger", //log anything "--verbose=2", //be much more verbose then normal for debugging purpose "--plugin-path=./plugins/" }; #ifdef Q_WS_X11 _videoWidget=new QX11EmbedContainer(this); #else _videoWidget=new QFrame(this); #endif // [20101215 JG] If KDE is used like unique desktop environment, only use _videoWidget=new QFrame(this); _volumeSlider=new QSlider(Qt::Horizontal,this); _volumeSlider->setMaximum(100); //the volume is between 0 and 100 _volumeSlider->setToolTip("Audio slider"); _volumeSlider->setVisible( false ); // Note: if you use streaming, there is no ability to use the position slider _positionSlider=new QSlider(Qt::Horizontal,this); _positionSlider->setMaximum(POSITION_RESOLUTION); _positionSlider->setVisible( false ); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(_videoWidget); layout->addWidget(_positionSlider); layout->addWidget(_volumeSlider); setLayout(layout); _isPlaying=false; poller=new QTimer(this); //Initialize an instance of vlc //a structure for the exception is neede for this initalization //libvlc_exception_init(&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //create a new libvlc instance _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //tricky calculation of the char space used //_vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args,&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. // Create a media player playing environement _mp = libvlc_media_player_new (_vlcinstance); //_mp = libvlc_media_player_new (_vlcinstance, &_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //raise (&_vlcexcep); // [20101215 JG] Used for versions prior to VLC 1.2.0. //connect the two sliders to the corresponding slots (uses Qt's signal / slots technology) connect(poller, SIGNAL(timeout()), this, SLOT(updateInterface())); connect(_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int))); connect(_volumeSlider, SIGNAL(sliderMoved(int)), this, SLOT(changeVolume(int))); poller->start(100); //start timer to trigger every 100 ms the updateInterface slot }
VlcVideoPlayer::VlcVideoPlayer(wxWindow* win, const VideoID& id, wxPoint pt, wxSize size) : wxPanel(win, wxID_ANY, pt, size), videoID_(id), firstPlay_(1) { SetBackgroundColour(axColor(0, 0, 0)); _DEBUG_ nb_time_callback = 0; // Create new VLC instance. char const* vlcOptions[] = {"--no-video-title-show"}; //Hide filename. vlcInstance = NULL; vlcPlayer = NULL; // Create VLC instance vlcInstance = libvlc_new(1, vlcOptions); if( vlcInstance ) { vlcPlayer = libvlc_media_player_new(vlcInstance); // Create VLC player if( vlcPlayer ) { // Create VLC EventManager vlcEventManager = libvlc_media_player_event_manager(vlcPlayer); if( !vlcEventManager ) { _DEBUG_ DSTREAM << "Can't create VLC Event Manager" << endl; wxMessageDialog (this, "Can't create VLC Event Manager"); } } else // vlcPlayer { _DEBUG_ DSTREAM << "Can't create player from vlcMedia" << endl; wxMessageDialog (this, "Can't create player from vlcMedia"); } } else // vlcInstance. { _DEBUG_ DSTREAM << "Can't Open VLC instance" << endl; wxMessageDialog (this, "Can't Open VLC instance"); } // libVLC events and callback if( vlcInstance && vlcPlayer && vlcEventManager ) { libvlc_event_attach(vlcEventManager, libvlc_MediaPlayerPositionChanged, VlcVideoPlayer::vlcPositionChanged, this); libvlc_event_attach(vlcEventManager, libvlc_MediaPlayerTimeChanged, VlcVideoPlayer::vlcTimeChanged, this); } }
int main(int argc, char* argv[]) { const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--plugin-path=/set/your/path/to/libvlc/module/if/you/are/on/windows/or/macosx" }; libvlc_exception_t ex; libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; libvlc_exception_init (&ex); /* init vlc modules, should be done only once */ inst = libvlc_new (sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args, &ex); raise (&ex); /* Create a new item */ m = libvlc_media_new (inst, "http://mycool.movie.com/test.mov", &ex); raise (&ex); /* XXX: demo art and meta information fetching */ /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m, &ex); raise (&ex); /* No need to keep the media now */ libvlc_media_release (m); #if 0 /* This is a non working code that show how to hooks into a window, * if we have a window around */ libvlc_drawable_t drawable = xdrawable; /* or on windows */ libvlc_drawable_t drawable = hwnd; libvlc_media_player_set_drawable (mp, drawable, &ex); raise (&ex); #endif /* play the media_player */ libvlc_media_player_play (mp, &ex); raise (&ex); sleep (10); /* Let it play a bit */ /* Stop playing */ #warning There is known deadlock bug here. Please update to LibVLC 1.1! libvlc_media_player_stop (mp, &ex); /* Free the media_player */ libvlc_media_player_release (mp); libvlc_release (inst); raise (&ex); return 0; }
int main (int argc, char *argv[]) { #ifdef _WIN32 SetErrorMode(SEM_FAILCRITICALERRORS); #endif #ifdef HAVE_GETOPT_H static const struct option opts[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { NULL, no_argument, NULL, '\0'} }; int c; while ((c = getopt_long (argc, argv, "hV", opts, NULL)) != -1) switch (c) { case 'h': usage (argv[0]); return 0; case 'V': version (); return 0; default: usage (argv[0]); return 1; } #else int optind = 1; #endif for (int i = optind; i < argc; i++) { const char *path = argv[i]; if (setenv ("VLC_PLUGIN_PATH", path, 1)) abort (); const char *vlc_argv[4]; int vlc_argc = 0; vlc_argv[vlc_argc++] = "--quiet"; vlc_argv[vlc_argc++] = "--reset-plugins-cache"; vlc_argv[vlc_argc++] = "--"; /* end of options */ vlc_argv[vlc_argc] = NULL; libvlc_instance_t *vlc = libvlc_new (vlc_argc, vlc_argv); if (vlc != NULL) libvlc_release (vlc); if (vlc == NULL) fprintf (stderr, "No plugins in %s\n", path); if (vlc == NULL) return 1; } return 0; }
int main(int argc, const char **argv) { libvlc_instance_t *libvlc = libvlc_new(argc - 1, argv + 1); if (!libvlc) return 1; size_t modules = 0; module_t **mod_list; mod_list = module_list_get(&modules); if (!mod_list || modules == 0) { libvlc_release(libvlc); return 2; } module_t **max = &mod_list[modules]; puts("#compdef vlc cvlc rvlc svlc mvlc qvlc nvlc\n" "#This file is autogenerated by zsh.cpp\n" "typeset -A opt_args\n" "local context state line ret=1\n" "local modules\n"); printf("vlc_modules=\""); for (module_t **mod = mod_list; mod < max; mod++) PrintModule(*mod); puts("\"\n"); puts("_arguments -S -s \\"); for (module_t **mod = mod_list; mod < max; mod++) ParseModule(*mod); puts(" \"(--module)-p[print help on module]:print help on module:($vlc_modules)\"\\"); puts(" \"(-p)--module[print help on module]:print help on module:($vlc_modules)\"\\"); puts(" \"(--help)-h[print help]\"\\"); puts(" \"(-h)--help[print help]\"\\"); puts(" \"(--longhelp)-H[print detailed help]\"\\"); puts(" \"(-H)--longhelp[print detailed help]\"\\"); puts(" \"(--list)-l[print a list of available modules]\"\\"); puts(" \"(-l)--list[print a list of available modules]\"\\"); puts(" \"--reset-config[reset the current config to the default values]\"\\"); puts(" \"--config[use alternate config file]\"\\"); puts(" \"--reset-plugins-cache[resets the current plugins cache]\"\\"); puts(" \"--version[print version information]\"\\"); puts(" \"*:Playlist item:->mrl\" && ret=0\n"); puts("case $state in"); puts(" mrl)"); puts(" _alternative 'files:file:_files' 'urls:URL:_urls' && ret=0"); puts(" ;;"); puts("esac\n"); puts("return ret"); module_list_free(mod_list); libvlc_release(libvlc); return 0; }
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; }
void qtVlc::init(const char* url, const char* TmpFile) { if(TmpFile) { char result[1000]; // array to hold the result. strcpy(result,"--sout=file/ps:"); strcat(result,TmpFile); // append string two to the result. qDebug() << QString(TmpFile); const char * const vlc_args[] = { "-I", "dummy", // Don't use any interface "--ignore-config", // Don't use VLC's config "--extraintf=logger", // Log anything "--verbose=2", // Be much more verbose then normal for debugging purpose result // Stream to file }; // We launch VLC inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); } else { inst = libvlc_new(0, NULL); } // Check if instance is running if(inst) { qDebug() << "libvlc-qt initialised by " << QString(url); } else { qDebug() << "libvlc-qt Error: libvlc failed to load!"; exit(-100); } /* Create a new item */ m = libvlc_media_new_path (inst, url); /* Create a media player playing environement */ mp = libvlc_media_player_new_from_media (m); /* No need to keep the media now */ libvlc_media_release (m); connectToPlayerVLCEvents(); mUrl = QString(url); }
int main(void) { ssize_t val; char buf[16]; bool b; test_init(); vlc = libvlc_new(0, NULL); assert(vlc != NULL); parent = VLC_OBJECT(vlc->p_libvlc_int); s = vlc_stream_fifo_New(parent); assert(s != NULL); val = stream_Control(s, STREAM_CAN_SEEK, &b); assert(val == VLC_SUCCESS && !b); val = stream_GetSize(s, &(uint64_t){ 0 }); assert(val < 0); val = stream_Control(s, STREAM_GET_PTS_DELAY, &(int64_t){ 0 }); assert(val == VLC_SUCCESS); stream_Delete(s); vlc_stream_fifo_Close(s); s = vlc_stream_fifo_New(parent); assert(s != NULL); val = vlc_stream_fifo_Write(s, "123", 3); vlc_stream_fifo_Close(s); val = stream_Read(s, buf, sizeof (buf)); assert(val == 3); assert(memcmp(buf, "123", 3) == 0); val = stream_Read(s, buf, sizeof (buf)); assert(val == 0); stream_Delete(s); s = vlc_stream_fifo_New(parent); assert(s != NULL); val = vlc_stream_fifo_Write(s, "Hello ", 6); assert(val == 6); val = vlc_stream_fifo_Write(s, "world!\n", 7); assert(val == 7); val = vlc_stream_fifo_Write(s, "blahblah", 8); assert(val == 8); val = stream_Read(s, buf, 13); assert(val == 13); assert(memcmp(buf, "Hello world!\n", 13) == 0); stream_Delete(s); val = vlc_stream_fifo_Write(s, "cough cough", 11); assert(val == -1 && errno == EPIPE); vlc_stream_fifo_Close(s); libvlc_release(vlc); return 0; }
VLCImageStream( const char* const* vlc_argv=0 ) : osg::ImageStream(), _vlcMedia(0) { if ( !vlc_argv ) { const char* vlc_args[] = { "--ignore-config", // don't use VLC's config "--data-path="VLC_PLUGIN_PATH }; _vlc = libvlc_new( sizeof(vlc_args)/sizeof(vlc_args[0]), vlc_args ); } else _vlc = libvlc_new( sizeof(vlc_argv)/sizeof(vlc_argv[0]), vlc_argv ); _vlcPlayer = libvlc_media_player_new( _vlc ); libvlc_event_attach( libvlc_media_player_event_manager(_vlcPlayer), libvlc_MediaPlayerStopped, &VLCImageStream::videoEndFunc, this ); _status = INVALID; }
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); }
VideoStream::VideoStream(const std::string& uri, irr::video::IVideoDriver* const videoDriver, IrrIMGUI::IIMGUIHandle* const gui) : gui_{gui} { videoTexture_ = videoDriver->createImage(irr::video::ECF_A8R8G8B8, irr::core::dimension2du(1280, 720)); guiVideoTexture_ = gui_->createTexture(videoTexture_); char const *vlc_argv[] = { // "-I", "dummy", // Don't use any interface //"--ignore-config", // Don't use VLC's config "--no-audio", /* skip any audio track */ "--no-xlib", /* tell VLC to not use Xlib */ "--network-caching=4000", }; int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); vlcInstance_ = libvlc_new(vlc_argc, vlc_argv); auto vlcMedia = libvlc_media_new_location(vlcInstance_, "http://iphone-streaming.ustream.tv/uhls/17074538/streams/live/iphone/playlist.m3u8"); vlcMediaPlayer_ = libvlc_media_player_new_from_media(vlcMedia); libvlc_media_release(vlcMedia); libvlc_video_set_callbacks(vlcMediaPlayer_, VideoStream::preRenderCallback, VideoStream::postRenderCallback, VideoStream::displayCallback, this); libvlc_video_set_format(vlcMediaPlayer_, "RV32", 1280, 720, videoTexture_->getPitch()); libvlc_media_player_play(vlcMediaPlayer_); }
void VLCNative::startTranscoding() { DEBUG("VLCNative::startTranscoding called"); // init vlc vlc = libvlc_new(this->argc, this->argv); libvlc_set_user_agent(vlc, USER_AGENT, HTTP_USER_AGENT); // open log libvlc_set_log_verbosity(vlc, 3); log = libvlc_log_open(vlc); // register for events eventManager = libvlc_vlm_get_event_manager(vlc); libvlc_event_attach(eventManager, libvlc_VlmMediaInstanceStarted, event_handler_started, (void*)this); libvlc_event_attach(eventManager, libvlc_VlmMediaInstanceStatusPlaying, event_handler_status_playing, (void*)this); libvlc_event_attach(eventManager, libvlc_VlmMediaInstanceStatusError, event_handler_status_error, (void*)this); libvlc_event_attach(eventManager, libvlc_VlmMediaInstanceStatusEnd, event_handler_status_end, (void*)this); // start broadcast libvlc_vlm_add_broadcast(vlc, medianame, input, sout, 0, NULL, true, false); this->state = CREATED; DEBUG("VLCNative: created media"); // and start playing libvlc_vlm_play_media(vlc, medianame); DEBUG("VLCNative: started media") handleMessages(); }