[svn-commits] file: branch group/media_formats r411017 - in /team/group/media_formats: ./ c...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Sun Mar 23 16:00:51 CDT 2014
Author: file
Date: Sun Mar 23 16:00:44 2014
New Revision: 411017
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411017
Log:
Finish up getting chan_h323 to build.
Ignore the configure change.
Modified:
team/group/media_formats/channels/chan_iax2.c
team/group/media_formats/channels/h323/ast_h323.cxx
team/group/media_formats/configure
team/group/media_formats/include/asterisk/format_compatibility.h
team/group/media_formats/main/format_compatibility.c
Modified: team/group/media_formats/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_iax2.c?view=diff&rev=411017&r1=411016&r2=411017
==============================================================================
--- team/group/media_formats/channels/chan_iax2.c (original)
+++ team/group/media_formats/channels/chan_iax2.c Sun Mar 23 16:00:44 2014
@@ -1791,7 +1791,7 @@
for (i = 0; i < ast_format_cap_count(cap); i++) {
struct ast_format *fmt = ast_format_cap_get_format(cap, i);
- ast_codec_pref_append(pref, fmt);
+ ast_codec_pref_append(pref, fmt, ast_format_cap_get_framing(cap, fmt));
ao2_ref(fmt, -1);
}
@@ -4530,7 +4530,7 @@
struct ast_format *format = ast_format_cap_get_format(
ast_channel_nativeformats(c), i);
- ast_codec_pref_prepend(&ourprefs, format, 1);
+ ast_codec_pref_prepend(&ourprefs, format, ast_format_cap_get_framing(ast_channel_nativeformats(c), format), 1);
ao2_ref(format, -1);
}
}
@@ -4564,7 +4564,7 @@
struct ast_format *tmpfmt = ast_format_cap_get_format(
ast_channel_nativeformats(c), i);
- ast_codec_pref_prepend(&ourprefs, tmpfmt, 1);
+ ast_codec_pref_prepend(&ourprefs, tmpfmt, ast_format_cap_get_framing(ast_channel_nativeformats(c), tmpfmt), 1);
ao2_ref(tmpfmt, -1);
}
}
Modified: team/group/media_formats/channels/h323/ast_h323.cxx
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/h323/ast_h323.cxx?view=diff&rev=411017&r1=411016&r2=411017
==============================================================================
--- team/group/media_formats/channels/h323/ast_h323.cxx (original)
+++ team/group/media_formats/channels/h323/ast_h323.cxx Sun Mar 23 16:00:44 2014
@@ -80,6 +80,7 @@
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/astobj.h"
+#include "asterisk/format_cache.h"
#ifdef __cplusplus
}
#endif
@@ -1717,19 +1718,19 @@
H245_TerminalCapabilitySetReject & reject)
{
struct __codec__ {
- unsigned int asterisk_codec;
+ uint64_t asterisk_codec;
unsigned int h245_cap;
const char *oid;
const char *formatName;
};
static const struct __codec__ codecs[] = {
- { AST_FORMAT_G723_1, H245_AudioCapability::e_g7231 },
- { AST_FORMAT_GSM, H245_AudioCapability::e_gsmFullRate },
- { AST_FORMAT_ULAW, H245_AudioCapability::e_g711Ulaw64k },
- { AST_FORMAT_ALAW, H245_AudioCapability::e_g711Alaw64k },
- { AST_FORMAT_G729A, H245_AudioCapability::e_g729AnnexA },
- { AST_FORMAT_G729A, H245_AudioCapability::e_g729 },
- { AST_FORMAT_G726_AAL2, H245_AudioCapability::e_nonStandard, NULL, CISCO_G726r32 },
+ { (1ULL << 0), H245_AudioCapability::e_g7231 },
+ { (1ULL << 1), H245_AudioCapability::e_gsmFullRate },
+ { (1ULL << 2), H245_AudioCapability::e_g711Ulaw64k },
+ { (1ULL << 3), H245_AudioCapability::e_g711Alaw64k },
+ { (1ULL << 8), H245_AudioCapability::e_g729AnnexA },
+ { (1ULL << 8), H245_AudioCapability::e_g729 },
+ { (1ULL << 4), H245_AudioCapability::e_nonStandard, NULL, CISCO_G726r32 },
#ifdef AST_FORMAT_MODEM
{ AST_FORMAT_MODEM, H245_DataApplicationCapability_application::e_t38fax },
#endif
@@ -1768,23 +1769,20 @@
case H323Capability::e_Audio:
for (int x = 0; codecs[x].asterisk_codec > 0; ++x) {
if ((subType == codecs[x].h245_cap) && (!codecs[x].formatName || (!strcmp(codecs[x].formatName, (const char *)remoteCapabilities[i].GetFormatName())))) {
- int ast_codec = codecs[x].asterisk_codec;
+ uint64_t ast_codec = codecs[x].asterisk_codec;
int ms = 0;
- struct ast_format tmpfmt;
- if (!(peer_capabilities & ast_format_id_to_old_bitfield((enum ast_format_id) ast_codec))) {
- struct ast_format_list format;
- ast_codec_pref_append(&prefs, ast_format_set(&tmpfmt, (enum ast_format_id) ast_codec, 0));
- format = ast_codec_pref_getsize(&prefs, &tmpfmt);
- if ((ast_codec == AST_FORMAT_ALAW) || (ast_codec == AST_FORMAT_ULAW)) {
+ if (!(peer_capabilities & ast_codec)) {
+ ast_codec_pref_append(&prefs, ast_format_compatibility_bitfield2format(ast_codec), 0);
+ if ((ast_codec == (1ULL << 3)) || (ast_codec == (1ULL << 2))) {
ms = remoteCapabilities[i].GetTxFramesInPacket();
} else
- ms = remoteCapabilities[i].GetTxFramesInPacket() * format.inc_ms;
- ast_codec_pref_setsize(&prefs, &tmpfmt, ms);
+ ms = remoteCapabilities[i].GetTxFramesInPacket() * ast_format_compatibility_bitfield2format(ast_codec)->codec->increment_ms;
+ ast_codec_pref_setsize(&prefs, ast_format_compatibility_bitfield2format(ast_codec), ms);
}
if (h323debug) {
cout << "Found peer capability " << remoteCapabilities[i] << ", Asterisk code is " << ast_codec << ", frame size (in ms) is " << ms << endl;
}
- peer_capabilities |= ast_format_id_to_old_bitfield((enum ast_format_id) ast_codec);
+ peer_capabilities |= ast_codec;
}
}
break;
@@ -1894,9 +1892,9 @@
int codec;
int x, y;
struct ast_codec_pref *prefs = (struct ast_codec_pref *)_prefs;
- struct ast_format_list format;
+ unsigned int framing;
int frames_per_packet;
- struct ast_format tmpfmt;
+ struct ast_format *tmpfmt;
H323Capability *cap;
localCapabilities.RemoveAll();
@@ -1904,7 +1902,6 @@
/* Add audio codecs in preference order first, then
audio codecs without preference as allowed by mask */
for (y = 0, x = -1; x < 32 + 32; ++x) {
- ast_format_clear(&tmpfmt);
if (x < 0)
codec = pref_codec;
else if (y || (!(ast_codec_pref_index(prefs, x, &tmpfmt)))) {
@@ -1914,67 +1911,51 @@
y <<= 1;
codec = y;
}
- if (tmpfmt.id) {
- codec = ast_format_to_old_bitfield(&tmpfmt);
- }
- if (!(caps & codec) || (alreadysent & codec) || (AST_FORMAT_GET_TYPE(ast_format_id_from_old_bitfield(codec)) != AST_FORMAT_TYPE_AUDIO))
+ if (tmpfmt) {
+ codec = ast_format_compatibility_format2bitfield(tmpfmt);
+ } else {
+ tmpfmt = ast_format_compatibility_bitfield2format(codec);
+ }
+ if (!(caps & codec) || (alreadysent & codec) || (tmpfmt->codec->type != AST_MEDIA_TYPE_AUDIO))
continue;
alreadysent |= codec;
/* format.cur_ms will be set to default if packetization is not explicitly set */
- format = ast_codec_pref_getsize(prefs, ast_format_from_old_bitfield(&tmpfmt, codec));
- frames_per_packet = (format.inc_ms ? format.cur_ms / format.inc_ms : format.cur_ms);
- switch(ast_format_id_from_old_bitfield(codec)) {
-#if 0
- case AST_FORMAT_SPEEX:
- /* Not real sure if Asterisk acutally supports all
- of the various different bit rates so add them
- all and figure it out later*/
-
- lastcap = localCapabilities.SetCapability(0, 0, new SpeexNarrow2AudioCapability());
- lastcap = localCapabilities.SetCapability(0, 0, new SpeexNarrow3AudioCapability());
- lastcap = localCapabilities.SetCapability(0, 0, new SpeexNarrow4AudioCapability());
- lastcap = localCapabilities.SetCapability(0, 0, new SpeexNarrow5AudioCapability());
- lastcap = localCapabilities.SetCapability(0, 0, new SpeexNarrow6AudioCapability());
- break;
-#endif
- case AST_FORMAT_G729A:
+ framing = ast_codec_pref_getsize(prefs, x);
+ frames_per_packet = (framing ? framing / tmpfmt->codec->increment_ms : tmpfmt->codec->default_ms);
+ if (!framing) {
+ framing = tmpfmt->codec->default_ms;
+ }
+ if (ast_format_cmp(tmpfmt, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
AST_G729ACapability *g729aCap;
AST_G729Capability *g729Cap;
lastcap = localCapabilities.SetCapability(0, 0, g729aCap = new AST_G729ACapability(frames_per_packet));
lastcap = localCapabilities.SetCapability(0, 0, g729Cap = new AST_G729Capability(frames_per_packet));
- g729aCap->SetTxFramesInPacket(format.cur_ms);
- g729Cap->SetTxFramesInPacket(format.cur_ms);
- break;
- case AST_FORMAT_G723_1:
+ g729aCap->SetTxFramesInPacket(framing);
+ g729Cap->SetTxFramesInPacket(framing);
+ } else if (ast_format_cmp(tmpfmt, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
AST_G7231Capability *g7231Cap;
lastcap = localCapabilities.SetCapability(0, 0, g7231Cap = new AST_G7231Capability(frames_per_packet, TRUE));
- g7231Cap->SetTxFramesInPacket(format.cur_ms);
+ g7231Cap->SetTxFramesInPacket(framing);
lastcap = localCapabilities.SetCapability(0, 0, g7231Cap = new AST_G7231Capability(frames_per_packet, FALSE));
- g7231Cap->SetTxFramesInPacket(format.cur_ms);
- break;
- case AST_FORMAT_GSM:
+ g7231Cap->SetTxFramesInPacket(framing);
+ } else if (ast_format_cmp(tmpfmt, ast_format_gsm) == AST_FORMAT_CMP_EQUAL) {
AST_GSM0610Capability *gsmCap;
lastcap = localCapabilities.SetCapability(0, 0, gsmCap = new AST_GSM0610Capability(frames_per_packet));
- gsmCap->SetTxFramesInPacket(format.cur_ms);
- break;
- case AST_FORMAT_ULAW:
+ gsmCap->SetTxFramesInPacket(framing);
+ } else if (ast_format_cmp(tmpfmt, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
AST_G711Capability *g711uCap;
- lastcap = localCapabilities.SetCapability(0, 0, g711uCap = new AST_G711Capability(format.cur_ms, H323_G711Capability::muLaw));
- g711uCap->SetTxFramesInPacket(format.cur_ms);
- break;
- case AST_FORMAT_ALAW:
+ lastcap = localCapabilities.SetCapability(0, 0, g711uCap = new AST_G711Capability(framing, H323_G711Capability::muLaw));
+ g711uCap->SetTxFramesInPacket(framing);
+ } else if (ast_format_cmp(tmpfmt, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
AST_G711Capability *g711aCap;
- lastcap = localCapabilities.SetCapability(0, 0, g711aCap = new AST_G711Capability(format.cur_ms, H323_G711Capability::ALaw));
- g711aCap->SetTxFramesInPacket(format.cur_ms);
- break;
- case AST_FORMAT_G726_AAL2:
+ lastcap = localCapabilities.SetCapability(0, 0, g711aCap = new AST_G711Capability(framing, H323_G711Capability::ALaw));
+ g711aCap->SetTxFramesInPacket(framing);
+ } else if (ast_format_cmp(tmpfmt, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL) {
AST_CiscoG726Capability *g726Cap;
lastcap = localCapabilities.SetCapability(0, 0, g726Cap = new AST_CiscoG726Capability(frames_per_packet));
- g726Cap->SetTxFramesInPacket(format.cur_ms);
- break;
- default:
+ g726Cap->SetTxFramesInPacket(framing);
+ } else {
alreadysent &= ~codec;
- break;
}
}
Modified: team/group/media_formats/include/asterisk/format_compatibility.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_compatibility.h?view=diff&rev=411017&r1=411016&r2=411017
==============================================================================
--- team/group/media_formats/include/asterisk/format_compatibility.h (original)
+++ team/group/media_formats/include/asterisk/format_compatibility.h Sun Mar 23 16:00:44 2014
@@ -34,6 +34,8 @@
struct ast_codec_pref {
/*! This array is ordered by preference and contains the codec bitfield. */
uint64_t order[AST_CODEC_PREF_SIZE];
+ /*! Framing size of the codec */
+ unsigned int framing[AST_CODEC_PREF_SIZE];
};
/*!
@@ -100,6 +102,9 @@
*/
struct ast_format *ast_codec_pref_index(struct ast_codec_pref *pref, int index, struct ast_format **result);
+/*! \brief Convert a preference structure to a capabilities structure */
+void ast_codec_pref_to_cap(struct ast_codec_pref *pref, struct ast_format_cap *cap);
+
/*! \brief Remove audio a codec from a preference list */
void ast_codec_pref_remove(struct ast_codec_pref *pref, struct ast_format *format);
@@ -108,11 +113,20 @@
/*! \brief Append a audio codec to a preference list, removing it first if it was already there
*/
-int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format);
+int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format, unsigned int framing);
/*! \brief Prepend an audio codec to a preference list, removing it first if it was already there
*/
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, int only_if_existing);
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, unsigned int framing,
+ int only_if_existing);
+
+/*! \brief Get packet size for codec
+*/
+unsigned int ast_codec_pref_getsize(struct ast_codec_pref *pref, int index);
+
+/*! \brief Set packet size for codec
+*/
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_format *format, int framems);
/*! \brief Shift an audio codec preference list up or down 65 bytes so that it becomes an ASCII string
* \note Due to a misunderstanding in how codec preferences are stored, this
Modified: team/group/media_formats/main/format_compatibility.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/main/format_compatibility.c?view=diff&rev=411017&r1=411016&r2=411017
==============================================================================
--- team/group/media_formats/main/format_compatibility.c (original)
+++ team/group/media_formats/main/format_compatibility.c Sun Mar 23 16:00:44 2014
@@ -312,6 +312,18 @@
return *result;
}
+void ast_codec_pref_to_cap(struct ast_codec_pref *pref, struct ast_format_cap *cap)
+{
+ int idx;
+
+ for (idx = 0; idx < sizeof(pref->order); idx++) {
+ if (!pref->order[idx]) {
+ break;
+ }
+ ast_format_cap_add(cap, ast_format_compatibility_bitfield2format(pref->order[idx]), pref->framing[idx]);
+ }
+}
+
int ast_codec_pref_string(struct ast_codec_pref *pref, char *buf, size_t size)
{
int x;
@@ -371,7 +383,7 @@
}
/*! \brief Append codec to list */
-int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format)
+int ast_codec_pref_append(struct ast_codec_pref *pref, struct ast_format *format, unsigned int framing)
{
uint64_t bitfield = ast_format_compatibility_format2bitfield(format);
int x;
@@ -381,6 +393,7 @@
for (x = 0; x < AST_CODEC_PREF_SIZE; x++) {
if (!pref->order[x]) {
pref->order[x] = bitfield;
+ pref->framing[x] = framing;
break;
}
}
@@ -389,7 +402,8 @@
}
/*! \brief Prepend codec to list */
-void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, int only_if_existing)
+void ast_codec_pref_prepend(struct ast_codec_pref *pref, struct ast_format *format, unsigned int framing,
+ int only_if_existing)
{
uint64_t bitfield = ast_format_compatibility_format2bitfield(format);
int x;
@@ -413,10 +427,39 @@
or as far as the existing location (which will be overwritten) */
for (; x > 0; x--) {
pref->order[x] = pref->order[x - 1];
+ pref->framing[x] = pref->framing[x - 1];
}
/* And insert the new entry */
pref->order[0] = bitfield;
+ pvt->framing[0] = framing;
+}
+
+unsigned int ast_codec_pref_getsize(struct ast_codec_pref *pref, int index)
+{
+ if ((idx >= 0) && (idx < sizeof(pref->order)) && pref->order[idx]) {
+ return pref->framing[idx];
+ } else {
+ return 0;
+ }
+}
+
+int ast_codec_pref_setsize(struct ast_codec_pref *pref, struct ast_format *format, int framems)
+{
+ int idx;
+
+ for (idx = 0; idx < sizeof(pref->order); idx++) {
+ if (!pref->order[idx]) {
+ break;
+ } else if (ast_format_cmp(ast_format_compatibility_bitfield2format(pref->order[idx]),
+ format) != AST_FORMAT_CMP_EQUAL) {
+ continue;
+ }
+ pref->framing[idx] = framems;
+ return 0;
+ }
+
+ return -1;
}
void ast_codec_pref_convert(struct ast_codec_pref *pref, char *buf, size_t size, int right)
More information about the svn-commits
mailing list