| 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 | |