diff --git a/src/firewirecamera.cpp b/src/firewirecamera.cpp index 7ee5e62c67fa0db645baef8cea30f2e4a336f202..82691e84e92a5bd3e129eae4d8c85cb379e9749d 100644 --- a/src/firewirecamera.cpp +++ b/src/firewirecamera.cpp @@ -945,6 +945,32 @@ void CFirewireCamera::set_ISO_speed(float speed) DEBUG_INFO("ok\n"); } +bool CFirewireCamera::is_feature_present(dc1394feature_t feature_id) +{ + dc1394error_t error; + dc1394bool_t present; + + DEBUG_INFO("Checking if the feature is present ... "); + error=dc1394_feature_is_present(this->camera_handle,feature_id,&present); + if ( error != DC1394_SUCCESS ) + { + DEBUG_INFO("failed\n"); + /* handle the error */ + throw CFirewireInternalException(_HERE_,error); + } + DEBUG_INFO("ok\n"); + if ( present == DC1394_TRUE) + { + DEBUG_INFO("\tFeature is present.\n"); + return true; + } + else + { + DEBUG_INFO("\tFeature is not present.\n"); + return false; + } +} + void CFirewireCamera::enable_feature(dc1394feature_t feature_id) { dc1394error_t error; @@ -1371,7 +1397,56 @@ void CFirewireCamera::set_white_balance_value(unsigned int u_b_value, unsigned i void CFirewireCamera::get_white_balance_value(unsigned int *u_b_value, unsigned int *v_r_value) { + dc1394error_t error; + dc1394bool_t present; + dc1394bool_t readable; + DEBUG_INFO("Checking if the feature is present ... "); + error=dc1394_feature_is_present(this->camera_handle,DC1394_FEATURE_WHITE_BALANCE,&present); + if ( error != DC1394_SUCCESS ) + { + DEBUG_INFO("failed\n"); + /* handle the error */ + throw CFirewireInternalException(_HERE_,error); + } + DEBUG_INFO("ok\n"); + if ( present == DC1394_TRUE) + { + DEBUG_INFO("\tFeature is present.\n"); + DEBUG_INFO("Checking the reading status of the feature ... "); + error=dc1394_feature_is_readable(this->camera_handle,DC1394_FEATURE_WHITE_BALANCE,&readable); + if ( error != DC1394_SUCCESS ) + { + DEBUG_INFO("failed\n"); + /* handle the error */ + throw CFirewireInternalException(_HERE_,error); + } + DEBUG_INFO("ok\n"); + if ( readable == DC1394_TRUE) + { + DEBUG_INFO("Reading the current value ... "); + error=dc1394_feature_whitebalance_get_value(this->camera_handle,u_b_value,v_r_value); + if ( error != DC1394_SUCCESS ) + { + DEBUG_INFO("failed\n"); + /* handle the error */ + throw CFirewireInternalException(_HERE_,error); + } + DEBUG_INFO("ok\n"); + } + else + { + DEBUG_INFO("Feature is not readable.\n"); + /* handle exception */ + throw CFirewireFeatureException(_HERE_,dc1394_feature_get_string(DC1394_FEATURE_WHITE_BALANCE),"Is not readable.\n"); + } + } + else + { + DEBUG_INFO("\tFeature is not present.\n"); + /* handle exception */ + throw CFirewireFeatureException(_HERE_,dc1394_feature_get_string(DC1394_FEATURE_WHITE_BALANCE),"Is not present.\n"); + } } void CFirewireCamera::reset(void) diff --git a/src/firewirecamera.h b/src/firewirecamera.h index a58234a1c8285a277f8d9a03316d797ecebaa5c6..3204265510852a3cf6d190f3b7c4d309e7b736f3 100644 --- a/src/firewirecamera.h +++ b/src/firewirecamera.h @@ -979,6 +979,7 @@ class CFirewireCamera //@} /** @name Functions to handle the camera features */ //@{ + bool is_feature_present(dc1394feature_t feature_id); void enable_feature(dc1394feature_t feature_id); void disable_feature(dc1394feature_t feature_id); bool is_feature_enabled(dc1394feature_t feature_id);