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