/************************************************************************** * load (Public) * * It doesn't yet load the playlists **************************************************************************/ int libvlc_media_library_load( libvlc_media_library_t * p_mlib ) { char *psz_datadir = config_GetUserDir( VLC_DATA_DIR ); char * psz_uri; if( psz_datadir == NULL || asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp", psz_datadir ) == -1 ) psz_uri = NULL; free( psz_datadir ); if( psz_uri == NULL ) { libvlc_printerr( "Not enough memory" ); return -1; } if( p_mlib->p_mlist ) libvlc_media_list_release( p_mlib->p_mlist ); p_mlib->p_mlist = libvlc_media_list_new( p_mlib->p_libvlc_instance ); int ret = libvlc_media_list_add_file_content( p_mlib->p_mlist, psz_uri ); free( psz_uri ); return ret; }
/************************************************************************** * 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 ); }
/************************************************************************** * new (Public) **************************************************************************/ libvlc_media_discoverer_t * libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name ) { /* podcast SD is a hack and only works with custom playlist callbacks. */ if( !strncasecmp( psz_name, "podcast", 7 ) ) return NULL; libvlc_media_discoverer_t *p_mdis; p_mdis = malloc(sizeof(*p_mdis) + strlen(psz_name) + 1); if( unlikely(p_mdis == NULL) ) { libvlc_printerr( "Not enough memory" ); return NULL; } p_mdis->p_libvlc_instance = p_inst; p_mdis->p_mlist = libvlc_media_list_new( p_inst ); p_mdis->p_mlist->b_read_only = true; p_mdis->p_sd = NULL; vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 ); libvlc_event_manager_init( &p_mdis->event_manager, p_mdis ); libvlc_retain( p_inst ); strcpy( p_mdis->name, psz_name ); return p_mdis; }
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); }
VlcMediaList::VlcMediaList(VlcInstance *instance) : QObject(instance) { _vlcMediaList = libvlc_media_list_new(instance->core()); _vlcEvents = libvlc_media_list_event_manager(_vlcMediaList); createCoreConnections(); VlcError::errmsg(); }
/* * Create an empty media list. * * @param [VLC::Core] core the core instance * @raise [ArgumentError] Invalid or unsupported arguments * @todo fixme */ static VALUE rg_initialize(int argc, VALUE *argv, VALUE self) { VALUE core; libvlc_media_list_t *instance; rb_scan_args(argc, argv, "01", &core); if (NIL_P(core)) core = rb_funcall(GTYPE2CLASS(VLC_TYPE_CORE), rb_intern("new"), 0); instance = libvlc_media_list_new(RVAL2VLCCORE(core)); if (!instance) rb_raise(rb_eArgError, "Invalid arguments."); rb_ivar_set(self, id_core, core); G_INITIALIZE(self, instance); vlc_media_list_free(instance); return Qnil; }
static libvlc_media_list_t *media_get_subitems( libvlc_media_t * p_md, bool b_create ) { libvlc_media_list_t *p_subitems = NULL; vlc_mutex_lock( &p_md->subitems_lock ); if( p_md->p_subitems == NULL && b_create ) { p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance ); if( p_md->p_subitems != NULL ) { p_md->p_subitems->b_read_only = true; p_md->p_subitems->p_internal_md = p_md; } } p_subitems = p_md->p_subitems; vlc_mutex_unlock( &p_md->subitems_lock ); return p_subitems; }
/************************************************************************** * 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; 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_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance ); return p_md; }
bool VideoPlayer::initPlayer(string mediaURL) { if(VideoPlayer::disabled == true) { return true; } #ifdef HAS_LIBVLC ctxPtr->libvlc = NULL; ctxPtr->m = NULL; ctxPtr->mp = NULL; ctxPtr->vlc_argv.clear(); ctxPtr->vlc_argv.push_back("--intf=dummy"); //ctxPtr->vlc_argv.push_back("--intf=http"); //ctxPtr->vlc_argv.push_back("--no-media-library"); ctxPtr->vlc_argv.push_back("--ignore-config"); /* Don't use VLC's config */ ctxPtr->vlc_argv.push_back("--no-xlib"); /* tell VLC to not use Xlib */ ctxPtr->vlc_argv.push_back("--no-video-title-show"); //ctxPtr->vlc_argv.push_back("--network-caching=10000"); if(loop == true) { ctxPtr->vlc_argv.push_back("--loop"); ctxPtr->vlc_argv.push_back("--repeat"); } #if defined(LIBVLC_VERSION_PRE_2) ctxPtr->vlc_argv_str.push_back("--plugin-path=" + pluginsPath); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); #endif #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) char clock[64], cunlock[64], cdata[64]; char cwidth[32], cheight[32], cpitch[32]; /* * Initialise libVLC */ sprintf(clock, "%lld", (long long int)(intptr_t)lock); sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock); sprintf(cdata, "%lld", (long long int)(intptr_t)ctxPtr); sprintf(cwidth, "%i", width); sprintf(cheight, "%i", height); sprintf(cpitch, "%i", colorBits); vlc_argv.push_back("--vout"); vlc_argv.push_back("vmem"); vlc_argv.push_back("--vmem-width"); ctxPtr->vlc_argv_str.push_back(cwidth); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-height"); ctxPtr->vlc_argv_str.push_back(cheight); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-pitch"); ctxPtr->vlc_argv_str.push_back(cpitch); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-chroma"); vlc_argv.push_back("RV16"); vlc_argv.push_back("--vmem-lock"); ctxPtr->vlc_argv_str.push_back(clock); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-unlock"); ctxPtr->vlc_argv_str.push_back(cunlock); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); vlc_argv.push_back("--vmem-data"); ctxPtr->vlc_argv_str.push_back(cdata); ctxPtr->vlc_argv.push_back(ctxPtr->vlc_argv_str[ctxPtr->vlc_argv_str.size()-1].c_str()); #endif if(verboseEnabled) ctxPtr->vlc_argv.push_back("--verbose=2"); if(verboseEnabled) ctxPtr->vlc_argv.push_back("--extraintf=logger"); //log anything #if defined(WIN32) if(verboseEnabled) _putenv("VLC_VERBOSE=2"); #endif int vlc_argc = ctxPtr->vlc_argv.size(); // char const *vlc_argv[] = // { // //"--no-audio", /* skip any audio track */ // "--no-xlib", /* tell VLC to not use Xlib */ // "--no-video-title-show", // pluginParam.c_str(), // }; // int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv); #endif ctxPtr->empty = NULL; glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); // Init Texture glGenTextures(1, &ctxPtr->textureId); glBindTexture(GL_TEXTURE_2D, ctxPtr->textureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ctxPtr->empty = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, colorBits, 0, 0, 0, 0); ctxPtr->surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, colorBits, 0x001f, 0x07e0, 0xf800, 0); ctxPtr->mutex = SDL_CreateMutex(); #ifdef HAS_LIBVLC /* * Initialize libVLC */ if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) libvlc_exception_t ex; libvlc_exception_init(&ex); ctxPtr->libvlc = libvlc_new(ctxPtr->vlc_argc, &ctxPtr->vlc_argv[0],&ex); catchError(&ex); #else ctxPtr->libvlc = libvlc_new(vlc_argc, &ctxPtr->vlc_argv[0]); #endif if(verboseEnabled) printf("In [%s] Line: %d, libvlc [%p]\n",__FUNCTION__,__LINE__,ctxPtr->libvlc); /* It is meaningless to try all this because we have to restart mg to pickup new env vars #if defined(WIN32) if(libvlc == NULL) { // For windows check registry for install path std::string strValue = getRegKey("Software\\VideoLAN\\VLC", "InstallDir"); if(strValue != "") { if(strValue.length() >= 2) { if(strValue[0] == '"') { strValue = strValue.erase(0); } if(strValue[strValue.length()-1] == '"') { strValue = strValue.erase(strValue.length()-1); } } strValue = "VLC_PLUGIN_PATH=" + strValue; _putenv(strValue.c_str()); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=c:\\program files\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=\\program files\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=c:\\program files (x86)\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } if(libvlc == NULL) { _putenv("VLC_PLUGIN_PATH=\\program files (x86)\\videolan\\vlc\\plugins"); if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH")); libvlc = libvlc_new(vlc_argc, &vlc_argv[0]); } } #endif */ if(ctxPtr->libvlc != NULL) { #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) ctxPtr->m = libvlc_media_new(ctxPtr->libvlc, mediaURL.c_str(), &ex); if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m); catchError(&ex); ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m); if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp); libvlc_media_release(ctxPtr->m); #else if(mediaURL.find(HTTP_PREFIX) == 0) { ctxPtr->mlp = libvlc_media_list_player_new(ctxPtr->libvlc); ctxPtr->ml = libvlc_media_list_new(ctxPtr->libvlc); ctxPtr->m = libvlc_media_new_location(ctxPtr->libvlc, mediaURL.c_str()); libvlc_media_list_add_media(ctxPtr->ml, ctxPtr->m); } else { ctxPtr->m = libvlc_media_new_path(ctxPtr->libvlc, mediaURL.c_str()); } /* Create a new item */ if(verboseEnabled) printf("In [%s] Line: %d, m [%p]\n",__FUNCTION__,__LINE__,ctxPtr->m); if(loop == true) { libvlc_media_add_option(ctxPtr->m, "input-repeat=-1"); } if(mediaURL.find(HTTP_PREFIX) == 0) { ctxPtr->mp = libvlc_media_player_new(ctxPtr->libvlc); } else { ctxPtr->mp = libvlc_media_player_new_from_media(ctxPtr->m); } if(verboseEnabled) printf("In [%s] Line: %d, mp [%p]\n",__FUNCTION__,__LINE__,ctxPtr->mp); libvlc_media_player_set_media(ctxPtr->mp, ctxPtr->m); libvlc_media_release(ctxPtr->m); if(mediaURL.find(HTTP_PREFIX) == 0) { // Use our media list libvlc_media_list_player_set_media_list(ctxPtr->mlp, ctxPtr->ml); // Use a given media player libvlc_media_list_player_set_media_player(ctxPtr->mlp, ctxPtr->mp); } // Get an event manager for the media player. if(mediaURL.find(HTTP_PREFIX) == 0) { libvlc_event_manager_t *eventManager = libvlc_media_list_player_event_manager(ctxPtr->mlp); if(eventManager) { // libvlc_event_attach(eventManager, libvlc_MediaPlayerPlaying, (libvlc_callback_t)trapPlayingEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, (libvlc_callback_t)trapEndReachedEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerBuffering, (libvlc_callback_t)trapBufferingEvent, NULL, &ex); // libvlc_event_attach(eventManager, libvlc_MediaPlayerEncounteredError, (libvlc_callback_t)trapErrorEvent, NULL, &ex); int event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerNextItemSet, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerNextItemSet]\n"); } } } //else { //libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex); libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(ctxPtr->mp); if(eventManager) { int event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerSnapshotTaken, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerSnapshotTaken]\n"); } // event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerTimeChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerTimeChanged]\n"); // } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPlaying, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPlaying]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPaused, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPaused]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerStopped, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerStopped]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerEndReached, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerEndReached]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPositionChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPositionChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerLengthChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerLengthChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerEncounteredError,callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerEncounteredError]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerPausableChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerPausableChanged]\n"); } event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerSeekableChanged, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerSeekableChanged]\n"); } // event_added = libvlc_event_attach( eventManager, libvlc_MediaStateChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaStateChanged]\n"); // } // event_added = libvlc_event_attach( eventManager, libvlc_MediaParsedChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaParsedChanged]\n"); // } #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) event_added = libvlc_event_attach( eventManager, libvlc_MediaPlayerVout, callbacks, ctxPtr ); if(event_added != 0) { printf("ERROR CANNOT ADD EVENT [libvlc_MediaPlayerVout]\n"); } #endif // event_added = libvlc_event_attach( eventManager, libvlc_MediaListItemAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListItemAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListWillAddItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListWillAddItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListItemDeleted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListItemDeleted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListWillDeleteItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListWillDeleteItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewItemAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewItemAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewWillAddItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewWillAddItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewItemDeleted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewItemDeleted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListViewWillDeleteItem, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListViewWillDeleteItem]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerPlayed, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerPlayed]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerNextItemSet, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerNextItemSet]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaListPlayerStopped, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaListPlayerStopped]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaDiscovererStarted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaDiscovererStarted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_MediaDiscovererEnded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_MediaDiscovererEnded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaAdded, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaAdded]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaRemoved, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaRemoved]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaChanged, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaChanged]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStarted, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStarted]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStopped, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStopped]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusInit, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusInit]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusOpening, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusOpening]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusPlaying, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusPlaying]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusPause, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusPause]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusEnd, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusEnd]\n"); // } // // event_added = libvlc_event_attach( eventManager, libvlc_VlmMediaInstanceStatusError, callbacks, ctxPtr ); // if(event_added != 0) { // printf("ERROR CANNOT ADD EVENT [libvlc_VlmMediaInstanceStatusError]\n"); // } } //} //libvlc_media_release(ctxPtr->m); #endif #if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0) libvlc_video_set_callbacks(ctxPtr->mp, lock, unlock, display, ctxPtr); libvlc_video_set_format(ctxPtr->mp, "RV16", width, height, this->surface->pitch); #endif ctxPtr->isPlaying = true; #if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_0) int play_result = libvlc_media_player_play(ctxPtr->mp,&ex); #else int play_result = 0; if(mediaURL.find(HTTP_PREFIX) == 0) { libvlc_media_list_player_play(ctxPtr->mlp); } else { play_result = libvlc_media_player_play(ctxPtr->mp); } // Play //int play_result = 0; //libvlc_media_list_player_play(ctxPtr->mlp); #endif //SDL_Delay(5); if(verboseEnabled) printf("In [%s] Line: %d, play_result [%d]\n",__FUNCTION__,__LINE__,play_result); successLoadingLib = (play_result == 0); } #endif return successLoadingLib; }
/************************************************************************** * new (Public) * * Init an object. **************************************************************************/ libvlc_media_discoverer_t * libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, const char * psz_name, libvlc_exception_t * p_e ) { libvlc_media_discoverer_t * p_mdis; p_mdis = malloc(sizeof(libvlc_media_discoverer_t)); if( !p_mdis ) { libvlc_exception_raise( p_e, "Not enough memory" ); return NULL; } p_mdis->p_libvlc_instance = p_inst; p_mdis->p_mlist = libvlc_media_list_new( p_inst, NULL ); p_mdis->p_mlist->b_read_only = true; p_mdis->running = false; vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 ); p_mdis->p_event_manager = libvlc_event_manager_new( p_mdis, p_inst, NULL ); libvlc_event_manager_register_event_type( p_mdis->p_event_manager, libvlc_MediaDiscovererStarted, NULL ); libvlc_event_manager_register_event_type( p_mdis->p_event_manager, libvlc_MediaDiscovererEnded, NULL ); p_mdis->p_sd = services_discovery_Create( (vlc_object_t*)p_inst->p_libvlc_int, psz_name ); if( !p_mdis->p_sd ) { libvlc_exception_raise( p_e, "Can't find the services_discovery module named '%s'", psz_name ); libvlc_media_list_release( p_mdis->p_mlist ); free( p_mdis ); return NULL; } vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemAdded, services_discovery_item_added, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemRemoved, services_discovery_item_removed, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryStarted, services_discovery_started, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryEnded, services_discovery_ended, p_mdis ); services_discovery_Start( p_mdis->p_sd ); /* Here we go */ return p_mdis; }
void VlcPlugin::playlist_clear( libvlc_exception_t *ex ) { if( libvlc_media_list ) libvlc_media_list_release(libvlc_media_list); libvlc_media_list = libvlc_media_list_new(getVLC(),ex); }
libvlc_media_list_t *VLC::newMediaList() { return libvlc_media_list_new(libvlcInstance); }
/************************************************************************** * new (Public) * * Init an object. **************************************************************************/ libvlc_media_discoverer_t * libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst, const char * psz_name ) { libvlc_media_discoverer_t * p_mdis; p_mdis = malloc(sizeof(libvlc_media_discoverer_t)); if( unlikely(!p_mdis) ) { libvlc_printerr( "Not enough memory" ); return NULL; } p_mdis->p_libvlc_instance = p_inst; p_mdis->p_mlist = libvlc_media_list_new( p_inst ); p_mdis->p_mlist->b_read_only = true; p_mdis->running = false; vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 ); p_mdis->p_event_manager = libvlc_event_manager_new( p_mdis, p_inst ); if( unlikely(p_mdis->p_event_manager == NULL) ) { free( p_mdis ); return NULL; } libvlc_event_manager_register_event_type( p_mdis->p_event_manager, libvlc_MediaDiscovererStarted ); libvlc_event_manager_register_event_type( p_mdis->p_event_manager, libvlc_MediaDiscovererEnded ); p_mdis->p_sd = vlc_sd_Create( (vlc_object_t*)p_inst->p_libvlc_int, psz_name ); if( unlikely(p_mdis->p_sd == NULL) ) { libvlc_printerr( "%s: no such discovery module found", psz_name ); libvlc_media_list_release( p_mdis->p_mlist ); libvlc_event_manager_release( p_mdis->p_event_manager ); free( p_mdis ); return NULL; } vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemAdded, services_discovery_item_added, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemRemoved, services_discovery_item_removed, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryStarted, services_discovery_started, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryEnded, services_discovery_ended, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemRemoveAll, services_discovery_removeall, p_mdis ); /* Here we go */ if( !vlc_sd_Start( p_mdis->p_sd ) ) { libvlc_printerr( "%s: internal module error", p_mdis->p_sd->psz_name ); libvlc_media_list_release( p_mdis->p_mlist ); libvlc_event_manager_release( p_mdis->p_event_manager ); free( p_mdis ); return NULL; } return p_mdis; }
void VideoSource::UpdateSettings() { EnterCriticalSection(&textureLock); isRendering = false; LeaveCriticalSection(&textureLock); if (mediaPlayer) { libvlc_video_set_callbacks(mediaPlayer, nullptr, nullptr, nullptr, nullptr); libvlc_media_player_stop(mediaPlayer); } config->Reload(); hasSetVolume = false; videoSize.x = float(config->width); videoSize.y = float(config->height); if (mediaPlayer == nullptr) { mediaPlayer = libvlc_media_player_new(vlc); libvlc_event_manager_t *em = libvlc_media_player_event_manager(mediaPlayer); libvlc_event_attach(em, libvlc_MediaPlayerEndReached, vlcEvent, this); libvlc_event_attach(em, libvlc_MediaPlayerPlaying, vlcEvent, this); } if (mediaListPlayer == nullptr) { mediaListPlayer = libvlc_media_list_player_new(vlc); libvlc_media_list_player_set_media_player(mediaListPlayer, mediaPlayer); } else { libvlc_media_list_player_stop(mediaListPlayer); } if (mediaList) { libvlc_media_list_lock(mediaList); while(libvlc_media_list_count(mediaList)) { libvlc_media_list_remove_index(mediaList, 0); } libvlc_media_list_unlock(mediaList); } else { mediaList = libvlc_media_list_new(vlc); libvlc_media_list_player_set_media_list(mediaListPlayer, mediaList); } char *utf8PathOrUrl; for(unsigned int i = 0; i < config->playlist.Num(); i++) { String &mediaEntry = config->playlist[i]; String token = mediaEntry.GetToken(1, L':'); // .. Yup. bool isStream = token.Length() >= 2 && token[0] == L'/' && token[1] == L'/'; utf8PathOrUrl = config->playlist[i].CreateUTF8String(); if (utf8PathOrUrl) { libvlc_media_t *media; if (!isStream) { media = libvlc_media_new_path(vlc, utf8PathOrUrl); } else { media = libvlc_media_new_location(vlc, utf8PathOrUrl); } libvlc_media_list_lock(mediaList); libvlc_media_list_add_media(mediaList, media); libvlc_media_list_unlock(mediaList); libvlc_media_release(media); Free(utf8PathOrUrl); } } if (!config->isPlaylistLooping) { remainingVideos = config->playlist.Num(); } libvlc_video_set_callbacks(mediaPlayer, lock, unlock, display, this); libvlc_video_set_format_callbacks(mediaPlayer, videoFormatProxy, videoCleanupProxy); libvlc_media_list_player_set_playback_mode(mediaListPlayer, config->isPlaylistLooping ? libvlc_playback_mode_loop : libvlc_playback_mode_default); if (!audioOutputStreamHandler) { audioOutputStreamHandler = new AudioOutputStreamHandler(vlc, mediaPlayer); } audioOutputStreamHandler->SetOutputParameters( config->audioOutputType, config->audioOutputTypeDevice, config->audioOutputDevice, config->isAudioOutputToStream); audioOutputStreamHandler->SetVolume(config->volume); // set (possibly in vane) the volume. If it doesn't work it will try later until it works // vlc... que pasa amigo hasSetVolume = libvlc_audio_set_volume(mediaPlayer, config->volume) == 0; EnterCriticalSection(&textureLock); isRendering = true; LeaveCriticalSection(&textureLock); libvlc_media_list_player_play(mediaListPlayer); }
NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) { /* prepare VLC command line */ const char *ppsz_argv[32]; int ppsz_argc = 0; #ifndef NDEBUG ppsz_argv[ppsz_argc++] = "--no-plugins-cache"; #endif /* locate VLC module path */ #ifdef XP_MACOSX ppsz_argv[ppsz_argc++] = "--plugin-path=/Library/Internet\\ Plug-Ins/VLC\\ Plugin.plugin/Contents/MacOS/modules"; ppsz_argv[ppsz_argc++] = "--vout=minimal_macosx"; #elif defined(XP_WIN) HKEY h_key; DWORD i_type, i_data = MAX_PATH + 1; char p_data[MAX_PATH + 1]; if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC", 0, KEY_READ, &h_key ) == ERROR_SUCCESS ) { if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type, (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS ) { if( i_type == REG_SZ ) { strcat( p_data, "\\plugins" ); ppsz_argv[ppsz_argc++] = "--plugin-path"; ppsz_argv[ppsz_argc++] = p_data; } } RegCloseKey( h_key ); } ppsz_argv[ppsz_argc++] = "--no-one-instance"; #endif /* XP_MACOSX */ /* common settings */ ppsz_argv[ppsz_argc++] = "-vv"; ppsz_argv[ppsz_argc++] = "--no-stats"; ppsz_argv[ppsz_argc++] = "--no-media-library"; ppsz_argv[ppsz_argc++] = "--intf=dummy"; ppsz_argv[ppsz_argc++] = "--no-video-title-show"; const char *progid = NULL; /* parse plugin arguments */ for( int i = 0; (i < argc) && (ppsz_argc < 32); i++ ) { /* fprintf(stderr, "argn=%s, argv=%s\n", argn[i], argv[i]); */ if( !strcmp( argn[i], "target" ) || !strcmp( argn[i], "mrl") || !strcmp( argn[i], "filename") || !strcmp( argn[i], "src") ) { psz_target = argv[i]; } else if( !strcmp( argn[i], "text" ) ) { free( psz_text ); psz_text = strdup( argv[i] ); } else if( !strcmp( argn[i], "autoplay") || !strcmp( argn[i], "autostart") ) { b_autoplay = boolValue(argv[i]); } else if( !strcmp( argn[i], "fullscreen" ) ) { if( boolValue(argv[i]) ) { ppsz_argv[ppsz_argc++] = "--fullscreen"; } else { ppsz_argv[ppsz_argc++] = "--no-fullscreen"; } } else if( !strcmp( argn[i], "mute" ) ) { if( boolValue(argv[i]) ) { ppsz_argv[ppsz_argc++] = "--volume=0"; } } else if( !strcmp( argn[i], "loop") || !strcmp( argn[i], "autoloop") ) { if( boolValue(argv[i]) ) { ppsz_argv[ppsz_argc++] = "--loop"; } else { ppsz_argv[ppsz_argc++] = "--no-loop"; } } else if( !strcmp( argn[i], "version") || !strcmp( argn[i], "progid") ) { progid = argv[i]; } else if( !strcmp( argn[i], "toolbar" ) ) { /* FIXME: Remove this when toolbar functionality has been implemented on * MacOS X and Win32 for Firefox/Mozilla/Safari. */ #ifdef XP_UNIX b_toolbar = boolValue(argv[i]); #endif } } libvlc_exception_t ex; libvlc_exception_init(&ex); libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv, &ex); if( libvlc_exception_raised(&ex) ) { libvlc_exception_clear(&ex); return NPERR_GENERIC_ERROR; } libvlc_media_list = libvlc_media_list_new(libvlc_instance,&ex); if( libvlc_exception_raised(&ex) ) { libvlc_exception_clear(&ex); return NPERR_GENERIC_ERROR; } /* ** fetch plugin base URL, which is the URL of the page containing the plugin ** this URL is used for making absolute URL from relative URL that may be ** passed as an MRL argument */ NPObject *plugin = NULL; if( NPERR_NO_ERROR == NPN_GetValue(p_browser, NPNVWindowNPObject, &plugin) ) { /* ** is there a better way to get that info ? */ static const char docLocHref[] = "document.location.href"; NPString script; NPVariant result; script.utf8characters = docLocHref; script.utf8length = sizeof(docLocHref)-1; if( NPN_Evaluate(p_browser, plugin, &script, &result) ) { if( NPVARIANT_IS_STRING(result) ) { NPString &location = NPVARIANT_TO_STRING(result); psz_baseURL = (char *) malloc(location.utf8length+1); if( psz_baseURL ) { strncpy(psz_baseURL, location.utf8characters, location.utf8length); psz_baseURL[location.utf8length] = '\0'; } } NPN_ReleaseVariantValue(&result); } NPN_ReleaseObject(plugin); } if( psz_target ) { // get absolute URL from src char *psz_absurl = getAbsoluteURL(psz_target); psz_target = psz_absurl ? psz_absurl : strdup(psz_target); } /* assign plugin script root class */ /* new APIs */ p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass(); return NPERR_NO_ERROR; }
static void test_media_list (const char ** argv, int argc) { libvlc_instance_t *vlc; libvlc_media_t *md, *md1, *md2, *md3, *md4; libvlc_media_list_t *ml; int ret; log ("Testing media_list\n"); vlc = libvlc_new (argc, argv); assert (vlc != NULL); ml = libvlc_media_list_new (vlc); assert (ml != NULL); md1 = libvlc_media_new_path (vlc, "/dev/null"); assert (md1 != NULL); md2 = libvlc_media_new_path (vlc, "/dev/null"); assert (md2 != NULL); md3 = libvlc_media_new_path (vlc, "/dev/null"); assert (md3 != NULL); ret = libvlc_media_list_add_media (ml, md1); assert (!ret); ret = libvlc_media_list_add_media (ml, md2); assert (!ret); assert( libvlc_media_list_count (ml) == 2 ); assert( libvlc_media_list_index_of_item (ml, md1) == 0 ); assert( libvlc_media_list_index_of_item (ml, md2) == 1 ); ret = libvlc_media_list_remove_index (ml, 0); /* removing first item */ assert (!ret); /* test if second item was moved on first place */ assert( libvlc_media_list_index_of_item (ml, md2) == 0 ); ret = libvlc_media_list_add_media (ml, md1); /* add 2 items */ assert (!ret); ret = libvlc_media_list_add_media (ml, md1); assert (!ret); /* there should be 3 pieces */ assert( libvlc_media_list_count (ml) == 3 ); ret = libvlc_media_list_insert_media (ml, md3, 2); assert (!ret); /* there should be 4 pieces */ assert( libvlc_media_list_count (ml) == 4 ); /* test inserting on right place */ assert( libvlc_media_list_index_of_item (ml, md3) == 2 ); /* test right returning descriptor*/ md = libvlc_media_list_item_at_index (ml, 0); assert(md == md2); libvlc_media_release(md); md = libvlc_media_list_item_at_index (ml, 2); assert(md == md3); libvlc_media_release(md); /* test if give errors, when it should */ /* have 4 items, so index 4 should give error */ ret = libvlc_media_list_remove_index (ml, 4); assert (ret == -1); ret = libvlc_media_list_remove_index (ml, 100); assert (ret == -1); ret = libvlc_media_list_remove_index (ml, -1); assert (ret == -1); /* getting non valid items */ libvlc_media_t * p_non_exist = libvlc_media_list_item_at_index (ml, 4); assert (p_non_exist == NULL); p_non_exist = libvlc_media_list_item_at_index (ml, 100); assert (p_non_exist == NULL); p_non_exist = libvlc_media_list_item_at_index (ml, -1); assert (p_non_exist == NULL); md4 = libvlc_media_new_path (vlc, "/dev/null"); assert (md4 != NULL); /* try to find non inserted item */ int i_non_exist = 0; i_non_exist = libvlc_media_list_index_of_item (ml, md4); assert ( i_non_exist == -1 ); libvlc_media_release (md1); libvlc_media_release (md2); libvlc_media_release (md3); libvlc_media_release (md4); libvlc_media_list_release (ml); libvlc_release (vlc); }
/************************************************************************** * new (Public) **************************************************************************/ libvlc_media_discoverer_t * libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name ) { /* podcast SD is a hack and only works with custom playlist callbacks. */ if( !strncasecmp( psz_name, "podcast", 7 ) ) return NULL; libvlc_media_discoverer_t *p_mdis = malloc(sizeof(*p_mdis)); if( unlikely(!p_mdis) ) { libvlc_printerr( "Not enough memory" ); return NULL; } p_mdis->p_libvlc_instance = p_inst; p_mdis->p_mlist = libvlc_media_list_new( p_inst ); p_mdis->p_mlist->b_read_only = true; p_mdis->running = false; vlc_dictionary_init( &p_mdis->catname_to_submedialist, 0 ); p_mdis->p_event_manager = libvlc_event_manager_new( p_mdis ); if( unlikely(p_mdis->p_event_manager == NULL) ) { free( p_mdis ); return NULL; } p_mdis->p_sd = vlc_sd_Create( (vlc_object_t*)p_inst->p_libvlc_int, psz_name ); if( unlikely(p_mdis->p_sd == NULL) ) { libvlc_printerr( "%s: no such discovery module found", psz_name ); libvlc_media_list_release( p_mdis->p_mlist ); libvlc_event_manager_release( p_mdis->p_event_manager ); free( p_mdis ); return NULL; } vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemAdded, services_discovery_item_added, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemRemoved, services_discovery_item_removed, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryStarted, services_discovery_started, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryEnded, services_discovery_ended, p_mdis ); vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ), vlc_ServicesDiscoveryItemRemoveAll, services_discovery_removeall, p_mdis ); libvlc_retain( p_inst ); return p_mdis; }