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

📄 qtliveutils.cpp

📁 最新osg包
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                                  // Create GWorld                                  GetGWorld (&origPort, &origDevice);                                  SetGWorld (gw, NULL); // set current graphics port to offscreen                                  pixmap = GetGWorldPixMap (gw);                                  if (pixmap)                                  {                                      if (!LockPixels (pixmap)) // lock offscreen pixel map                                      {                                          osg::notify(osg::FATAL) << "Could not lock PixMap" << std::endl;                                      }                                  }                                  // Set GWorld                                  result = SGSetGWorld(gSeqGrabber, (CGrafPtr)gw, 0);                                  // Set GWorld back                                  // SetGWorld(origPort, origDevice);                                  if (result != noErr)                                  {                                      osg::notify(osg::FATAL) << "Could not set GWorld on SG" << std::endl;                                  }                                  else                                  {                                      // Get a video channel                                      result = SGNewChannel (gSeqGrabber, VideoMediaType, &gVideoChannel);                                      if ((gVideoChannel != nil) && (result == noErr))                                      {                                          // Init                                          // result = SGInitChannel(gVideoChannel, gSeqGrabber);//                                           if (result != noErr)//                                           {//                                               osg::notify(osg::NOTICE) << "SGInitChannel - failed!" << std::endl;                                              //                                           }                                          // Usage                                          result = SGSetChannelUsage (gVideoChannel, seqGrabPreview);                                          // Panel                                          // Crashes every time                                          // result = SGSettingsDialog(gSeqGrabber, gVideoChannel, 0, 0, seqGrabSettingsPreviewOnly, &MyModalFilter, 0);                                          // Bounds                                          result = SGGetSrcVideoBounds (gVideoChannel, &gActiveVideoRect);                                          osg::notify(osg::NOTICE) << "SrcVideoBounds: " << gActiveVideoRect.right << " " << gActiveVideoRect.bottom << std::endl;                                          Str255 deviceName;                                          Str255 inputName;                                          short  inputNumber;                                          result = SGGetChannelDeviceAndInputNames( gVideoChannel, deviceName, inputName, &inputNumber);                                          if (result != noErr)                                          {                                              osg::notify(osg::NOTICE) << "Could not get DeviceAndInput names from Video SG" << std::endl;                                                                                        }                                          osg::notify(osg::NOTICE) << "ChannelDeviceAndInputNamesNumber: " << pstr_printable(deviceName) << " : " << pstr_printable(inputName) << " : " << inputNumber << std::endl;                                          SGDeviceList deviceList;                                          result = SGGetChannelDeviceList( gVideoChannel, sgDeviceListIncludeInputs, &deviceList);                                          if (result != noErr)                                          {                                              osg::notify(osg::NOTICE) << "Could not get DeviceList from Video SG" << std::endl;                                                                                        }                                          else                                          {                                              osg::notify(osg::NOTICE) << "DeviceList from Video SG ok" << std::endl;                                                             device_list = print_sequence_grabber_device_list(deviceList);                                              devices_list.push_back(device_list);                                          }                                      }                                      // Get a sound channel                                      result = SGNewChannel (gSeqGrabber, SoundMediaType, &gSoundChannel);                                      if ((gSoundChannel != nil) && (result == noErr))                                      {                                          // Usage                                          result = SGSetChannelUsage (gSoundChannel, seqGrabPreview);                                          Str255 deviceName;                                          Str255 inputName;                                          short  inputNumber;                                          result = SGGetChannelDeviceAndInputNames( gVideoChannel, deviceName, inputName, &inputNumber);                                          if (result != noErr)                                          {                                              osg::notify(osg::NOTICE) << "Could not get DeviceAndInput names from Sound SG" << std::endl;                                                                                        }                                          osg::notify(osg::NOTICE) << "ChannelDeviceAndInputNamesNumber: " << pstr_printable(deviceName) << " : " << pstr_printable(inputName) << " : " << inputNumber << std::endl;                                          SGDeviceList deviceList;                                          result = SGGetChannelDeviceList( gSoundChannel, sgDeviceListIncludeInputs, &deviceList);                                          if (result != noErr)                                          {                                              osg::notify(osg::NOTICE) << "Could not get DeviceList from Sound SG" << std::endl;                                                                                        }                                          else                                          {                                              osg::notify(osg::NOTICE) << "DeviceList from Sound SG ok" << std::endl;                                                             device_list = print_sequence_grabber_device_list(deviceList);                                              devices_list.push_back(device_list);                                          }                                      }                                  }                              SetGWorld(origPort, origDevice);                              DisposeGWorld(gw);                              }                          }                      }                      SGDisposeChannel(gSeqGrabber, gVideoChannel);                      CloseComponent(gSeqGrabber);                  }              }              while (0 != aComponent);          }      // End QuickTime      }      return devices_list;}void get_video_device_bounds_idstr(short deviceID, short deviceInputID, short& out_width, short& out_height, Str63& out_deviceIDStr){      // Extra scopes for DEBUG and breakpoint/stack checking plus QT init/destroy      {          // Begin QuickTime          QTScopedQTMLInitialiser  qt_init;          QTScopedMovieInitialiser qt_movie_init;          ComponentDescription sg_component_description;          sg_component_description.componentType         = SeqGrabComponentType; /* A unique 4-byte code indentifying the command set */          sg_component_description.componentSubType      = 0L;      /* Particular flavor of this instance */          sg_component_description.componentManufacturer = 0L;      /* Vendor indentification */          sg_component_description.componentFlags        = 0L;      /* 8 each for Component,Type,SubType,Manuf/revision */          sg_component_description.componentFlagsMask    = 0L;      /* Mask for specifying which flags to consider in search, zero during registration */          long num_sg_components = CountComponents (&sg_component_description);          if (num_sg_components)          {              Component aComponent = 0;              do              {                  ComponentDescription full_sg_component_description = sg_component_description;                  aComponent = FindNextComponent(aComponent, &full_sg_component_description);                  if (aComponent)                  {                      SeqGrabComponent gSeqGrabber;                      SGChannel           gVideoChannel;                      Rect               gActiveVideoRect;                      gSeqGrabber = OpenComponent (aComponent);                      // If we got a sequence grabber, set it up                      if (gSeqGrabber != 0L)                      {                          ComponentResult result = noErr;                          // Initialize the sequence grabber                          result = SGInitialize (gSeqGrabber);                          if (result == noErr)                          {                              // Check capability and setting of Sequence Grabber                              Rect         destinationBounds;                              OSStatus     err;                              GDHandle     origDevice;                              CGrafPtr     origPort;                              GWorldPtr    gw;                              PixMapHandle pixmap = NULL;                              int*         destinationData = new int [1024*1024]; // 1024*1024*4 bytes (32bit RGBA)                              destinationBounds.left   = 0;                              destinationBounds.top    = 0;                              destinationBounds.right  = 256;                              destinationBounds.bottom = 256;                              err = QTNewGWorldFromPtr(&gw, k32ARGBPixelFormat, &destinationBounds,                                                       NULL, NULL, 0, (Ptr)destinationData, 4*256);                              if (err !=0 )                                  osg::notify(osg::NOTICE) << "Could not create gWorld" << std::endl;                              else                              {                                  // Create GWorld                                  GetGWorld (&origPort, &origDevice);                                  SetGWorld (gw, NULL); // set current graphics port to offscreen                                  pixmap = GetGWorldPixMap (gw);                                  if (pixmap)                                  {                                      if (!LockPixels (pixmap)) // lock offscreen pixel map                                          osg::notify(osg::FATAL) << "Could not lock PixMap" << std::endl;                                  }                                  // Set GWorld                                  result = SGSetGWorld(gSeqGrabber, (CGrafPtr)gw, 0);                                  // Set GWorld back                                  // SetGWorld(origPort, origDevice);                                  if (result != noErr)                                  {                                      osg::notify(osg::FATAL) << "Could not set GWorld on SG" << std::endl;                                  }                                  else                                  {                                      // Get a video channel                                      result = SGNewChannel (gSeqGrabber, VideoMediaType, &gVideoChannel);                                      if ((gVideoChannel != nil) && (result == noErr))                                      {                                          result = SGSetChannelUsage (gVideoChannel, seqGrabPreview);                                          Str255 deviceName;                                          Str255 inputName;                                          short  inputNumber;                                          result = SGGetChannelDeviceAndInputNames( gVideoChannel, deviceName, inputName, &inputNumber);                                          SGDeviceList deviceList;                                          result = SGGetChannelDeviceList( gVideoChannel, sgDeviceListIncludeInputs, &deviceList);                                          short count = (*deviceList)->count;                                          if (deviceID >= count)                                              osg::notify(osg::FATAL) << "DeviceID : " << deviceID << " too large - we only have " << count << " devices" << std::endl;                                          SGDeviceName deviceNameRec = (*deviceList)->entry[deviceID];                                          SGDeviceInputList deviceInputList = deviceNameRec.inputs;                                          if (deviceInputList == 0)                                              osg::notify(osg::FATAL) << "DeviceInputList is empty!" << std::endl;                                          else                                          {                                              short inputCount = (*deviceInputList)->count;                                              if (deviceInputID >= inputCount)                                                  osg::notify(osg::FATAL) << "DeviceInputID : " << deviceInputID << " too large - we only have " << inputCount << " inputs for device" << std::endl;                                          }                                          // Ok                                          Str63 deviceNameStr;                                          memcpy(deviceNameStr, deviceNameRec.name, sizeof(Str63));                                          // Set                                          result = SGSetChannelDevice     ( gVideoChannel, deviceNameStr);                                          result = SGSetChannelDeviceInput( gVideoChannel, deviceInputID);                                          VideoDigitizerComponent vdig = SGGetVideoDigitizerComponent(gVideoChannel);

⌨️ 快捷键说明

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