// Initialization bool MediaPlayer::initialize( const std::string &url ) { LDEBUG( "vlc", "Initialize: url=%s", url.c_str() ); // Create media from url libvlc_media_t *m=libvlc_media_new_path( instance(), url.c_str() ); if (!m) { LERROR( "vlc", "Cannot initialize new media from url: url=%s", url.c_str() ); return false; } // Add common parameters libvlc_media_add_option( m, "verbose=1000" ); libvlc_media_add_option( m, "no-osd" ); libvlc_media_add_option( m, "ffmpeg-hw" ); // Create a media player playing environement _mp = libvlc_media_player_new_from_media(m); if (!_mp) { libvlc_media_release (m); LERROR( "vlc", "Cannot create media player from url: url=%s", url.c_str() ); return false; } // No need to keep the media now libvlc_media_release (m); { // Set WindowID VideoDescription desc; if (getVideoDescription( desc )) { #ifndef _WIN32 libvlc_media_player_set_xwindow( _mp, desc.winID ); #else libvlc_media_player_set_hwnd( _mp, desc ); #endif } } { // Attach to stop asyn events libvlc_event_manager_t *mgr=libvlc_media_player_event_manager( _mp ); libvlc_event_attach( mgr, libvlc_MediaPlayerEndReached, vlcCallback, this ); } return true; }
void VLCMainwindow::openFile() { /* Just the basic file-select box */ QString fileOpen = QFileDialog::getOpenFileName(this,tr("Load a file"), "~"); fileOpen.replace("/", "\\"); /* Stop if something is playing */ if( vlcPlayer && libvlc_media_player_is_playing(vlcPlayer) ) stop(); /* New Media */ libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcObject,qtu(fileOpen)); if( !vlcMedia ) return; vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); libvlc_media_release(vlcMedia); /* Integrate the video in the interface */ #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId()); #endif //int windid = videoWidget->winId(); //libvlc_media_player_set_xwindow (vlcPlayer, windid ); /* And play */ libvlc_media_player_play (vlcPlayer); //Set vars and text correctly playBut->setText("Pause"); }
/************************************************************************** * set_current_playing_item (private) * * Playlist lock should be held **************************************************************************/ static void set_current_playing_item(libvlc_media_list_player_t * p_mlp, libvlc_media_list_path_t path) { assert_locked(p_mlp); /* First, save the new path that we are going to play */ if (p_mlp->current_playing_item_path != path) { free(p_mlp->current_playing_item_path); p_mlp->current_playing_item_path = path; } if (!path) return; libvlc_media_t * p_md; p_md = libvlc_media_list_item_at_path(p_mlp->p_mlist, path); if (!p_md) return; /* Make sure media_player_reached_end() won't get called */ uninstall_media_player_observer(p_mlp); /* Create a new media_player if there is none */ if (!p_mlp->p_mi) p_mlp->p_mi = libvlc_media_player_new_from_media(p_md, NULL); libvlc_media_player_set_media(p_mlp->p_mi, p_md, NULL); install_media_player_observer(p_mlp); libvlc_media_release(p_md); /* for libvlc_media_list_item_at_index */ }
bool QtVLCWidget::playMedia(const char* url) { m_media = libvlc_media_new_location (m_vlc, url); if (m_media == nullptr) { fprintf(stderr, "unable to create media %s", url); return false; } m_mp = libvlc_media_player_new_from_media (m_media); if (m_mp == nullptr) { fprintf(stderr, "unable to create media player"); libvlc_media_release(m_media); return false; } // Define the opengl rendering callbacks libvlc_video_set_output_callbacks(m_mp, libvlc_video_engine_opengl, VLCVideo::setup, VLCVideo::cleanup, VLCVideo::resizeRenderTextures, VLCVideo::swap, VLCVideo::make_current, VLCVideo::get_proc_address, mVLC); // Play the video libvlc_media_player_play (m_mp); 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; }
void Mwindow::openFile() { /* The basic file-select box */ QString fileOpen = QFileDialog::getOpenFileName(this, tr("Load a file"), "~"); /* Stop if something is playing */ if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer)) stop(); /* Create a new Media */ libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcInstance, qtu(fileOpen)); if (!vlcMedia) return; /* Create a new libvlc player */ vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); /* Release the media */ libvlc_media_release(vlcMedia); /* Integrate the video in the interface */ #if defined(Q_OS_MAC) libvlc_media_player_set_nsobject(vlcPlayer, (void *)videoWidget->winId()); #elif defined(Q_OS_UNIX) libvlc_media_player_set_xwindow(vlcPlayer, videoWidget->winId()); #elif defined(Q_OS_WIN) libvlc_media_player_set_hwnd(vlcPlayer, videoWidget->winId()); #endif /* And start playback */ libvlc_media_player_play (vlcPlayer); /* Update playback button */ playBut->setText("Pause"); }
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); }
// retorna true si es un video, false en caso contrario // Si es un video ademas rellena los parametros Tiempo, nAncho y nAlto const bool InformacionArchivoEx::_AnalisisVLC(const TCHAR *Path, UINT64 &Tiempo, UINT &nAncho, UINT &nAlto, libvlc_instance_t *Instancia) { char Destino[2049]; size_t TamnTexto = wcslen(Path); int TamRes = WideCharToMultiByte(CP_UTF8, NULL, Path, TamnTexto, Destino, 2048, NULL, NULL); Destino[TamRes] = 0; libvlc_media_t *Media = NULL; libvlc_media_player_t *nMediaPlayer = NULL; Media = libvlc_media_new_path(Instancia, Destino); libvlc_media_parse(Media); libvlc_media_add_option(Media, "sout=#description:dummy"); nMediaPlayer = libvlc_media_player_new_from_media(Media); libvlc_state_t Estado = libvlc_Opening; libvlc_media_player_play(nMediaPlayer); //posible deadlock // Esperamos hasta que empieze el play while (Estado != libvlc_Playing && Estado != libvlc_Ended) { Estado = libvlc_media_player_get_state(nMediaPlayer); Sleep(100); if (Estado == libvlc_Error) { // Hay un error en la libvlc, salimos Sleep(300); // Nos aseguramos de que el log se escriba libvlc_media_player_stop(nMediaPlayer); libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); Tiempo = 0; nAncho = 0; nAlto = 0; return false; } } // Miramos los streams disponibles y buscamos el de video libvlc_media_track_info_t *TI = NULL; int z = libvlc_media_get_tracks_info(Media, &TI); for (int n = 0; n < z; n++) { if (TI->i_type == libvlc_track_video) { libvlc_media_player_stop(nMediaPlayer); Tiempo = 0; //libvlc_media_player_get_length(nMediaPlayer); // NO DA BIEN EL TIEMPO.............. nAncho = TI->u.video.i_width; nAlto = TI->u.video.i_height; libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); return true; } TI ++; } libvlc_media_release(Media); libvlc_media_player_release(nMediaPlayer); // No hay streams de video retornamos false Tiempo = 0; nAncho = 0; nAlto = 0; return false; }
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 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; }
static bool media_file_dj_play(const char *filename,int * panel, float start,uint8_t end) { hwnd_handle = panel; media_inst = libvlc_new(0,NULL); media_handle = libvlc_media_new_path(media_inst,filename); mediaplay = libvlc_media_player_new_from_media(media_handle); }
int main(int argc, const char **argv) { const char *in; char *out, *out_with_ext; int width; pthread_condattr_t attr; libvlc_instance_t *libvlc; libvlc_media_player_t *mp; libvlc_media_t *m; /* mandatory to support UTF-8 filenames (provided the locale is well set)*/ setlocale(LC_ALL, ""); cmdline(argc, argv, &in, &out, &out_with_ext, &width); pthread_condattr_init(&attr); pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); pthread_cond_init(&wait, &attr); pthread_condattr_destroy(&attr); /* starts vlc */ libvlc = create_libvlc(); assert(libvlc); m = libvlc_media_new_path(libvlc, in); assert(m); mp = libvlc_media_player_new_from_media(m); assert(mp); libvlc_media_player_play(mp); /* takes snapshot */ set_position(mp); snapshot(mp, width, out_with_ext); libvlc_media_player_stop(mp); /* clean up */ if (out != out_with_ext) { rename(out_with_ext, out); free(out_with_ext); } free(out); libvlc_media_player_release(mp); libvlc_media_release(m); libvlc_release(libvlc); pthread_cond_destroy(&wait); return 0; }
bool CAVPlayer::Play(const std::string &strPath) { if (! m_pVLC_Inst) {// 如果播放引擎没有创建,则创建它 Init(); } if(strPath.empty() || ! m_pVLC_Inst) {// 如果链接地址为空,或播放引擎没创建,则直接返回 return false; } // 验证地址是网络地址,还是本地地址 bool bURL = false; bURL = IsURL(strPath); Stop(); bool bRet = false; libvlc_media_t *m = NULL; if (bURL) {// 网络路径 m = libvlc_media_new_location(m_pVLC_Inst, strPath.c_str()); } else {// 本地路径 m = libvlc_media_new_path(m_pVLC_Inst, strPath.c_str()); } if (m) { if (m_pVLC_Player = libvlc_media_player_new_from_media(m)) { libvlc_media_player_set_hwnd(m_pVLC_Player, m_hWnd); libvlc_media_player_play(m_pVLC_Player); m_bStatus = em_play;//播放状态 // 事件管理 libvlc_event_manager_t *vlc_evt_man = libvlc_media_player_event_manager(m_pVLC_Player); libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPlaying,CAVPlayer::OnVLC_Event, this); libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerPositionChanged, CAVPlayer::OnVLC_Event, this); libvlc_event_attach(vlc_evt_man, libvlc_MediaPlayerEndReached, CAVPlayer::OnVLC_Event, this); bRet = true; } libvlc_media_release(m); } return bRet; }
bool Transcode::m_doTranscode( const QString &transStr ) { QString sout( ":sout=" ); sout += transStr; char const *vlc_argv[] = { "-I", "dummy", "--no-skip-frame", }; int vlc_argc = sizeof( vlc_argv ) / sizeof( *vlc_argv ); libvlc_exception_init( &m_vlcEx ); m_libvlc = libvlc_new( vlc_argc, vlc_argv, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; m_vlcMedia = libvlc_media_new( m_libvlc, m_origVidPath.toLocal8Bit(), &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; libvlc_media_add_option(m_vlcMedia, sout.toStdString().c_str(), &m_vlcEx); if ( catchVLCException( &m_vlcEx ) ) return false; m_vlcMp = libvlc_media_player_new_from_media( m_vlcMedia, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; m_vlcEM = libvlc_media_player_event_manager( m_vlcMp, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; libvlc_event_attach( m_vlcEM, libvlc_MediaPlayerPlaying, m_callback, this, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; libvlc_event_attach( m_vlcEM, libvlc_MediaPlayerEndReached, m_callback, this, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; libvlc_media_player_play( m_vlcMp, &m_vlcEx ); if ( catchVLCException( &m_vlcEx ) ) return false; m_running = true; m_initProgressDialog(); return true; }
libvlc_media_player_t * player::open(string path) { //stop(); inst = libvlc_new(0, NULL); //constructor m = libvlc_media_new_path(inst, path.c_str()); if (!m) { qDebug("error load"); return NULL; } // 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); return mp; }
bool media_url_play(const char *url,int * panel) { hwnd_handle = panel; media_inst = libvlc_new(0,NULL); media_handle = libvlc_media_new_location(media_inst,url); mediaplay = libvlc_media_player_new_from_media(media_handle); return media_play(); }
void VPlayer::setFile(QString _file) { stop(); file=_file; if(m){ libvlc_media_release(m); } if(mp){ libvlc_media_player_release(mp); } m=libvlc_media_new_path(vlc,file.toUtf8()); if(m){ mp=libvlc_media_player_new_from_media(m); } }
void Java_org_videolan_libvlc_MediaPlayer_nativeNewFromMedia(JNIEnv *env, jobject thiz, jobject jmedia, jobject jwindow) { vlcjni_object *p_obj; vlcjni_object *p_m_obj = VLCJniObject_getInstance(env, jmedia); if (!p_m_obj) return; p_obj = VLCJniObject_newFromLibVlc(env, thiz, p_m_obj->p_libvlc); if (!p_obj) return; p_obj->u.p_mp = libvlc_media_player_new_from_media(p_m_obj->u.p_m); MediaPlayer_newCommon(env, thiz, p_obj, jwindow); }
bool media_file_play(const char * filename,int * panel) { hwnd_handle = panel; media_inst = libvlc_new(0,NULL); if(mediaplay != NULL) { libvlc_media_player_stop(mediaplay); } media_handle = libvlc_media_new_path(media_inst,filename); mediaplay = libvlc_media_player_new_from_media(media_handle); return media_play(); }
static void test_media_has_slaves_from_player(libvlc_instance_t *p_vlc, libvlc_media_slave_t *p_expected_slaves, unsigned i_expected_slaves) { /* This function test subtitles_Detect() when playing a local file */ libvlc_media_t *p_m = libvlc_media_new_path(p_vlc, MAIN_MEDIA_PATH); assert(p_m != NULL); libvlc_media_player_t *p_mp = libvlc_media_player_new_from_media(p_m); assert(p_mp != NULL); mediaplayer_play_sync(p_mp); test_expected_slaves(p_m, p_expected_slaves, i_expected_slaves); libvlc_media_release(p_m); libvlc_media_player_release(p_mp); }
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); }
void PlayerEngine_vlc::get_File(std::string uri){ /* Stop if something is playing */ if (vlcPlayer && libvlc_media_player_is_playing(vlcPlayer)) stopState(); message = "Status : Loading"; /* Create a new Media */ libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcInstance,&uri[0]/*uri.c_str()*/); if (!vlcMedia) { message = "Error : failed to create media"; return; } /* Create a new libvlc player */ vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); //gulong window_id; //libvlc_media_player_set_xwindow(vlcPlayer,window_id); //Player_ControlsGUI win; //win.set_xwindows_id(window_id); /* Release the media */ libvlc_media_release(vlcMedia); /* And start playback */ /* libvlc_media_player_play (vlcPlayer); message = "Status : Playing"; */ // catch the exception from here }
static void _file_set(struct _App *app) { if (app->opening) { libvlc_media_release(app->m); libvlc_media_player_release(app->mp); free(app->filename); } _em_str_read(app->em_read, &app->filename); app->m = libvlc_media_new_path(app->libvlc, app->filename); if (!app->m) { fprintf(stderr, "could not open path: \"%s\"\n", app->filename); return; } app->mp = libvlc_media_player_new_from_media(app->m); if (!app->mp) { fprintf(stderr, "could not create new player from media.\n"); return; } app->opening = 1; libvlc_video_set_format(app->mp, "RV32", DEFAULTWIDTH, DEFAULTHEIGHT, DEFAULTWIDTH * 4); libvlc_video_set_callbacks(app->mp, _tmp_lock, _tmp_unlock, _tmp_display, app); app->event_mgr = libvlc_media_player_event_manager(app->mp); libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerPositionChanged, _event_cb, app); libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerStopped, _event_cb, app); app->mevent_mgr = libvlc_media_event_manager(app->m); app->tmpbuffer = malloc(sizeof(char) * DEFAULTWIDTH * DEFAULTHEIGHT * 4); libvlc_audio_set_mute(app->mp, 1); libvlc_media_player_play(app->mp); }
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; }
QString VideoWidget::GetTitle(QString file) { libvlc_instance_t * pinst; libvlc_media_player_t *pmp; libvlc_media_t *pm; pinst = libvlc_new (0, NULL); pm = libvlc_media_new_path (pinst, file.toStdString().c_str()); pmp = libvlc_media_player_new_from_media (pm); libvlc_media_player_play (pmp); while (libvlc_media_get_state(pm) != 3) { libvlc_media_get_state(pm); } char *meta = libvlc_media_get_meta (pm, libvlc_meta_Title); QString title = QString(meta); title.detach(); libvlc_media_release (pm); libvlc_media_player_stop (pmp); libvlc_media_player_release (pmp); libvlc_release (pinst); return title; }
void VlcVideoWidget::RestartPlayback() { if (!status.doRestart) return; status.doRestart = false; vlcPlayer_ = libvlc_media_player_new_from_media(vlcMedia_); 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); libvlc_video_set_callbacks( vlcPlayer_, &CallBackLock, &CallBackUnlock, &CallBackDisplay, this); renderPixmap_ = QImage(status.sourceSize.width(), status.sourceSize.height(), QImage::Format_RGB32); libvlc_video_set_format(vlcPlayer_, "RV32", renderPixmap_.width(), renderPixmap_.height(), renderPixmap_.bytesPerLine()); if (!status.doNotPlayAfterRestart) { Play(); status.doNotPlayAfterRestart = false; } }
bool VlcPlugin::playlist_select( int idx, libvlc_exception_t *ex ) { libvlc_media_t *p_m = NULL; libvlc_media_list_lock(libvlc_media_list); int count = libvlc_media_list_count(libvlc_media_list,ex); if( libvlc_exception_raised(ex) ) goto bad_unlock; if( idx<0||idx>=count ) goto bad_unlock; playlist_index = idx; p_m = libvlc_media_list_item_at_index(libvlc_media_list,playlist_index,ex); libvlc_media_list_unlock(libvlc_media_list); if( libvlc_exception_raised(ex) ) return false; if( libvlc_media_player ) { libvlc_media_player_release( libvlc_media_player ); libvlc_media_player = NULL; } libvlc_media_player = libvlc_media_player_new_from_media(p_m,ex); if( libvlc_media_player ) set_player_window(ex); libvlc_media_release( p_m ); return !libvlc_exception_raised(ex); bad_unlock: libvlc_media_list_unlock(libvlc_media_list); return false; }
void VLCMainwindow::StartPlayMainURL(QString rtspURL) { if( vlcPlayer && libvlc_media_player_is_playing(vlcPlayer) ) stop(); // New Media // libvlc_media_t *vlcMedia = libvlc_media_new_path(vlcObject,qtu(fileOpen)); libvlc_media_t *vlcMedia = libvlc_media_new_location(vlcObject,qtu(rtspURL)); if( !vlcMedia ) return; QMessageBox::warning(NULL, "Hello", "startPlayMainURL"); vlcPlayer = libvlc_media_player_new_from_media (vlcMedia); libvlc_media_release(vlcMedia); //libvlc_media_player_set_xwindow(vlcPlayer, windid); /* And play */ libvlc_media_player_play (vlcPlayer); //Set vars and text correctly playBut->setText("Pause"); }
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_); }
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); }