您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ stream_Delete函数代码示例

51自学网 2021-06-03 08:28:51
  C++
这篇教程C++ stream_Delete函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中stream_Delete函数的典型用法代码示例。如果您正苦于以下问题:C++ stream_Delete函数的具体用法?C++ stream_Delete怎么用?C++ stream_Delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了stream_Delete函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Android_ParseSystemFonts

static int Android_ParseSystemFonts( filter_t *p_filter, const char *psz_path ){    int i_ret = VLC_SUCCESS;    stream_t *p_stream = stream_UrlNew( p_filter, psz_path );    if( !p_stream )        return VLC_EGENERIC;    xml_reader_t *p_xml = xml_ReaderCreate( p_filter, p_stream );    if( !p_xml )    {        stream_Delete( p_stream );        return VLC_EGENERIC;    }    const char *p_node;    int i_type;    while( ( i_type = xml_ReaderNextNode( p_xml, &p_node ) ) > 0 )    {        if( i_type == XML_READER_STARTELEM && !strcasecmp( "family", p_node ) )        {            if( ( i_ret = Android_ParseFamily( p_filter, p_xml ) ) )                break;        }    }    xml_ReaderDelete( p_xml );    stream_Delete( p_stream );    return i_ret;}
开发者ID:0xheart0,项目名称:vlc,代码行数:31,


示例2: vlclua_dofile

/** Replacement for luaL_dofile, using VLC's input capabilities */int vlclua_dofile( vlc_object_t *p_this, lua_State *L, const char *uri ){    if( !strstr( uri, "://" ) )        return luaL_dofile( L, uri );    if( !strncasecmp( uri, "file://", 7 ) )        return luaL_dofile( L, uri + 7 );    stream_t *s = stream_UrlNew( p_this, uri );    if( !s )    {        return 1;    }    int64_t i_size = stream_Size( s );    char *p_buffer = ( i_size > 0 ) ? malloc( i_size ) : NULL;    if( !p_buffer )    {        // FIXME: read the whole stream until we reach the end (if no size)        stream_Delete( s );        return 1;    }    int64_t i_read = stream_Read( s, p_buffer, (int) i_size );    int i_ret = ( i_read == i_size ) ? 0 : 1;    if( !i_ret )        i_ret = luaL_loadbuffer( L, p_buffer, (size_t) i_size, uri );    if( !i_ret )        i_ret = lua_pcall( L, 0, LUA_MULTRET, 0 );    stream_Delete( s );    free( p_buffer );    return i_ret;}
开发者ID:banketree,项目名称:faplayer,代码行数:30,


示例3: Import_WPL

int Import_WPL( vlc_object_t* p_this ){    demux_t* p_demux = (demux_t*)p_this;    CHECK_FILE();    if( !demux_IsPathExtension( p_demux, ".wpl" ) &&        !demux_IsPathExtension( p_demux, ".zpl" ) )        return VLC_EGENERIC;    DEMUX_INIT_COMMON();    demux_sys_t* p_sys = p_demux->p_sys;    uint8_t *p_peek;    ssize_t i_peek = stream_Peek( p_demux->s, (const uint8_t **) &p_peek, 2048 );    if( unlikely( i_peek <= 0 ) )    {        Close_WPL( p_this );        return VLC_EGENERIC;    }    stream_t *p_probestream = stream_MemoryNew( p_demux->s, p_peek, i_peek, true );    if( unlikely( !p_probestream ) )    {        Close_WPL( p_this );        return VLC_EGENERIC;    }    p_sys->p_reader = xml_ReaderCreate( p_this, p_probestream );    if ( !p_sys->p_reader )    {        msg_Err( p_demux, "Failed to create an XML reader" );        Close_WPL( p_this );        stream_Delete( p_probestream );        return VLC_EGENERIC;    }    const int i_flags = p_sys->p_reader->i_flags;    p_sys->p_reader->i_flags |= OBJECT_FLAGS_QUIET;    const char* psz_name;    int type = xml_ReaderNextNode( p_sys->p_reader, &psz_name );    p_sys->p_reader->i_flags = i_flags;    if ( type != XML_READER_STARTELEM || strcasecmp( psz_name, "smil" ) )    {        msg_Err( p_demux, "Invalid WPL playlist. Root element should have been <smil>" );        Close_WPL( p_this );        stream_Delete( p_probestream );        return VLC_EGENERIC;    }    p_sys->p_reader = xml_ReaderReset( p_sys->p_reader, p_demux->s );    stream_Delete( p_probestream );    msg_Dbg( p_demux, "Found valid WPL playlist" );    return VLC_SUCCESS;}
开发者ID:J861449197,项目名称:vlc,代码行数:56,


示例4: main

int main(void){    ssize_t val;    char buf[16];    bool b;    test_init();    vlc = libvlc_new(0, NULL);    assert(vlc != NULL);    parent = VLC_OBJECT(vlc->p_libvlc_int);    s = vlc_stream_fifo_New(parent);    assert(s != NULL);    val = stream_Control(s, STREAM_CAN_SEEK, &b);    assert(val == VLC_SUCCESS && !b);    val = stream_GetSize(s, &(uint64_t){ 0 });    assert(val < 0);    val = stream_Control(s, STREAM_GET_PTS_DELAY, &(int64_t){ 0 });    assert(val == VLC_SUCCESS);    stream_Delete(s);    vlc_stream_fifo_Close(s);    s = vlc_stream_fifo_New(parent);    assert(s != NULL);    val = vlc_stream_fifo_Write(s, "123", 3);    vlc_stream_fifo_Close(s);    val = stream_Read(s, buf, sizeof (buf));    assert(val == 3);    assert(memcmp(buf, "123", 3) == 0);    val = stream_Read(s, buf, sizeof (buf));    assert(val == 0);    stream_Delete(s);    s = vlc_stream_fifo_New(parent);    assert(s != NULL);    val = vlc_stream_fifo_Write(s, "Hello ", 6);    assert(val == 6);    val = vlc_stream_fifo_Write(s, "world!/n", 7);    assert(val == 7);    val = vlc_stream_fifo_Write(s, "blahblah", 8);    assert(val == 8);    val = stream_Read(s, buf, 13);    assert(val == 13);    assert(memcmp(buf, "Hello world!/n", 13) == 0);    stream_Delete(s);    val = vlc_stream_fifo_Write(s, "cough cough", 11);    assert(val == -1 && errno == EPIPE);    vlc_stream_fifo_Close(s);    libvlc_release(vlc);    return 0;}
开发者ID:DaemonSnake,项目名称:vlc,代码行数:56,


示例5: VLC_OBJECT

stream_t *stream_DemuxNew( demux_t *p_demux, const char *psz_demux, es_out_t *out ){    vlc_object_t *p_obj = VLC_OBJECT(p_demux);    /* We create a stream reader, and launch a thread */    stream_t     *s;    stream_sys_t *p_sys;    s = stream_CommonNew( p_obj );    if( s == NULL )        return NULL;    s->p_input = p_demux->p_input;    s->pf_read   = DStreamRead;    s->pf_control= DStreamControl;    s->pf_destroy= DStreamDelete;    s->p_sys = p_sys = malloc( sizeof( *p_sys) );    if( !s->p_sys )    {        stream_Delete( s );        return NULL;    }    p_sys->i_pos = 0;    p_sys->out = out;    p_sys->p_block = NULL;    p_sys->psz_name = strdup( psz_demux );    p_sys->stats.position = 0.;    p_sys->stats.length = 0;    p_sys->stats.time = 0;    /* decoder fifo */    if( ( p_sys->p_fifo = block_FifoNew() ) == NULL )    {        stream_Delete( s );        free( p_sys->psz_name );        free( p_sys );        return NULL;    }    atomic_init( &p_sys->active, true );    vlc_mutex_init( &p_sys->lock );    if( vlc_clone( &p_sys->thread, DStreamThread, s, VLC_THREAD_PRIORITY_INPUT ) )    {        vlc_mutex_destroy( &p_sys->lock );        block_FifoRelease( p_sys->p_fifo );        stream_Delete( s );        free( p_sys->psz_name );        free( p_sys );        return NULL;    }    return s;}
开发者ID:rohilsurana,项目名称:vlc,代码行数:54,


示例6: InstallFile

static int InstallFile( addons_storage_t *p_this, const char *psz_downloadlink,                        const char *psz_dest ){    stream_t *p_stream;    FILE *p_destfile;    char buffer[1<<10];    int i_read = 0;    p_stream = stream_UrlNew( p_this, psz_downloadlink );    if( !p_stream )    {        msg_Err( p_this, "Failed to access Addon download url %s", psz_downloadlink );        return VLC_EGENERIC;    }    char *psz_path = strdup( psz_dest );    if ( !psz_path )    {        stream_Delete( p_stream );        return VLC_ENOMEM;    }    char *psz_buf = strrchr( psz_path, DIR_SEP_CHAR );    if( psz_buf )    {        *++psz_buf = '/0';        /* ensure directory exists */        if( !EMPTY_STR( psz_path ) ) recursive_mkdir( VLC_OBJECT(p_this), psz_path );        free( psz_path );    }    p_destfile = vlc_fopen( psz_dest, "w" );    if( !p_destfile )    {        msg_Err( p_this, "Failed to open Addon storage file %s", psz_dest );        stream_Delete( p_stream );        return VLC_EGENERIC;    }    while ( ( i_read = stream_Read( p_stream, &buffer, 1<<10 ) ) > 0 )    {        if ( fwrite( &buffer, i_read, 1, p_destfile ) < 1 )        {            msg_Err( p_this, "Failed to write to Addon file" );            fclose( p_destfile );            stream_Delete( p_stream );            return VLC_EGENERIC;        }    }    fclose( p_destfile );    stream_Delete( p_stream );    return VLC_SUCCESS;}
开发者ID:LTNGlobal-opensource,项目名称:vlc-sdi,代码行数:53,


示例7: Find

static int Find( addons_finder_t *p_finder ){    bool b_done = false;    while ( !b_done )    {        char *psz_uri = NULL;        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"/xml" ) ) return VLC_ENOMEM;        b_done = true;        stream_t *p_stream = stream_UrlNew( p_finder, psz_uri );        free( psz_uri );        if ( !p_stream ) return VLC_EGENERIC;        if ( ! ParseCategoriesInfo( p_finder, p_stream ) )        {            /* no more entries have been read: was last page or error */            b_done = true;        }        stream_Delete( p_stream );    }    return VLC_SUCCESS;}
开发者ID:sorbits,项目名称:vlc,代码行数:26,


示例8: stream_close

static voidstream_close( struct reader *p_reader ){    stream_Delete( p_reader->u.s );    libvlc_release( p_reader->p_data );    free( p_reader );}
开发者ID:743848887,项目名称:vlc,代码行数:7,


示例9: StreamDelete

static void StreamDelete( stream_t *s ){    module_unneed( s, s->p_module );    if( s->p_source )        stream_Delete( s->p_source );}
开发者ID:0xheart0,项目名称:vlc,代码行数:7,


示例10: Seek

static int Seek(access_t *access, uint64_t position){    access_sys_t *sys = access->p_sys;    const rar_file_t *file = sys->file;    if (position > file->real_size)        position = file->real_size;    /* Search the chunk */    const rar_file_chunk_t *old_chunk = sys->chunk;    for (int i = 0; i < file->chunk_count; i++) {        sys->chunk = file->chunk[i];        if (position < sys->chunk->cummulated_size + sys->chunk->size)            break;    }    access->info.i_pos = position;    access->info.b_eof = false;    const uint64_t offset = sys->chunk->offset +                            (position - sys->chunk->cummulated_size);    if (strcmp(old_chunk->mrl, sys->chunk->mrl)) {        if (sys->s)            stream_Delete(sys->s);        sys->s = stream_UrlNew(access, sys->chunk->mrl);    }    return sys->s ? stream_Seek(sys->s, offset) : VLC_EGENERIC;}
开发者ID:Ackhuman,项目名称:vlc,代码行数:28,


示例11: Open

static int Open(vlc_object_t *object){    access_t *access = (access_t*)object;    if (!strchr(access->psz_location, '|'))        return VLC_EGENERIC;    char *base = strdup(access->psz_location);    if (!base)        return VLC_EGENERIC;    char *name = strchr(base, '|');    *name++ = '/0';    decode_URI(base);    stream_t *s = stream_UrlNew(access, base);    if (!s)        goto error;    int count;    rar_file_t **files;    if (RarProbe(s) || RarParse(s, &count, &files) || count <= 0)        goto error;    rar_file_t *file = NULL;    for (int i = 0; i < count; i++) {        if (!file && !strcmp(files[i]->name, name))            file = files[i];        else            RarFileDelete(files[i]);    }    free(files);    if (!file)        goto error;    access_sys_t *sys = access->p_sys = malloc(sizeof(*sys));    sys->s    = s;    sys->file = file;    access->pf_read    = Read;    access->pf_block   = NULL;    access->pf_control = Control;    access->pf_seek    = Seek;    access_InitFields(access);    access->info.i_size = file->size;    rar_file_chunk_t dummy = {        .mrl = base,    };    sys->chunk = &dummy;    Seek(access, 0);    free(base);    return VLC_SUCCESS;error:    if (s)        stream_Delete(s);    free(base);    return VLC_EGENERIC;}
开发者ID:Ackhuman,项目名称:vlc,代码行数:59,


示例12: RarStreamClose

void RarStreamClose(vlc_object_t *object){    stream_t *s = (stream_t*)object;    stream_sys_t *sys = s->p_sys;    stream_Delete(sys->payload);    free(sys);}
开发者ID:839687571,项目名称:vlc-2.2.1.32-2013,代码行数:8,


示例13: Close

static void Close(vlc_object_t *object){    access_t *access = (access_t*)object;    access_sys_t *sys = access->p_sys;    if (sys->s)        stream_Delete(sys->s);    RarFileDelete(sys->file);    free(sys);}
开发者ID:Ackhuman,项目名称:vlc,代码行数:10,


示例14: cancelDoAcoustIdWebRequest

static void cancelDoAcoustIdWebRequest( void *p_arg ){    struct webrequest_t *p_request = (struct webrequest_t *) p_arg;    if ( p_request->p_stream )        stream_Delete( p_request->p_stream );    if ( p_request->psz_url )        free( p_request->psz_url );    if ( p_request->p_buffer )        free( p_request->p_buffer );}
开发者ID:371816210,项目名称:vlc_vlc,代码行数:10,


示例15: SwitchCallback

static int SwitchCallback(struct archive *p_archive, void *p_object, void *p_object2){    VLC_UNUSED(p_archive);    callback_data_t *p_data = (callback_data_t *) p_object;    callback_data_t *p_nextdata = (callback_data_t *) p_object2;    access_sys_t *p_sys = p_data->p_access->p_sys;    msg_Dbg(p_data->p_access, "opening next volume %s", p_nextdata->psz_uri);    stream_Delete(p_sys->p_stream);    p_sys->p_stream = stream_UrlNew(p_nextdata->p_access, p_nextdata->psz_uri);    return p_sys->p_stream ? ARCHIVE_OK : ARCHIVE_FATAL;}
开发者ID:9034725985,项目名称:vlc,代码行数:12,


示例16: CloseCallback

static int CloseCallback(struct archive *p_archive, void *p_object){    VLC_UNUSED(p_archive);    callback_data_t *p_data = (callback_data_t *) p_object;    access_sys_t *p_sys = p_data->p_access->p_sys;    if (p_sys->p_stream)    {        stream_Delete(p_sys->p_stream);        p_sys->p_stream = NULL;    }    return ARCHIVE_OK;}
开发者ID:9034725985,项目名称:vlc,代码行数:14,


示例17: stream_UrlNew

static picture_t *ImageReadUrl( image_handler_t *p_image, const char *psz_url,                                video_format_t *p_fmt_in,                                video_format_t *p_fmt_out ){    block_t *p_block;    picture_t *p_pic;    stream_t *p_stream = NULL;    int i_size;    p_stream = stream_UrlNew( p_image->p_parent, psz_url );    if( !p_stream )    {        msg_Dbg( p_image->p_parent, "could not open %s for reading",                 psz_url );        return NULL;    }    i_size = stream_Size( p_stream );    p_block = block_New( p_image->p_parent, i_size );    stream_Read( p_stream, p_block->p_buffer, i_size );    if( !p_fmt_in->i_chroma )    {        char *psz_mime = NULL;        stream_Control( p_stream, STREAM_GET_CONTENT_TYPE, &psz_mime );        if( psz_mime )            p_fmt_in->i_chroma = image_Mime2Fourcc( psz_mime );        free( psz_mime );    }    stream_Delete( p_stream );    if( !p_fmt_in->i_chroma )    {        /* Try to guess format from file name */        p_fmt_in->i_chroma = image_Ext2Fourcc( psz_url );    }    p_pic = ImageRead( p_image, p_block, p_fmt_in, p_fmt_out );    return p_pic;}
开发者ID:Flameeyes,项目名称:vlc,代码行数:44,


示例18: Open

//.........这里部分代码省略.........            {                if (s_path.find_last_of(DIR_SEP_CHAR) > 0)                {                    s_path = s_path.substr(0,s_path.find_last_of(DIR_SEP_CHAR));                }            }            DIR *p_src_dir = vlc_opendir(s_path.c_str());            if (p_src_dir != NULL)            {                const char *psz_file;                while ((psz_file = vlc_readdir(p_src_dir)) != NULL)                {                    if (strlen(psz_file) > 4)                    {                        s_filename = s_path + DIR_SEP_CHAR + psz_file;#if defined(_WIN32) || defined(__OS2__)                        if (!strcasecmp(s_filename.c_str(), p_demux->psz_file))#else                        if (!s_filename.compare(p_demux->psz_file))#endif                        {                            continue; // don't reuse the original opened file                        }                        if (!s_filename.compare(s_filename.length() - 3, 3, "mkv") ||                            !s_filename.compare(s_filename.length() - 3, 3, "mka"))                        {                            // test whether this file belongs to our family                            const uint8_t *p_peek;                            bool          file_ok = false;                            char          *psz_url = vlc_path2uri( s_filename.c_str(), "file" );                            stream_t      *p_file_stream = stream_UrlNew(                                                            p_demux,                                                            psz_url );                            /* peek the begining */                            if( p_file_stream &&                                stream_Peek( p_file_stream, &p_peek, 4 ) >= 4                                && p_peek[0] == 0x1a && p_peek[1] == 0x45 &&                                p_peek[2] == 0xdf && p_peek[3] == 0xa3 ) file_ok = true;                            if ( file_ok )                            {                                vlc_stream_io_callback *p_file_io = new vlc_stream_io_callback( p_file_stream, true );                                EbmlStream *p_estream = new EbmlStream(*p_file_io);                                p_stream = p_sys->AnalyseAllSegmentsFound( p_demux, p_estream );                                if ( p_stream == NULL )                                {                                    msg_Dbg( p_demux, "the file '%s' will not be used", s_filename.c_str() );                                    delete p_estream;                                    delete p_file_io;                                }                                else                                {                                    p_stream->p_io_callback = p_file_io;                                    p_stream->p_estream = p_estream;                                    p_sys->streams.push_back( p_stream );                                }                            }                            else                            {                                if( p_file_stream ) {                                    stream_Delete( p_file_stream );                                }                                msg_Dbg( p_demux, "the file '%s' cannot be opened", s_filename.c_str() );                            }                            free( psz_url );                        }                    }                }                closedir( p_src_dir );            }        }        p_sys->PreloadFamily( *p_segment );    }    else if (b_need_preload)        msg_Warn( p_demux, "This file references other files, you may want to enable the preload of local directory");    if ( !p_sys->PreloadLinked() ||         !p_sys->PreparePlayback( NULL ) )    {        msg_Err( p_demux, "cannot use the segment" );        goto error;    }    p_sys->FreeUnused();    p_sys->InitUi();    return VLC_SUCCESS;error:    delete p_sys;    return VLC_EGENERIC;}
开发者ID:QuincyPYoung,项目名称:vlc,代码行数:101,


示例19: DoAcoustIdWebRequest

int DoAcoustIdWebRequest( vlc_object_t *p_obj, acoustid_fingerprint_t *p_data ){    int i_ret;    int i_status;    struct webrequest_t request = { NULL, NULL, NULL };    if ( !p_data->psz_fingerprint ) return VLC_SUCCESS;    i_ret = asprintf( & request.psz_url,              "http://fingerprint.videolan.org/acoustid.php?meta=recordings+tracks+usermeta+releases&duration=%d&fingerprint=%s",              p_data->i_duration, p_data->psz_fingerprint );    if ( i_ret < 1 ) return VLC_EGENERIC;    vlc_cleanup_push( cancelDoAcoustIdWebRequest, &request );    msg_Dbg( p_obj, "Querying AcoustID from %s", request.psz_url );    request.p_stream = stream_UrlNew( p_obj, request.psz_url );    if ( !request.p_stream )    {        i_status = VLC_EGENERIC;        goto cleanup;    }    /* read answer */    i_ret = 0;    for( ;; )    {        int i_read = 65536;        if( i_ret >= INT_MAX - i_read )            break;        request.p_buffer = realloc_or_free( request.p_buffer, 1 + i_ret + i_read );        if( !request.p_buffer )        {            i_status = VLC_ENOMEM;            goto cleanup;        }        i_read = stream_Read( request.p_stream, &request.p_buffer[i_ret], i_read );        if( i_read <= 0 )            break;        i_ret += i_read;    }    stream_Delete( request.p_stream );    request.p_stream = NULL;    request.p_buffer[ i_ret ] = 0;    int i_canc = vlc_savecancel();    if ( ParseJson( p_obj, request.p_buffer, & p_data->results ) )    {        msg_Dbg( p_obj, "results count == %d", p_data->results.count );    } else {        msg_Dbg( p_obj, "No results" );    }    vlc_restorecancel( i_canc );    i_status = VLC_SUCCESS;cleanup:    vlc_cleanup_run( );    return i_status;}
开发者ID:371816210,项目名称:vlc_vlc,代码行数:63,


示例20: RarStreamOpen

int RarStreamOpen(vlc_object_t *object){    stream_t *s = (stream_t*)object;    if (RarProbe(s->p_source))        return VLC_EGENERIC;    int count;    rar_file_t **files;    const int64_t position = stream_Tell(s->p_source);    if ((RarParse(s->p_source, &count, &files, false) &&         RarParse(s->p_source, &count, &files, true )) || count == 0 )    {        stream_Seek(s->p_source, position);        msg_Info(s, "Invalid or unsupported RAR archive");        free(files);        return VLC_EGENERIC;    }    /* TODO use xspf to have node for directories     * Reusing WriteXSPF from the zip access is probably a good idea     * (becareful about '/' and '/'.     */    char *mrl;    if (asprintf(&mrl, "%s://%s", s->psz_access, s->psz_path)< 0)        mrl = NULL;    char *base;    char *encoded = mrl ? encode_URI_component(mrl) : NULL;    free(mrl);    if (!encoded || asprintf(&base, "rar://%s", encoded) < 0)        base = NULL;    free(encoded);    char *data = strdup("#EXTM3U/n");    for (int i = 0; i < count; i++) {        rar_file_t *f = files[i];        char *next;        if (base && data &&            asprintf(&next, "%s"                            "#EXTINF:,,%s/n"                            "%s|%s/n",                            data, f->name, base, f->name) >= 0) {            free(data);            data = next;        }        RarFileDelete(f);    }    free(base);    free(files);    if (!data)        return VLC_EGENERIC;    stream_t *payload = stream_MemoryNew(s, (uint8_t*)data, strlen(data), false);    if (!payload) {        free(data);        return VLC_EGENERIC;    }    s->pf_read = Read;    s->pf_peek = Peek;    s->pf_control = Control;    stream_sys_t *sys = s->p_sys = malloc(sizeof(*sys));    if (!sys) {        stream_Delete(payload);        return VLC_ENOMEM;    }    sys->payload = payload;    char *tmp;    if (asprintf(&tmp, "%s.m3u", s->psz_path) < 0) {        RarStreamClose(object);        return VLC_ENOMEM;    }    free(s->psz_path);    s->psz_path = tmp;    return VLC_SUCCESS;}
开发者ID:839687571,项目名称:vlc-2.2.1.32-2013,代码行数:79,


示例21: RarAccessOpen

int RarAccessOpen(vlc_object_t *object){    access_t *access = (access_t*)object;    const char *name = strchr(access->psz_location, '|');    if (name == NULL)        return VLC_EGENERIC;    char *base = strndup(access->psz_location, name - access->psz_location);    if (unlikely(base == NULL))        return VLC_ENOMEM;    name++;    decode_URI(base);    stream_t *s = stream_UrlNew(access, base);    if (!s || RarProbe(s))        goto error;    struct    {        int filescount;        rar_file_t **files;        unsigned int i_nbvols;    } newscheme = { 0, NULL, 0 }, oldscheme = { 0, NULL, 0 }, *p_scheme;    if (RarParse(s, &newscheme.filescount, &newscheme.files, &newscheme.i_nbvols, false)            || newscheme.filescount < 1 || newscheme.i_nbvols < 2 )    {        /* We might want to lookup old naming scheme, could be a part1.rar,part1.r00 */        stream_Seek(s, 0);        RarParse(s, &oldscheme.filescount, &oldscheme.files, &oldscheme.i_nbvols, true);    }    if (oldscheme.filescount >= newscheme.filescount && oldscheme.i_nbvols > newscheme.i_nbvols)    {        for (int i = 0; i < newscheme.filescount; i++)            RarFileDelete(newscheme.files[i]);        free(newscheme.files);        p_scheme = &oldscheme;        msg_Dbg(s, "using rar old naming for %d files nbvols %u", p_scheme->filescount, oldscheme.i_nbvols);    }    else if (newscheme.filescount)    {        for (int i = 0; i < oldscheme.filescount; i++)            RarFileDelete(oldscheme.files[i]);        free(oldscheme.files);        p_scheme = &newscheme;        msg_Dbg(s, "using rar new naming for %d files nbvols %u", p_scheme->filescount, oldscheme.i_nbvols);    }    else    {        msg_Info(s, "Invalid or unsupported RAR archive");        for (int i = 0; i < oldscheme.filescount; i++)            RarFileDelete(oldscheme.files[i]);        free(oldscheme.files);        for (int i = 0; i < newscheme.filescount; i++)            RarFileDelete(newscheme.files[i]);        free(newscheme.files);        goto error;    }    rar_file_t *file = NULL;    for (int i = 0; i < p_scheme->filescount; i++) {        if (!file && !strcmp(p_scheme->files[i]->name, name))            file = p_scheme->files[i];        else            RarFileDelete(p_scheme->files[i]);    }    free(p_scheme->files);    if (!file)        goto error;    access_sys_t *sys = access->p_sys = malloc(sizeof(*sys));    sys->s    = s;    sys->file = file;    access->pf_read    = Read;    access->pf_block   = NULL;    access->pf_control = Control;    access->pf_seek    = Seek;    access_InitFields(access);    rar_file_chunk_t dummy = {        .mrl = base,    };    sys->chunk = &dummy;    Seek(access, 0);    free(base);    return VLC_SUCCESS;error:    if (s)        stream_Delete(s);    free(base);    return VLC_EGENERIC;}
开发者ID:9034725985,项目名称:vlc,代码行数:99,


示例22: RarParse

int RarParse(stream_t *s, int *count, rar_file_t ***file){    *count = 0;    *file = NULL;    const rar_pattern_t *pattern = FindVolumePattern(s->psz_path);    int volume_offset = 0;    char *volume_mrl;    if (asprintf(&volume_mrl, "%s://%s",                 s->psz_access, s->psz_path) < 0)        return VLC_EGENERIC;    stream_t *vol = s;    for (;;) {        /* Skip marker & archive */        if (IgnoreBlock(vol, RAR_BLOCK_MARKER) ||            IgnoreBlock(vol, RAR_BLOCK_ARCHIVE)) {            if (vol != s)                stream_Delete(vol);            free(volume_mrl);            return VLC_EGENERIC;        }        /* */        bool has_next = false;        for (;;) {            rar_block_t bk;            int ret;            if (PeekBlock(vol, &bk))                break;            switch(bk.type) {            case RAR_BLOCK_END:                ret = SkipEnd(vol, &bk);                has_next = ret && (bk.flags & RAR_BLOCK_END_HAS_NEXT);                break;            case RAR_BLOCK_FILE:                ret = SkipFile(vol, count, file, &bk, volume_mrl);                break;            default:                ret = SkipBlock(vol, &bk);                break;            }            if (ret)                break;        }        if (vol != s)            stream_Delete(vol);        if (!has_next || !pattern ||            (*count > 0 && !(*file)[*count -1]->is_complete)) {            free(volume_mrl);            return VLC_SUCCESS;        }        /* Open next volume */        const int volume_index = pattern->start + volume_offset++;        if (volume_index > pattern->stop) {            free(volume_mrl);            return VLC_SUCCESS;        }        char *volume_base;        if (asprintf(&volume_base, "%s://%.*s",                     s->psz_access,                     (int)(strlen(s->psz_path) - strlen(pattern->match)), s->psz_path) < 0) {            free(volume_mrl);            return VLC_SUCCESS;        }        free(volume_mrl);        if (asprintf(&volume_mrl, pattern->format, volume_base, volume_index) < 0)            volume_mrl = NULL;        free(volume_base);        if (!volume_mrl)            return VLC_SUCCESS;        vol = stream_UrlNew(s, volume_mrl);        if (!vol) {            free(volume_mrl);            return VLC_SUCCESS;        }    }}
开发者ID:Flameeyes,项目名称:vlc,代码行数:87,


示例23: vlclua_stream_delete

static int vlclua_stream_delete( lua_State *L ){    stream_t **pp_stream = (stream_t **)luaL_checkudata( L, 1, "stream" );    stream_Delete( *pp_stream );    return 0;}
开发者ID:CSRedRat,项目名称:vlc,代码行数:6,


示例24: Handshake

/***************************************************************************** * Handshake : Init audioscrobbler connection *****************************************************************************/static int Handshake(intf_thread_t *p_this){    char                *psz_username, *psz_password;    char                *psz_scrobbler_url;    time_t              timestamp;    char                psz_timestamp[21];    struct md5_s        p_struct_md5;    stream_t            *p_stream;    char                *psz_handshake_url;    uint8_t             p_buffer[1024];    char                *p_buffer_pos;    int                 i_ret;    char                *psz_url;    intf_thread_t       *p_intf                 = (intf_thread_t*) p_this;    intf_sys_t          *p_sys                  = p_this->p_sys;    psz_username = var_InheritString(p_this, "lastfm-username");    psz_password = var_InheritString(p_this, "lastfm-password");    /* username or password have not been setup */    if (EMPTY_STR(psz_username) || EMPTY_STR(psz_password))    {        free(psz_username);        free(psz_password);        return VLC_ENOVAR;    }    time(&timestamp);    /* generates a md5 hash of the password */    InitMD5(&p_struct_md5);    AddMD5(&p_struct_md5, (uint8_t*) psz_password, strlen(psz_password));    EndMD5(&p_struct_md5);    free(psz_password);    char *psz_password_md5 = psz_md5_hash(&p_struct_md5);    if (!psz_password_md5)    {        free(psz_username);        return VLC_ENOMEM;    }    snprintf(psz_timestamp, sizeof(psz_timestamp), "%"PRIu64,              (uint64_t)timestamp);    /* generates a md5 hash of :     * - md5 hash of the password, plus     * - timestamp in clear text     */    InitMD5(&p_struct_md5);    AddMD5(&p_struct_md5, (uint8_t*) psz_password_md5, 32);    AddMD5(&p_struct_md5, (uint8_t*) psz_timestamp, strlen(psz_timestamp));    EndMD5(&p_struct_md5);    free(psz_password_md5);    char *psz_auth_token = psz_md5_hash(&p_struct_md5);    if (!psz_auth_token)    {        free(psz_username);        return VLC_ENOMEM;    }    psz_scrobbler_url = var_InheritString(p_this, "scrobbler-url");    if (!psz_scrobbler_url)    {        free(psz_auth_token);        free(psz_username);        return VLC_ENOMEM;    }    i_ret = asprintf(&psz_handshake_url,    "http://%s/?hs=true&p=1.2&c="CLIENT_NAME"&v="CLIENT_VERSION"&u=%s&t=%s&a=%s"    , psz_scrobbler_url, psz_username, psz_timestamp, psz_auth_token);    free(psz_auth_token);    free(psz_scrobbler_url);    free(psz_username);    if (i_ret == -1)        return VLC_ENOMEM;    /* send the http handshake request */    p_stream = stream_UrlNew(p_intf, psz_handshake_url);    free(psz_handshake_url);    if (!p_stream)        return VLC_EGENERIC;    /* read answer */    i_ret = stream_Read(p_stream, p_buffer, sizeof(p_buffer) - 1);    if (i_ret == 0)    {        stream_Delete(p_stream);//.........这里部分代码省略.........
开发者ID:Kubink,项目名称:vlc,代码行数:101,


示例25: Retrieve

static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry ){    if ( !p_entry->psz_archive_uri )        return VLC_EGENERIC;    /* get archive and parse manifest */    stream_t *p_stream;    if ( p_entry->psz_archive_uri[0] == '/' )    {        /* Relative path */        char *psz_uri;        if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", p_entry->psz_archive_uri ) )            return VLC_ENOMEM;        p_stream = stream_UrlNew( p_finder, psz_uri );        free( psz_uri );    }    else    {        p_stream = stream_UrlNew( p_finder, p_entry->psz_archive_uri );    }    msg_Dbg( p_finder, "downloading archive %s", p_entry->psz_archive_uri );    if ( !p_stream ) return VLC_EGENERIC;    /* In case of pf_ reuse */    if ( p_finder->p_sys->psz_tempfile )    {        vlc_unlink( p_finder->p_sys->psz_tempfile );        FREENULL( p_finder->p_sys->psz_tempfile );    }    p_finder->p_sys->psz_tempfile = tempnam( NULL, "vlp" );    if ( !p_finder->p_sys->psz_tempfile )    {        msg_Err( p_finder, "Can't create temp storage file" );        stream_Delete( p_stream );        return VLC_EGENERIC;    }    FILE *p_destfile = vlc_fopen( p_finder->p_sys->psz_tempfile, "w" );    if( !p_destfile )    {        msg_Err( p_finder, "Failed to open addon temp storage file" );        FREENULL(p_finder->p_sys->psz_tempfile);        stream_Delete( p_stream );        return VLC_EGENERIC;    }    char buffer[1<<10];    int i_read = 0;    while ( ( i_read = stream_Read( p_stream, &buffer, 1<<10 ) ) )    {        if ( fwrite( &buffer, i_read, 1, p_destfile ) < 1 )        {            msg_Err( p_finder, "Failed to write to Addon file" );            fclose( p_destfile );            stream_Delete( p_stream );            return VLC_EGENERIC;        }    }    fclose( p_destfile );    stream_Delete( p_stream );    msg_Dbg( p_finder, "Reading manifest from %s", p_finder->p_sys->psz_tempfile );    char *psz_manifest;    if ( asprintf( &psz_manifest, "unzip://%s!/manifest.xml",                   p_finder->p_sys->psz_tempfile ) < 1 )        return VLC_ENOMEM;    p_stream = stream_UrlNew( p_finder, psz_manifest );    free( psz_manifest );    int i_ret = ( ParseManifest( p_finder, p_entry,                                 p_finder->p_sys->psz_tempfile, p_stream ) > 0 )                    ? VLC_SUCCESS : VLC_EGENERIC;    stream_Delete( p_stream );    return i_ret;}
开发者ID:sorbits,项目名称:vlc,代码行数:82,


示例26: FetchRSS

/**************************************************************************** * FetchRSS (or Atom) feeds ***************************************************************************/static rss_feed_t* FetchRSS( filter_t *p_filter ){    filter_sys_t *p_sys = p_filter->p_sys;    stream_t *p_stream;    xml_t *p_xml;    xml_reader_t *p_xml_reader;    int i_feed;    /* These data are not modified after the creation of the module so we don't       need to hold the lock */    int i_feeds = p_sys->i_feeds;    bool b_images = p_sys->b_images;    /* Allocate a new structure */    rss_feed_t *p_feeds = (rss_feed_t *)malloc( i_feeds * sizeof( rss_feed_t ) );			// sunqueen modify    if( !p_feeds )        return NULL;    p_xml = xml_Create( p_filter );    if( !p_xml )    {        msg_Err( p_filter, "Failed to open XML parser" );        free( p_feeds );        return NULL;    }    /* Fetch all feeds and parse them */    for( i_feed = 0; i_feed < i_feeds; i_feed++ )    {        rss_feed_t *p_feed = p_feeds + i_feed;        rss_feed_t *p_old_feed = p_sys->p_feeds + i_feed;        /* Initialize the structure */        p_feed->psz_title = NULL;        p_feed->psz_description = NULL;        p_feed->psz_link = NULL;        p_feed->psz_image = NULL;        p_feed->p_pic = NULL;        p_feed->i_items = 0;        p_feed->p_items = NULL;        p_feed->psz_url = strdup( p_old_feed->psz_url );        /* Fetch the feed */        msg_Dbg( p_filter, "opening %s RSS/Atom feed ...", p_feed->psz_url );        p_stream = stream_UrlNew( p_filter, p_feed->psz_url );        if( !p_stream )        {            msg_Err( p_filter, "Failed to open %s for reading", p_feed->psz_url );            p_xml_reader = NULL;            goto error;        }        p_xml_reader = xml_ReaderCreate( p_xml, p_stream );        if( !p_xml_reader )        {            msg_Err( p_filter, "Failed to open %s for parsing", p_feed->psz_url );            goto error;        }        /* Parse the feed */        if( !ParseFeed( p_filter, p_xml_reader, p_feed ) )            goto error;        /* If we have a image: load it if requiere */        if( b_images && p_feed->psz_image && !p_feed->p_pic )        {            p_feed->p_pic = LoadImage( p_filter, p_feed->psz_image );        }        msg_Dbg( p_filter, "done with %s RSS/Atom feed", p_feed->psz_url );        xml_ReaderDelete( p_xml_reader );        stream_Delete( p_stream );    }    xml_Delete( p_xml );    return p_feeds;error:    FreeRSS( p_feeds, i_feed + 1 );    if( p_xml_reader )        xml_ReaderDelete( p_xml_reader );    if( p_stream )        stream_Delete( p_stream );    if( p_xml )        xml_Delete( p_xml );    return NULL;}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:94,


示例27:

XMLParser::~XMLParser(){    if( m_pReader ) xml_ReaderDelete( m_pReader );    if( m_pXML ) xml_Delete( m_pXML );    if( m_pStream ) stream_Delete( m_pStream );}
开发者ID:Adatan,项目名称:vlc,代码行数:6,


示例28: LoadCatalog

static int LoadCatalog( addons_finder_t *p_finder ){    char *psz_path;    char * psz_userdir = config_GetUserDir( VLC_DATA_DIR );    if ( !psz_userdir ) return VLC_ENOMEM;    if ( asprintf( &psz_path, "%s%s", psz_userdir, ADDONS_CATALOG ) < 1 )    {        free( psz_userdir );        return VLC_ENOMEM;    }    free( psz_userdir );    addon_entry_t *p_entry = NULL;    const char *p_node;    int i_current_node_type;    int i_ret = VLC_SUCCESS;    /* attr */    const char *attr, *value;    /* temp reading */    char *psz_filename = NULL;    int i_filetype = -1;    struct stat stat_;    if ( vlc_stat( psz_path, &stat_ ) )    {        free( psz_path );        return VLC_EGENERIC;    }    char *psz_catalog_uri = vlc_path2uri( psz_path, "file" );    free( psz_path );    if ( !psz_catalog_uri )        return VLC_EGENERIC;    stream_t *p_stream = stream_UrlNew( p_finder, psz_catalog_uri );    free( psz_catalog_uri );    if (! p_stream ) return VLC_EGENERIC;    xml_reader_t *p_xml_reader = xml_ReaderCreate( p_finder, p_stream );    if( !p_xml_reader )    {        stream_Delete( p_stream );        return VLC_EGENERIC;    }    if( xml_ReaderNextNode( p_xml_reader, &p_node ) != XML_READER_STARTELEM )    {        msg_Err( p_finder, "invalid catalog" );        i_ret = VLC_EGENERIC;        goto end;    }    if ( strcmp( p_node, "videolan") )    {        msg_Err( p_finder, "unsupported catalog data format" );        i_ret = VLC_EGENERIC;        goto end;    }    while( (i_current_node_type = xml_ReaderNextNode( p_xml_reader, &p_node )) > 0 )    {        switch( i_current_node_type )        {        case XML_READER_STARTELEM:        {            if ( ! strcmp( p_node, "addon" ) )            {                if ( p_entry ) /* ?!? Unclosed tag */                    addon_entry_Release( p_entry );                p_entry = addon_entry_New();                //p_entry->psz_source_module = strdup( ADDONS_MODULE_SHORTCUT );                p_entry->e_flags = ADDON_MANAGEABLE;                p_entry->e_state = ADDON_INSTALLED;                while( (attr = xml_ReaderNextAttr( p_xml_reader, &value )) )                {                    if ( !strcmp( attr, "type" ) )                    {                        p_entry->e_type = ReadType( value );                    }                    else if ( !strcmp( attr, "id" ) )                    {                        addons_uuid_read( value, & p_entry->uuid );                    }                    else if ( !strcmp( attr, "downloads" ) )                    {                        p_entry->i_downloads = atoi( value );                        if ( p_entry->i_downloads < 0 )                            p_entry->i_downloads = 0;                    }                    else if ( !strcmp( attr, "score" ) )                    {                        p_entry->i_score = atoi( value );                        if ( p_entry->i_score < 0 )                            p_entry->i_score = 0;                        else if ( p_entry->i_score > ADDON_MAX_SCORE )//.........这里部分代码省略.........
开发者ID:LTNGlobal-opensource,项目名称:vlc-sdi,代码行数:101,


示例29: ListSkins

static int ListSkins( addons_finder_t *p_finder ){    char *psz_dir = getAddonInstallDir( ADDON_SKIN2 );    if ( !psz_dir )        return VLC_EGENERIC;    char **ppsz_list = NULL;    int i_count = vlc_scandir( psz_dir, &ppsz_list, ListSkin_filter, NULL );    for ( int i=0; i< i_count; i++ )    {        char *psz_file = ppsz_list[i];        if( !psz_file )            break;        if ( FileBelongsToManagedAddon( p_finder, ADDON_SKIN2, psz_file ) )             continue;        char *psz_uri;        if( asprintf( &psz_uri, "unzip://%s/%s!/theme.xml", psz_dir, psz_file ) >= 0)        {            int i_ret;            char *psz_name = NULL;            char *psz_source = NULL;            stream_t *p_stream = stream_UrlNew( p_finder, psz_uri );            free( psz_uri );            if ( !p_stream )            {                i_ret = VLC_EGENERIC;            }            else            {                i_ret = ParseSkins2Info( p_finder, p_stream, &psz_name, &psz_source );                if ( i_ret != VLC_SUCCESS )                {                    free( psz_name );                    free( psz_source );                }                stream_Delete( p_stream );            }            addon_entry_t *p_entry = addon_entry_New();            p_entry->e_type = ADDON_SKIN2;            p_entry->e_state = ADDON_INSTALLED;            if ( i_ret == VLC_SUCCESS )            {                p_entry->psz_name = psz_name;                p_entry->psz_description = strdup("Skins2 theme");                p_entry->psz_source_uri = psz_source;            }            else            {                p_entry->e_flags |= ADDON_BROKEN;                p_entry->psz_name = strdup(psz_file);                p_entry->psz_description = strdup("Skins2 theme");            }            ARRAY_APPEND( p_finder->entries, p_entry );        }        free( psz_file );    }    free( ppsz_list );    free( psz_dir );    return VLC_SUCCESS;}
开发者ID:LTNGlobal-opensource,项目名称:vlc-sdi,代码行数:66,



注:本文中的stream_Delete函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ stream_Peek函数代码示例
C++ stream函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。