/************************************************************************** * libvlc_media_list_release (Public) * * Release an object. **************************************************************************/ void libvlc_media_list_release( libvlc_media_list_t * p_mlist ) { libvlc_media_t * p_md; int i; vlc_mutex_lock( &p_mlist->refcount_lock ); p_mlist->i_refcount--; if( p_mlist->i_refcount > 0 ) { vlc_mutex_unlock( &p_mlist->refcount_lock ); return; } vlc_mutex_unlock( &p_mlist->refcount_lock ); /* Refcount null, time to free */ libvlc_event_manager_release( p_mlist->p_event_manager ); libvlc_media_release( p_mlist->p_md ); for ( i = 0; i < vlc_array_count( &p_mlist->items ); i++ ) { p_md = vlc_array_item_at_index( &p_mlist->items, i ); libvlc_media_release( p_md ); } vlc_mutex_destroy( &p_mlist->object_lock ); vlc_array_clear( &p_mlist->items ); free( p_mlist ); }
// 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; }
static void services_discovery_item_added( services_discovery_t *sd, input_item_t *parent, input_item_t *p_item, const char *psz_cat ) { libvlc_media_t * p_md; libvlc_media_discoverer_t *p_mdis = sd->owner.sys; libvlc_media_list_t * p_mlist = p_mdis->p_mlist; p_md = libvlc_media_new_from_input_item( p_mdis->p_libvlc_instance, p_item ); if( parent != NULL ) { /* Flatten items list for now. TODO: tree support. */ } else /* If we have a category, that mean we have to group the items having * that category in a media_list. */ if( psz_cat ) { p_mlist = vlc_dictionary_value_for_key( &p_mdis->catname_to_submedialist, psz_cat ); if( p_mlist == kVLCDictionaryNotFound ) { libvlc_media_t * p_catmd; p_catmd = libvlc_media_new_as_node( p_mdis->p_libvlc_instance, psz_cat ); p_mlist = libvlc_media_subitems( p_catmd ); p_mlist->b_read_only = true; /* Insert the newly created mlist in our dictionary */ vlc_dictionary_insert( &p_mdis->catname_to_submedialist, psz_cat, p_mlist ); /* Insert the md into the root list */ libvlc_media_list_lock( p_mdis->p_mlist ); libvlc_media_list_internal_add_media( p_mdis->p_mlist, p_catmd ); libvlc_media_list_unlock( p_mdis->p_mlist ); /* We don't release the mlist cause the dictionary * doesn't retain the object. But we release the md. */ libvlc_media_release( p_catmd ); } } libvlc_media_list_lock( p_mlist ); libvlc_media_list_internal_add_media( p_mlist, p_md ); libvlc_media_list_unlock( p_mlist ); libvlc_media_release( p_md ); }
static void test_media_has_slaves_from_parent(libvlc_instance_t *p_vlc, libvlc_media_slave_t *p_expected_slaves, unsigned i_expected_slaves) { libvlc_media_t *p_m = libvlc_media_new_path(p_vlc, SLAVES_DIR); assert(p_m != NULL); printf("Parse media dir to get subitems\n"); media_parse_sync(p_m); char *psz_main_media_mrl = path_to_mrl(p_vlc, MAIN_MEDIA_PATH); assert(psz_main_media_mrl != NULL); printf("Main media mrl: '%s'\n", psz_main_media_mrl); printf("Fetch main media from subitems\n"); libvlc_media_list_t *p_ml = libvlc_media_subitems(p_m); assert(p_ml != NULL); libvlc_media_list_lock(p_ml); int i_count = libvlc_media_list_count(p_ml); assert(i_count > 0); libvlc_media_t *p_subm = NULL; for (int i = 0; i < i_count; ++i) { p_subm = libvlc_media_list_item_at_index(p_ml, i); assert(p_subm != NULL); char *psz_mrl = libvlc_media_get_mrl(p_subm); assert(psz_mrl != NULL); if (strcmp(psz_main_media_mrl, psz_mrl) == 0) { printf("Found main media\n"); free(psz_mrl); break; } free(psz_mrl); libvlc_media_release(p_subm); p_subm = NULL; } free(psz_main_media_mrl); libvlc_media_list_unlock(p_ml); libvlc_media_list_release(p_ml); assert(p_subm != NULL); test_expected_slaves(p_subm, p_expected_slaves, i_expected_slaves); libvlc_media_release(p_subm); libvlc_media_release(p_m); }
/* TODO: NOT IN VLC API */ void Java_org_videolan_libvlc_MediaPlayer_nativePlayMRL(JNIEnv *env, jobject thiz, jstring mrl, jobjectArray mediaOptions) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return; /* New Media */ const char* p_mrl = (*env)->GetStringUTFChars(env, mrl, 0); libvlc_media_t* p_md = libvlc_media_new_location(p_obj->p_libvlc, p_mrl); /* media options */ if (mediaOptions != NULL) add_media_options(p_md, env, mediaOptions); (*env)->ReleaseStringUTFChars(env, mrl, p_mrl); /* Connect the media event manager. */ /* TODO use VlcObject events */ libvlc_event_manager_t *ev_media = libvlc_media_event_manager(p_md); static const libvlc_event_type_t mp_media_events[] = { libvlc_MediaParsedChanged, libvlc_MediaMetaChanged, }; for(int i = 0; i < (sizeof(mp_media_events) / sizeof(*mp_media_events)); i++) libvlc_event_attach(ev_media, mp_media_events[i], vlc_event_callback, NULL); libvlc_media_player_set_media(p_obj->u.p_mp, p_md); libvlc_media_release(p_md); libvlc_media_player_play(p_obj->u.p_mp); }
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"); }
static void _file_close(struct _App *app) { app->playing = 0; if (app->opening) goto release_resources; if (libvlc_media_player_get_state(app->mp) != libvlc_Playing) { _send_file_closed(app); return; } app->closing = 1; release_resources: libvlc_media_player_stop(app->mp); if (app->filename) free(app->filename); if (app->mp) { libvlc_media_release(app->m); libvlc_media_player_release(app->mp); free(app->tmpbuffer); } }
/************************************************************************** * Create a new media descriptor object **************************************************************************/ libvlc_media_t * libvlc_media_new_as_node( libvlc_instance_t *p_instance, const char * psz_name ) { input_item_t * p_input_item; libvlc_media_t * p_md; libvlc_media_list_t * p_subitems; p_input_item = input_item_New( "vlc://nop", psz_name ); if (!p_input_item) { libvlc_printerr( "Not enough memory" ); return NULL; } p_md = libvlc_media_new_from_input_item( p_instance, p_input_item ); p_subitems = media_get_subitems( p_md, true ); if( p_subitems == NULL) { libvlc_media_release( p_md ); return NULL; } return p_md; }
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"); }
VideoWindow::~VideoWindow() { if (!init) return; // we didn't initialise properly so all bets are off #if (defined Q_OS_LINUX) && (QT_VERSION < 0x050000) && (defined GC_VIDEO_VLC) // unembed vlc backend first x11Container->discardClient(); #endif stopPlayback(); #ifdef GC_VIDEO_VLC // VLC /* No need to keep the media now */ if (m) libvlc_media_release (m); /* nor the player */ libvlc_media_player_release (mp); // unload vlc libvlc_release (inst); #endif #ifdef GC_VIDEO_QT5 // QT MEDIA delete mp; delete wd; #endif }
void Java_org_videolan_libvlc_MediaPlayer_stop(JNIEnv *env, jobject thiz) { vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return; /* TODO: REMOVE */ libvlc_media_t* p_md = libvlc_media_player_get_media(p_obj->u.p_mp); if (p_md) { libvlc_event_manager_t *ev_media = libvlc_media_event_manager(p_md); static const libvlc_event_type_t mp_media_events[] = { libvlc_MediaParsedChanged, libvlc_MediaMetaChanged, }; for(int i = 0; i < (sizeof(mp_media_events) / sizeof(*mp_media_events)); i++) libvlc_event_detach(ev_media, mp_media_events[i], vlc_event_callback, NULL); libvlc_media_release(p_md); libvlc_media_player_set_media(p_obj->u.p_mp, NULL); } libvlc_media_player_stop(p_obj->u.p_mp); }
static int expand_media_internal(JNIEnv *env, libvlc_instance_t* p_instance, jobject arrayList, libvlc_media_t* p_md) { if(!p_md) { return -1; } libvlc_media_list_t* p_subitems = libvlc_media_subitems(p_md); libvlc_media_release(p_md); if(p_subitems) { // Expand any subitems if needed int subitem_count = libvlc_media_list_count(p_subitems); if(subitem_count > 0) { LOGD("Found %d subitems, expanding", subitem_count); jclass arrayListClass; jmethodID methodAdd; arrayListGetIDs(env, &arrayListClass, &methodAdd, NULL); for(int i = subitem_count - 1; i >= 0; i--) { libvlc_media_t* p_subitem = libvlc_media_list_item_at_index(p_subitems, i); char* p_subitem_uri = libvlc_media_get_mrl(p_subitem); arrayListStringAdd(env, arrayListClass, methodAdd, arrayList, p_subitem_uri); free(p_subitem_uri); } } libvlc_media_list_release(p_subitems); if(subitem_count > 0) { return 0; } else { return -1; } } else { return -1; } }
void play_next(struct info *data) { char errormsg[] = "Next mix not found."; int errn; struct track *t; libvlc_media_t *media; /* Check if we are already on the last track. * If so request a similar mix and continue playing. */ if (data->m->track_count > 0) { if (data->m->track[data->m->track_count-1]->last == TRUE) { errn = search_nextmix(data); if (errn == ERROR) { draw_error(errormsg); data->state = START; return; } } } t = mix_nexttrack(data); if (t == NULL) return; media = libvlc_media_new_location(data->vlc_inst, t->url); if (media == NULL) return; libvlc_media_player_set_media(data->vlc_mp, media); (void)libvlc_media_player_play(data->vlc_mp); libvlc_media_release(media); }
void VlcVideoWidget::ShutDown() { if (vlcPlayer_ && vlcInstance_) { /** @bug @todo These should not be here and is not actually doing anything. Take a fresh look at the threading in this object and remove these hacks. */ if (onScreenPixmapMutex_.tryLock(50)) onScreenPixmapMutex_.unlock(); if (renderPixmapMutex_.tryLock(50)) renderPixmapMutex_.unlock(); if (statusAccess.tryLock(50)) statusAccess.unlock(); libvlc_media_release(vlcMedia_); libvlc_media_player_stop(vlcPlayer_); libvlc_media_player_release(vlcPlayer_); libvlc_release(vlcInstance_); vlcMedia_ = 0; vlcPlayer_ = 0; vlcInstance_ = 0; close(); } }
CReportCameraWorker::~CReportCameraWorker() { m_Thread.WaitStopThread(); CloseHandle(m_hStartCaptureEvent); CloseHandle(m_hStopCaptureEvent); m_Client = NULL; // clear vlc StopCapture(); if (m_m) { libvlc_media_release (m_m); m_m = NULL; } if (m_mp) { libvlc_media_player_stop (m_mp); libvlc_media_player_release (m_mp); m_mp = NULL; } if (m_inst) { libvlc_release(m_inst); m_inst = NULL; } }
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); }
void VLC::load(const std::string & theFilename) { AC_DEBUG << "VLC::load('" << theFilename << "')"; _EOF = false; _playTime = 0; std::vector<std::string> elements = asl::splitString(theFilename, "#"); if (elements.size() == 2) { _playTime = as<asl::Unsigned64>(elements[1]); AC_DEBUG << "parsed playback position at " << _playTime << " milliseconds."; } _mediaURL = elements[0]; libvlc_media_t *media = libvlc_media_new_location(_libvlc, _mediaURL.c_str()); libvlc_media_player_set_media(_mediaPlayer, media); libvlc_media_release(media); libvlc_video_set_callbacks(_mediaPlayer, VLC::lock, VLC::unlock, VLC::display, this); _rasterEncoding = BGR; setPixelFormat(_rasterEncoding); libvlc_video_set_format_callbacks(_mediaPlayer, VLC::setup_video, VLC::cleanup_video); libvlc_media_player_play(_mediaPlayer); if (_playTime > 0) { libvlc_media_player_set_time(_mediaPlayer, _playTime); } }
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; }
/************************************************************************** * flat_media_list_view_item_at_index (private) * (called by flat_media_list_view_item_at_index) **************************************************************************/ static libvlc_media_t * hierarch_node_media_list_view_item_at_index( libvlc_media_list_view_t * p_mlv, int index, libvlc_exception_t * p_e ) { /* FIXME: we may want to cache that */ libvlc_media_t * p_md; libvlc_media_list_t * p_submlist; trace("%d\n", index); int i, current_index, count = libvlc_media_list_count( p_mlv->p_mlist, p_e ); current_index = -1; for( i = 0; i < count; i++ ) { p_md = libvlc_media_list_item_at_index( p_mlv->p_mlist, i, p_e ); if( !p_md ) continue; p_submlist = libvlc_media_subitems( p_md ); if( !p_submlist ) continue; libvlc_media_list_release( p_submlist ); current_index++; if( current_index == index ) return p_md; libvlc_media_release( p_md ); } libvlc_exception_raise( p_e ); libvlc_printerr( "Index out of bound in Media List View" ); return NULL; }
VLCVideoWidgetDelegator:: ~VLCVideoWidgetDelegator(){ //may run on the main thread if( m_widgetInstance != Nullptr ){ delete m_widgetInstance; } if( m_player != Nullptr ){ if( m_isPlaying ){ libvlc_media_player_stop ( m_player ); } } if( m_currentMedia != Nullptr ){ libvlc_media_release( m_currentMedia ); } if( m_player != Nullptr ){ /* Free the media_player */ libvlc_media_player_release (m_player); } if( m_instance != Nullptr ){ libvlc_release (m_instance); } }
/************************************************************************** * Destroy a Media Instance object (libvlc internal) * * Warning: No lock held here, but hey, this is internal. Caller must lock. **************************************************************************/ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ) { assert( p_mi ); /* Detach Callback from the main libvlc object */ var_DelCallback( p_mi->p_libvlc, "snapshot-file", snapshot_was_taken, p_mi ); /* No need for lock_input() because no other threads knows us anymore */ if( p_mi->input.p_thread ) release_input_thread(p_mi, true); if( p_mi->input.p_resource ) { input_resource_Terminate( p_mi->input.p_resource ); input_resource_Release( p_mi->input.p_resource ); p_mi->input.p_resource = NULL; } vlc_mutex_destroy( &p_mi->input.lock ); libvlc_event_manager_release( p_mi->p_event_manager ); libvlc_media_release( p_mi->p_md ); vlc_mutex_destroy( &p_mi->object_lock ); libvlc_instance_t *instance = p_mi->p_libvlc_instance; vlc_object_release( p_mi ); libvlc_release(instance); }
/************************************************************************** * 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 */ }
static bool media_play() { int64_t ms_media_length; int s_length; libvlc_media_parse(media_handle); s_length = (int)(ceil(libvlc_media_get_duration(media_handle)/1000)); current_media_duration = s_length; if(s_length == -1) return false; libvlc_media_player_set_hwnd(mediaplay,(void *)hwnd_handle); libvlc_media_player_play(mediaplay); sleep(s_length); libvlc_media_player_stop(mediaplay); libvlc_media_release(media_handle); return true; }
/************************************************************************** * input_item_subitem_added (Private) (vlc event Callback) **************************************************************************/ static void input_item_subitem_added( const vlc_event_t *p_event, void * user_data ) { libvlc_media_t * p_md = user_data; libvlc_media_t * p_md_child; libvlc_event_t event; p_md_child = libvlc_media_new_from_input_item( p_md->p_libvlc_instance, p_event->u.input_item_subitem_added.p_new_child ); /* Add this to our media list */ if( !p_md->p_subitems ) { p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance ); libvlc_media_list_set_media( p_md->p_subitems, p_md ); } if( p_md->p_subitems ) { libvlc_media_list_add_media( p_md->p_subitems, p_md_child ); } /* Construct the event */ event.type = libvlc_MediaSubItemAdded; event.u.media_subitem_added.new_child = p_md_child; /* Send the event */ libvlc_event_send( p_md->p_event_manager, &event ); libvlc_media_release( p_md_child ); }
static void uninstall_md_listener( libvlc_media_list_view_t * p_mlv, libvlc_media_t * p_md) { libvlc_media_list_t * p_mlist; libvlc_exception_t ignored_exception; libvlc_exception_init( &ignored_exception ); libvlc_event_detach( p_md->p_event_manager, libvlc_MediaSubItemAdded, media_list_subitem_added, p_mlv, &ignored_exception ); if( libvlc_exception_raised( &ignored_exception ) ) libvlc_exception_clear( &ignored_exception ); /* We don't care if we encounter an exception */ if((p_mlist = libvlc_media_subitems( p_md ))) { libvlc_media_list_lock( p_mlist ); libvlc_event_detach( p_mlist->p_event_manager, libvlc_MediaListItemAdded, media_list_item_added, p_mlv, NULL ); libvlc_event_detach( p_mlist->p_event_manager, libvlc_MediaListItemDeleted, media_list_item_removed, p_mlv, NULL ); int i, count = libvlc_media_list_count( p_mlist, NULL ); for( i = 0; i < count; i++) { libvlc_media_t * p_submd; p_submd = libvlc_media_list_item_at_index( p_mlist,i, NULL ); uninstall_md_listener( p_mlv, p_submd ); libvlc_media_release( p_submd ); } libvlc_media_list_unlock( p_mlist ); libvlc_media_list_release( p_mlist ); } }
void VideoWindow::mediaSelected(QString filename) { // stop any current playback stopPlayback(); // release whatever is already loaded if (m) libvlc_media_release(m); m = NULL; if (filename.endsWith("/DVD") || (filename != "" && QFile(filename).exists())) { #ifdef Q_OS_LINUX QString fileURL = "file://" + filename.replace(" ","%20").replace("\\", "/"); #else // A Windows "c:\xyz\abc def.avi" filename should become file:///c:/xyz/abc%20def.avi QString fileURL = "file:///" + filename.replace(" ","%20").replace("\\", "/"); #endif //qDebug()<<"file url="<<fileURL; /* open media */ m = libvlc_media_new_path(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLatin1()); /* set the media to playback */ if (m) libvlc_media_player_set_media (mp, m); m_MediaChanged = true; } }
bool VlcVideoPlayer::loadVideo(const char* path) { if(vlcMedia = libvlc_media_new_path(vlcInstance, path)) { libvlc_media_player_set_media(vlcPlayer, vlcMedia); libvlc_media_release(vlcMedia); // Needed for mixing VLC and wxWidgets. // Needs to be after above calls, or else bug with stop button! libvlc_media_player_set_hwnd( vlcPlayer, reinterpret_cast<void *> ( (HWND)this->GetHandle() ) ); /// @todo ???? // Stuff //libvlc_media_player_next_frame(vlcPlayer); //libvlc_video_set_format(vlcPlayer); _DEBUG_ DSTREAM << "Loaded video file." << endl; } else { _DEBUG_ DSTREAM << "Can't load media from path" << endl; wxMessageDialog (this, "Can't load media from path"); return false; } return true; // Didn't fails loading. }
static void test_media_subitems(const char** argv, int argc) { const char *subitems_path = SRCDIR"/samples/subitems"; libvlc_instance_t *vlc = libvlc_new (argc, argv); assert (vlc != NULL); libvlc_media_t *media; log ("Testing media_subitems: path: '%s'\n", subitems_path); media = libvlc_media_new_path (vlc, subitems_path); assert (media != NULL); test_media_subitems_media (media, false); libvlc_media_release (media); #define NB_LOCATIONS 2 char *subitems_realpath = realpath (subitems_path, NULL); assert (subitems_realpath != NULL); const char *schemes[NB_LOCATIONS] = { "file://", "dir://" }; for (unsigned i = 0; i < NB_LOCATIONS; ++i) { char *location; assert (asprintf (&location, "%s%s", schemes[i], subitems_realpath) != -1); log ("Testing media_subitems: location: '%s'\n", location); media = libvlc_media_new_location (vlc, location); assert (media != NULL); test_media_subitems_media (media, false); free (location); libvlc_media_release (media); } free (subitems_realpath); #ifdef HAVE_OPENAT /* listing directory via a fd works only if HAVE_OPENAT is defined */ int fd = open (subitems_path, O_RDONLY); log ("Testing media_subitems: fd: '%d'\n", fd); assert (fd >= 0); media = libvlc_media_new_fd (vlc, fd); assert (media != NULL); test_media_subitems_media (media, true); libvlc_media_release (media); close (fd); #else #warning not testing subitems list via a fd location #endif libvlc_release (vlc); }
VlcMedia::~VlcMedia() { removeCoreConnections(); libvlc_media_release(_vlcMedia); VlcError::errmsg(); }
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_); }