示例#1
0
void Downloader::Run()
{
    while(1)
    {
        vlc_mutex_lock(&lock);
        if(killed)
            break;

        while(chunks.empty() && !killed)
        {
            vlc_cond_wait(&waitcond, &lock);
        }

        if(killed)
            break;

        if(!chunks.empty())
        {
            HTTPChunkBufferedSource *source = chunks.front();
            DownloadSource(source);
            if(source->isDone())
                chunks.pop_front();
        }

        vlc_mutex_unlock(&lock);
    }
    vlc_mutex_unlock(&lock);
}
示例#2
0
文件: Segment.cpp 项目: 0xheart0/vlc
SegmentChunk * ISegment::getChunk(const std::string &url, HTTPConnectionManager *connManager)
{
    HTTPChunkBufferedSource *source = new HTTPChunkBufferedSource(url, connManager);
    if(startByte != endByte)
        source->setBytesRange(BytesRange(startByte, endByte));
    connManager->downloader->schedule(source);
    return new (std::nothrow) SegmentChunk(this, source);
}
示例#3
0
文件: Segment.cpp 项目: Geal/vlc
SegmentChunk* ISegment::toChunk(size_t index, BaseRepresentation *rep, AbstractConnectionManager *connManager)
{
    const std::string url = getUrlSegment().toString(index, rep);
    HTTPChunkBufferedSource *source = new (std::nothrow) HTTPChunkBufferedSource(url, connManager,
                                                                                 rep->getAdaptationSet()->getID());
    if( source )
    {
        if(startByte != endByte)
            source->setBytesRange(BytesRange(startByte, endByte));

        SegmentChunk *chunk = new (std::nothrow) SegmentChunk(this, source, rep);
        if( chunk )
        {
            connManager->start(source);
            return chunk;
        }
        else
        {
            delete source;
        }
    }
    return NULL;
}