void MediaServer::_buildPlaylist( Container* parent ) { for ( unsigned int i = 0; i < parent->getNumContainers(); i++ ) { Container* container = parent->getContainer( i ); input_item_t* p_input_item = input_item_New( _p_sd, "vlc://nop", parent->getTitle() ); input_item_AddSubItem( parent->getInputItem(), p_input_item ); container->setInputItem( p_input_item ); _buildPlaylist( container ); } for ( unsigned int i = 0; i < parent->getNumItems(); i++ ) { Item* item = parent->getItem( i ); input_item_t* p_input_item = input_item_New( _p_sd, item->getResource(), item->getTitle() ); assert( p_input_item ); input_item_AddSubItem( parent->getInputItem(), p_input_item ); item->setInputItem( p_input_item ); } }
static void test_cancel_thumbnail( libvlc_instance_t* p_vlc ) { vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create( VLC_OBJECT( p_vlc->p_libvlc_int ) ); assert( p_thumbnailer != NULL ); struct test_ctx ctx; vlc_cond_init( &ctx.cond ); vlc_mutex_init( &ctx.lock ); const char* psz_mrl = "mock://video_track_count=1;audio_track_count=1"; input_item_t* p_item = input_item_New( psz_mrl, "mock item" ); assert( p_item != NULL ); vlc_mutex_lock( &ctx.lock ); int res = 0; vlc_thumbnailer_request_t* p_req = vlc_thumbnailer_RequestByTime( p_thumbnailer, VLC_TICK_FROM_SEC( 1 ), VLC_THUMBNAILER_SEEK_PRECISE, p_item, VLC_TICK_INVALID, thumbnailer_callback_cancel, &ctx ); vlc_thumbnailer_Cancel( p_thumbnailer, p_req ); while ( ctx.b_done == false ) { vlc_tick_t timeout = vlc_tick_now() + VLC_TICK_FROM_SEC( 1 ); res = vlc_cond_timedwait( &ctx.cond, &ctx.lock, timeout ); assert( res != ETIMEDOUT ); } vlc_mutex_unlock( &ctx.lock ); input_item_Release( p_item ); vlc_thumbnailer_Release( p_thumbnailer ); }
static int ReadDir(access_t* p_access, input_item_node_t* p_node) { using ItemsHeap = std::map<uint64_t, input_item_t*>; const auto& torrent = p_access->p_sys->torrent; const auto& metadata = torrent.torrent_metadata(); const auto& files = metadata.files(); ItemsHeap items; for (auto i = 0; i < metadata.num_files(); ++i) { const auto f = metadata.file_at(i); const auto psz_uri = torrent.uri().c_str(); const auto psz_name = files.file_name(i); const auto psz_option = "torrent-file-index=" + std::to_string(i); auto p_item = input_item_New(psz_uri, psz_name.c_str()); input_item_AddOption(p_item, psz_option.c_str(), VLC_INPUT_OPTION_TRUSTED); items[f.size] = p_item; } std::for_each(items.rbegin(), items.rend(), [p_node](ItemsHeap::value_type& p) { input_item_node_AppendItem(p_node, p.second); input_item_Release(p.second); }); return VLC_SUCCESS; }
/************************************************************************** * 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; }
/************************************************************************** * add_file_content (Public) **************************************************************************/ int libvlc_media_list_add_file_content( libvlc_media_list_t * p_mlist, const char * psz_uri ) { input_item_t * p_input_item; libvlc_media_t * p_md; p_input_item = input_item_New( psz_uri, _("Media Library") ); if( !p_input_item ) { libvlc_printerr( "Not enough memory" ); return -1; } p_md = libvlc_media_new_from_input_item( p_mlist->p_libvlc_instance, p_input_item ); if( !p_md ) { vlc_gc_decref( p_input_item ); return -1; } if( libvlc_media_list_add_media( p_mlist, p_md ) ) { #warning Missing error handling! /* printerr and leaks */ return -1; } input_Read( p_mlist->p_libvlc_instance->p_libvlc_int, p_input_item ); return 0; }
void Playtree::insertItems( VarTree& elem, const list<string>& files, bool start ) { bool first = true; VarTree* p_elem = &elem; playlist_item_t* p_node = NULL; int i_pos = -1; playlist_Lock( m_pPlaylist ); if( p_elem->getId() == m_pPlaylist->p_local_category->i_id ) { p_node = m_pPlaylist->p_local_category; i_pos = 0; } else if( p_elem->getId() == m_pPlaylist->p_ml_category->i_id ) { p_node = m_pPlaylist->p_ml_category; i_pos = 0; } else if( p_elem->size() && p_elem->isExpanded() ) { p_node = playlist_ItemGetById( m_pPlaylist, p_elem->getId() ); i_pos = 0; } else { p_node = playlist_ItemGetById( m_pPlaylist, p_elem->parent()->getId() ); i_pos = p_elem->getIndex(); i_pos++; } if( !p_node ) goto fin; for( list<string>::const_iterator it = files.begin(); it != files.end(); ++it, i_pos++, first = false ) { char* psz_uri = make_URI( it->c_str(), NULL ); if( !psz_uri ) continue; input_item_t* pItem = input_item_New( psz_uri, NULL ); if( pItem ) { int i_mode = PLAYLIST_APPEND; if( first && start ) i_mode |= PLAYLIST_GO; playlist_NodeAddInput( m_pPlaylist, pItem, p_node, i_mode, i_pos, pl_Locked ); } free( psz_uri ); } fin: playlist_Unlock( m_pPlaylist ); }
/* <genrelist> * <genre name="the name"></genre> * ... * </genrelist> **/ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader, input_item_node_t *p_input_node ) { const char *node; char *psz_name = NULL; /* genre name */ int type; while( (type = xml_ReaderNextNode( p_xml_reader, &node )) > 0 ) { switch( type ) { case XML_READER_STARTELEM: { if( !strcmp( node, "genre" ) ) { // Read the attributes const char *name, *value; while( (name = xml_ReaderNextAttr( p_xml_reader, &value )) ) { if( !strcmp( name, "name" ) ) { free(psz_name); psz_name = strdup( value ); } else msg_Warn( p_demux, "unexpected attribute %s in <%s>", name, node ); } } break; } case XML_READER_ENDELEM: if( !strcmp( node, "genre" ) && psz_name != NULL ) { char* psz_mrl; if( asprintf( &psz_mrl, SHOUTCAST_BASE_URL "?genre=%s", psz_name ) != -1 ) { input_item_t *p_input; vlc_xml_decode( psz_mrl ); p_input = input_item_New( psz_mrl, psz_name ); input_item_CopyOptions( p_input_node->p_item, p_input ); free( psz_mrl ); input_item_node_AppendItem( p_input_node, p_input ); vlc_gc_decref( p_input ); } FREENULL( psz_name ); } break; } } free( psz_name ); return 0; }
static void test_thumbnails( libvlc_instance_t* p_vlc ) { vlc_thumbnailer_t* p_thumbnailer = vlc_thumbnailer_Create( VLC_OBJECT( p_vlc->p_libvlc_int ) ); assert( p_thumbnailer != NULL ); struct test_ctx ctx; vlc_cond_init( &ctx.cond ); vlc_mutex_init( &ctx.lock ); for ( size_t i = 0; i < sizeof(test_params) / sizeof(test_params[0]); ++i) { char* psz_mrl; ctx.test_idx = i; ctx.b_done = false; if ( asprintf( &psz_mrl, "mock://video_track_count=%u;audio_track_count=%u" ";length=%" PRId64 ";video_chroma=ARGB;add_video_track_at=%" PRId64, test_params[i].i_nb_video_tracks, test_params[i].i_nb_audio_tracks, MOCK_DURATION, test_params[i].i_add_video_track_at ) < 0 ) assert( !"Failed to allocate mock mrl" ); input_item_t* p_item = input_item_New( psz_mrl, "mock item" ); assert( p_item != NULL ); vlc_mutex_lock( &ctx.lock ); int res = 0; if ( test_params[i].b_use_pos ) { vlc_thumbnailer_RequestByPos( p_thumbnailer, test_params[i].f_pos, test_params[i].b_fast_seek ? VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE, p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx ); } else { vlc_thumbnailer_RequestByTime( p_thumbnailer, test_params[i].i_time, test_params[i].b_fast_seek ? VLC_THUMBNAILER_SEEK_FAST : VLC_THUMBNAILER_SEEK_PRECISE, p_item, test_params[i].i_timeout, thumbnailer_callback, &ctx ); } while ( ctx.b_done == false ) { vlc_tick_t timeout = vlc_tick_now() + VLC_TICK_FROM_SEC( 1 ); res = vlc_cond_timedwait( &ctx.cond, &ctx.lock, timeout ); assert( res != ETIMEDOUT ); } vlc_mutex_unlock( &ctx.lock ); input_item_Release( p_item ); free( psz_mrl ); } vlc_thumbnailer_Release( p_thumbnailer ); }
int playlist_MLLoad( playlist_t *p_playlist ) { input_item_t *p_input; char *psz_datadir = config_GetUserDir( VLC_DATA_DIR ); if( !psz_datadir ) /* XXX: This should never happen */ { msg_Err( p_playlist, "no data directory, cannot load media library") ; return VLC_EGENERIC; } char *psz_file; if( asprintf( &psz_file, "%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 ) psz_file = NULL; free( psz_datadir ); if( psz_file == NULL ) return VLC_ENOMEM; /* lousy check for media library file */ struct stat st; if( vlc_stat( psz_file, &st ) ) { free( psz_file ); return VLC_EGENERIC; } char *psz_uri = vlc_path2uri( psz_file, "file/xspf-open" ); free( psz_file ); if( psz_uri == NULL ) return VLC_ENOMEM; p_input = input_item_New( psz_uri, _("Media Library") ); free( psz_uri ); if( p_input == NULL ) return VLC_EGENERIC; PL_LOCK; if( p_playlist->p_media_library->p_input ) vlc_gc_decref( p_playlist->p_media_library->p_input ); p_playlist->p_media_library->p_input = p_input; vlc_event_attach( &p_input->event_manager, vlc_InputItemSubItemTreeAdded, input_item_subitem_tree_added, p_playlist ); PL_UNLOCK; vlc_object_t *dummy = vlc_object_create( p_playlist, sizeof (*dummy) ); var_Create( dummy, "meta-file", VLC_VAR_VOID ); input_Read( dummy, p_input ); vlc_object_release( dummy ); vlc_event_detach( &p_input->event_manager, vlc_InputItemSubItemTreeAdded, input_item_subitem_tree_added, p_playlist ); return VLC_SUCCESS; }
void OpenDialog::finish( bool b_enqueue = false ) { toggleVisible(); if( i_action_flag == SELECT ) { accept(); return; } /* Sort alphabetically */ itemsMRL.sort(); /* Go through the item list */ for( int i = 0; i < itemsMRL.size(); i++ ) { bool b_start = !i && !b_enqueue; input_item_t *p_input; p_input = input_item_New( qtu( itemsMRL[i] ), NULL ); /* Insert options only for the first element. We don't know how to edit that anyway. */ if( i == 0 ) { /* Take options from the UI, not from what we stored */ QStringList optionsList = ui.advancedLineInput->text().split( " :" ); /* Insert options */ for( int j = 0; j < optionsList.size(); j++ ) { QString qs = colon_unescape( optionsList[j] ); if( !qs.isEmpty() ) { input_item_AddOption( p_input, qtu( qs ), VLC_INPUT_OPTION_TRUSTED ); #ifdef DEBUG_QT msg_Warn( p_intf, "Input option: %s", qtu( qs ) ); #endif } } } /* Switch between enqueuing and starting the item */ /* FIXME: playlist_AddInput() can fail */ playlist_AddInput( THEPL, p_input, PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ), PLAYLIST_END, b_pl ? true : false, pl_Unlocked ); vlc_gc_decref( p_input ); /* Do not add the current MRL if playlist_AddInput fail */ RecentsMRL::getInstance( p_intf )->addRecent( itemsMRL[i] ); } }
static bool parse_track_dict( demux_t *p_demux, input_item_node_t *p_input_node, track_elem_t *p_track, xml_reader_t *p_xml_reader, const char *psz_element, xml_elem_hnd_t *p_handlers ) { VLC_UNUSED(psz_element); VLC_UNUSED(p_handlers); input_item_t *p_new_input = NULL; int i_ret; p_track = new_track(); xml_elem_hnd_t track_elements[] = // sunqueen modify start // { {"array", COMPLEX_CONTENT, {.cmplx = skip_element} }, // {"key", SIMPLE_CONTENT, {.smpl = save_data} }, // {"integer", SIMPLE_CONTENT, {.smpl = save_data} }, // {"string", SIMPLE_CONTENT, {.smpl = save_data} }, // {"date", SIMPLE_CONTENT, {.smpl = save_data} }, { {"array", COMPLEX_CONTENT, {(bool (__cdecl *)(track_elem_t *,const char *,char *))skip_element} }, {"key", SIMPLE_CONTENT, {save_data} }, {"integer", SIMPLE_CONTENT, {save_data} }, {"string", SIMPLE_CONTENT, {save_data} }, {"date", SIMPLE_CONTENT, {save_data} }, // sunqueen modify end {"true", SIMPLE_CONTENT, {NULL} }, {"false", SIMPLE_CONTENT, {NULL} }, {NULL, UNKNOWN_CONTENT, {NULL} } }; i_ret = parse_dict( p_demux, p_input_node, p_track, p_xml_reader, "dict", track_elements ); msg_Dbg( p_demux, "name: %s, artist: %s, album: %s, genre: %s, trackNum: %s, location: %s", p_track->name, p_track->artist, p_track->album, p_track->genre, p_track->trackNum, p_track->location ); if( !p_track->location ) { msg_Err( p_demux, "Track needs Location" ); free_track( p_track ); return false; } msg_Info( p_demux, "Adding '%s'", p_track->location ); p_new_input = input_item_New( p_track->location, NULL ); input_item_node_AppendItem( p_input_node, p_new_input ); /* add meta info */ add_meta( p_new_input, p_track ); vlc_gc_decref( p_new_input ); p_demux->p_sys->i_ntracks++; free_track( p_track ); return i_ret; }
static void ParseRequest( services_discovery_t *p_sd ) { services_discovery_sys_t *p_sys = p_sd->p_sys; char *psz_request = p_sys->psz_request; int i; char *psz_tok = strchr( psz_request, ':' ); if( !psz_tok ) return; *psz_tok = '\0'; if( !strcmp( psz_request, "ADD" ) ) { psz_request = psz_tok + 1; for( i = 0; i<p_sys->i_urls; i++ ) if( !strcmp(p_sys->ppsz_urls[i],psz_request) ) break; if( i == p_sys->i_urls ) { INSERT_ELEM( p_sys->ppsz_urls, p_sys->i_urls, p_sys->i_urls, strdup( psz_request ) ); input_item_t *p_input; p_input = input_item_New( p_sd, psz_request, psz_request ); input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED ); INSERT_ELEM( p_sys->pp_items, p_sys->i_items, p_sys->i_items, p_input ); services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ ); INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input, input_CreateAndStart( p_sd, p_input, NULL ) ); SaveUrls( p_sd ); } } else if ( !strcmp( psz_request, "RM" ) ) { psz_request = psz_tok + 1; for( i = 0; i<p_sys->i_urls; i++ ) if( !strcmp(p_sys->ppsz_urls[i],psz_request) ) break; if( i != p_sys->i_urls ) { services_discovery_RemoveItem( p_sd, p_sys->pp_items[i] ); vlc_gc_decref( p_sys->pp_items[i] ); REMOVE_ELEM( p_sys->ppsz_urls, p_sys->i_urls, i ); REMOVE_ELEM( p_sys->pp_items, p_sys->i_items, i ); } SaveUrls( p_sd ); } free( p_sys->psz_request ); p_sys->psz_request = NULL; }
static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { (void)p_this; services_discovery_t *p_sd = p_data; services_discovery_sys_t *p_sys = p_sd->p_sys; (void)psz_var; (void)oldval; char* psz_file = newval.psz_string; if( !psz_file || !*psz_file ) return VLC_EGENERIC; char* psz_uri = make_URI( psz_file, "file" ); input_item_t* p_item = input_item_New( psz_uri, NULL ); if( p_sys->i_type == Picture ) { if( fileType( p_sd, psz_file ) == Picture ) { formatSnapshotItem( p_item ); services_discovery_AddItem( p_sd, p_item, NULL ); msg_Dbg( p_sd, "New snapshot added : %s", psz_file ); } } else if( p_sys->i_type == Audio ) { if( fileType( p_sd, psz_file ) == Audio ) { services_discovery_AddItem( p_sd, p_item, NULL ); msg_Dbg( p_sd, "New recorded audio added : %s", psz_file ); } } else if( p_sys->i_type == Video ) { if( fileType( p_sd, psz_file ) == Video || fileType( p_sd, psz_file ) == Unknown ) { services_discovery_AddItem( p_sd, p_item, NULL ); msg_Dbg( p_sd, "New recorded video added : %s", psz_file ); } } vlc_gc_decref( p_item ); free( psz_uri ); return VLC_SUCCESS; }
/***************************************************************************** * Run: *****************************************************************************/ static void *Run( void *data ) { services_discovery_t *p_sd = data; services_discovery_sys_t *p_sys = p_sd->p_sys; int canc = vlc_savecancel(); int num_dir = sizeof( p_sys->psz_dir ) / sizeof( p_sys->psz_dir[0] ); for( int i = 0; i < num_dir; i++ ) { char* psz_dir = p_sys->psz_dir[i]; /* make sure the directory exists */ struct stat st; if( psz_dir == NULL || utf8_stat( psz_dir, &st ) || !S_ISDIR( st.st_mode ) ) continue; // TODO: make_URI is only for file://, what about dir:// ? // char* psz_uri = make_URI( psz_dir ); char* psz_uri; if( asprintf( &psz_uri, "dir://%s", psz_dir ) == -1 ) continue; input_item_t* p_root = input_item_New( p_sd, psz_uri, NULL ); if( p_sys->i_type == Picture ) input_item_AddOption( p_root, "ignore-filetypes=ini,db,lnk,txt", VLC_INPUT_OPTION_TRUSTED ); input_item_AddOption( p_root, "recursive=collapse", VLC_INPUT_OPTION_TRUSTED ); vlc_event_manager_t *p_em = &p_root->event_manager; vlc_event_attach( p_em, vlc_InputItemSubItemAdded, input_item_subitem_added, p_sd ); input_Read( p_sd, p_root ); vlc_event_detach( p_em, vlc_InputItemSubItemAdded, input_item_subitem_added, p_sd ); vlc_gc_decref( p_root ); free( psz_uri ); } vlc_restorecancel(canc); return NULL; }
/***************************************************************************** * CreateInputItemFromShoutItem: *****************************************************************************/ static input_item_t * CreateInputItemFromShoutItem( services_discovery_t *p_sd, const struct shout_item_t * p_item ) { /* Create the item */ input_item_t *p_input = input_item_New( p_sd, p_item->psz_url, vlc_gettext(p_item->psz_name) ); /* Copy options */ for(int i = 0; p_item->ppsz_options[i] != NULL; i++) input_item_AddOption( p_input, p_item->ppsz_options[i], VLC_INPUT_OPTION_TRUSTED ); input_item_AddOption( p_input, "no-playlist-autostart", VLC_INPUT_OPTION_TRUSTED ); return p_input; }
playlist_item_t *RecentsMRL::toPlaylist(int length) { playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG, NULL); if ( p_node_recent == NULL ) return NULL; if (length == 0 || recents.count() < length) length = recents.count(); for (int i = 0; i < length; i++) { input_item_t *p_input = input_item_New(qtu(recents.at(i)), NULL); playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END, false); } return p_node_recent; }
static void add_to_playlist(intf_thread_t *intf, const char *uri, bool play_now, int options_count, const char *const *options) { vlc_playlist_t *playlist = vlc_intf_GetMainPlaylist(intf); input_item_t *media = input_item_New(uri, NULL); if (!media) return; input_item_AddOptions(media, options_count, options, VLC_INPUT_OPTION_TRUSTED); vlc_playlist_Lock(playlist); vlc_playlist_AppendOne(playlist, media); if (play_now) vlc_playlist_Start(playlist); vlc_playlist_Unlock(playlist); input_item_Release(media); }
bool MediaServerList::addServer( MediaServer* s ) { input_item_t* p_input_item = NULL; if ( getServer( s->getUDN() ) != 0 ) return false; msg_Dbg( _p_sd, "Adding server '%s'", s->getFriendlyName() ); services_discovery_t* p_sd = _p_sd; p_input_item = input_item_New( p_sd, "vlc://nop", s->getFriendlyName() ); s->setInputItem( p_input_item ); services_discovery_AddItem( p_sd, p_input_item, NULL ); _list.push_back( s ); return true; }
bool MediaServerList::addServer( MediaServer* p_server ) { input_item_t* p_input_item = NULL; if ( getServer( p_server->getUDN() ) != 0 ) return false; msg_Dbg( _p_sd, "Adding server '%s' with uuid '%s'", p_server->getFriendlyName(), p_server->getUDN() ); p_input_item = input_item_New( "vlc://nop", p_server->getFriendlyName() ); input_item_SetDescription( p_input_item, p_server->getUDN() ); p_server->setInputItem( p_input_item ); services_discovery_AddItem( _p_sd, p_input_item, NULL ); _list.push_back( p_server ); return true; }
/***************************************************************************** * Run: *****************************************************************************/ static void *Run( void *data ) { services_discovery_t *p_sd = data; services_discovery_sys_t *p_sys = p_sd->p_sys; int num_dir = sizeof( p_sys->psz_dir ) / sizeof( p_sys->psz_dir[0] ); for( int i = 0; i < num_dir; i++ ) { char* psz_dir = p_sys->psz_dir[i]; /* make sure the directory exists */ struct stat st; if( psz_dir == NULL || vlc_stat( psz_dir, &st ) || !S_ISDIR( st.st_mode ) ) continue; char* psz_uri = vlc_path2uri( psz_dir, "file" ); input_item_t* p_root = input_item_New( psz_uri, NULL ); if( p_sys->i_type == Picture ) input_item_AddOption( p_root, "ignore-filetypes=ini,db,lnk,txt", VLC_INPUT_OPTION_TRUSTED|VLC_INPUT_OPTION_UNIQUE ); input_item_AddOption( p_root, "recursive=collapse", VLC_INPUT_OPTION_TRUSTED|VLC_INPUT_OPTION_UNIQUE ); vlc_event_manager_t *p_em = &p_root->event_manager; vlc_event_attach( p_em, vlc_InputItemSubItemTreeAdded, input_subnode_added, p_sd ); input_Read( p_sd, p_root ); vlc_event_detach( p_em, vlc_InputItemSubItemTreeAdded, input_subnode_added, p_sd ); input_item_Release( p_root ); free( psz_uri ); } return NULL; }
/************************************************************************** * 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; }
static int ReadDVD( stream_t *p_stream, input_item_node_t *node ) { const char *psz_location = StreamLocation(p_stream); char *psz_url = strndup( psz_location, strlen( psz_location ) - 12 ); if( !psz_url ) return VLC_ENOMEM; input_item_t *p_input = input_item_New( psz_url, psz_url ); if( p_input ) { input_item_AddOption( p_input, "demux=dvd", VLC_INPUT_OPTION_TRUSTED ); input_item_node_AppendItem( node, p_input ); input_item_Release( p_input ); } free( psz_url ); return VLC_SUCCESS; }
static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track ) { input_item_t *p_input; char *psz_string; char *extension; extension = rindex( p_track->filename, '.' ); if( asprintf( &psz_string, "mtp://%"PRIu32":%"PRIu8":%"PRIu16":%d%s", p_sd->p_sys->i_bus, p_sd->p_sys->i_dev, p_sd->p_sys->i_product_id, p_track->item_id, extension ) == -1 ) { msg_Err( p_sd, "Error adding %s, skipping it", p_track->filename ); return; } if( ( p_input = input_item_New( psz_string, p_track->title ) ) == NULL ) { msg_Err( p_sd, "Error adding %s, skipping it", p_track->filename ); free( psz_string ); return; } free( psz_string ); input_item_SetArtist( p_input, p_track->artist ); input_item_SetGenre( p_input, p_track->genre ); input_item_SetAlbum( p_input, p_track->album ); if( asprintf( &psz_string, "%d", p_track->tracknumber ) != -1 ) { input_item_SetTrackNum( p_input, psz_string ); free( psz_string ); } if( asprintf( &psz_string, "%d", p_track->rating ) != -1 ) { input_item_SetRating( p_input, psz_string ); free( psz_string ); } input_item_SetDate( p_input, p_track->date ); input_item_SetDuration( p_input, p_track->duration * 1000 ); services_discovery_AddItem( p_sd, p_input, NULL ); p_sd->p_sys->pp_items[p_sd->p_sys->i_count++] = p_input; }
int playlist_Import( playlist_t *p_playlist, const char *psz_file ) { input_item_t *p_input; char *psz_uri = vlc_path2uri( psz_file, NULL ); if( psz_uri == NULL ) return VLC_EGENERIC; p_input = input_item_New( psz_uri, psz_file ); free( psz_uri ); playlist_AddInput( p_playlist, p_input, false, true ); vlc_object_t *dummy = vlc_object_create( p_playlist, sizeof (*dummy) ); var_Create( dummy, "meta-file", VLC_VAR_VOID ); int ret = input_Read( dummy, p_input ); vlc_object_release( dummy ); return ret; }
static int Demux( demux_t *p_demux ) { char *psz_url, *psz_dir; psz_dir = strrchr( p_demux->psz_location, '/' ); if( psz_dir != NULL ) psz_dir[1] = '\0'; if( asprintf( &psz_url, "dvd://%s", p_demux->psz_location ) == -1 ) return 0; input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_t *p_input = input_item_New( psz_url, psz_url ); input_item_PostSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); vlc_gc_decref(p_current_input); free( psz_url ); return 0; /* Needed for correct operation of go back */ }
/************************************************************************** * Create a new media descriptor object **************************************************************************/ libvlc_media_t *libvlc_media_new_location( libvlc_instance_t *p_instance, const char * psz_mrl ) { input_item_t * p_input_item; libvlc_media_t * p_md; p_input_item = input_item_New( psz_mrl, NULL ); if (!p_input_item) { libvlc_printerr( "Not enough memory" ); return NULL; } p_md = libvlc_media_new_from_input_item( p_instance, p_input_item ); /* The p_input_item is retained in libvlc_media_new_from_input_item */ vlc_gc_decref( p_input_item ); return p_md; }
static int Demux( demux_t *p_demux ) { size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_path ) - strlen( "VIDEO_TS.IFO" ); char *psz_url; psz_url = malloc( len+1 ); if( !psz_url ) return 0; snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path ); input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url ); input_item_PostSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); vlc_gc_decref(p_current_input); free( psz_url ); return 0; /* Needed for correct operation of go back */ }
static int DemuxDVD_VR( demux_t *p_demux ) { char *psz_url = strdup( p_demux->psz_path ); if( !psz_url ) return 0; size_t len = strlen( psz_url ); strncpy( psz_url + len - 12, "VR_MOVIE.VRO", 12 ); input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url ); input_item_PostSubItem( p_current_input, p_input ); vlc_gc_decref( p_input ); vlc_gc_decref(p_current_input); free( psz_url ); return 0; /* Needed for correct operation of go back */ }
/* * Builds playlist based on available input items. */ void MediaServer::_buildPlaylist( Container* p_parent, input_item_node_t *p_input_node ) { bool b_send = p_input_node == NULL; if( b_send ) p_input_node = input_item_node_Create( p_parent->getInputItem() ); for ( unsigned int i = 0; i < p_parent->getNumContainers(); i++ ) { Container* p_container = p_parent->getContainer( i ); input_item_t* p_input_item = input_item_New( "vlc://nop", p_container->getTitle() ); input_item_node_t *p_new_node = input_item_node_AppendItem( p_input_node, p_input_item ); p_container->setInputItem( p_input_item ); _buildPlaylist( p_container, p_new_node ); } for ( unsigned int i = 0; i < p_parent->getNumItems(); i++ ) { Item* p_item = p_parent->getItem( i ); input_item_t* p_input_item = input_item_NewExt( p_item->getResource(), p_item->getTitle(), 0, NULL, 0, p_item->getDuration() ); assert( p_input_item ); input_item_node_AppendItem( p_input_node, p_input_item ); p_item->setInputItem( p_input_item ); } if( b_send ) input_item_node_PostAndDelete( p_input_node ); }
static int ReadDVD_VR( stream_t *p_stream, input_item_node_t *node ) { const char *psz_location = StreamLocation(p_stream); size_t len = strlen( psz_location ); char *psz_url = strdup( psz_location ); if( unlikely( psz_url == NULL ) ) return VLC_EGENERIC; strcpy( &psz_url[len - 12], "VR_MOVIE.VRO" ); input_item_t *p_input = input_item_New( psz_url, psz_url ); if( p_input ) { input_item_node_AppendItem( node, p_input ); input_item_Release( p_input ); } free( psz_url ); return VLC_SUCCESS; }