root/OpenSceneGraph/branches/osg-cocoa-dev/src/osgPlugins/ffmpeg/ReaderWriterFFmpeg.cpp @ 9846

Revision 9846, 1.6 kB (checked in by shuber, 6 years ago)

merging from trunk using

svn merge -r 9837:9843 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk

Line 
1
2#include <osgDB/Registry>
3#include <osgDB/FileNameUtils>
4#include <osgDB/FileUtils>
5
6#include "FFmpegHeaders.hpp"
7#include "FFmpegImageStream.hpp"
8
9
10
11/** Implementation heavily inspired by http://www.dranger.com/ffmpeg/ */
12
13class ReaderWriterFFmpeg : public osgDB::ReaderWriter
14{
15public:
16
17    ReaderWriterFFmpeg()
18    {
19        supportsExtension("avi", "");
20        supportsExtension("flv", "");
21        supportsExtension("mov", "");
22        supportsExtension("ogg", "Theora movie format");
23        supportsExtension("mpg", "Mpeg movie format");
24        supportsExtension("mpv", "Mpeg movie format");
25        supportsExtension("wmv", "");
26
27        // Register all FFmpeg formats/codecs
28        av_register_all();
29    }
30
31    virtual ~ReaderWriterFFmpeg()
32    {
33
34    }
35
36    virtual const char * className() const
37    {
38        return "ReaderWriterFFmpeg";
39    }
40
41    virtual ReadResult readImage(const std::string & filename, const osgDB::ReaderWriter::Options * options) const
42    {
43        const std::string ext = osgDB::getLowerCaseFileExtension(filename);
44
45        if (! acceptsExtension(ext))
46            return ReadResult::FILE_NOT_HANDLED;
47
48        const std::string path = osgDB::findDataFile(filename, options);
49
50        if (path.empty())
51            return ReadResult::FILE_NOT_FOUND;
52
53        osg::notify(osg::INFO) << "ReaderWriterFFmpeg::readImage " << path << std::endl;
54
55        osg::ref_ptr<osgFFmpeg::FFmpegImageStream> image_stream(new osgFFmpeg::FFmpegImageStream);
56
57        if (! image_stream->open(path))
58            return ReadResult::FILE_NOT_HANDLED;
59
60        return image_stream.release();
61    }
62
63private:
64
65};
66
67
68
69REGISTER_OSGPLUGIN(ffmpeg, ReaderWriterFFmpeg)
Note: See TracBrowser for help on using the browser.