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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
/************************************************************************/
/*
*
* Filename     :  MilCaptureBase.H
* Revision     :  10.30.0643
* Content      :  This file contains the interface structure required for 
*                 MIL Capture DirectShow Filter.
*
* Comments     :  Some defines may be here but not yet
*                 implemented in the library.
*
* Copyright © Matrox Electronic Systems Ltd., 1992-2018.
* All Rights Reserved
*************************************************************************/
 
#pragma once
#pragma warning(disable:4995)
 
#include <initguid.h>
#include "MilDSFCaptureGUID.h"
 
#include <mil.h>
 
#define MEDIASUBTYPE_INVERTED 0x10000000L
enum MEDIASUBTYPE_FORMAT
{
   MF_UNKNOWN     = -1,
   MF_RGB32       = 0,
   MF_YUV16       = 1,
   MF_NV12        = 2,
   MF_RGB24       = 3,
   MF_ARGB32      = 4,
   MF_RGB32_INV   = MEDIASUBTYPE_INVERTED|MF_RGB32,
   MF_RGB24_INV   = MEDIASUBTYPE_INVERTED|MF_RGB24,
   MF_ARGB32_INV  = MEDIASUBTYPE_INVERTED|MF_ARGB32,
};
 
enum CAPTURE_BUFFER_FORMAT
{
   CBF_UNKNOWN    = -1,
   CBF_BGR32      = 0,
   CBF_YUV16_YUYV = 1,
   CBF_MONO8      = 2,
};
 
enum PinDbgParam
   {
   PRINT_PIN_FRAME_COUNTER,
   PRINT_PIN_TIMESTAMP,
   };
 
/////////////////////////////////////////////////////////////////
//
// Interface         : IMilCapture
//
// Synopsis          : Access the system
//
// Comments          : for the functions begining with "sys" they are
//                      equivalent to Msys from Mil but you do not
//                      need to place the MIL_ID of the system
//
/////////////////////////////////////////////////////////////////
DECLARE_INTERFACE_(IMilCapture, IBaseFilter)
   {
   // USE THIS METHOD BEFORE ADDING THE FILTER
#if UNICODE
#define setSystemInfo setSystemInfoW
#else
#define setSystemInfo setSystemInfoA
#endif
 
   STDMETHOD(setSystemInfoA)
      ( THIS_
      const char* systemName, // [in] system descriptor string
      MIL_INT devNum // [in] system Number
      )  PURE;
 
   STDMETHOD(setSystemInfoW)
      ( THIS_
      const wchar_t* systemName, // [in] system descriptor string
      MIL_INT devNum // [in] system Number
      )  PURE;
 
   STDMETHOD(getAppID)
      ( THIS_
      MIL_ID* appID  // [out] adress to contain the returning application MIL_ID
      )  PURE;
 
   // -------------------------------------------------------------------------
   // Mil System exposed function
   // -------------------------------------------------------------------------
   // Same Call as Mil MsysControl without SystemId
   STDMETHOD(sysControl)
      ( THIS_
      MIL_INT64 ControlType,
      MIL_INT ControlValue
      )  PURE;
 
   // Same Call as Mil MsysGetHookInfo without SystemId
   STDMETHOD(sysGetHookInfo)
      ( THIS_
      MIL_ID EventId,
      MIL_INT64 InquireType,
      MIL_INT* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MsysHookFunction without SystemId
   STDMETHOD(sysHookFunction)
      ( THIS_
      MIL_INT HookType,
      MIL_SYS_HOOK_FUNCTION_PTR HookHandlerPtr,
      void* UserDataPtr
      )  PURE;
 
   // *************************************************************************
   // Multiple definition for sysInquire to support all output format
   // *************************************************************************
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_INT32* UserVarPtr 
      )  PURE;
 
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_INT64* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_TEXT_CHAR* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_DOUBLE* UserVarPtr
      )  PURE;
 
#if M_MIL_SAFE_TYPE_SUPPORTS_UNSIGNED
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_UINT32* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MsysInquire without SystemId
   STDMETHOD(sysInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_UINT64* UserVarPtr
      )  PURE;
#endif // M_MIL_SAFE_TYPE_SUPPORTS_UNSIGNED
 
   };
 
 
/////////////////////////////////////////////////////////////////
//
// Interface         : IMilCapturePin
//
// Synopsis          : Access the digitizer
//
// Comments          : for the functions begining with "dig" they are
//                      equivalent to Mdig call from Mil but you do not
//                      need to place the MIL_ID of the Digitizer
//
/////////////////////////////////////////////////////////////////
DECLARE_INTERFACE_(IMilCapturePin, IPin)
   {
#if UNICODE
#define set_DigitizerInfo set_DigitizerInfoW
#else
#define set_DigitizerInfo set_DigitizerInfoA
#endif
 
   STDMETHOD(DigAlloc)
      (THIS_
         bool bRealloc = false
         )  PURE;
 
   STDMETHOD(DigFree)
      (THIS_
         )  PURE;
 
   STDMETHOD(set_DigitizerInfoW)
      ( THIS_
      MIL_INT DevNum,   // [in] Digitizer Number.
      MIL_INT64 ChNum,  // [in] Digitizer channel Number.
      const wchar_t* DCFPath    // [in] complete string to represent the DCF.
      )  PURE;
 
   STDMETHOD(set_DigitizerInfoA)
      ( THIS_
      MIL_INT DevNum,   // [in] Digitizer Number.
      MIL_INT64 ChNum,  // [in] Digitizer channel Number.
      const char* DCFPath    // [in] complete string to represent the DCF.
      )  PURE;
 
   STDMETHOD(get_FIFOSize)
      ( THIS_
      MIL_INT* FIFOSize // [out] Number of buffer to allocate for MdigProcess.
      )  PURE;
 
   STDMETHOD(set_FIFOSize)
      ( THIS_
      MIL_INT FIFOSize // [in] Number of buffer to allocate for MdigProcess.
      )  PURE;
 
   STDMETHOD(is_DigAllocated)
      ( THIS_
      )  PURE;
 
   STDMETHOD(set_DebugParam)
      ( THIS_
      PinDbgParam DebugOptionType, // [in] Debug parameter ID.
      MIL_INT DebugOptionValue // [in] Value to set.
      )  PURE;
 
   STDMETHOD(get_DebugParam)
      ( THIS_
      PinDbgParam DebugOptionType, // [in] Debug parameter ID.
      MIL_INT* DebugOptionValue // [out] Value of the parameter.
      )  PURE;
 
   // Function moves specified MediaSubType Format to desired rank
   STDMETHOD(Set_PinMediaSubTypePriority)
      ( THIS_
      MEDIASUBTYPE_FORMAT mfID,  // [in] Pin MediaSubtype format to move.
      MIL_INT priorityIdx        // [in] position indexed at 0 of the rank in priority.
      )  PURE;
 
   STDMETHOD(Get_PinMediaSubTypeAtPriority)
      ( THIS_
      MIL_INT priorityIdx,       // [in] position indexed at 0 of the rank in priority.
      MEDIASUBTYPE_FORMAT* mfID  // [out] Pin MediaSubtype format pointer.
      )  PURE;
 
   // Function moves specified Capture Buffer Format to desired rank
   STDMETHOD(Set_CaptureBufferFormatPriority)
      ( THIS_
      CAPTURE_BUFFER_FORMAT cbfID,  // [in] Capture Buffer Format to move.
      MIL_INT priorityIdx           // [in] position indexed at 0 of the rank in priority.
      )  PURE;
 
   STDMETHOD(Get_CaptureBufferFormatAtPriority)
      ( THIS_
      MIL_INT priorityIdx,          // [in] position indexed at 0 of the rank in priority.
      CAPTURE_BUFFER_FORMAT* cbfID  // [out] Capture Buffer Format pointer.
      )  PURE;
 
   STDMETHOD_(void, Set_SyncFrameRate)
      ( THIS_
      BOOL bForce,                  // [in] force to use the custom value.
      MIL_DOUBLE fSyncFrameRate     // [in] specifies the frame rate used for synchronization.
      )  PURE;
 
   // Return if the value was forced to a custom value.
   // true means the value is set to a custom value
   // false means it uses the digitizer internal value
   STDMETHOD_(BOOL, IsForcedSyncFrameRate)
      ( THIS_
      MIL_DOUBLE* pfSyncFrameRate
      )  PURE;
 
 
   // -------------------------------------------------------------------------
   // Mil Digitizer exposed function
   // -------------------------------------------------------------------------
   // Same Call as Mil MdigChannel without DigId
   __declspec(deprecated) STDMETHOD(digChannel)
      ( THIS_
      MIL_INT64 channel
      )  PURE;
 
   // Same Call as Mil MdigControl without DigId
   STDMETHOD(digControl)
      ( THIS_
      MIL_INT64  ControlType,
      MIL_DOUBLE ControlValue
      )  PURE;
 
   // Same Call as Mil MdigControl without DigId
   STDMETHOD(digControl)
      ( THIS_
      MIL_INT64  ControlType,
      MIL_INT32 ControlValue
      )  PURE;
 
   // Same Call as Mil MdigControl without DigId
   STDMETHOD(digControl)
      ( THIS_
      MIL_INT64  ControlType,
      MIL_INT64 ControlValue
      )  PURE;
 
   // Same Call as Mil MdigControl without DigId
   STDMETHOD(digControl)
      (THIS_
         MIL_INT64  ControlType,
         MIL_CONST_TEXT_PTR ControlValue
         )  PURE;
 
#if UNICODE
#define digControlFeature digControlFeatureW
#else
#define digControlFeature digControlFeatureA
#endif
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      char* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT64* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_DOUBLE* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT32* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_UINT8* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureA)
      ( THIS_
      MIL_INT64 ControlFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      int FeatureValue
      )  PURE;
 
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_TEXT_CHAR* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT64* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_DOUBLE* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT32* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_UINT8* FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigControlFeature without DigitizerId
   STDMETHOD(digControlFeatureW)
      ( THIS_
      MIL_INT64 ControlFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      int FeatureValue
      )  PURE;
 
   // *************************************************************************
   // Multiple definition for digGetHookInfo to support all output format
   // *************************************************************************
   // Same Call as Mil MdigGetHookInfo without DigId
   STDMETHOD(digGetHookInfo)
      ( THIS_
      MIL_ID EventId,
      MIL_INT64 InfoType,
      MIL_DOUBLE* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigGetHookInfo
   STDMETHOD(digGetHookInfo)
      ( THIS_
      MIL_ID EventId,
      MIL_INT64 InfoType,
      MIL_INT* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigHokfunction without DigId
   STDMETHOD(digHookFunction)
      ( THIS_
      MIL_INT HookType,
      MIL_DIG_HOOK_FUNCTION_PTR HookHandlerPtr,
      void* UserDataPtr
      )  PURE;
 
   // *************************************************************************
   // Multiple definition for digInquire to support all output format
   // *************************************************************************
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_INT32* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_INT64* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_TEXT_CHAR* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_DOUBLE* UserVarPtr
      )  PURE;
 
#if M_MIL_SAFE_TYPE_SUPPORTS_UNSIGNED
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_UINT32* UserVarPtr
      )  PURE;
 
   // Same Call as Mil MdigInquire without DigId
   STDMETHOD(digInquire)
      ( THIS_
      MIL_INT64 InquireType,
      MIL_UINT64* UserVarPtr
      )  PURE;
#endif // M_MIL_SAFE_TYPE_SUPPORTS_UNSIGNED
 
#if UNICODE
#define digInquireFeature digInquireFeatureW
#else
#define digInquireFeature digInquireFeatureA
#endif
 
   // Same Call as Mil MdigInquireFeature without DigitizerId
   STDMETHOD(digInquireFeatureA)
      ( THIS_
      MIL_INT64 InquireFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      char* FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureA)
      ( THIS_
      MIL_INT64 InquireFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT64 *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureA)
      ( THIS_
      MIL_INT64 InquireFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_DOUBLE *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureA)
      ( THIS_
      MIL_INT64 InquireFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT32 *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureA)
      ( THIS_
      MIL_INT64 InquireFlag,
      const char* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_UINT8 *FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigInquireFeature without DigitizerId
   STDMETHOD(digInquireFeatureW)
      ( THIS_
      MIL_INT64 InquireFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_TEXT_CHAR* FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureW)
      ( THIS_
      MIL_INT64 InquireFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT64 *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureW)
      ( THIS_
      MIL_INT64 InquireFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_DOUBLE *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureW)
      ( THIS_
      MIL_INT64 InquireFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_INT32 *FeatureValuePtr
      )  PURE;
 
   STDMETHOD(digInquireFeatureW)
      ( THIS_
      MIL_INT64 InquireFlag,
      const wchar_t* FeatureName,
      MIL_INT64 FeatureDataType,
      MIL_UINT8 *FeatureValuePtr
      )  PURE;
 
   // Same Call as Mil MdigReference without DigId
   __declspec(deprecated) STDMETHOD(digReference)
      ( THIS_
      MIL_INT64  ReferenceType,
      MIL_DOUBLE ReferenceLevel
      )  PURE;
   };
 
// callback definition
typedef void (*MANAGEDCALLBACKPROC)(MIL_ID bufID, AM_MEDIA_TYPE *pmt, void* userCallbackData);
 
/////////////////////////////////////////////////////////////////
//
// Interface         : IMilSampleGrabber
//
// Synopsis          : Receive hook on each Media Sample
//
// Comments          : 
//
/////////////////////////////////////////////////////////////////
DECLARE_INTERFACE_(IMilSampleGrabber, IUnknown)
   {
   STDMETHOD(RegisterCallback)
      ( THIS_
      MANAGEDCALLBACKPROC callback,
      void* UserCallbackData=NULL
      )  PURE;
 
   STDMETHOD(SetMediaType)
      ( THIS_
      const AM_MEDIA_TYPE *pType
      )  PURE;
   };