| [9816] | 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 | |
|---|
| 12 | |
|---|
| 13 | class ReaderWriterFFmpeg : public osgDB::ReaderWriter |
|---|
| 14 | { |
|---|
| 15 | public: |
|---|
| 16 | |
|---|
| 17 | ReaderWriterFFmpeg() |
|---|
| 18 | { |
|---|
| 19 | supportsExtension("avi", ""); |
|---|
| 20 | supportsExtension("flv", ""); |
|---|
| 21 | supportsExtension("mov", ""); |
|---|
| 22 | supportsExtension("mpg", "Mpeg movie format"); |
|---|
| 23 | supportsExtension("mpv", "Mpeg movie format"); |
|---|
| 24 | supportsExtension("wmv", ""); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | av_register_all(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | virtual ~ReaderWriterFFmpeg() |
|---|
| 31 | { |
|---|
| 32 | |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | virtual const char * className() const |
|---|
| 36 | { |
|---|
| 37 | return "ReaderWriterFFmpeg"; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | virtual ReadResult readImage(const std::string & filename, const osgDB::ReaderWriter::Options * options) const |
|---|
| 41 | { |
|---|
| 42 | const std::string ext = osgDB::getLowerCaseFileExtension(filename); |
|---|
| 43 | |
|---|
| 44 | if (! acceptsExtension(ext)) |
|---|
| 45 | return ReadResult::FILE_NOT_HANDLED; |
|---|
| 46 | |
|---|
| 47 | const std::string path = osgDB::findDataFile(filename, options); |
|---|
| 48 | |
|---|
| 49 | if (path.empty()) |
|---|
| 50 | return ReadResult::FILE_NOT_FOUND; |
|---|
| 51 | |
|---|
| 52 | osg::notify(osg::INFO) << "ReaderWriterFFmpeg::readImage " << path << std::endl; |
|---|
| 53 | |
|---|
| 54 | osg::ref_ptr<osgFFmpeg::FFmpegImageStream> image_stream(new osgFFmpeg::FFmpegImageStream); |
|---|
| 55 | |
|---|
| 56 | if (! image_stream->open(path)) |
|---|
| 57 | return ReadResult::FILE_NOT_HANDLED; |
|---|
| 58 | |
|---|
| 59 | return image_stream.release(); |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | private: |
|---|
| 63 | |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | REGISTER_OSGPLUGIN(ffmpeg, ReaderWriterFFmpeg) |
|---|