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; IsSimpleCodecCCodecInfoEx22 bool IsSimpleCodec() const { return NumOutStreams == 1 && NumInStreams == 1; } CCodecInfoExCCodecInfoEx23 CCodecInfoEx(): EncoderIsAssigned(false), DecoderIsAssigned(false) {} 24 }; 25 26 HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodecInfoEx> &externalCodecs); 27 28 #define PUBLIC_ISetCompressCodecsInfo public ISetCompressCodecsInfo, 29 #define QUERY_ENTRY_ISetCompressCodecsInfo MY_QUERYINTERFACE_ENTRY(ISetCompressCodecsInfo) 30 #define DECL_ISetCompressCodecsInfo STDMETHOD(SetCompressCodecsInfo)(ICompressCodecsInfo *compressCodecsInfo); 31 #define IMPL_ISetCompressCodecsInfo2(x) \ 32 STDMETHODIMP x::SetCompressCodecsInfo(ICompressCodecsInfo *compressCodecsInfo) { \ 33 COM_TRY_BEGIN _codecsInfo = compressCodecsInfo; return LoadExternalCodecs(_codecsInfo, _externalCodecs); COM_TRY_END } 34 #define IMPL_ISetCompressCodecsInfo IMPL_ISetCompressCodecsInfo2(CHandler) 35 36 #define EXTERNAL_CODECS_VARS2 _codecsInfo, &_externalCodecs 37 38 #define DECL_EXTERNAL_CODECS_VARS CMyComPtr<ICompressCodecsInfo> _codecsInfo; CObjectVector<CCodecInfoEx> _externalCodecs; 39 #define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2, 40 41 #define DECL_EXTERNAL_CODECS_LOC_VARS2 ICompressCodecsInfo *codecsInfo, const CObjectVector<CCodecInfoEx> *externalCodecs 42 #define EXTERNAL_CODECS_LOC_VARS2 codecsInfo, externalCodecs 43 44 #define DECL_EXTERNAL_CODECS_LOC_VARS DECL_EXTERNAL_CODECS_LOC_VARS2, 45 #define EXTERNAL_CODECS_LOC_VARS EXTERNAL_CODECS_LOC_VARS2, 46 47 #else 48 49 #define PUBLIC_ISetCompressCodecsInfo 50 #define QUERY_ENTRY_ISetCompressCodecsInfo 51 #define DECL_ISetCompressCodecsInfo 52 #define IMPL_ISetCompressCodecsInfo 53 #define EXTERNAL_CODECS_VARS2 54 #define DECL_EXTERNAL_CODECS_VARS 55 #define EXTERNAL_CODECS_VARS EXTERNAL_CODECS_VARS2 56 #define DECL_EXTERNAL_CODECS_LOC_VARS2 57 #define EXTERNAL_CODECS_LOC_VARS2 58 #define DECL_EXTERNAL_CODECS_LOC_VARS 59 #define EXTERNAL_CODECS_LOC_VARS 60 61 #endif 62 63 bool FindMethod( 64 DECL_EXTERNAL_CODECS_LOC_VARS 65 const UString &name, CMethodId &methodId, UInt32 &numInStreams, UInt32 &numOutStreams); 66 67 bool FindMethod( 68 DECL_EXTERNAL_CODECS_LOC_VARS 69 CMethodId methodId, UString &name); 70 71 72 HRESULT CreateCoder( 73 DECL_EXTERNAL_CODECS_LOC_VARS 74 CMethodId methodId, 75 CMyComPtr<ICompressFilter> &filter, 76 CMyComPtr<ICompressCoder> &coder, 77 CMyComPtr<ICompressCoder2> &coder2, 78 bool encode, bool onlyCoder); 79 80 HRESULT CreateCoder( 81 DECL_EXTERNAL_CODECS_LOC_VARS 82 CMethodId methodId, 83 CMyComPtr<ICompressCoder> &coder, 84 CMyComPtr<ICompressCoder2> &coder2, 85 bool encode); 86 87 HRESULT CreateCoder( 88 DECL_EXTERNAL_CODECS_LOC_VARS 89 CMethodId methodId, 90 CMyComPtr<ICompressCoder> &coder, bool encode); 91 92 HRESULT CreateFilter( 93 DECL_EXTERNAL_CODECS_LOC_VARS 94 CMethodId methodId, 95 CMyComPtr<ICompressFilter> &filter, 96 bool encode); 97 98 #endif 99