1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
#include "filtre_orion.h"
#include <Mil.h>
#include <winbase.h>
#include <Windows.h>
/*definition de l'identifiant unique du filtre dans la base de registre*/
DEFINE_GUID(CLSID_Matrox_Orion,0x252d6dea, 0xeec5, 0x49ac, 0xb5, 0x46, 0x6a, 0xa4, 0x7d, 0xd4, 0x44, 0x44);
/*=============================================================*/
/*Declaration des structures de données pour les pins et la dll*/
/*=============================================================*/
//---------------------------------------------------------------------------------------------
const AMOVIESETUP_MEDIATYPE sudOpPinTypes =
{
&MEDIATYPE_Video, // Major type
&MEDIASUBTYPE_NULL // Minor type
};
const AMOVIESETUP_PIN sudOpPin[] =
{
{L"Capture", // Pin string name
FALSE, // Is it rendered
TRUE, // Is it an output
FALSE, // Can we have none
FALSE, // Can we have many
&CLSID_NULL, // Connects to filter
NULL, // Connects to pin
1, // Number of types
&sudOpPinTypes},{
L"Preview", // Pin string name
FALSE, // Is it rendered
TRUE, // Is it an output
FALSE, // Can we have none
FALSE, // Can we have many
&CLSID_NULL, // Connects to filter
NULL, // Connects to pin
1, // Number of types
&sudOpPinTypes
}
}; // Pin details
const AMOVIESETUP_FILTER sudOrionax =
{
&CLSID_Matrox_Orion, // Filter CLSID
L"Orion", // String name
MERIT_DO_NOT_USE, // Filter merit
2, // Number pins
sudOpPin // Pin details
};
// COM global table of objects in this dll
CFactoryTemplate g_Templates[] = {
{ L"Matrox Orion Capture Filter"
, &CLSID_VideoInputDeviceCategory
, COrion::CreateInstance
, NULL
, &sudOrionax }
};
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
/*===============================================*/
/*Fonction d'entree et d'initialisation de la dll*/
/*===============================================*/
//---------------------------------------------------------------------------------------------
/* DllRegisterServer
Exported entry points for registration and unregistration*/
STDAPI DllRegisterServer()
{
return AMovieDllRegisterServer2(TRUE);
}
/*DllUnregisterServer*/
STDAPI DllUnregisterServer()
{
return AMovieDllRegisterServer2(FALSE);
}
/*DllEntryPoint*/
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD dwReason,
LPVOID lpReserved)
{
return DllEntryPoint((HINSTANCE)(hModule), dwReason, lpReserved);
}
/*================================*/
/*Methodes pour le corps du filtre */
/*================================*/
//---------------------------------------------------------------------------------------------
/*Fonction appelée par CoCreateInstance*/
CUnknown * WINAPI COrion::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr){
/*teste la valeur de phr et affiche le message d'erreur associe si faux*/
ASSERT(phr);
/*on demande la creation du filtre*/
CUnknown * pUnk = new COrion(lpunk, phr);
if(!pUnk){
if(phr)
*phr = E_OUTOFMEMORY;
}
return pUnk;
}
/*Constructeur de la classe COrion*/
COrion::COrion(LPUNKNOWN lpunk, HRESULT *phr):
CSource(NAME("Orion"), lpunk, CLSID_Matrox_Orion){
ASSERT(phr);
CAutoLock cAutoLock(&m_cStateLock);
/*On alloue de la place pour
les pins du filtre*/
m_paStreams = (CSourceStream **) new COrionCapturePin*[2];
if (!m_paStreams){
if (phr)
*phr = E_OUTOFMEMORY;
return ;
}
/*==============================*/
/*initialisation du systeme MIL*/
/*==============================*/
int n;
/*Allocation de l'application MIL*/
MappAlloc(M_DEFAULT, &MilApplication);
/*Allocation du systeme MIL*/
MsysAlloc(M_SYSTEM_ORION, M_DEV0, M_DEFAULT, &MilSystem);
/*Allocation du digitizer*/
MdigAlloc(MilSystem, M_DEV0, "c:/Program Files/Matrox Imaging/drivers/orion/dcf/PAL.DCF", M_DEFAULT, &MilDigitizer);
MdigChannel(MilDigitizer, M_CH1);
/* Allocate sequence storage image buffers. */
for (n=0; n<NBGRAB; n++)
{
MbufAllocColor( M_DEFAULT, 3L, IMAGE_WIDTH, IMAGE_HEIGHT, 8L+M_UNSIGNED, M_IMAGE+M_GRAB+M_PROC, &MilImage[n]);
MbufAllocColor( M_DEFAULT, 3L, IMAGE_WIDTH, IMAGE_HEIGHT, 8L+M_UNSIGNED, M_IMAGE+M_GRAB+M_PROC, &MilImageCapt[n]);
}
/*Creation du display*/
MdispAlloc(MilSystem, M_DEV0, "M_PAL" , M_DEFAULT, &MilDisplay);
MbufAllocColor(M_DEFAULT, 3L, IMAGE_WIDTH, IMAGE_HEIGHT, 8L+M_UNSIGNED, M_IMAGE+M_DISP+M_PROC, &MilImageDisplay);
MdispSelect(MilDisplay, MilImageDisplay);
/*Une fois que la memoire est reservee,
on construit les pins*/
/*le pin de capture*/
m_paStreams[0] = new COrionCapturePin(phr, this, L"Capture Pin");
if(!m_paStreams[0]){
if(phr)
*phr = E_OUTOFMEMORY;
return ;
}
/*le pin de pre-visualisation*/
m_paStreams[1] = new COrionPreviewPin(phr, this, L"Preview Pin");
if(!m_paStreams[1]){
if(phr)
*phr = E_OUTOFMEMORY;
return ;
}
}
COrion::~COrion(){
int n;
for (n=0; n<NBGRAB; n++)
{
MbufFree(MilImage[n]);
MbufFree(MilImageCapt[n]);
}
MbufFree(MilImageDisplay);
MdispFree(MilDisplay);
MdigFree(MilDigitizer);
MsysFree(MilSystem);
MappFree(MilApplication);
} |
Partager