int transcode_spu_new( sout_stream_t *p_stream, sout_stream_id_t *id ) { sout_stream_sys_t *p_sys = p_stream->p_sys; /* * Open decoder */ /* Initialization of decoder structures */ id->p_decoder->pf_decode_sub = NULL; id->p_decoder->pf_spu_buffer_new = spu_new_buffer; id->p_decoder->pf_spu_buffer_del = spu_del_buffer; id->p_decoder->p_owner = (decoder_owner_sys_t *)p_stream; /* id->p_decoder->p_cfg = p_sys->p_spu_cfg; */ id->p_decoder->p_module = module_need( id->p_decoder, "decoder", "$codec", false ); if( !id->p_decoder->p_module ) { msg_Err( p_stream, "cannot find spu decoder" ); return VLC_EGENERIC; } if( !p_sys->b_soverlay ) { /* Open encoder */ /* Initialization of encoder format structures */ es_format_Init( &id->p_encoder->fmt_in, id->p_decoder->fmt_in.i_cat, id->p_decoder->fmt_in.i_codec ); id->p_encoder->p_cfg = p_sys->p_spu_cfg; id->p_encoder->p_module = module_need( id->p_encoder, "encoder", p_sys->psz_senc, true ); if( !id->p_encoder->p_module ) { module_unneed( id->p_decoder, id->p_decoder->p_module ); msg_Err( p_stream, "cannot find spu encoder (%s)", p_sys->psz_senc ); return VLC_EGENERIC; } } if( !p_sys->p_spu ) p_sys->p_spu = spu_Create( p_stream ); return VLC_SUCCESS; }
bool Dialogs::init() { // Allocate descriptor m_pProvider = (intf_thread_t *)vlc_object_create( getIntf(), sizeof( intf_thread_t ) ); if( m_pProvider == NULL ) return false; // Attach the dialogs provider to its parent interface vlc_object_attach( m_pProvider, getIntf() ); m_pModule = module_need( m_pProvider, "dialogs provider", NULL, false ); if( m_pModule == NULL ) { msg_Err( getIntf(), "no suitable dialogs provider found (hint: compile the qt4 plugin, and make sure it is loaded properly)" ); vlc_object_release( m_pProvider ); m_pProvider = NULL; return false; } /* Register callback for the intf-popupmenu variable */ var_AddCallback( getIntf()->p_libvlc, "intf-popupmenu", PopupMenuCB, this ); return true; }
static filter_t *CreateFilter( vlc_object_t *p_this, es_format_t *p_fmt_in, video_format_t *p_fmt_out, const char *psz_module ) { filter_t *p_filter; p_filter = vlc_custom_create( p_this, sizeof(filter_t), "filter" ); p_filter->pf_video_buffer_new = (picture_t *(*)(filter_t *))video_new_buffer; p_filter->pf_video_buffer_del = (void (*)(filter_t *, picture_t *))video_del_buffer; p_filter->fmt_in = *p_fmt_in; p_filter->fmt_out = *p_fmt_in; p_filter->fmt_out.i_codec = p_fmt_out->i_chroma; p_filter->fmt_out.video = *p_fmt_out; p_filter->p_module = module_need( p_filter, "video filter2", psz_module, false ); if( !p_filter->p_module ) { msg_Dbg( p_filter, "no video filter found" ); DeleteFilter( p_filter ); return NULL; } return p_filter; }
int filter_ConfigureBlend( filter_t *p_blend, int i_dst_width, int i_dst_height, const video_format_t *p_src ) { /* */ if( p_blend->p_module && p_blend->fmt_in.video.i_chroma != p_src->i_chroma ) { /* The chroma is not the same, we need to reload the blend module */ module_unneed( p_blend, p_blend->p_module ); p_blend->p_module = NULL; } /* */ p_blend->fmt_in.i_codec = p_src->i_chroma; p_blend->fmt_in.video = *p_src; /* */ p_blend->fmt_out.video.i_width = p_blend->fmt_out.video.i_visible_width = i_dst_width; p_blend->fmt_out.video.i_height = p_blend->fmt_out.video.i_visible_height = i_dst_height; /* */ if( !p_blend->p_module ) p_blend->p_module = module_need( p_blend, "video blending", NULL, false ); if( !p_blend->p_module ) return VLC_EGENERIC; return VLC_SUCCESS; }
/** * Creates an OpenGL context (and its underlying surface). * * @note In most cases, you should vlc_gl_MakeCurrent() afterward. * * @param wnd window to use as OpenGL surface * @param flags OpenGL context type * @param name module name (or NULL for auto) * @return a new context, or NULL on failure */ vlc_gl_t *vlc_gl_Create(struct vout_window_t *wnd, unsigned flags, const char *name) { vlc_object_t *parent = (vlc_object_t *)wnd; struct vlc_gl_priv_t *glpriv; const char *type; switch (flags /*& VLC_OPENGL_API_MASK*/) { case VLC_OPENGL: type = "opengl"; break; case VLC_OPENGL_ES2: type = "opengl es2"; break; default: return NULL; } glpriv = vlc_custom_create(parent, sizeof (*glpriv), "gl"); if (unlikely(glpriv == NULL)) return NULL; glpriv->gl.surface = wnd; glpriv->gl.module = module_need(&glpriv->gl, type, name, true); if (glpriv->gl.module == NULL) { vlc_object_release(&glpriv->gl); return NULL; } atomic_init(&glpriv->ref_count, 1); return &glpriv->gl; }
static filter_t *CreateFilter( vlc_object_t *p_this, const es_format_t *p_fmt_in, vlc_fourcc_t fmt_out ) { filter_t *p_filter; p_filter = vlc_object_create( p_this, sizeof(filter_t) ); if (unlikely(p_filter == NULL)) return NULL; p_filter->owner.video.buffer_new = (picture_t *(*)(filter_t *))video_new_buffer; es_format_InitFromVideo( &p_filter->fmt_in, &p_fmt_in->video ); es_format_InitFromVideo( &p_filter->fmt_out, &p_fmt_in->video ); p_filter->fmt_in.i_codec = p_filter->fmt_in.video.i_chroma = VLC_CODEC_D3D11_OPAQUE; p_filter->fmt_out.i_codec = p_filter->fmt_out.video.i_chroma = fmt_out; p_filter->p_module = module_need( p_filter, "video filter2", NULL, false ); if( !p_filter->p_module ) { msg_Dbg( p_filter, "no video filter found" ); DeleteFilter( p_filter ); return NULL; } return p_filter; }
/* * XXX name and p_cfg are used (-> do NOT free them) */ static sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_name, config_chain_t *p_cfg, sout_stream_t *p_next) { sout_stream_t *p_stream; assert(psz_name); p_stream = vlc_custom_create( p_sout, sizeof( *p_stream ), "stream out" ); if( !p_stream ) return NULL; p_stream->p_sout = p_sout; p_stream->p_sys = NULL; p_stream->psz_name = psz_name; p_stream->p_cfg = p_cfg; p_stream->p_next = p_next; msg_Dbg( p_sout, "stream=`%s'", p_stream->psz_name ); p_stream->p_module = module_need( p_stream, "sout stream", p_stream->psz_name, true ); if( !p_stream->p_module ) { /* those must be freed by the caller if creation failed */ p_stream->psz_name = NULL; p_stream->p_cfg = NULL; sout_StreamDelete( p_stream ); return NULL; } return p_stream; }
/***************************************************************************** * Open: allocate video thread output method *****************************************************************************/ static int Open( vlc_object_t *p_this ) { vout_thread_t * p_vout = (vout_thread_t *)p_this; /* Allocate structure */ p_vout->p_sys = (struct vout_sys_t*) malloc( sizeof( struct vout_sys_t ) ); if( p_vout->p_sys == NULL ) return( 1 ); p_vout->pf_init = Init; p_vout->pf_end = End; p_vout->pf_manage = Manage; p_vout->pf_render = NULL; //Render; p_vout->pf_display = Display; #ifdef NEED_QTE_MAIN p_vout->p_sys->p_qte_main = module_need( p_this, "gui-helper", "qte", true ); if( p_vout->p_sys->p_qte_main == NULL ) { free( p_vout->p_sys ); return VLC_ENOMOD; } #endif if (OpenDisplay(p_vout)) { msg_Err( p_vout, "Cannot set up qte video output" ); Close(p_this); return( -1 ); } return( 0 ); }
/***************************************************************************** * Wrappers for loading and unloading osd parser modules. *****************************************************************************/ static bool osd_ParserLoad( osd_menu_t *p_menu, const char *psz_file ) { /* Stuff needed for Parser */ p_menu->psz_file = strdup( psz_file ); p_menu->p_image = image_HandlerCreate( p_menu ); if( !p_menu->p_image || !p_menu->psz_file ) { msg_Err( p_menu, "unable to load images, aborting .." ); return false; } else { const char *psz_type; const char *psz_ext = strrchr( p_menu->psz_file, '.' ); if( psz_ext && !strcmp( psz_ext, ".cfg") ) psz_type = "import-osd"; else psz_type = "import-osd-xml"; p_menu->p_parser = module_need( p_menu, "osd parser", psz_type, true ); if( !p_menu->p_parser ) { return false; } } return true; }
static filter_t *CreateFilter( vlc_object_t *p_this, const es_format_t *p_fmt_in, const video_format_t *p_fmt_out ) { filter_t *p_filter; p_filter = vlc_custom_create( p_this, sizeof(filter_t), "filter" ); p_filter->owner.video.buffer_new = filter_new_picture; es_format_Copy( &p_filter->fmt_in, p_fmt_in ); es_format_Copy( &p_filter->fmt_out, p_fmt_in ); video_format_Copy( &p_filter->fmt_out.video, p_fmt_out ); /* whatever the input offset, write at offset 0 in the target image */ p_filter->fmt_out.video.i_x_offset = 0; p_filter->fmt_out.video.i_y_offset = 0; p_filter->fmt_out.i_codec = p_fmt_out->i_chroma; p_filter->p_module = module_need( p_filter, "video converter", NULL, false ); if( !p_filter->p_module ) { msg_Dbg( p_filter, "no video converter found" ); DeleteFilter( p_filter ); return NULL; } return p_filter; }
/** * Allocates a whole server's TLS credentials. * * @param cert_path required (Unicode) path to an x509 certificate, * if NULL, anonymous key exchange will be used. * @param key_path (UTF-8) path to the PKCS private key for the certificate, * if NULL; cert_path will be used. * * @return NULL on error. */ vlc_tls_creds_t * vlc_tls_ServerCreate (vlc_object_t *obj, const char *cert_path, const char *key_path) { vlc_tls_creds_t *srv = vlc_custom_create (obj, sizeof (*srv), "tls creds"); if (unlikely(srv == NULL)) return NULL; var_Create (srv, "tls-x509-cert", VLC_VAR_STRING); var_Create (srv, "tls-x509-key", VLC_VAR_STRING); if (cert_path != NULL) { var_SetString (srv, "tls-x509-cert", cert_path); if (key_path == NULL) key_path = cert_path; var_SetString (srv, "tls-x509-key", key_path); } srv->module = module_need (srv, "tls server", NULL, false ); if (srv->module == NULL) { msg_Err (srv, "TLS server plugin not available"); vlc_object_release (srv); return NULL; } msg_Dbg (srv, "TLS server plugin initialized"); return srv; }
stream_t *vlc_stream_FilterNew( stream_t *p_source, const char *psz_stream_filter ) { stream_t *s; assert( p_source != NULL ); s = vlc_stream_CommonNew( p_source->obj.parent, StreamDelete ); if( s == NULL ) return NULL; s->p_input = p_source->p_input; if( p_source->psz_url != NULL ) { s->psz_url = strdup( p_source->psz_url ); if( unlikely(s->psz_url == NULL) ) goto error; } s->p_source = p_source; /* */ s->p_module = module_need( s, "stream_filter", psz_stream_filter, true ); if( s->p_module == NULL ) goto error; return s; error: stream_CommonDelete( s ); return NULL; }
/* * OSD menu */ int transcode_osd_new( sout_stream_t *p_stream, sout_stream_id_sys_t *id ) { sout_stream_sys_t *p_sys = p_stream->p_sys; id->p_decoder->fmt_in.i_cat = SPU_ES; id->p_encoder->fmt_out.psz_language = strdup( "osd" ); if( p_sys->i_osdcodec != 0 || p_sys->psz_osdenc ) { msg_Dbg( p_stream, "creating osdmenu transcoding from fcc=`%4.4s' " "to fcc=`%4.4s'", (char*)&id->p_encoder->fmt_out.i_codec, (char*)&p_sys->i_osdcodec ); /* Complete destination format */ id->p_encoder->fmt_out.i_codec = p_sys->i_osdcodec; /* Open encoder */ es_format_Init( &id->p_encoder->fmt_in, id->p_decoder->fmt_in.i_cat, VLC_CODEC_YUVA ); id->p_encoder->fmt_in.psz_language = strdup( "osd" ); id->p_encoder->p_cfg = p_sys->p_osd_cfg; id->p_encoder->p_module = module_need( id->p_encoder, "encoder", p_sys->psz_osdenc, true ); if( !id->p_encoder->p_module ) { msg_Err( p_stream, "cannot find spu encoder (%s)", p_sys->psz_osdenc ); goto error; } /* open output stream */ id->id = sout_StreamIdAdd( p_stream->p_next, &id->p_encoder->fmt_out ); id->b_transcode = true; if( !id->id ) goto error; } else { msg_Dbg( p_stream, "not transcoding a stream (fcc=`%4.4s')", (char*)&id->p_decoder->fmt_out.i_codec ); id->id = sout_StreamIdAdd( p_stream->p_next, &id->p_decoder->fmt_out ); id->b_transcode = false; if( !id->id ) goto error; } if( !p_sys->p_spu ) p_sys->p_spu = spu_Create( p_stream ); return VLC_SUCCESS; error: msg_Err( p_stream, "starting osd encoding thread failed" ); if( id->p_encoder->p_module ) module_unneed( id->p_encoder, id->p_encoder->p_module ); p_sys->b_osd = false; return VLC_EGENERIC; }
/***************************************************************************** * sout_AccessOutNew: allocate a new access out *****************************************************************************/ sout_access_out_t *sout_AccessOutNew( vlc_object_t *p_sout, const char *psz_access, const char *psz_name ) { sout_access_out_t *p_access; char *psz_next; p_access = vlc_custom_create( p_sout, sizeof( *p_access ), "access out" ); if( !p_access ) return NULL; psz_next = config_ChainCreate( &p_access->psz_access, &p_access->p_cfg, psz_access ); free( psz_next ); p_access->psz_path = strdup( psz_name ? psz_name : "" ); p_access->p_sys = NULL; p_access->pf_seek = NULL; p_access->pf_read = NULL; p_access->pf_write = NULL; p_access->pf_control = NULL; p_access->p_module = NULL; p_access->p_module = module_need( p_access, "sout access", p_access->psz_access, true ); if( !p_access->p_module ) { free( p_access->psz_access ); free( p_access->psz_path ); vlc_object_release( p_access ); return( NULL ); } return p_access; }
static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry ) { vlc_object_t *p_this = VLC_OBJECT( p_storage ); int i_ret = VLC_EGENERIC; if ( ! p_entry->psz_source_module ) return i_ret; /* Query origin module for download path */ addons_finder_t *p_finder = vlc_object_create( p_this, sizeof( addons_finder_t ) ); if( !p_finder ) return VLC_ENOMEM; module_t *p_module = module_need( p_finder, "addons finder", p_entry->psz_source_module, true ); if( p_module ) { if ( p_finder->pf_retrieve( p_finder, p_entry ) == VLC_SUCCESS ) { /* Do things while retrieved data is here */ vlc_mutex_lock( &p_entry->lock ); i_ret = InstallAllFiles( p_storage, p_entry ); vlc_mutex_unlock( &p_entry->lock ); /* !Do things while retrieved data is here */ } module_unneed( p_finder, p_module ); } vlc_object_release( p_finder ); return i_ret; }
int input_item_WriteMeta( vlc_object_t *obj, input_item_t *p_item ) { meta_export_t *p_export = (meta_export_t *) vlc_custom_create( obj, sizeof( *p_export ), "meta writer" ); // sunqueen modify if( p_export == NULL ) return VLC_ENOMEM; p_export->p_item = p_item; int type; vlc_mutex_lock( &p_item->lock ); type = p_item->i_type; vlc_mutex_unlock( &p_item->lock ); if( type != ITEM_TYPE_FILE ) goto error; char *psz_uri = input_item_GetURI( p_item ); p_export->psz_file = make_path( psz_uri ); if( p_export->psz_file == NULL ) msg_Err( p_export, "cannot write meta to remote media %s", psz_uri ); free( psz_uri ); if( p_export->psz_file == NULL ) goto error; module_t *p_mod = module_need( p_export, "meta writer", NULL, false ); if( p_mod ) module_unneed( p_export, p_mod ); vlc_object_release( p_export ); return VLC_SUCCESS; error: vlc_object_release( p_export ); return VLC_EGENERIC; }
static filter_t *CreateFilter (vlc_object_t *obj, const char *type, const char *name, filter_owner_sys_t *owner, const audio_sample_format_t *infmt, const audio_sample_format_t *outfmt) { filter_t *filter = vlc_custom_create (obj, sizeof (*filter), type); if (unlikely(filter == NULL)) return NULL; filter->owner.sys = owner; filter->fmt_in.audio = *infmt; filter->fmt_in.i_codec = infmt->i_format; filter->fmt_out.audio = *outfmt; filter->fmt_out.i_codec = outfmt->i_format; filter->p_module = module_need (filter, type, name, false); if (filter->p_module == NULL) { /* If probing failed, formats shall not have been modified. */ assert (AOUT_FMTS_IDENTICAL(&filter->fmt_in.audio, infmt)); assert (AOUT_FMTS_IDENTICAL(&filter->fmt_out.audio, outfmt)); vlc_object_release (filter); filter = NULL; } else assert (filter->pf_audio_filter != NULL); return filter; }
sql_t *sql_Create( vlc_object_t *p_this, const char *psz_name, const char* psz_host, int i_port, const char* psz_user, const char* psz_pass ) { sql_t *p_sql; p_sql = ( sql_t * ) vlc_custom_create( p_this, sizeof( sql_t ), VLC_OBJECT_GENERIC, "sql" ); if( !p_sql ) { msg_Err( p_this, "unable to create sql object" ); return NULL; } vlc_object_attach( p_sql, p_this ); p_sql->psz_host = strdup( psz_host ); p_sql->psz_user = strdup( psz_user ); p_sql->psz_pass = strdup( psz_pass ); p_sql->i_port = i_port; p_sql->p_module = module_need( p_sql, "sql", psz_name, psz_name && *psz_name ); if( !p_sql->p_module ) { free( p_sql->psz_host ); free( p_sql->psz_user ); free( p_sql->psz_pass ); vlc_object_release( p_sql ); msg_Err( p_this, "SQL provider not found" ); return NULL; } return p_sql; }
/** * Creates an OpenGL context (and its underlying surface). * * @note In most cases, you should vlc_gl_MakeCurrent() afterward. * * @param wnd window to use as OpenGL surface * @param flags OpenGL context type * @param name module name (or NULL for auto) * @return a new context, or NULL on failure */ vlc_gl_t *vlc_gl_Create(struct vout_window_t *wnd, unsigned flags, const char *name) { vlc_object_t *parent = (vlc_object_t *)wnd; vlc_gl_t *gl; const char *type; switch (flags /*& VLC_OPENGL_API_MASK*/) { case VLC_OPENGL: type = "opengl"; break; case VLC_OPENGL_ES2: type = "opengl es2"; break; default: return NULL; } gl = vlc_custom_create(parent, sizeof (*gl), "gl"); if (unlikely(gl == NULL)) return NULL; gl->surface = wnd; gl->module = module_need(gl, type, name, true); if (gl->module == NULL) { vlc_object_release(gl); return NULL; } return gl; }
static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt ) { decoder_t *p_dec; p_dec = vlc_custom_create( p_this, sizeof( *p_dec ), "image decoder" ); if( p_dec == NULL ) return NULL; p_dec->p_module = NULL; es_format_Init( &p_dec->fmt_in, VIDEO_ES, fmt->i_chroma ); es_format_Init( &p_dec->fmt_out, VIDEO_ES, 0 ); p_dec->fmt_in.video = *fmt; p_dec->b_frame_drop_allowed = false; p_dec->pf_vout_format_update = video_update_format; p_dec->pf_vout_buffer_new = video_new_buffer; /* Find a suitable decoder module */ p_dec->p_module = module_need( p_dec, "decoder", "$codec", false ); if( !p_dec->p_module ) { msg_Err( p_dec, "no suitable decoder module for fourcc `%4.4s'. " "VLC probably does not support this image format.", (char*)&p_dec->fmt_in.i_codec ); DeleteDecoder( p_dec ); return NULL; } return p_dec; }
static int transcode_video_encoder_open( sout_stream_t *p_stream, sout_stream_id_t *id ) { sout_stream_sys_t *p_sys = p_stream->p_sys; msg_Dbg( p_stream, "destination (after video filters) %ix%i", id->p_encoder->fmt_in.video.i_width, id->p_encoder->fmt_in.video.i_height ); id->p_encoder->p_module = module_need( id->p_encoder, "encoder", p_sys->psz_venc, true ); if( !id->p_encoder->p_module ) { msg_Err( p_stream, "cannot find video encoder (module:%s fourcc:%4.4s)", p_sys->psz_venc ? p_sys->psz_venc : "any", (char *)&p_sys->i_vcodec ); return VLC_EGENERIC; } id->p_encoder->fmt_in.video.i_chroma = id->p_encoder->fmt_in.i_codec; /* */ id->p_encoder->fmt_out.i_codec = vlc_fourcc_GetCodec( VIDEO_ES, id->p_encoder->fmt_out.i_codec ); id->id = sout_StreamIdAdd( p_stream->p_next, &id->p_encoder->fmt_out ); if( !id->id ) { msg_Err( p_stream, "cannot add this stream" ); return VLC_EGENERIC; } return VLC_SUCCESS; }
int playlist_Export( playlist_t * p_playlist, const char *psz_filename, bool b_playlist, const char *psz_type ) { playlist_export_t *p_export = vlc_custom_create( p_playlist, sizeof( *p_export ), "playlist export" ); if( unlikely(p_export == NULL) ) return VLC_ENOMEM; msg_Dbg( p_export, "saving %s to file %s", b_playlist ? "playlist" : "media library", psz_filename ); int ret = VLC_EGENERIC; /* Prepare the playlist_export_t structure */ p_export->base_url = vlc_path2uri( psz_filename, NULL ); p_export->p_file = vlc_fopen( psz_filename, "wt" ); if( p_export->p_file == NULL ) { msg_Err( p_export, "could not create playlist file %s: %s", psz_filename, vlc_strerror_c(errno) ); goto out; } module_t *p_module; /* And call the module ! All work is done now */ playlist_Lock( p_playlist ); p_export->p_root = b_playlist ? p_playlist->p_playing : p_playlist->p_media_library; p_module = module_need( p_export, "playlist export", psz_type, true ); playlist_Unlock( p_playlist ); if( p_module != NULL ) { module_unneed( p_export, p_module ); if( !ferror( p_export->p_file ) ) ret = VLC_SUCCESS; else msg_Err( p_playlist, "could not write playlist file: %s", vlc_strerror_c(errno) ); } else msg_Err( p_playlist, "could not export playlist" ); fclose( p_export->p_file ); out: free( p_export->base_url ); vlc_object_release( p_export ); return ret; }
static int StreamExtractorAttach( stream_t** source, char const* identifier, char const* module_name ) { const bool extractor = identifier != NULL; char const* capability = extractor ? "stream_extractor" : "stream_directory"; struct stream_extractor_private* priv = vlc_custom_create( (*source)->obj.parent, sizeof( *priv ), capability ); if( unlikely( !priv ) ) return VLC_ENOMEM; if( extractor ) { priv->object = VLC_OBJECT( &priv->extractor ); priv->pf_init = se_InitStream; priv->pf_clean = se_CleanStream; priv->extractor.source = *source; priv->extractor.identifier = strdup( identifier ); if( unlikely( !priv->extractor.identifier ) ) goto error; } else { priv->object = VLC_OBJECT( &priv->directory ); priv->pf_init = se_InitDirectory; priv->pf_clean = NULL; priv->directory.source = *source; } priv->module = module_need( priv->object, capability, module_name, true ); if( !priv->module || se_AttachWrapper( priv, *source ) ) goto error; *source = priv->wrapper; return VLC_SUCCESS; error: se_Release( priv ); return VLC_EGENERIC; }
int playlist_Export( playlist_t * p_playlist, const char *psz_filename, playlist_item_t *p_export_root, const char *psz_type ) { if( p_export_root == NULL ) return VLC_EGENERIC; playlist_export_t *p_export = vlc_custom_create( p_playlist, sizeof( *p_export ), "playlist export" ); if( unlikely(p_export == NULL) ) return VLC_ENOMEM; msg_Dbg( p_export, "saving %s to file %s", p_export_root->p_input->psz_name, psz_filename ); int ret = VLC_EGENERIC; /* Prepare the playlist_export_t structure */ p_export->p_root = p_export_root; p_export->psz_filename = psz_filename; p_export->p_file = vlc_fopen( psz_filename, "wt" ); if( p_export->p_file == NULL ) { msg_Err( p_export, "could not create playlist file %s: %s", psz_filename, vlc_strerror_c(errno) ); goto out; } module_t *p_module; /* And call the module ! All work is done now */ playlist_Lock( p_playlist ); p_module = module_need( p_export, "playlist export", psz_type, true ); playlist_Unlock( p_playlist ); if( p_module != NULL ) { module_unneed( p_export, p_module ); if( !ferror( p_export->p_file ) ) ret = VLC_SUCCESS; else msg_Err( p_playlist, "could not write playlist file: %s", vlc_strerror_c(errno) ); } else msg_Err( p_playlist, "could not export playlist" ); fclose( p_export->p_file ); out: vlc_object_release( p_export ); return ret; }
/***************************************************************************** * Render: displays previously rendered output *****************************************************************************/ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) { filter_sys_t *p_sys = p_filter->p_sys; filter_t *p_blend; if( p_sys->b_done ) return p_pic; p_blend = vlc_object_create( p_filter, sizeof(filter_t) ); if( !p_blend ) { picture_Release( p_pic ); return NULL; } p_blend->fmt_out.video = p_sys->p_base_image->format; p_blend->fmt_in.video = p_sys->p_blend_image->format; p_blend->p_module = module_need( p_blend, "video blending", NULL, false ); if( !p_blend->p_module ) { picture_Release( p_pic ); vlc_object_delete(p_blend); return NULL; } vlc_tick_t time = vlc_tick_now(); for( int i_iter = 0; i_iter < p_sys->i_loops; ++i_iter ) { p_blend->pf_video_blend( p_blend, p_sys->p_base_image, p_sys->p_blend_image, 0, 0, p_sys->i_alpha ); } time = vlc_tick_now() - time; msg_Info( p_filter, "Blended %d images in %f sec", p_sys->i_loops, secf_from_vlc_tick(time) ); msg_Info( p_filter, "Speed is: %f images/second, %f pixels/second", (float) p_sys->i_loops / time * CLOCK_FREQ, (float) p_sys->i_loops / time * CLOCK_FREQ * p_sys->p_blend_image->p[Y_PLANE].i_visible_pitch * p_sys->p_blend_image->p[Y_PLANE].i_visible_lines ); module_unneed( p_blend, p_blend->p_module ); vlc_object_delete(p_blend); p_sys->b_done = true; return p_pic; }
/***************************************************************************** * access_New: *****************************************************************************/ access_t *access_New( vlc_object_t *p_obj, input_thread_t *p_parent_input, const char *psz_access, const char *psz_demux, const char *psz_location ) { access_t *p_access = vlc_custom_create( p_obj, sizeof (*p_access), "access" ); if( p_access == NULL ) return NULL; /* */ p_access->p_input = p_parent_input; p_access->psz_access = strdup( psz_access ); p_access->psz_location = strdup( psz_location ); p_access->psz_filepath = get_path( psz_location ); p_access->psz_demux = strdup( psz_demux ); if( p_access->psz_access == NULL || p_access->psz_location == NULL || p_access->psz_demux == NULL ) goto error; msg_Dbg( p_obj, "creating access '%s' location='%s', path='%s'", psz_access, psz_location, p_access->psz_filepath ? p_access->psz_filepath : "(null)" ); p_access->pf_read = NULL; p_access->pf_block = NULL; p_access->pf_seek = NULL; p_access->pf_control = NULL; p_access->p_sys = NULL; access_InitFields( p_access ); p_access->p_module = module_need( p_access, "access", psz_access, true ); if( p_access->p_module == NULL ) goto error; return p_access; error: free( p_access->psz_access ); free( p_access->psz_location ); free( p_access->psz_filepath ); free( p_access->psz_demux ); vlc_object_release( p_access ); return NULL; }
/** * Creates an XML reader. * @param obj parent VLC object * @param stream stream to read XML from * @return NULL on error. */ xml_reader_t *xml_ReaderCreate(vlc_object_t *obj, stream_t *stream) { xml_reader_t *reader; reader = vlc_custom_create(obj, sizeof(*reader), "xml reader"); reader->p_stream = stream; reader->p_module = module_need(reader, "xml reader", NULL, false); if (unlikely(reader->p_module == NULL)) { msg_Err(reader, "XML reader not found"); vlc_object_delete(reader); return NULL; } return reader; }
/** * Creates a software amplifier. */ audio_mixer_t *aout_MixerNew(vlc_object_t *obj, vlc_fourcc_t format) { audio_mixer_t *mixer = vlc_custom_create(obj, sizeof (*mixer), "mixer"); if (unlikely(mixer == NULL)) return NULL; mixer->format = format; mixer->mix = NULL; mixer->module = module_need(mixer, "audio mixer", NULL, false); if (mixer->module == NULL) { vlc_object_release(mixer); mixer = NULL; } return mixer; }
/***************************************************************************** * xml_Create: ***************************************************************************** * Create an instance of an XML parser. * Returns NULL on error. *****************************************************************************/ xml_t *xml_Create( vlc_object_t *p_this ) { xml_t *p_xml; p_xml = vlc_custom_create( p_this, sizeof( *p_xml ), "xml" ); p_xml->p_module = module_need( p_xml, "xml", NULL, false ); if( !p_xml->p_module ) { vlc_object_delete(p_xml); msg_Err( p_this, "XML provider not found" ); return NULL; } return p_xml; }
/** * Allocates a client's TLS credentials and shakes hands through the network. * This is a blocking network operation. * * @param fd stream socket through which to establish the secure communication * layer. * @param psz_hostname Server Name Indication to pass to the server, or NULL. * * @return NULL on error. **/ tls_session_t * tls_ClientCreate (vlc_object_t *obj, int fd, const char *psz_hostname) { tls_session_t *cl; int val; cl = (tls_session_t *)vlc_custom_create (obj, sizeof (*cl), VLC_OBJECT_GENERIC, "tls client"); if (cl == NULL) return NULL; var_Create (cl, "tls-server-name", VLC_VAR_STRING); if (psz_hostname != NULL) { msg_Dbg (cl, "requested server name: %s", psz_hostname); var_SetString (cl, "tls-server-name", psz_hostname); } else msg_Dbg (cl, "requested anonymous server"); vlc_object_attach (cl, obj); cl->p_module = module_need (cl, "tls client", NULL, false ); if (cl->p_module == NULL) { msg_Err (cl, "TLS client plugin not available"); vlc_object_release (cl); return NULL; } cl->pf_set_fd (cl, fd); do val = cl->pf_handshake (cl); while (val > 0); if (val == 0) { msg_Dbg (cl, "TLS client session initialized"); return cl; } msg_Err (cl, "TLS client session handshake error"); module_unneed (cl, cl->p_module); vlc_object_release (cl); return NULL; }