Add pgs color type setting
[xy_vsfilter.git] / include / realmedia / pncom.h
blob6e89ecc4676fe1f18ffd75e5ddc48525bff362ab
1 /****************************************************************************
2 *
3 * $Id: pncom.h 7 2003-05-30 02:18:02Z gabest $
5 * Copyright (C) 1995-1999 RealNetworks, Inc. All rights reserved.
6 *
7 * http://www.real.com/devzone
9 * This program contains proprietary
10 * information of Progressive Networks, Inc, and is licensed
11 * subject to restrictions on use and distribution.
14 * Component Object Model defines, and macros
16 * This file defines items required for COM interfaces in RealMedia and
17 * Progressive Networks SDKs.
22 #ifndef _PNCOM_H_
23 #define _PNCOM_H_
25 #include "pntypes.h" /* Needed for most type definitions */
26 #include "string.h"
28 // have to use the double expansion to get the prescan level
30 #define STATCONCAT1(w,x,y,z) STATCONCAT2(w,x,y,z)
31 #define STATCONCAT2(w,x,y,z) w##x##y##z
33 #ifdef _STATICALLY_LINKED
34 #ifndef _PLUGINNAME
35 #define ENTRYPOINT(func) STATCONCAT1(entrypoint_error_symbol_should_not_be_needed,_PLUGINNAME,_,func)
36 #else /* _PLUGINNAME */
37 #define ENTRYPOINT(func) STATCONCAT1(entrypoint_for_,_PLUGINNAME,_,func)
38 #endif
39 #else /* _STATICALLY_LINKED */
40 #define ENTRYPOINT(func) func
41 #endif
44 * We include objbase.h when building for windows so that pncom.h can
45 * easily be used in any windows code.
47 #ifdef _WIN32
48 #include <objbase.h>
49 #endif /* _WIN32 */
51 #include "pnresult.h"
54 * REF:
55 * Use this for reference parameters, so that C users can
56 * use the interface as well.
58 #if defined(__cplusplus)
59 #define REF(type) type&
60 #else
61 #define REF(type) const type * const
62 #endif
65 * CONSTMETHOD:
66 * Use this for constant methods in an interface
67 * Compiles away under C
69 #if !defined( CONSTMETHOD )
71 #if defined(__cplusplus)
72 #define CONSTMETHOD const
73 #else
74 #define CONSTMETHOD
75 #endif
77 #endif
79 * CALL:
81 * Used by C users to easily call a function through an interface
83 * EXAMPLE:
85 * pIFooObject->CALL(IFoo,DoSomething)(bar);
88 #if !defined(__cplusplus) || defined(CINTERFACE)
89 #define CALL(iface, func) iface##Vtbl->func
90 #endif
93 #define _INTERFACE struct
96 * If useing windows.h or the windows implementation of COM
97 * these defines are not needed.
99 #if !defined( _OBJBASE_H_ )
101 #ifdef _WIN16
102 typedef unsigned int MMRESULT;
103 #define FAR _far
104 #else
105 #define FAR
106 #endif /* WIN16 */
107 #define PASCAL _pascal
108 #define CDECL _cdecl
111 * EXTERN_C
113 #ifndef EXTERN_C
114 #ifdef __cplusplus
115 #define EXTERN_C extern "C"
116 #else
117 #define EXTERN_C extern
118 #endif
119 #endif
121 #ifdef OLDERRORCODES
122 #ifndef MAKE_HRESULT
123 #define MAKE_HRESULT(sev,fac,code) ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
124 #endif /*MAKE_HRESULT*/
125 #endif /* OLDERRORCODES */
128 * STDMETHODCALLTYPE
130 #ifndef STDMETHODCALLTYPE
131 #if defined(_WIN32) || defined(_MPPC_)
132 #ifdef _MPPC_
133 #define STDMETHODCALLTYPE __cdecl
134 #else
135 #define STDMETHODCALLTYPE __stdcall
136 #endif
137 #elif defined(_WIN16)
138 #define STDMETHODCALLTYPE __export FAR CDECL
139 #else
140 #define STDMETHODCALLTYPE
141 #endif
142 #endif
145 * STDMETHODVCALLTYPE
147 #ifndef STDMETHODVCALLTYPE
148 #if defined(_WINDOWS) || defined(_MPPC_)
149 #define STDMETHODVCALLTYPE __cdecl
150 #else
151 #define STDMETHODVCALLTYPE
152 #endif
153 #endif
156 * STDAPICALLTYPE
158 #ifndef STDAPICALLTYPE
159 #if defined(_WIN32) || defined(_MPPC_)
160 #define STDAPICALLTYPE __stdcall
161 #elif defined(_WIN16)
162 #define STDAPICALLTYPE __export FAR PASCAL
163 #else
164 #define STDAPICALLTYPE
165 #endif
166 #endif
169 * STDAPIVCALLTYPE
171 #ifndef STDAPIVCALLTYPE
172 #if defined(_WINDOWS) || defined(_MPPC_)
173 #define STDAPIVCALLTYPE __cdecl
174 #else
175 #define STDAPIVCALLTYPE
176 #endif
177 #endif
180 * Standard API defines:
182 * NOTE: the 'V' versions allow Variable Argument lists.
184 * STDAPI
185 * STDAPI_(type)
186 * STDAPIV
187 * STDAPIV_(type)
189 #ifndef STDAPI
190 #define STDAPI EXTERN_C PN_RESULT STDAPICALLTYPE
191 #endif
192 #ifndef STDAPI_
193 #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
194 #endif
195 #ifndef STDAPIV
196 #define STDAPIV EXTERN_C PN_RESULT STDAPIVCALLTYPE
197 #endif
198 #ifndef STDAPIV_
199 #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
200 #endif
204 * Standard Interface Method defines:
206 * NOTE: the 'V' versions allow Variable Argument lists.
208 * STDMETHODIMP
209 * STDMETHODIMP_(type)
210 * STDMETHODIMPV
211 * STDMETHODIMPV_(type)
213 #ifndef STDMETHODIMP
214 #define STDMETHODIMP PN_RESULT STDMETHODCALLTYPE
215 #endif
216 #ifndef STDMETHODIMP_
217 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
218 #endif
219 #ifndef STDMETHODIMPV
220 #define STDMETHODIMPV PN_RESULT STDMETHODVCALLTYPE
221 #endif
222 #ifndef STDMETHODIMPV_
223 #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
224 #endif
229 * Interface Declaration
231 * These are macros for declaring interfaces. They exist so that
232 * a single definition of the interface is simulataneously a proper
233 * declaration of the interface structures (C++ abstract classes)
234 * for both C and C++.
236 * DECLARE_INTERFACE(iface) is used to declare an interface that does
237 * not derive from a base interface.
238 * DECLARE_INTERFACE_(iface, baseiface) is used to declare an interface
239 * that does derive from a base interface.
241 * By default if the source file has a .c extension the C version of
242 * the interface declaratations will be expanded; if it has a .cpp
243 * extension the C++ version will be expanded. if you want to force
244 * the C version expansion even though the source file has a .cpp
245 * extension, then define the macro "CINTERFACE".
246 * eg. cl -DCINTERFACE file.cpp
248 * Example Interface declaration:
250 * #undef INTERFACE
251 * #define INTERFACE IClassFactory
253 * DECLARE_INTERFACE_(IClassFactory, IUnknown)
255 * // *** IUnknown methods
256 * STDMETHOD(QueryInterface) (THIS_
257 * REFIID riid,
258 * LPVOID FAR* ppvObj) PURE;
259 * STDMETHOD_(ULONG,AddRef) (THIS) PURE;
260 * STDMETHOD_(ULONG,Release) (THIS) PURE;
262 * // *** IClassFactory methods ***
263 * STDMETHOD(CreateInstance) (THIS_
264 * LPUNKNOWN pUnkOuter,
265 * REFIID riid,
266 * LPVOID FAR* ppvObject) PURE;
267 * };
269 * Example C++ expansion:
271 * struct FAR IClassFactory : public IUnknown
273 * virtual PN_RESULT STDMETHODCALLTYPE QueryInterface(
274 * IID FAR& riid,
275 * LPVOID FAR* ppvObj) = 0;
276 * virtual PN_RESULT STDMETHODCALLTYPE AddRef(void) = 0;
277 * virtual PN_RESULT STDMETHODCALLTYPE Release(void) = 0;
278 * virtual PN_RESULT STDMETHODCALLTYPE CreateInstance(
279 * LPUNKNOWN pUnkOuter,
280 * IID FAR& riid,
281 * LPVOID FAR* ppvObject) = 0;
282 * };
284 * NOTE: Our documentation says '#define interface class' but we use
285 * 'struct' instead of 'class' to keep a lot of 'public:' lines
286 * out of the interfaces. The 'FAR' forces the 'this' pointers to
287 * be far, which is what we need.
289 * Example C expansion:
291 * typedef struct IClassFactory
293 * const struct IClassFactoryVtbl FAR* lpVtbl;
294 * } IClassFactory;
296 * typedef struct IClassFactoryVtbl IClassFactoryVtbl;
298 * struct IClassFactoryVtbl
300 * PN_RESULT (STDMETHODCALLTYPE * QueryInterface) (
301 * IClassFactory FAR* This,
302 * IID FAR* riid,
303 * LPVOID FAR* ppvObj) ;
304 * PN_RESULT (STDMETHODCALLTYPE * AddRef) (IClassFactory FAR* This) ;
305 * PN_RESULT (STDMETHODCALLTYPE * Release) (IClassFactory FAR* This) ;
306 * PN_RESULT (STDMETHODCALLTYPE * CreateInstance) (
307 * IClassFactory FAR* This,
308 * LPUNKNOWN pUnkOuter,
309 * IID FAR* riid,
310 * LPVOID FAR* ppvObject);
311 * PN_RESULT (STDMETHODCALLTYPE * LockServer) (
312 * IClassFactory FAR* This,
313 * BOOL fLock);
314 * };
318 #if defined(__cplusplus) && !defined(CINTERFACE)
319 #define _INTERFACE struct
320 #define STDMETHOD(method) virtual PN_RESULT STDMETHODCALLTYPE method
321 #define STDMETHOD_(type,method) virtual type STDMETHODCALLTYPE method
322 #define PURE = 0
323 #define THIS_
324 #define THIS void
326 #if defined(_WINDOWS) && defined(EXPORT_CLASSES)
327 #define DECLARE_INTERFACE(iface) _INTERFACE PNEXPORT_CLASS iface
328 #define DECLARE_INTERFACE_(iface, baseiface) _INTERFACE PNEXPORT_CLASS iface : public baseiface
329 #else
330 #define DECLARE_INTERFACE(iface) _INTERFACE iface
331 #define DECLARE_INTERFACE_(iface, baseiface) _INTERFACE iface : public baseiface
332 #endif // defined(_WINDOWS) && defined(EXPORT_CLASSES)
334 #if !defined(BEGIN_INTERFACE)
335 #if defined(_MPPC_) && \
336 ( (defined(_MSC_VER) || defined(__SC__) || defined(__MWERKS__)) && \
337 !defined(NO_NULL_VTABLE_ENTRY) )
338 #define BEGIN_INTERFACE virtual void a() {}
339 #define END_INTERFACE
340 #else
341 #define BEGIN_INTERFACE
342 #define END_INTERFACE
343 #endif
344 #endif
347 #else
349 #define _INTERFACE struct
351 #define STDMETHOD(method) PN_RESULT (STDMETHODCALLTYPE * method)
352 #define STDMETHOD_(type,method) type (STDMETHODCALLTYPE * method)
354 #if !defined(BEGIN_INTERFACE)
355 #if defined(_MPPC_)
356 #define BEGIN_INTERFACE void *b;
357 #define END_INTERFACE
358 #else
359 #define BEGIN_INTERFACE
360 #define END_INTERFACE
361 #endif
362 #endif
365 #define PURE
366 #define THIS_ INTERFACE FAR* This,
367 #define THIS INTERFACE FAR* This
368 #ifdef CONST_VTABLE
369 #undef CONST_VTBL
370 #define CONST_VTBL const
371 #define DECLARE_INTERFACE(iface) typedef _INTERFACE iface { \
372 const struct iface##Vtbl FAR* lpVtbl; \
373 } iface; \
374 typedef const struct iface##Vtbl iface##Vtbl; \
375 const struct iface##Vtbl
376 #else
377 #undef CONST_VTBL
378 #define CONST_VTBL
379 #define DECLARE_INTERFACE(iface) typedef _INTERFACE iface { \
380 struct iface##Vtbl FAR* lpVtbl; \
381 } iface; \
382 typedef struct iface##Vtbl iface##Vtbl; \
383 struct iface##Vtbl
384 #endif
385 #define DECLARE_INTERFACE_(iface, baseiface) DECLARE_INTERFACE(iface)
387 #endif
390 * COMMON TYPES
393 #ifndef GUID_DEFINED
394 #define GUID_DEFINED
395 typedef struct _GUID
397 ULONG32 Data1;
398 UINT16 Data2;
399 UINT16 Data3;
400 UCHAR Data4[ 8 ];
401 } GUID;
403 #endif
405 #if !defined( __IID_DEFINED__ )
406 #define __IID_DEFINED__
407 typedef GUID IID;
408 #define IID_NULL GUID_NULL
409 typedef GUID CLSID;
410 #define CLSID_NULL GUID_NULL
412 #if defined(__cplusplus)
413 #ifndef _REFGUID_DEFINED
414 #define _REFGUID_DEFINED
415 #define REFGUID const GUID &
416 #endif
418 #ifndef _REFIID_DEFINED
419 #define _REFIID_DEFINED
420 #define REFIID const IID &
421 #endif
423 #ifndef _REFCLSID_DEFINED
424 #define _REFCLSID_DEFINED
425 #define REFCLSID const CLSID &
426 #endif
428 #else
429 #ifndef _REFGUID_DEFINED
430 #define _REFGUID_DEFINED
431 #define REFGUID const GUID * const
432 #endif
433 #ifndef _REFIID_DEFINED
434 #define _REFIID_DEFINED
435 #define REFIID const IID * const
436 #endif
437 #ifndef _REFCLSID_DEFINED
438 #define _REFCLSID_DEFINED
439 #define REFCLSID const CLSID * const
440 #endif
441 #endif
442 #endif
447 * macros to define byte pattern for a GUID.
448 * Example: DEFINE_GUID(GUID_XXX, a, b, c, ...);
450 * Each dll/exe must initialize the GUIDs once. This is done in one of
451 * two ways. If you are not using precompiled headers for the file(s) which
452 * initializes the GUIDs, define INITGUID before including objbase.h. This
453 * is how OLE builds the initialized versions of the GUIDs which are included
454 * in ole2.lib. The GUIDs in ole2.lib are all defined in the same text
455 * segment GUID_TEXT.
457 * The alternative (which some versions of the compiler don't handle properly;
458 * they wind up with the initialized GUIDs in a data, not a text segment),
459 * is to use a precompiled version of objbase.h and then include initguid.h
460 * after objbase.h followed by one or more of the guid defintion files.
464 #if !defined (INITGUID) || (defined (_STATICALLY_LINKED) && !defined(NCIHACK))
465 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
466 EXTERN_C const GUID FAR name
467 #else
469 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
470 EXTERN_C const GUID name \
471 = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
472 #endif
474 #ifndef _VXWORKS
475 #include <memory.h> /* for memcmp */
476 #endif
478 #ifdef __cplusplus
479 inline BOOL IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
481 return !memcmp(&rguid1, &rguid2, sizeof(GUID));
484 inline void SetGUID(GUID& rguid1, REFGUID rguid2)
486 memcpy(&rguid1, &rguid2, sizeof(GUID));
488 #else
489 #define IsEqualGUID(rguid1, rguid2) (!memcmp(rguid1, rguid2, sizeof(GUID)))
490 #define SetGUID(rguid1, rguid2) (memcpy(rguid1, rguid2, sizeof(GUID)))
491 #endif
493 #define IsEqualIID(riid1, riid2) IsEqualGUID(riid1, riid2)
494 #define IsEqualCLSID(rclsid1, rclsid2) IsEqualGUID(rclsid1, rclsid2)
496 #define SetIID(riid1, riid2) SetGUID(riid1, riid2)
497 #define SetCLSID(rclsid1, rclsid2) SetGUID(rclsid1, rclsid2)
499 #ifdef __cplusplus
502 * Because GUID is defined elsewhere in WIN32 land, the operator == and !=
503 * are moved outside the class to global scope.
506 inline BOOL operator==(const GUID& guidOne, const GUID& guidOther)
508 return !memcmp(&guidOne,&guidOther,sizeof(GUID));
511 inline BOOL operator!=(const GUID& guidOne, const GUID& guidOther)
513 return !(guidOne == guidOther);
516 #endif
519 /****************************************************************************
521 * Interface:
523 * IUnknown
525 * Purpose:
527 * Base class of all interfaces. Defines life time management and
528 * support for dynamic cast.
530 * IID_IUnknown:
532 * {00000000-0000-0000-C000000000000046}
535 DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00,
536 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
538 #undef INTERFACE
539 #define INTERFACE IUnknown
541 DECLARE_INTERFACE(IUnknown)
543 STDMETHOD(QueryInterface) (THIS_
544 REFIID riid,
545 void** ppvObj) PURE;
547 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
549 STDMETHOD_(ULONG,Release) (THIS) PURE;
553 /****************************************************************************
555 * Interface:
557 * IMalloc
559 * Purpose:
561 * Basic memory management interface.
563 * IID_IMalloc:
565 * {00000002-0000-0000-C000000000000046}
568 DEFINE_GUID(IID_IMalloc, 00000002, 0x0000, 0x0000, 0xC0, 0x00,
569 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
571 #undef INTERFACE
572 #define INTERFACE IMalloc
574 DECLARE_INTERFACE_(IMalloc, IUnknown)
577 * IUnknown methods
579 STDMETHOD(QueryInterface) (THIS_
580 REFIID riid,
581 void** ppvObj) PURE;
583 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
585 STDMETHOD_(ULONG,Release) (THIS) PURE;
588 * IMalloc methods
590 STDMETHOD_(void*,Alloc) (THIS_
591 UINT32 /*IN*/ count) PURE;
593 STDMETHOD_(void*,Realloc) (THIS_
594 void* /*IN*/ pMem,
595 UINT32 /*IN*/ count) PURE;
597 STDMETHOD_(void,Free) (THIS_
598 void* /*IN*/ pMem) PURE;
600 STDMETHOD_(UINT32,GetSize) (THIS_
601 void* /*IN*/ pMem) PURE;
603 STDMETHOD_(BOOL,DidAlloc) (THIS_
604 void* /*IN*/ pMem) PURE;
606 STDMETHOD_(void,HeapMinimize) (THIS) PURE;
611 * Synchronization: NOTE: These should be made thread safe or use built
612 * in synchronization support in an OS that supports it.
615 #define InterlockedIncrement(plong) (++(*(plong)))
616 #define InterlockedDecrement(plong) (--(*(plong)))
618 #else /* else case of !defined( _OBJBASE_H_ ) && !defined( _COMPOBJ_H_ ) */
621 /* Even in windows we want these GUID's defined... */
623 #if !(defined(INITGUID) && defined(USE_IUNKNOWN_AND_IMALLOC_FROM_UUID_LIB))
624 DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00,
625 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
627 DEFINE_GUID(IID_IMalloc, 00000002, 0x0000, 0x0000, 0xC0, 0x00,
628 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
629 #endif
631 #include <memory.h> /* for memcmp */
633 #ifdef __cplusplus
634 inline void SetGUID(REFGUID rguid1, REFGUID rguid2)
636 memcpy((void*)&rguid1, (void*)&rguid2, sizeof(GUID));
638 #else
639 #define SetGUID(rguid1, rguid2) (memcpy((void*)rguid1, (void*)rguid2, sizeof(GUID)))
640 #endif
641 #define SetIID(riid1, riid2) SetGUID(riid1, riid2)
642 #define SetCLSID(rclsid1, rclsid2) SetGUID(rclsid1, rclsid2)
644 #endif /* !defined( _OBJBASE_H_ ) && !defined( _COMPOBJ_H_ )*/
646 #ifdef IsEqualIID
647 #undef IsEqualIID
648 #endif
650 #ifdef IsEqualCLSID
651 #undef IsEqualCLSID
652 #endif
654 #define IsEqualIID(riid1, riid2) RNIsEqualGUID(riid1, riid2)
655 #define IsEqualCLSID(rclsid1, rclsid2) RNIsEqualGUID(rclsid1, rclsid2)
657 #ifdef __cplusplus
658 inline BOOL RNIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
660 return (((UINT32*) &rguid1)[0] == ((UINT32*) &rguid2)[0] &&
661 ((UINT32*) &rguid1)[1] == ((UINT32*) &rguid2)[1] &&
662 ((UINT32*) &rguid1)[2] == ((UINT32*) &rguid2)[2] &&
663 ((UINT32*) &rguid1)[3] == ((UINT32*) &rguid2)[3]);
665 #else
666 #define RNIsEqualGUID(rguid1, rguid2) \
667 (((UINT32*) &rguid1)[0] == ((UINT32*) &rguid2)[0] && \
668 ((UINT32*) &rguid1)[1] == ((UINT32*) &rguid2)[1] && \
669 ((UINT32*) &rguid1)[2] == ((UINT32*) &rguid2)[2] && \
670 ((UINT32*) &rguid1)[3] == ((UINT32*) &rguid2)[3]);
671 #endif
673 /****************************************************************************
675 * Putting the following macro in the definition of your class will overload
676 * new and delete for that object. New will then take an IMalloc* from
677 * which to allocate memory from and store it in the begining of the
678 * memory which it will return. Delete will grab this IMalloc* from
679 * the beginning of the mem and use this pointer to deallocate the mem.
681 * Example useage:
682 * class A
684 * public:
685 * A(int);
686 * ~A();
688 * IMALLOC_MEM
689 * };
691 * IMalloc* pMalloc;
692 * m_pContext->QueryInterface(IID_IMalloc, (void**)&pMalloc);
693 * A* p = new(pMalloc) A(0);
694 * pMalloc->Release();
695 * delete p;
698 #define IMALLOC_MEM\
699 void* operator new(size_t size, IMalloc* pMalloc)\
701 void* pMem = pMalloc->Alloc(size + sizeof(IMalloc*));\
702 *(IMalloc**)pMem = pMalloc;\
703 pMalloc->AddRef();\
704 return ((unsigned char*)pMem + sizeof(IMalloc*));\
707 void operator delete(void* pMem)\
709 pMem = (unsigned char*)pMem - sizeof(IMalloc*);\
710 IMalloc* pMalloc = *(IMalloc**)pMem;\
711 pMalloc->Free(pMem);\
712 pMalloc->Release();\
715 #endif /* _PNCOM_H_ */