00001 /*============================================================================= 00002 Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved. 00003 00004 Redistribution of this file, in original or modified form, without 00005 prior written consent of Allied Vision Technologies is prohibited. 00006 00007 ------------------------------------------------------------------------------- 00008 00009 File: AncillaryData.cpp 00010 00011 Description: Implementation of class AVT::VmbAPI::AncillaryData. 00012 00013 ------------------------------------------------------------------------------- 00014 00015 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00016 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, 00017 NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00019 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00022 AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 =============================================================================*/ 00027 00028 #include <VimbaCPP/Include/AncillaryData.h> 00029 00030 #define IMAGE_CHUNK_TRAILER_LENGTH 8 00031 00032 00033 namespace AVT { 00034 namespace VmbAPI { 00035 00036 struct AncillaryData::Impl 00037 { 00038 VmbFrame_t *m_pFrame; 00039 }; 00040 00041 AncillaryData::AncillaryData() 00042 { 00043 // No default ctor 00044 } 00045 00046 AncillaryData::AncillaryData( const AncillaryData& ) 00047 { 00048 // No copy ctor 00049 } 00050 00051 AncillaryData& AncillaryData::operator=( const AncillaryData& ) 00052 { 00053 // No assignment operator 00054 return *this; 00055 } 00056 00057 AncillaryData::AncillaryData( VmbFrame_t *pFrame ) 00058 : m_pImpl( new Impl() ) 00059 { 00060 m_pImpl->m_pFrame = pFrame; 00061 } 00062 00063 AncillaryData::~AncillaryData() 00064 { 00065 delete m_pImpl; 00066 } 00067 00068 VmbErrorType AncillaryData::GetBuffer( VmbUchar_t* &rpValue ) 00069 { 00070 VmbErrorType result = VmbErrorNotSupported; 00071 00072 if (m_pImpl->m_pFrame->ancillarySize > 0) 00073 { 00074 rpValue = (VmbUchar_t*)m_pImpl->m_pFrame->buffer + m_pImpl->m_pFrame->imageSize + IMAGE_CHUNK_TRAILER_LENGTH; 00075 result = VmbErrorSuccess; 00076 } 00077 00078 return result; 00079 } 00080 00081 VmbErrorType AncillaryData::GetBuffer( const VmbUchar_t* &rpValue ) const 00082 { 00083 VmbErrorType result = VmbErrorNotSupported; 00084 00085 if (m_pImpl->m_pFrame->ancillarySize > 0) 00086 { 00087 rpValue = (VmbUchar_t*)m_pImpl->m_pFrame->buffer + m_pImpl->m_pFrame->imageSize + IMAGE_CHUNK_TRAILER_LENGTH; 00088 result = VmbErrorSuccess; 00089 } 00090 00091 return result; 00092 } 00093 00094 VmbErrorType AncillaryData::GetSize( VmbUint32_t &nSize ) const 00095 { 00096 nSize = m_pImpl->m_pFrame->ancillarySize; 00097 00098 return VmbErrorSuccess; 00099 } 00100 00101 VmbErrorType AncillaryData::Open() 00102 { 00103 VmbError_t res; 00104 VmbHandle_t hHandle; 00105 00106 res = VmbAncillaryDataOpen( m_pImpl->m_pFrame, &hHandle ); 00107 00108 if ( VmbErrorSuccess == res ) 00109 { 00110 SetHandle( hHandle ); 00111 } 00112 00113 return (VmbErrorType)res; 00114 } 00115 00116 VmbError_t AncillaryData::Close() 00117 { 00118 VmbError_t res = VmbErrorSuccess; 00119 00120 res = VmbAncillaryDataClose( GetHandle() ); 00121 00122 Reset(); 00123 00124 RevokeHandle(); 00125 00126 return (VmbErrorType)res; 00127 } 00128 00129 }} // namespace AVT::VmbAPI