Show
Ignore:
Timestamp:
04/11/09 08:16:37 (4 years ago)
Author:
robert
Message:

From Jean Sebastien Guay, added error reporting handling of wider range of video formats.

Files:
1 modified

Legend:

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

    r9990 r10030  
    33 
    44#include <osg/Notify> 
     5#include <osgDB/FileNameUtils> 
    56 
    67#include <cassert> 
     
    89#include <stdexcept> 
    910#include <string.h> 
    10  
     11#include <iostream> 
    1112 
    1213 
     
    6566            formatParams.time_base.den = 30; 
    6667 
    67             iformat = av_find_input_format("video4linux2"); 
     68            std::string format = "video4linux2"; 
     69            iformat = av_find_input_format(format.c_str()); 
    6870             
    6971            if (iformat) 
    7072            { 
    71                 osg::notify(osg::NOTICE)<<"Found input format"<<std::endl; 
     73                osg::notify(osg::NOTICE)<<"Found input format: "<<format<<std::endl; 
    7274            } 
    7375            else 
    7476            { 
    75                 osg::notify(osg::NOTICE)<<"Failed to find input_format"<<std::endl; 
    76             } 
    77  
    78             if (av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams) != 0) 
    79                 throw std::runtime_error("av_open_input_file() failed"); 
     77                osg::notify(osg::NOTICE)<<"Failed to find input format: "<<format<<std::endl; 
     78            } 
     79 
     80            int error = av_open_input_file(&p_format_context, filename.c_str(), iformat, 0, &formatParams); 
     81            if (error != 0) 
     82            { 
     83                std::string error_str; 
     84                switch (error) 
     85                { 
     86                    //case AVERROR_UNKNOWN: error_str = "AVERROR_UNKNOWN"; break;   // same value as AVERROR_INVALIDDATA 
     87                    case AVERROR_IO: error_str = "AVERROR_IO"; break; 
     88                    case AVERROR_NUMEXPECTED: error_str = "AVERROR_NUMEXPECTED"; break; 
     89                    case AVERROR_INVALIDDATA: error_str = "AVERROR_INVALIDDATA"; break; 
     90                    case AVERROR_NOMEM: error_str = "AVERROR_NOMEM"; break; 
     91                    case AVERROR_NOFMT: error_str = "AVERROR_NOFMT"; break; 
     92                    case AVERROR_NOTSUPP: error_str = "AVERROR_NOTSUPP"; break; 
     93                    case AVERROR_NOENT: error_str = "AVERROR_NOENT"; break; 
     94                    case AVERROR_PATCHWELCOME: error_str = "AVERROR_PATCHWELCOME"; break; 
     95                    default: error_str = "Unknown error"; break; 
     96                } 
     97 
     98                throw std::runtime_error("av_open_input_file() failed : " + error_str); 
     99            } 
    80100        } 
    81101        else