"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/h323pluginmgr.cxx" between
h323plus-1_26_9.tar.gz and h323plus-1_27_0.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

h323pluginmgr.cxx  (h323plus-1_26_9):h323pluginmgr.cxx  (h323plus-1_27_0)
skipping to change at line 437 skipping to change at line 437
list.AppendString(PLUGINCODEC_OPTION_FRAME_HEIGHT); list.AppendString(PLUGINCODEC_OPTION_FRAME_HEIGHT);
list.AppendString(frameHeight); list.AppendString(frameHeight);
list.AppendString(PLUGINCODEC_OPTION_FRAME_TIME); list.AppendString(PLUGINCODEC_OPTION_FRAME_TIME);
list.AppendString(OpalMediaFormat::VideoTimeUnits * 1000 * 100 * frameRate / 2997); list.AppendString(OpalMediaFormat::VideoTimeUnits * 1000 * 100 * frameRate / 2997);
char ** _options = list.ToCharArray(); char ** _options = list.ToCharArray();
unsigned int optionsLen = sizeof(_options); unsigned int optionsLen = sizeof(_options);
PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_CUSTOMISED_ OPTIONS); PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_CUSTOMISED_ OPTIONS);
if (ctl != NULL) { if (ctl != NULL) {
(*ctl->control)(codec, context ,SET_CODEC_CUSTOMISED_OPTIONS, _options, &optionsLen); (*ctl->control)(codec, context ,SET_CODEC_CUSTOMISED_OPTIONS, _options, &optionsLen);
free(_options);
return true; return true;
} }
free(_options);
return false; return false;
} }
static bool SetCustomisedOptions(const PluginCodec_Definition * codec, static bool SetCustomisedOptions(const PluginCodec_Definition * codec,
void * context, void * context,
unsigned bitRate, unsigned bitRate,
unsigned sampleRate) unsigned sampleRate)
{ {
if (context == NULL) if (context == NULL)
return false; return false;
skipping to change at line 465 skipping to change at line 467
if (sampleRate > 0) { if (sampleRate > 0) {
list.AppendString(PLUGINCODEC_OPTION_MAX_FRAME_SIZE); list.AppendString(PLUGINCODEC_OPTION_MAX_FRAME_SIZE);
list.AppendString(sampleRate); list.AppendString(sampleRate);
} }
char ** _options = list.ToCharArray(); char ** _options = list.ToCharArray();
unsigned int optionsLen = sizeof(_options); unsigned int optionsLen = sizeof(_options);
PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_CUSTOMISED_ OPTIONS); PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_CUSTOMISED_ OPTIONS);
if (ctl != NULL) { if (ctl != NULL) {
(*ctl->control)(codec, context ,SET_CODEC_CUSTOMISED_OPTIONS, _options, &optionsLen); (*ctl->control)(codec, context ,SET_CODEC_CUSTOMISED_OPTIONS, _options, &optionsLen);
free(_options);
return true; return true;
} }
free(_options);
return false; return false;
} }
bool OpalPluginCodec::SetCustomFormat(unsigned frameWidth, unsigned frameHeight, unsigned frameRate) bool OpalPluginCodec::SetCustomFormat(unsigned frameWidth, unsigned frameHeight, unsigned frameRate)
{ {
return SetCustomisedOptions(codecDefn, context, frameWidth, frameHeight, fra meRate); return SetCustomisedOptions(codecDefn, context, frameWidth, frameHeight, fra meRate);
} }
bool OpalPluginCodec::SetCustomFormat(unsigned bitrate, unsigned samplerate) bool OpalPluginCodec::SetCustomFormat(unsigned bitrate, unsigned samplerate)
{ {
skipping to change at line 490 skipping to change at line 494
static PBoolean SetCodecControl(const PluginCodec_Definition * codec, static PBoolean SetCodecControl(const PluginCodec_Definition * codec,
void * context, void * context,
const char * name, const char * name,
const char * parm, const char * parm,
const char * value) const char * value)
{ {
PluginCodec_ControlDefn * codecControls = GetCodecControl(codec, name); PluginCodec_ControlDefn * codecControls = GetCodecControl(codec, name);
if (codecControls == NULL) if (codecControls == NULL)
return FALSE; return FALSE;
PStringArray list; PStringArray list;
list += parm; list += parm;
list += value; list += value;
char ** options = list.ToCharArray(); char ** options = list.ToCharArray();
unsigned int optionsLen = sizeof(options); unsigned int optionsLen = sizeof(options);
return (*codecControls->control)(codec, context, SET_CODEC_OPTIONS_CONTROL, op bool result = (*codecControls->control)(codec, context, SET_CODEC_OPTIONS_CONT
tions, &optionsLen); ROL, options, &optionsLen);
free(options);
return result;
} }
#if defined(H323_AUDIO_CODECS) || defined(H323_VIDEO) #if defined(H323_AUDIO_CODECS) || defined(H323_VIDEO)
static PBoolean SetCodecControl(const PluginCodec_Definition * codec, static PBoolean SetCodecControl(const PluginCodec_Definition * codec,
void * context, void * context,
const char * name, const char * name,
const char * parm, const char * parm,
int value) int value)
{ {
return SetCodecControl(codec, context, name, parm, PString(PString::Signed, va lue)); return SetCodecControl(codec, context, name, parm, PString(PString::Signed, va lue));
skipping to change at line 545 skipping to change at line 551
void * context, void * context,
const char * name, const char * name,
const char * parm ) const char * parm )
{ {
PStringArray list; PStringArray list;
list += name; list += name;
list += parm; list += parm;
char ** parms = list.ToCharArray(); char ** parms = list.ToCharArray();
unsigned int parmsLen = sizeof(parms); unsigned int parmsLen = sizeof(parms);
int retVal=0; int retVal = 0;
return CallCodecControl(codec,context,EVENT_CODEC_CONTROL, parms, &parmsLen, bool result = CallCodecControl(codec,context,EVENT_CODEC_CONTROL, parms, &par
retVal); msLen, retVal);
free(parms);
return result;
} }
static void PopulateMediaFormatOptions(PluginCodec_Definition * _encoderCodec, O palMediaFormat & format) static void PopulateMediaFormatOptions(PluginCodec_Definition * _encoderCodec, O palMediaFormat & format)
{ {
char ** _options = NULL; char ** _options = NULL;
unsigned int optionsLen = sizeof(_options); unsigned int optionsLen = sizeof(_options);
int retVal; int retVal;
if (CallCodecControl(_encoderCodec, NULL, GET_CODEC_OPTIONS_CONTROL, &_options , &optionsLen, retVal) && (_options != NULL)) { if (CallCodecControl(_encoderCodec, NULL, GET_CODEC_OPTIONS_CONTROL, &_options , &optionsLen, retVal) && (_options != NULL)) {
if (_encoderCodec->version < PLUGIN_CODEC_VERSION_OPTIONS) { if (_encoderCodec->version < PLUGIN_CODEC_VERSION_OPTIONS) {
PTRACE(3, "OpalPlugin\tAdding options to OpalMediaFormat " << format << " using old style method"); PTRACE(3, "OpalPlugin\tAdding options to OpalMediaFormat " << format << " using old style method");
skipping to change at line 1084 skipping to change at line 1092
if (ctl != NULL) { if (ctl != NULL) {
PStringArray list(mediaFormat.GetOptionCount()*2); PStringArray list(mediaFormat.GetOptionCount()*2);
for (PINDEX i = 0; i < mediaFormat.GetOptionCount(); i++) { for (PINDEX i = 0; i < mediaFormat.GetOptionCount(); i++) {
const OpalMediaOption & option = mediaFormat.GetOption(i); const OpalMediaOption & option = mediaFormat.GetOption(i);
list[i*2] = option.GetName(); list[i*2] = option.GetName();
list[(i*2)+1] = option.AsString(); list[(i*2)+1] = option.AsString();
} }
char ** _options = list.ToCharArray(); char ** _options = list.ToCharArray();
unsigned int optionsLen = sizeof(_options); unsigned int optionsLen = sizeof(_options);
(*ctl->control)(codec, context, SET_CODEC_OPTIONS_CONTROL, _options, &opti onsLen); (*ctl->control)(codec, context, SET_CODEC_OPTIONS_CONTROL, _options, &opti onsLen);
for (int i = 0; _options[i] != NULL; i += 2) { for (int i = 0; _options[i] != NULL; i += 2) {
const char * key = _options[i]; const char * key = _options[i];
int val = atoi(_options[i+1]); int val = atoi(_options[i+1]);
if (mediaFormat.HasOption(key)) if (mediaFormat.HasOption(key))
mediaFormat.SetOptionInteger(key,val); mediaFormat.SetOptionInteger(key,val);
} }
#ifdef H323_VIDEO #ifdef H323_VIDEO
mediaFormat.SetBandwidth(mediaFormat.GetOptionInteger(OpalVideoFormat: :MaxBitRateOption)); mediaFormat.SetBandwidth(mediaFormat.GetOptionInteger(OpalVideoFormat::Max BitRateOption));
#endif #endif
free(_options); free(_options);
return true; return true;
} }
return false; return false;
} }
#endif #endif
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
skipping to change at line 1529 skipping to change at line 1537
if (strcasecmp(key, OpalVideoFormat::TargetBitRateOption) == 0) { if (strcasecmp(key, OpalVideoFormat::TargetBitRateOption) == 0) {
mediaFormat.SetOptionInteger(OpalVideoFormat::TargetBitRateOptio n,val); mediaFormat.SetOptionInteger(OpalVideoFormat::TargetBitRateOptio n,val);
mediaFormat.SetOptionInteger(OpalVideoFormat::MaxBitRateOption,v al); mediaFormat.SetOptionInteger(OpalVideoFormat::MaxBitRateOption,v al);
} else if (strcasecmp(key, "Generic Parameter 42") == 0) } else if (strcasecmp(key, "Generic Parameter 42") == 0)
mediaFormat.SetOptionInteger("Generic Parameter 42",val); mediaFormat.SetOptionInteger("Generic Parameter 42",val);
else if (strcasecmp(key, "Generic Parameter 10") == 0) else if (strcasecmp(key, "Generic Parameter 10") == 0)
mediaFormat.SetOptionInteger("Generic Parameter 10",13); // 16: 9 Ratio mediaFormat.SetOptionInteger("Generic Parameter 10",13); // 16: 9 Ratio
_options += 2; _options += 2;
} }
//free(_options); free(_options);
#if PTRACING #if PTRACING
PTRACE(6, "H323\tCustom Video Format: "); PTRACE(6, "H323\tCustom Video Format: ");
OpalMediaFormat::DebugOptionList(mediaFormat); OpalMediaFormat::DebugOptionList(mediaFormat);
#endif #endif
return true; return true;
} }
return false; return false;
} }
bool OpalPluginCodec::SetMediaFormat(OpalMediaFormat & fmt) bool OpalPluginCodec::SetMediaFormat(OpalMediaFormat & fmt)
skipping to change at line 1677 skipping to change at line 1685
return; return;
} }
flowRequest = bitRateRestriction; flowRequest = bitRateRestriction;
} }
PBoolean H323PluginVideoCodec::SetSupportedFormats(std::list<PVideoFrameInfo> & info) PBoolean H323PluginVideoCodec::SetSupportedFormats(std::list<PVideoFrameInfo> & info)
{ {
PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_FORMAT_OPTI ONS); PluginCodec_ControlDefn * ctl = GetCodecControl(codec, SET_CODEC_FORMAT_OPTI ONS);
if (ctl != NULL && info.size() > 0) { if (ctl != NULL && !info.empty()) {
int i = 0; int i = 0;
PStringArray list(info.size()*2 + mediaFormat.GetOptionCount()*2); PStringArray list(info.size()*2 + mediaFormat.GetOptionCount()*2);
for (std::list<PVideoFrameInfo>::const_iterator r = info.begin(); r != inf o.end(); ++r) { for (std::list<PVideoFrameInfo>::const_iterator r = info.begin(); r != inf o.end(); ++r) {
PString option(PString(r->GetFrameWidth()) + "," + PString(r->GetFrameHe ight()) + "," + PString(r->GetFrameRate())); PString option(PString(r->GetFrameWidth()) + "," + PString(r->GetFrameHe ight()) + "," + PString(r->GetFrameRate()));
list[i*2] = PString("InputFmt"+ PString(i+1)); list[i*2] = PString("InputFmt"+ PString(i+1));
list[(i*2)+1] = option; list[(i*2)+1] = option;
i++; i++;
} }
for (PINDEX j = 0; j < mediaFormat.GetOptionCount(); j++) { for (PINDEX j = 0; j < mediaFormat.GetOptionCount(); j++) {
skipping to change at line 1701 skipping to change at line 1709
i++; i++;
} }
int nw = frameWidth; int nw = frameWidth;
int nh = frameHeight; int nh = frameHeight;
char ** _options = list.ToCharArray(); char ** _options = list.ToCharArray();
unsigned int optionsLen = sizeof(_options); unsigned int optionsLen = sizeof(_options);
(*ctl->control)(codec, context, SET_CODEC_FORMAT_OPTIONS, _options, &optio nsLen); (*ctl->control)(codec, context, SET_CODEC_FORMAT_OPTIONS, _options, &optio nsLen);
for (i = 0; _options[i] != NULL; i += 2) { for (i = 0; _options[i] != NULL; i += 2) {
const char * key = _options[i]; const char * key = _options[i];
int val = atoi(_options[i+1]);; int val = atoi(_options[i+1]);;
if (mediaFormat.HasOption(key)) { if (mediaFormat.HasOption(key)) {
mediaFormat.SetOptionInteger(key,val); mediaFormat.SetOptionInteger(key,val);
if (strcmp(key, OpalVideoFormat::FrameWidthOption) == 0) if (strcmp(key, OpalVideoFormat::FrameWidthOption) == 0)
nw = val; nw = val;
else if (strcmp(key, OpalVideoFormat::FrameHeightOption) == 0) else if (strcmp(key, OpalVideoFormat::FrameHeightOption) == 0)
nh = val; nh = val;
else if (strcmp(key, OpalVideoFormat::FrameTimeOption) == 0) else if (strcmp(key, OpalVideoFormat::FrameTimeOption) == 0)
targetFrameTimeMs = val; targetFrameTimeMs = val;
} }
} }
SetFrameSize(nw,nh); free(_options);
return true; SetFrameSize(nw,nh);
return true;
} else { } else {
PTRACE(4,"PLUGIN\tUnable to set format options in codec"); PTRACE(4,"PLUGIN\tUnable to set format options in codec");
return false; return false;
} }
} }
PBoolean H323PluginVideoCodec::Read(BYTE * /*buffer*/, unsigned & length, RTP_Da taFrame & dst) PBoolean H323PluginVideoCodec::Read(BYTE * /*buffer*/, unsigned & length, RTP_Da taFrame & dst)
{ {
PWaitAndSignal mutex(videoHandlerActive); PWaitAndSignal mutex(videoHandlerActive);
skipping to change at line 2633 skipping to change at line 2642
virtual PluginCodec_GetCodecFunction Get_GetCodecFn() = 0; virtual PluginCodec_GetCodecFunction Get_GetCodecFn() = 0;
}; };
PMutex & H323PluginCodecManager::GetMediaFormatMutex() PMutex & H323PluginCodecManager::GetMediaFormatMutex()
{ {
static PMutex mutex; static PMutex mutex;
return mutex; return mutex;
} }
H323PluginCodecManager::H323PluginCodecManager(PPluginManager * _pluginMgr) H323PluginCodecManager::H323PluginCodecManager(PPluginManager * _pluginMgr)
: PPluginModuleManager(PLUGIN_CODEC_GET_CODEC_FN_STR, _pluginMgr) : PPluginModuleManager(PLUGIN_CODEC_GET_CODEC_FN_STR, _pluginMgr), m_skipRedefi nitions(false)
{ {
// this code runs before the application is able to set the trace level // this code runs before the application is able to set the trace level
char * debug_level = getenv ("PTLIB_TRACE_CODECS"); char * debug_level = getenv ("PTLIB_TRACE_CODECS");
if (debug_level != NULL) { if (debug_level != NULL) {
PTrace::SetLevel(atoi(debug_level)); PTrace::SetLevel(atoi(debug_level));
} }
// skip plugin codecs that re-define built-in codecs (default is to overwrite)
char * codec_redefine = getenv ("PTLIB_SKIP_CODEC_REDEFINITION");
if (codec_redefine != NULL) {
m_skipRedefinitions = true;
}
// instantiate all of the media formats // instantiate all of the media formats
{ {
OpalMediaFormatFactory::KeyList_T keyList = OpalMediaFormatFactory::GetKeyLi st(); OpalMediaFormatFactory::KeyList_T keyList = OpalMediaFormatFactory::GetKeyLi st();
OpalMediaFormatFactory::KeyList_T::const_iterator r; OpalMediaFormatFactory::KeyList_T::const_iterator r;
for (r = keyList.begin(); r != keyList.end(); ++r) { for (r = keyList.begin(); r != keyList.end(); ++r) {
OpalMediaFormat * instance = OpalMediaFormatFactory::CreateInstance(*r); OpalMediaFormat * instance = OpalMediaFormatFactory::CreateInstance(*r);
if (instance == NULL) { if (instance == NULL) {
PTRACE(4, "H323PLUGIN\tCannot instantiate opal media format " << *r); PTRACE(4, "H323PLUGIN\tCannot instantiate opal media format " << *r);
} else { } else {
skipping to change at line 2899 skipping to change at line 2913
} }
// add the media format // add the media format
if (defaultSessionID == 0) { if (defaultSessionID == 0) {
PTRACE(3, "H323PLUGIN\tCodec DLL provides unknown media format " << (int)(en coderCodec->flags & PluginCodec_MediaTypeMask)); PTRACE(3, "H323PLUGIN\tCodec DLL provides unknown media format " << (int)(en coderCodec->flags & PluginCodec_MediaTypeMask));
} else { } else {
PString fmtName = CreateCodecName(encoderCodec, FALSE); PString fmtName = CreateCodecName(encoderCodec, FALSE);
OpalMediaFormat existingFormat(fmtName, TRUE); OpalMediaFormat existingFormat(fmtName, TRUE);
if (existingFormat.IsValid()) { if (existingFormat.IsValid()) {
PTRACE(5, "H323PLUGIN\tMedia format " << fmtName << " already exists"); PTRACE(5, "H323PLUGIN\tMedia format " << fmtName << " already exists");
if (m_skipRedefinitions) {
PTRACE(3, "H323PLUGIN\tSkipping new definition of " << fmtName);
return;
}
H323PluginCodecManager::AddFormat(existingFormat); H323PluginCodecManager::AddFormat(existingFormat);
} else { } else {
PTRACE(5, "H323PLUGIN\tCreating new media format " << fmtName); PTRACE(5, "H323PLUGIN\tCreating new media format " << fmtName);
OpalMediaFormat * mediaFormat = NULL; OpalMediaFormat * mediaFormat = NULL;
// manually register the new singleton type, as we do not have a concrete type // manually register the new singleton type, as we do not have a concrete type
switch (encoderCodec->flags & PluginCodec_MediaTypeMask) { switch (encoderCodec->flags & PluginCodec_MediaTypeMask) {
#ifdef H323_VIDEO #ifdef H323_VIDEO
case PluginCodec_MediaTypeVideo: case PluginCodec_MediaTypeVideo:
 End of changes. 15 change blocks. 
35 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)