OPAL  Version 3.18.8
opalplugin.hpp
Go to the documentation of this file.
1 /*
2  * opalplugins.hpp
3  *
4  * OPAL codec plugins handler (C++ version)
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (C) 2010 Vox Lucida
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 
35 #ifndef OPAL_CODEC_OPALPLUGIN_HPP
36 #define OPAL_CODEC_OPALPLUGIN_HPP
37 
38 #include "opalplugin.h"
39 
40 #include <string.h>
41 #include <stdlib.h>
42 #include <limits.h>
43 #include <stdio.h>
44 
45 #include <map>
46 #include <string>
47 
48 
50 
51 #ifndef PLUGINCODEC_TRACING
52  #define PLUGINCODEC_TRACING 1
53 #endif
54 
55 #if PLUGINCODEC_TRACING
57  extern int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len);
58 
59 #define PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF \
60  PluginCodec_LogFunction PluginCodec_LogFunctionInstance; \
61  int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len) \
62  { \
63  if (len == NULL || *len != sizeof(PluginCodec_LogFunction)) \
64  return false; \
65  \
66  PluginCodec_LogFunctionInstance = (PluginCodec_LogFunction)parm; \
67  if (PluginCodec_LogFunctionInstance != NULL) \
68  PluginCodec_LogFunctionInstance(4, __FILE__, __LINE__, "Plugin", "Started logging."); \
69  \
70  return true; \
71  } \
72 
73  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC { PLUGINCODEC_CONTROL_SET_LOG_FUNCTION, PluginCodec_SetLogFunction },
74 #else
75  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF
76  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC
77 #endif
78 
79 #if !defined(PTRACE)
80  #if PLUGINCODEC_TRACING
81  #include <sstream>
82  #define PTRACE_CHECK(level) \
83  (PluginCodec_LogFunctionInstance != NULL && PluginCodec_LogFunctionInstance(level, NULL, 0, NULL, NULL))
84  #define PTRACE(level, section, args) \
85  if (PTRACE_CHECK(level)) { \
86  std::ostringstream ptrace_strm; ptrace_strm << args; \
87  PluginCodec_LogFunctionInstance(level, __FILE__, __LINE__, section, ptrace_strm.str().c_str()); \
88  } else (void)0
89  #else
90  #define PTRACE_CHECK(level)
91  #define PTRACE(level, section, expr)
92  #endif
93 #endif
94 
95 
97 
99 {
100  unsigned char * m_packet;
101  size_t m_maxSize;
102  size_t m_headerSize;
103  size_t m_payloadSize;
104 
105  public:
106  PluginCodec_RTP(const void * packet, unsigned size)
107  : m_packet((unsigned char *)packet)
108  , m_maxSize(size)
109  , m_headerSize(PluginCodec_RTP_GetHeaderLength(m_packet))
110  , m_payloadSize(size - m_headerSize)
111  {
112  }
113 
114  __inline size_t GetMaxSize() const { return m_maxSize; }
115  __inline size_t GetPacketSize() const { return m_headerSize+m_payloadSize; }
116  __inline size_t GetHeaderSize() const { return m_headerSize; }
117  __inline size_t GetPayloadSize() const { return m_payloadSize; }
118  __inline bool SetPayloadSize(size_t size)
119  {
120  if (m_headerSize+size > m_maxSize)
121  return false;
122  m_payloadSize = (unsigned int)size;
123  return true;
124  }
125 
126  __inline unsigned GetPayloadType() const { return PluginCodec_RTP_GetPayloadType(m_packet); }
127  __inline void SetPayloadType(unsigned type) { PluginCodec_RTP_SetPayloadType(m_packet, type); }
128  __inline bool GetMarker() const { return PluginCodec_RTP_GetMarker(m_packet); }
129  __inline void SetMarker(bool mark) { PluginCodec_RTP_SetMarker(m_packet, mark); }
130  __inline unsigned GetTimestamp() const { return PluginCodec_RTP_GetTimestamp(m_packet); }
131  __inline void SetTimestamp(unsigned ts) { PluginCodec_RTP_SetTimestamp(m_packet, ts); }
132  __inline unsigned GetSequenceNumber() const { return PluginCodec_RTP_GetSequenceNumber(m_packet); }
133  __inline void SetSequenceNumber(unsigned sn) { PluginCodec_RTP_SetSequenceNumber(m_packet, sn); }
134  __inline unsigned GetSSRC() const { return PluginCodec_RTP_GetSSRC(m_packet); }
135  __inline void SetSSRC(unsigned ssrc) { PluginCodec_RTP_SetSSRC(m_packet, ssrc); }
136 
137  __inline unsigned char * SetExtended(unsigned id, unsigned len)
138  {
139  m_packet[0] |= 0x10;
140 
141  unsigned char * ptr = m_packet + PluginCodec_RTP_GetCSRCHdrLength(m_packet);
142  switch (id >> 16) {
143  case 0 :
144  PluginCodec_RTP_SetWORD(ptr, 0, id);
145  PluginCodec_RTP_SetWORD(ptr, 2, (len+3)/4);
146  ptr += 4;
147  break;
148 
149  case 1 :
150  *ptr++ = 0xbe;
151  *ptr++ = 0xde;
152  PluginCodec_RTP_SetWORD(ptr, 0, (len+7)/4); ptr += 2;
153  *ptr++ = (unsigned char)(((id&0xf) << 4)|(len-1));
154  break;
155 
156  case 2 :
157  *ptr++ = 0x10;
158  *ptr++ = 0x00;
159  PluginCodec_RTP_SetWORD(ptr, 0, (len+8)/4); ptr += 2;
160  *ptr++ = (unsigned char)(id&0xff);
161  *ptr++ = (unsigned char)(len&0xff);
162  }
163 
164  m_headerSize = PluginCodec_RTP_GetHeaderLength(m_packet);
165  return ptr;
166  }
167 
168  __inline unsigned char * GetExtendedHeader(unsigned & id, size_t & len) const
169  {
170  if ((m_packet[0]&0x10) == 0)
171  return NULL;
172 
173  unsigned char * ptr = m_packet + PluginCodec_RTP_GetCSRCHdrLength(m_packet);
174  id = PluginCodec_RTP_GetWORD(ptr, 0);
175 
176  if (id == 0xbede) {
177  id = (0x10000|(ptr[4] >> 4));
178  len = (ptr[4] & 0xf)+1;
179  return ptr + 5;
180  }
181 
182  if ((id&0xfff0) == 0x1000) {
183  id = 0x20000 | ptr[4];
184  len = ptr[5];
185  return ptr + 6;
186  }
187 
188  len = PluginCodec_RTP_GetWORD(ptr, 2)*4;
189  return ptr + 4;
190  }
191 
192  __inline unsigned char * GetPayloadPtr() const { return m_packet + m_headerSize; }
193  __inline unsigned char & operator[](size_t offset) { return m_packet[m_headerSize + offset]; }
194  __inline unsigned const char & operator[](size_t offset) const { return m_packet[m_headerSize + offset]; }
195  __inline bool CopyPayload(const void * data, size_t size, size_t offset = 0)
196  {
197  if (!SetPayloadSize(offset + size))
198  return false;
199  memcpy(GetPayloadPtr()+offset, data, size);
200  return true;
201  }
202 
204  __inline unsigned char * GetVideoFrameData() const { return m_packet + m_headerSize + sizeof(PluginCodec_Video_FrameHeader); }
205 };
206 
207 
209 
210 typedef std::map<std::string, std::string> PluginCodec_OptionMapBase;
211 
213 {
214  public:
215  static unsigned String2Unsigned(const std::string & str)
216  {
217  return strtoul(str.c_str(), NULL, 10);
218  }
219 
220 
221  static void AppendUnsigned2String(unsigned value, std::string & str)
222  {
223  // Not very efficient, but really, really simple
224  if (value > 9)
225  AppendUnsigned2String(value/10, str);
226  str += (char)(value%10 + '0');
227  }
228 
229 
230  static void Unsigned2String(unsigned value, std::string & str)
231  {
232  str.clear();
233  AppendUnsigned2String(value,str);
234  }
235 
236 
237  static void Change(const char * value,
238  PluginCodec_OptionMapBase & original,
239  PluginCodec_OptionMapBase & changed,
240  const char * option)
241  {
242  PluginCodec_OptionMapBase::iterator it = original.find(option);
243  if (it != original.end() && it->second != value)
244  changed[option] = value;
245  }
246 
247 
248  static void Change(unsigned value,
249  PluginCodec_OptionMapBase & original,
250  PluginCodec_OptionMapBase & changed,
251  const char * option)
252  {
253  if (String2Unsigned(original[option]) != value)
254  Unsigned2String(value, changed[option]);
255  }
256 
257 
258  static void ClampMax(unsigned maximum,
259  PluginCodec_OptionMapBase & original,
260  PluginCodec_OptionMapBase & changed,
261  const char * option,
262  bool forceIfZero = false)
263  {
264  unsigned value = String2Unsigned(original[option]);
265  if (value > maximum || (forceIfZero && value == 0))
266  Unsigned2String(maximum, changed[option]);
267  }
268 
269 
270  static void ClampMin(unsigned minimum,
271  PluginCodec_OptionMapBase & original,
272  PluginCodec_OptionMapBase & changed,
273  const char * option)
274  {
275  unsigned value = String2Unsigned(original[option]);
276  if (value < minimum)
277  Unsigned2String(minimum, changed[option]);
278  }
279 
280 
281  static unsigned GetMacroBlocks(unsigned width, unsigned height)
282  {
283  return ((width+15)/16) * ((height+15)/16);
284  }
285 
286 
287  static bool ClampResolution(
288  unsigned & width,
289  unsigned & height,
290  unsigned & maxFrameSize)
291  {
292  static struct {
293  unsigned m_width;
294  unsigned m_height;
295  unsigned m_macroblocks;
296  } MaxVideoResolutions[] = {
297  #define OPAL_PLUGIN_CLAMPED_RESOLUTION(width, height) { width, height, ((width+15)/16) * ((height+15)/16) }
298  OPAL_PLUGIN_CLAMPED_RESOLUTION(4096, 2304), // 36864 - Cinema 16:9 (H.264 Level 5.1 - 5.2)
299  OPAL_PLUGIN_CLAMPED_RESOLUTION(4096, 2160), // 34560 - DCI HD
300  OPAL_PLUGIN_CLAMPED_RESOLUTION(3840, 2160), // 32400 - 4k UHDTV
301  OPAL_PLUGIN_CLAMPED_RESOLUTION(3672, 1536), // 22080 - Cinema 2.39:1 (H.264 Level 5)
302  OPAL_PLUGIN_CLAMPED_RESOLUTION(2048, 1080), // 8704 - 2Kx1080 (H.264 Level 4.2)
303  OPAL_PLUGIN_CLAMPED_RESOLUTION(2048, 1024), // 8192 - 2Kx1K (H.264 Level 4 - 4.1)
304  OPAL_PLUGIN_CLAMPED_RESOLUTION(1920, 1080), // 8100 - 1080p HD
305  OPAL_PLUGIN_CLAMPED_RESOLUTION(1408, 1152), // 6336 - 16CIF
306  OPAL_PLUGIN_CLAMPED_RESOLUTION(1280, 1024), // 5120 - SXGA (H.264 Level 3.2)
307  OPAL_PLUGIN_CLAMPED_RESOLUTION(1280, 720), // 3600 - 720p HD (H.264 Level 3.1)
308  OPAL_PLUGIN_CLAMPED_RESOLUTION( 720, 576), // 1620 - 625 SD (H.264 Level 2.2 - 3)
309  OPAL_PLUGIN_CLAMPED_RESOLUTION( 704, 576), // 1584 - 4CIF
310  OPAL_PLUGIN_CLAMPED_RESOLUTION( 640, 480), // 1200 - VGA
311  OPAL_PLUGIN_CLAMPED_RESOLUTION( 352, 576), // 792 - 625 HHR (H.264 Level 2.1)
312  OPAL_PLUGIN_CLAMPED_RESOLUTION( 352, 288), // 396 - CIF (H.264 Level 1.1 - 2)
313  OPAL_PLUGIN_CLAMPED_RESOLUTION( 320, 240), // 300 - QVGA
314  OPAL_PLUGIN_CLAMPED_RESOLUTION( 176, 144), // 99 - QCIF (H.264 Level 1, 1b)
315  OPAL_PLUGIN_CLAMPED_RESOLUTION( 128, 96) // 48 - SQCIF
316  };
317  static size_t const LastMaxVideoResolutions = sizeof(MaxVideoResolutions)/sizeof(MaxVideoResolutions[0]) - 1;
318 
319  size_t index = 0;
320 
321  if (maxFrameSize > 0) {
322  static unsigned const MinWidth = 4*16; // Four macroblocks wide
323  static unsigned const MinHeight = 3*16; // Three macroblocks high
324 
325  unsigned maxWidth = maxFrameSize*16*16/MinHeight;
326  unsigned maxHeight = maxFrameSize*16*16/MinWidth;
327 
328  // Check if total frame size below threshold total of macroblocks.
329  unsigned macroBlocks = GetMacroBlocks(width, height);
330  if (macroBlocks <= maxFrameSize &&
331  width >= MinWidth && width <= maxWidth &&
332  height >= MinHeight && height <= maxHeight)
333  return false;
334 
335  while (index < LastMaxVideoResolutions &&
336  (MaxVideoResolutions[index].m_macroblocks > maxFrameSize ||
337  MaxVideoResolutions[index].m_width > maxWidth ||
338  MaxVideoResolutions[index].m_height > maxHeight))
339  ++index;
340  }
341 
342  PTRACE(4, "Plugin", "ClampResolution: idx=" << index << ' '
343  << width << 'x' << height << " > " << maxFrameSize << "mb reduced to "
344  << MaxVideoResolutions[index].m_width << 'x' << MaxVideoResolutions[index].m_height
345  << '=' << MaxVideoResolutions[index].m_macroblocks << "mb");
346  width = MaxVideoResolutions[index].m_width;
347  height = MaxVideoResolutions[index].m_height;
348  maxFrameSize = MaxVideoResolutions[index].m_macroblocks;
349  return true;
350  }
351 
352  static bool ClampResolution(
353  PluginCodec_OptionMapBase & original,
354  PluginCodec_OptionMapBase & changed,
355  unsigned maxWidth,
356  unsigned maxHeight,
357  unsigned & maxMacroBlocks,
358  const char * widthKey = PLUGINCODEC_OPTION_FRAME_WIDTH,
359  const char * heightKey = PLUGINCODEC_OPTION_FRAME_HEIGHT,
360  const char * maxWidthKey = PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH,
361  const char * maxHeightKey = PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT,
362  const char * minWidthKey = PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH,
363  const char * minHeightKey = PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT
364  )
365  {
366  if (!ClampResolution(maxWidth, maxHeight, maxMacroBlocks))
367  return false;
368 
369  ClampMax(maxWidth, original, changed, widthKey);
370  ClampMax(maxHeight, original, changed, heightKey);
371  ClampMax(maxWidth, original, changed, maxWidthKey);
372  ClampMax(maxHeight, original, changed, maxHeightKey);
373  ClampMax(maxWidth, original, changed, minWidthKey);
374  ClampMax(maxHeight, original, changed, minHeightKey);
375  return true;
376  }
377 };
378 
379 
381 {
382  public:
383  PluginCodec_OptionMap(const char * const * * options = NULL)
384  {
385  if (options != NULL) {
386  for (const char * const * option = *options; *option != NULL; option += 2)
387  insert(value_type(option[0], option[1]));
388  }
389  }
390 
391 
392  unsigned GetUnsigned(const char * key, unsigned dflt = 0) const
393  {
394  const_iterator it = find(key);
395  return it == end() ? dflt : String2Unsigned(it->second);
396  }
397 
398  void SetUnsigned(unsigned value, const char * key)
399  {
400  Unsigned2String(value, operator[](key));
401  }
402 
403 
404  char ** GetOptions() const
405  {
406  char ** options = (char **)calloc(size()*2+1, sizeof(char *));
407  if (options == NULL) {
408  PTRACE(1, "Plugin", "Could not allocate new option lists.");
409  return NULL;
410  }
411 
412  char ** opt = options;
413  for (const_iterator it = begin(); it != end(); ++it) {
414  *opt++ = strdup(it->first.c_str());
415  *opt++ = strdup(it->second.c_str());
416  }
417 
418  return options;
419  }
420 };
421 
422 
423 template<typename NAME>
425 {
426  public:
427  typedef struct PluginCodec_Option const * const * OptionsTable;
429 
430  protected:
431  const char * m_rawFormat;
432  const char * m_formatName;
433  const char * m_payloadName;
434  unsigned m_payloadType;
435  const char * m_description;
436  unsigned m_maxBandwidth;
438  const void * m_h323CapabilityData;
439  unsigned m_flags;
441 
442  protected:
444  const char * rawFormat,
445  const char * formatName,
446  const char * payloadName,
447  const char * description,
448  unsigned maxBandwidth,
449  OptionsTable options,
450  unsigned flags = PluginCodec_RTPTypeDynamic
451  ) : m_rawFormat(rawFormat)
452  , m_formatName(formatName)
453  , m_payloadName(payloadName)
454  , m_payloadType(0)
455  , m_description(description)
456  , m_maxBandwidth(maxBandwidth)
458  , m_h323CapabilityData(NULL)
459  , m_flags(flags)
460  , m_options(options)
461  {
462  }
463 
464  public:
466  {
467  }
468 
469 
470  __inline const char * GetRawFormat() const { return this->m_rawFormat; }
471  __inline const char * GetFormatName() const { return this->m_formatName; }
472  __inline const char * GetPayloadName() const { return this->m_payloadName; }
473  __inline unsigned char GetPayloadType() const { return (unsigned char)this->m_payloadType; }
474  __inline const char * GetDescription() const { return this->m_description; }
475  __inline unsigned GetMaxBandwidth() const { return this->m_maxBandwidth; }
476  __inline unsigned char GetH323CapabilityType() const { return (unsigned char)this->m_h323CapabilityType; }
477  __inline const void * GetH323CapabilityData() const { return this->m_h323CapabilityData; }
478  __inline unsigned GetFlags() const { return this->m_flags; }
479  __inline const void * GetOptionsTable() const { return this->m_options; }
480 
481  __inline void SetFlags(unsigned b, unsigned m = 0) { this->m_flags = (this->m_flags&~m) | b; }
482  __inline void SetPayloadType(unsigned p) { this->m_payloadType = p; this->m_flags |= PluginCodec_RTPTypeExplicit; }
483  __inline void SetH323Capability(unsigned type, const void * data = NULL) { this->m_h323CapabilityType = type; this->m_h323CapabilityData = data; }
484 
485 
487  virtual bool IsValidForProtocol(const char * /*protocol*/) const = 0;
488 
490  bool AdjustOptions(void * parm, unsigned * parmLen, bool (PluginCodec_MediaFormat:: * adjuster)(OptionMap & original, OptionMap & changed) const) const
491  {
492  if (parmLen == NULL || parm == NULL || *parmLen != sizeof(char ***)) {
493  PTRACE(1, "Plugin", "Invalid parameters to AdjustOptions.");
494  return false;
495  }
496 
497  OptionMap originalOptions((const char * const * *)parm);
498  OptionMap changedOptions;
499  if (!(this->*adjuster)(originalOptions, changedOptions)) {
500  PTRACE(1, "Plugin", "Could not normalise/customise options.");
501  return false;
502  }
503 
504  return (*(char ***)parm = changedOptions.GetOptions()) != NULL;
505  }
506 
507 
509  virtual bool ToNormalised(OptionMap & /*original*/, OptionMap & /*changed*/) const = 0;
510 
511  // Adjust codec specific options calculated from normalised options.
512  virtual bool ToCustomised(OptionMap & /*original*/, OptionMap & /*changed*/) const = 0;
513 
514  virtual void AdjustForVersion(unsigned version, const PluginCodec_Definition * /*definition*/) const
515  {
516  if (version < PLUGIN_CODEC_VERSION_INTERSECT) {
517  for (PluginCodec_Option ** options = (PluginCodec_Option **)m_options; *options != NULL; ++options) {
518  if (strcmp((*options)->m_name, PLUGINCODEC_MEDIA_PACKETIZATIONS) == 0) {
519  *options = NULL;
520  break;
521  }
522  }
523  }
524  }
525 
526 
527  static void AdjustAllForVersion(unsigned version, const PluginCodec_Definition * definitions, size_t size)
528  {
529  while (size-- > 0) {
531  if (info != NULL)
532  info->AdjustForVersion(version, definitions);
533  ++definitions;
534  }
535  }
536 };
537 
538 
539 template<typename NAME>
541 {
542  public:
545 
546  protected:
548  unsigned m_bytesPerFrame;
549  unsigned m_sampleRate;
552  unsigned m_frameTime;
553 
554 
556  const char * formatName,
557  const char * payloadName,
558  const char * description,
559  unsigned samplesPerFrame,
560  unsigned bytesPerFrame,
561  unsigned sampleRate = 8000,
562  OptionsTable options = NULL
563  ) : Parent(PLUGINCODEC_RAW_AUDIO, formatName, payloadName, description, bytesPerFrame*8 * samplesPerFrame*1000000/sampleRate, options)
564  , m_samplesPerFrame(samplesPerFrame)
565  , m_bytesPerFrame(bytesPerFrame)
566  , m_sampleRate(sampleRate)
567  , m_recommendedFramesPerPacket((50*sampleRate)/(1000*samplesPerFrame))
568  , m_maxFramesPerPacket((120*sampleRate)/(1000*samplesPerFrame))
569  , m_frameTime(samplesPerFrame * 1000000 / sampleRate)
570  {
571  this->m_flags = PluginCodec_MediaTypeAudio /* audio codec */
572  | PluginCodec_InputTypeRaw /* raw input data */
573  | PluginCodec_OutputTypeRaw; /* raw output data */
574  }
575 
576  __inline PluginCodec_AudioFormat & SetFlags(unsigned b, unsigned m = 0) { this->Parent::SetFlags(b,m); return *this; }
577  __inline PluginCodec_AudioFormat & SetPayloadType(unsigned p) { this->Parent::SetPayloadType(p); return *this; }
578  __inline PluginCodec_AudioFormat & SetH323Capability(unsigned type, const void * data = NULL) { this->Parent::SetH323Capability(type, data); return *this; }
579  __inline PluginCodec_AudioFormat & SetMaxFramesPerPacket(unsigned p) { this->m_maxFramesPerPacket = p; return *this; }
580  __inline PluginCodec_AudioFormat & SetChannels(unsigned n) { this->m_flags |= PluginCodec_SetChannels(n); return *this; }
581 
582  public:
583  __inline unsigned GetSamplesPerFrame() const { return this->m_samplesPerFrame; }
584  __inline unsigned GetBytesPerFrame() const { return this->m_bytesPerFrame; }
585  __inline unsigned GetSampleRate() const { return this->m_sampleRate; }
586  __inline unsigned GetFrameTime() const { return this->m_frameTime; }
587  __inline unsigned GetRecommendedFramesPerPacket() const { return this->m_recommendedFramesPerPacket; }
588  __inline unsigned GetMaxFramesPerPacket() const { return this->m_maxFramesPerPacket; }
589 };
590 
591 
592 template<typename NAME>
594 {
595  public:
598 
599  protected:
600  unsigned m_maxWidth;
601  unsigned m_maxHeight;
602 
603 
605  const char * formatName,
606  const char * payloadName,
607  const char * description,
608  unsigned maxBandwidth,
609  OptionsTable options = NULL
610  ) : Parent(PLUGINCODEC_RAW_VIDEO, formatName, payloadName, description, maxBandwidth, options)
611  , m_maxWidth(1920)
612  , m_maxHeight(1200)
613  {
614  this->m_flags = PluginCodec_MediaTypeVideo /* audio codec */
615  | PluginCodec_InputTypeRTP /* raw input data */
616  | PluginCodec_OutputTypeRTP; /* raw output data */
617  }
618 
619  __inline PluginCodec_VideoFormat & SetFlags(unsigned b, unsigned m = 0) { this->Parent::SetFlags(b,m); return *this; }
620  __inline PluginCodec_VideoFormat & SetPayloadType(unsigned p) { this->Parent::SetPayloadType(p); return *this; }
621  __inline PluginCodec_VideoFormat & SetH323Capability(unsigned type, const void * data = NULL) { this->Parent::SetH323Capability(type, data); return *this; }
622 
623  public:
624  __inline unsigned GetMaxWidth() const { return this->m_maxWidth; }
625  __inline unsigned GetMaxHeight() const { return this->m_maxHeight; }
626 };
627 
628 
630 
631 template<typename NAME>
633 {
634  protected:
636  : m_definition(defn)
637  , m_optionsSame(false)
638  , m_maxBitRate(defn->bitsPerSec > 0 ? defn->bitsPerSec : 4*1024*1024)
639  , m_frameTime((defn->sampleRate/1000*defn->usPerFrame)/1000) // Odd way of calculation to avoid 32 bit integer overflow
640  {
641  PTRACE(3, "Plugin", "Codec created: \"" << defn->descr
642  << "\", \"" << defn->sourceFormat << "\" -> \"" << defn->destFormat << '"');
643  }
644 
645 
646  public:
647  virtual ~PluginCodec()
648  {
649  }
650 
651 
653  virtual bool Construct()
654  {
655  return true;
656  }
657 
658 
663  static bool Terminate()
664  {
665  return true;
666  }
667 
668 
670  virtual bool Transcode(const void * fromPtr,
671  unsigned & fromLen,
672  void * toPtr,
673  unsigned & toLen,
674  unsigned & flags) = 0;
675 
676 
678  virtual int GetStatistics(char * /*bufferPtr*/, unsigned /*bufferSize*/)
679  {
680  return -1;
681  }
682 
683 
685  virtual size_t GetOutputDataSize()
686  {
687  return 576-20-16; // Max safe MTU size (576 bytes as per RFC879) minus IP & UDP headers
688  }
689 
690 
697  virtual bool SetInstanceID(const char * /*idPtr*/, unsigned /*idLen*/)
698  {
699  return true;
700  }
701 
702 
704  virtual bool GetActiveOptions(PluginCodec_OptionMap & /*options*/)
705  {
706  return false;
707  }
708 
709 
711  virtual bool SetOptions(const char * const * options)
712  {
713  this->m_optionsSame = true;
714 
715  // get the media format options after adjustment from protocol negotiation
716  for (const char * const * option = options; *option != NULL; option += 2) {
717  if (!this->SetOption(option[0], option[1])) {
718  PTRACE(1, "Plugin", "Could not set option \"" << option[0] << "\" to \"" << option[1] << '"');
719  return false;
720  }
721  }
722 
723  if (this->m_optionsSame)
724  return true;
725 
726  return this->OnChangedOptions();
727  }
728 
729 
731  virtual bool OnChangedOptions()
732  {
733  return true;
734  }
735 
736 
738  virtual bool SetOption(const char * optionName, const char * optionValue)
739  {
740  if (strcasecmp(optionName, PLUGINCODEC_OPTION_TARGET_BIT_RATE) == 0)
741  return this->SetOptionUnsigned(this->m_maxBitRate, optionValue, 1);
742 
743  if (strcasecmp(optionName, PLUGINCODEC_OPTION_MAX_BIT_RATE) == 0) {
744  unsigned bitRate = this->m_maxBitRate;
745  if (!this->SetOptionUnsigned(bitRate, optionValue, 1))
746  return false;
747  if (m_maxBitRate > bitRate)
748  m_maxBitRate = bitRate;
749  return true;
750  }
751 
752  if (strcasecmp(optionName, PLUGINCODEC_OPTION_FRAME_TIME) == 0)
753  return this->SetOptionUnsigned(this->m_frameTime, optionValue, 1);
754 
755  return true;
756  }
757 
758 
759  template <typename T>
760  bool SetOptionUnsigned(T & oldValue, const char * optionValue, unsigned minimum, unsigned maximum = UINT_MAX)
761  {
762  unsigned newValue = oldValue;
763  if (!this->SetOptionUnsigned(newValue, optionValue, minimum, maximum))
764  return false;
765  oldValue = (T)newValue;
766  return true;
767  }
768 
769 
770  bool SetOptionUnsigned(unsigned & oldValue, const char * optionValue, unsigned minimum, unsigned maximum = UINT_MAX)
771  {
772  char * end;
773  unsigned newValue = strtoul(optionValue, &end, 10);
774  if (*end != '\0')
775  return false;
776 
777  if (newValue < minimum)
778  newValue = minimum;
779  else if (newValue > maximum)
780  newValue = maximum;
781 
782  if (oldValue != newValue) {
783  oldValue = newValue;
784  this->m_optionsSame = false;
785  }
786 
787  return true;
788  }
789 
790 
791  template <typename T>
792  bool SetOptionBoolean(T & oldValue, const char * optionValue)
793  {
794  bool opt = oldValue != 0;
795  if (!this->SetOptionBoolean(opt, optionValue))
796  return false;
797  oldValue = (T)opt;
798  return true;
799  }
800 
801 
802  bool SetOptionBoolean(bool & oldValue, const char * optionValue)
803  {
804  bool newValue;
805  if ( strcasecmp(optionValue, "0") == 0 ||
806  strcasecmp(optionValue, "n") == 0 ||
807  strcasecmp(optionValue, "f") == 0 ||
808  strcasecmp(optionValue, "no") == 0 ||
809  strcasecmp(optionValue, "false") == 0)
810  newValue = false;
811  else if (strcasecmp(optionValue, "1") == 0 ||
812  strcasecmp(optionValue, "y") == 0 ||
813  strcasecmp(optionValue, "t") == 0 ||
814  strcasecmp(optionValue, "yes") == 0 ||
815  strcasecmp(optionValue, "true") == 0)
816  newValue = true;
817  else
818  return false;
819 
820  if (oldValue != newValue) {
821  oldValue = newValue;
822  this->m_optionsSame = false;
823  }
824 
825  return true;
826  }
827 
828 
829  bool SetOptionBit(int & oldValue, unsigned bit, const char * optionValue)
830  {
831  return this->SetOptionBit((unsigned &)oldValue, bit, optionValue);
832  }
833 
834 
835  bool SetOptionBit(unsigned & oldValue, unsigned bit, const char * optionValue)
836  {
837  bool newValue;
838  if (strcmp(optionValue, "0") == 0)
839  newValue = false;
840  else if (strcmp(optionValue, "1") == 0)
841  newValue = true;
842  else
843  return false;
844 
845  if (((oldValue&bit) != 0) != newValue) {
846  if (newValue)
847  oldValue |= bit;
848  else
849  oldValue &= ~bit;
850  this->m_optionsSame = false;
851  }
852 
853  return true;
854  }
855 
856 
857  template <class CodecClass> static void * Create_s(const PluginCodec_Definition * defn)
858  {
859  CodecClass * codec = new CodecClass(defn);
860  if (codec != NULL && codec->Construct())
861  return codec;
862 
863  PTRACE(1, "Plugin", "Could not open codec, no context being returned.");
864  delete codec;
865  return NULL;
866  }
867 
868 
869  static void Destroy_s(const PluginCodec_Definition * /*defn*/, void * context)
870  {
871  delete (PluginCodec *)context;
872  }
873 
874 
875  static int Transcode_s(const PluginCodec_Definition * /*defn*/,
876  void * context,
877  const void * fromPtr,
878  unsigned * fromLen,
879  void * toPtr,
880  unsigned * toLen,
881  unsigned int * flags)
882  {
883  if (context != NULL && fromPtr != NULL && fromLen != NULL && toPtr != NULL && toLen != NULL && flags != NULL)
884  return ((PluginCodec *)context)->Transcode(fromPtr, *fromLen, toPtr, *toLen, *flags);
885 
886  PTRACE(1, "Plugin", "Invalid parameter to Transcode.");
887  return false;
888  }
889 
890 
891  static int GetOutputDataSize_s(const PluginCodec_Definition *, void * context, const char *, void *, unsigned *)
892  {
893  return context != NULL ? (int)((PluginCodec *)context)->GetOutputDataSize() : 0;
894  }
895 
897 
898  static int ToNormalised_s(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
899  {
900  return defn->userData != NULL ? ((MediaFormat *)defn->userData)->AdjustOptions(parm, len, &MediaFormat::ToNormalised) : -1;
901  }
902 
903 
904  static int ToCustomised_s(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
905  {
906  return defn->userData != NULL ? ((MediaFormat *)defn->userData)->AdjustOptions(parm, len, &MediaFormat::ToCustomised) : -1;
907  }
908 
909 
910  static int GetActiveOptions_s(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * parmLen)
911  {
912  if (context == NULL || parmLen == NULL || parm == NULL || *parmLen != sizeof(char ***)) {
913  PTRACE(1, "Plugin", "Invalid parameters to GetActiveOptions.");
914  return false;
915  }
916 
917  PluginCodec_OptionMap activeOptions;
918  if (!((PluginCodec *)context)->GetActiveOptions(activeOptions))
919  return false;
920 
921  return (*(char ***)parm = activeOptions.GetOptions()) != NULL;
922  }
923 
924 
925  static int FreeOptions_s(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len)
926  {
927  if (parm == NULL || len == NULL || *len != sizeof(char ***))
928  return false;
929 
930  char ** strings = (char **)parm;
931  for (char ** string = strings; *string != NULL; string++)
932  free(*string);
933  free(strings);
934  return true;
935  }
936 
937 
938  static int GetOptions_s(const struct PluginCodec_Definition * codec, void *, const char *, void * parm, unsigned * len)
939  {
940  if (parm == NULL || len == NULL || *len != sizeof(struct PluginCodec_Option **))
941  return false;
942 
943  *(const void **)parm = codec->userData != NULL ? ((MediaFormat *)codec->userData)->GetOptionsTable() : NULL;
944  *len = 0;
945  return true;
946  }
947 
948 
949  static int SetOptions_s(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
950  {
951  PluginCodec * codec = (PluginCodec *)context;
952  return len != NULL && *len == sizeof(const char **) && parm != NULL &&
953  codec != NULL && codec->SetOptions((const char * const *)parm);
954  }
955 
956  static int ValidForProtocol_s(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
957  {
958  return len != NULL && *len == sizeof(const char *) && parm != NULL && defn->userData != NULL &&
959  ((MediaFormat *)defn->userData)->IsValidForProtocol((const char *)parm);
960  }
961 
962  static int SetInstanceID_s(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
963  {
964  PluginCodec * codec = (PluginCodec *)context;
965  return len != NULL && parm != NULL &&
966  codec != NULL && codec->SetInstanceID((const char *)parm, *len);
967  }
968 
969  static int GetStatistics_s(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
970  {
971  PluginCodec * codec = (PluginCodec *)context;
972  return len != NULL && parm != NULL && codec != NULL ? codec->GetStatistics((char *)parm, *len) : -1;
973  }
974 
975  static int Terminate_s(const PluginCodec_Definition *, void * context, const char *, void *, unsigned *)
976  {
977  PluginCodec * codec = (PluginCodec *)context;
978  return codec != NULL && codec->Terminate();
979  }
980 
982  {
983  static PluginCodec_ControlDefn ControlsTable[] = {
996  { NULL }
997  };
998  return ControlsTable;
999  }
1000 
1001  protected:
1003 
1005  unsigned m_maxBitRate;
1006  unsigned m_frameTime;
1007 };
1008 
1009 
1011 
1012 template<typename NAME>
1013 class PluginVideoCodec : public PluginCodec<NAME>
1014 {
1015  typedef PluginCodec<NAME> BaseClass;
1016 
1017  protected:
1018  unsigned m_maxWidth;
1019  unsigned m_maxHeight;
1020  unsigned m_width;
1021  unsigned m_height;
1022 
1023  public:
1024  enum {
1025  DefaultWidth = 352, // CIF size
1027  };
1028 
1029 
1031  : BaseClass(defn)
1036  {
1037  }
1038 
1039 
1040  virtual int GetStatistics(char * bufferPtr, unsigned bufferSize)
1041  {
1042  return ::snprintf(bufferPtr, bufferSize, "Width=%u\nHeight=%u\n", this->m_width, this->m_height);
1043  }
1044 
1045 
1046  virtual size_t GetRawFrameSize(unsigned width, unsigned height)
1047  {
1048  return OpalDataSizeYUV420P(width, height); // YUV420P
1049  }
1050 
1051 
1052  __inline unsigned GetMaxWidth() const { return m_maxWidth; }
1053  __inline unsigned GetMaxHeight() const { return m_maxHeight; }
1054  __inline unsigned GetWidth() const { return m_width; }
1055  __inline unsigned GetHeight() const { return m_height; }
1056 };
1057 
1058 
1060 
1061 template<typename NAME>
1063 {
1065 
1066  protected:
1067  unsigned m_maxRTPSize;
1068  unsigned m_tsto;
1070 
1071  public:
1073  : BaseClass(defn)
1075  , m_tsto(31)
1076  , m_keyFramePeriod(0) // Indicates auto/default
1077  {
1078  }
1079 
1080 
1081  virtual size_t GetOutputDataSize()
1082  {
1083  return this->m_maxRTPSize;
1084  }
1085 
1086 
1087  virtual bool SetOption(const char * optionName, const char * optionValue)
1088  {
1089  if (strcasecmp(optionName, PLUGINCODEC_OPTION_FRAME_WIDTH) == 0)
1090  return this->SetOptionUnsigned(this->m_width, optionValue, 16, this->m_maxWidth);
1091 
1092  if (strcasecmp(optionName, PLUGINCODEC_OPTION_FRAME_HEIGHT) == 0)
1093  return this->SetOptionUnsigned(this->m_height, optionValue, 16, this->m_maxHeight);
1094 
1095  if (strcasecmp(optionName, PLUGINCODEC_OPTION_MAX_TX_PACKET_SIZE) == 0)
1096  return this->SetOptionUnsigned(this->m_maxRTPSize, optionValue, 256);
1097 
1098  if (strcasecmp(optionName, PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF) == 0)
1099  return this->SetOptionUnsigned(this->m_tsto, optionValue, 1, 31);
1100 
1101  if (strcasecmp(optionName, PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD) == 0)
1102  return this->SetOptionUnsigned(this->m_keyFramePeriod, optionValue, 0);
1103 
1104  // Base class sets bit rate and frame time
1105  return BaseClass::SetOption(optionName, optionValue);
1106  }
1107 
1108 
1110  virtual bool GetActiveOptions(PluginCodec_OptionMap & options)
1111  {
1113  return true;
1114  }
1115 
1116 
1117  virtual size_t GetPacketSpace(const PluginCodec_RTP & rtp, size_t total)
1118  {
1119  size_t space = rtp.GetMaxSize();
1120  if (space > this->m_maxRTPSize)
1121  space = this->m_maxRTPSize;
1122  space -= rtp.GetHeaderSize();
1123  if (space > total)
1124  space = total;
1125  return space;
1126  }
1127 };
1128 
1129 
1131 
1132 template<typename NAME>
1134 {
1136 
1137  protected:
1139 
1140  public:
1142  : BaseClass(defn)
1144  {
1145  }
1146 
1147 
1148  virtual bool SetOption(const char * optionName, const char * optionValue)
1149  {
1150  if (strcasecmp(optionName, PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH) == 0)
1151  return this->SetOptionUnsigned(this->m_width, optionValue, 16, this->m_maxWidth);
1152 
1153  if (strcasecmp(optionName, PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT) == 0)
1154  return this->SetOptionUnsigned(this->m_height, optionValue, 16, this->m_maxHeight);
1155 
1156  // Base class sets bit rate and frame time
1157  return BaseClass::SetOption(optionName, optionValue);
1158  }
1159 
1160 
1161  virtual size_t GetOutputDataSize()
1162  {
1163  return this->m_outputSize;
1164  }
1165 
1166 
1167  virtual bool CanOutputImage(unsigned width, unsigned height, PluginCodec_RTP & rtp, unsigned & flags)
1168  {
1169  if (width == 0 || height == 0)
1170  return false;
1171 
1172  size_t newSize = this->GetRawFrameSize(width, height) + sizeof(PluginCodec_Video_FrameHeader);
1173  if (!rtp.SetPayloadSize(newSize)) {
1174  m_outputSize = newSize + rtp.GetHeaderSize();
1176  return false;
1177  }
1178 
1179  PluginCodec_Video_FrameHeader * videoHeader = rtp.GetVideoHeader();
1180  videoHeader->x = 0;
1181  videoHeader->y = 0;
1182  videoHeader->width = this->m_width = width;
1183  videoHeader->height = this->m_height = height;
1184 
1186  rtp.SetMarker(true);
1187  return true;
1188  }
1189 
1190 
1192  {
1193  unsigned m_width;
1194  unsigned m_height;
1196  unsigned char * m_source;
1197  unsigned char * m_destination;
1198 
1199  void Copy()
1200  {
1201  for (unsigned y = 0; y < m_height; ++y) {
1202  memcpy(m_destination, m_source, m_width);
1203  this->m_source += m_raster;
1204  this->m_destination += m_width;
1205  }
1206  }
1207  };
1208 
1209  virtual unsigned OutputImage(unsigned char * planes[3], int raster[3],
1210  unsigned width, unsigned height, PluginCodec_RTP & rtp, unsigned & flags)
1211  {
1212  if (!CanOutputImage(width, height, rtp, flags))
1213  return 0;
1214 
1215  width = (width+1)&~1;
1216  height = (height+1)&~1;
1217  size_t ySize = width*height;
1218  size_t uvSize = ySize/4;
1219  if (planes[1] == planes[0]+ySize && planes[2] == planes[1]+uvSize)
1220  memcpy(rtp.GetVideoFrameData(), planes[0], ySize+uvSize*2);
1221  else {
1222  OutputImagePlaneInfo planeInfo[3] = {
1223  { width, height, raster[0], planes[0], rtp.GetVideoFrameData() },
1224  { width/2, height/2, raster[1], planes[1], planeInfo[0].m_destination + ySize },
1225  { width/2, height/2, raster[2], planes[2], planeInfo[1].m_destination + uvSize }
1226  };
1227 
1228  for (unsigned plane = 0; plane < 3; ++plane)
1229  planeInfo[plane].Copy();
1230  }
1231 
1232  return (unsigned)rtp.GetPacketSize();
1233  }
1234 };
1235 
1236 
1238 
1240 #define PLUGINCODEC_KNOWN_CODEC_CXX(MediaType, \
1241  Name, \
1242  Description, \
1243  EncoderClass, \
1244  DecoderClass \
1245  ) \
1246  PLUGINCODEC_CODEC_PAIR(Name, \
1247  NULL, \
1248  Description, \
1249  0, \
1250  0, \
1251  0, \
1252  0, \
1253  0, \
1254  0, \
1255  0, \
1256  0, \
1257  0, \
1258  0, \
1259  EncoderClass::Create_s<EncoderClass>, \
1260  EncoderClass::Destroy_s, \
1261  EncoderClass::Transcode_s, \
1262  DecoderClass::Create_s<DecoderClass>, \
1263  DecoderClass::Destroy_s, \
1264  DecoderClass::Transcode_s, \
1265  DecoderClass::GetControls(), /* Note doesn't matter if encoder or decoder */ \
1266  PluginCodec_MediaTypeKnown, \
1267  PLUGINCODEC_RAW_##MediaType, \
1268  NULL)
1269 
1271 #define PLUGINCODEC_AUDIO_CODEC_CXX(MediaFormat, \
1272  EncoderClass, \
1273  DecoderClass \
1274  ) \
1275  PLUGINCODEC_CODEC_PAIR(MediaFormat.GetFormatName(), \
1276  MediaFormat.GetPayloadName(), \
1277  MediaFormat.GetDescription(), \
1278  MediaFormat.GetSampleRate(), \
1279  MediaFormat.GetMaxBandwidth(), \
1280  MediaFormat.GetFrameTime(), \
1281  MediaFormat.GetSamplesPerFrame(), \
1282  MediaFormat.GetBytesPerFrame(), \
1283  MediaFormat.GetRecommendedFramesPerPacket(), \
1284  MediaFormat.GetMaxFramesPerPacket(), \
1285  MediaFormat.GetPayloadType(), \
1286  MediaFormat.GetH323CapabilityType(), \
1287  MediaFormat.GetH323CapabilityData(), \
1288  EncoderClass::Create_s<EncoderClass>, \
1289  EncoderClass::Destroy_s, \
1290  EncoderClass::Transcode_s, \
1291  DecoderClass::Create_s<DecoderClass>, \
1292  DecoderClass::Destroy_s, \
1293  DecoderClass::Transcode_s, \
1294  DecoderClass::GetControls(), /* Note doesn't matter if encoder or decoder */ \
1295  MediaFormat.GetFlags(), \
1296  MediaFormat.GetRawFormat(), \
1297  &MediaFormat)
1298 
1300 #define PLUGINCODEC_VIDEO_CODEC_CXX(MediaFormat, \
1301  EncoderClass, \
1302  DecoderClass \
1303  ) \
1304  PLUGINCODEC_CODEC_PAIR(MediaFormat.GetFormatName(), \
1305  MediaFormat.GetPayloadName(), \
1306  MediaFormat.GetDescription(), \
1307  PLUGINCODEC_VIDEO_CLOCK, \
1308  MediaFormat.GetMaxBandwidth(), \
1309  1000000/PLUGINCODEC_MAX_FRAME_RATE, \
1310  MediaFormat.GetMaxWidth(), \
1311  MediaFormat.GetMaxHeight(), \
1312  0,PLUGINCODEC_MAX_FRAME_RATE, \
1313  MediaFormat.GetPayloadType(), \
1314  MediaFormat.GetH323CapabilityType(), \
1315  MediaFormat.GetH323CapabilityData(), \
1316  EncoderClass::Create_s<EncoderClass>, \
1317  EncoderClass::Destroy_s, \
1318  EncoderClass::Transcode_s, \
1319  DecoderClass::Create_s<DecoderClass>, \
1320  DecoderClass::Destroy_s, \
1321  DecoderClass::Transcode_s, \
1322  DecoderClass::GetControls(), /* Note doesn't matter if encoder or decoder */ \
1323  MediaFormat.GetFlags(), \
1324  MediaFormat.GetRawFormat(), \
1325  &MediaFormat)
1326 
1327 
1328 #define PLUGIN_CODEC_IMPLEMENT_CXX(NAME, table) \
1329  extern "C" { \
1330  PLUGIN_CODEC_IMPLEMENT(NAME) \
1331  PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) { \
1332  if (version < PLUGIN_CODEC_VERSION_OPTIONS) return NULL; \
1333  *count = sizeof(table)/sizeof(struct PluginCodec_Definition); \
1334  PluginCodec_MediaFormat<NAME>::AdjustAllForVersion(version, table, *count); \
1335  return table; \
1336  } \
1337  }
1338 
1339 
1340 #endif // OPAL_CODEC_OPALPLUGIN_HPP
Definition: opalplugin.hpp:1133
PluginCodec_MediaFormat< NAME > Parent
Definition: opalplugin.hpp:543
virtual size_t GetRawFrameSize(unsigned width, unsigned height)
Definition: opalplugin.hpp:1046
virtual size_t GetOutputDataSize()
Get the required output buffer size to be passed into Transcode.
Definition: opalplugin.hpp:1161
void Copy()
Definition: opalplugin.hpp:1199
bool SetOptionBit(int &oldValue, unsigned bit, const char *optionValue)
Definition: opalplugin.hpp:829
#define PLUGINCODEC_CONTROL_SET_INSTANCE_ID
Definition: opalplugin.h:226
Definition: opalplugin.hpp:380
virtual ~PluginCodec_MediaFormat()
Definition: opalplugin.hpp:465
static void Unsigned2String(unsigned value, std::string &str)
Definition: opalplugin.hpp:230
#define PLUGINCODEC_CONTROL_GET_STATISTICS
Definition: opalplugin.h:228
virtual bool IsValidForProtocol(const char *) const =0
Determine if codec is valid for the specified protocol.
#define PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT
Definition: opalplugin.h:326
virtual bool SetOptions(const char *const *options)
Set all the options for the codec.
Definition: opalplugin.hpp:711
#define PLUGINCODEC_MEDIA_PACKETIZATIONS
Definition: opalplugin.h:881
__inline size_t GetPacketSize() const
Definition: opalplugin.hpp:115
Definition: opalplugin.h:339
__inline unsigned char GetH323CapabilityType() const
Definition: opalplugin.hpp:476
OptionsTable m_options
Definition: opalplugin.hpp:440
static int GetStatistics_s(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:969
unsigned char * m_source
Definition: opalplugin.hpp:1196
__inline unsigned char * GetPayloadPtr() const
Definition: opalplugin.hpp:192
unsigned m_maxHeight
Definition: opalplugin.hpp:1019
Definition: opalplugin.hpp:1026
bool SetOptionBoolean(bool &oldValue, const char *optionValue)
Definition: opalplugin.hpp:802
virtual bool Transcode(const void *fromPtr, unsigned &fromLen, void *toPtr, unsigned &toLen, unsigned &flags)=0
Convert from one media format to another.
unsigned GetUnsigned(const char *key, unsigned dflt=0) const
Definition: opalplugin.hpp:392
Definition: opalplugin.h:289
virtual bool Construct()
Complete construction of the plug in codec.
Definition: opalplugin.hpp:653
const void * m_h323CapabilityData
Definition: opalplugin.hpp:438
__inline unsigned GetMaxHeight() const
Definition: opalplugin.hpp:625
PluginVideoCodec(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:1030
__inline PluginCodec_Video_FrameHeader * GetVideoHeader() const
Definition: opalplugin.hpp:203
virtual bool CanOutputImage(unsigned width, unsigned height, PluginCodec_RTP &rtp, unsigned &flags)
Definition: opalplugin.hpp:1167
const char * sourceFormat
Definition: opalplugin.h:353
bool m_optionsSame
Definition: opalplugin.hpp:1004
#define PLUGINCODEC_RAW_VIDEO
Definition: opalplugin.h:405
virtual int GetStatistics(char *bufferPtr, unsigned bufferSize)
Gather any statistics as a string into the provide buffer.
Definition: opalplugin.hpp:1040
Definition: opalplugin.hpp:1062
virtual bool ToNormalised(OptionMap &, OptionMap &) const =0
Adjust normalised options calculated from codec specific options.
__inline void SetMarker(bool mark)
Definition: opalplugin.hpp:129
#define PLUGINCODEC_OPTION_MAX_TX_PACKET_SIZE
Definition: opalplugin.h:315
#define PLUGINCODEC_OPTION_MAX_BIT_RATE
Definition: opalplugin.h:316
unsigned m_keyFramePeriod
Definition: opalplugin.hpp:1069
#define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE
Definition: opalplugin.h:221
__inline unsigned GetHeight() const
Definition: opalplugin.hpp:1055
static void Destroy_s(const PluginCodec_Definition *, void *context)
Definition: opalplugin.hpp:869
#define OPAL_PLUGIN_CLAMPED_RESOLUTION(width, height)
__inline size_t GetPayloadSize() const
Definition: opalplugin.hpp:117
virtual unsigned OutputImage(unsigned char *planes[3], int raster[3], unsigned width, unsigned height, PluginCodec_RTP &rtp, unsigned &flags)
Definition: opalplugin.hpp:1209
unsigned int width
Definition: opalplugin.h:949
#define PluginCodec_RTP_SetSequenceNumber(ptr, sn)
Definition: opalplugin.h:935
#define PluginCodec_RTP_GetTimestamp(ptr)
Definition: opalplugin.h:932
__inline const char * GetRawFormat() const
Definition: opalplugin.hpp:470
bool AdjustOptions(void *parm, unsigned *parmLen, bool(PluginCodec_MediaFormat::*adjuster)(OptionMap &original, OptionMap &changed) const) const
Utility function to adjust option strings, used by ToNormalised()/ToCustomised(). ...
Definition: opalplugin.hpp:490
Definition: opalplugin.h:152
__inline size_t GetMaxSize() const
Definition: opalplugin.hpp:114
#define PluginCodec_RTP_SetSSRC(ptr, ssrc)
Definition: opalplugin.h:937
__inline bool SetPayloadSize(size_t size)
Definition: opalplugin.hpp:118
PluginCodec_MediaFormat(const char *rawFormat, const char *formatName, const char *payloadName, const char *description, unsigned maxBandwidth, OptionsTable options, unsigned flags=PluginCodec_RTPTypeDynamic)
Definition: opalplugin.hpp:443
#define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL
Definition: opalplugin.h:218
#define PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH
Definition: opalplugin.h:325
#define PluginCodec_RTP_MinHeaderSize
Definition: opalplugin.h:905
struct PluginCodec_Option const *const * OptionsTable
Definition: opalplugin.hpp:427
unsigned m_payloadType
Definition: opalplugin.hpp:434
PluginCodec_MediaFormat< NAME > MediaFormat
Definition: opalplugin.hpp:896
Definition: opalplugin.hpp:1025
#define PluginCodec_RTP_GetSequenceNumber(ptr)
Definition: opalplugin.h:934
unsigned m_height
Definition: opalplugin.hpp:1021
unsigned m_maxRTPSize
Definition: opalplugin.hpp:1067
__inline unsigned GetWidth() const
Definition: opalplugin.hpp:1054
#define PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF
Definition: opalplugin.h:327
unsigned m_maxHeight
Definition: opalplugin.hpp:601
Parent::OptionsTable OptionsTable
Definition: opalplugin.hpp:597
__inline unsigned GetSSRC() const
Definition: opalplugin.hpp:134
static int ToNormalised_s(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:898
__inline unsigned GetSamplesPerFrame() const
Definition: opalplugin.hpp:583
bool SetOptionUnsigned(T &oldValue, const char *optionValue, unsigned minimum, unsigned maximum=UINT_MAX)
Definition: opalplugin.hpp:760
Definition: opalplugin.hpp:632
#define PLUGIN_CODEC_VERSION_INTERSECT
Definition: opalplugin.h:87
static void Change(const char *value, PluginCodec_OptionMapBase &original, PluginCodec_OptionMapBase &changed, const char *option)
Definition: opalplugin.hpp:237
__inline PluginCodec_AudioFormat & SetFlags(unsigned b, unsigned m=0)
Definition: opalplugin.hpp:576
Definition: opalplugin.h:146
unsigned m_h323CapabilityType
Definition: opalplugin.hpp:437
__inline unsigned char GetPayloadType() const
Definition: opalplugin.hpp:473
__inline const char * GetDescription() const
Definition: opalplugin.hpp:474
#define PluginCodec_RTP_MaxPacketSize
Definition: opalplugin.h:904
__inline const char * GetFormatName() const
Definition: opalplugin.hpp:471
Definition: opalplugin.hpp:1191
__inline unsigned char & operator[](size_t offset)
Definition: opalplugin.hpp:193
static int GetOptions_s(const struct PluginCodec_Definition *codec, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:938
unsigned m_frameTime
Definition: opalplugin.hpp:552
static struct PluginCodec_ControlDefn * GetControls()
Definition: opalplugin.hpp:981
Definition: opalplugin.h:153
#define PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD
Definition: opalplugin.h:328
static int GetActiveOptions_s(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *parmLen)
Definition: opalplugin.hpp:910
__inline unsigned GetSequenceNumber() const
Definition: opalplugin.hpp:132
__inline unsigned GetBytesPerFrame() const
Definition: opalplugin.hpp:584
__inline PluginCodec_VideoFormat & SetFlags(unsigned b, unsigned m=0)
Definition: opalplugin.hpp:619
unsigned m_maxFramesPerPacket
Definition: opalplugin.hpp:551
unsigned m_maxBandwidth
Definition: opalplugin.hpp:436
Definition: opalplugin.hpp:540
Definition: opalplugin.h:946
int(* PluginCodec_LogFunction)(unsigned level, const char *file, unsigned line, const char *section, const char *log)
Definition: opalplugin.h:237
__inline PluginCodec_VideoFormat & SetH323Capability(unsigned type, const void *data=NULL)
Definition: opalplugin.hpp:621
__inline unsigned GetMaxHeight() const
Definition: opalplugin.hpp:1053
unsigned m_maxWidth
Definition: opalplugin.hpp:1018
#define PluginCodec_RTP_SetTimestamp(ptr, ts)
Definition: opalplugin.h:933
virtual bool OnChangedOptions()
Callback for if any options are changed.
Definition: opalplugin.hpp:731
#define PluginCodec_RTP_GetHeaderLength(ptr)
Definition: opalplugin.h:926
__inline const char * GetPayloadName() const
Definition: opalplugin.hpp:472
PluginCodec_AudioFormat(const char *formatName, const char *payloadName, const char *description, unsigned samplesPerFrame, unsigned bytesPerFrame, unsigned sampleRate=8000, OptionsTable options=NULL)
Definition: opalplugin.hpp:555
static int SetInstanceID_s(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:962
__inline const void * GetOptionsTable() const
Definition: opalplugin.hpp:479
virtual bool SetOption(const char *optionName, const char *optionValue)
Set an individual option of the given name.
Definition: opalplugin.hpp:738
Definition: opalplugin.hpp:424
unsigned m_flags
Definition: opalplugin.hpp:439
const char * m_payloadName
Definition: opalplugin.hpp:433
__inline PluginCodec_AudioFormat & SetPayloadType(unsigned p)
Definition: opalplugin.hpp:577
unsigned m_maxBitRate
Definition: opalplugin.hpp:1005
virtual bool SetOption(const char *optionName, const char *optionValue)
Set an individual option of the given name.
Definition: opalplugin.hpp:1148
unsigned m_height
Definition: opalplugin.hpp:1194
#define PLUGINCODEC_OPTION_FRAME_WIDTH
Definition: opalplugin.h:321
static void AppendUnsigned2String(unsigned value, std::string &str)
Definition: opalplugin.hpp:221
PluginCodec_LogFunction PluginCodec_LogFunctionInstance
PluginCodec(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:635
bool SetOptionBit(unsigned &oldValue, unsigned bit, const char *optionValue)
Definition: opalplugin.hpp:835
static unsigned GetMacroBlocks(unsigned width, unsigned height)
Definition: opalplugin.hpp:281
Definition: opalplugin.h:207
#define PLUGINCODEC_CONTROL_GET_ACTIVE_OPTIONS
Definition: opalplugin.h:223
__inline size_t GetHeaderSize() const
Definition: opalplugin.hpp:116
static int GetOutputDataSize_s(const PluginCodec_Definition *, void *context, const char *, void *, unsigned *)
Definition: opalplugin.hpp:891
static bool ClampResolution(PluginCodec_OptionMapBase &original, PluginCodec_OptionMapBase &changed, unsigned maxWidth, unsigned maxHeight, unsigned &maxMacroBlocks, const char *widthKey=PLUGINCODEC_OPTION_FRAME_WIDTH, const char *heightKey=PLUGINCODEC_OPTION_FRAME_HEIGHT, const char *maxWidthKey=PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH, const char *maxHeightKey=PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT, const char *minWidthKey=PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH, const char *minHeightKey=PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT)
Definition: opalplugin.hpp:352
static void Change(unsigned value, PluginCodec_OptionMapBase &original, PluginCodec_OptionMapBase &changed, const char *option)
Definition: opalplugin.hpp:248
__inline void SetSequenceNumber(unsigned sn)
Definition: opalplugin.hpp:133
virtual bool ToCustomised(OptionMap &, OptionMap &) const =0
static int SetOptions_s(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:949
static void * Create_s(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:857
unsigned m_width
Definition: opalplugin.hpp:1020
unsigned int x
Definition: opalplugin.h:947
#define PTRACE(level, section, args)
Definition: opalplugin.hpp:84
char ** GetOptions() const
Definition: opalplugin.hpp:404
#define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS
Definition: opalplugin.h:224
__inline PluginCodec_VideoFormat & SetPayloadType(unsigned p)
Definition: opalplugin.hpp:620
Definition: opalplugin.h:244
static int Transcode_s(const PluginCodec_Definition *, void *context, const void *fromPtr, unsigned *fromLen, void *toPtr, unsigned *toLen, unsigned int *flags)
Definition: opalplugin.hpp:875
__inline void SetFlags(unsigned b, unsigned m=0)
Definition: opalplugin.hpp:481
virtual bool SetOption(const char *optionName, const char *optionValue)
Set an individual option of the given name.
Definition: opalplugin.hpp:1087
#define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS
Definition: opalplugin.h:222
int m_raster
Definition: opalplugin.hpp:1195
__inline unsigned GetMaxBandwidth() const
Definition: opalplugin.hpp:475
PluginCodec_VideoFormat(const char *formatName, const char *payloadName, const char *description, unsigned maxBandwidth, OptionsTable options=NULL)
Definition: opalplugin.hpp:604
__inline unsigned char * GetVideoFrameData() const
Definition: opalplugin.hpp:204
const PluginCodec_Definition * m_definition
Definition: opalplugin.hpp:1002
#define PluginCodec_RTP_SetPayloadType(ptr, type)
Definition: opalplugin.h:929
virtual int GetStatistics(char *, unsigned)
Gather any statistics as a string into the provide buffer.
Definition: opalplugin.hpp:678
__inline void SetPayloadType(unsigned p)
Definition: opalplugin.hpp:482
Definition: opalplugin.hpp:98
__inline bool GetMarker() const
Definition: opalplugin.hpp:128
Definition: opalplugin.h:160
PluginCodec_OptionMap OptionMap
Definition: opalplugin.hpp:428
Definition: opalplugin.h:210
#define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC
Definition: opalplugin.hpp:73
virtual bool SetInstanceID(const char *, unsigned)
Definition: opalplugin.hpp:697
static int Terminate_s(const PluginCodec_Definition *, void *context, const char *, void *, unsigned *)
Definition: opalplugin.hpp:975
static bool Terminate()
Definition: opalplugin.hpp:663
Definition: opalplugin.h:157
__inline unsigned GetFlags() const
Definition: opalplugin.hpp:478
__inline unsigned const char & operator[](size_t offset) const
Definition: opalplugin.hpp:194
const void * userData
Definition: opalplugin.h:356
void SetUnsigned(unsigned value, const char *key)
Definition: opalplugin.hpp:398
static void ClampMax(unsigned maximum, PluginCodec_OptionMapBase &original, PluginCodec_OptionMapBase &changed, const char *option, bool forceIfZero=false)
Definition: opalplugin.hpp:258
#define PLUGINCODEC_OPTION_FRAME_HEIGHT
Definition: opalplugin.h:322
#define PLUGINCODEC_OPTION_FRAME_TIME
Definition: opalplugin.h:313
#define PluginCodec_RTP_GetWORD(ptr, off)
Definition: opalplugin.h:908
__inline unsigned GetRecommendedFramesPerPacket() const
Definition: opalplugin.hpp:587
Definition: opalplugin.h:145
Definition: opalplugin.hpp:1013
unsigned int height
Definition: opalplugin.h:950
virtual bool GetActiveOptions(PluginCodec_OptionMap &)
Get options that are &quot;active&quot; and may be different from the last SetOptions() call.
Definition: opalplugin.hpp:704
__inline unsigned GetTimestamp() const
Definition: opalplugin.hpp:130
__inline unsigned GetMaxWidth() const
Definition: opalplugin.hpp:1052
#define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS
Definition: opalplugin.h:225
unsigned m_bytesPerFrame
Definition: opalplugin.hpp:548
unsigned int y
Definition: opalplugin.h:948
__inline void SetSSRC(unsigned ssrc)
Definition: opalplugin.hpp:135
__inline unsigned GetFrameTime() const
Definition: opalplugin.hpp:586
unsigned m_frameTime
Definition: opalplugin.hpp:1006
unsigned m_samplesPerFrame
Definition: opalplugin.hpp:547
virtual size_t GetOutputDataSize()
Get the required output buffer size to be passed into Transcode.
Definition: opalplugin.hpp:685
__inline void SetH323Capability(unsigned type, const void *data=NULL)
Definition: opalplugin.hpp:483
#define PluginCodec_RTP_SetWORD(ptr, off, val)
Definition: opalplugin.h:915
size_t m_outputSize
Definition: opalplugin.hpp:1138
static void ClampMin(unsigned minimum, PluginCodec_OptionMapBase &original, PluginCodec_OptionMapBase &changed, const char *option)
Definition: opalplugin.hpp:270
__inline unsigned char * SetExtended(unsigned id, unsigned len)
Definition: opalplugin.hpp:137
virtual size_t GetPacketSpace(const PluginCodec_RTP &rtp, size_t total)
Definition: opalplugin.hpp:1117
#define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS
Definition: opalplugin.h:220
unsigned char * m_destination
Definition: opalplugin.hpp:1197
virtual size_t GetOutputDataSize()
Get the required output buffer size to be passed into Transcode.
Definition: opalplugin.hpp:1081
unsigned m_maxWidth
Definition: opalplugin.hpp:600
unsigned m_sampleRate
Definition: opalplugin.hpp:549
static unsigned String2Unsigned(const std::string &str)
Definition: opalplugin.hpp:215
unsigned m_recommendedFramesPerPacket
Definition: opalplugin.hpp:550
#define PLUGINCODEC_OPTION_TARGET_BIT_RATE
Definition: opalplugin.h:317
Definition: opalplugin.hpp:593
bool SetOptionBoolean(T &oldValue, const char *optionValue)
Definition: opalplugin.hpp:792
Definition: opalplugin.hpp:212
unsigned m_tsto
Definition: opalplugin.hpp:1068
PluginVideoEncoder(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:1072
std::map< std::string, std::string > PluginCodec_OptionMapBase
Definition: opalplugin.hpp:210
const char * descr
Definition: opalplugin.h:351
bool SetOptionUnsigned(unsigned &oldValue, const char *optionValue, unsigned minimum, unsigned maximum=UINT_MAX)
Definition: opalplugin.hpp:770
#define PluginCodec_RTP_GetSSRC(ptr)
Definition: opalplugin.h:936
#define PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT
Definition: opalplugin.h:324
Definition: opalplugin.h:817
__inline PluginCodec_AudioFormat & SetMaxFramesPerPacket(unsigned p)
Definition: opalplugin.hpp:579
#define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS
Definition: opalplugin.h:219
Definition: opalplugin.h:156
#define PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH
Definition: opalplugin.h:323
static int ToCustomised_s(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:904
const char * m_description
Definition: opalplugin.hpp:435
__inline unsigned GetSampleRate() const
Definition: opalplugin.hpp:585
__inline const void * GetH323CapabilityData() const
Definition: opalplugin.hpp:477
virtual bool GetActiveOptions(PluginCodec_OptionMap &options)
Get options that are &quot;active&quot; and may be different from the last SetOptions() call.
Definition: opalplugin.hpp:1110
int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.h:161
#define PLUGINCODEC_CONTROL_TERMINATE_CODEC
Definition: opalplugin.h:229
unsigned m_width
Definition: opalplugin.hpp:1193
__inline bool CopyPayload(const void *data, size_t size, size_t offset=0)
Definition: opalplugin.hpp:195
PluginCodec_MediaFormat< NAME > Parent
Definition: opalplugin.hpp:596
const char * m_rawFormat
Definition: opalplugin.hpp:431
__inline PluginCodec_AudioFormat & SetChannels(unsigned n)
Definition: opalplugin.hpp:580
__inline unsigned GetMaxWidth() const
Definition: opalplugin.hpp:624
static int FreeOptions_s(const PluginCodec_Definition *, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:925
static void AdjustAllForVersion(unsigned version, const PluginCodec_Definition *definitions, size_t size)
Definition: opalplugin.hpp:527
#define PluginCodec_RTP_GetPayloadType(ptr)
Definition: opalplugin.h:928
virtual ~PluginCodec()
Definition: opalplugin.hpp:647
__inline unsigned GetMaxFramesPerPacket() const
Definition: opalplugin.hpp:588
#define PluginCodec_SetChannels(n)
Definition: opalplugin.h:197
#define PluginCodec_RTP_SetMarker(ptr, mark)
Definition: opalplugin.h:931
static int ValidForProtocol_s(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:956
__inline unsigned char * GetExtendedHeader(unsigned &id, size_t &len) const
Definition: opalplugin.hpp:168
#define PluginCodec_RTP_GetCSRCHdrLength(ptr)
Definition: opalplugin.h:923
const char * destFormat
Definition: opalplugin.h:354
static bool ClampResolution(unsigned &width, unsigned &height, unsigned &maxFrameSize)
Definition: opalplugin.hpp:287
virtual void AdjustForVersion(unsigned version, const PluginCodec_Definition *) const
Definition: opalplugin.hpp:514
PluginCodec_OptionMap(const char *const **options=NULL)
Definition: opalplugin.hpp:383
const char * m_formatName
Definition: opalplugin.hpp:432
__inline unsigned GetPayloadType() const
Definition: opalplugin.hpp:126
__inline void SetPayloadType(unsigned type)
Definition: opalplugin.hpp:127
__inline void SetTimestamp(unsigned ts)
Definition: opalplugin.hpp:131
#define PLUGINCODEC_RAW_AUDIO
Definition: opalplugin.h:404
PluginCodec_RTP(const void *packet, unsigned size)
Definition: opalplugin.hpp:106
Parent::OptionsTable OptionsTable
Definition: opalplugin.hpp:544
__inline PluginCodec_AudioFormat & SetH323Capability(unsigned type, const void *data=NULL)
Definition: opalplugin.hpp:578
PluginVideoDecoder(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:1141
#define PluginCodec_RTP_GetMarker(ptr)
Definition: opalplugin.h:930