int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
{
    int ret = ERROR_SUCCESS;
    
    string stream_url = req->get_stream_url();
    string vhost = req->vhost;
    
    if (pool.find(stream_url) == pool.end()) {
        SrsSource* source = new SrsSource(req);
        if ((ret = source->initialize()) != ERROR_SUCCESS) {
            srs_freep(source);
            return ret;
        }
        
        pool[stream_url] = source;
        srs_info("create new source for url=%s, vhost=%s", stream_url.c_str(), vhost.c_str());
    }
    
    // we always update the request of resource, 
    // for origin auth is on, the token in request maybe invalid,
    // and we only need to update the token of request, it's simple.
    if (true) {
        SrsSource* source = pool[stream_url];
        source->_req->update_auth(req);
        *ppsource = source;
    }
    
    return ret;
}
Beispiel #2
0
int SrsSource::find(SrsRequest* req, SrsSource** ppsource)
{
    int ret = ERROR_SUCCESS;
    
    string stream_url = req->get_stream_url();
    string vhost = req->vhost;
    
    if (pool.find(stream_url) == pool.end()) {
        SrsSource* source = new SrsSource(req);
        if ((ret = source->initialize()) != ERROR_SUCCESS) {
            srs_freep(source);
            return ret;
        }
        
        pool[stream_url] = source;
        srs_info("create new source for url=%s, vhost=%s", stream_url.c_str(), vhost.c_str());
    }
    
    *ppsource = pool[stream_url];
    
    return ret;
}