1 // CreateCoder.h
2 
3 #ifndef __CREATE_CODER_H
4 #define __CREATE_CODER_H
5 
6 #include "../../Common/MyCom.h"
7 #include "../../Common/MyString.h"
8 #include "../ICoder.h"
9 
10 #include "MethodId.h"
11 
12 #ifdef EXTERNAL_CODECS
13 
14 struct CCodecInfoEx
15 {
16   UString Name;
17   CMethodId Id;
18   UInt32 NumInStreams;
19   UInt32 NumOutStreams;
20   bool EncoderIsAssigned;
21   bool DecoderIsAssigned;
22 
IsSimpleCodecCCodecInfoEx23   bool IsSimpleCodec() const { return NumOutStreams == 1 && NumInStreams == 1; }
CCodecInfoExCCodecInfoEx24   CCodecInfoEx(): EncoderIsAssigned(false), DecoderIsAssigned(false) {}
25 };
26 
27 struct CHasherInfoEx
28 {
29   UString Name;
30   CMethodId Id;
31 };
32 
33 #define PUBLIC_ISetCompressCodecsInfo public ISetCompressCodecsInfo,
34 #define QUERY_ENTRY_ISetCompressCodecsInfo MY_QUERYINTERFACE_ENTRY(ISetCompressCodecsInfo)
35 #define DECL_ISetCompressCodecsInfo STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo);
36 #define IMPL_ISetCompressCodecsInfo2(x) \
37 STDMETHODIMP x::SetCompressCodecsInfo(ICompressCodecsInfo *compressCodecsInfo) { \
38   COM_TRY_BEGIN __externalCodecs.GetCodecs = compressCodecsInfo;  return __externalCodecs.LoadCodecs(); COM_TRY_END }
39 #define IMPL_ISetCompressCodecsInfo IMPL_ISetCompressCodecsInfo2(CHandler)
40 
41 struct CExternalCodecs
42 {
43   CMyComPtr<ICompressCodecsInfo> GetCodecs;
44   CMyComPtr<IHashers> GetHashers;
45 
46   CObjectVector<CCodecInfoEx> Codecs;
47   CObjectVector<CHasherInfoEx> Hashers;
48 
49   HRESULT LoadCodecs();
50 };
51 
52 #define EXTERNAL_CODECS_VARS2 &__externalCodecs
53 
54 #define DECL_EXTERNAL_CODECS_VARS CExternalCodecs __externalCodecs;
55 #define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2,
56 
57 #define DECL_EXTERNAL_CODECS_LOC_VARS2 const CExternalCodecs *__externalCodecs
58 #define EXTERNAL_CODECS_LOC_VARS2 __externalCodecs
59 
60 #define DECL_EXTERNAL_CODECS_LOC_VARS DECL_EXTERNAL_CODECS_LOC_VARS2,
61 #define EXTERNAL_CODECS_LOC_VARS EXTERNAL_CODECS_LOC_VARS2,
62 
63 #else
64 
65 #define PUBLIC_ISetCompressCodecsInfo
66 #define QUERY_ENTRY_ISetCompressCodecsInfo
67 #define DECL_ISetCompressCodecsInfo
68 #define IMPL_ISetCompressCodecsInfo
69 #define EXTERNAL_CODECS_VARS2
70 #define DECL_EXTERNAL_CODECS_VARS
71 #define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2
72 #define DECL_EXTERNAL_CODECS_LOC_VARS2
73 #define EXTERNAL_CODECS_LOC_VARS2
74 #define DECL_EXTERNAL_CODECS_LOC_VARS
75 #define EXTERNAL_CODECS_LOC_VARS
76 
77 #endif
78 
79 bool FindMethod(
80   DECL_EXTERNAL_CODECS_LOC_VARS
81   const UString &name, CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams);
82 
83 bool FindMethod(
84   DECL_EXTERNAL_CODECS_LOC_VARS
85   CMethodId methodId, UString &name);
86 
87 bool FindHashMethod(
88   DECL_EXTERNAL_CODECS_LOC_VARS
89   const UString &name, CMethodId &methodId);
90 
91 void GetHashMethods(
92   DECL_EXTERNAL_CODECS_LOC_VARS
93   CRecordVector<CMethodId> &methods);
94 
95 HRESULT CreateCoder(
96   DECL_EXTERNAL_CODECS_LOC_VARS
97   CMethodId methodId,
98   CMyComPtr<ICompressFilter> &filter,
99   CMyComPtr<ICompressCoder> &coder,
100   CMyComPtr<ICompressCoder2> &coder2,
101   bool encode, bool onlyCoder);
102 
103 HRESULT CreateCoder(
104   DECL_EXTERNAL_CODECS_LOC_VARS
105   CMethodId methodId,
106   CMyComPtr<ICompressCoder> &coder,
107   CMyComPtr<ICompressCoder2> &coder2,
108   bool encode);
109 
110 HRESULT CreateCoder(
111   DECL_EXTERNAL_CODECS_LOC_VARS
112   CMethodId methodId,
113   CMyComPtr<ICompressCoder> &coder, bool encode);
114 
115 HRESULT CreateFilter(
116   DECL_EXTERNAL_CODECS_LOC_VARS
117   CMethodId methodId,
118   CMyComPtr<ICompressFilter> &filter,
119   bool encode);
120 
121 HRESULT CreateHasher(
122   DECL_EXTERNAL_CODECS_LOC_VARS
123   CMethodId methodId,
124   UString &name,
125   CMyComPtr<IHasher> &hacher);
126 
127 #endif
128