void show_storage_info( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo) { CAMStorageInfoPtr pStorInfo = 0; CAMStorageIDPtr pStorID = 0; int i; do { if (GetStorageIds( hCam, &pStorID)) { camcli_error( "Could not get storage IDs."); break; } if (pStorID->cntStorageIDs == 0) { camcli_error( "No storage IDs returned."); break; } printf ( "\n Storage information %s\n", pDevInfo->Model); printf ( " =================== %s\n", underline(pDevInfo->Model)); for (i = 0; i < pStorID->cntStorageIDs; i++) { if (GetStorageInfo( hCam, pStorID->StorageIDs[i], &pStorInfo)) { camcli_error( "Could not get storage info for id %d", pStorID->StorageIDs[i]); continue; } printf ( " StorageID: 0x%04X\n", pStorID->StorageIDs[i]); printf ( " StorageType: 0x%04X\t%s\n", pStorInfo->StorageType, GetCodeName( pStorInfo->StorageType, CAM_STORAGE)); printf ( " FilesystemType: 0x%04X\t%s\n", pStorInfo->FilesystemType, GetCodeName( pStorInfo->FilesystemType, CAM_FILESYSTEM)); printf ( " AccessCapability: 0x%04X\t%s\n", pStorInfo->AccessCapability, GetCodeName( pStorInfo->AccessCapability, CAM_STORAGE_ACCESS)); printf ( " MaxCapacity: %lld\n", pStorInfo->MaxCapacity); printf ( " FreeSpaceInBytes: %lld\n", pStorInfo->FreeSpaceInBytes); printf ( " FreeSpaceInImages: 0x%04X\n", pStorInfo->FreeSpaceInImages); printf ( " StorageDescription: %s\n", (pStorInfo->StorageDescription ? pStorInfo->StorageDescription : "[none]")); printf ( " VolumeLabel: %s\n\n", (pStorInfo->VolumeLabel ? pStorInfo->VolumeLabel : "[none]")); free( pStorInfo); pStorInfo = 0; } } while (0); if (pStorInfo); free( pStorInfo); if (pStorID) free( pStorID); return; }
void show_info( CAMDeviceInfoPtr pDevInfo) { printf("\n Camera information %s\n", pDevInfo->Model); printf(" ================== %s\n", underline(pDevInfo->Model)); printf(" Manufacturer: %s\n", pDevInfo->Manufacturer); printf(" SerialNumber: %s\n", pDevInfo->SerialNumber); printf(" DeviceVersion: %s\n", pDevInfo->DeviceVersion); printf(" ExtensionID: 0x%04X\n", pDevInfo->VendorExtensionID); printf(" ExtensionVersion: 0x%04X\n", pDevInfo->VendorExtensionVersion); printf(" ExtDescription: %s\n", pDevInfo->VendorExtensionDesc); if (pDevInfo->cntCaptureFormats == 0) printf( " CaptureFormats: [unknown]\n"); else { uint32_t ctr; uint16_t fmt; for (ctr = 0; ctr < pDevInfo->cntCaptureFormats; ctr++) { fmt = pDevInfo->CaptureFormats[ctr]; printf( "%s0x%04X %s\n", (ctr ? " " : " CaptureFormats: "), fmt, GetCodeName( fmt, CAM_OBJECT_FORMAT)); } } if (pDevInfo->cntImageFormats == 0) printf( " FileFormats: [unknown]\n"); else { uint32_t ctr; uint16_t fmt; for (ctr = 0; ctr < pDevInfo->cntImageFormats; ctr++) { fmt = pDevInfo->ImageFormats[ctr]; printf( "%s0x%04X %s\n", (ctr ? " " : " FileFormats: "), fmt, GetCodeName( fmt, CAM_OBJECT_FORMAT)); } } return; }
/*! ************************************************************************************* * \brief System trace log output in Wels * * \param pCtx instance pointer * \param kiLevel log iLevel ( WELS_LOG_QUIET, ERROR, WARNING, INFO, DEBUG ) * \param kpFmtStr formated string to mount * \param argv pData string argument * * \return NONE * * \note N/A ************************************************************************************* */ void WelsLogDefault( void *pCtx, const int32_t kiLevel, const str_t *kpFmtStr, va_list argv ) { sWelsEncCtx *pEncCtx = (sWelsEncCtx *)pCtx; iWelsLogLevel iVal = (kiLevel & g_iLevelLog); if ( 0 == iVal || NULL == pEncCtx ) // such iLevel not enabled { return; } else { str_t pBuf[WELS_LOG_BUF_SIZE+1] = {0}; const int32_t kiBufSize = sizeof(pBuf) / sizeof(pBuf[0]) - 1; int32_t iCurUsed = 0; int32_t iBufUsed = 0; int32_t iBufLeft = kiBufSize - iBufUsed; if ( pEncCtx ){ time_t l_time; #if defined(WIN32) #if defined(_MSC_VER) #if _MSC_VER >= 1500 struct tm t_now; #else//VC6 struct tm* t_now; #endif//_MSC_VER >= 1500 #endif//_MSC_VER #else//__GNUC__ struct tm* t_now; #endif//WIN32 #if defined( WIN32 ) struct _timeb tb; time(&l_time); #ifdef _MSC_VER #if _MSC_VER >= 1500 LOCALTIME(&t_now, &l_time); #else t_now = LOCALTIME(&l_time); if ( NULL == t_now ) { return; } #endif//_MSC_VER >= 1500 #endif//_MSC_VER FTIME(&tb); #elif defined( __GNUC__ ) struct timeval tv; time(&l_time); t_now = (struct tm *)LOCALTIME(&l_time); gettimeofday(&tv,NULL); #endif//WIN32 if (iBufLeft > 0){ #ifdef _MSC_VER #if _MSC_VER >= 1500 iCurUsed = SNPRINTF( &pBuf[iBufUsed], iBufLeft, iBufLeft, "[0x%p @ ", pEncCtx ); // confirmed_safe_unsafe_usage #else iCurUsed = SNPRINTF( &pBuf[iBufUsed], iBufLeft, "[0x%p @ ", pEncCtx ); // confirmed_safe_unsafe_usage #endif//_MSC_VER >= 1500 #endif//_MSC_VER if (iCurUsed >= 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } if ( iBufLeft > 0 ){ iCurUsed = GetCodeName( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; iCurUsed = GetLibName( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; pBuf[iBufUsed] = 'v'; ++ iBufUsed; -- iBufLeft; iCurUsed = GetVerNum( &pBuf[iBufUsed], iBufLeft ); if ( iCurUsed > 0 ){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } pBuf[iBufUsed] = ' '; ++ iBufUsed; -- iBufLeft; } if (iBufLeft > 0){ #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1500) iCurUsed = strftime(&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", &t_now); #else iCurUsed = strftime(&pBuf[iBufUsed], iBufLeft, "%y-%m-%d %H:%M:%S", t_now); #endif//WIN32.. if (iCurUsed > 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } if (iBufLeft > 0){ #if defined (WIN32) #ifdef _MSC_VER #if _MSC_VER >= 1500 iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, iBufLeft, ".%03.3u]: ", tb.millitm); // confirmed_safe_unsafe_usage #else iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tb.millitm); // confirmed_safe_unsafe_usage #endif//_MSC_VER >= 1500 #endif//_MSC_VER #elif defined (__GNUC__) iCurUsed = SNPRINTF(&pBuf[iBufUsed], iBufLeft, ".%3.3u]: ", tv.tv_usec/1000); // confirmed_safe_unsafe_usage #endif//WIN32 if (iCurUsed >= 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } else{ return; } } // fixed stack corruption issue on vs2008 if ( iBufLeft > 0 ){ int32_t i_shift = 0; str_t *pStr = NULL; pStr = GetLogTag( kiLevel, &i_shift ); if ( NULL != pCtx){ int32_t iLenTag = STRNLEN( pStr, 8 ); // confirmed_safe_unsafe_usage STRCAT( &pBuf[iBufUsed], iBufLeft, pStr ); // confirmed_safe_unsafe_usage iBufUsed += iLenTag; pBuf[iBufUsed] = ' '; iBufUsed++; ++iLenTag; iBufLeft -= iLenTag; } } if (iBufLeft > 0){ #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1500) int32_t len = 0; len = _vscprintf( kpFmtStr, argv ) // _vscprintf doesn't count + 1; // terminating '\0' iCurUsed = VSPRINTF(&pBuf[iBufUsed], len, kpFmtStr, argv); // confirmed_safe_unsafe_usage #else iCurUsed = VSPRINTF(&pBuf[iBufUsed], kpFmtStr, argv); // confirmed_safe_unsafe_usage #endif//WIN32.. if (iCurUsed > 0){ iBufUsed += iCurUsed; iBufLeft -= iCurUsed; } } #ifdef ENABLE_TRACE_FILE if (NULL != pEncCtx && NULL != pEncCtx->pFileLog){ if ( pEncCtx->uiSizeLog > MAX_TRACE_LOG_SIZE){ if (0 == fseek(pEncCtx->pFileLog, 0L, SEEK_SET)) pEncCtx->uiSizeLog = 0; } if ( iBufUsed > 0 && iBufUsed < WELS_LOG_BUF_SIZE ) { iCurUsed = fwrite(pBuf, 1, iBufUsed, pEncCtx->pFileLog); fflush( pEncCtx->pFileLog ); if ( iCurUsed == iBufUsed ) pEncCtx->uiSizeLog += iBufUsed; } } else{ #if defined(WIN32) && defined(_DEBUG) OutputDebugStringA(pBuf); #endif } #endif//ENABLE_TRACE_FILE } }
void getset_property( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo, OPTS *pOpts) { CAMPropertyDescPtr pProp = 0; if (validate_property( pDevInfo, pOpts->property)) { camcli_error( "The device does not support property 0x%04X", pOpts->property); return; } if (GetPropertyDesc( hCam, pOpts->property, &pProp)) { camcli_error( "Could not get device property description for 0x%04X", pOpts->property); return; } printf( "\n Get/Set Property %s\n", pDevInfo->Model); printf( " ================ %s\n", underline( pDevInfo->Model)); printf( " Property: 0x%04X\n", pProp->DevicePropertyCode); printf( " Description: %s\n", GetPropertyName( pDevInfo, pOpts->property)); printf( " DataType: %s\n", GetCodeName( pProp->DataType, CAM_DATATYPE)); printf( " %sValue: ", (pOpts->value ? "Previous" : " Current")); print_propval( pProp->DataType, pProp->cntCurrentValue, pProp->CurrentValue, (pProp->FormFlag == CAM_PROP_EnumForm)); printf("\n"); if (pOpts->value) { uint16_t ret; CAMPropertyValuePtr pValue = 0; ret = set_property( hCam, pProp->DevicePropertyCode, pOpts->value, pProp->DataType); if (ret == CAMERR_BADPARM) camcli_error( "Unable to set property value for this datatype"); else if (ret) camcli_error( "Unable to set property value - rc= %X", ret); else { ret = GetPropertyValue( hCam, pProp->DevicePropertyCode, pProp->DataType, &pValue); if (ret == 0) { printf( " NewValue: "); print_propval( pValue->DataType, pValue->cntValue, pValue->Value, (pProp->FormFlag == CAM_PROP_EnumForm)); printf("\n"); } else camcli_error( "Unable to get new property value - rc= %X", ret); } if (pValue) free( pValue); if (pProp) free( pProp); return; } printf( " DefaultValue: "); print_propval( pProp->DataType, pProp->cntDefaultValue, pProp->DefaultValue, (pProp->FormFlag == CAM_PROP_EnumForm)); printf("\n"); if (pProp->GetSet == CAM_PROP_ReadOnly) printf( " Read/Write: read only\n"); else printf( " Read/Write: read & write\n"); if (pProp->FormFlag == CAM_PROP_EnumForm) { if (pProp->Form.Enum.cntSupportedValues) { printf( " ValueFormat: enumeration\n"); printf( " AllowedValues: "); print_propval( pProp->DataType, pProp->Form.Enum.cntSupportedValues, pProp->Form.Enum.SupportedValues, 1); printf( "\n"); } } else if (pProp->FormFlag == CAM_PROP_RangeForm) { printf( " ValueFormat: range\n"); printf( " AllowedValues: "); print_propval( pProp->DataType, 1, pProp->Form.Range.MinimumValue, 1); printf( " - "); print_propval( pProp->DataType, 1, pProp->Form.Range.MaximumValue, 1); printf( "; step size: "); print_propval( pProp->DataType, 1, pProp->Form.Range.StepSize, 1); printf( "\n"); } else if (pProp->FormFlag != CAM_PROP_None) printf( " ValueFormat: %02X [not supported]\n", (uint8_t)pProp->FormFlag); if (pProp) free( pProp); return; }
void show_handle_info( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo, OPTS *pOpts) { uint32_t *pHandle; uint32_t *pEnd; struct tm *ptm; CAMObjectHandlePtr pHandles = 0; CAMObjectInfoPtr pObjInfo = 0; if (GetObjectHandles( hCam, 0xffffffff, 0, 0, &pHandles)) { camcli_error( "Could not get object handles"); return; } if (!validate_range( pHandles, pOpts, &pHandle, &pEnd)) { if (pHandles) free( pHandles); return; } printf ( "\n File information %s\n", pDevInfo->Model); printf ( " ================ %s\n", underline( pDevInfo->Model)); for (; pHandle <= pEnd; pHandle++) { if (GetObjectInfo( hCam, *pHandle, &pObjInfo)) { camcli_error( "Could not get object info for handle %d", *pHandle); continue; } printf ( " Handle: %04d\n", *pHandle); printf ( " Filename: %s\n", (pObjInfo->Filename ? pObjInfo->Filename : "[none]")); if (pObjInfo->CaptureDate == 0) ptm = 0; else ptm = localtime( &pObjInfo->CaptureDate); if (!ptm) printf ( " CaptureDate: [unknown]\n"); else printf ( " CaptureDate: %04d-%02d-%02d %02d:%02d:%02d\n", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); if (pObjInfo->ModificationDate == 0) ptm = 0; else ptm = localtime( &pObjInfo->ModificationDate); if (!ptm) printf ( " ModificationDate: [unknown]\n"); else printf ( " ModificationDate: %04d-%02d-%02d %02d:%02d:%02d\n", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); printf ( " Keywords: %s\n", (pObjInfo->Keywords ? pObjInfo->Keywords : "[none]")); printf ( " ProtectionStatus: 0x%04X\t%s\n", pObjInfo->ProtectionStatus, GetCodeName( pObjInfo->ProtectionStatus, CAM_PROTECTION)); printf ( "ObjectCompressedSize: %d\n", pObjInfo->ObjectCompressedSize); printf ( " ObjectFormat: 0x%04X\t%s\n", pObjInfo->ObjectFormat, GetCodeName( pObjInfo->ObjectFormat, CAM_OBJECT_FORMAT)); printf ( " ImagePixWidth: %d\n", pObjInfo->ImagePixWidth); printf ( " ImagePixHeight: %d\n", pObjInfo->ImagePixHeight); printf ( " ImageBitDepth: %d\n", pObjInfo->ImageBitDepth); printf ( " ThumbCompressedSize: %d\n", pObjInfo->ThumbCompressedSize); printf ( " ThumbFormat: 0x%04X\t%s\n", pObjInfo->ThumbFormat, GetCodeName( pObjInfo->ThumbFormat, CAM_OBJECT_FORMAT)); printf ( " ThumbPixWidth: %d\n", pObjInfo->ThumbPixWidth); printf ( " ThumbPixHeight: %d\n", pObjInfo->ThumbPixHeight); printf ( " ParentObject: %04d\n", pObjInfo->ParentObject); printf ( " AssociationType: 0x%04X\t%s\n", pObjInfo->AssociationType, GetCodeName( pObjInfo->AssociationType, CAM_ASSOCIATION)); printf ( " AssociationDesc: 0x%04X\n", pObjInfo->AssociationDesc); printf ( " SequenceNumber: 0x%04X\n", pObjInfo->SequenceNumber); printf ( " StorageID: 0x%04X\n\n", pObjInfo->StorageID); free( pObjInfo); pObjInfo = 0; } if (pObjInfo) free( pObjInfo); if (pHandles) free( pHandles); return; }