Fixed numerous spelling errors.
[opal.git] / include / codec / opalplugin.h
blobcf90459e1d9143a0cf0119a7488cb074aaa4a1d0
1 /*
2 * opalplugins.h
4 * OPAL codec plugins handler
6 * Open Phone Abstraction Library (OPAL)
7 * Formally known as the Open H323 project.
9 * Copyright (C) 2004-2006 Post Increment
11 * The contents of this file are subject to the Mozilla Public License
12 * Version 1.0 (the "License"); you may not use this file except in
13 * compliance with the License. You may obtain a copy of the License at
14 * http://www.mozilla.org/MPL/
16 * Software distributed under the License is distributed on an "AS IS"
17 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18 * the License for the specific language governing rights and limitations
19 * under the License.
21 * The Original Code is Open Phone Abstraction Library.
23 * The Initial Developer of the Original Code is Post Increment
25 * Contributor(s): ______________________________________.
27 * $Log$
28 * Revision 2.12 2007/08/10 09:04:57 rjongbloed
29 * Fixed numerous spelling errors.
30 * Added extra symbols for backward compatibility.
31 * Removed unused (and commented out) code.
33 * Revision 2.11 2007/06/27 12:29:45 rjongbloed
34 * Add new OpalMediaOption for octet strings (simple block of bytes).
36 * Revision 2.10 2007/06/22 17:58:30 csoutheren
37 * Added explicit names to union in plugin defn for gcc
39 * Revision 2.9 2007/06/22 05:41:47 rjongbloed
40 * Major codec API update:
41 * Automatically map OpalMediaOptions to SIP/SDP FMTP parameters.
42 * Automatically map OpalMediaOptions to H.245 Generic Capability parameters.
43 * Largely removed need to distinguish between SIP and H.323 codecs.
44 * New mechanism for setting OpalMediaOptions from within a plug in.
46 * Revision 2.8 2007/05/15 09:39:37 rjongbloed
47 * Fixed various OIDs for H.245 generic capabilities.
48 * Added G.722.2 OID for H.245 generic capabilities.
49 * Changed the H.323 capability "extra info" pointer to be const.
51 * Revision 2.7 2007/03/12 23:17:04 csoutheren
52 * Add new code plugins types (backport from OpenH323)
54 * Revision 2.6 2006/11/01 06:57:23 csoutheren
55 * Fixed usage of YUV frame header
57 * Revision 2.5 2006/10/17 13:04:36 shorne
58 * comments were accidently truncated
60 * Revision 2.4 2006/10/17 04:09:08 shorne
61 * Corrected generic parameter identifiers & added generic codec identifiers
63 * Revision 2.3 2006/10/02 13:30:50 rjongbloed
64 * Added LID plug ins
66 * Revision 2.2 2006/08/11 07:52:00 csoutheren
67 * Fix problem with media format factory in VC 2005
68 * Fixing problems with Speex codec
69 * Remove non-portable usages of PFactory code
71 * Revision 2.1 2006/07/24 14:03:38 csoutheren
72 * Merged in audio and video plugins from CVS branch PluginBranch
74 * Revision 1.1.2.4 2006/04/24 09:09:37 csoutheren
75 * Added LGPL license
77 * Revision 1.1.2.3 2006/04/19 07:52:30 csoutheren
78 * Add ability to have SIP-only and H.323-only codecs, and implement for H.261
80 * Revision 1.1.2.2 2006/04/06 01:21:16 csoutheren
81 * More implementation of video codec plugins
83 * Revision 1.1.2.1 2006/03/16 07:06:00 csoutheren
84 * Initial support for audio plugins
86 * Revision 1.9 2005/11/21 21:04:10 shorne
87 * Added more HID input switches
89 * Revision 1.8 2005/08/23 08:13:06 shorne
90 * Added HID plugin volume & LCD display support
92 * Revision 1.7 2005/07/03 13:54:23 shorne
93 * Added Initial LID Plugin Support
95 * Revision 1.6 2005/06/07 03:22:22 csoutheren
96 * Added patch 1198741 with support for plugin codecs with generic capabilities
97 * Added patch 1198754 with support for setting quality level on audio codecs
98 * Added patch 1198760 with GSM-AMR codec support
99 * Many thanks to Richard van der Hoff for his work
101 * Revision 1.5 2004/12/20 23:30:20 csoutheren
102 * Added plugin support for packet loss concealment frames
104 * Revision 1.4 2004/11/29 06:30:53 csoutheren
105 * Added support for wideband codecs
107 * Revision 1.3 2004/05/18 22:26:28 csoutheren
108 * Initial support for embedded codecs
109 * Fixed problems with streamed codec support
110 * Updates for abstract factory loading methods
112 * Revision 1.2 2004/05/09 14:44:36 csoutheren
113 * Added support for streamed plugin audio codecs
115 * Revision 1.1 2004/04/09 12:25:25 csoutheren
116 * Renamed from h323plugin.h
118 * Revision 1.2 2004/04/03 10:38:24 csoutheren
119 * Added in initial cut at codec plugin code. Branches are for wimps :)
121 * Revision 1.1.2.1 2004/03/31 11:03:16 csoutheren
122 * Initial public version
124 * Revision 1.8 2004/02/23 13:17:32 craigs
125 * Fixed problems with codec interface functions
127 * Revision 1.7 2004/02/23 13:04:09 craigs
128 * Removed warnings when compliing plugins
130 * Revision 1.6 2004/01/27 14:55:46 craigs
131 * Implemented static linking of new codecs
133 * Revision 1.5 2004/01/23 05:21:15 craigs
134 * Updated for changes to the codec plugin interface
136 * Revision 1.4 2004/01/09 11:27:46 craigs
137 * Plugin codec audio now works :)
139 * Revision 1.3 2004/01/09 07:32:22 craigs
140 * More fixes for capability problems
142 * Revision 1.2 2004/01/06 07:05:03 craigs
143 * Changed to support plugin codecs
145 * Revision 1.1 2004/01/04 13:37:51 craigs
146 * Implementation of codec plugins
151 #ifndef __OPAL_CODECPLUGIN_H
152 #define __OPAL_CODECPLUGIN_H
154 #ifdef __cplusplus
155 extern "C" {
156 #endif
158 #include <time.h>
160 #ifdef _MSC_VER
161 #pragma warning(disable:4201)
162 #endif
164 #ifdef _WIN32
165 # ifdef PLUGIN_CODEC_DLL_EXPORTS
166 # define PLUGIN_CODEC_DLL_API __declspec(dllexport)
167 # else
168 # define PLUGIN_CODEC_DLL_API __declspec(dllimport)
169 # endif
171 #else
173 #define PLUGIN_CODEC_DLL_API
175 #endif
177 #define PWLIB_PLUGIN_API_VERSION 0
179 #define PLUGIN_CODEC_VERSION 1 // initial version
180 #define PLUGIN_CODEC_VERSION_WIDEBAND 2 // added wideband
181 #define PLUGIN_CODEC_VERSION_VIDEO 3 // added video
182 #define PLUGIN_CODEC_VERSION_FAX 4 // added fax
183 #define PLUGIN_CODEC_VERSION_OPTIONS 5 // added options handling
185 #define PLUGIN_CODEC_API_VER_FN PWLibPlugin_GetAPIVersion
186 #define PLUGIN_CODEC_API_VER_FN_STR "PWLibPlugin_GetAPIVersion"
188 #define PLUGIN_CODEC_GET_CODEC_FN OpalCodecPlugin_GetCodecs
189 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
191 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
192 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
193 { return PWLIB_PLUGIN_API_VERSION; }
195 enum {
196 PluginCodec_License_None = 0,
197 PluginCodec_Licence_None = PluginCodec_License_None, // allow for old code with misspelled constant
198 PluginCodec_License_GPL = 1,
199 PluginCodec_License_MPL = 2,
200 PluginCodec_License_Freeware = 3,
201 PluginCodec_License_ResearchAndDevelopmentUseOnly = 4,
202 PluginCodec_License_BSD = 5,
203 PluginCodec_License_LGPL = 6,
205 PluginCodec_License_NoRoyalties = 0x7f,
207 // any license codes above here require royalty payments
208 PluginCodec_License_RoyaltiesRequired = 0x80
211 struct PluginCodec_information {
212 // start of version 1 fields
213 time_t timestamp; // codec creation time and date - obtain with command: date -u "+%c = %s"
215 const char * sourceAuthor; // source code author
216 const char * sourceVersion; // source code version
217 const char * sourceEmail; // source code email contact information
218 const char * sourceURL; // source code web site
219 const char * sourceCopyright; // source code copyright
220 const char * sourceLicense; // source code license
221 unsigned char sourceLicenseCode; // source code license
223 const char * codecDescription; // codec description
224 const char * codecAuthor; // codec author
225 const char * codecVersion; // codec version
226 const char * codecEmail; // codec email contact information
227 const char * codecURL; // codec web site
228 const char * codecCopyright; // codec copyright information
229 const char * codecLicense; // codec license
230 unsigned short codecLicenseCode; // codec license code
231 // end of version 1 fields
235 enum PluginCodec_Flags {
236 PluginCodec_MediaTypeMask = 0x000f,
237 PluginCodec_MediaTypeAudio = 0x0000,
238 PluginCodec_MediaTypeVideo = 0x0001,
239 PluginCodec_MediaTypeAudioStreamed = 0x0002,
240 PluginCodec_MediaTypeFax = 0x0003,
241 PluginCodec_MediaTypeExtVideo = 0x0004,
243 PluginCodec_InputTypeMask = 0x0010,
244 PluginCodec_InputTypeRaw = 0x0000,
245 PluginCodec_InputTypeRTP = 0x0010,
247 PluginCodec_OutputTypeMask = 0x0020,
248 PluginCodec_OutputTypeRaw = 0x0000,
249 PluginCodec_OutputTypeRTP = 0x0020,
251 PluginCodec_RTPTypeMask = 0x0040,
252 PluginCodec_RTPTypeDynamic = 0x0000,
253 PluginCodec_RTPTypeExplicit = 0x0040,
255 PluginCodec_RTPSharedMask = 0x0080,
256 PluginCodec_RTPTypeNotShared = 0x0000,
257 PluginCodec_RTPTypeShared = 0x0080,
259 PluginCodec_DecodeSilenceMask = 0x0100,
260 PluginCodec_NoDecodeSilence = 0x0000,
261 PluginCodec_DecodeSilence = 0x0100,
263 PluginCodec_EncodeSilenceMask = 0x0200,
264 PluginCodec_NoEncodeSilence = 0x0000,
265 PluginCodec_EncodeSilence = 0x0200,
267 PluginCodec_BitsPerSamplePos = 12,
268 PluginCodec_BitsPerSampleMask = 0xf000,
271 enum PluginCodec_CoderFlags {
272 PluginCodec_CoderSilenceFrame = 1, // request audio codec to create silence frame
273 PluginCodec_CoderForceIFrame = 2 // request video codec to force I frame
276 enum PluginCodec_ReturnCoderFlags {
277 PluginCodec_ReturnCoderLastFrame = 1, // indicates when video codec returns last data for frame
278 PluginCodec_ReturnCoderIFrame = 2, // indicates when video returns I frame
279 PluginCodec_ReturnCoderRequestIFrame = 4 // indicates when video decoder request I frame for resync
282 struct PluginCodec_Definition;
284 struct PluginCodec_ControlDefn {
285 const char * name;
286 int (*control)(const struct PluginCodec_Definition * codec, void * context,
287 const char * name, void * parm, unsigned * parmLen);
291 enum PluginCodec_OptionTypes {
292 PluginCodec_StringOption,
293 PluginCodec_BoolOption,
294 PluginCodec_IntegerOption,
295 PluginCodec_RealOption,
296 PluginCodec_EnumOption,
297 PluginCodec_OctetsOption,
298 PluginCodec_NumOptionTypes,
301 enum PluginCodec_OptionMerge {
302 PluginCodec_NoMerge,
303 PluginCodec_MinMerge,
304 PluginCodec_MaxMerge,
305 PluginCodec_EqualMerge,
306 PluginCodec_NotEqualMerge,
307 PluginCodec_AlwaysMerge,
308 PluginCodec_NumOptionMerge,
310 PluginCodec_AndMerge = PluginCodec_MaxMerge,
311 PluginCodec_OrMerge = PluginCodec_MinMerge,
312 PluginCodec_XorMerge = PluginCodec_NotEqualMerge,
313 PluginCodec_NotXorMerge = PluginCodec_EqualMerge
316 #define PluginCodec_H245_Collapsing 0x40000000
317 #define PluginCodec_H245_NonCollapsing 0x20000000
318 #define PluginCodec_H245_Unsigned32 0x10000000
319 #define PluginCodec_H245_BooleanArray 0x08000000
320 #define PluginCodec_H245_TCS 0x04000000
321 #define PluginCodec_H245_OLC 0x02000000
322 #define PluginCodec_H245_ReqMode 0x01000000
323 #define PluginCodec_H245_OrdinalMask 0x0000ffff
325 struct PluginCodec_Option {
326 // start of version 4 fields
327 enum PluginCodec_OptionTypes m_type;
328 const char * m_name;
329 unsigned m_readOnly;
330 enum PluginCodec_OptionMerge m_merge;
331 const char * m_value;
332 const char * m_FMTPName;
333 const char * m_FMTPDefault;
334 int m_H245Generic;
335 const char * m_minimum;
336 const char * m_maximum;
340 struct PluginCodec_Definition {
341 unsigned int version; // codec structure version
343 // start of version 1 fields
344 struct PluginCodec_information * info; // license information
346 unsigned int flags; // b0-3: 0 = audio, 1 = video
347 // b4: 0 = raw input, 1 = RTP input
348 // b5: 0 = raw output, 1 = RTP output
349 // b6: 0 = dynamic RTP, 1 = explicit RTP
350 // b7: 0 = no share RTP, 1 = share RTP
352 const char * descr; // text decription
354 const char * sourceFormat; // source format
355 const char * destFormat; // destination format
357 const void * userData; // user data value
359 unsigned int sampleRate; // samples per second
360 unsigned int bitsPerSec; // raw bits per second
361 unsigned int usPerFrame; // microseconds per frame
363 union _parm {
364 struct _audio {
365 unsigned int samplesPerFrame; // audio: samples per frame
366 unsigned int bytesPerFrame; // audio: max bytes per frame
367 unsigned int recommendedFramesPerPacket; // audio: recommended number of frames per packet
368 unsigned int maxFramesPerPacket; // audio: maximum number of frames per packet
369 } audio;
370 struct _video {
371 unsigned int maxFrameWidth; // video: frame width
372 unsigned int maxFrameHeight; // video: frame height
373 unsigned int recommendedFrameRate; // video: recommended frame rate
374 unsigned int maxFrameRate; // video: max frame rate
375 } video;
376 } parm;
378 unsigned char rtpPayload; // IANA RTP payload code (if defined)
379 const char * sdpFormat; // SDP format string (or NULL, if no SDP format)
381 void * (*createCodec)(const struct PluginCodec_Definition * codec); // create codec
382 void (*destroyCodec) (const struct PluginCodec_Definition * codec, void * context); // destroy codec
383 int (*codecFunction) (const struct PluginCodec_Definition * codec, void * context, // do codec function
384 const void * from, unsigned * fromLen,
385 void * to, unsigned * toLen,
386 unsigned int * flag);
387 struct PluginCodec_ControlDefn * codecControls;
389 // H323 specific fields
390 unsigned char h323CapabilityType;
391 const void * h323CapabilityData;
393 // end of version 1 fields
395 // NOTE!!!!! Due to an error in judgement, you cannot add ANY more fields
396 // to this structure without an API version change!!!!
399 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
400 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
402 ///////////////////////////////////////////////////////////////////
404 // H.323 specific values
408 struct PluginCodec_H323CapabilityExtension {
409 unsigned int index;
410 void * data;
411 unsigned dataLength;
414 struct PluginCodec_H323NonStandardCodecData {
415 const char * objectId;
416 unsigned char t35CountryCode;
417 unsigned char t35Extension;
418 unsigned short manufacturerCode;
419 const unsigned char * data;
420 unsigned int dataLength;
421 int (*capabilityMatchFunction)(struct PluginCodec_H323NonStandardCodecData *);
425 struct PluginCodec_H323GenericParameterDefinition
427 /* The following used to be a simple integer for the collapsing flag in
428 version 3 and earlier. We hope that all those implementations just used
429 zero and one (a good bet) and thus the below bit fields will be backward
430 compatible, putting the parameter in all three PDU types.
432 struct {
433 int collapsing:1; /* boolean */
434 int excludeTCS:1;
435 int excludeOLC:1;
436 int excludeReqMode:1;
437 int readOnly:1;
440 unsigned int id;
442 enum PluginCodec_H323GenericParameterType {
443 /* these need to be in the same order as the choices in
444 H245_ParameterValue::Choices, as the value is just cast to that type
446 PluginCodec_GenericParameter_Logical = 0,
447 PluginCodec_GenericParameter_BooleanArray,
448 PluginCodec_GenericParameter_UnsignedMin,
449 PluginCodec_GenericParameter_UnsignedMax,
450 PluginCodec_GenericParameter_Unsigned32Min,
451 PluginCodec_GenericParameter_Unsigned32Max,
452 PluginCodec_GenericParameter_OctetString,
453 PluginCodec_GenericParameter_GenericParameter,
455 PluginCodec_GenericParameter_logical = 0,
456 PluginCodec_GenericParameter_booleanArray,
457 PluginCodec_GenericParameter_unsignedMin,
458 PluginCodec_GenericParameter_unsignedMax,
459 PluginCodec_GenericParameter_unsigned32Min,
460 PluginCodec_GenericParameter_unsigned32Max,
461 PluginCodec_GenericParameter_octetString,
462 PluginCodec_GenericParameter_genericParameter
463 } type;
465 union {
466 unsigned long integer;
467 const char * octetstring;
468 struct PluginCodec_H323GenericParameterDefinition *genericparameter;
469 } value;
472 struct PluginCodec_H323GenericCodecData
474 // some cunning structures & lists, and associated logic in
475 // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
476 const char * standardIdentifier;
477 unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
479 /* parameters; these are the parameters which are set in the
480 'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
481 unsigned int nParameters;
482 /* an array of nParameters parameter definitions */
483 const struct PluginCodec_H323GenericParameterDefinition *params;
487 struct PluginCodec_H323AudioGSMData {
488 int comfortNoise:1;
489 int scrambled:1;
492 struct PluginCodec_H323AudioG7231AnnexC {
493 unsigned char maxAl_sduAudioFrames;
494 int silenceSuppression:1;
495 int highRateMode0:6; // INTEGER (27..78), -- units octets
496 int highRateMode1:6; // INTEGER (27..78), -- units octets
497 int lowRateMode0:6; // INTEGER (23..66), -- units octets
498 int lowRateMode1:6; // INTEGER (23..66), -- units octets
499 int sidMode0:4; // INTEGER (6..17), -- units octets
500 int sidMode1:4; // INTEGER (6..17), -- units octets
504 enum {
505 PluginCodec_H323Codec_undefined, // must be zero, so empty struct is undefined
506 PluginCodec_H323Codec_programmed, // H323ProgrammedCapability
507 PluginCodec_H323Codec_nonStandard, // H323NonStandardData
508 PluginCodec_H323Codec_generic, // H323GenericCodecData
510 // audio codecs
511 PluginCodec_H323AudioCodec_g711Alaw_64k, // int
512 PluginCodec_H323AudioCodec_g711Alaw_56k, // int
513 PluginCodec_H323AudioCodec_g711Ulaw_64k, // int
514 PluginCodec_H323AudioCodec_g711Ulaw_56k, // int
515 PluginCodec_H323AudioCodec_g722_64k, // int
516 PluginCodec_H323AudioCodec_g722_56k, // int
517 PluginCodec_H323AudioCodec_g722_48k, // int
518 PluginCodec_H323AudioCodec_g7231, // H323AudioG7231Data
519 PluginCodec_H323AudioCodec_g728, // int
520 PluginCodec_H323AudioCodec_g729, // int
521 PluginCodec_H323AudioCodec_g729AnnexA, // int
522 PluginCodec_H323AudioCodec_is11172, // not yet implemented
523 PluginCodec_H323AudioCodec_is13818Audio, // not yet implemented
524 PluginCodec_H323AudioCodec_g729wAnnexB, // int
525 PluginCodec_H323AudioCodec_g729AnnexAwAnnexB, // int
526 PluginCodec_H323AudioCodec_g7231AnnexC, // H323AudioG7231AnnexC
527 PluginCodec_H323AudioCodec_gsmFullRate, // H323AudioGSMData
528 PluginCodec_H323AudioCodec_gsmHalfRate, // H323AudioGSMData
529 PluginCodec_H323AudioCodec_gsmEnhancedFullRate, // H323AudioGSMData
530 PluginCodec_H323AudioCodec_g729Extensions, // not yet implemented
532 // video codecs
533 PluginCodec_H323VideoCodec_h261, // implemented
534 PluginCodec_H323VideoCodec_h262, // not yet implemented
535 PluginCodec_H323VideoCodec_h263, // implemented
536 PluginCodec_H323VideoCodec_is11172, // not yet implemented
538 // other capabilities
539 PluginCodec_H323VideoCodec_Extended, // implemented (for use with H.239)
540 PluginCodec_H323T38Codec, // not yet implemented
542 // special codes
543 PluginCodec_H323Codec_NoH323 = 0xff, // used for SIP-only codecs
546 /////////////////
548 // Generic Codec Standard Identifiers
551 // Audio Capabilities
552 // AMR (as defined in H.245v13 Annex I)
553 #define OpalPluginCodec_Identifer_AMR "0.0.8.245.1.1.1"
555 // AMR-NB\WB (as defined in H.245v13 Annex R)
556 #define OpalPluginCodec_Identifer_AMR_NB "0.0.8.245.1.1.9"
557 #define OpalPluginCodec_Identifer_AMR_WB "0.0.8.245.1.1.10"
559 // G.722.2 (aka AMR-WB)
560 #define OpalPluginCodec_Identifer_G7222 "0.0.7.7222.1.0"
562 // iLBC (as defined in H.245v13 Annex S)
563 #define OpalPluginCodec_Identifer_iLBC "0.0.8.245.1.1.11"
566 // Video Capabilities
568 // H264 (as defined in H.241)
569 #define OpalPluginCodec_Identifer_H264 "0.0.8.241.0.0.0.0"
570 #define OpalPluginCodec_Identifer_H264_RFC3984 "0.0.8.241.0.0.0.1"
571 #define OpalPluginCodec_Identifer_H264_RFC3984Int "0.0.8.241.0.0.0.2"
572 #define OpalPluginCodec_Identifer_H264_Generic "0.0.8.241.0.0.1"
574 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
575 #define OpalPluginCodec_Identifer_MPEG4 "0.0.8.245.1.0.0"
578 /////////////////
580 // RTP specific definitions
583 #define PluginCodec_RTP_GetHeaderLength(ptr) ((((BYTE*)(ptr))[0] & 0x0f)*4 + 12)
584 #define PluginCodec_RTP_GetPayloadPtr(ptr) ((BYTE*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
585 #define PluginCodec_RTP_GetPayloadType(ptr) (((BYTE*)(ptr))[1] & 0x7f)
586 #define PluginCodec_RTP_SetPayloadType(ptr, type) (((BYTE*)(ptr))[1] = (((BYTE*)(ptr))[1] & 0x80) | (type & 0x7f))
587 #define PluginCodec_RTP_GetMarker(ptr) ((((BYTE*)(ptr))[1] & 0x80) != 0)
588 #define PluginCodec_RTP_SetMarker(ptr, mark) (((BYTE*)(ptr))[1] = (((BYTE*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0))
589 #define PluginCodec_RTP_GetTimestamp(ptr) ((((BYTE*)(ptr))[4] << 24) | (((BYTE*)(ptr))[5] << 16) | (((BYTE*)(ptr))[6] << 8) | ((BYTE*)(ptr))[7])
590 #define PluginCodec_RTP_SetTimestamp(ptr, ts) ((((BYTE*)(ptr))[4] = ((ts) >> 24)),(((BYTE*)(ptr))[5] = ((ts) >> 16)),(((BYTE*)(ptr))[6] = ((ts) >> 8)),(((BYTE*)(ptr))[7] = (ts)))
593 /////////////////
595 // video specific definitions
598 struct PluginCodec_Video_FrameHeader {
599 unsigned int x;
600 unsigned int y;
601 unsigned int width;
602 unsigned int height;
605 #ifdef __cplusplus
608 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
609 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
611 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
612 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
614 extern "C" {
615 #endif
617 #define PLUGIN_CODEC_VIDEO_SET_FRAME_SIZE_FN "set_frame_size" // argument is struct PluginCodec_VideoSetFrameInfo
618 struct PluginCodec_Video_SetFrameInfo {
619 int width;
620 int height;
624 /////////////////
626 // experimental definitions for statically linking codecs
629 #ifdef OPAL_STATIC_CODEC
631 # undef PLUGIN_CODEC_DLL_API
632 # define PLUGIN_CODEC_DLL_API static
633 # define PLUGIN_CODEC_IMPLEMENT(name) \
634 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
635 { return PWLIB_PLUGIN_API_VERSION; } \
636 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
637 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
638 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
640 #else
642 # define PLUGIN_CODEC_IMPLEMENT(name) \
643 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
644 { return PWLIB_PLUGIN_API_VERSION; } \
646 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
647 PLUGIN_CODEC_IMPLEMENT(name) \
648 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
649 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
652 #endif
654 #ifdef __cplusplus
656 #endif
659 #ifdef _MSC_VER
660 #pragma warning(default:4201)
661 #endif
663 #endif // __OPAL_CODECPLUGIN_H