⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readerwriterqt.cpp

📁 最新osg包
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "osg/Image"#include "osg/Notify"#include <osg/Geode>#include <osg/observer_ptr>#include "osg/GL"#include "osgDB/FileNameUtils"#include "osgDB/Registry"#include "osgDB/FileUtils"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sstream>#ifndef __APPLE__#include "Components.h"#include "QuickTimeComponents.h"#else#include <QuickTime/QuickTime.h>#endif#ifndef SEEK_SET#  define SEEK_SET 0#endif#include "QTUtils.h"#include "QTLiveUtils.h"#include "QTImportExport.h"#include "QuicktimeImageStream.h"#include "QuicktimeLiveImageStream.h"using namespace osg;// This class is used as a helper to de-initialize// properly quicktime, when the last media loaded // with the quicktime plugin is released. // All loaded media must be added to the observer // (see ReaderWriterQT::readImage() function) class QuicktimeExitObserver : public osg::Observer{public:   QuicktimeExitObserver () : _instanceCount(0)   {   }   virtual ~QuicktimeExitObserver()   {   };   void addMedia(Image* ptr)   {      ptr->addObserver(this);      ++ _instanceCount;   }      virtual void objectDeleted(void*)    {      -- _instanceCount;      if(_instanceCount== 0)         exitQuicktime();   }private:   unsigned int _instanceCount;};class ReaderWriterQT : public osgDB::ReaderWriter{public:    ReaderWriterQT::ReaderWriterQT()    {        supportsExtension("mov","Movie format");        supportsExtension("mpg","Movie format");        supportsExtension("mpv","Movie format");        supportsExtension("mp4","Movie format");        supportsExtension("m4v","Movie format");        supportsExtension("dv","Movie format");        supportsExtension("avi","Movie format");        supportsExtension("flv","Movie format");        supportsExtension("swf","Movie format");        supportsExtension("3gp","Mobile movie format");        supportsExtension("live","Live video streaming");        #ifdef QT_HANDLE_IMAGES_ALSO        supportsExtension("jpg","jpg image format");        supportsExtension("jpeg","jpeg image format");        supportsExtension("tif","tif image format");        supportsExtension("tiff","tiff image format");        supportsExtension("gif","gif image format");        supportsExtension("png","png image format");        supportsExtension("pict","pict image format");        supportsExtension("pct","pct image format");        supportsExtension("tga","tga image format");        supportsExtension("psd","psd image format");        #endif    }    ReaderWriterQT::~ReaderWriterQT()    {    }   virtual const char* className() const { return "Default Quicktime Image Reader/Writer"; }   virtual bool acceptsMovieExtension(const std::string& extension) const   {      return osgDB::equalCaseInsensitive(extension,"mov") ||         osgDB::equalCaseInsensitive(extension,"mpg") ||         osgDB::equalCaseInsensitive(extension,"mpv") ||         osgDB::equalCaseInsensitive(extension,"mp4") ||         osgDB::equalCaseInsensitive(extension,"m4v") ||         osgDB::equalCaseInsensitive(extension,"dv")  ||         osgDB::equalCaseInsensitive(extension,"avi") ||         osgDB::equalCaseInsensitive(extension,"flv") ||         osgDB::equalCaseInsensitive(extension,"swf") ||         osgDB::equalCaseInsensitive(extension,"3gp");   }   virtual bool acceptsLiveExtension(const std::string& extension) const   {       return osgDB::equalCaseInsensitive(extension,"live");        }   virtual bool acceptsExtension(const std::string& extension) const   {      // this should be the only image importer required on the Mac      // dont know what else it supports, but these will do      return         #ifdef QT_HANDLE_IMAGES_ALSO         osgDB::equalCaseInsensitive(extension,"jpg") ||          osgDB::equalCaseInsensitive(extension,"jpeg") ||         osgDB::equalCaseInsensitive(extension,"tif") ||                        osgDB::equalCaseInsensitive(extension,"tiff") ||          osgDB::equalCaseInsensitive(extension,"gif") ||         osgDB::equalCaseInsensitive(extension,"png") ||         osgDB::equalCaseInsensitive(extension,"pict") ||         osgDB::equalCaseInsensitive(extension,"pct") ||         osgDB::equalCaseInsensitive(extension,"tga") ||         osgDB::equalCaseInsensitive(extension,"psd") ||         #endif          acceptsMovieExtension(extension) ||         acceptsLiveExtension(extension);   }   virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const   {      std::string ext = osgDB::getLowerCaseFileExtension(file);      if (osgDB::equalCaseInsensitive(ext,"qt"))      {         return readImage(osgDB::getNameLessExtension(file),options);      }            if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED;      // if the file is a ".live" video encoded string then load as an ImageStream      if (acceptsLiveExtension(ext))      {          long num_video_components;          {              // Begin QuickTime              QTScopedQTMLInitialiser  qt_init;              QTScopedMovieInitialiser qt_movie_init;              //              ComponentDescription video_component_description;              video_component_description.componentType         = 'vdig';  /* A unique 4-byte code indentifying the command set */              video_component_description.componentSubType      = 0L;      /* Particular flavor of this instance */              video_component_description.componentManufacturer = 0L;      /* Vendor indentification */              video_component_description.componentFlags        = 0L;      /* 8 each for Component,Type,SubType,Manuf/revision */              video_component_description.componentFlagsMask    = 0L;      /* Mask for specifying which flags to consider in search, zero during registration */              num_video_components = CountComponents (&video_component_description);          }          if (osgDB::getNameLessExtension(file) == "devices")          {              osg::notify(osg::ALWAYS) << " available Video DigitizerComponents : " << num_video_components << std::endl;              if (num_video_components)              {                  // Probe Video Dig                  probe_video_digitizer_components();                  // Probe SG                  std::vector<OSG_SGDeviceList> devices_list = probe_sequence_grabber_components();                  if (devices_list.size())                  {                      // Video                      OSG_SGDeviceList& video_device_list = devices_list[0];                      // Print                      osg::notify(osg::ALWAYS) << std::endl;                      osg::notify(osg::ALWAYS) << "Video Component/Input IDs follow: " << std::endl;                      osg::notify(osg::ALWAYS) << std::endl;                      for (unsigned int device_input = 0; device_input < video_device_list.size(); ++device_input)                      {                          OSG_SGDevicePair device_pair = video_device_list[device_input];                          osg::notify(osg::ALWAYS) << device_pair.first.c_str() << "    " << device_pair.second.c_str() << std::endl;                      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -