OPAL  Version 3.10.4
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: 26796 $
35  * $Author: rjongbloed $
36  * $Date: 2011-12-13 03:26:25 -0600 (Tue, 13 Dec 2011) $
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 
89 #define PLUGIN_CODEC_VERSION PLUGIN_CODEC_VERSION_INTERSECT // Always latest version
90 
91 #define PLUGIN_CODEC_API_VER_FN PWLibPlugin_GetAPIVersion
92 #define PLUGIN_CODEC_API_VER_FN_STR "PWLibPlugin_GetAPIVersion"
93 
94 #define PLUGIN_CODEC_GET_CODEC_FN OpalCodecPlugin_GetCodecs
95 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
96 
97 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
98 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
99 { return PWLIB_PLUGIN_API_VERSION; }
100 
101 enum {
103  PluginCodec_Licence_None = PluginCodec_License_None, // allow for old code with misspelled constant
110 
112 
113  // any license codes above here require royalty payments
115 };
116 
118  // start of version 1 fields
119  time_t timestamp; // codec creation time and date - obtain with command: date -u "+%c = %s"
120 
121  const char * sourceAuthor; // source code author
122  const char * sourceVersion; // source code version
123  const char * sourceEmail; // source code email contact information
124  const char * sourceURL; // source code web site
125  const char * sourceCopyright; // source code copyright
126  const char * sourceLicense; // source code license
127  unsigned char sourceLicenseCode; // source code license
128 
129  const char * codecDescription; // codec description
130  const char * codecAuthor; // codec author
131  const char * codecVersion; // codec version
132  const char * codecEmail; // codec email contact information
133  const char * codecURL; // codec web site
134  const char * codecCopyright; // codec copyright information
135  const char * codecLicense; // codec license
136  unsigned short codecLicenseCode; // codec license code
137  // end of version 1 fields
138 
139 };
140 
147 
149  PluginCodec_InputTypeRaw = 0x0000, // Note video is always RTP
151 
153  PluginCodec_OutputTypeRaw = 0x0000, // Note video is always RTP
155 
159 
163 
167 
171 
174 
177 
180 
183 
186 
189 };
190 
191 #define PluginCodec_SetChannels(n) (((n-1)<<PluginCodec_ChannelsPos)&PluginCodec_ChannelsMask)
192 
193 
195  PluginCodec_CoderSilenceFrame = 1, // request audio codec to create silence frame
196  PluginCodec_CoderForceIFrame = 2 // request video codec to force I frame
197 };
198 
200  PluginCodec_ReturnCoderLastFrame = 1, // indicates when video codec returns last data for frame
201  PluginCodec_ReturnCoderIFrame = 2, // indicates when video returns I frame
202  PluginCodec_ReturnCoderRequestIFrame = 4, // indicates when video decoder request I frame for resync
203  PluginCodec_ReturnCoderBufferTooSmall = 8 // indicates when output buffer is not large enough to receive
204  // the data, another call to get_output_data_size is required
205 };
206 
208 
209 // Control function names
210 
211 #define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL "valid_for_protocol"
212 #define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS "get_codec_options"
213 #define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS "free_codec_options"
214 #define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE "get_output_data_size"
215 #define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS "set_codec_options"
216 #define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS "to_normalised_options"
217 #define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS "to_customised_options"
218 #define PLUGINCODEC_CONTROL_SET_INSTANCE_ID "set_instance_id"
219 #define PLUGINCODEC_CONTROL_SET_LOG_FUNCTION "set_log_function"
220 #define PLUGINCODEC_CONTROL_GET_STATISTICS "get_statistics"
221 #define PLUGINCODEC_CONTROL_TERMINATE_CODEC "terminate_codec"
222 
223 
224 /* Log function, plug in gets a pointer to this function which allows
225  it to use the standard OPAL logging system. The function returns 0 if
226  no logging was performed due to the log level. Note if log == NULL
227  then this return state is all that happens, so this may be executed
228  first to prevent lengthy logs that would not result in any output. */
229 typedef int (*PluginCodec_LogFunction)(unsigned level,
230  const char * file,
231  unsigned line,
232  const char * section,
233  const char * log);
234 
235 
237  const char * name;
238  int (*control)(const struct PluginCodec_Definition * codec, void * context,
239  const char * name, void * parm, unsigned * parmLen);
240 
241 };
242 
251 };
252 
262 
265 };
266 
267 #define PluginCodec_H245_Collapsing 0x40000000
268 #define PluginCodec_H245_NonCollapsing 0x20000000
269 #define PluginCodec_H245_Unsigned32 0x10000000
270 #define PluginCodec_H245_BooleanArray 0x08000000
271 #define PluginCodec_H245_TCS 0x04000000
272 #define PluginCodec_H245_OLC 0x02000000
273 #define PluginCodec_H245_ReqMode 0x01000000
274 #define PluginCodec_H245_OrdinalMask 0x0000ffff
275 
276 typedef int (*PluginCodec_MergeFunction)(char ** result, const char * dest, const char * src);
277 typedef void (*PluginCodec_FreeFunction)(char * string);
278 
280  // start of version 4 fields
282  const char * m_name;
283  unsigned m_readOnly;
285  const char * m_value;
286  const char * m_FMTPName;
287  const char * m_FMTPDefault;
289  const char * m_minimum;
290  const char * m_maximum;
291  PluginCodec_MergeFunction m_mergeFunction; // Used if m_merge==PluginCodec_CustomMerge
293 };
294 
295 
296 // Normalised option names
297 #define PLUGINCODEC_OPTION_NEEDS_JITTER "Needs Jitter"
298 #define PLUGINCODEC_OPTION_CLOCK_RATE "Clock Rate"
299 #define PLUGINCODEC_OPTION_CHANNELS "Channels"
300 #define PLUGINCODEC_OPTION_FRAME_TIME "Frame Time"
301 #define PLUGINCODEC_OPTION_MAX_FRAME_SIZE "Max Frame Size"
302 #define PLUGINCODEC_OPTION_MAX_TX_PACKET_SIZE "Max Tx Packet Size"
303 #define PLUGINCODEC_OPTION_MAX_BIT_RATE "Max Bit Rate"
304 #define PLUGINCODEC_OPTION_TARGET_BIT_RATE "Target Bit Rate"
305 #define PLUGINCODEC_OPTION_RX_FRAMES_PER_PACKET "Rx Frames Per Packet"
306 #define PLUGINCODEC_OPTION_TX_FRAMES_PER_PACKET "Tx Frames Per Packet"
307 #define PLUGINCODEC_OPTION_FRAME_WIDTH "Frame Width"
308 #define PLUGINCODEC_OPTION_FRAME_HEIGHT "Frame Height"
309 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH "Min Rx Frame Width"
310 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT "Min Rx Frame Height"
311 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH "Max Rx Frame Width"
312 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT "Max Rx Frame Height"
313 #define PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF "Temporal Spatial Trade Off"
314 #define PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD "Tx Key Frame Period"
315 
316 
317 
318 // Full definition of the codec
319 
321  unsigned int version; // codec structure version
322 
323  // start of version 1 fields
324  struct PluginCodec_information * info; // license information
325 
326  unsigned int flags; // b0-3: 0 = audio, 1 = video
327  // b4: 0 = raw input, 1 = RTP input
328  // b5: 0 = raw output, 1 = RTP output
329  // b6: 0 = dynamic RTP, 1 = explicit RTP
330  // b7: 0 = no share RTP, 1 = share RTP
331 
332  const char * descr; // text decription
333 
334  const char * sourceFormat; // source format
335  const char * destFormat; // destination format
336 
337  const void * userData; // user data value
338 
339  unsigned int sampleRate; // samples per second
340  unsigned int bitsPerSec; // raw bits per second
341  unsigned int usPerFrame; // microseconds per frame
342 
343  union _parm {
344  struct _audio {
345  unsigned int samplesPerFrame; // audio: samples per frame
346  unsigned int bytesPerFrame; // audio: max bytes per frame
347  unsigned int recommendedFramesPerPacket; // audio: recommended number of frames per packet
348  unsigned int maxFramesPerPacket; // audio: maximum number of frames per packet
349  } audio;
350  struct _video {
351  unsigned int maxFrameWidth; // video: frame width
352  unsigned int maxFrameHeight; // video: frame height
353  unsigned int recommendedFrameRate; // video: recommended frame rate
354  unsigned int maxFrameRate; // video: max frame rate
355  } video;
356  } parm;
357 
358  unsigned char rtpPayload; // IANA RTP payload code (if defined)
359  const char * sdpFormat; // SDP format string (or NULL, if no SDP format)
360 
361  void * (*createCodec)(const struct PluginCodec_Definition * codec); // create codec
362  void (*destroyCodec) (const struct PluginCodec_Definition * codec, void * context); // destroy codec
363  int (*codecFunction) (const struct PluginCodec_Definition * codec, void * context, // do codec function
364  const void * from, unsigned * fromLen,
365  void * to, unsigned * toLen,
366  unsigned int * flag);
368 
369  // H323 specific fields
370  unsigned char h323CapabilityType;
371  const void * h323CapabilityData;
372 
373  // end of version 1 fields
374 
375  // NOTE!!!!! Due to an error in judgement, you cannot add ANY more fields
376  // to this structure without an API version change!!!!
377 };
378 
379 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
380 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
381 
382 
384 
385 #define PLUGINCODEC_RAW_AUDIO "L16"
386 #define PLUGINCODEC_RAW_VIDEO "YUV420P"
387 
389 #define PLUGINCODEC_CODEC_PAIR(MediaFormat, \
390  PayloadName, \
391  Description, \
392  SampleRate, \
393  BitsPerSecond, \
394  FrameTime, \
395  p1,p2,p3,p4, \
396  PayloadType, \
397  H323type, \
398  H323data, \
399  CreateEncoder, \
400  DestroyEncoder, \
401  EncodeMedia, \
402  CreateDecoder, \
403  DestroyDecoder, \
404  DecodeMedia, \
405  ControlsTable, \
406  Flags, \
407  RawFormat \
408  ) \
409  { \
410  PLUGIN_CODEC_VERSION, &MyLicenseInfo, Flags, Description, RawFormat, MediaFormat, NULL, \
411  SampleRate, BitsPerSecond, FrameTime, {{ p1,p2,p3,p4 }}, PayloadType, PayloadName, \
412  CreateEncoder, DestroyEncoder, EncodeMedia, ControlsTable, H323type, H323data \
413  }, \
414  { \
415  PLUGIN_CODEC_VERSION, &MyLicenseInfo, Flags, Description, MediaFormat, RawFormat, NULL, \
416  SampleRate, BitsPerSecond, FrameTime, {{ p1,p2,p3,p4 }}, PayloadType, PayloadName, \
417  CreateDecoder, DestroyDecoder, DecodeMedia, ControlsTable, H323type, H323data \
418  }
419 
420 #define PLUGINCODEC_AUDIO_CODEC(MediaFormat, \
421  PayloadName, \
422  Description, \
423  SampleRate, \
424  BitsPerSecond, \
425  FrameTime, \
426  SamplesPerFrame, \
427  BytesPerFrame, \
428  RecFramesPerPacket, \
429  MaxFramesPerPacket, \
430  RtpFlags, \
431  PayloadType, \
432  H323type, \
433  H323data, \
434  CreateEncoder, \
435  DestroyEncoder, \
436  EncodeAudio, \
437  CreateDecoder, \
438  DestroyDecoder, \
439  DecodeAudio, \
440  ControlsTable \
441  ) \
442  PLUGINCODEC_CODEC_PAIR(MediaFormat, \
443  PayloadName, \
444  Description, \
445  SampleRate, \
446  BitsPerSecond, \
447  FrameTime, \
448  SamplesPerFrame, \
449  BytesPerFrame, \
450  RecFramesPerPacket, \
451  MaxFramesPerPacket, \
452  PayloadType, \
453  H323type, \
454  H323data, \
455  CreateEncoder, \
456  DestroyEncoder, \
457  EncodeAudio, \
458  CreateDecoder, \
459  DestroyDecoder, \
460  DecodeAudio, \
461  ControlsTable, \
462  PluginCodec_MediaTypeAudio | /* audio codec */ \
463  PluginCodec_InputTypeRaw | /* raw input data */ \
464  PluginCodec_OutputTypeRaw | /* raw output data */ \
465  (RtpFlags), \
466  PLUGINCODEC_RAW_AUDIO)
467 
468 #define PLUGINCODEC_ONE_AUDIO_CODEC(MediaFormat, \
469  PayloadName, \
470  Description, \
471  SampleRate, \
472  BitsPerSecond, \
473  FrameTime, \
474  SamplesPerFrame, \
475  BytesPerFrame, \
476  RecFramesPerPacket, \
477  MaxFramesPerPacket, \
478  RtpFlags, \
479  PayloadType, \
480  H323type, \
481  H323data \
482  ) \
483  static struct PluginCodec_Definition CodecDefinitionTable[] = { \
484  PLUGINCODEC_AUDIO_CODEC(MediaFormat, \
485  PayloadName, \
486  Description, \
487  SampleRate, \
488  BitsPerSecond, \
489  FrameTime, \
490  SamplesPerFrame, \
491  BytesPerFrame, \
492  RecFramesPerPacket, \
493  MaxFramesPerPacket, \
494  RtpFlags, \
495  PayloadType, \
496  H323type, \
497  H323data, \
498  MyCreateEncoder, \
499  MyDestroyEncoder, \
500  MyEncodeAudio, \
501  MyCreateDecoder, \
502  MyDestroyDecoder, \
503  MyDecodeAudio, \
504  MyControlsTable \
505  ) \
506  }
507 
508 #define PLUGINCODEC_VIDEO_CODEC(MediaFormat, \
509  PayloadName, \
510  Description, \
511  BitsPerSecond, \
512  MaxWidth, \
513  MaxHeight, \
514  RtpFlags, \
515  PayloadType, \
516  H323type, \
517  H323data, \
518  CreateEncoder, \
519  DestroyEncoder, \
520  EncodeVideo, \
521  CreateDecoder, \
522  DestroyDecoder, \
523  DecodeVideo, \
524  ControlsTable \
525  ) \
526  PLUGINCODEC_CODEC_PAIR(MediaFormat, \
527  PayloadName, \
528  Description, \
529  SampleRate, \
530  BitsPerSecond, \
531  90000, \
532  BitsPerSecond, \
533  100000, \
534  MaxWidth, \
535  MaxHeight, \
536  0,30, \
537  PayloadType, \
538  H323type, \
539  H323data, \
540  CreateEncoder, \
541  DestroyEncoder, \
542  EncodeVideo, \
543  CreateDecoder, \
544  DestroyDecoder, \
545  DecodeVideo, \
546  ControlsTable, \
547  PluginCodec_MediaTypeVideo | /* video codec */ \
548  PluginCodec_InputTypeRRP | /* RTP input data */ \
549  PluginCodec_OutputTypeRRP | /* RTP output data */ \
550  (RtpFlags), \
551  PLUGINCODEC_RAW_VIDEO)
552 
553 #define PLUGINCODEC_ONE_VIDEO_CODEC(MediaFormat, \
554  PayloadName, \
555  Description, \
556  BitsPerSecond, \
557  MaxWidth, \
558  MaxHeight, \
559  RtpFlags, \
560  PayloadType, \
561  H323type, \
562  H323data \
563  ) \
564  static struct PluginCodec_Definition CodecDefinitionTable[] = { \
565  PLUGINCODEC_VIDEO_CODEC(MediaFormat, \
566  PayloadName, \
567  Description, \
568  BitsPerSecond, \
569  MaxWidth, \
570  MaxHeight, \
571  RtpFlags, \
572  PayloadType, \
573  H323type, \
574  H323data, \
575  CreateEncoder, \
576  DestroyEncoder, \
577  EncodeAudio, \
578  CreateDecoder, \
579  DestroyDecoder, \
580  DecodeAudio, \
581  ControlsTable \
582  ) \
583  }
584 
585 
587 //
588 // H.323 specific values
589 //
590 
591 
593  unsigned int index;
594  void * data;
595  unsigned dataLength;
596 };
597 
599  const char * objectId;
600  unsigned char t35CountryCode;
601  unsigned char t35Extension;
602  unsigned short manufacturerCode;
603  const unsigned char * data;
604  unsigned int dataLength;
606 };
607 
608 
610 {
611  /* The following used to be a simple integer for the collapsing flag in
612  version 3 and earlier. We hope that all those implementations just used
613  zero and one (a good bet) and thus the below bit fields will be backward
614  compatible, putting the parameter in all three PDU types.
615  */
616 #ifndef SOLARIS
617  struct {
618 #endif
619  int collapsing:1; /* boolean */
620  int excludeTCS:1;
621  int excludeOLC:1;
622  int excludeReqMode:1;
623  int readOnly:1;
624 #ifndef SOLARIS
625  };
626 #endif
627 
628  unsigned int id;
631  /* these need to be in the same order as the choices in
632  H245_ParameterValue::Choices, as the value is just cast to that type
633  */
642 
651  } type;
653  union {
654  unsigned long integer;
655  const char * octetstring;
657  } value;
658 };
661 {
662  // some cunning structures & lists, and associated logic in
663  // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
664  const char * standardIdentifier;
665  unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
667  /* parameters; these are the parameters which are set in the
668  'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
669  unsigned int nParameters;
670  /* an array of nParameters parameter definitions */
672 };
673 
677  int scrambled:1;
678 };
681  unsigned char maxAl_sduAudioFrames;
682  int silenceSuppression:1;
683  int highRateMode0:6; // INTEGER (27..78), -- units octets
684  int highRateMode1:6; // INTEGER (27..78), -- units octets
685  int lowRateMode0:6; // INTEGER (23..66), -- units octets
686  int lowRateMode1:6; // INTEGER (23..66), -- units octets
687  int sidMode0:4; // INTEGER (6..17), -- units octets
688  int sidMode1:4; // INTEGER (6..17), -- units octets
689 };
690 
692 enum {
693  PluginCodec_H323Codec_undefined, // must be zero, so empty struct is undefined
694  PluginCodec_H323Codec_programmed, // H323ProgrammedCapability
695  PluginCodec_H323Codec_nonStandard, // H323NonStandardData
696  PluginCodec_H323Codec_generic, // H323GenericCodecData
697 
698  // audio codecs
706  PluginCodec_H323AudioCodec_g7231, // H323AudioG7231Data
710  PluginCodec_H323AudioCodec_is11172, // not yet implemented
714  PluginCodec_H323AudioCodec_g7231AnnexC, // H323AudioG7231AnnexC
720  // video codecs
721  PluginCodec_H323VideoCodec_h261, // implemented
722  PluginCodec_H323VideoCodec_h262, // not yet implemented
723  PluginCodec_H323VideoCodec_h263, // implemented
724  PluginCodec_H323VideoCodec_is11172, // not yet implemented
726  // other capabilities
727  PluginCodec_H323VideoCodec_Extended, // implemented (for use with H.239)
728  PluginCodec_H323T38Codec, // not yet implemented
729 
730  // special codes
731  PluginCodec_H323Codec_NoH323 = 0xff, // used for SIP-only codecs
732 };
735 //
736 // Generic Codec Standard Identifiers
737 //
739 // Audio Capabilities
740 // AMR (as defined in H.245v13 Annex I)
741 #define OpalPluginCodec_Identifer_AMR "0.0.8.245.1.1.1"
743 // AMR-NB\WB (as defined in H.245v13 Annex R)
744 #define OpalPluginCodec_Identifer_AMR_NB "0.0.8.245.1.1.9"
745 #define OpalPluginCodec_Identifer_AMR_WB "0.0.8.245.1.1.10"
747 // G.722.1
748 #define OpalPluginCodec_Identifer_G7221 "0.0.7.7221.1.0"
749 #define OpalPluginCodec_Identifer_G7221ext "0.0.7.7221.1.1.0"
750 
751 // G.722.2 (aka AMR-WB)
752 #define OpalPluginCodec_Identifer_G7222 "0.0.7.7222.1.0"
754 // iLBC (as defined in H.245v13 Annex S)
755 #define OpalPluginCodec_Identifer_iLBC "0.0.8.245.1.1.11"
756 
757 
758 // Video Capabilities
760 // H264 (as defined in H.241)
761 #define OpalPluginCodec_Identifer_H264_Aligned "0.0.8.241.0.0.0.0"
762 #define OpalPluginCodec_Identifer_H264_NonInterleaved "0.0.8.241.0.0.0.1"
763 #define OpalPluginCodec_Identifer_H264_Interleaved "0.0.8.241.0.0.0.2"
764 #define OpalPluginCodec_Identifer_H264_Generic "0.0.8.241.0.0.1"
765 
766 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
767 #define OpalPluginCodec_Identifer_MPEG4 "0.0.8.245.1.0.0"
768 
769 
771 //
772 // Predefined options for H.323 codecs
773 //
774 
775 #define PLUGINCODEC_SQCIF_MPI "SQCIF MPI"
776 #define PLUGINCODEC_QCIF_MPI "QCIF MPI"
777 #define PLUGINCODEC_CIF_MPI "CIF MPI"
778 #define PLUGINCODEC_CIF4_MPI "CIF4 MPI"
779 #define PLUGINCODEC_CIF16_MPI "CIF16 MPI"
780 #define PLUGINCODEC_CUSTOM_MPI "Custom MPI"
781 
782 #define PLUGINCODEC_MPI_DISABLED 33
784 #define PLUGINCODEC_MEDIA_PACKETIZATION "Media Packetization"
785 #define PLUGINCODEC_MEDIA_PACKETIZATIONS "Media Packetizations"
787 #define H261_ANNEX_D "Annex D - Still Image Transmit"
788 #define H263_ANNEX_D "Annex D - Unrestricted Motion Vector"
789 #define H263_ANNEX_F "Annex F - Advanced Prediction"
790 #define H263_ANNEX_I "Annex I - Advanced INTRA Coding"
791 #define H263_ANNEX_J "Annex J - Deblocking Filter"
792 #define H263_ANNEX_K "Annex K - Slice Structure"
793 #define H263_ANNEX_N "Annex N - Reference Picture Selection"
794 #define H263_ANNEX_S "Annex S - Alternative INTER VLC"
795 #define H263_ANNEX_T "Annex T - Modified Quantization"
796 
797 #ifndef STRINGIZE
798 #define __INTERNAL_STRINGIZE__(v) #v
799 #define STRINGIZE(v) __INTERNAL_STRINGIZE__(v)
800 #endif
801 
802 
804 //
805 // RTP specific definitions
806 //
808 #define PluginCodec_RTP_MaxPacketSize (1518-14-4-8-20-16) // Max Ethernet packet (1518 bytes) minus 802.3/CRC, 802.3, IP, UDP headers
809 #define PluginCodec_RTP_MinHeaderSize (12)
810 #define PluginCodec_RTP_MaxPayloadSize (PluginCodec_RTP_MaxPacketSize - PluginCodec_RTP_MinHeaderSize)
812 #define PluginCodec_RTP_GetWORD(ptr, off) ((((unsigned char*)(ptr))[off] << 8) | ((unsigned char*)(ptr))[off+1])
814 #define PluginCodec_RTP_GetDWORD(ptr, off) ((((unsigned char*)(ptr))[off ] << 24)|\
815  (((unsigned char*)(ptr))[off+1] << 16)|\
816  (((unsigned char*)(ptr))[off+2] << 8 )|\
817  ((unsigned char*)(ptr))[off+3])
819 #define PluginCodec_RTP_SetWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 8 )),\
820  (((unsigned char*)(ptr))[off+1] = (unsigned char) (val) ))
822 #define PluginCodec_RTP_SetDWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 24)),\
823  (((unsigned char*)(ptr))[off+1] = (unsigned char)((val) >> 16)),\
824  (((unsigned char*)(ptr))[off+2] = (unsigned char)((val) >> 8 )),\
825  (((unsigned char*)(ptr))[off+3] = (unsigned char) (val) ))
827 #define PluginCodec_RTP_GetCSRCHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x0f)*4 + PluginCodec_RTP_MinHeaderSize)
828 #define PluginCodec_RTP_GetExtHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x10) ? (PluginCodec_RTP_GetWORD(ptr, PluginCodec_RTP_GetCSRCHdrLength(ptr)+2)*4+4) : 0)
830 #define PluginCodec_RTP_GetHeaderLength(ptr) (PluginCodec_RTP_GetCSRCHdrLength(ptr) + PluginCodec_RTP_GetExtHdrLength(ptr))
831 #define PluginCodec_RTP_GetPayloadPtr(ptr) ((unsigned char*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
832 #define PluginCodec_RTP_GetPayloadType(ptr) (((unsigned char*)(ptr))[1] & 0x7f)
833 #define PluginCodec_RTP_SetPayloadType(ptr, type) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x80) | (type & 0x7f)))
834 #define PluginCodec_RTP_GetMarker(ptr) ((((unsigned char*)(ptr))[1] & 0x80) != 0)
835 #define PluginCodec_RTP_SetMarker(ptr, mark) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0)))
836 #define PluginCodec_RTP_GetTimestamp(ptr) PluginCodec_RTP_GetDWORD(ptr, 4)
837 #define PluginCodec_RTP_SetTimestamp(ptr, ts) PluginCodec_RTP_SetDWORD(ptr, 4, ts)
838 #define PluginCodec_RTP_GetSequenceNumber(ptr) PluginCodec_RTP_GetWORD(ptr, 2)
839 #define PluginCodec_RTP_SetSequenceNumber(ptr, sn) PluginCodec_RTP_SetWORD(ptr, 2, sn)
840 #define PluginCodec_RTP_GetSSRC(ptr) PluginCodec_RTP_GetDWORD(ptr, 8)
841 #define PluginCodec_RTP_SetSSRC(ptr, ssrc) PluginCodec_RTP_SetDWORD(ptr, 8, ssrc)
842 
843 #define PluginCodec_RTP_SetExtended(ptr, type, sz) ((((unsigned char*)(ptr))[0] |= 0x10), \
844  PluginCodec_RTP_SetWORD(ptr, PluginCodec_RTP_GetCSRCHdrLength(ptr), type), \
845  PluginCodec_RTP_SetWORD(ptr, PluginCodec_RTP_GetCSRCHdrLength(ptr)+2, sz))
846 
847 
849 //
850 // video specific definitions
851 //
852 
854  unsigned int x;
855  unsigned int y;
856  unsigned int width;
857  unsigned int height;
858 };
860 #ifdef __cplusplus
861 };
863 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
864 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
866 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
867 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
869 extern "C" {
870 #endif
872 #define PLUGIN_CODEC_VIDEO_SET_FRAME_SIZE_FN "set_frame_size" // argument is struct PluginCodec_VideoSetFrameInfo
874  int width;
875  int height;
876 };
877 
878 
880 //
881 // experimental definitions for statically linking codecs
882 //
883 
884 #ifdef OPAL_STATIC_CODEC
886 # undef PLUGIN_CODEC_DLL_API
887 # define PLUGIN_CODEC_DLL_API static
888 # define PLUGIN_CODEC_IMPLEMENT(name) \
889 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
890 { return PWLIB_PLUGIN_API_VERSION; } \
891 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
892 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
893 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
894 
895 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
896 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
897 { return PWLIB_PLUGIN_API_VERSION; } \
898 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * count, unsigned version) \
899 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
900 
901 
902 #else
904 # define PLUGIN_CODEC_IMPLEMENT(name) \
905 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
906 { return PWLIB_PLUGIN_API_VERSION; } \
907 
908 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
909 PLUGIN_CODEC_IMPLEMENT(name) \
910 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
911 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
912 
913 
914 #endif
915 
916 #ifdef __cplusplus
917 };
918 #endif
919 
920 
921 #ifdef _MSC_VER
922 #pragma warning(default:4201)
923 #endif
924 
925 #endif // OPAL_CODEC_OPALPLUGIN_H