FrameHandler.cpp
Go to the documentation of this file.
1 /*=============================================================================
2  Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
3 
4  Redistribution of this file, in original or modified form, without
5  prior written consent of Allied Vision Technologies is prohibited.
6 
7 -------------------------------------------------------------------------------
8 
9  File: FrameHandler.cpp
10 
11  Description: Implementation of class AVT::VmbAPI::FrameHandler.
12 
13 -------------------------------------------------------------------------------
14 
15  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
16  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
17  NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
23  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 =============================================================================*/
27 
29 
31 
32 namespace AVT {
33 namespace VmbAPI {
34 
35 FrameHandler::FrameHandler( FramePtr pFrame, IFrameObserverPtr pFrameObserver )
36  : m_pFrame( pFrame )
37  , m_pObserver( pFrameObserver )
38  , m_pMutex( new Mutex() )
39 {
40 }
41 
43 {
44  return m_pFrame;
45 }
46 
47 bool FrameHandler::EnterWriteLock( bool bExclusive )
48 {
49  return m_conditionHelper.EnterWriteLock( m_pMutex, bExclusive );
50 }
51 
53 {
55 }
56 
58 {
60 }
61 
63 {
65 }
66 
67 void VMB_CALL FrameHandler::FrameDoneCallback( const VmbHandle_t /*handle*/, VmbFrame_t *pVmbFrame )
68 {
69  if ( NULL != pVmbFrame )
70  {
71  FrameHandler* pFrameHandler = reinterpret_cast<FrameHandler*>( pVmbFrame->context[FRAME_HDL] );
72  if ( NULL != pFrameHandler)
73  {
74  // Begin read lock frame handler
75 
76  if ( true == pFrameHandler->EnterReadLock() )
77  {
78  {
79  IFrameObserverPtr pObs;
80  if ( true == SP_ACCESS( pFrameHandler->m_pFrame )->GetObserver( pObs ))
81  {
82  SP_ACCESS( pObs )->FrameReceived( pFrameHandler->m_pFrame );
83  }
84  }// scope to destroy observer pointer before releasing the lock
85  // End read lock frame handler
86  pFrameHandler->ExitReadLock();
87  }
88  else
89  {
90  LOG_FREE_TEXT( "Could not lock frame handler. Skipping frame." )
91  }
92  }
93  else // No FrameHandler
94  {
95  LOG_FREE_TEXT( "No frame handler passed. Frame has been removed from the frame queue." )
96  }
97  }
98  else // pVmbFrame == NULL (Just for safety)
99  {
100  LOG_FREE_TEXT( "Received callback for already freed frame." )
101  }
102 }
103 
104 }}
bool EnterWriteLock(BasicLockable &rLockable, bool bExclusive=false)
NetPointer< Frame, AVT::VmbAPINET::Frame > FramePtr
#define SP_ACCESS(sp)
static void VMB_CALL FrameDoneCallback(const VmbHandle_t handle, VmbFrame_t *pFrame)
void ExitWriteLock(BasicLockable &rLockable)
void * context[4]
Definition: VimbaC.h:278
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:57
void * VmbHandle_t
bool EnterWriteLock(bool bExclusive=false)
FramePtr GetFrame() const
void ExitReadLock(BasicLockable &rLockable)
bool EnterReadLock(BasicLockable &rLockable)
FrameHandler(FramePtr pFrame, IFrameObserverPtr pFrameObserver)
ConditionHelper m_conditionHelper
Definition: FrameHandler.h:62


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Wed Jun 5 2019 22:22:40