-
Notifications
You must be signed in to change notification settings - Fork 1
/
MFMediaEngine.cs
1807 lines (1665 loc) · 88.1 KB
/
MFMediaEngine.cs
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using DXGI;
using GlobalStructures;
namespace MFMediaEngine
{
[ComImport]
[Guid("fee7c112-e776-42b5-9bbf-0048524e2bd5")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEngineNotify
{
//[return: MarshalAs(UnmanagedType.U4)]
[PreserveSig]
HRESULT EventNotify(MF_MEDIA_ENGINE_EVENT nEvent, IntPtr param1, uint param2);
}
public enum MF_MEDIA_ENGINE_EVENT
{
MF_MEDIA_ENGINE_EVENT_LOADSTART = 1,
MF_MEDIA_ENGINE_EVENT_PROGRESS = 2,
MF_MEDIA_ENGINE_EVENT_SUSPEND = 3,
MF_MEDIA_ENGINE_EVENT_ABORT = 4,
MF_MEDIA_ENGINE_EVENT_ERROR = 5,
MF_MEDIA_ENGINE_EVENT_EMPTIED = 6,
MF_MEDIA_ENGINE_EVENT_STALLED = 7,
MF_MEDIA_ENGINE_EVENT_PLAY = 8,
MF_MEDIA_ENGINE_EVENT_PAUSE = 9,
MF_MEDIA_ENGINE_EVENT_LOADEDMETADATA = 10,
MF_MEDIA_ENGINE_EVENT_LOADEDDATA = 11,
MF_MEDIA_ENGINE_EVENT_WAITING = 12,
MF_MEDIA_ENGINE_EVENT_PLAYING = 13,
MF_MEDIA_ENGINE_EVENT_CANPLAY = 14,
MF_MEDIA_ENGINE_EVENT_CANPLAYTHROUGH = 15,
MF_MEDIA_ENGINE_EVENT_SEEKING = 16,
MF_MEDIA_ENGINE_EVENT_SEEKED = 17,
MF_MEDIA_ENGINE_EVENT_TIMEUPDATE = 18,
MF_MEDIA_ENGINE_EVENT_ENDED = 19,
MF_MEDIA_ENGINE_EVENT_RATECHANGE = 20,
MF_MEDIA_ENGINE_EVENT_DURATIONCHANGE = 21,
MF_MEDIA_ENGINE_EVENT_VOLUMECHANGE = 22,
MF_MEDIA_ENGINE_EVENT_FORMATCHANGE = 1000,
MF_MEDIA_ENGINE_EVENT_PURGEQUEUEDEVENTS = 1001,
MF_MEDIA_ENGINE_EVENT_TIMELINE_MARKER = 1002,
MF_MEDIA_ENGINE_EVENT_BALANCECHANGE = 1003,
MF_MEDIA_ENGINE_EVENT_DOWNLOADCOMPLETE = 1004,
MF_MEDIA_ENGINE_EVENT_BUFFERINGSTARTED = 1005,
MF_MEDIA_ENGINE_EVENT_BUFFERINGENDED = 1006,
MF_MEDIA_ENGINE_EVENT_FRAMESTEPCOMPLETED = 1007,
MF_MEDIA_ENGINE_EVENT_NOTIFYSTABLESTATE = 1008,
MF_MEDIA_ENGINE_EVENT_FIRSTFRAMEREADY = 1009,
MF_MEDIA_ENGINE_EVENT_TRACKSCHANGE = 1010,
MF_MEDIA_ENGINE_EVENT_OPMINFO = 1011,
MF_MEDIA_ENGINE_EVENT_RESOURCELOST = 1012,
MF_MEDIA_ENGINE_EVENT_DELAYLOADEVENT_CHANGED = 1013,
MF_MEDIA_ENGINE_EVENT_STREAMRENDERINGERROR = 1014,
MF_MEDIA_ENGINE_EVENT_SUPPORTEDRATES_CHANGED = 1015,
MF_MEDIA_ENGINE_EVENT_AUDIOENDPOINTCHANGE = 1016
}
[ComImport]
[Guid("4D645ACE-26AA-4688-9BE1-DF3516990B93")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEngineClassFactory
{
HRESULT CreateInstance(uint dwFlags, IMFAttributes pAttr, out IMFMediaEngine ppPlayer);
HRESULT CreateTimeRange(out IMFMediaTimeRange ppTimeRange);
HRESULT CreateError(out IMFMediaError ppError);
}
[ComImport]
[Guid("2cd2d921-c447-44a7-a13c-4adabfc247e3")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFAttributes
{
HRESULT GetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
HRESULT GetItemType(ref Guid guidKey, out MF_ATTRIBUTE_TYPE pType);
HRESULT CompareItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value, out bool pbResult);
HRESULT Compare(IMFAttributes pTheirs, MF_ATTRIBUTES_MATCH_TYPE MatchType, out bool pbResult);
HRESULT GetUINT32(ref Guid guidKey, out uint punValue);
HRESULT GetUINT64(ref Guid guidKey, out ulong punValue);
HRESULT GetDouble(ref Guid guidKey, out double pfValue);
HRESULT GetGUID(ref Guid guidKey, out Guid pguidValue);
HRESULT GetStringLength(ref Guid guidKey, out uint pcchLength);
HRESULT GetString(ref Guid guidKey, out string pwszValue, uint cchBufSize, ref uint pcchLength);
HRESULT GetAllocatedString(ref Guid guidKey, out string ppwszValue, out uint pcchLength);
HRESULT GetBlobSize(ref Guid guidKey, out uint pcbBlobSize);
HRESULT GetBlob(ref Guid guidKey, out char pBuf, uint cbBufSize, ref uint pcbBlobSize);
HRESULT GetAllocatedBlob(ref Guid guidKey, out char ppBuf, out uint pcbSize);
HRESULT GetUnknown(ref Guid guidKey, ref Guid riid, out IntPtr ppv);
HRESULT SetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value);
HRESULT DeleteItem(ref Guid guidKey);
HRESULT DeleteAllItems();
HRESULT SetUINT32(ref Guid guidKey, uint unValue);
HRESULT SetUINT64(ref Guid guidKey, ulong unValue);
HRESULT SetDouble(ref Guid guidKey, double fValue);
HRESULT SetGUID(ref Guid guidKey, ref Guid guidValue);
HRESULT SetString(ref Guid guidKey, string wszValue);
HRESULT SetBlob(ref Guid guidKey, char pBuf, uint cbBufSize);
//HRESULT SetUnknown(ref Guid guidKey, IUnknown pUnknown = null);
HRESULT SetUnknown(ref Guid guidKey, IntPtr pUnknown);
HRESULT LockStore();
HRESULT UnlockStore();
HRESULT GetCount(out uint pcItems);
HRESULT GetItemByIndex(uint unIndex, out Guid pguidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
HRESULT CopyAllItems(IMFAttributes pDest = null);
}
public enum MF_ATTRIBUTES_MATCH_TYPE
{
MF_ATTRIBUTES_MATCH_OUR_ITEMS = 0,
MF_ATTRIBUTES_MATCH_THEIR_ITEMS = 1,
MF_ATTRIBUTES_MATCH_ALL_ITEMS = 2,
MF_ATTRIBUTES_MATCH_INTERSECTION = 3,
MF_ATTRIBUTES_MATCH_SMALLER = 4
}
public enum MF_ATTRIBUTE_TYPE
{
MF_ATTRIBUTE_UINT32 = VARENUM.VT_UI4,
MF_ATTRIBUTE_UINT64 = VARENUM.VT_UI8,
MF_ATTRIBUTE_DOUBLE = VARENUM.VT_R8,
MF_ATTRIBUTE_GUID = VARENUM.VT_CLSID,
MF_ATTRIBUTE_STRING = VARENUM.VT_LPWSTR,
MF_ATTRIBUTE_BLOB = (VARENUM.VT_VECTOR | VARENUM.VT_UI1),
MF_ATTRIBUTE_IUNKNOWN = VARENUM.VT_UNKNOWN
}
[ComImport]
[Guid("98a1b0bb-03eb-4935-ae7c-93c1fa0e1c93")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEngine
{
HRESULT GetError(out IMFMediaError ppError);
HRESULT SetErrorCode(MF_MEDIA_ENGINE_ERR error);
HRESULT SetSourceElements(IMFMediaEngineSrcElements pSrcElements);
[PreserveSig]
HRESULT SetSource(string pUrl);
HRESULT GetCurrentSource(out string ppUrl);
[PreserveSig]
byte GetNetworkState();
[PreserveSig]
MF_MEDIA_ENGINE_PRELOAD GetPreload();
HRESULT SetPreload(MF_MEDIA_ENGINE_PRELOAD Preload);
HRESULT GetBuffered(out IMFMediaTimeRange ppBuffered);
[PreserveSig]
HRESULT Load();
HRESULT CanPlayType(string type, out MF_MEDIA_ENGINE_CANPLAY pAnswer);
[PreserveSig]
MF_MEDIA_ENGINE_READY GetReadyState();
[PreserveSig]
bool IsSeeking();
[PreserveSig]
double GetCurrentTime();
HRESULT SetCurrentTime(double seekTime);
[PreserveSig]
double GetStartTime();
[PreserveSig]
double GetDuration();
[PreserveSig]
bool IsPaused();
[PreserveSig]
double GetDefaultPlaybackRate();
HRESULT SetDefaultPlaybackRate(double Rate);
[PreserveSig]
double GetPlaybackRate();
HRESULT SetPlaybackRate(double Rate);
HRESULT GetPlayed(out IMFMediaTimeRange ppPlayed);
HRESULT GetSeekable(out IMFMediaTimeRange ppSeekable);
[PreserveSig]
bool IsEnded();
[PreserveSig]
bool GetAutoPlay();
HRESULT SetAutoPlay(bool AutoPlay);
[PreserveSig]
bool GetLoop();
HRESULT SetLoop(bool Loop);
HRESULT Play();
HRESULT Pause();
[PreserveSig]
bool GetMuted();
HRESULT SetMuted(bool Muted);
[PreserveSig]
double GetVolume();
HRESULT SetVolume(double Volume);
[PreserveSig]
bool HasVideo();
[PreserveSig]
bool HasAudio();
HRESULT GetNativeVideoSize(out uint cx, out uint cy);
HRESULT GetVideoAspectRatio(out uint cx, out uint cy);
HRESULT Shutdown();
[PreserveSig]
HRESULT TransferVideoFrame(IntPtr pDstSurf, ref MFVideoNormalizedRect pSrc, ref RECT pDst, ref MFARGB pBorderClr);
[PreserveSig]
HRESULT OnVideoStreamTick(out long pPts);
}
public enum MF_MEDIA_ENGINE_READY : byte
{
MF_MEDIA_ENGINE_READY_HAVE_NOTHING = 0,
MF_MEDIA_ENGINE_READY_HAVE_METADATA = 1,
MF_MEDIA_ENGINE_READY_HAVE_CURRENT_DATA = 2,
MF_MEDIA_ENGINE_READY_HAVE_FUTURE_DATA = 3,
MF_MEDIA_ENGINE_READY_HAVE_ENOUGH_DATA = 4
};
[ComImport]
[Guid("fc0e10d2-ab2a-4501-a951-06bb1075184c")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaError
{
[PreserveSig]
byte GetErrorCode();
HRESULT GetExtendedErrorCode();
HRESULT SetErrorCode(MF_MEDIA_ENGINE_ERR error);
HRESULT SetExtendedErrorCode(HRESULT error);
}
public enum MF_MEDIA_ENGINE_ERR
{
MF_MEDIA_ENGINE_ERR_NOERROR = 0,
MF_MEDIA_ENGINE_ERR_ABORTED = 1,
MF_MEDIA_ENGINE_ERR_NETWORK = 2,
MF_MEDIA_ENGINE_ERR_DECODE = 3,
MF_MEDIA_ENGINE_ERR_SRC_NOT_SUPPORTED = 4,
MF_MEDIA_ENGINE_ERR_ENCRYPTED = 5
}
[ComImport]
[Guid("7a5e5354-b114-4c72-b991-3131d75032ea")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEngineSrcElements
{
[PreserveSig]
uint GetLength();
[PreserveSig]
HRESULT GetURL(uint index, out string pURL);
[PreserveSig]
HRESULT GetType(uint index, out string pType);
[PreserveSig]
HRESULT GetMedia(uint index, out string pMedia);
[PreserveSig]
HRESULT AddElement(string pURL, string pType, string pMedia);
[PreserveSig]
HRESULT RemoveAllElements();
}
public enum MF_MEDIA_ENGINE_PRELOAD
{
MF_MEDIA_ENGINE_PRELOAD_MISSING = 0,
MF_MEDIA_ENGINE_PRELOAD_EMPTY = 1,
MF_MEDIA_ENGINE_PRELOAD_NONE = 2,
MF_MEDIA_ENGINE_PRELOAD_METADATA = 3,
MF_MEDIA_ENGINE_PRELOAD_AUTOMATIC = 4
}
public enum MF_MEDIA_ENGINE_CANPLAY
{
MF_MEDIA_ENGINE_CANPLAY_NOT_SUPPORTED = 0,
MF_MEDIA_ENGINE_CANPLAY_MAYBE = 1,
MF_MEDIA_ENGINE_CANPLAY_PROBABLY = 2
}
[ComImport]
[Guid("db71a2fc-078a-414e-9df9-8c2531b0aa6c")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaTimeRange
{
[PreserveSig]
uint GetLength();
HRESULT GetStart(uint index, out double pStart);
HRESULT GetEnd(uint index, out double pEnd);
[PreserveSig]
bool ContainsTime(double time);
HRESULT AddRange(double startTime, double endTime);
HRESULT Clear();
}
[StructLayout(LayoutKind.Sequential)]
public struct MFVideoNormalizedRect
{
public float left;
public float top;
public float right;
public float bottom;
public MFVideoNormalizedRect(float Left, float Top, float Right, float Bottom)
{
left = Left;
top = Top;
right = Right;
bottom = Bottom;
}
}
[StructLayout(LayoutKind.Sequential)]
public struct MFARGB
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbAlpha;
public MFARGB(byte RgbBlue, byte RgbGreen, byte RgbRed, byte RgbAlpha)
{
rgbBlue = RgbBlue;
rgbGreen = RgbGreen;
rgbRed = RgbRed;
rgbAlpha = RgbAlpha;
}
}
[ComImport]
[Guid("ad4c1b00-4bf7-422f-9175-756693d9130d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFByteStream
{
HRESULT GetCapabilities(out int pdwCapabilities);
HRESULT GetLength(out ulong pqwLength);
HRESULT SetLength(ulong qwLength);
HRESULT GetCurrentPosition(out ulong pqwPosition);
HRESULT SetCurrentPosition(ulong qwPosition);
HRESULT IsEndOfStream(out bool pfEndOfStream);
HRESULT Read(out IntPtr pb, uint cb, out uint pcbRead);
HRESULT BeginRead(out IntPtr pb, uint cb, IMFAsyncCallback pCallback, IntPtr punkState);
HRESULT EndRead(IMFAsyncResult pResult, out uint pcbRead);
HRESULT Write(IntPtr pb, uint cb, out uint pcbWritten);
HRESULT BeginWrite(IntPtr pb, uint cb, IMFAsyncCallback pCallback, IntPtr punkState);
HRESULT EndWrite(IMFAsyncResult pResult, out uint pcbWritten);
HRESULT Seek(MFBYTESTREAM_SEEK_ORIGIN SeekOrigin, long llSeekOffset, int dwSeekFlags, out ulong pqwCurrentPosition);
HRESULT Flush();
HRESULT Close();
}
[ComImport]
[Guid("a27003cf-2354-4f2a-8d6a-ab7cff15437e")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFAsyncCallback
{
HRESULT GetParameters(out int pdwFlags, out int pdwQueue);
HRESULT Invoke(IMFAsyncResult pAsyncResult);
}
[ComImport]
[Guid("ac6b7889-0740-4d51-8619-905994a55cc6")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFAsyncResult
{
//HRESULT GetState(out IUnknown **ppunkState);
HRESULT GetState(out IntPtr ppunkState);
HRESULT GetStatus();
HRESULT SetStatus(HRESULT hrStatus);
//HRESULT GetObject(out IUnknown ppObject);
HRESULT GetObject(out IntPtr ppObject);
//IUnknown* GetStateNoAddRef();
IntPtr GetStateNoAddRef();
}
public enum MFBYTESTREAM_SEEK_ORIGIN
{
msoBegin = 0,
msoCurrent = (msoBegin + 1)
}
[ComImport]
[Guid("3137f1cd-fe5e-4805-a5d8-fb477448cb3d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFSinkWriter
{
HRESULT AddStream(IMFMediaType pTargetMediaType, out int pdwStreamIndex);
[PreserveSig]
HRESULT SetInputMediaType(int dwStreamIndex, IMFMediaType pInputMediaType, IMFAttributes pEncodingParameters);
HRESULT BeginWriting();
[PreserveSig]
HRESULT WriteSample(int dwStreamIndex, IMFSample pSample);
HRESULT SendStreamTick(int dwStreamIndex, long llTimestamp);
HRESULT PlaceMarker(int dwStreamIndex, IntPtr pvContext);
HRESULT NotifyEndOfSegment(int dwStreamIndex);
HRESULT Flush(int dwStreamIndex);
[PreserveSig]
HRESULT Finalize();
HRESULT GetServiceForStream(int dwStreamIndex, ref Guid guidService, ref Guid riid, out IntPtr ppvObject);
HRESULT GetStatistics(int dwStreamIndex, out MF_SINK_WRITER_STATISTICS pStats);
}
[StructLayout(LayoutKind.Sequential)]
public struct MF_SINK_WRITER_STATISTICS
{
int cb;
long llLastTimestampReceived;
long llLastTimestampEncoded;
long llLastTimestampProcessed;
long llLastStreamTickReceived;
long llLastSinkSampleRequest;
ulong qwNumSamplesReceived;
ulong qwNumSamplesEncoded;
ulong qwNumSamplesProcessed;
ulong qwNumStreamTicksReceived;
int dwByteCountQueued;
ulong qwByteCountProcessed;
int dwNumOutstandingSinkSampleRequests;
int dwAverageSampleRateReceived;
int dwAverageSampleRateEncoded;
int dwAverageSampleRateProcessed;
}
[ComImport]
[Guid("44ae0fa8-ea31-4109-8d2e-4cae4997c555")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaType : IMFAttributes
{
#region IMFAttributes
new HRESULT GetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT GetItemType(ref Guid guidKey, out MF_ATTRIBUTE_TYPE pType);
new HRESULT CompareItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value, out bool pbResult);
new HRESULT Compare(IMFAttributes pTheirs, MF_ATTRIBUTES_MATCH_TYPE MatchType, out bool pbResult);
new HRESULT GetUINT32(ref Guid guidKey, out uint punValue);
new HRESULT GetUINT64(ref Guid guidKey, out ulong punValue);
new HRESULT GetDouble(ref Guid guidKey, out double pfValue);
new HRESULT GetGUID(ref Guid guidKey, out Guid pguidValue);
new HRESULT GetStringLength(ref Guid guidKey, out uint pcchLength);
new HRESULT GetString(ref Guid guidKey, out string pwszValue, uint cchBufSize, ref uint pcchLength);
new HRESULT GetAllocatedString(ref Guid guidKey, out string ppwszValue, out uint pcchLength);
new HRESULT GetBlobSize(ref Guid guidKey, out uint pcbBlobSize);
new HRESULT GetBlob(ref Guid guidKey, out char pBuf, uint cbBufSize, ref uint pcbBlobSize);
new HRESULT GetAllocatedBlob(ref Guid guidKey, out char ppBuf, out uint pcbSize);
new HRESULT GetUnknown(ref Guid guidKey, ref Guid riid, out IntPtr ppv);
new HRESULT SetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value);
new HRESULT DeleteItem(ref Guid guidKey);
new HRESULT DeleteAllItems();
new HRESULT SetUINT32(ref Guid guidKey, uint unValue);
new HRESULT SetUINT64(ref Guid guidKey, ulong unValue);
new HRESULT SetDouble(ref Guid guidKey, double fValue);
new HRESULT SetGUID(ref Guid guidKey, ref Guid guidValue);
new HRESULT SetString(ref Guid guidKey, string wszValue);
new HRESULT SetBlob(ref Guid guidKey, char pBuf, uint cbBufSize);
//new HRESULT SetUnknown(ref Guid guidKey, IUnknown pUnknown = null);
new HRESULT SetUnknown(ref Guid guidKey, IntPtr pUnknown);
new HRESULT LockStore();
new HRESULT UnlockStore();
new HRESULT GetCount(out uint pcItems);
new HRESULT GetItemByIndex(uint unIndex, out Guid pguidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT CopyAllItems(IMFAttributes pDest = null);
#endregion
HRESULT GetMajorType(out Guid pguidMajorType);
HRESULT IsCompressedFormat(out bool pfCompressed);
HRESULT IsEqual(IMFMediaType pIMediaType, out int pdwFlags);
HRESULT GetRepresentation(ref Guid guidRepresentation, out IntPtr ppvRepresentation);
HRESULT FreeRepresentation(ref Guid guidRepresentation, IntPtr pvRepresentation);
}
[ComImport]
[Guid("c40a00f2-b93a-4d80-ae8c-5a1c634f58e4")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFSample : IMFAttributes
{
#region IMFAttributes
new HRESULT GetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT GetItemType(ref Guid guidKey, out MF_ATTRIBUTE_TYPE pType);
new HRESULT CompareItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value, out bool pbResult);
new HRESULT Compare(IMFAttributes pTheirs, MF_ATTRIBUTES_MATCH_TYPE MatchType, out bool pbResult);
new HRESULT GetUINT32(ref Guid guidKey, out uint punValue);
new HRESULT GetUINT64(ref Guid guidKey, out ulong punValue);
new HRESULT GetDouble(ref Guid guidKey, out double pfValue);
new HRESULT GetGUID(ref Guid guidKey, out Guid pguidValue);
new HRESULT GetStringLength(ref Guid guidKey, out uint pcchLength);
new HRESULT GetString(ref Guid guidKey, out string pwszValue, uint cchBufSize, ref uint pcchLength);
new HRESULT GetAllocatedString(ref Guid guidKey, out string ppwszValue, out uint pcchLength);
new HRESULT GetBlobSize(ref Guid guidKey, out uint pcbBlobSize);
new HRESULT GetBlob(ref Guid guidKey, out char pBuf, uint cbBufSize, ref uint pcbBlobSize);
new HRESULT GetAllocatedBlob(ref Guid guidKey, out char ppBuf, out uint pcbSize);
new HRESULT GetUnknown(ref Guid guidKey, ref Guid riid, out IntPtr ppv);
new HRESULT SetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value);
new HRESULT DeleteItem(ref Guid guidKey);
new HRESULT DeleteAllItems();
new HRESULT SetUINT32(ref Guid guidKey, uint unValue);
new HRESULT SetUINT64(ref Guid guidKey, ulong unValue);
new HRESULT SetDouble(ref Guid guidKey, double fValue);
new HRESULT SetGUID(ref Guid guidKey, ref Guid guidValue);
new HRESULT SetString(ref Guid guidKey, string wszValue);
new HRESULT SetBlob(ref Guid guidKey, char pBuf, uint cbBufSize);
//new HRESULT SetUnknown(ref Guid guidKey, IUnknown pUnknown = null);
new HRESULT SetUnknown(ref Guid guidKey, IntPtr pUnknown);
new HRESULT LockStore();
new HRESULT UnlockStore();
new HRESULT GetCount(out uint pcItems);
new HRESULT GetItemByIndex(uint unIndex, out Guid pguidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT CopyAllItems(IMFAttributes pDest = null);
#endregion
HRESULT GetSampleFlags(out int pdwSampleFlags);
HRESULT SetSampleFlags(int dwSampleFlags);
HRESULT GetSampleTime(out long phnsSampleTime);
HRESULT SetSampleTime(long hnsSampleTime);
HRESULT GetSampleDuration(out long phnsSampleDuration);
HRESULT SetSampleDuration(long hnsSampleDuration);
HRESULT GetBufferCount(out int pdwBufferCount);
HRESULT GetBufferByIndex(int dwIndex, out IMFMediaBuffer ppBuffer);
HRESULT ConvertToContiguousBuffer(out IMFMediaBuffer ppBuffer);
HRESULT AddBuffer(IMFMediaBuffer pBuffer);
HRESULT RemoveBufferByIndex(int dwIndex);
HRESULT RemoveAllBuffers();
HRESULT GetTotalLength(out int pcbTotalLength);
HRESULT CopyToBuffer(IMFMediaBuffer pBuffer);
}
[Guid("045FA593-8799-42b8-BC8D-8968C6453507")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaBuffer
{
HRESULT Lock(out IntPtr ppbBuffer, out int pcbMaxLength, out int pcbCurrentLength);
HRESULT Unlock();
HRESULT GetCurrentLength(out int pcbCurrentLength);
HRESULT SetCurrentLength(int cbCurrentLength);
HRESULT GetMaxLength(out int pcbMaxLength);
}
[ComImport]
[Guid("7DC9D5F9-9ED9-44ec-9BBF-0600BB589FBB")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMF2DBuffer
{
HRESULT Lock2D(out IntPtr ppbScanline0, out uint plPitch);
HRESULT Unlock2D();
HRESULT GetScanline0AndPitch(out IntPtr pbScanline0, out uint plPitch);
HRESULT IsContiguousFormat(out bool pfIsContiguous);
HRESULT GetContiguousLength(out uint pcbLength);
HRESULT ContiguousCopyTo(out IntPtr pbDestBuffer, uint cbDestBuffer);
HRESULT ContiguousCopyFrom(IntPtr pbSrcBuffer, uint cbSrcBuffer);
}
[ComImport]
[Guid("33ae5ea6-4316-436f-8ddd-d73d22f829ec")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMF2DBuffer2 : IMF2DBuffer
{
#region IMF2DBuffer
new HRESULT Lock2D(out IntPtr ppbScanline0, out uint plPitch);
new HRESULT Unlock2D();
new HRESULT GetScanline0AndPitch(out IntPtr pbScanline0, out uint plPitch);
new HRESULT IsContiguousFormat(out bool pfIsContiguous);
new HRESULT GetContiguousLength(out uint pcbLength);
new HRESULT ContiguousCopyTo(out IntPtr pbDestBuffer, uint cbDestBuffer);
new HRESULT ContiguousCopyFrom(IntPtr pbSrcBuffer, uint cbSrcBuffer);
#endregion
HRESULT Lock2DSize(MF2DBuffer_LockFlags lockFlags, out IntPtr ppbScanline0, out int plPitch, out IntPtr ppbBufferStart, out uint pcbBufferLength);
HRESULT Copy2DTo(IMF2DBuffer2 pDestBuffer);
}
public enum MF2DBuffer_LockFlags
{
MF2DBuffer_LockFlags_LockTypeMask = ((0x1 | 0x2) | 0x3),
MF2DBuffer_LockFlags_Read = 0x1,
MF2DBuffer_LockFlags_Write = 0x2,
MF2DBuffer_LockFlags_ReadWrite = 0x3,
MF2DBuffer_LockFlags_ForceDWORD = 0x7fffffff
}
[ComImport]
[Guid("83015ead-b1e6-40d0-a98a-37145ffe1ad1")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEngineEx : IMFMediaEngine
{
#region IMFMediaEngine
new HRESULT GetError(out IMFMediaError ppError);
new HRESULT SetErrorCode(MF_MEDIA_ENGINE_ERR error);
new HRESULT SetSourceElements(IMFMediaEngineSrcElements pSrcElements);
[PreserveSig]
new HRESULT SetSource(string pUrl);
new HRESULT GetCurrentSource(out string ppUrl);
[PreserveSig]
new byte GetNetworkState();
[PreserveSig]
new MF_MEDIA_ENGINE_PRELOAD GetPreload();
new HRESULT SetPreload(MF_MEDIA_ENGINE_PRELOAD Preload);
new HRESULT GetBuffered(out IMFMediaTimeRange ppBuffered);
[PreserveSig]
new HRESULT Load();
new HRESULT CanPlayType(string type, out MF_MEDIA_ENGINE_CANPLAY pAnswer);
[PreserveSig]
new MF_MEDIA_ENGINE_READY GetReadyState();
[PreserveSig]
new bool IsSeeking();
[PreserveSig]
new double GetCurrentTime();
new HRESULT SetCurrentTime(double seekTime);
[PreserveSig]
new double GetStartTime();
[PreserveSig]
new double GetDuration();
[PreserveSig]
new bool IsPaused();
[PreserveSig]
new double GetDefaultPlaybackRate();
new HRESULT SetDefaultPlaybackRate(double Rate);
[PreserveSig]
new double GetPlaybackRate();
new HRESULT SetPlaybackRate(double Rate);
new HRESULT GetPlayed(out IMFMediaTimeRange ppPlayed);
new HRESULT GetSeekable(out IMFMediaTimeRange ppSeekable);
[PreserveSig]
new bool IsEnded();
[PreserveSig]
new bool GetAutoPlay();
new HRESULT SetAutoPlay(bool AutoPlay);
[PreserveSig]
new bool GetLoop();
new HRESULT SetLoop(bool Loop);
new HRESULT Play();
new HRESULT Pause();
[PreserveSig]
new bool GetMuted();
new HRESULT SetMuted(bool Muted);
[PreserveSig]
new double GetVolume();
new HRESULT SetVolume(double Volume);
[PreserveSig]
new bool HasVideo();
[PreserveSig]
new bool HasAudio();
new HRESULT GetNativeVideoSize(out uint cx, out uint cy);
new HRESULT GetVideoAspectRatio(out uint cx, out uint cy);
new HRESULT Shutdown();
[PreserveSig]
new HRESULT TransferVideoFrame(IntPtr pDstSurf, ref MFVideoNormalizedRect pSrc, ref RECT pDst, ref MFARGB pBorderClr);
[PreserveSig]
new HRESULT OnVideoStreamTick(out long pPts);
#endregion
HRESULT SetSourceFromByteStream(IMFByteStream pByteStream, string pURL);
HRESULT GetStatistics(MF_MEDIA_ENGINE_STATISTIC StatisticID, [Out, MarshalAs(UnmanagedType.Struct)] out PROPVARIANT pStatistic);
HRESULT UpdateVideoStream(ref MFVideoNormalizedRect pSrc, ref RECT pDst, ref MFARGB pBorderClr);
[PreserveSig]
double GetBalance();
HRESULT SetBalance(double balance);
[PreserveSig]
bool IsPlaybackRateSupported(double rate);
[PreserveSig]
HRESULT FrameStep(bool Forward);
HRESULT GetResourceCharacteristics(out uint pCharacteristics);
HRESULT GetPresentationAttribute(ref Guid guidMFAttribute, [Out, MarshalAs(UnmanagedType.Struct)] out PROPVARIANT pvValue);
HRESULT GetNumberOfStreams(out uint pdwStreamCount);
HRESULT GetStreamAttribute(uint dwStreamIndex, ref Guid guidMFAttribute, [Out, MarshalAs(UnmanagedType.Struct)] out PROPVARIANT pvValue);
HRESULT GetStreamSelection(uint dwStreamIndex, out bool pEnabled);
HRESULT SetStreamSelection(uint dwStreamIndex, bool Enabled);
HRESULT ApplyStreamSelections();
HRESULT IsProtected(out bool pProtected);
HRESULT InsertVideoEffect(IntPtr pEffect, bool fOptional);
HRESULT InsertAudioEffect(IntPtr pEffect, bool fOptional);
HRESULT RemoveAllEffects();
HRESULT SetTimelineMarkerTimer(double timeToFire);
HRESULT GetTimelineMarkerTimer(out double pTimeToFire);
HRESULT CancelTimelineMarkerTimer();
[PreserveSig]
bool IsStereo3D();
HRESULT GetStereo3DFramePackingMode(out MF_MEDIA_ENGINE_S3D_PACKING_MODE packMode);
HRESULT SetStereo3DFramePackingMode(MF_MEDIA_ENGINE_S3D_PACKING_MODE packMode);
HRESULT GetStereo3DRenderMode(out MF3DVideoOutputType outputType);
HRESULT SetStereo3DRenderMode(MF3DVideoOutputType outputType);
HRESULT EnableWindowlessSwapchainMode(bool fEnable);
HRESULT GetVideoSwapchainIntPtr(out IntPtr phSwapchain);
HRESULT EnableHorizontalMirrorMode(bool fEnable);
HRESULT GetAudioStreamCategory(out uint pCategory);
HRESULT SetAudioStreamCategory(uint category);
HRESULT GetAudioEndpointRole(out uint pRole);
HRESULT SetAudioEndpointRole(uint role);
HRESULT GetRealTimeMode(out bool pfEnabled);
HRESULT SetRealTimeMode(bool fEnable);
HRESULT SetCurrentTimeEx(double seekTime, MF_MEDIA_ENGINE_SEEK_MODE seekMode);
HRESULT EnableTimeUpdateTimer(bool fEnableTimer);
}
public enum MF_MEDIA_ENGINE_STATISTIC
{
MF_MEDIA_ENGINE_STATISTIC_FRAMES_RENDERED = 0,
MF_MEDIA_ENGINE_STATISTIC_FRAMES_DROPPED = 1,
MF_MEDIA_ENGINE_STATISTIC_BYTES_DOWNLOADED = 2,
MF_MEDIA_ENGINE_STATISTIC_BUFFER_PROGRESS = 3,
MF_MEDIA_ENGINE_STATISTIC_FRAMES_PER_SECOND = 4,
MF_MEDIA_ENGINE_STATISTIC_PLAYBACK_JITTER = 5,
MF_MEDIA_ENGINE_STATISTIC_FRAMES_CORRUPTED = 6,
MF_MEDIA_ENGINE_STATISTIC_TOTAL_FRAME_DELAY = 7
}
public enum MF_MEDIA_ENGINE_S3D_PACKING_MODE
{
MF_MEDIA_ENGINE_S3D_PACKING_MODE_NONE = 0,
MF_MEDIA_ENGINE_S3D_PACKING_MODE_SIDE_BY_SIDE = 1,
MF_MEDIA_ENGINE_S3D_PACKING_MODE_TOP_BOTTOM = 2
}
public enum MF_MEDIA_ENGINE_SEEK_MODE
{
MF_MEDIA_ENGINE_SEEK_MODE_NORMAL = 0,
MF_MEDIA_ENGINE_SEEK_MODE_APPROXIMATE = 1
}
public enum MF3DVideoOutputType
{
MF3DVideoOutputType_BaseView = 0,
MF3DVideoOutputType_Stereo = 1
}
[ComImport]
[Guid("bf94c121-5b05-4e6f-8000-ba598961414d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTransform
{
HRESULT GetStreamLimits(out uint pdwInputMinimum, out uint pdwInputMaximum, out uint pdwOutputMinimum, out uint pdwOutputMaximum);
HRESULT GetStreamCount(out uint pcInputStreams, out uint pcOutputStreams);
HRESULT GetStreamIDs(uint dwInputIDArraySize, out uint pdwInputIDs, uint dwOutputIDArraySize, out uint pdwOutputIDs);
HRESULT GetInputStreamInfo(uint dwInputStreamID, out MFT_INPUT_STREAM_INFO pStreamInfo);
HRESULT GetOutputStreamInfo(uint dwOutputStreamID, out MFT_OUTPUT_STREAM_INFO pStreamInfo);
HRESULT GetAttributes(out IMFAttributes pAttributes);
HRESULT GetInputStreamAttributes(uint dwInputStreamID, out IMFAttributes pAttributes);
HRESULT GetOutputStreamAttributes(uint dwOutputStreamID, out IMFAttributes pAttributes);
HRESULT DeleteInputStream(uint dwStreamID);
HRESULT AddInputStreams(uint cStreams, uint adwStreamIDs);
HRESULT GetInputAvailableType(uint dwInputStreamID, uint dwTypeIndex, out IMFMediaType ppType);
HRESULT GetOutputAvailableType(uint dwOutputStreamID, uint dwTypeIndex, out IMFMediaType ppType);
HRESULT SetInputType(uint dwInputStreamID, IMFMediaType pType, uint dwFlags);
HRESULT SetOutputType(uint dwOutputStreamID, IMFMediaType pType, uint dwFlags);
HRESULT GetInputCurrentType(uint dwInputStreamID, out IMFMediaType ppType);
HRESULT GetOutputCurrentType(uint dwOutputStreamID, out IMFMediaType ppType);
HRESULT GetInputStatus(uint dwInputStreamID, out uint pdwFlags);
HRESULT GetOutputStatus(out uint pdwFlags);
HRESULT SetOutputBounds(long hnsLowerBound, long hnsUpperBound);
HRESULT ProcessEvent(uint dwInputStreamID, IMFMediaEvent pEvent);
HRESULT ProcessMessage(MFT_MESSAGE_TYPE eMessage, IntPtr ulParam);
HRESULT ProcessInput(uint dwInputStreamID, IMFSample pSample, uint dwFlags);
HRESULT ProcessOutput(uint dwFlags, uint cOutputBufferCount, ref MFT_OUTPUT_DATA_BUFFER pOutputSamples, out uint pdwStatus);
}
public enum MFT_INPUT_STREAM_INFO_FLAGS
{
MFT_INPUT_STREAM_WHOLE_SAMPLES = 0x1,
MFT_INPUT_STREAM_SINGLE_SAMPLE_PER_BUFFER = 0x2,
MFT_INPUT_STREAM_FIXED_SAMPLE_SIZE = 0x4,
MFT_INPUT_STREAM_HOLDS_BUFFERS = 0x8,
MFT_INPUT_STREAM_DOES_NOT_ADDREF = 0x100,
MFT_INPUT_STREAM_REMOVABLE = 0x200,
MFT_INPUT_STREAM_OPTIONAL = 0x400,
MFT_INPUT_STREAM_PROCESSES_IN_PLACE = 0x800
};
[StructLayout(LayoutKind.Sequential)]
public struct MFT_INPUT_STREAM_INFO
{
public long hnsMaxLatency;
public uint dwFlags;
public uint cbSize;
public uint cbMaxLookahead;
public uint cbAlignment;
}
[StructLayout(LayoutKind.Sequential)]
public struct MFT_OUTPUT_STREAM_INFO
{
public uint dwFlags;
public uint cbSize;
public uint cbAlignment;
}
public enum MFT_MESSAGE_TYPE
{
MFT_MESSAGE_COMMAND_FLUSH = 0,
MFT_MESSAGE_COMMAND_DRAIN = 0x1,
MFT_MESSAGE_SET_D3D_MANAGER = 0x2,
MFT_MESSAGE_DROP_SAMPLES = 0x3,
MFT_MESSAGE_COMMAND_TICK = 0x4,
MFT_MESSAGE_NOTIFY_BEGIN_STREAMING = 0x10000000,
MFT_MESSAGE_NOTIFY_END_STREAMING = 0x10000001,
MFT_MESSAGE_NOTIFY_END_OF_STREAM = 0x10000002,
MFT_MESSAGE_NOTIFY_START_OF_STREAM = 0x10000003,
MFT_MESSAGE_NOTIFY_RELEASE_RESOURCES = 0x10000004,
MFT_MESSAGE_NOTIFY_REACQUIRE_RESOURCES = 0x10000005,
MFT_MESSAGE_NOTIFY_EVENT = 0x10000006,
MFT_MESSAGE_COMMAND_SET_OUTPUT_STREAM_STATE = 0x10000007,
MFT_MESSAGE_COMMAND_FLUSH_OUTPUT_STREAM = 0x10000008,
MFT_MESSAGE_COMMAND_MARKER = 0x20000000
}
[StructLayout(LayoutKind.Sequential)]
public struct MFT_OUTPUT_DATA_BUFFER
{
public uint dwStreamID;
public IMFSample pSample;
public uint dwStatus;
public IMFCollection pEvents;
}
[ComImport]
[Guid("5BC8A76B-869A-46a3-9B03-FA218A66AEBE")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFCollection
{
HRESULT GetElementCount(out uint pcElements);
HRESULT GetElement(uint dwElementIndex, out IntPtr ppUnkElement);
HRESULT AddElement(IntPtr pUnkElement);
HRESULT RemoveElement(uint dwElementIndex, out IntPtr ppUnkElement);
HRESULT InsertElementAt(uint dwIndex, IntPtr pUnknown);
HRESULT RemoveAllElements();
}
[ComImport]
[Guid("DF598932-F10C-4E39-BBA2-C308F101DAA3")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFMediaEvent : IMFAttributes
{
#region IMFAttributes
new HRESULT GetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT GetItemType(ref Guid guidKey, out MF_ATTRIBUTE_TYPE pType);
new HRESULT CompareItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value, out bool pbResult);
new HRESULT Compare(IMFAttributes pTheirs, MF_ATTRIBUTES_MATCH_TYPE MatchType, out bool pbResult);
new HRESULT GetUINT32(ref Guid guidKey, out uint punValue);
new HRESULT GetUINT64(ref Guid guidKey, out ulong punValue);
new HRESULT GetDouble(ref Guid guidKey, out double pfValue);
new HRESULT GetGUID(ref Guid guidKey, out Guid pguidValue);
new HRESULT GetStringLength(ref Guid guidKey, out uint pcchLength);
new HRESULT GetString(ref Guid guidKey, out string pwszValue, uint cchBufSize, ref uint pcchLength);
new HRESULT GetAllocatedString(ref Guid guidKey, out string ppwszValue, out uint pcchLength);
new HRESULT GetBlobSize(ref Guid guidKey, out uint pcbBlobSize);
new HRESULT GetBlob(ref Guid guidKey, out char pBuf, uint cbBufSize, ref uint pcbBlobSize);
new HRESULT GetAllocatedBlob(ref Guid guidKey, out char ppBuf, out uint pcbSize);
new HRESULT GetUnknown(ref Guid guidKey, ref Guid riid, out IntPtr ppv);
new HRESULT SetItem(ref Guid guidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT Value);
new HRESULT DeleteItem(ref Guid guidKey);
new HRESULT DeleteAllItems();
new HRESULT SetUINT32(ref Guid guidKey, uint unValue);
new HRESULT SetUINT64(ref Guid guidKey, ulong unValue);
new HRESULT SetDouble(ref Guid guidKey, double fValue);
new HRESULT SetGUID(ref Guid guidKey, ref Guid guidValue);
new HRESULT SetString(ref Guid guidKey, string wszValue);
new HRESULT SetBlob(ref Guid guidKey, char pBuf, uint cbBufSize);
//new HRESULT SetUnknown(ref Guid guidKey, IUnknown pUnknown = null);
new HRESULT SetUnknown(ref Guid guidKey, IntPtr pUnknown);
new HRESULT LockStore();
new HRESULT UnlockStore();
new HRESULT GetCount(out uint pcItems);
new HRESULT GetItemByIndex(uint unIndex, out Guid pguidKey, [In, MarshalAs(UnmanagedType.Struct)] ref PROPVARIANT pValue);
new HRESULT CopyAllItems(IMFAttributes pDest = null);
#endregion
HRESULT GetType(out uint pmet);
HRESULT GetExtendedType(out Guid pguidExtendedType);
HRESULT GetStatus(out HRESULT phrStatus);
HRESULT GetValue([Out, MarshalAs(UnmanagedType.Struct)] out PROPVARIANT pvValue);
}
[ComImport]
[Guid("1f2a94c9-a3df-430d-9d0f-acd85ddc29af")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedText
{
HRESULT RegisterNotifications(IMFTimedTextNotify notify);
[PreserveSig]
HRESULT SelectTrack(uint trackId, bool selected);
[PreserveSig]
HRESULT AddDataSource(IMFByteStream byteStream, string label, string language, MF_TIMED_TEXT_TRACK_KIND kind, bool isDefault, out uint trackId);
[PreserveSig]
HRESULT AddDataSourceFromUrl(string url, string label, string language, MF_TIMED_TEXT_TRACK_KIND kind, bool isDefault, out uint trackId);
[PreserveSig]
HRESULT AddTrack(string label, string language, MF_TIMED_TEXT_TRACK_KIND kind, out IMFTimedTextTrack track);
HRESULT RemoveTrack(IMFTimedTextTrack track);
HRESULT GetCueTimeOffset(out double offset);
HRESULT SetCueTimeOffset(double offset);
HRESULT GetTracks(out IMFTimedTextTrackList tracks);
HRESULT GetActiveTracks(out IMFTimedTextTrackList activeTracks);
HRESULT GetTextTracks(out IMFTimedTextTrackList textTracks);
HRESULT GetMetadataTracks(out IMFTimedTextTrackList metadataTracks);
HRESULT SetInBandEnabled(bool enabled);
[PreserveSig]
bool IsInBandEnabled();
}
public enum MF_TIMED_TEXT_TRACK_KIND
{
MF_TIMED_TEXT_TRACK_KIND_UNKNOWN = 0,
MF_TIMED_TEXT_TRACK_KIND_SUBTITLES = 1,
MF_TIMED_TEXT_TRACK_KIND_CAPTIONS = 2,
MF_TIMED_TEXT_TRACK_KIND_METADATA = 3
}
[ComImport]
[Guid("df6b87b6-ce12-45db-aba7-432fe054e57d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedTextNotify
{
void TrackAdded(uint trackId);
void TrackRemoved(uint trackId);
void TrackSelected(uint trackId, bool selected);
void TrackReadyStateChanged(MF_TIMED_TEXT_TRACK_READY_STATE trackId);
void Error(MF_TIMED_TEXT_ERROR_CODE errorCode, HRESULT extendedErrorCode, uint sourceTrackId);
void Cue(MF_TIMED_TEXT_CUE_EVENT cueEvent, double currentTime, IMFTimedTextCue cue);
void Reset();
}
public enum MF_TIMED_TEXT_ERROR_CODE
{
MF_TIMED_TEXT_ERROR_CODE_NOERROR = 0,
MF_TIMED_TEXT_ERROR_CODE_FATAL = 1,
MF_TIMED_TEXT_ERROR_CODE_DATA_FORMAT = 2,
MF_TIMED_TEXT_ERROR_CODE_NETWORK = 3,
MF_TIMED_TEXT_ERROR_CODE_INTERNAL = 4
}
public enum MF_TIMED_TEXT_CUE_EVENT
{
MF_TIMED_TEXT_CUE_EVENT_ACTIVE = 0,
MF_TIMED_TEXT_CUE_EVENT_INACTIVE = (MF_TIMED_TEXT_CUE_EVENT_ACTIVE + 1),
MF_TIMED_TEXT_CUE_EVENT_CLEAR = (MF_TIMED_TEXT_CUE_EVENT_INACTIVE + 1)
}
[ComImport]
[Guid("8822c32d-654e-4233-bf21-d7f2e67d30d4")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedTextTrack
{
[PreserveSig]
uint GetId();
HRESULT GetLabel([Out, MarshalAs(UnmanagedType.LPWStr)] out string label);
HRESULT SetLabel(string label);
HRESULT GetLanguage([Out, MarshalAs(UnmanagedType.LPWStr)] out string language);
[PreserveSig]
MF_TIMED_TEXT_TRACK_KIND GetTrackKind();
[PreserveSig]
bool IsInBand();
HRESULT GetInBandMetadataTrackDispatchType(out string dispatchType);
[PreserveSig]
bool IsActive();
[PreserveSig]
MF_TIMED_TEXT_ERROR_CODE GetErrorCode();
HRESULT GetExtendedErrorCode();
HRESULT GetDataFormat(out Guid format);
[PreserveSig]
MF_TIMED_TEXT_TRACK_READY_STATE GetReadyState();
HRESULT GetCueList(out IMFTimedTextCueList cues);
}
public enum MF_TIMED_TEXT_TRACK_READY_STATE
{
MF_TIMED_TEXT_TRACK_READY_STATE_NONE = 0,
MF_TIMED_TEXT_TRACK_READY_STATE_LOADING = (MF_TIMED_TEXT_TRACK_READY_STATE_NONE + 1),
MF_TIMED_TEXT_TRACK_READY_STATE_LOADED = (MF_TIMED_TEXT_TRACK_READY_STATE_LOADING + 1),
MF_TIMED_TEXT_TRACK_READY_STATE_ERROR = (MF_TIMED_TEXT_TRACK_READY_STATE_LOADED + 1)
}
[ComImport]
[Guid("23ff334c-442c-445f-bccc-edc438aa11e2")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedTextTrackList
{
[PreserveSig]
uint GetLength();
HRESULT GetTrack(uint index, out IMFTimedTextTrack track);
HRESULT GetTrackById(uint trackId, out IMFTimedTextTrack track);
}
[ComImport]
[Guid("ad128745-211b-40a0-9981-fe65f166d0fd")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedTextCueList
{
[PreserveSig]
uint GetLength();
HRESULT GetCueByIndex(uint index, out IMFTimedTextCue cue);
HRESULT GetCueById(uint id, out IMFTimedTextCue cue);
HRESULT GetCueByOriginalId(string originalId, out IMFTimedTextCue cue);
HRESULT AddTextCue(double start, double duration, string text, out IMFTimedTextCue cue);
HRESULT AddDataCue(double start, double duration, IntPtr data, uint dataSize, IMFTimedTextCue cue);
HRESULT RemoveCue(IMFTimedTextCue cue);
}
[ComImport]
[Guid("1e560447-9a2b-43e1-a94c-b0aaabfbfbc9")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMFTimedTextCue
{
[PreserveSig]
uint GetId();
[PreserveSig]
//HRESULT GetOriginalId(out IntPtr originalId);
//HRESULT GetOriginalId(StringBuilder originalId);
HRESULT GetOriginalId([Out, MarshalAs(UnmanagedType.LPWStr)] out string originalId);
[PreserveSig]
MF_TIMED_TEXT_TRACK_KIND GetCueKind();
[PreserveSig]
double GetStartTime();
[PreserveSig]
double GetDuration();
[PreserveSig]
uint GetTrackId();
HRESULT GetData(out IMFTimedTextBinary data);