OPAL  Version 3.12.9
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: 30579 $
39  * $Author: rjongbloed $
40  * $Date: 2013-09-30 10:42:24 +1000 (Mon, 30 Sep 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  1000000/PLUGINCODEC_MAX_FRAME_RATE, \
575  MaxWidth, \
576  MaxHeight, \
577  0,PLUGINCODEC_MAX_FRAME_RATE, \
578  PayloadType, \
579  H323type, \
580  H323data, \
581  CreateEncoder, \
582  DestroyEncoder, \
583  EncodeVideo, \
584  CreateDecoder, \
585  DestroyDecoder, \
586  DecodeVideo, \
587  ControlsTable, \
588  PluginCodec_MediaTypeVideo | /* video codec */ \
589  PluginCodec_InputTypeRTP | /* RTP input data */ \
590  PluginCodec_OutputTypeRTP | /* RTP output data */ \
591  (RtpFlags), \
592  PLUGINCODEC_RAW_VIDEO, \
593  NULL)
594 
595 #define PLUGINCODEC_ONE_VIDEO_CODEC(MediaFormat, \
596  PayloadName, \
597  Description, \
598  BitsPerSecond, \
599  MaxWidth, \
600  MaxHeight, \
601  RtpFlags, \
602  PayloadType, \
603  H323type, \
604  H323data \
605  ) \
606  static struct PluginCodec_Definition CodecDefinitionTable[] = { \
607  PLUGINCODEC_VIDEO_CODEC(MediaFormat, \
608  PayloadName, \
609  Description, \
610  BitsPerSecond, \
611  MaxWidth, \
612  MaxHeight, \
613  RtpFlags, \
614  PayloadType, \
615  H323type, \
616  H323data, \
617  CreateEncoder, \
618  DestroyEncoder, \
619  EncodeAudio, \
620  CreateDecoder, \
621  DestroyDecoder, \
622  DecodeAudio, \
623  ControlsTable \
624  ) \
625  }
626 
627 
629 //
630 // H.323 specific values
631 //
632 
633 
635  unsigned int index;
636  void * data;
637  unsigned dataLength;
638 };
639 
641  const char * objectId;
642  unsigned char t35CountryCode;
643  unsigned char t35Extension;
644  unsigned short manufacturerCode;
645  const unsigned char * data;
646  unsigned int dataLength;
648 };
649 
650 
652 {
653  /* The following used to be a simple integer for the collapsing flag in
654  version 3 and earlier. We hope that all those implementations just used
655  zero and one (a good bet) and thus the below bit fields will be backward
656  compatible, putting the parameter in all three PDU types.
657  */
658 #ifndef SOLARIS
659  struct {
660 #endif
661  int collapsing:1; /* boolean */
662  int excludeTCS:1;
663  int excludeOLC:1;
664  int excludeReqMode:1;
665  int readOnly:1;
666 #ifndef SOLARIS
667  };
668 #endif
670  unsigned int id;
671 
673  /* these need to be in the same order as the choices in
674  H245_ParameterValue::Choices, as the value is just cast to that type
675  */
684 
693  } type;
695  union {
696  unsigned long integer;
697  const char * octetstring;
699  } value;
700 };
701 
703 {
704  // some cunning structures & lists, and associated logic in
705  // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
706  const char * standardIdentifier;
707  unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
709  /* parameters; these are the parameters which are set in the
710  'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
711  unsigned int nParameters;
712  /* an array of nParameters parameter definitions */
714 };
716 
719  int scrambled:1;
720 };
723  unsigned char maxAl_sduAudioFrames;
725  int highRateMode0:6; // INTEGER (27..78), -- units octets
726  int highRateMode1:6; // INTEGER (27..78), -- units octets
727  int lowRateMode0:6; // INTEGER (23..66), -- units octets
728  int lowRateMode1:6; // INTEGER (23..66), -- units octets
729  int sidMode0:4; // INTEGER (6..17), -- units octets
730  int sidMode1:4; // INTEGER (6..17), -- units octets
731 };
732 
733 
734 enum {
735  PluginCodec_H323Codec_undefined, // must be zero, so empty struct is undefined
736  PluginCodec_H323Codec_programmed, // H323ProgrammedCapability
737  PluginCodec_H323Codec_nonStandard, // H323NonStandardData
738  PluginCodec_H323Codec_generic, // H323GenericCodecData
740  // audio codecs
748  PluginCodec_H323AudioCodec_g7231, // H323AudioG7231Data
752  PluginCodec_H323AudioCodec_is11172, // not yet implemented
753  PluginCodec_H323AudioCodec_is13818Audio, // not yet implemented
756  PluginCodec_H323AudioCodec_g7231AnnexC, // H323AudioG7231AnnexC
762  // video codecs
763  PluginCodec_H323VideoCodec_h261, // implemented
764  PluginCodec_H323VideoCodec_h262, // not yet implemented
765  PluginCodec_H323VideoCodec_h263, // implemented
766  PluginCodec_H323VideoCodec_is11172, // not yet implemented
768  // other capabilities
769  PluginCodec_H323VideoCodec_Extended, // implemented (for use with H.239)
770  PluginCodec_H323T38Codec, // not yet implemented
771 
772  // special codes
773  PluginCodec_H323Codec_NoH323 = 0xff, // used for SIP-only codecs
774 };
777 //
778 // Generic Codec Standard Identifiers
779 //
781 // Audio Capabilities
782 // AMR (as defined in H.245v13 Annex I)
783 #define OpalPluginCodec_Identifer_AMR "0.0.8.245.1.1.1"
785 // AMR-NB\WB (as defined in H.245v13 Annex R)
786 #define OpalPluginCodec_Identifer_AMR_NB "0.0.8.245.1.1.9"
787 #define OpalPluginCodec_Identifer_AMR_WB "0.0.8.245.1.1.10"
789 // G.722.1
790 #define OpalPluginCodec_Identifer_G7221 "0.0.7.7221.1.0"
791 #define OpalPluginCodec_Identifer_G7221ext "0.0.7.7221.1.1.0"
793 // G.722.2 (aka AMR-WB)
794 #define OpalPluginCodec_Identifer_G7222 "0.0.7.7222.1.0"
796 // iLBC (as defined in H.245v13 Annex S)
797 #define OpalPluginCodec_Identifer_iLBC "0.0.8.245.1.1.11"
799 
800 // Video Capabilities
802 // H264 (as defined in H.241)
803 #define OpalPluginCodec_Identifer_H264_Aligned "0.0.8.241.0.0.0.0"
804 #define OpalPluginCodec_Identifer_H264_NonInterleaved "0.0.8.241.0.0.0.1"
805 #define OpalPluginCodec_Identifer_H264_Interleaved "0.0.8.241.0.0.0.2"
806 #define OpalPluginCodec_Identifer_H264_Generic "0.0.8.241.0.0.1"
807 
808 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
809 #define OpalPluginCodec_Identifer_MPEG4 "0.0.8.245.1.0.0"
810 
811 
813 //
814 // Predefined options for H.323 codecs
815 //
816 
817 #define PLUGINCODEC_SQCIF_MPI "SQCIF MPI"
818 #define PLUGINCODEC_QCIF_MPI "QCIF MPI"
819 #define PLUGINCODEC_CIF_MPI "CIF MPI"
820 #define PLUGINCODEC_CIF4_MPI "CIF4 MPI"
821 #define PLUGINCODEC_CIF16_MPI "CIF16 MPI"
822 #define PLUGINCODEC_CUSTOM_MPI "Custom MPI"
824 #define PLUGINCODEC_MPI_DISABLED 33
825 
826 #define PLUGINCODEC_MEDIA_PACKETIZATION "Media Packetization"
827 #define PLUGINCODEC_MEDIA_PACKETIZATIONS "Media Packetizations"
828 
829 #define H261_ANNEX_D "Annex D - Still Image Transmit"
830 #define H263_ANNEX_D "Annex D - Unrestricted Motion Vector"
831 #define H263_ANNEX_F "Annex F - Advanced Prediction"
832 #define H263_ANNEX_I "Annex I - Advanced INTRA Coding"
833 #define H263_ANNEX_J "Annex J - Deblocking Filter"
834 #define H263_ANNEX_K "Annex K - Slice Structure"
835 #define H263_ANNEX_N "Annex N - Reference Picture Selection"
836 #define H263_ANNEX_S "Annex S - Alternative INTER VLC"
837 #define H263_ANNEX_T "Annex T - Modified Quantization"
839 #ifndef STRINGIZE
840 #define __INTERNAL_STRINGIZE__(v) #v
841 #define STRINGIZE(v) __INTERNAL_STRINGIZE__(v)
842 #endif
843 
844 
846 //
847 // RTP specific definitions
848 //
850 #define PluginCodec_RTP_MaxPacketSize (1518-14-4-8-20-16) // Max Ethernet packet (1518 bytes) minus 802.3/CRC, 802.3, IP, UDP headers
851 #define PluginCodec_RTP_MinHeaderSize (12)
852 #define PluginCodec_RTP_MaxPayloadSize (PluginCodec_RTP_MaxPacketSize - PluginCodec_RTP_MinHeaderSize)
854 #define PluginCodec_RTP_GetWORD(ptr, off) ((((unsigned char*)(ptr))[off] << 8) | ((unsigned char*)(ptr))[off+1])
855 
856 #define PluginCodec_RTP_GetDWORD(ptr, off) ((((unsigned char*)(ptr))[off ] << 24)|\
857  (((unsigned char*)(ptr))[off+1] << 16)|\
858  (((unsigned char*)(ptr))[off+2] << 8 )|\
859  ((unsigned char*)(ptr))[off+3])
860 
861 #define PluginCodec_RTP_SetWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 8 )),\
862  (((unsigned char*)(ptr))[off+1] = (unsigned char) (val) ))
864 #define PluginCodec_RTP_SetDWORD(ptr, off, val) ((((unsigned char*)(ptr))[off ] = (unsigned char)((val) >> 24)),\
865  (((unsigned char*)(ptr))[off+1] = (unsigned char)((val) >> 16)),\
866  (((unsigned char*)(ptr))[off+2] = (unsigned char)((val) >> 8 )),\
867  (((unsigned char*)(ptr))[off+3] = (unsigned char) (val) ))
869 #define PluginCodec_RTP_GetCSRCHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x0f)*4 + PluginCodec_RTP_MinHeaderSize)
870 #define PluginCodec_RTP_GetExtHdrLength(ptr) ((((unsigned char*)(ptr))[0] & 0x10) ? (PluginCodec_RTP_GetWORD(ptr, PluginCodec_RTP_GetCSRCHdrLength(ptr)+2)*4+4) : 0)
871 
872 #define PluginCodec_RTP_GetHeaderLength(ptr) (PluginCodec_RTP_GetCSRCHdrLength(ptr) + PluginCodec_RTP_GetExtHdrLength(ptr))
873 #define PluginCodec_RTP_GetPayloadPtr(ptr) ((unsigned char*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
874 #define PluginCodec_RTP_GetPayloadType(ptr) (((unsigned char*)(ptr))[1] & 0x7f)
875 #define PluginCodec_RTP_SetPayloadType(ptr, type) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x80) | (type & 0x7f)))
876 #define PluginCodec_RTP_GetMarker(ptr) ((((unsigned char*)(ptr))[1] & 0x80) != 0)
877 #define PluginCodec_RTP_SetMarker(ptr, mark) (((unsigned char*)(ptr))[1] = (unsigned char)((((unsigned char*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0)))
878 #define PluginCodec_RTP_GetTimestamp(ptr) PluginCodec_RTP_GetDWORD(ptr, 4)
879 #define PluginCodec_RTP_SetTimestamp(ptr, ts) PluginCodec_RTP_SetDWORD(ptr, 4, ts)
880 #define PluginCodec_RTP_GetSequenceNumber(ptr) PluginCodec_RTP_GetWORD(ptr, 2)
881 #define PluginCodec_RTP_SetSequenceNumber(ptr, sn) PluginCodec_RTP_SetWORD(ptr, 2, sn)
882 #define PluginCodec_RTP_GetSSRC(ptr) PluginCodec_RTP_GetDWORD(ptr, 8)
883 #define PluginCodec_RTP_SetSSRC(ptr, ssrc) PluginCodec_RTP_SetDWORD(ptr, 8, ssrc)
885 
888 //
889 // video specific definitions
890 //
891 
893  unsigned int x;
894  unsigned int y;
895  unsigned int width;
896  unsigned int height;
897 };
898 
899 #ifdef __cplusplus
900 };
902 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
903 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
905 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
906 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
908 extern "C" {
909 #endif
913 //
914 // experimental definitions for statically linking codecs
915 //
916 
917 #ifdef OPAL_STATIC_CODEC
918 
919 # undef PLUGIN_CODEC_DLL_API
920 # define PLUGIN_CODEC_DLL_API static
921 # define PLUGIN_CODEC_IMPLEMENT(name) \
922 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
923 { return PWLIB_PLUGIN_API_VERSION; } \
924 static const struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
925 struct const PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
926 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
928 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
929 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
930 { return PWLIB_PLUGIN_API_VERSION; } \
931 PLUGIN_CODEC_DLL_API const struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * count, unsigned version) \
932 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
933 
934 
935 #else
936 
937 # define PLUGIN_CODEC_IMPLEMENT(name) \
938 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
939 { return PWLIB_PLUGIN_API_VERSION; } \
940 
941 # define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
942 PLUGIN_CODEC_IMPLEMENT(name) \
943 PLUGIN_CODEC_DLL_API const struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
944 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
945 
946 
947 #endif
948 
949 #ifdef __cplusplus
950 };
951 #endif
952 
953 
954 #ifdef _MSC_VER
955 #pragma warning(default:4201)
956 #endif
957 
958 #endif // OPAL_CODEC_OPALPLUGIN_H