| 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 |
#ifdef HAVE_CONFIG_H |
|---|
| 29 |
# include "config.h" |
|---|
| 30 |
#endif |
|---|
| 31 |
|
|---|
| 32 |
#include <vlc_common.h> |
|---|
| 33 |
#include <vlc_vout.h> |
|---|
| 34 |
|
|---|
| 35 |
#ifndef _MSC_VER |
|---|
| 36 |
|
|---|
| 37 |
# define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE |
|---|
| 38 |
#endif |
|---|
| 39 |
|
|---|
| 40 |
#include "common.h" |
|---|
| 41 |
#include "filter.h" |
|---|
| 42 |
|
|---|
| 43 |
#define DEBUG_DSHOW 1 |
|---|
| 44 |
|
|---|
| 45 |
#define FILTER_NAME L"VideoLAN Capture Filter" |
|---|
| 46 |
#define PIN_NAME L"Capture" |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
const GUID CLSID_SystemDeviceEnum = {0x62be5d10, 0x60eb, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}}; |
|---|
| 53 |
const GUID CLSID_VideoInputDeviceCategory = {0x860BB310,0x5D01,0x11d0,{0xBD,0x3B,0x00,0xA0,0xC9,0x11,0xCE,0x86}}; |
|---|
| 54 |
const GUID CLSID_AudioInputDeviceCategory = {0x33d9a762, 0x90c8, 0x11d0, {0xbd, 0x43, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}}; |
|---|
| 55 |
|
|---|
| 56 |
extern const GUID IID_IPropertyBag; |
|---|
| 57 |
const GUID IID_ICreateDevEnum = {0x29840822, 0x5b84, 0x11d0, {0xbd, 0x3b, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86}}; |
|---|
| 58 |
const GUID IID_IFilterGraph = {0x56a8689f, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 59 |
const GUID IID_IMediaControl = {0x56a868b1, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 60 |
const GUID CLSID_FilterGraph = {0xe436ebb3, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
extern const GUID IID_IUnknown; |
|---|
| 64 |
|
|---|
| 65 |
extern const GUID IID_IPersist; |
|---|
| 66 |
const GUID IID_IMediaFilter = {0x56a86899, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; |
|---|
| 67 |
const GUID IID_IBaseFilter = {0x56a86895, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 68 |
const GUID IID_IPin = {0x56a86891, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; |
|---|
| 69 |
const GUID IID_IMemInputPin = {0x56a8689d, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; |
|---|
| 70 |
extern const GUID IID_IMemInputPin; |
|---|
| 71 |
|
|---|
| 72 |
const GUID IID_IEnumPins = {0x56a86892, 0x0ad4, 0x11ce, {0xb0,0x3a, 0x00,0x20,0xaf,0x0b,0xa7,0x70}}; |
|---|
| 73 |
const GUID IID_IEnumMediaTypes = {0x89c31040, 0x846b, 0x11ce, {0x97,0xd3, 0x00,0xaa,0x00,0x55,0x59,0x5a}}; |
|---|
| 74 |
|
|---|
| 75 |
const GUID IID_IAMBufferNegotiation = {0x56ed71a0, 0xaf5f, 0x11d0, {0xb3, 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5}}; |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
extern const GUID IID_ISpecifyPropertyPages; |
|---|
| 79 |
|
|---|
| 80 |
const GUID IID_IQualityControl = {0x56a868a5, 0x0ad4, 0x11ce, {0xb, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 81 |
|
|---|
| 82 |
const GUID CLSID_CaptureGraphBuilder2 = {0xBF87B6E1, 0x8C27, 0x11d0, {0xB3, 0xF0, 0x0, 0xAA, 0x00, 0x37, 0x61, 0xC5}}; |
|---|
| 83 |
|
|---|
| 84 |
const GUID IID_IGraphBuilder = {0x56a868a9, 0x0ad4, 0x11ce, {0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 85 |
|
|---|
| 86 |
const GUID IID_ICaptureGraphBuilder2 = {0x93E5A4E0, 0x2D50, 0x11d2, {0xAB, 0xFA, 0x00, 0xA0, 0xC9, 0xC6, 0xE3, 0x8D}}; |
|---|
| 87 |
|
|---|
| 88 |
const GUID IID_IAMTVAudio = {0x83EC1C30, 0x23D1, 0x11d1, {0x99, 0xE6, 0x00, 0xA0, 0xC9, 0x56, 0x02, 0x66}}; |
|---|
| 89 |
const GUID IID_IAMStreamConfig = {0xC6E13340, 0x30AC, 0x11d0, {0xA1, 0x8C, 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56}}; |
|---|
| 90 |
const GUID IID_IAMCrossbar = {0xC6E13380, 0x30AC, 0x11d0, {0xA1, 0x8C, 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56}}; |
|---|
| 91 |
const GUID IID_IAMTVTuner = {0x211A8766, 0x03AC, 0x11d1, {0x8D, 0x13, 0x00, 0xAA, 0x00, 0xBD, 0x83, 0x39}}; |
|---|
| 92 |
|
|---|
| 93 |
const GUID IID_IKsPropertySet = {0x31EFAC30, 0x515C, 0x11d0, {0xA9, 0xAA, 0x00, 0xAA, 0x00, 0x61, 0xBE, 0x93}}; |
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
const GUID FORMAT_VideoInfo = {0x05589f80, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
const GUID MEDIATYPE_Video = {0x73646976, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 102 |
const GUID MEDIATYPE_Interleaved = {0x73766169, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 103 |
const GUID MEDIATYPE_Stream = {0xe436eb83, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 104 |
const GUID MEDIASUBTYPE_PREVIEW_VIDEO = {0x2859e1da, 0xb81f, 0x4fbd, {0x94, 0x3b, 0xe2, 0x37, 0x24, 0xa1, 0xab, 0xb3}}; |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
const GUID MEDIASUBTYPE_RGB1 = {0xe436eb78, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 108 |
const GUID MEDIASUBTYPE_RGB4 = {0xe436eb79, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 109 |
const GUID MEDIASUBTYPE_RGB8 = {0xe436eb7a, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 110 |
const GUID MEDIASUBTYPE_RGB565 = {0xe436eb7b, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 111 |
const GUID MEDIASUBTYPE_RGB555 = {0xe436eb7c, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 112 |
const GUID MEDIASUBTYPE_RGB24 = {0xe436eb7d, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 113 |
const GUID MEDIASUBTYPE_RGB32 = {0xe436eb7e, 0x524f, 0x11ce, {0x9f, 0x53, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70}}; |
|---|
| 114 |
const GUID MEDIASUBTYPE_ARGB32 = {0x773c9ac0, 0x3274, 0x11d0, {0xb7, 0x24, 0x0, 0xaa, 0x0, 0x6c, 0x1a, 0x1}}; |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
const GUID MEDIASUBTYPE_YUYV = {0x56595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 118 |
const GUID MEDIASUBTYPE_Y411 = {0x31313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 119 |
const GUID MEDIASUBTYPE_Y211 = {0x31313259, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 120 |
const GUID MEDIASUBTYPE_YUY2 = {0x32595559, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 121 |
const GUID MEDIASUBTYPE_YVYU = {0x55595659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 122 |
const GUID MEDIASUBTYPE_UYVY = {0x59565955, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 |
const GUID MEDIASUBTYPE_YVU9 = {0x39555659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 126 |
const GUID MEDIASUBTYPE_YV12 = {0x32315659, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 127 |
const GUID MEDIASUBTYPE_IYUV = {0x56555949, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 128 |
const GUID MEDIASUBTYPE_Y41P = {0x50313459, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 129 |
const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 130 |
|
|---|
| 131 |
const GUID MEDIATYPE_Audio = {0x73647561, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 132 |
const GUID FORMAT_WaveFormatEx = {0x05589f81, 0xc356, 0x11ce, {0xbf, 0x01, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a}}; |
|---|
| 133 |
const GUID MEDIASUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 134 |
const GUID MEDIASUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
const GUID MEDIASUBTYPE_dvsd = {0x64737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 138 |
const GUID MEDIASUBTYPE_dvhd = {0x64687664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 139 |
const GUID MEDIASUBTYPE_dvsl = {0x6c737664, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
const GUID MEDIASUBTYPE_MPEG2_VIDEO = {0xe06d8026, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}}; |
|---|
| 143 |
const GUID MEDIASUBTYPE_MPEG2_PROGRAM = {0xe06d8022, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}}; |
|---|
| 144 |
const GUID MEDIASUBTYPE_MPEG2_TRANSPORT = {0xe06d8023, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}}; |
|---|
| 145 |
const GUID FORMAT_MPEG2Video = {0xe06d80e3, 0xdb46, 0x11cf, {0xb4, 0xd1, 0x00, 0x80, 0x5f, 0x6c, 0xbb, 0xea}}; |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
const GUID MEDIASUBTYPE_MJPG = {0x47504A4D, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
const GUID MEDIASUBTYPE_DIVX = {0x58564944, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; |
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
const GUID FORMAT_AnalogVideo = {0x482dde0, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 155 |
|
|---|
| 156 |
const GUID MEDIATYPE_AnalogVideo = {0x482dde1, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xab, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 157 |
|
|---|
| 158 |
const GUID MEDIASUBTYPE_AnalogVideo_NTSC_M = {0x482dde2, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 159 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_B = {0x482dde5, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 160 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_D = {0x482dde6, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 161 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_G = {0x482dde7, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 162 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_H = {0x482dde8, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 163 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_I = {0x482dde9, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 164 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_M = {0x482ddea, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 165 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_N = {0x482ddeb, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 166 |
const GUID MEDIASUBTYPE_AnalogVideo_PAL_N_COMBO = {0x482ddec, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 167 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_B = {0x482ddf0, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 168 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_D = {0x482ddf1, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 169 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_G = {0x482ddf2, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 170 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_H = {0x482ddf3, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 171 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_K = {0x482ddf4, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 172 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_K1 = {0x482ddf5, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 173 |
const GUID MEDIASUBTYPE_AnalogVideo_SECAM_L = {0x482ddf6, 0x7817, 0x11cf, {0x8a, 0x3, 0x0, 0xaa, 0x0, 0x6e, 0xcb, 0x65}}; |
|---|
| 174 |
|
|---|
| 175 |
const GUID AMPROPSETID_Pin= {0x9b00f101, 0x1567, 0x11d1, {0xb3, 0xf1, 0x0, 0xaa, 0x0, 0x37, 0x61, 0xc5}}; |
|---|
| 176 |
const GUID PIN_CATEGORY_ANALOGVIDEOIN= {0xfb6c4283, 0x0353, 0x11d1, {0x90, 0x5f, 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba}}; |
|---|
| 177 |
const GUID PIN_CATEGORY_CAPTURE= {0xfb6c4281, 0x0353, 0x11d1, {0x90, 0x5f, 0x0, 0x0, 0xc0, 0xcc, 0x16, 0xba}}; |
|---|
| 178 |
const GUID LOOK_UPSTREAM_ONLY= {0xac798be0, 0x98e3, 0x11d1, {0xb3, 0xf1, 0x0, 0xaa, 0x0, 0x37, 0x61, 0xc}}; |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
extern const GUID GUID_NULL; |
|---|
| 182 |
|
|---|
| 183 |
void WINAPI FreeMediaType( AM_MEDIA_TYPE& mt ) |
|---|
| 184 |
{ |
|---|
| 185 |
if( mt.cbFormat != 0 ) |
|---|
| 186 |
{ |
|---|
| 187 |
CoTaskMemFree( (PVOID)mt.pbFormat ); |
|---|
| 188 |
mt.cbFormat = 0; |
|---|
| 189 |
mt.pbFormat = NULL; |
|---|
| 190 |
} |
|---|
| 191 |
if( mt.pUnk != NULL ) |
|---|
| 192 |
{ |
|---|
| 193 |
mt.pUnk->Release(); |
|---|
| 194 |
mt.pUnk = NULL; |
|---|
| 195 |
} |
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
HRESULT WINAPI CopyMediaType( AM_MEDIA_TYPE *pmtTarget, |
|---|
| 199 |
const AM_MEDIA_TYPE *pmtSource ) |
|---|
| 200 |
{ |
|---|
| 201 |
*pmtTarget = *pmtSource; |
|---|
| 202 |
|
|---|
| 203 |
if( !pmtSource || !pmtTarget ) return S_FALSE; |
|---|
| 204 |
|
|---|
| 205 |
if( pmtSource->cbFormat && pmtSource->pbFormat ) |
|---|
| 206 |
{ |
|---|
| 207 |
pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc( pmtSource->cbFormat ); |
|---|
| 208 |
if( pmtTarget->pbFormat == NULL ) |
|---|
| 209 |
{ |
|---|
| 210 |
pmtTarget->cbFormat = 0; |
|---|
| 211 |
return E_OUTOFMEMORY; |
|---|
| 212 |
} |
|---|
| 213 |
else |
|---|
| 214 |
{ |
|---|
| 215 |
CopyMemory( (PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat, |
|---|
| 216 |
pmtTarget->cbFormat ); |
|---|
| 217 |
} |
|---|
| 218 |
} |
|---|
| 219 |
if( pmtTarget->pUnk != NULL ) |
|---|
| 220 |
{ |
|---|
| 221 |
pmtTarget->pUnk->AddRef(); |
|---|
| 222 |
} |
|---|
| 223 |
|
|---|
| 224 |
return S_OK; |
|---|
| 225 |
} |
|---|
| 226 |
|
|---|
| 227 |
int GetFourCCFromMediaType( const AM_MEDIA_TYPE &media_type ) |
|---|
| 228 |
{ |
|---|
| 229 |
int i_fourcc = 0; |
|---|
| 230 |
|
|---|
| 231 |
if( media_type.majortype == MEDIATYPE_Video ) |
|---|
| 232 |
{ |
|---|
| 233 |
|
|---|
| 234 |
if( 1 ) |
|---|
| 235 |
{ |
|---|
| 236 |
|
|---|
| 237 |
if( media_type.subtype == MEDIASUBTYPE_RGB1 ) |
|---|
| 238 |
i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '1' ); |
|---|
| 239 |
else if( media_type.subtype == MEDIASUBTYPE_RGB4 ) |
|---|
| 240 |
i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '4' ); |
|---|
| 241 |
else if( media_type.subtype == MEDIASUBTYPE_RGB8 ) |
|---|
| 242 |
i_fourcc = VLC_FOURCC( 'R', 'G', 'B', '8' ); |
|---|
| 243 |
else if( media_type.subtype == MEDIASUBTYPE_RGB555 ) |
|---|
| 244 |
i_fourcc = VLC_FOURCC( 'R', 'V', '1', '5' ); |
|---|
| 245 |
else if( media_type.subtype == MEDIASUBTYPE_RGB565 ) |
|---|
| 246 |
i_fourcc = VLC_FOURCC( 'R', 'V', '1', '6' ); |
|---|
| 247 |
else if( media_type.subtype == MEDIASUBTYPE_RGB24 ) |
|---|
| 248 |
i_fourcc = VLC_FOURCC( 'R', 'V', '2', '4' ); |
|---|
| 249 |
else if( media_type.subtype == MEDIASUBTYPE_RGB32 ) |
|---|
| 250 |
i_fourcc = VLC_FOURCC( 'R', 'V', '3', '2' ); |
|---|
| 251 |
else if( media_type.subtype == MEDIASUBTYPE_ARGB32 ) |
|---|
| 252 |
i_fourcc = VLC_FOURCC( 'R', 'G', 'B', 'A' ); |
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
else if( media_type.subtype == MEDIASUBTYPE_I420 ) |
|---|
| 256 |
i_fourcc = VLC_FOURCC( 'I', '4', '2', '0' ); |
|---|
| 257 |
else if( media_type.subtype == MEDIASUBTYPE_Y41P ) |
|---|
| 258 |
i_fourcc = VLC_FOURCC( 'I', '4', '1', '1' ); |
|---|
| 259 |
else if( media_type.subtype == MEDIASUBTYPE_YV12 ) |
|---|
| 260 |
i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' ); |
|---|
| 261 |
else if( media_type.subtype == MEDIASUBTYPE_IYUV ) |
|---|
| 262 |
i_fourcc = VLC_FOURCC( 'Y', 'V', '1', '2' ); |
|---|
| 263 |
else if( media_type.subtype == MEDIASUBTYPE_YVU9 ) |
|---|
| 264 |
i_fourcc = VLC_FOURCC( 'Y', 'V', 'U', '9' ); |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
else if( media_type.subtype == MEDIASUBTYPE_YVYU ) |
|---|
| 268 |
i_fourcc = VLC_FOURCC( 'Y', 'V', 'Y', 'U' ); |
|---|
| 269 |
else if( media_type.subtype == MEDIASUBTYPE_YUYV ) |
|---|
| 270 |
i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' ); |
|---|
| 271 |
else if( media_type.subtype == MEDIASUBTYPE_Y411 ) |
|---|
| 272 |
i_fourcc = VLC_FOURCC( 'I', '4', '1', 'N' ); |
|---|
| 273 |
else if( media_type.subtype == MEDIASUBTYPE_Y211 ) |
|---|
| 274 |
i_fourcc = VLC_FOURCC( 'Y', '2', '1', '1' ); |
|---|
| 275 |
else if( media_type.subtype == MEDIASUBTYPE_YUY2 ) |
|---|
| 276 |
i_fourcc = VLC_FOURCC( 'Y', 'U', 'Y', '2' ); |
|---|
| 277 |
else if( media_type.subtype == MEDIASUBTYPE_UYVY ) |
|---|
| 278 |
i_fourcc = VLC_FOURCC( 'U', 'Y', 'V', 'Y' ); |
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
else if( media_type.subtype == MEDIASUBTYPE_MPEG2_VIDEO ) |
|---|
| 282 |
i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'v' ); |
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
else if( media_type.subtype == MEDIASUBTYPE_DIVX ) |
|---|
| 286 |
i_fourcc = VLC_FOURCC( 'D', 'I', 'V', 'X' ); |
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
else if( media_type.subtype == MEDIASUBTYPE_dvsl ) |
|---|
| 290 |
i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'l' ); |
|---|
| 291 |
else if( media_type.subtype == MEDIASUBTYPE_dvsd ) |
|---|
| 292 |
i_fourcc = VLC_FOURCC( 'd', 'v', 's', 'd' ); |
|---|
| 293 |
else if( media_type.subtype == MEDIASUBTYPE_dvhd ) |
|---|
| 294 |
i_fourcc = VLC_FOURCC( 'd', 'v', 'h', 'd' ); |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
else if( media_type.subtype == MEDIASUBTYPE_MJPG ) |
|---|
| 298 |
i_fourcc = VLC_FOURCC( 'M', 'J', 'P', 'G' ); |
|---|
| 299 |
|
|---|
| 300 |
} |
|---|
| 301 |
} |
|---|
| 302 |
else if( media_type.majortype == MEDIATYPE_Audio ) |
|---|
| 303 |
{ |
|---|
| 304 |
|
|---|
| 305 |
if( media_type.formattype == FORMAT_WaveFormatEx ) |
|---|
| 306 |
{ |
|---|
| 307 |
if( media_type.subtype == MEDIASUBTYPE_PCM ) |
|---|
| 308 |
i_fourcc = VLC_FOURCC( 'a', 'r', 'a', 'w' ); |
|---|
| 309 |
else if( media_type.subtype == MEDIASUBTYPE_IEEE_FLOAT ) |
|---|
| 310 |
i_fourcc = VLC_FOURCC( 'f', 'l', '3', '2' ); |
|---|
| 311 |
} |
|---|
| 312 |
} |
|---|
| 313 |
else if( media_type.majortype == MEDIATYPE_Stream ) |
|---|
| 314 |
{ |
|---|
| 315 |
if( media_type.subtype == MEDIASUBTYPE_MPEG2_PROGRAM ) |
|---|
| 316 |
i_fourcc = VLC_FOURCC( 'm', 'p', '2', 'p' ); |
|---|
| 317 |
else if( media_type.subtype == MEDIASUBTYPE_MPEG2_TRANSPORT ) |
|---|
| 318 |
i_fourcc = VLC_FOURCC( 'm', 'p', '2', 't' ); |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
return i_fourcc; |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
CapturePin::CapturePin( vlc_object_t *_p_input, access_sys_t *_p_sys, |
|---|
| 329 |
CaptureFilter *_p_filter, |
|---|
| 330 |
AM_MEDIA_TYPE *mt, size_t mt_count ) |
|---|
| 331 |
: p_input( _p_input ), p_sys( _p_sys ), p_filter( _p_filter ), |
|---|
| 332 |
p_connected_pin( NULL ), media_types(mt), media_type_count(mt_count), |
|---|
| 333 |
i_ref( 1 ) |
|---|
| 334 |
{ |
|---|
| 335 |
cx_media_type.majortype = mt[0].majortype; |
|---|
| 336 |
cx_media_type.subtype = GUID_NULL; |
|---|
| 337 |
cx_media_type.pbFormat = NULL; |
|---|
| 338 |
cx_media_type.cbFormat = 0; |
|---|
| 339 |
cx_media_type.pUnk = NULL; |
|---|
| 340 |
} |
|---|
| 341 |
|
|---|
| 342 |
CapturePin::~CapturePin() |
|---|
| 343 |
{ |
|---|
| 344 |
#ifdef DEBUG_DSHOW |
|---|
| 345 |
msg_Dbg( p_input, "CapturePin::~CapturePin" ); |
|---|
| 346 |
#endif |
|---|
| 347 |
for( size_t c=0; c<media_type_count; c++ ) |
|---|
| 348 |
{ |
|---|
| 349 |
FreeMediaType(media_types[c]); |
|---|
| 350 |
} |
|---|
| 351 |
FreeMediaType(cx_media_type); |
|---|
| 352 |
} |
|---|
| 353 |
|
|---|
| 354 |
HRESULT CapturePin::CustomGetSample( VLCMediaSample *vlc_sample ) |
|---|
| 355 |
{ |
|---|
| 356 |
#if 0 //def DEBUG_DSHOW |
|---|
| 357 |
msg_Dbg( p_input, "CapturePin::CustomGetSample" ); |
|---|
| 358 |
#endif |
|---|
| 359 |
|
|---|
| 360 |
vlc_mutex_lock( &p_sys->lock ); |
|---|
| 361 |
if( samples_queue.size() ) |
|---|
| 362 |
{ |
|---|
| 363 |
*vlc_sample = samples_queue.back(); |
|---|
| 364 |
samples_queue.pop_back(); |
|---|
| 365 |
vlc_mutex_unlock( &p_sys->lock ); |
|---|
| 366 |
return S_OK; |
|---|
| 367 |
} |
|---|
| 368 |
vlc_mutex_unlock( &p_sys->lock ); |
|---|
| 369 |
return S_FALSE; |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
AM_MEDIA_TYPE &CapturePin::CustomGetMediaType() |
|---|
| 373 |
{ |
|---|
| 374 |
return cx_media_type; |
|---|
| 375 |
} |
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
STDMETHODIMP CapturePin::QueryInterface(REFIID riid, void **ppv) |
|---|
| 379 |
{ |
|---|
| 380 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 381 |
msg_Dbg( p_input, "CapturePin::QueryInterface" ); |
|---|
| 382 |
#endif |
|---|
| 383 |
|
|---|
| 384 |
if( riid == IID_IUnknown || |
|---|
| 385 |
riid == IID_IPin ) |
|---|
| 386 |
{ |
|---|
| 387 |
AddRef(); |
|---|
| 388 |
*ppv = (IPin *)this; |
|---|
| 389 |
return NOERROR; |
|---|
| 390 |
} |
|---|
| 391 |
if( riid == IID_IMemInputPin ) |
|---|
| 392 |
{ |
|---|
| 393 |
AddRef(); |
|---|
| 394 |
*ppv = (IMemInputPin *)this; |
|---|
| 395 |
return NOERROR; |
|---|
| 396 |
} |
|---|
| 397 |
else |
|---|
| 398 |
{ |
|---|
| 399 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 400 |
msg_Dbg( p_input, "CapturePin::QueryInterface() failed for: " |
|---|
| 401 |
"%04X-%02X-%02X-%02X%02X%02X%02X%02X%02X%02X%02X", |
|---|
| 402 |
(int)riid.Data1, (int)riid.Data2, (int)riid.Data3, |
|---|
| 403 |
static_cast<int>(riid.Data4[0]), (int)riid.Data4[1], |
|---|
| 404 |
(int)riid.Data4[2], (int)riid.Data4[3], |
|---|
| 405 |
(int)riid.Data4[4], (int)riid.Data4[5], |
|---|
| 406 |
(int)riid.Data4[6], (int)riid.Data4[7] ); |
|---|
| 407 |
#endif |
|---|
| 408 |
*ppv = NULL; |
|---|
| 409 |
return E_NOINTERFACE; |
|---|
| 410 |
} |
|---|
| 411 |
} |
|---|
| 412 |
|
|---|
| 413 |
STDMETHODIMP_(ULONG) CapturePin::AddRef() |
|---|
| 414 |
{ |
|---|
| 415 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 416 |
msg_Dbg( p_input, "CapturePin::AddRef (ref: %i)", i_ref ); |
|---|
| 417 |
#endif |
|---|
| 418 |
|
|---|
| 419 |
return i_ref++; |
|---|
| 420 |
}; |
|---|
| 421 |
STDMETHODIMP_(ULONG) CapturePin::Release() |
|---|
| 422 |
{ |
|---|
| 423 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 424 |
msg_Dbg( p_input, "CapturePin::Release (ref: %i)", i_ref ); |
|---|
| 425 |
#endif |
|---|
| 426 |
|
|---|
| 427 |
if( !InterlockedDecrement(&i_ref) ) delete this; |
|---|
| 428 |
|
|---|
| 429 |
return 0; |
|---|
| 430 |
}; |
|---|
| 431 |
|
|---|
| 432 |
|
|---|
| 433 |
STDMETHODIMP CapturePin::Connect( IPin * pReceivePin, |
|---|
| 434 |
const AM_MEDIA_TYPE *pmt ) |
|---|
| 435 |
{ |
|---|
| 436 |
if( State_Running == p_filter->state ) |
|---|
| 437 |
{ |
|---|
| 438 |
msg_Dbg( p_input, "CapturePin::Connect [not stopped]" ); |
|---|
| 439 |
return VFW_E_NOT_STOPPED; |
|---|
| 440 |
} |
|---|
| 441 |
|
|---|
| 442 |
if( p_connected_pin ) |
|---|
| 443 |
{ |
|---|
| 444 |
msg_Dbg( p_input, "CapturePin::Connect [already connected]" ); |
|---|
| 445 |
return VFW_E_ALREADY_CONNECTED; |
|---|
| 446 |
} |
|---|
| 447 |
|
|---|
| 448 |
if( !pmt ) return S_OK; |
|---|
| 449 |
|
|---|
| 450 |
if( GUID_NULL != pmt->majortype && |
|---|
| 451 |
media_types[0].majortype != pmt->majortype ) |
|---|
| 452 |
{ |
|---|
| 453 |
msg_Dbg( p_input, "CapturePin::Connect [media major type mismatch]" ); |
|---|
| 454 |
return S_FALSE; |
|---|
| 455 |
} |
|---|
| 456 |
|
|---|
| 457 |
if( GUID_NULL != pmt->subtype && !GetFourCCFromMediaType(*pmt) ) |
|---|
| 458 |
{ |
|---|
| 459 |
msg_Dbg( p_input, "CapturePin::Connect [media subtype type " |
|---|
| 460 |
"not supported]" ); |
|---|
| 461 |
return S_FALSE; |
|---|
| 462 |
} |
|---|
| 463 |
|
|---|
| 464 |
if( pmt->pbFormat && pmt->majortype == MEDIATYPE_Video ) |
|---|
| 465 |
{ |
|---|
| 466 |
if( !((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight || |
|---|
| 467 |
!((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth ) |
|---|
| 468 |
{ |
|---|
| 469 |
msg_Dbg( p_input, "CapturePin::Connect " |
|---|
| 470 |
"[video width/height == 0 ]" ); |
|---|
| 471 |
return S_FALSE; |
|---|
| 472 |
} |
|---|
| 473 |
} |
|---|
| 474 |
|
|---|
| 475 |
msg_Dbg( p_input, "CapturePin::Connect [OK]" ); |
|---|
| 476 |
return S_OK; |
|---|
| 477 |
} |
|---|
| 478 |
STDMETHODIMP CapturePin::ReceiveConnection( IPin * pConnector, |
|---|
| 479 |
const AM_MEDIA_TYPE *pmt ) |
|---|
| 480 |
{ |
|---|
| 481 |
if( State_Stopped != p_filter->state ) |
|---|
| 482 |
{ |
|---|
| 483 |
msg_Dbg( p_input, "CapturePin::ReceiveConnection [not stopped]" ); |
|---|
| 484 |
return VFW_E_NOT_STOPPED; |
|---|
| 485 |
} |
|---|
| 486 |
|
|---|
| 487 |
if( !pConnector || !pmt ) |
|---|
| 488 |
{ |
|---|
| 489 |
msg_Dbg( p_input, "CapturePin::ReceiveConnection [null pointer]" ); |
|---|
| 490 |
return E_POINTER; |
|---|
| 491 |
} |
|---|
| 492 |
|
|---|
| 493 |
if( p_connected_pin ) |
|---|
| 494 |
{ |
|---|
| 495 |
msg_Dbg( p_input, "CapturePin::ReceiveConnection [already connected]"); |
|---|
| 496 |
return VFW_E_ALREADY_CONNECTED; |
|---|
| 497 |
} |
|---|
| 498 |
|
|---|
| 499 |
if( S_OK != QueryAccept(pmt) ) |
|---|
| 500 |
{ |
|---|
| 501 |
msg_Dbg( p_input, "CapturePin::ReceiveConnection " |
|---|
| 502 |
"[media type not accepted]" ); |
|---|
| 503 |
return VFW_E_TYPE_NOT_ACCEPTED; |
|---|
| 504 |
} |
|---|
| 505 |
|
|---|
| 506 |
msg_Dbg( p_input, "CapturePin::ReceiveConnection [OK]" ); |
|---|
| 507 |
|
|---|
| 508 |
p_connected_pin = pConnector; |
|---|
| 509 |
p_connected_pin->AddRef(); |
|---|
| 510 |
|
|---|
| 511 |
FreeMediaType( cx_media_type ); |
|---|
| 512 |
return CopyMediaType( &cx_media_type, pmt ); |
|---|
| 513 |
} |
|---|
| 514 |
STDMETHODIMP CapturePin::Disconnect() |
|---|
| 515 |
{ |
|---|
| 516 |
if( ! p_connected_pin ) |
|---|
| 517 |
{ |
|---|
| 518 |
msg_Dbg( p_input, "CapturePin::Disconnect [not connected]" ); |
|---|
| 519 |
return S_FALSE; |
|---|
| 520 |
} |
|---|
| 521 |
|
|---|
| 522 |
msg_Dbg( p_input, "CapturePin::Disconnect [OK]" ); |
|---|
| 523 |
|
|---|
| 524 |
|
|---|
| 525 |
|
|---|
| 526 |
p_connected_pin->Release(); |
|---|
| 527 |
p_connected_pin = NULL; |
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
return S_OK; |
|---|
| 532 |
} |
|---|
| 533 |
STDMETHODIMP CapturePin::ConnectedTo( IPin **pPin ) |
|---|
| 534 |
{ |
|---|
| 535 |
if( !p_connected_pin ) |
|---|
| 536 |
{ |
|---|
| 537 |
msg_Dbg( p_input, "CapturePin::ConnectedTo [not connected]" ); |
|---|
| 538 |
return VFW_E_NOT_CONNECTED; |
|---|
| 539 |
} |
|---|
| 540 |
|
|---|
| 541 |
p_connected_pin->AddRef(); |
|---|
| 542 |
*pPin = p_connected_pin; |
|---|
| 543 |
|
|---|
| 544 |
msg_Dbg( p_input, "CapturePin::ConnectedTo [OK]" ); |
|---|
| 545 |
|
|---|
| 546 |
return S_OK; |
|---|
| 547 |
} |
|---|
| 548 |
STDMETHODIMP CapturePin::ConnectionMediaType( AM_MEDIA_TYPE *pmt ) |
|---|
| 549 |
{ |
|---|
| 550 |
if( !p_connected_pin ) |
|---|
| 551 |
{ |
|---|
| 552 |
msg_Dbg( p_input, "CapturePin::ConnectionMediaType [not connected]" ); |
|---|
| 553 |
return VFW_E_NOT_CONNECTED; |
|---|
| 554 |
} |
|---|
| 555 |
|
|---|
| 556 |
return CopyMediaType( pmt, &cx_media_type ); |
|---|
| 557 |
} |
|---|
| 558 |
STDMETHODIMP CapturePin::QueryPinInfo( PIN_INFO * pInfo ) |
|---|
| 559 |
{ |
|---|
| 560 |
#ifdef DEBUG_DSHOW |
|---|
| 561 |
msg_Dbg( p_input, "CapturePin::QueryPinInfo" ); |
|---|
| 562 |
#endif |
|---|
| 563 |
|
|---|
| 564 |
pInfo->pFilter = p_filter; |
|---|
| 565 |
if( p_filter ) p_filter->AddRef(); |
|---|
| 566 |
|
|---|
| 567 |
memcpy(pInfo->achName, PIN_NAME, sizeof(PIN_NAME)); |
|---|
| 568 |
pInfo->dir = PINDIR_INPUT; |
|---|
| 569 |
|
|---|
| 570 |
return NOERROR; |
|---|
| 571 |
} |
|---|
| 572 |
STDMETHODIMP CapturePin::QueryDirection( PIN_DIRECTION * pPinDir ) |
|---|
| 573 |
{ |
|---|
| 574 |
#ifdef DEBUG_DSHOW |
|---|
| 575 |
msg_Dbg( p_input, "CapturePin::QueryDirection" ); |
|---|
| 576 |
#endif |
|---|
| 577 |
|
|---|
| 578 |
*pPinDir = PINDIR_INPUT; |
|---|
| 579 |
return NOERROR; |
|---|
| 580 |
} |
|---|
| 581 |
STDMETHODIMP CapturePin::QueryId( LPWSTR * Id ) |
|---|
| 582 |
{ |
|---|
| 583 |
#ifdef DEBUG_DSHOW |
|---|
| 584 |
msg_Dbg( p_input, "CapturePin::QueryId" ); |
|---|
| 585 |
#endif |
|---|
| 586 |
|
|---|
| 587 |
*Id = L"VideoLAN Capture Pin"; |
|---|
| 588 |
|
|---|
| 589 |
return S_OK; |
|---|
| 590 |
} |
|---|
| 591 |
STDMETHODIMP CapturePin::QueryAccept( const AM_MEDIA_TYPE *pmt ) |
|---|
| 592 |
{ |
|---|
| 593 |
if( State_Stopped != p_filter->state ) |
|---|
| 594 |
{ |
|---|
| 595 |
msg_Dbg( p_input, "CapturePin::QueryAccept [not stopped]" ); |
|---|
| 596 |
return S_FALSE; |
|---|
| 597 |
} |
|---|
| 598 |
|
|---|
| 599 |
if( media_types[0].majortype != pmt->majortype ) |
|---|
| 600 |
{ |
|---|
| 601 |
msg_Dbg( p_input, "CapturePin::QueryAccept [media type mismatch]" ); |
|---|
| 602 |
return S_FALSE; |
|---|
| 603 |
} |
|---|
| 604 |
|
|---|
| 605 |
int i_fourcc = GetFourCCFromMediaType(*pmt); |
|---|
| 606 |
if( !i_fourcc ) |
|---|
| 607 |
{ |
|---|
| 608 |
msg_Dbg( p_input, "CapturePin::QueryAccept " |
|---|
| 609 |
"[media type not supported]" ); |
|---|
| 610 |
return S_FALSE; |
|---|
| 611 |
} |
|---|
| 612 |
|
|---|
| 613 |
if( pmt->majortype == MEDIATYPE_Video ) |
|---|
| 614 |
{ |
|---|
| 615 |
if( pmt->pbFormat && |
|---|
| 616 |
( (((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight == 0) || |
|---|
| 617 |
(((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth == 0) ) ) |
|---|
| 618 |
{ |
|---|
| 619 |
msg_Dbg( p_input, "CapturePin::QueryAccept [video size wxh == 0]"); |
|---|
| 620 |
return S_FALSE; |
|---|
| 621 |
} |
|---|
| 622 |
|
|---|
| 623 |
msg_Dbg( p_input, "CapturePin::QueryAccept [OK] " |
|---|
| 624 |
"(width=%ld, height=%ld, chroma=%4.4s, fps=%f)", |
|---|
| 625 |
((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biWidth, |
|---|
| 626 |
((VIDEOINFOHEADER *)pmt->pbFormat)->bmiHeader.biHeight, |
|---|
| 627 |
(char *)&i_fourcc, |
|---|
| 628 |
10000000.0f/((float)((VIDEOINFOHEADER *)pmt->pbFormat)->AvgTimePerFrame) ); |
|---|
| 629 |
} |
|---|
| 630 |
else if( pmt->majortype == MEDIATYPE_Audio ) |
|---|
| 631 |
{ |
|---|
| 632 |
msg_Dbg( p_input, "CapturePin::QueryAccept [OK] (channels=%d, " |
|---|
| 633 |
"samples/sec=%lu, bits/samples=%d, format=%4.4s)", |
|---|
| 634 |
((WAVEFORMATEX *)pmt->pbFormat)->nChannels, |
|---|
| 635 |
((WAVEFORMATEX *)pmt->pbFormat)->nSamplesPerSec, |
|---|
| 636 |
((WAVEFORMATEX *)pmt->pbFormat)->wBitsPerSample, |
|---|
| 637 |
(char *)&i_fourcc ); |
|---|
| 638 |
} |
|---|
| 639 |
else |
|---|
| 640 |
{ |
|---|
| 641 |
msg_Dbg( p_input, "CapturePin::QueryAccept [OK] (stream format=%4.4s)", |
|---|
| 642 |
(char *)&i_fourcc ); |
|---|
| 643 |
} |
|---|
| 644 |
|
|---|
| 645 |
if( p_connected_pin ) |
|---|
| 646 |
{ |
|---|
| 647 |
FreeMediaType( cx_media_type ); |
|---|
| 648 |
CopyMediaType( &cx_media_type, pmt ); |
|---|
| 649 |
} |
|---|
| 650 |
|
|---|
| 651 |
return S_OK; |
|---|
| 652 |
} |
|---|
| 653 |
STDMETHODIMP CapturePin::EnumMediaTypes( IEnumMediaTypes **ppEnum ) |
|---|
| 654 |
{ |
|---|
| 655 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 656 |
msg_Dbg( p_input, "CapturePin::EnumMediaTypes" ); |
|---|
| 657 |
#endif |
|---|
| 658 |
|
|---|
| 659 |
*ppEnum = new CaptureEnumMediaTypes( p_input, this, NULL ); |
|---|
| 660 |
|
|---|
| 661 |
if( *ppEnum == NULL ) return E_OUTOFMEMORY; |
|---|
| 662 |
|
|---|
| 663 |
return NOERROR; |
|---|
| 664 |
} |
|---|
| 665 |
STDMETHODIMP CapturePin::QueryInternalConnections( IPin* *apPin, ULONG *nPin ) |
|---|
| 666 |
{ |
|---|
| 667 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 668 |
msg_Dbg( p_input, "CapturePin::QueryInternalConnections" ); |
|---|
| 669 |
#endif |
|---|
| 670 |
return E_NOTIMPL; |
|---|
| 671 |
} |
|---|
| 672 |
STDMETHODIMP CapturePin::EndOfStream( void ) |
|---|
| 673 |
{ |
|---|
| 674 |
#ifdef DEBUG_DSHOW |
|---|
| 675 |
msg_Dbg( p_input, "CapturePin::EndOfStream" ); |
|---|
| 676 |
#endif |
|---|
| 677 |
return S_OK; |
|---|
| 678 |
} |
|---|
| 679 |
STDMETHODIMP CapturePin::BeginFlush( void ) |
|---|
| 680 |
{ |
|---|
| 681 |
#ifdef DEBUG_DSHOW |
|---|
| 682 |
msg_Dbg( p_input, "CapturePin::BeginFlush" ); |
|---|
| 683 |
#endif |
|---|
| 684 |
return S_OK; |
|---|
| 685 |
} |
|---|
| 686 |
STDMETHODIMP CapturePin::EndFlush( void ) |
|---|
| 687 |
{ |
|---|
| 688 |
#ifdef DEBUG_DSHOW |
|---|
| 689 |
msg_Dbg( p_input, "CapturePin::EndFlush" ); |
|---|
| 690 |
#endif |
|---|
| 691 |
|
|---|
| 692 |
VLCMediaSample vlc_sample; |
|---|
| 693 |
|
|---|
| 694 |
vlc_mutex_lock( &p_sys->lock ); |
|---|
| 695 |
while( samples_queue.size() ) |
|---|
| 696 |
{ |
|---|
| 697 |
vlc_sample = samples_queue.back(); |
|---|
| 698 |
samples_queue.pop_back(); |
|---|
| 699 |
vlc_sample.p_sample->Release(); |
|---|
| 700 |
} |
|---|
| 701 |
vlc_mutex_unlock( &p_sys->lock ); |
|---|
| 702 |
|
|---|
| 703 |
return S_OK; |
|---|
| 704 |
} |
|---|
| 705 |
STDMETHODIMP CapturePin::NewSegment( REFERENCE_TIME tStart, |
|---|
| 706 |
REFERENCE_TIME tStop, |
|---|
| 707 |
double dRate ) |
|---|
| 708 |
{ |
|---|
| 709 |
#ifdef DEBUG_DSHOW |
|---|
| 710 |
msg_Dbg( p_input, "CapturePin::NewSegment" ); |
|---|
| 711 |
#endif |
|---|
| 712 |
return S_OK; |
|---|
| 713 |
} |
|---|
| 714 |
|
|---|
| 715 |
|
|---|
| 716 |
STDMETHODIMP CapturePin::GetAllocator( IMemAllocator **ppAllocator ) |
|---|
| 717 |
{ |
|---|
| 718 |
#ifdef DEBUG_DSHOW |
|---|
| 719 |
msg_Dbg( p_input, "CapturePin::GetAllocator" ); |
|---|
| 720 |
#endif |
|---|
| 721 |
|
|---|
| 722 |
return VFW_E_NO_ALLOCATOR; |
|---|
| 723 |
} |
|---|
| 724 |
STDMETHODIMP CapturePin::NotifyAllocator( IMemAllocator *pAllocator, |
|---|
| 725 |
BOOL bReadOnly ) |
|---|
| 726 |
{ |
|---|
| 727 |
#ifdef DEBUG_DSHOW |
|---|
| 728 |
msg_Dbg( p_input, "CapturePin::NotifyAllocator" ); |
|---|
| 729 |
#endif |
|---|
| 730 |
|
|---|
| 731 |
return S_OK; |
|---|
| 732 |
} |
|---|
| 733 |
STDMETHODIMP CapturePin::GetAllocatorRequirements( ALLOCATOR_PROPERTIES *pProps ) |
|---|
| 734 |
{ |
|---|
| 735 |
#ifdef DEBUG_DSHOW |
|---|
| 736 |
msg_Dbg( p_input, "CapturePin::GetAllocatorRequirements" ); |
|---|
| 737 |
#endif |
|---|
| 738 |
|
|---|
| 739 |
return E_NOTIMPL; |
|---|
| 740 |
} |
|---|
| 741 |
STDMETHODIMP CapturePin::Receive( IMediaSample *pSample ) |
|---|
| 742 |
{ |
|---|
| 743 |
#if 0 //def DEBUG_DSHOW |
|---|
| 744 |
msg_Dbg( p_input, "CapturePin::Receive" ); |
|---|
| 745 |
#endif |
|---|
| 746 |
|
|---|
| 747 |
pSample->AddRef(); |
|---|
| 748 |
mtime_t i_timestamp = mdate() * 10; |
|---|
| 749 |
VLCMediaSample vlc_sample = {pSample, i_timestamp}; |
|---|
| 750 |
|
|---|
| 751 |
vlc_mutex_lock( &p_sys->lock ); |
|---|
| 752 |
samples_queue.push_front( vlc_sample ); |
|---|
| 753 |
|
|---|
| 754 |
|
|---|
| 755 |
if( samples_queue.size() > 10 ) |
|---|
| 756 |
{ |
|---|
| 757 |
vlc_sample = samples_queue.back(); |
|---|
| 758 |
samples_queue.pop_back(); |
|---|
| 759 |
msg_Dbg( p_input, "CapturePin::Receive trashing late input sample" ); |
|---|
| 760 |
vlc_sample.p_sample->Release(); |
|---|
| 761 |
} |
|---|
| 762 |
|
|---|
| 763 |
vlc_cond_signal( &p_sys->wait ); |
|---|
| 764 |
vlc_mutex_unlock( &p_sys->lock ); |
|---|
| 765 |
|
|---|
| 766 |
return S_OK; |
|---|
| 767 |
} |
|---|
| 768 |
STDMETHODIMP CapturePin::ReceiveMultiple( IMediaSample **pSamples, |
|---|
| 769 |
long nSamples, |
|---|
| 770 |
long *nSamplesProcessed ) |
|---|
| 771 |
{ |
|---|
| 772 |
HRESULT hr = S_OK; |
|---|
| 773 |
|
|---|
| 774 |
*nSamplesProcessed = 0; |
|---|
| 775 |
while( nSamples-- > 0 ) |
|---|
| 776 |
{ |
|---|
| 777 |
hr = Receive( pSamples[*nSamplesProcessed] ); |
|---|
| 778 |
if( hr != S_OK ) break; |
|---|
| 779 |
(*nSamplesProcessed)++; |
|---|
| 780 |
} |
|---|
| 781 |
return hr; |
|---|
| 782 |
} |
|---|
| 783 |
STDMETHODIMP CapturePin::ReceiveCanBlock( void ) |
|---|
| 784 |
{ |
|---|
| 785 |
#ifdef DEBUG_DSHOW |
|---|
| 786 |
msg_Dbg( p_input, "CapturePin::ReceiveCanBlock" ); |
|---|
| 787 |
#endif |
|---|
| 788 |
|
|---|
| 789 |
return S_FALSE; |
|---|
| 790 |
} |
|---|
| 791 |
|
|---|
| 792 |
|
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 |
CaptureFilter::CaptureFilter( vlc_object_t *_p_input, access_sys_t *p_sys, |
|---|
| 796 |
AM_MEDIA_TYPE *mt, size_t mt_count ) |
|---|
| 797 |
: p_input( _p_input ), |
|---|
| 798 |
p_pin( new CapturePin( _p_input, p_sys, this, mt, mt_count ) ), |
|---|
| 799 |
state( State_Stopped ), i_ref( 1 ) |
|---|
| 800 |
{ |
|---|
| 801 |
} |
|---|
| 802 |
|
|---|
| 803 |
CaptureFilter::~CaptureFilter() |
|---|
| 804 |
{ |
|---|
| 805 |
#ifdef DEBUG_DSHOW |
|---|
| 806 |
msg_Dbg( p_input, "CaptureFilter::~CaptureFilter" ); |
|---|
| 807 |
#endif |
|---|
| 808 |
p_pin->Release(); |
|---|
| 809 |
} |
|---|
| 810 |
|
|---|
| 811 |
|
|---|
| 812 |
STDMETHODIMP CaptureFilter::QueryInterface( REFIID riid, void **ppv ) |
|---|
| 813 |
{ |
|---|
| 814 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 815 |
msg_Dbg( p_input, "CaptureFilter::QueryInterface" ); |
|---|
| 816 |
#endif |
|---|
| 817 |
|
|---|
| 818 |
if( riid == IID_IUnknown ) |
|---|
| 819 |
{ |
|---|
| 820 |
AddRef(); |
|---|
| 821 |
*ppv = (IUnknown *)this; |
|---|
| 822 |
return NOERROR; |
|---|
| 823 |
} |
|---|
| 824 |
if( riid == IID_IPersist ) |
|---|
| 825 |
{ |
|---|
| 826 |
AddRef(); |
|---|
| 827 |
*ppv = (IPersist *)this; |
|---|
| 828 |
return NOERROR; |
|---|
| 829 |
} |
|---|
| 830 |
if( riid == IID_IMediaFilter ) |
|---|
| 831 |
{ |
|---|
| 832 |
AddRef(); |
|---|
| 833 |
*ppv = (IMediaFilter *)this; |
|---|
| 834 |
return NOERROR; |
|---|
| 835 |
} |
|---|
| 836 |
if( riid == IID_IBaseFilter ) |
|---|
| 837 |
{ |
|---|
| 838 |
AddRef(); |
|---|
| 839 |
*ppv = (IBaseFilter *)this; |
|---|
| 840 |
return NOERROR; |
|---|
| 841 |
} |
|---|
| 842 |
else |
|---|
| 843 |
{ |
|---|
| 844 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 845 |
msg_Dbg( p_input, "CaptureFilter::QueryInterface() failed for: " |
|---|
| 846 |
"%04X-%02X-%02X-%02X%02X%02X%02X%02X%02X%02X%02X", |
|---|
| 847 |
(int)riid.Data1, (int)riid.Data2, (int)riid.Data3, |
|---|
| 848 |
static_cast<int>(riid.Data4[0]), (int)riid.Data4[1], |
|---|
| 849 |
(int)riid.Data4[2], (int)riid.Data4[3], |
|---|
| 850 |
(int)riid.Data4[4], (int)riid.Data4[5], |
|---|
| 851 |
(int)riid.Data4[6], (int)riid.Data4[7] ); |
|---|
| 852 |
#endif |
|---|
| 853 |
*ppv = NULL; |
|---|
| 854 |
return E_NOINTERFACE; |
|---|
| 855 |
} |
|---|
| 856 |
}; |
|---|
| 857 |
STDMETHODIMP_(ULONG) CaptureFilter::AddRef() |
|---|
| 858 |
{ |
|---|
| 859 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 860 |
msg_Dbg( p_input, "CaptureFilter::AddRef (ref: %i)", i_ref ); |
|---|
| 861 |
#endif |
|---|
| 862 |
|
|---|
| 863 |
return i_ref++; |
|---|
| 864 |
}; |
|---|
| 865 |
STDMETHODIMP_(ULONG) CaptureFilter::Release() |
|---|
| 866 |
{ |
|---|
| 867 |
#ifdef DEBUG_DSHOW_L1 |
|---|
| 868 |
msg_Dbg( p_input, "CaptureFilter::Release (ref: %i)", i_ref ); |
|---|
| 869 |
#endif |
|---|
| 870 |
|
|---|
| 871 |
if( !InterlockedDecrement(&i_ref) ) delete this; |
|---|
| 872 |
|
|---|
| 873 |
return 0; |
|---|
| 874 |
}; |
|---|
| 875 |
|
|---|
| 876 |
|
|---|
| 877 |
STDMETHODIMP CaptureFilter::GetClassID(C |
|---|