OPAL  Version 3.10.10
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  * $Revision: 27366 $
35  * $Author: rjongbloed $
36  * $Date: 2012-03-29 00:58:03 -0500 (Thu, 29 Mar 2012) $
37  */
38 
39 #ifndef OPAL_CODEC_OPALPLUGIN_HPP
40 #define OPAL_CODEC_OPALPLUGIN_HPP
41 
42 #include "opalplugin.h"
43 
44 #include <string.h>
45 #include <stdlib.h>
46 #include <limits.h>
47 
48 #include <map>
49 #include <string>
50 
51 
53 
54 #ifndef PLUGINCODEC_TRACING
55  #define PLUGINCODEC_TRACING 1
56 #endif
57 
58 #if PLUGINCODEC_TRACING
60  extern int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len);
61 
62 #define PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF \
63  PluginCodec_LogFunction PluginCodec_LogFunctionInstance; \
64  int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len) \
65  { \
66  if (len == NULL || *len != sizeof(PluginCodec_LogFunction)) \
67  return false; \
68  \
69  PluginCodec_LogFunctionInstance = (PluginCodec_LogFunction)parm; \
70  if (PluginCodec_LogFunctionInstance != NULL) \
71  PluginCodec_LogFunctionInstance(4, __FILE__, __LINE__, "Plugin", "Started logging."); \
72  \
73  return true; \
74  } \
75 
76  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC { PLUGINCODEC_CONTROL_SET_LOG_FUNCTION, PluginCodec_SetLogFunction },
77 #else
78  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF
79  #define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC
80 #endif
81 
82 #if !defined(PTRACE)
83  #if PLUGINCODEC_TRACING
84  #include <sstream>
85  #define PTRACE_CHECK(level) \
86  (PluginCodec_LogFunctionInstance != NULL && PluginCodec_LogFunctionInstance(level, NULL, 0, NULL, NULL))
87  #define PTRACE(level, section, args) \
88  if (PTRACE_CHECK(level)) { \
89  std::ostringstream strm; strm << args; \
90  PluginCodec_LogFunctionInstance(level, __FILE__, __LINE__, section, strm.str().c_str()); \
91  } else (void)0
92  #else
93  #define PTRACE_CHECK(level)
94  #define PTRACE(level, section, expr)
95  #endif
96 #endif
97 
98 
100 
102 {
103  public:
104  typedef struct PluginCodec_Option const * const * OptionsTable;
105  typedef std::map<std::string, std::string> OptionMap;
106 
107  protected:
108  OptionsTable m_options;
109 
110  protected:
111  PluginCodec_MediaFormat(OptionsTable options)
112  : m_options(options)
113  {
114  }
115 
116  public:
118  {
119  }
120 
121 
122  const void * GetOptionsTable() const { return m_options; }
123 
125  virtual bool IsValidForProtocol(const char * /*protocol*/)
126  {
127  return true;
128  }
129 
130 
132  bool AdjustOptions(void * parm, unsigned * parmLen, bool (PluginCodec_MediaFormat:: * adjuster)(OptionMap & original, OptionMap & changed))
133  {
134  if (parmLen == NULL || parm == NULL || *parmLen != sizeof(char ***)) {
135  PTRACE(1, "Plugin", "Invalid parameters to AdjustOptions.");
136  return false;
137  }
138 
139  OptionMap originalOptions;
140  for (const char * const * option = *(const char * const * *)parm; *option != NULL; option += 2)
141  originalOptions[option[0]] = option[1];
142 
143  OptionMap changedOptions;
144  if (!(this->*adjuster)(originalOptions, changedOptions)) {
145  PTRACE(1, "Plugin", "Could not normalise/customise options.");
146  return false;
147  }
148 
149  char ** options = (char **)calloc(changedOptions.size()*2+1, sizeof(char *));
150  *(char ***)parm = options;
151  if (options == NULL) {
152  PTRACE(1, "Plugin", "Could not allocate new option lists.");
153  return false;
154  }
155 
156  for (OptionMap::iterator i = changedOptions.begin(); i != changedOptions.end(); ++i) {
157  *options++ = strdup(i->first.c_str());
158  *options++ = strdup(i->second.c_str());
159  }
160 
161  return true;
162  }
163 
164 
166  virtual bool ToNormalised(OptionMap & original, OptionMap & changed) = 0;
167 
168 
169  // Adjust codec specific options calculated from normalised options.
170  virtual bool ToCustomised(OptionMap & original, OptionMap & changed) = 0;
171 
172 
173  static void Change(const char * value,
174  OptionMap & original,
175  OptionMap & changed,
176  const char * option)
177  {
178  OptionMap::iterator it = original.find(option);
179  if (it != original.end() && it->second != value)
180  changed[option] = value;
181  }
182 
183 
184  static unsigned String2Unsigned(const std::string & str)
185  {
186  return strtoul(str.c_str(), NULL, 10);
187  }
188 
189 
190  static void AppendUnsigned2String(unsigned value, std::string & str)
191  {
192  // Not very efficient, but really, really simple
193  if (value > 9)
194  AppendUnsigned2String(value/10, str);
195  str += (char)(value%10 + '0');
196  }
197 
198 
199  static void Unsigned2String(unsigned value, std::string & str)
200  {
201  str.clear();
202  AppendUnsigned2String(value,str);
203  }
204 
205 
206  static void Change(unsigned value,
207  OptionMap & original,
208  OptionMap & changed,
209  const char * option)
210  {
211  if (String2Unsigned(original[option]) != value)
212  Unsigned2String(value, changed[option]);
213  }
214 
215 
216  static void ClampMax(unsigned maximum,
217  OptionMap & original,
218  OptionMap & changed,
219  const char * option)
220  {
221  unsigned value = String2Unsigned(original[option]);
222  if (value > maximum)
223  Unsigned2String(maximum, changed[option]);
224  }
225 
226 
227  static void ClampMin(unsigned minimum,
228  OptionMap & original,
229  OptionMap & changed,
230  const char * option)
231  {
232  unsigned value = String2Unsigned(original[option]);
233  if (value < minimum)
234  Unsigned2String(minimum, changed[option]);
235  }
236 
237  virtual void AdjustForVersion(unsigned version, const PluginCodec_Definition * /*definition*/)
238  {
239  if (version < PLUGIN_CODEC_VERSION_INTERSECT) {
240  for (PluginCodec_Option ** options = (PluginCodec_Option **)m_options; *options != NULL; ++options) {
241  if (strcmp((*options)->m_name, PLUGINCODEC_MEDIA_PACKETIZATIONS) == 0) {
242  *options = NULL;
243  break;
244  }
245  }
246  }
247  }
248 
249  static void AdjustAllForVersion(unsigned version, const PluginCodec_Definition * definitions, size_t size)
250  {
251  while (size-- > 0) {
253  if (info != NULL)
254  info->AdjustForVersion(version, definitions);
255  ++definitions;
256  }
257  }
258 };
259 
260 
262 
263 template<typename NAME>
265 {
266  protected:
268  : m_definition(defn)
269  , m_optionsSame(false)
270  , m_maxBitRate(defn->bitsPerSec)
271  , m_frameTime((defn->sampleRate/1000*defn->usPerFrame)/1000) // Odd way of calculation to avoid 32 bit integer overflow
272  {
273  PTRACE(3, "Plugin", "Codec created: \"" << defn->descr
274  << "\", \"" << defn->sourceFormat << "\" -> \"" << defn->destFormat << '"');
275  }
276 
277 
278  public:
279  virtual ~PluginCodec()
280  {
281  }
282 
283 
285  virtual bool Construct()
286  {
287  return true;
288  }
289 
290 
295  static bool Terminate()
296  {
297  return true;
298  }
299 
300 
302  virtual bool Transcode(const void * fromPtr,
303  unsigned & fromLen,
304  void * toPtr,
305  unsigned & toLen,
306  unsigned & flags) = 0;
307 
308 
310  virtual bool GetStatistics(char * /*bufferPtr*/, unsigned /*bufferSize*/)
311  {
312  return true;
313  }
314 
315 
317  virtual size_t GetOutputDataSize()
318  {
319  return 576-20-16; // Max safe MTU size (576 bytes as per RFC879) minus IP & UDP headers
320  }
321 
322 
329  virtual bool SetInstanceID(const char * /*idPtr*/, unsigned /*idLen*/)
330  {
331  return true;
332  }
333 
334 
336  virtual bool SetOptions(const char * const * options)
337  {
338  m_optionsSame = true;
339 
340  // get the media format options after adjustment from protocol negotiation
341  for (const char * const * option = options; *option != NULL; option += 2) {
342  if (!SetOption(option[0], option[1])) {
343  PTRACE(1, "Plugin", "Could not set option \"" << option[0] << "\" to \"" << option[1] << '"');
344  return false;
345  }
346  }
347 
348  if (m_optionsSame)
349  return true;
350 
351  return OnChangedOptions();
352  }
353 
354 
356  virtual bool OnChangedOptions()
357  {
358  return true;
359  }
360 
361 
363  virtual bool SetOption(const char * optionName, const char * optionValue)
364  {
365  if (strcasecmp(optionName, PLUGINCODEC_OPTION_TARGET_BIT_RATE) == 0)
366  return SetOptionUnsigned(m_maxBitRate, optionValue, 1, m_definition->bitsPerSec);
367 
368  if (strcasecmp(optionName, PLUGINCODEC_OPTION_FRAME_TIME) == 0)
369  return SetOptionUnsigned(m_frameTime, optionValue, m_definition->sampleRate/1000, m_definition->sampleRate); // 1ms to 1 second
370 
371  return true;
372  }
373 
374 
375  template <typename T>
376  bool SetOptionUnsigned(T & oldValue, const char * optionValue, unsigned minimum, unsigned maximum = UINT_MAX)
377  {
378  unsigned newValue = oldValue;
379  if (!SetOptionUnsigned(newValue, optionValue, minimum, maximum))
380  return false;
381  oldValue = (T)newValue;
382  return true;
383  }
384 
385 
386  bool SetOptionUnsigned(unsigned & oldValue, const char * optionValue, unsigned minimum, unsigned maximum = UINT_MAX)
387  {
388  char * end;
389  unsigned newValue = strtoul(optionValue, &end, 10);
390  if (*end != '\0')
391  return false;
392 
393  if (newValue < minimum)
394  newValue = minimum;
395  else if (newValue > maximum)
396  newValue = maximum;
397 
398  if (oldValue != newValue) {
399  oldValue = newValue;
400  m_optionsSame = false;
401  }
402 
403  return true;
404  }
405 
406 
407  template <typename T>
408  bool SetOptionBoolean(T & oldValue, const char * optionValue)
409  {
410  bool opt = oldValue != 0;
411  if (!SetOptionBoolean(opt, optionValue))
412  return false;
413  oldValue = (T)opt;
414  return true;
415  }
416 
417 
418  bool SetOptionBoolean(bool & oldValue, const char * optionValue)
419  {
420  bool newValue;
421  if ( strcasecmp(optionValue, "0") == 0 ||
422  strcasecmp(optionValue, "n") == 0 ||
423  strcasecmp(optionValue, "f") == 0 ||
424  strcasecmp(optionValue, "no") == 0 ||
425  strcasecmp(optionValue, "false") == 0)
426  newValue = false;
427  else if (strcasecmp(optionValue, "1") == 0 ||
428  strcasecmp(optionValue, "y") == 0 ||
429  strcasecmp(optionValue, "t") == 0 ||
430  strcasecmp(optionValue, "yes") == 0 ||
431  strcasecmp(optionValue, "true") == 0)
432  newValue = true;
433  else
434  return false;
435 
436  if (oldValue != newValue) {
437  oldValue = newValue;
438  m_optionsSame = false;
439  }
440 
441  return true;
442  }
443 
444 
445  bool SetOptionBit(int & oldValue, unsigned bit, const char * optionValue)
446  {
447  return SetOptionBit((unsigned &)oldValue, bit, optionValue);
448  }
449 
450 
451  bool SetOptionBit(unsigned & oldValue, unsigned bit, const char * optionValue)
452  {
453  bool newValue;
454  if (strcmp(optionValue, "0") == 0)
455  newValue = false;
456  else if (strcmp(optionValue, "1") == 0)
457  newValue = true;
458  else
459  return false;
460 
461  if (((oldValue&bit) != 0) != newValue) {
462  if (newValue)
463  oldValue |= bit;
464  else
465  oldValue &= ~bit;
466  m_optionsSame = false;
467  }
468 
469  return true;
470  }
471 
472 
473  template <class CodecClass> static void * Create(const PluginCodec_Definition * defn)
474  {
475  CodecClass * codec = new CodecClass(defn);
476  if (codec != NULL && codec->Construct())
477  return codec;
478 
479  PTRACE(1, "Plugin", "Could not open codec, no context being returned.");
480  delete codec;
481  return NULL;
482  }
483 
484 
485  static void Destroy(const PluginCodec_Definition * /*defn*/, void * context)
486  {
487  delete (PluginCodec *)context;
488  }
489 
490 
491  static int Transcode(const PluginCodec_Definition * /*defn*/,
492  void * context,
493  const void * fromPtr,
494  unsigned * fromLen,
495  void * toPtr,
496  unsigned * toLen,
497  unsigned int * flags)
498  {
499  if (context != NULL && fromPtr != NULL && fromLen != NULL && toPtr != NULL && toLen != NULL && flags != NULL)
500  return ((PluginCodec *)context)->Transcode(fromPtr, *fromLen, toPtr, *toLen, *flags);
501 
502  PTRACE(1, "Plugin", "Invalid parameter to Transcode.");
503  return false;
504  }
505 
506 
507  static int GetOutputDataSize(const PluginCodec_Definition *, void * context, const char *, void *, unsigned *)
508  {
509  return context != NULL ? ((PluginCodec *)context)->GetOutputDataSize() : 0;
510  }
511 
512 
513  static int ToNormalised(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
514  {
515  return defn->userData != NULL ? ((PluginCodec_MediaFormat *)defn->userData)->AdjustOptions(parm, len, &PluginCodec_MediaFormat::ToNormalised) : -1;
516  }
517 
518 
519  static int ToCustomised(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
520  {
521  return defn->userData != NULL ? ((PluginCodec_MediaFormat *)defn->userData)->AdjustOptions(parm, len, &PluginCodec_MediaFormat::ToCustomised) : -1;
522  }
523 
524 
525  static int FreeOptions(const PluginCodec_Definition *, void *, const char *, void * parm, unsigned * len)
526  {
527  if (parm == NULL || len == NULL || *len != sizeof(char ***))
528  return false;
529 
530  char ** strings = (char **)parm;
531  for (char ** string = strings; *string != NULL; string++)
532  free(*string);
533  free(strings);
534  return true;
535  }
536 
537 
538  static int GetOptions(const struct PluginCodec_Definition * codec, void *, const char *, void * parm, unsigned * len)
539  {
540  if (parm == NULL || len == NULL || *len != sizeof(struct PluginCodec_Option **))
541  return false;
542 
543  *(const void **)parm = codec->userData != NULL ? ((PluginCodec_MediaFormat *)codec->userData)->GetOptionsTable() : NULL;
544  *len = 0;
545  return true;
546  }
547 
548 
549  static int SetOptions(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
550  {
551  PluginCodec * codec = (PluginCodec *)context;
552  return len != NULL && *len == sizeof(const char **) && parm != NULL &&
553  codec != NULL && codec->SetOptions((const char * const *)parm);
554  }
555 
556  static int ValidForProtocol(const PluginCodec_Definition * defn, void *, const char *, void * parm, unsigned * len)
557  {
558  return len != NULL && *len == sizeof(const char *) && parm != NULL && defn->userData != NULL &&
559  ((PluginCodec_MediaFormat *)defn->userData)->IsValidForProtocol((const char *)parm);
560  }
561 
562  static int SetInstanceID(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
563  {
564  PluginCodec * codec = (PluginCodec *)context;
565  return len != NULL && parm != NULL &&
566  codec != NULL && codec->SetInstanceID((const char *)parm, *len);
567  }
568 
569  static int GetStatistics(const PluginCodec_Definition *, void * context, const char *, void * parm, unsigned * len)
570  {
571  PluginCodec * codec = (PluginCodec *)context;
572  return len != NULL && parm != NULL &&
573  codec != NULL && codec->GetStatistics((char *)parm, *len);
574  }
575 
576  static int Terminate(const PluginCodec_Definition *, void * context, const char *, void *, unsigned *)
577  {
578  PluginCodec * codec = (PluginCodec *)context;
579  return codec != NULL && codec->Terminate();
580  }
581 
583  {
584  static PluginCodec_ControlDefn ControlsTable[] = {
596  { NULL }
597  };
598  return ControlsTable;
599  }
600 
601  protected:
603 
605  unsigned m_maxBitRate;
606  unsigned m_frameTime;
607 };
608 
609 
610 #endif // OPAL_CODEC_OPALPLUGIN_HPP
static int FreeOptions(const PluginCodec_Definition *, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:525
virtual ~PluginCodec_MediaFormat()
Definition: opalplugin.hpp:117
bool SetOptionBit(int &oldValue, unsigned bit, const char *optionValue)
Definition: opalplugin.hpp:445
#define PLUGINCODEC_CONTROL_SET_INSTANCE_ID
Definition: opalplugin.h:219
#define PLUGINCODEC_CONTROL_GET_STATISTICS
Definition: opalplugin.h:221
static int ToCustomised(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:519
virtual bool SetOptions(const char *const *options)
Set all the options for the codec.
Definition: opalplugin.hpp:336
#define PLUGINCODEC_MEDIA_PACKETIZATIONS
Definition: opalplugin.h:824
Definition: opalplugin.h:328
const void * GetOptionsTable() const
Definition: opalplugin.hpp:122
bool SetOptionBoolean(bool &oldValue, const char *optionValue)
Definition: opalplugin.hpp:418
static void Unsigned2String(unsigned value, std::string &str)
Definition: opalplugin.hpp:199
Definition: opalplugin.h:282
virtual bool Construct()
Complete construction of the plug in codec.
Definition: opalplugin.hpp:285
const char * sourceFormat
Definition: opalplugin.h:342
bool m_optionsSame
Definition: opalplugin.hpp:604
static void AdjustAllForVersion(unsigned version, const PluginCodec_Definition *definitions, size_t size)
Definition: opalplugin.hpp:249
static int ValidForProtocol(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:556
#define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE
Definition: opalplugin.h:215
PluginCodec_MediaFormat(OptionsTable options)
Definition: opalplugin.hpp:111
virtual bool ToNormalised(OptionMap &original, OptionMap &changed)=0
Adjust normalised options calculated from codec specific options.
static void AppendUnsigned2String(unsigned value, std::string &str)
Definition: opalplugin.hpp:190
bool AdjustOptions(void *parm, unsigned *parmLen, bool(PluginCodec_MediaFormat::*adjuster)(OptionMap &original, OptionMap &changed))
Utility function to adjust option strings, used by ToNormalised()/ToCustomised(). ...
Definition: opalplugin.hpp:132
#define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL
Definition: opalplugin.h:212
static int ToNormalised(const PluginCodec_Definition *defn, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:513
bool SetOptionUnsigned(T &oldValue, const char *optionValue, unsigned minimum, unsigned maximum=UINT_MAX)
Definition: opalplugin.hpp:376
Definition: opalplugin.hpp:264
#define PLUGIN_CODEC_VERSION_INTERSECT
Definition: opalplugin.h:87
static void Destroy(const PluginCodec_Definition *, void *context)
Definition: opalplugin.hpp:485
struct PluginCodec_Option const *const * OptionsTable
Definition: opalplugin.hpp:104
static int GetOutputDataSize(const PluginCodec_Definition *, void *context, const char *, void *, unsigned *)
Definition: opalplugin.hpp:507
static int GetOptions(const struct PluginCodec_Definition *codec, void *, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:538
static struct PluginCodec_ControlDefn * GetControls()
Definition: opalplugin.hpp:582
virtual bool OnChangedOptions()
Callback for if any options are changed.
Definition: opalplugin.hpp:356
std::map< std::string, std::string > OptionMap
Definition: opalplugin.hpp:105
static void Change(const char *value, OptionMap &original, OptionMap &changed, const char *option)
Definition: opalplugin.hpp:173
virtual bool SetOption(const char *optionName, const char *optionValue)
Set an individual option of teh given name.
Definition: opalplugin.hpp:363
Definition: opalplugin.hpp:101
unsigned m_maxBitRate
Definition: opalplugin.hpp:605
PluginCodec_LogFunction PluginCodec_LogFunctionInstance
PluginCodec(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:267
bool SetOptionBit(unsigned &oldValue, unsigned bit, const char *optionValue)
Definition: opalplugin.hpp:451
static int Terminate(const PluginCodec_Definition *, void *context, const char *, void *, unsigned *)
Definition: opalplugin.hpp:576
#define PTRACE(level, section, args)
Definition: opalplugin.hpp:87
#define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS
Definition: opalplugin.h:217
static void ClampMin(unsigned minimum, OptionMap &original, OptionMap &changed, const char *option)
Definition: opalplugin.hpp:227
Definition: opalplugin.h:237
#define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS
Definition: opalplugin.h:216
const PluginCodec_Definition * m_definition
Definition: opalplugin.hpp:602
static int SetOptions(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:549
OptionsTable m_options
Definition: opalplugin.hpp:108
#define PLUGINCODEC_CONTROL_LOG_FUNCTION_INC
Definition: opalplugin.hpp:76
virtual bool SetInstanceID(const char *, unsigned)
Definition: opalplugin.hpp:329
static void ClampMax(unsigned maximum, OptionMap &original, OptionMap &changed, const char *option)
Definition: opalplugin.hpp:216
static bool Terminate()
Definition: opalplugin.hpp:295
virtual bool GetStatistics(char *, unsigned)
Gather any statistics as a string into the provide buffer.
Definition: opalplugin.hpp:310
const void * userData
Definition: opalplugin.h:345
virtual bool ToCustomised(OptionMap &original, OptionMap &changed)=0
#define PLUGINCODEC_OPTION_FRAME_TIME
Definition: opalplugin.h:304
static int GetStatistics(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:569
#define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS
Definition: opalplugin.h:218
unsigned m_frameTime
Definition: opalplugin.hpp:606
virtual size_t GetOutputDataSize()
Get the required output buffer size to be passed into Transcode.
Definition: opalplugin.hpp:317
static void * Create(const PluginCodec_Definition *defn)
Definition: opalplugin.hpp:473
static int SetInstanceID(const PluginCodec_Definition *, void *context, const char *, void *parm, unsigned *len)
Definition: opalplugin.hpp:562
#define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS
Definition: opalplugin.h:214
#define PLUGINCODEC_OPTION_TARGET_BIT_RATE
Definition: opalplugin.h:308
virtual bool IsValidForProtocol(const char *)
Determine if codec is valid for the specified protocol.
Definition: opalplugin.hpp:125
bool SetOptionBoolean(T &oldValue, const char *optionValue)
Definition: opalplugin.hpp:408
virtual void AdjustForVersion(unsigned version, const PluginCodec_Definition *)
Definition: opalplugin.hpp:237
const char * descr
Definition: opalplugin.h:340
bool SetOptionUnsigned(unsigned &oldValue, const char *optionValue, unsigned minimum, unsigned maximum=UINT_MAX)
Definition: opalplugin.hpp:386
#define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS
Definition: opalplugin.h:213
static void Change(unsigned value, OptionMap &original, OptionMap &changed, const char *option)
Definition: opalplugin.hpp:206
int PluginCodec_SetLogFunction(const PluginCodec_Definition *, void *, const char *, void *parm, unsigned *len)
#define PLUGINCODEC_CONTROL_TERMINATE_CODEC
Definition: opalplugin.h:222
static unsigned String2Unsigned(const std::string &str)
Definition: opalplugin.hpp:184
virtual ~PluginCodec()
Definition: opalplugin.hpp:279
const char * destFormat
Definition: opalplugin.h:343
static int Transcode(const PluginCodec_Definition *, void *context, const void *fromPtr, unsigned *fromLen, void *toPtr, unsigned *toLen, unsigned int *flags)
Definition: opalplugin.hpp:491
int(* PluginCodec_LogFunction)(unsigned level, const char *file, unsigned line, const char *section, const char *log)
Definition: opalplugin.h:230