OPAL  Version 3.12.5
opalplugin.h
Go to the documentation of this file.
1 /*
2  * opalplugins.h
3  *
4  * OPAL codec plugins handler
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (C) 2004-2011 Post Increment
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  *
15  * - Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17 
18  * - Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  *
22  * - Neither the name of the Xiph.org Foundation nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
30  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  * $Revision: 28932 $
39  * $Author: csoutheren $
40  * $Date: 2013-01-18 06:34:20 -0600 (Fri, 18 Jan 2013) $
41  */
42 
43 #ifndef OPAL_CODEC_OPALPLUGIN_H
44 #define OPAL_CODEC_OPALPLUGIN_H
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #ifndef _CRT_NONSTDC_NO_DEPRECATE
51 #define _CRT_NONSTDC_NO_DEPRECATE 1
52 #endif
53 
54 #ifndef _CRT_SECURE_NO_WARNINGS
55 #define _CRT_SECURE_NO_WARNINGS 1
56 #endif
57 
58 #include <time.h>
59 
60 #ifdef _MSC_VER
61 #pragma warning(disable:4201)
62 #endif
63 
64 #ifdef _MSC_VER
65 # ifdef PLUGIN_CODEC_DLL_EXPORTS
66 # define PLUGIN_CODEC_DLL_API __declspec(dllexport)
67 # else
68 # define PLUGIN_CODEC_DLL_API __declspec(dllimport)
69 # endif
70 
71 #if !defined(strcasecmp) && !defined(_WIN32_WCE)
72 #define strcasecmp stricmp
73 #endif
74 
75 #else
76 
77 #define PLUGIN_CODEC_DLL_API
78 
79 #endif
80 
81 #ifdef PWLIB_PLUGIN_API_VERSION
82 #undef PWLIB_PLUGIN_API_VERSION
83 #endif
84 #define PWLIB_PLUGIN_API_VERSION 1
85 
86 #define PLUGIN_CODEC_VERSION_FIRST 1 // initial version
87 #define PLUGIN_CODEC_VERSION_WIDEBAND 2 // added wideband
88 #define PLUGIN_CODEC_VERSION_VIDEO 3 // added video
89 #define PLUGIN_CODEC_VERSION_FAX 4 // added fax
90 #define PLUGIN_CODEC_VERSION_OPTIONS 5 // added options handling
91 #define PLUGIN_CODEC_VERSION_INTERSECT 6 // added media option intersection merge functionality
92 #define PLUGIN_CODEC_VERSION_H245_DEF_GEN_PARAM 7 // added suppression of H.245 generic parameters via default
93 
94 #define PLUGIN_CODEC_VERSION PLUGIN_CODEC_VERSION_H245_DEF_GEN_PARAM // Always latest version
95 
96 #define PLUGIN_CODEC_API_VER_FN PWLibPlugin_GetAPIVersion
97 #define PLUGIN_CODEC_API_VER_FN_STR "PWLibPlugin_GetAPIVersion"
98 
99 #define PLUGIN_CODEC_GET_CODEC_FN OpalCodecPlugin_GetCodecs
100 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
101 
102 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
103 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
104 { return PWLIB_PLUGIN_API_VERSION; }
105 
106 enum {
108  PluginCodec_Licence_None = PluginCodec_License_None, // allow for old code with misspelled constant
115 
117 
118  // any license codes above here require royalty payments
120 };
121 
123  // start of version 1 fields
125 
126  const char * sourceAuthor; // source code author
127  const char * sourceVersion; // source code version
128  const char * sourceEmail; // source code email contact information
129  const char * sourceURL; // source code web site
130  const char * sourceCopyright; // source code copyright
131  const char * sourceLicense; // source code license
132  unsigned char sourceLicenseCode; // source code license
133 
134  const char * codecDescription; // codec description
135  const char * codecAuthor; // codec author
136  const char * codecVersion; // codec version
137  const char * codecEmail; // codec email contact information
138  const char * codecURL; // codec web site
139  const char * codecCopyright; // codec copyright information
140  const char * codecLicense; // codec license
141  unsigned short codecLicenseCode; // codec license code
142  // end of version 1 fields
143 
144  const char * timestamp; // String form of timestamp for plug in, generally as provided by __TIMESTAMP__
145 };
146 
153 
155  PluginCodec_InputTypeRaw = 0x0000, // Note video is always RTP
157 
159  PluginCodec_OutputTypeRaw = 0x0000, // Note video is always RTP
161 
165 
169 
173 
177 
180 
181  PluginCodec_ComfortNoiseMask = 0x0800, // Audio only
183 
184  PluginCodec_ErrorConcealmentMask = 0x0800, // Video only
186 
189 
192 
195 
198 };
199 
200 #define PluginCodec_SetChannels(n) (((n-1)<<PluginCodec_ChannelsPos)&PluginCodec_ChannelsMask)
201 
202 
204  PluginCodec_CoderSilenceFrame = 1, // request audio codec to create silence frame
205  PluginCodec_CoderForceIFrame = 2, // request video codec to force I frame
206  PluginCodec_CoderPacketLoss = 4 // indicate to video codec packets were lost
207 };
208 
210  PluginCodec_ReturnCoderLastFrame = 1, // indicates when video codec returns last data for frame
211  PluginCodec_ReturnCoderIFrame = 2, // indicates when video returns I frame
212  PluginCodec_ReturnCoderRequestIFrame = 4, // indicates when video decoder request I frame for resync
213  PluginCodec_ReturnCoderBufferTooSmall = 8 // indicates when output buffer is not large enough to receive
214  // the data, another call to get_output_data_size is required
215 };
216 
218 
219 // Control function names
220 
221 #define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL "valid_for_protocol"
222 #define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS "get_codec_options"
223 #define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS "free_codec_options"
224 #define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE "get_output_data_size"
225 #define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS "set_codec_options"
226 #define PLUGINCODEC_CONTROL_GET_ACTIVE_OPTIONS "get_active_options"
227 #define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS "to_normalised_options"
228 #define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS "to_customised_options"
229 #define PLUGINCODEC_CONTROL_SET_INSTANCE_ID "set_instance_id"
230 #define PLUGINCODEC_CONTROL_SET_LOG_FUNCTION "set_log_function"
231 #define PLUGINCODEC_CONTROL_GET_STATISTICS "get_statistics"
232 #define PLUGINCODEC_CONTROL_TERMINATE_CODEC "terminate_codec"
233 
234 
235 /* Log function, plug in gets a pointer to this function which allows
236  it to use the standard OPAL logging system. The function returns 0 if
237  no logging was performed due to the log level. Note if log == NULL
238  then this return state is all that happens, so this may be executed
239  first to prevent lengthy logs that would not result in any output. */
240 typedef int (*PluginCodec_LogFunction)(unsigned level,
241  const char * file,
242  unsigned line,
243  const char * section,
244  const char * log);
245 
246 
248  const char * name;
249  int (*control)(const struct PluginCodec_Definition * codec, void * context,
250  const char * name, void * parm, unsigned * parmLen);
251 
252 };
253 
262 };
263 
273 
276 };
277 
278 #define PluginCodec_H245_Collapsing 0x40000000
279 #define PluginCodec_H245_NonCollapsing 0x20000000
280 #define PluginCodec_H245_Unsigned32 0x10000000
281 #define PluginCodec_H245_BooleanArray 0x08000000
282 #define PluginCodec_H245_TCS 0x04000000
283 #define PluginCodec_H245_OLC 0x02000000
284 #define PluginCodec_H245_ReqMode 0x01000000
285 #define PluginCodec_H245_OrdinalMask 0x0000ffff
286 #define PluginCodec_H245_PositionMask 0x00ff0000
287 #define PluginCodec_H245_PositionShift 16
288 
289 typedef int (*PluginCodec_MergeFunction)(char ** result, const char * dest, const char * src);
290 typedef void (*PluginCodec_FreeFunction)(char * string);
291 
293  // start of version 4 fields
295  const char * m_name;
296  unsigned m_readOnly;
298  const char * m_value;
299  const char * m_FMTPName;
300  const char * m_FMTPDefault;
302  const char * m_minimum;
303  const char * m_maximum;
304  PluginCodec_MergeFunction m_mergeFunction; // Used if m_merge==PluginCodec_CustomMerge
306  const char * m_H245Default;
307 };
308 
309 
310 // Normalised option names
311 #define PLUGINCODEC_OPTION_NEEDS_JITTER "Needs Jitter"
312 #define PLUGINCODEC_OPTION_CLOCK_RATE "Clock Rate"
313 #define PLUGINCODEC_OPTION_CHANNELS "Channels"
314 #define PLUGINCODEC_OPTION_FRAME_TIME "Frame Time"
315 #define PLUGINCODEC_OPTION_MAX_FRAME_SIZE "Max Frame Size"
316 #define PLUGINCODEC_OPTION_MAX_TX_PACKET_SIZE "Max Tx Packet Size" /* Really max PAYLOAD size */
317 #define PLUGINCODEC_OPTION_MAX_BIT_RATE "Max Bit Rate"
318 #define PLUGINCODEC_OPTION_TARGET_BIT_RATE "Target Bit Rate"
319 #define PLUGINCODEC_OPTION_RATE_CONTROL_PERIOD "Rate Control Period"
320 #define PLUGINCODEC_OPTION_RX_FRAMES_PER_PACKET "Rx Frames Per Packet"
321 #define PLUGINCODEC_OPTION_TX_FRAMES_PER_PACKET "Tx Frames Per Packet"
322 #define PLUGINCODEC_OPTION_FRAME_WIDTH "Frame Width"
323 #define PLUGINCODEC_OPTION_FRAME_HEIGHT "Frame Height"
324 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH "Min Rx Frame Width"
325 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT "Min Rx Frame Height"
326 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH "Max Rx Frame Width"
327 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT "Max Rx Frame Height"
328 #define PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF "Temporal Spatial Trade Off"
329 #define PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD "Tx Key Frame Period"
330 
331 #define PLUGINCODEC_OPTION_PROTOCOL "Protocol"
332 #define PLUGINCODEC_OPTION_PROTOCOL_H323 "H.323"
333 #define PLUGINCODEC_OPTION_PROTOCOL_SIP "SIP"
334 
335 
336 // Full definition of the codec
337 
339  unsigned int version; // codec structure version
340 
341  // start of version 1 fields
342  const struct PluginCodec_information * info; // license information
343 
344  unsigned int flags; // b0-3: 0 = audio, 1 = video
345  // b4: 0 = raw input, 1 = RTP input
346  // b5: 0 = raw output, 1 = RTP output
347  // b6: 0 = dynamic RTP, 1 = explicit RTP
348  // b7: 0 = no share RTP, 1 = share RTP
349 
350  const char * descr; // text decription
351 
352  const char * sourceFormat; // source format
353  const char * destFormat; // destination format
354 
355  const void * userData; // user data value
356 
357  unsigned int sampleRate; // samples per second
358  unsigned int bitsPerSec; // raw bits per second
359  unsigned int usPerFrame; // microseconds per frame
360 
361  union _parm {
362  struct _audio {
363  unsigned int samplesPerFrame; // audio: samples per frame
364  unsigned int bytesPerFrame; // audio: max bytes per frame
365  unsigned int recommendedFramesPerPacket; // audio: recommended number of frames per packet
366  unsigned int maxFramesPerPacket; // audio: maximum number of frames per packet
367  } audio;
368  struct _video {
369  unsigned int maxFrameWidth; // video: frame width
370  unsigned int maxFrameHeight; // video: frame height
371  unsigned int recommendedFrameRate; // video: recommended frame rate
372  unsigned int maxFrameRate; // video: max frame rate
373  } video;
374  } parm;
375 
376  unsigned char rtpPayload; // IANA RTP payload code (if defined)
377  const char * sdpFormat; // SDP format string (or NULL, if no SDP format)
378 
379  void * (*createCodec)(const struct PluginCodec_Definition * codec); // create codec
380  void (*destroyCodec) (const struct PluginCodec_Definition * codec, void * context); // destroy codec
381  int (*codecFunction) (const struct PluginCodec_Definition * codec, void * context, // do codec function
382  const void * from, unsigned * fromLen,
383  void * to, unsigned * toLen,
384  unsigned int * flag);
386 
387  // H323 specific fields
388  unsigned char h323CapabilityType;
389  const void * h323CapabilityData;
390 
391  // end of version 1 fields
392 
393  // NOTE!!!!! Due to an error in judgement, you cannot add ANY more fields
394  // to this structure without an API version change!!!!
395 };
396 
397 typedef const struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
398 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
399 
400 
402 
403 #define PLUGINCODEC_RAW_AUDIO "L16"
404 #define PLUGINCODEC_RAW_VIDEO "YUV420P"
405 #define PLUGINCODEC_VIDEO_CLOCK 90000
406 #define PLUGINCODEC_MAX_FRAME_RATE 30
407 
408 #define PLUGINCODEC_CIF_WIDTH 352
409 #define PLUGINCODEC_CIF_HEIGHT 288
410 
411 #define PLUGINCODEC_CIF4_WIDTH (PLUGINCODEC_CIF_WIDTH*2)
412 #define PLUGINCODEC_CIF4_HEIGHT (PLUGINCODEC_CIF_HEIGHT*2)
413 
414 #define PLUGINCODEC_CIF16_WIDTH (PLUGINCODEC_CIF_WIDTH*4)
415 #define PLUGINCODEC_CIF16_HEIGHT (PLUGINCODEC_CIF_HEIGHT*4)
416 
417 #define PLUGINCODEC_QCIF_WIDTH (PLUGINCODEC_CIF_WIDTH/2)
418 #define PLUGINCODEC_QCIF_HEIGHT (PLUGINCODEC_CIF_HEIGHT/2)
419 
420 #define PLUGINCODEC_QCIF4_WIDTH (PLUGINCODEC_CIF4_WIDTH/2)
421 #define PLUGINCODEC_QCIF4_HEIGHT (PLUGINCODEC_CIF4_HEIGHT/2)
422 
423 #define PLUGINCODEC_SQCIF_WIDTH 128
424 #define PLUGINCODEC_SQCIF_HEIGHT 96
425 
426 
427 #ifndef __TIMESTAMP__
428 #define __TIMESTAMP__ "0"
429 #endif
430 
431 #define PLUGINCODEC_LICENSE(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15) \
432  static struct PluginCodec_information MyLicenseInfo = { 0,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,__TIMESTAMP__ }
433 
434 
436 #define PLUGINCODEC_CODEC_PAIR(MediaFormat, \
437  PayloadName, \
438  Description, \
439  SampleRate, \
440  BitsPerSecond, \
441  FrameTime, \
442  p1,p2,p3,p4, \
443  PayloadType, \
444  H323type, \
445  H323data, \
446  CreateEncoder, \
447  DestroyEncoder, \
448  EncodeMedia, \
449  CreateDecoder, \
450  DestroyDecoder, \
451  DecodeMedia, \
452  ControlsTable, \
453  Flags, \
454  RawFormat, \
455  UserData \
456  ) \
457  { \
458  PLUGIN_CODEC_VERSION, &MyLicenseInfo, Flags, Description, RawFormat, MediaFormat, UserData, \
459  SampleRate, BitsPerSecond, FrameTime, {{ p1,p2,p3,p4 }}, PayloadType, PayloadName, \
460  CreateEncoder, DestroyEncoder, EncodeMedia, ControlsTable, H323type, H323data \
461  }, \
462  { \
463  PLUGIN_CODEC_VERSION, &MyLicenseInfo, Flags, Description, MediaFormat, RawFormat, UserData, \
464  SampleRate, BitsPerSecond, FrameTime, {{ p1,p2,p3,p4 }}, PayloadType, PayloadName, \
465  CreateDecoder, DestroyDecoder, DecodeMedia, ControlsTable, H323type, H323data \
466  }
467 
468 #define PLUGINCODEC_AUDIO_CODEC(MediaFormat, \
469  PayloadName, \
470  Description, \
471  SampleRate, \
472  BitsPerSecond, \
473  SamplesPerFrame, \
474  RecFramesPerPacket, \
475  MaxFramesPerPacket, \
476  RtpFlags, \
477  PayloadType, \
478  H323type, \
479  H323data, \
480  CreateEncoder, \
481  DestroyEncoder, \
482  EncodeAudio, \
483  CreateDecoder, \
484  DestroyDecoder, \
485  DecodeAudio, \
486  ControlsTable \
487  ) \
488  PLUGINCODEC_CODEC_PAIR(MediaFormat, \
489  PayloadName, \
490  Description, \
491  SampleRate, \
492  BitsPerSecond, \
493  (SamplesPerFrame)*1000000/(SampleRate), \
494  SamplesPerFrame, \
495  (BitsPerSecond)*(SampleRate)/(SamplesPerFrame)/8, \
496  RecFramesPerPacket, \
497  MaxFramesPerPacket, \
498  PayloadType, \
499  H323type, \
500  H323data, \
501  CreateEncoder, \
502  DestroyEncoder, \
503  EncodeAudio, \
504  CreateDecoder, \
505  DestroyDecoder, \
506  DecodeAudio, \
507  ControlsTable, \
508  PluginCodec_MediaTypeAudio | /* audio codec */ \
509  PluginCodec_InputTypeRaw | /* raw input data */ \
510  PluginCodec_OutputTypeRaw | /* raw output data */ \
511  (RtpFlags), \
512  PLUGINCODEC_RAW_AUDIO, \
513  NULL)
514 
515 #define PLUGINCODEC_ONE_AUDIO_CODEC(MediaFormat, \
516  PayloadName, \
517  Description, \
518  SampleRate, \
519  BitsPerSecond, \
520  SamplesPerFrame, \
521  RecFramesPerPacket, \
522  MaxFramesPerPacket, \
523  RtpFlags, \
524  PayloadType, \
525  H323type, \
526  H323data \
527  ) \
528  static struct PluginCodec_Definition CodecDefinitionTable[] = { \
529  PLUGINCODEC_AUDIO_CODEC(MediaFormat, \
530  PayloadName, \
531  Description, \
532  SampleRate, \
533  BitsPerSecond, \
534  SamplesPerFrame, \
535  RecFramesPerPacket, \
536  MaxFramesPerPacket, \
537  RtpFlags, \
538  PayloadType, \
539  H323type, \
540  H323data, \
541  MyCreateEncoder, \
542  MyDestroyEncoder, \
543  MyEncodeAudio, \
544  MyCreateDecoder, \
545  MyDestroyDecoder, \
546  MyDecodeAudio, \
547  MyControlsTable \
548  ) \
549  }
550 
551 #define PLUGINCODEC_VIDEO_CODEC(MediaFormat, \
552  PayloadName, \
553  Description, \
554  BitsPerSecond, \
555  MaxWidth, \
556  MaxHeight, \
557  RtpFlags, \
558  PayloadType, \
559  H323type, \
560  H323data, \
561  CreateEncoder, \
562  DestroyEncoder, \
563  EncodeVideo, \
564  CreateDecoder, \
565  DestroyDecoder, \
566  DecodeVideo, \
567  ControlsTable \
568  ) \
569  PLUGINCODEC_CODEC_PAIR(MediaFormat, \
570  PayloadName, \
571  Description, \
572  SampleRate, \
573  BitsPerSecond, \
574  PLUGINCODEC_VIDEO_CLOCK, \
575  BitsPerSecond, \
576  1000000/PLUGINCODEC_MAX_FRAME_RATE, \
577  MaxWidth, \
578  MaxHeight, \
579  0,PLUGINCODEC_MAX_FRAME_RATE, \
580  PayloadType, \
581  H323type, \
582  H323data, \
583  CreateEncoder, \
584  DestroyEncoder, \
585  EncodeVideo, \
586  CreateDecoder, \
587  DestroyDecoder, \
588  DecodeVideo, \
589  ControlsTable, \
590  PluginCodec_MediaTypeVideo | /* video codec */ \
591  PluginCodec_InputTypeRTP | /* RTP input data */ \
592  PluginCodec_OutputTypeRTP | /* RTP output data */ \
593  (RtpFlags), \
594  PLUGINCODEC_RAW_VIDEO, \
595  NULL)
596 
597 #define PLUGINCODEC_ONE_VIDEO_CODEC(MediaFormat, \
598  PayloadName, \
599  Description, \
600  BitsPerSecond, \
601  MaxWidth, \
602  MaxHeight, \
603  RtpFlags, \
604  PayloadType, \
605  H323type, \
606  H323data \
607  ) \
608  static struct PluginCodec_Definition CodecDefinitionTable[] = { \
609  PLUGINCODEC_VIDEO_CODEC(MediaFormat, \
610  PayloadName, \
611  Description, \
612  BitsPerSecond, \
613  MaxWidth, \
614  MaxHeight, \
615  RtpFlags, \
616  PayloadType, \
617  H323type, \
618  H323data, \
619  CreateEncoder, \
620  DestroyEncoder, \
621  EncodeAudio, \
622  CreateDecoder, \
623  DestroyDecoder, \
624  DecodeAudio, \
625  ControlsTable \
626  ) \
627  }
628 
629 
631 //
632 // H.323 specific values
633 //
634 
635 
637  unsigned int index;
638  void * data;
639  unsigned dataLength;
640 };
641 
643  const char * objectId;
644  unsigned char t35CountryCode;
645  unsigned char t35Extension;
646  unsigned short manufacturerCode;
647  const unsigned char * data;
648  unsigned int dataLength;
650 };
651 
652 
654 {
655  /* The following used to be a simple integer for the collapsing flag in
656  version 3 and earlier. We hope that all those implementations just used
657  zero and one (a good bet) and thus the below bit fields will be backward
658  compatible, putting the parameter in all three PDU types.
659  */
660 #ifndef SOLARIS
661  struct {
662 #endif
663  int collapsing:1; /* boolean */
664  int excludeTCS:1;
665  int excludeOLC:1;
666  int excludeReqMode:1;
667  int readOnly:1;
668 #ifndef SOLARIS
669  };
670 #endif
672  unsigned int id;
673 
675  /* these need to be in the same order as the choices in
676  H245_ParameterValue::Choices, as the value is just cast to that type
677  */
686 
695  } type;
697  union {
698  unsigned long integer;
699  const char * octetstring;
701  } value;
702 };
703 
705 {
706  // some cunning structures & lists, and associated logic in
707  // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
708  const char * standardIdentifier;
709  unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
711  /* parameters; these are the parameters which are set in the
712  'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
713  unsigned int nParameters;
714  /* an array of nParameters parameter definitions */
716 };
718 
721  int scrambled:1;
722 };
725  unsigned char maxAl_sduAudioFrames;
727  int highRateMode0:6; // INTEGER (27..78), -- units octets
728  int highRateMode1:6; // INTEGER (27..78), -- units octets
729  int lowRateMode0:6; // INTEGER (23..66), -- units octets
730  int lowRateMode1:6; // INTEGER (23..66), -- units octets
731  int sidMode0:4; // INTEGER (6..17), -- units octets
732  int sidMode1:4; // INTEGER (6..17), -- units octets
733 };
734 
735 
736 enum {
737  PluginCodec_H323Codec_undefined, // must be zero, so empty struct is undefined
738  PluginCodec_H323Codec_programmed, // H323ProgrammedCapability
739  PluginCodec_H323Codec_nonStandard, // H323NonStandardData
740  PluginCodec_H323Codec_generic, // H323GenericCodecData
742  // audio codecs
750  PluginCodec_H323AudioCodec_g7231, // H323AudioG7231Data
754  PluginCodec_H323AudioCodec_is11172, // not yet implemented
755  PluginCodec_H323AudioCodec_is13818Audio, // not yet implemented
758  PluginCodec_H323AudioCodec_g7231AnnexC, // H323AudioG7231AnnexC
764  // video codecs
765  PluginCodec_H323VideoCodec_h261, // implemented
766  PluginCodec_H323VideoCodec_h262, // not yet implemented
767  PluginCodec_H323VideoCodec_h263, // implemented
768  PluginCodec_H323VideoCodec_is11172, // not yet implemented
770  // other capabilities
771  PluginCodec_H323VideoCodec_Extended, // implemented (for use with H.239)
772  PluginCodec_H323T38Codec, // not yet implemented
773 
774  // special codes
775  PluginCodec_H323Codec_NoH323 = 0xff, // used for SIP-only codecs
776 };
779 //
780 // Generic Codec Standard Identifiers
781 //
783 // Audio Capabilities
784 // AMR (as defined in H.245v13 Annex I)
785 #define OpalPluginCodec_Identifer_AMR "0.0.8.245.1.1.1"
787 // AMR-NB\WB (as defined in H.245v13 Annex R)
788 #define OpalPluginCodec_Identifer_AMR_NB "0.0.8.245.1.1.9"
789 #define OpalPluginCodec_Identifer_AMR_WB "0.0.8.245.1.1.10"
791 // G.722.1
792 #define OpalPluginCodec_Identifer_G7221 "0.0.7.7221.1.0"
793 #define OpalPluginCodec_Identifer_G7221ext "0.0.7.7221.1.1.0"
795 // G.722.2 (aka AMR-WB)
796 #define OpalPluginCodec_Identifer_G7222 "0.0.7.7222.1.0"
798 // iLBC (as defined in H.245v13 Annex S)
799 #define OpalPluginCodec_Identifer_iLBC "0.0.8.245.1.1.11"
801 
802 // Video Capabilities
804 // H264 (as defined in H.241)
805 #define OpalPluginCodec_Identifer_H264_Aligned "0.0.8.241.0.0.0.0"
806 #define OpalPluginCodec_Identifer_H264_NonInterleaved "0.0.8.241.0.0.0.1"
807 #define OpalPluginCodec_Identifer_H264_Interleaved "0.0.8.241.0.0.0.2"
808 #define OpalPluginCodec_Identifer_H264_Generic "0.0.8.241.0.0.1"
809 
810 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
811 #define OpalPluginCodec_Identifer_MPEG4 "0.0.8.245.1.0.0"
812 
813 
815 //
816 // Predefined options for H.323 codecs
817 //
818 
819 #define PLUGINCODEC_SQCIF_MPI "SQCIF MPI"
820 #define PLUGINCODEC_QCIF_MPI "QCIF MPI"
821 #define PLUGINCODEC_CIF_MPI "CIF MPI"
822 #define PLUGINCODEC_CIF4_MPI "CIF4 MPI"
823 #define PLUGINCODEC_CIF16_MPI "CIF16 MPI"
824 #define PLUGINCODEC_CUSTOM_MPI "Custom MPI"
826 #define PLUGINCODEC_MPI_DISABLED 33
827 
828 #define PLUGINCODEC_MEDIA_PACKETIZATION "Media Packetization"
829 #define PLUGINCODEC_MEDIA_PACKETIZATIONS "Media Packetizations"
830 
831 #define H261_ANNEX_D "Annex D - Still Image Transmit"
832 #define H263_ANNEX_D "Annex D - Unrestricted Motion Vector"
833 #define H263_ANNEX_F "Annex F - Advanced Prediction"
834 #define H263_ANNEX_I "Annex I - Advanced INTRA Coding"
835 #define H263_ANNEX_J "Annex J - Deblocking Filter"
836 #define H263_ANNEX_K "Annex K - Slice Structure"
837 #define H263_ANNEX_N "Annex N - Reference Picture Selection"
838 #define H263_ANNEX_S "Annex S - Alternative INTER VLC"
839 #define H263_ANNEX_T "Annex T - Modified Quantization"
841 #ifndef STRINGIZE
842 #define __INTERNAL_STRINGIZE__(v) #v
843 #define STRINGIZE(v) __INTERNAL_STRINGIZE__(v)
844 #endif
845 
846 
848 //
849 // RTP specific definitions
850 //
852 #define PluginCodec_RTP_MaxPacketSize (1518-14-4-8-20-16) // Max Ethernet packet (1518 bytes) minus 802.3/CRC, 802.3, IP, UDP headers
853 #define PluginCodec_RTP_MinHeaderSize (12)
854 #define PluginCodec_RTP_MaxPayloadSize (PluginCodec_RTP_MaxPacketSize - PluginCodec_RTP_MinHeaderSize)
856 #define PluginCodec_RTP_GetWORD(ptr, off) ((((unsigned char*)(ptr))[off] << 8) | ((unsigned char*)(ptr))[off+1])
857 
858 #define PluginCodec_RTP_GetDWORD(ptr, off) ((((unsigned char*)(ptr))[off ] << 24)|\
859  (((unsigned char*)(ptr))[off+1] << 16)|\
860  (((unsigned char*)(ptr))[off+2] << 8 )|\
861  ((unsigned char*)(ptr))[off+3])
862 
863 #define PluginCodec_RTP_SetWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 8 )),\
864  (((unsigned char*)(ptr))[off+1] = (unsigned char) (val) ))
866 #define PluginCodec_RTP_SetDWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 24)),\
867  (((unsigned char*)(ptr))[off+1] = (unsigned char)((val) >> 16)),\
868  (((unsigned char*)(ptr))[off+2] = (unsigned char)((val) >> 8 )),\
869  (((unsigned char*)(ptr))[off+3] = (unsigned char) (val) ))
871 #define PluginCodec_RTP_GetCSRCHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x0f)*4 + PluginCodec_RTP_MinHeaderSize)
872 #define PluginCodec_RTP_GetExtHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x10) ? (PluginCodec_RTP_GetWORD(ptr, PluginCodec_RTP_GetCSRCHdrLength(ptr)+2)*4+4) : 0)
873 
874 #define PluginCodec_RTP_GetHeaderLength(ptr) (PluginCodec_RTP_GetCSRCHdrLength(ptr) + PluginCodec_RTP_GetExtHdrLength(ptr))
875 #define PluginCodec_RTP_GetPayloadPtr(ptr) ((unsigned char*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
876 #define PluginCodec_RTP_GetPayloadType(ptr) (((unsigned char*)(ptr))[1] & 0x7f)
877 #define PluginCodec_RTP_SetPayloadType(ptr, type) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x80) | (type & 0x7f)))
878 #define PluginCodec_RTP_GetMarker(ptr) ((((unsigned char*)(ptr))[1] & 0x80) != 0)
879 #define PluginCodec_RTP_SetMarker(ptr, mark) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0)))
880 #define PluginCodec_RTP_GetTimestamp(ptr) PluginCodec_RTP_GetDWORD(ptr, 4)
881 #define PluginCodec_RTP_SetTimestamp(ptr, ts) PluginCodec_RTP_SetDWORD(ptr, 4, ts)
882 #define PluginCodec_RTP_GetSequenceNumber(ptr) PluginCodec_RTP_GetWORD(ptr, 2)
883 #define PluginCodec_RTP_SetSequenceNumber(ptr, sn) PluginCodec_RTP_SetWORD(ptr, 2, sn)
884 #define PluginCodec_RTP_GetSSRC(ptr) PluginCodec_RTP_GetDWORD(ptr, 8)
885 #define PluginCodec_RTP_SetSSRC(ptr, ssrc) PluginCodec_RTP_SetDWORD(ptr, 8, ssrc)
887 
890 //
891 // video specific definitions
892 //
893 
895  unsigned int x;
896  unsigned int y;
897  unsigned int width;
898  unsigned int height;
899 };
900 
901 #ifdef __cplusplus
902 };
904 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
905 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
907 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
908 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
910 extern "C" {
911 #endif
915 //
916 // experimental definitions for statically linking codecs
917 //
918 
919 #ifdef OPAL_STATIC_CODEC
920 
921 # undef PLUGIN_CODEC_DLL_API
922 # define PLUGIN_CODEC_DLL_API static
923 # define PLUGIN_CODEC_IMPLEMENT(name) \
924 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
925 { return PWLIB_PLUGIN_API_VERSION; } \
926 static const struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
927 struct const PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
928 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
930 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
931 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
932 { return PWLIB_PLUGIN_API_VERSION; } \
933 PLUGIN_CODEC_DLL_API const struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * count, unsigned version) \
934 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
935 
936 
937 #else
938 
939 # define PLUGIN_CODEC_IMPLEMENT(name) \
940 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
941 { return PWLIB_PLUGIN_API_VERSION; } \
942 
943 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
944 PLUGIN_CODEC_IMPLEMENT(name) \
945 PLUGIN_CODEC_DLL_API const struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
946 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
947 
948 
949 #endif
950 
951 #ifdef __cplusplus
952 };
953 #endif
954 
955 
956 #ifdef _MSC_VER
957 #pragma warning(default:4201)
958 #endif
959 
960 #endif // OPAL_CODEC_OPALPLUGIN_H