Show
Ignore:
Timestamp:
03/05/09 11:57:54 (4 years ago)
Author:
robert
Message:

Added quick proof of concept for live video streaming under linux

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoder.cpp

    r9826 r9865  
    3636 
    3737 
    38  
    3938bool FFmpegDecoder::open(const std::string & filename) 
    4039{ 
     
    4443        AVFormatContext * p_format_context = 0; 
    4544 
    46         if (av_open_input_file(&p_format_context, filename.c_str(), 0, 0, 0) != 0) 
    47             throw std::runtime_error("av_open_input_file() failed"); 
    48  
     45        if (filename.compare(0, 5, "/dev/")==0) 
     46        { 
     47            avdevice_register_all(); 
     48         
     49            osg::notify(osg::NOTICE)<<"Attempting to stream "<<filename<<std::endl; 
     50 
     51            AVFormatParameters formatParams; 
     52            memset(&formatParams, 0, sizeof(AVFormatParameters)); 
     53            AVInputFormat *iformat; 
     54 
     55            formatParams.channel = 0; 
     56            formatParams.standard = 0; 
     57            formatParams.width = 640; 
     58            formatParams.height = 480; 
     59            formatParams.time_base.num = 1; 
     60            formatParams.time_base.den = 50; 
     61 
     62            iformat = av_find_input_format("video4linux2"); 
     63             
     64            if (iformat) 
     65            { 
     66                osg::notify(osg::NOTICE)<<"Found input format"<<std::endl; 
     67            } 
     68            else 
     69            { 
     70                osg::notify(osg::NOTICE)<<"Failed to find input_format"<<std::endl; 
     71            } 
     72 
     73            if (av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams) != 0) 
     74                throw std::runtime_error("av_open_input_file() failed"); 
     75        } 
     76        else 
     77        { 
     78            if (av_open_input_file(&p_format_context, filename.c_str(), 0, 0, 0) !=0 ) 
     79                throw std::runtime_error("av_open_input_file() failed"); 
     80        } 
     81         
    4982        m_format_context.reset(p_format_context); 
    5083