Visual Servoing Platform  version 3.0.0
vpDirectShowSampleGrabberI.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * DirectShow framegrabber callback.
32  *
33  * Authors:
34  * Bruno Renier
35  *
36  *****************************************************************************/
37 
38 #ifndef vpDirectShowSampleGrabberI_hh
39 #define vpDirectShowSampleGrabberI_hh
40 
41 #ifndef DOXYGEN_SHOULD_SKIP_THIS
42 
43 #include <visp3/core/vpConfig.h>
44 #if ( defined(VISP_HAVE_DIRECTSHOW) )
45 
46 #include <qedit.h>
47 #include <stdio.h>
48 #include <dshow.h>
49 
50 #include <visp3/core/vpImage.h>
51 #include <visp3/core/vpRGBa.h>
52 
57 class VISP_EXPORT vpDirectShowSampleGrabberI : public ISampleGrabberCB
58 {
59  vpDirectShowSampleGrabberI();
60  virtual ~vpDirectShowSampleGrabberI();
61 
62  //needed by the interface
63  STDMETHODIMP_(ULONG) AddRef() { return 1; }
64  STDMETHODIMP_(ULONG) Release() { return 2; }
65 
66  STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
67 
68  //not implemented
69  STDMETHODIMP SampleCB(double Time, IMediaSample *pSample)
70  {
71  return E_NOTIMPL;
72  }
73 
74  //our callback function
75  STDMETHODIMP BufferCB(double Time, BYTE *pBuffer, long BufferLen);
76 
77 private:
78  //the currently connected media type
79  AM_MEDIA_TYPE connectedMediaType;
80 
81  //true if the source media type is not a standard one
82  bool specialMediaType;
83  //true if the image needs to be flipped (only for special media types)
84  bool invertedSource;
85 
86  //booleans used to signal a demand from acquire
87  bool acqGrayDemand;
88  bool acqRGBaDemand;
89 
90  //pointer on the image to fill during the next callback if there has been a demand
91  vpImage<vpRGBa> * rgbaIm;
92  vpImage<unsigned char> * grayIm;
93 
94  //semaphore used to synchronize the productor (callback) and the consumer (acquire)
95  HANDLE copySem;
96 
97  friend class vpDirectShowGrabberImpl;
98 };
99 
100 #endif
101 #endif
102 #endif