From: Biswapriyo Nath nathbappai@gmail.com
Required for https://code.videolan.org/videolan/vlc/-/commit/e68f089d5419c7832c625f535f9e... --- include/Makefile.in | 2 + include/mpeg2bits.h | 70 +++++++++ include/mpeg2data.idl | 267 ++++++++++++++++++++++++++++++++++ include/mpeg2structs.idl | 300 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 639 insertions(+) create mode 100644 include/mpeg2bits.h create mode 100644 include/mpeg2data.idl create mode 100644 include/mpeg2structs.idl
diff --git a/include/Makefile.in b/include/Makefile.in index 5938a0b05ba..c0c7af415ef 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -465,6 +465,8 @@ SOURCES = \ mmreg.h \ mmstream.idl \ mmsystem.h \ + mpeg2data.idl \ + mpeg2structs.idl \ mpegtype.idl \ mprapi.h \ mprerror.h \ diff --git a/include/mpeg2bits.h b/include/mpeg2bits.h new file mode 100644 index 00000000000..f75690adb2f --- /dev/null +++ b/include/mpeg2bits.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2025 Biswapriyo Nath + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _MPEG2BITS_H_ +#define _MPEG2BITS_H_ + +#pragma pack(push) + +#pragma pack(1) + +#ifdef __WIDL__ +typedef struct +{ + WORD Bits; +} PID_BITS_MIDL; +#else +typedef struct +{ + WORD Reserved : 3; + WORD ProgramId : 13; +} PID_BITS, *PPID_BITS; +#endif + +#ifdef __WIDL__ +typedef struct +{ + WORD Bits; +} MPEG_HEADER_BITS_MIDL; +#else +typedef struct +{ + WORD SectionLength : 12; + WORD Reserved : 2; + WORD PrivateIndicator : 1; + WORD SectionSyntaxIndicator : 1; +} MPEG_HEADER_BITS, *PMPEG_HEADER_BITS; +#endif + +#ifdef __WIDL__ +typedef struct +{ + BYTE Bits; +} MPEG_HEADER_VERSION_BITS_MIDL; +#else +typedef struct +{ + BYTE CurrentNextIndicator : 1; + BYTE VersionNumber : 5; + BYTE Reserved : 2; +} MPEG_HEADER_VERSION_BITS, *PMPEG_HEADER_VERSION_BITS; +#endif + +#pragma pack(pop) + +#endif /* _MPEG2BITS_H_ */ diff --git a/include/mpeg2data.idl b/include/mpeg2data.idl new file mode 100644 index 00000000000..a437eb1148f --- /dev/null +++ b/include/mpeg2data.idl @@ -0,0 +1,267 @@ +/* + * Copyright (C) 2025 Biswapriyo Nath + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "oaidl.idl"; +import "ocidl.idl"; +import "bdaiface.idl"; +import "mpeg2structs.idl"; + +interface ISectionList; +interface IMpeg2Stream; + +cpp_quote("#define MPEG_PAT_PID 0x0000") +cpp_quote("#define MPEG_PAT_TID 0x00") + +cpp_quote("#define MPEG_CAT_PID 0x0001") +cpp_quote("#define MPEG_CAT_TID 0x01") + +cpp_quote("#define MPEG_PMT_TID 0x02") + +cpp_quote("#define MPEG_TSDT_PID 0x0002") +cpp_quote("#define MPEG_TSDT_TID 0x03") + +cpp_quote("#define ATSC_MGT_PID 0x1ffb") +cpp_quote("#define ATSC_MGT_TID 0xc7") + +cpp_quote("#define ATSC_VCT_PID 0x1ffb") +cpp_quote("#define ATSC_VCT_TERR_TID 0xc8") +cpp_quote("#define ATSC_VCT_CABL_TID 0xc9") + +cpp_quote("#define ATSC_EIT_TID 0xcb") + +cpp_quote("#define ATSC_ETT_TID 0xcc") + +cpp_quote("#define ATSC_RRT_TID 0xca") +cpp_quote("#define ATSC_RRT_PID 0x1ffb") + +cpp_quote("#define ATSC_STT_PID 0x1ffb") +cpp_quote("#define ATSC_STT_TID 0xcd") + +cpp_quote("#define ATSC_PIT_TID 0xd0") + +cpp_quote("#define DVB_NIT_PID 0x0010") +cpp_quote("#define DVB_NIT_ACTUAL_TID 0x40") +cpp_quote("#define DVB_NIT_OTHER_TID 0x41") + +cpp_quote("#define DVB_SDT_PID 0x0011") +cpp_quote("#define DVB_SDT_ACTUAL_TID 0x42") +cpp_quote("#define DVB_SDT_OTHER_TID 0x46") + +cpp_quote("#define DVB_BAT_PID 0x0011") +cpp_quote("#define DVB_BAT_TID 0x4a") + +cpp_quote("#define DVB_EIT_PID 0x0012") +cpp_quote("#define DVB_EIT_ACTUAL_TID 0x4e") +cpp_quote("#define DVB_EIT_OTHER_TID 0x4f") + +cpp_quote("#define DVB_RST_PID 0x0013") +cpp_quote("#define DVB_RST_TID 0x71") + +cpp_quote("#define DVB_TDT_PID 0x0014") +cpp_quote("#define DVB_TDT_TID 0x70") + +cpp_quote("#define DVB_ST_PID_16 0x0010") +cpp_quote("#define DVB_ST_PID_17 0x0011") +cpp_quote("#define DVB_ST_PID_18 0x0012") +cpp_quote("#define DVB_ST_PID_19 0x0013") +cpp_quote("#define DVB_ST_PID_20 0x0014") +cpp_quote("#define DVB_ST_TID 0x72") +cpp_quote("#define ISDB_ST_TID 0x72") + +cpp_quote("#define DVB_TOT_PID 0x0014") +cpp_quote("#define DVB_TOT_TID 0x73") + +cpp_quote("#define DVB_DIT_PID 0x001e") +cpp_quote("#define DVB_DIT_TID 0x7e") + +cpp_quote("#define DVB_SIT_PID 0x001f") +cpp_quote("#define DVB_SIT_TID 0x7f") + +cpp_quote("#define ISDB_EMM_TID 0x85") + +cpp_quote("#define ISDB_BIT_PID 0x0024") +cpp_quote("#define ISDB_BIT_TID 0xc4") + +cpp_quote("#define ISDB_NBIT_PID 0x0025") +cpp_quote("#define ISDB_NBIT_MSG_TID 0xc5") +cpp_quote("#define ISDB_NBIT_REF_TID 0xc6") + +cpp_quote("#define ISDB_LDT_PID 0x0025") +cpp_quote("#define ISDB_LDT_TID 0xc7") + +cpp_quote("#define ISDB_SDTT_PID 0x0023") +cpp_quote("#define ISDB_SDTT_ALT_PID 0x0028") +cpp_quote("#define ISDB_SDTT_TID 0xc3") + +cpp_quote("#define ISDB_CDT_PID 0x0029") +cpp_quote("#define ISDB_CDT_TID 0xc8") + +cpp_quote("#define SCTE_EAS_TID 0xd8") +cpp_quote("#define SCTE_EAS_IB_PID 0x1ffb") +cpp_quote("#define SCTE_EAS_OOB_PID 0x1ffc") + +[ + object, + uuid(bdcdd913-9ecd-4fb2-81ae-adf747ea75a5), + pointer_default(unique) +] +interface IMpeg2TableFilter : IUnknown +{ + HRESULT AddPID(PID p); + HRESULT AddTable(PID p, TID t); + HRESULT AddExtension(PID p, TID t, TEID e); + HRESULT RemovePID(PID p); + HRESULT RemoveTable(PID p, TID t); + HRESULT RemoveExtension(PID p, TID t, TEID e); +} + +[ + uuid(752845f1-758f-4c83-a043-4270c593308e) +] +coclass Mpeg2TableFilter +{ + [default] interface IMpeg2TableFilter; +} + +typedef struct Mpeg2TableSampleHdr +{ + BYTE SectionCount; + BYTE Reserved[3]; + long SectionOffsets[]; +} Mpeg2TableSampleHdr; + +[ + uuid(dbaf6c1b-b6a4-4898-ae65-204f0d9509a1), + version(1.0) +] +library Mpeg2DataLib +{ +importlib("stdole32.tlb"); +importlib("stdole2.tlb"); + +[ + object, + uuid(9b396d40-f380-4e3c-a514-1a82bf6ebfe6), + pointer_default(unique) +] +interface IMpeg2Data : IUnknown +{ + HRESULT GetSection( + [in] PID pid, + [in] TID tid, + [in] PMPEG2_FILTER filter, + [in] DWORD timeout, + [out] ISectionList **section_list); + + HRESULT GetTable( + [in] PID pid, + [in] TID tid, + [in] PMPEG2_FILTER filter, + [in] DWORD timeout, + [out] ISectionList **section_list); + + HRESULT GetStreamOfSections( + [in] PID pid, + [in] TID tid, + [in] PMPEG2_FILTER filter, + [in] HANDLE data_ready_event, + [out] IMpeg2Stream **mpeg_stream); +} + +[ + object, + uuid(afec1eb5-2a64-46c6-bf4b-ae3ccb6afdb0), + pointer_default(unique) +] +interface ISectionList : IUnknown +{ + HRESULT Initialize( + [in] MPEG_REQUEST_TYPE request_type, + [in] IMpeg2Data *mpeg2_data, + [in] PMPEG_CONTEXT context, + [in] PID pid, + [in] TID tid, + [in] PMPEG2_FILTER filter, + [in] DWORD timeout, + [in] HANDLE done_event); + + HRESULT InitializeWithRawSections( + [in] PMPEG_PACKET_LIST mpl_sections); + + HRESULT CancelPendingRequest(void); + + HRESULT GetNumberOfSections( + [out] WORD *count); + + HRESULT GetSectionData( + [in] WORD section_number, + [out] DWORD *raw_packet_length, + [out] PSECTION *section); + + HRESULT GetProgramIdentifier( + [out] PID *pid); + + HRESULT GetTableIdentifier( + [out] TID *tid); +} + +[ + object, + uuid(400cc286-32a0-4ce4-9041-39571125a635), + pointer_default(unique) +] +interface IMpeg2Stream : IUnknown +{ + HRESULT Initialize( + [in] MPEG_REQUEST_TYPE request_type, + [in] IMpeg2Data *mpeg2_data, + [in] PMPEG_CONTEXT context, + [in] PID pid, + [in] TID tid, + [in] PMPEG2_FILTER filter, + [in] HANDLE data_ready_event); + + HRESULT SupplyDataBuffer( + [in] PMPEG_STREAM_BUFFER stream_buffer); +} + +[ + uuid(73da5d04-4347-45d3-a9dc-fae9ddbe558d) +] +coclass SectionList +{ + [default] interface ISectionList; +} + +[ + uuid(f91d96c7-8509-4d0b-ab26-a0dd10904bb7) +] +coclass Mpeg2Stream +{ + [default] interface IMpeg2Stream; +} + +[ + uuid(c666e115-bb62-4027-a113-82d643fe2d99) +] +coclass Mpeg2Data +{ + [default] interface IMpeg2Data; +} + +} /* Mpeg2DataLib */ diff --git a/include/mpeg2structs.idl b/include/mpeg2structs.idl new file mode 100644 index 00000000000..643c2ffaa22 --- /dev/null +++ b/include/mpeg2structs.idl @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2025 Biswapriyo Nath + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "wtypes.idl"; +#include "mpeg2bits.h" + +typedef WORD PID; +typedef BYTE TID; +typedef WORD TEID; +typedef UINT ClientKey; + +typedef enum +{ + MPEG_SECTION_IS_NEXT = 0, + MPEG_SECTION_IS_CURRENT = 1, +} MPEG_CURRENT_NEXT_BIT; + +typedef struct +{ + WORD wTidExt; + WORD wCount; +} TID_EXTENSION, *PTID_EXTENSION; + +typedef struct +{ + TID TableId; + union + { + MPEG_HEADER_BITS_MIDL S; + WORD W; + } Header; + BYTE SectionData[1]; +} SECTION, *PSECTION; + +typedef struct +{ + TID TableId; + union + { + MPEG_HEADER_BITS_MIDL S; + WORD W; + } Header; + TEID TableIdExtension; + union + { + MPEG_HEADER_VERSION_BITS_MIDL S; + BYTE B; + } Version; + BYTE SectionNumber; + BYTE LastSectionNumber; + BYTE RemainingData[1]; +} LONG_SECTION, *PLONG_SECTION; + +typedef struct +{ + TID TableId; + union + { + MPEG_HEADER_BITS_MIDL S; + WORD W; + } Header; + TEID TableIdExtension; + union + { + MPEG_HEADER_VERSION_BITS_MIDL S; + BYTE B; + } Version; + BYTE SectionNumber; + BYTE LastSectionNumber; + BYTE ProtocolDiscriminator; + BYTE DsmccType; + WORD MessageId; + DWORD TransactionId; + BYTE Reserved; + BYTE AdaptationLength; + WORD MessageLength; + BYTE RemainingData[1]; +} DSMCC_SECTION, *PDSMCC_SECTION; + +typedef struct +{ + DWORD dwLength; + PSECTION pSection; +} MPEG_RQST_PACKET, *PMPEG_RQST_PACKET; + +typedef struct +{ + WORD wPacketCount; + [size_is(wPacketCount)] PMPEG_RQST_PACKET PacketList[]; +} MPEG_PACKET_LIST, *PMPEG_PACKET_LIST; + +typedef struct +{ + BOOL fSpecifyProtocol; + BYTE Protocol; + BOOL fSpecifyType; + BYTE Type; + BOOL fSpecifyMessageId; + WORD MessageId; + BOOL fSpecifyTransactionId; + BOOL fUseTrxIdMessageIdMask; + DWORD TransactionId; + BOOL fSpecifyModuleVersion; + BYTE ModuleVersion; + BOOL fSpecifyBlockNumber; + WORD BlockNumber; + BOOL fGetModuleCall; + WORD NumberOfBlocksInModule; +} DSMCC_FILTER_OPTIONS; + +typedef struct +{ + BOOL fSpecifyEtmId; + DWORD EtmId; +} ATSC_FILTER_OPTIONS; + +typedef struct +{ + BOOL fSpecifySegment; + BYTE bSegment; +} DVB_EIT_FILTER_OPTIONS; + +typedef struct +{ + BYTE bVersionNumber; + WORD wFilterSize; + BOOL fUseRawFilteringBits; + BYTE Filter[16]; + BYTE Mask[16]; + BOOL fSpecifyTableIdExtension; + WORD TableIdExtension; + BOOL fSpecifyVersion; + BYTE Version; + BOOL fSpecifySectionNumber; + BYTE SectionNumber; + BOOL fSpecifyCurrentNext; + BOOL fNext; + BOOL fSpecifyDsmccOptions; + DSMCC_FILTER_OPTIONS Dsmcc; + BOOL fSpecifyAtscOptions; + ATSC_FILTER_OPTIONS Atsc; +} MPEG2_FILTER, *PMPEG2_FILTER; + +typedef struct +{ + union + { + struct + { + BYTE bVersionNumber; + WORD wFilterSize; + BOOL fUseRawFilteringBits; + BYTE Filter[16]; + BYTE Mask[16]; + BOOL fSpecifyTableIdExtension; + WORD TableIdExtension; + BOOL fSpecifyVersion; + BYTE Version; + BOOL fSpecifySectionNumber; + BYTE SectionNumber; + BOOL fSpecifyCurrentNext; + BOOL fNext; + BOOL fSpecifyDsmccOptions; + DSMCC_FILTER_OPTIONS Dsmcc; + BOOL fSpecifyAtscOptions; + ATSC_FILTER_OPTIONS Atsc; + }; + BYTE bVersion1Bytes[124]; + }; + BOOL fSpecifyDvbEitOptions; + DVB_EIT_FILTER_OPTIONS DvbEit; +} MPEG2_FILTER2, *PMPEG2_FILTER2; + +cpp_quote("#define MPEG2_FILTER_VERSION_1_SIZE 124") +cpp_quote("#define MPEG2_FILTER_VERSION_2_SIZE 133") + +typedef struct +{ + HRESULT hr; + DWORD dwDataBufferSize; + DWORD dwSizeOfDataRead; + [size_is(dwDataBufferSize)] BYTE *pDataBuffer; +} MPEG_STREAM_BUFFER, *PMPEG_STREAM_BUFFER; + +typedef struct +{ + BYTE Hours; + BYTE Minutes; + BYTE Seconds; +} MPEG_TIME; + +typedef MPEG_TIME MPEG_DURATION; + +typedef struct +{ + BYTE Date; + BYTE Month; + WORD Year; +} MPEG_DATE; + +typedef struct +{ + MPEG_DATE D; + MPEG_TIME T; +} MPEG_DATE_AND_TIME; + +typedef enum +{ + MPEG_CONTEXT_BCS_DEMUX, + MPEG_CONTEXT_WINSOCK, +} MPEG_CONTEXT_TYPE; + +typedef struct +{ + DWORD AVMGraphId; +} MPEG_BCS_DEMUX; + +typedef struct +{ + DWORD AVMGraphId; +} MPEG_WINSOCK; + +typedef struct +{ + MPEG_CONTEXT_TYPE Type; + union + { + MPEG_BCS_DEMUX Demux; + MPEG_WINSOCK Winsock; + } U; +} MPEG_CONTEXT, *PMPEG_CONTEXT; + +typedef enum +{ + MPEG_RQST_UNKNOWN = 0, + MPEG_RQST_GET_SECTION, + MPEG_RQST_GET_SECTION_ASYNC, + MPEG_RQST_GET_TABLE, + MPEG_RQST_GET_TABLE_ASYNC, + MPEG_RQST_GET_SECTIONS_STREAM, + MPEG_RQST_GET_PES_STREAM, + MPEG_RQST_GET_TS_STREAM, + MPEG_RQST_START_MPE_STREAM, +} MPEG_REQUEST_TYPE; + +typedef struct +{ + MPEG_REQUEST_TYPE Type; + MPEG_CONTEXT Context; + PID Pid; + TID TableId; + MPEG2_FILTER Filter; + DWORD Flags; +} MPEG_SERVICE_REQUEST, *PMPEG_SERVICE_REQUEST; + +typedef struct +{ + DWORD IPAddress; + WORD Port; +} MPEG_SERVICE_RESPONSE, *PMPEG_SERVICE_RESPONSE; + +typedef struct _DSMCC_ELEMENT +{ + PID pid; + BYTE bComponentTag; + DWORD dwCarouselId; + DWORD dwTransactionId; + struct _DSMCC_ELEMENT *pNext; +} DSMCC_ELEMENT, *PDSMCC_ELEMENT; + +typedef struct _MPE_ELEMENT +{ + PID pid; + BYTE bComponentTag; + struct _MPE_ELEMENT *pNext; +} MPE_ELEMENT, *PMPE_ELEMENT; + +typedef struct _MPEG_STREAM_FILTER +{ + WORD wPidValue; + DWORD dwFilterSize; + BOOL fCrcEnabled; + BYTE rgchFilter[16]; + BYTE rgchMask[16]; +} MPEG_STREAM_FILTER;
Jacek Caban (@jacek) commented about include/mpeg2bits.h:
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
+#ifndef _MPEG2BITS_H_ +#define _MPEG2BITS_H_
+#pragma pack(push)
+#pragma pack(1)
Please include `pshpack1.h` instead (and `poppack.h` instead of `pack(pop)`).
Jacek Caban (@jacek) commented about include/mpeg2data.idl:
- HRESULT CancelPendingRequest(void);
- HRESULT GetNumberOfSections(
[out] WORD *count);
- HRESULT GetSectionData(
[in] WORD section_number,
[out] DWORD *raw_packet_length,
[out] PSECTION *section);
- HRESULT GetProgramIdentifier(
[out] PID *pid);
- HRESULT GetTableIdentifier(
[out] TID *tid);
Those two functions don't use `[out]` in winsdk. They are indeed output parameters and it's usually not a big deal, but since those are part of a typelib, we should probably match it.
On Fri Mar 7 10:31:36 2025 +0000, Jacek Caban wrote:
Please include `pshpack1.h` instead (and `poppack.h` instead of `pack(pop)`).
Maybe we should start allowing pragma pack push/pop? It seems to be portable enough nowadays.
On Fri Mar 7 11:22:36 2025 +0000, Alexandre Julliard wrote:
Maybe we should start allowing pragma pack push/pop? It seems to be portable enough nowadays.
Sounds good to me.
On Fri Mar 7 11:38:52 2025 +0000, Jacek Caban wrote:
Sounds good to me.
Should I just keep it that way?
On Fri Mar 7 10:33:00 2025 +0000, Jacek Caban wrote:
Those two functions don't use `[out]` in winsdk. They are indeed output parameters and it's usually not a big deal, but since those are part of a typelib, we should probably match it.
I think there was a MR to add annotations in dwrite*.idl files. Aren't those required for some reason?
On Fri Mar 7 13:17:33 2025 +0000, Biswapriyo Nath wrote:
I think there was a MR to add annotations in dwrite*.idl files. Aren't those required for some reason?
dwrite.idl changes were for more obscure use case, and I annotated all parameters for consistency.
With great sorrow, I would like to inform that I messed up this merge request by not creating a new branch 😔
This merge request was closed by Biswapriyo Nath.