Show
Ignore:
Timestamp:
02/27/09 18:00:28 (4 years ago)
Author:
robert
Message:

Ported across from using boost pointers, and prepped for integration of audio interface into core OSG

Files:
1 modified

Legend:

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

    r9816 r9826  
    33#define HEADER_GUARD_OSGFFMPEG_FFMPEG_DECODER_H 
    44 
    5 #include <boost/shared_ptr.hpp> 
    6  
    75#include "FFmpegDecoderAudio.hpp" 
    86#include "FFmpegDecoderVideo.hpp" 
    97 
     8#include <osg/Notify> 
    109 
    1110 
    1211namespace osgFFmpeg { 
    1312 
     13class FormatContextPtr 
     14{ 
     15    public: 
     16     
     17        typedef AVFormatContext T; 
     18     
     19        explicit FormatContextPtr() : _ptr(0) {} 
     20        explicit FormatContextPtr(T* ptr) : _ptr(ptr) {} 
     21         
     22        ~FormatContextPtr() 
     23        { 
     24            cleanup(); 
     25        } 
     26         
     27        T* get() { return _ptr; } 
     28 
     29        T * operator-> () const // never throws 
     30        { 
     31            return _ptr; 
     32        } 
     33 
     34        void reset(T* ptr)  
     35        { 
     36            if (ptr==_ptr) return; 
     37            cleanup(); 
     38            _ptr = ptr; 
     39        } 
     40 
     41        void cleanup() 
     42        { 
     43            if (_ptr)  
     44            { 
     45                osg::notify(osg::NOTICE)<<"Calling av_close_input_file("<<_ptr<<")"<<std::endl; 
     46                av_close_input_file(_ptr); 
     47            } 
     48            _ptr = 0; 
     49        } 
     50         
     51         
     52 
     53    protected: 
     54     
     55        T* _ptr; 
     56}; 
    1457 
    1558 
     
    4689    }; 
    4790 
    48     typedef boost::shared_ptr<AVFormatContext> FormatContextPtr; 
    4991    typedef BoundedMessageQueue<FFmpegPacket> PacketQueue; 
    5092