Exemple #1
0
void PropertyAccess::ReadPropertyValue(CameraWidget* widget, Variant& value, int _type)
{
   CameraWidgetType type = (CameraWidgetType)_type;

   switch (type)
   {
   case GP_WIDGET_MENU:
   case GP_WIDGET_RADIO:
   case GP_WIDGET_TEXT:
   {
      char* text = nullptr;
      int ret = gp_widget_get_value(widget, &text);
      CheckError(_T("gp_widget_get_value"), ret, __FILE__, __LINE__);

      value.Set<CString>(CString(text));
      value.SetType(Variant::typeString);
   }
   break;

   case GP_WIDGET_RANGE:
   {
      float floatValue = 0.0;
      int ret = gp_widget_get_value(widget, &floatValue);
      CheckError(_T("gp_widget_get_value"), ret, __FILE__, __LINE__);

      value.Set<float>(floatValue);
      value.SetType(Variant::typeFloat);
   }
   break;

   case GP_WIDGET_TOGGLE:
   case GP_WIDGET_DATE:
   {
      int intValue = 0;
      int ret = gp_widget_get_value(widget, &intValue);
      CheckError(_T("gp_widget_get_value"), ret, __FILE__, __LINE__);

      value.Set<int>(intValue);
      value.SetType(Variant::typeInt32);
      // TODO  use typeTime for GP_WIDGET_DATE?
   }
   break;

   default:
      // nothing to read
      value.SetType(Variant::typeInvalid);
      break;
   }
}
Exemple #2
0
void ViewfinderImpl::SetOutputType(T_enOutputType enOutputType)
{
   unsigned int output = 0;

   switch (enOutputType)
   {
   case Viewfinder::outputTypeUndefined:
      return; // do nothing

   case Viewfinder::outputTypeLCD:
      // corresponds to "Camera and PC", to have viewfinder on camera LCD also
      output = kEdsEvfOutputDevice_TFT | kEdsEvfOutputDevice_PC;
      break;

   case Viewfinder::outputTypeVideoOut:
      return; // do nothing, since on EDSDK, video out can't be set

   case Viewfinder::outputTypeOff:
      // corresponds to "PC", not "Off", to not shutdown viewfinder at all
      output = kEdsEvfOutputDevice_PC;
      break;

   default:
      ATLASSERT(false);
      return;
   }

   Variant outputValue;
   outputValue.Set(output);
   outputValue.SetType(Variant::typeUInt32);

   PropertyAccess p(m_hSourceDevice);
   p.Set(kEdsPropID_Evf_OutputDevice, outputValue);
}
Exemple #3
0
ImageProperty RemoteReleaseControlImpl::GetImageProperty(unsigned int uiImageProperty) const
{
   if (uiImageProperty == PSREC_PROP_IMAGE_FORMAT)
   {
      PropertyAccess access(m_hCamera);
      Variant value = access.GetImageFormatProperty();

      return ImageProperty(variantPsrec, uiImageProperty, value, true);
   }

   if (uiImageProperty == PSREC_PROP_AVAILABLE_SHOTS)
   {
      Variant value;
      value.Set<unsigned int>(NumAvailableShots());
      value.SetType(Variant::typeUInt32);

      return ImageProperty(variantPsrec, uiImageProperty, value, true);
   }

   DevicePropDesc desc(m_hCamera, static_cast<prUInt16>(uiImageProperty), false);

   // return in image property object
   ImageProperty ip(variantPsrec, uiImageProperty, desc.m_varCurrentValue, !desc.IsSetAllowed());
   return ip;
}
Exemple #4
0
ImageProperty RemoteReleaseControlImpl::GetImageProperty(unsigned int uiImagePropertyId) const
{
   // TODO implement
   Variant value;
   value.Set<unsigned char>(42);
   value.SetType(Variant::typeUInt8);

   return ImageProperty(T_enSDKVariant::variantGphoto2, uiImagePropertyId, value, true);
}
Exemple #5
0
ImageProperty RemoteReleaseControlImpl::MapShootingModeToImagePropertyValue(T_enShootingMode enShootingMode) const
{
   // TODO implement
   enShootingMode;

   Variant value;
   value.Set<unsigned char>(42);
   value.SetType(Variant::typeUInt8);

   return ImageProperty(T_enSDKVariant::variantGphoto2, 0, value, true);
}
Exemple #6
0
void RemoteReleaseControlImpl::AsyncRelease()
{
   // if another transfer is in progress, wait for completion
   if (m_evtReleaseImageTransferInProgress.Wait(0))
   {
      m_evtReleaseImageTransferDone.Wait();
   }

   m_evtReleaseImageTransferInProgress.Set();


   // set save target
   ShutterReleaseSettings::T_enSaveTarget enSaveTarget;
   {
      LightweightMutex::LockType lock(m_mtxShutterReleaseSettings);
      enSaveTarget = m_shutterReleaseSettings.SaveTarget();
   }

   PropertyAccess pa(m_hCamera);
   Variant val;
   // note: PSREC doesn't have a value for saveToBoth
   val.Set<prUInt16>(
      enSaveTarget == ShutterReleaseSettings::saveToHost ? 0x0002 :
      enSaveTarget == ShutterReleaseSettings::saveToCamera ? 0x0008 : 0x000a );
   val.SetType(Variant::typeUInt16);
   pa.Set(prPTP_DEV_PROP_CAPTURE_TRANSFER_MODE, val);

   Timer releaseTimer;
   releaseTimer.Start();

   // may return prWAIT_TIMEOUT_ERROR?, prINVALID_FN_CALL, prINVALID_HANDLE, prMEM_ALLOC_FAILED or @ERR
   prResponse err = PR_RC_Release(m_hCamera);
   LOG_TRACE(_T("PR_RC_Release(%08x) returned %08x\n"), m_hCamera, err);

   if (err != prOK)
      m_subjectStateEvent.Call(RemoteReleaseControl::stateEventReleaseError, 0);

   CheckError(_T("PR_RC_Release"), err, __FILE__, __LINE__);

   releaseTimer.Stop();
   LOG_TRACE(_T("PR_RC_Release took %u ms\n"), unsigned(releaseTimer.Elapsed() * 1000));

   // wait for event
   m_evtReleaseImageReady.Wait();

   try
   {
      StartImageDownload(m_hReleaseImage, true);
   }
   catch (const CameraException&)
   {
      m_subjectStateEvent.Call(RemoteReleaseControl::stateEventReleaseError, 0);
   }
}
Exemple #7
0
void PropertyAccess::ReadValidValues(DeviceProperty& dp, CameraWidget* widget, int _type)
{
   CameraWidgetType type = (CameraWidgetType)_type;

   if (type == GP_WIDGET_RANGE)
   {
      float minValue = 0.0, maxValue = 0.0, increment = 0.0;
      int ret = gp_widget_get_range(widget, &minValue, &maxValue, &increment);
      CheckError(_T("gp_widget_get_range"), ret, __FILE__, __LINE__);

      for (float floatValue = minValue; floatValue < maxValue; floatValue += increment)
      {
         Variant value;
         value.Set<float>(floatValue);
         value.SetType(Variant::typeFloat);

         dp.ValidValues().push_back(value);
      }
   }

   if (type == GP_WIDGET_RADIO ||
      type == GP_WIDGET_MENU)
   {
      int choiceCount = gp_widget_count_choices(widget);

      for (int index = 0; index < choiceCount; index++)
      {
         const char* choiceText = nullptr;
         int ret = gp_widget_get_choice(widget, index, &choiceText);
         CheckError(_T("gp_widget_get_choice"), ret, __FILE__, __LINE__);

         Variant value;
         value.Set<CString>(CString(choiceText));
         value.SetType(Variant::typeString);

         dp.ValidValues().push_back(value);
      }
   }
}
Exemple #8
0
   virtual void SetOutputType(Viewfinder::T_enOutputType enOutputType) override
   {
      // note that T_enOutputType values exactly correspond to values
      // expected by prPTP_DEV_PROP_CAMERA_OUTPUT
      prUInt8 output = static_cast<prUInt8>(enOutputType);

      Variant outputValue;
      outputValue.Set(output);
      outputValue.SetType(Variant::typeUInt8);

      PropertyAccess access(m_hCamera);
      access.Set(prPTP_DEV_PROP_CAMERA_OUTPUT, outputValue);
   }
Exemple #9
0
ImageProperty RemoteReleaseControlImpl::MapShootingModeToImagePropertyValue(RemoteReleaseControl::T_enShootingMode enShootingMode) const
{
   prUInt8 uiValue = 0;
   switch (enShootingMode)
   {
   case RemoteReleaseControl::shootingModeP:    uiValue = 0x01; break;
   case RemoteReleaseControl::shootingModeTv:   uiValue = 0x02; break;
   case RemoteReleaseControl::shootingModeAv:   uiValue = 0x03; break;
   case RemoteReleaseControl::shootingModeM:    uiValue = 0x04; break;
   default:
      ATLASSERT(false);
      break;
   }

   Variant value;
   value.Set(uiValue);
   value.SetType(Variant::typeUInt8);

   return ImageProperty(variantPsrec, prPTP_DEV_PROP_EXPOSURE_MODE, value, false);
}