[svn-commits] file: branch file/mf-attributes r417754 - in /team/file/mf-attributes: ./ add...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Jul 2 06:58:18 CDT 2014
Author: file
Date: Wed Jul 2 06:58:12 2014
New Revision: 417754
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417754
Log:
rtp_engine: Update APIs/RTP stack to handle packetization
Primarily, this patch does the following:
(1) Removes ast_rtp_codecs_packetization_set. This call was effectively a NoOp
with res_rtp_asterisk/res_rtp_multicast. The various channel drivers now
call ast_rtp_codecs_set_framing where appropriate.
(2) A major overhaul of ast_rtp_codec and its corresponding APIs was done.
This includes:
(a) Storing the framing on the structure. This allows for the smoother in
res_rtp_asterisk to easily get the framing specified without having to do
major gyrations.
(b) Payload types (which are ao2 ref counted objects) are no longer stored in
an ao2_container. This container had two patterns of usage: lookups by an
integer key value and iteration. Vectors work well for this type of access
and - for relatively small numbers of items (which is generally the case
for payload types), are much faster on both counts.
(3) The 'use_ptime' setting in res_pjsip_sdp_rtp now works. Packetization is
also handled a little bit better, as both the RTP engine and format_cap API
already do the job of managing the framing.
A variety of ref leaks were cleaned up as well along the way.
Review: https://reviewboard.asterisk.org/r/3687/
........
Merged revisions 417740 from http://svn.asterisk.org/svn/asterisk/team/group/media_formats-reviewed-trunk
Modified:
team/file/mf-attributes/ (props changed)
team/file/mf-attributes/addons/chan_ooh323.c
team/file/mf-attributes/addons/ooh323cDriver.c
team/file/mf-attributes/bridges/bridge_native_rtp.c
team/file/mf-attributes/bridges/bridge_softmix.c
team/file/mf-attributes/channels/chan_gtalk.c
team/file/mf-attributes/channels/chan_h323.c
team/file/mf-attributes/channels/chan_iax2.c
team/file/mf-attributes/channels/chan_jingle.c
team/file/mf-attributes/channels/chan_motif.c
team/file/mf-attributes/channels/chan_sip.c
team/file/mf-attributes/channels/chan_skinny.c
team/file/mf-attributes/formats/format_h263.c
team/file/mf-attributes/formats/format_h264.c
team/file/mf-attributes/include/asterisk/format.h
team/file/mf-attributes/include/asterisk/format_cap.h
team/file/mf-attributes/include/asterisk/frame.h
team/file/mf-attributes/include/asterisk/rtp_engine.h
team/file/mf-attributes/include/asterisk/vector.h
team/file/mf-attributes/main/format.c
team/file/mf-attributes/main/format_cap.c
team/file/mf-attributes/main/rtp_engine.c
team/file/mf-attributes/res/res_fax.c
team/file/mf-attributes/res/res_pjsip_sdp_rtp.c
team/file/mf-attributes/res/res_rtp_asterisk.c
team/file/mf-attributes/res/res_speech.c
team/file/mf-attributes/tests/test_format_cap.c
Propchange: team/file/mf-attributes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jul 2 06:58:12 2014
@@ -1,1 +1,1 @@
-/team/group/media_formats-reviewed-trunk:1-417733
+/team/group/media_formats-reviewed-trunk:1-417753
Modified: team/file/mf-attributes/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/addons/chan_ooh323.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/addons/chan_ooh323.c (original)
+++ team/file/mf-attributes/addons/chan_ooh323.c Wed Jul 2 06:58:12 2014
@@ -1548,12 +1548,7 @@
ast_verb(0, "Writeformat before update %s/%s\n",
ast_format_get_name(ast_channel_writeformat(p->owner)),
ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- if (txframes)
- ast_codec_pref_setsize(&p->prefs, fmt, txframes);
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
-#endif
+
if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp),
p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
@@ -1563,6 +1558,9 @@
p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
}
+ if (txframes) {
+ ast_format_cap_set_framing(caps, txframes);
+ }
ast_format_cap_add(caps, fmt, 0);
ast_channel_nativeformats_set(p->owner, caps);
ao2_ref(caps, -1);
@@ -4591,10 +4589,10 @@
ast_channel_unlock(p->owner);
if (p->rtp) {
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
-#endif
+ if (p->cap) {
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(p->rtp),
+ ast_format_cap_get_framing(p->cap));
+ }
if (p->nat) {
ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_NAT, 1);
}
Modified: team/file/mf-attributes/addons/ooh323cDriver.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/addons/ooh323cDriver.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/addons/ooh323cDriver.c (original)
+++ team/file/mf-attributes/addons/ooh323cDriver.c Wed Jul 2 06:58:12 2014
@@ -415,7 +415,7 @@
ast_verb(0, "\tAdding g711 ulaw capability to call(%s, %s)\n",
call->callType, call->callToken);
}
- txframes = ast_format_cap_get_framing(cap, format);
+ txframes = ast_format_cap_get_format_framing(cap, format);
ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes,
txframes, OORXANDTX,
&ooh323c_start_receive_channel,
@@ -429,7 +429,7 @@
ast_verb(0, "\tAdding g711 alaw capability to call(%s, %s)\n",
call->callType, call->callToken);
}
- txframes = ast_format_cap_get_framing(cap, format);
+ txframes = ast_format_cap_get_format_framing(cap, format);
ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes,
txframes, OORXANDTX,
&ooh323c_start_receive_channel,
@@ -444,7 +444,7 @@
ast_verb(0, "\tAdding g726 capability to call (%s, %s)\n",
call->callType, call->callToken);
}
- txframes = ast_format_cap_get_framing(cap, format);
+ txframes = ast_format_cap_get_format_framing(cap, format);
ret = ooCallAddG726Capability(call, OO_G726, txframes, grxframes, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
@@ -459,7 +459,7 @@
ast_verb(0, "\tAdding g726aal2 capability to call (%s, %s)\n",
call->callType, call->callToken);
}
- txframes = ast_format_cap_get_framing(cap, format);
+ txframes = ast_format_cap_get_format_framing(cap, format);
ret = ooCallAddG726Capability(call, OO_G726AAL2, txframes, grxframes, FALSE,
OORXANDTX, &ooh323c_start_receive_channel,
&ooh323c_start_transmit_channel,
@@ -471,7 +471,7 @@
if(ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL)
{
- txframes = (ast_format_cap_get_framing(cap, format))/10;
+ txframes = (ast_format_cap_get_format_framing(cap, format))/10;
if (gH323Debug) {
ast_verb(0, "\tAdding g729A capability to call(%s, %s)\n",
call->callType, call->callToken);
Modified: team/file/mf-attributes/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/bridges/bridge_native_rtp.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/bridges/bridge_native_rtp.c (original)
+++ team/file/mf-attributes/bridges/bridge_native_rtp.c Wed Jul 2 06:58:12 2014
@@ -383,10 +383,10 @@
return 0;
}
- read_ptime0 = ast_format_cap_get_framing(cap0, ast_channel_rawreadformat(c0->chan));
- read_ptime1 = ast_format_cap_get_framing(cap1, ast_channel_rawreadformat(c1->chan));
- write_ptime0 = ast_format_cap_get_framing(cap0, ast_channel_rawwriteformat(c0->chan));
- write_ptime1 = ast_format_cap_get_framing(cap1, ast_channel_rawwriteformat(c1->chan));
+ read_ptime0 = ast_format_cap_get_format_framing(cap0, ast_channel_rawreadformat(c0->chan));
+ read_ptime1 = ast_format_cap_get_format_framing(cap1, ast_channel_rawreadformat(c1->chan));
+ write_ptime0 = ast_format_cap_get_format_framing(cap0, ast_channel_rawwriteformat(c0->chan));
+ write_ptime1 = ast_format_cap_get_format_framing(cap1, ast_channel_rawwriteformat(c1->chan));
if (read_ptime0 != write_ptime1 || read_ptime1 != write_ptime0) {
ast_debug(1, "Packetization differs between RTP streams (%d != %d or %d != %d). Cannot native bridge in RTP\n",
Modified: team/file/mf-attributes/bridges/bridge_softmix.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/bridges/bridge_softmix.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/bridges/bridge_softmix.c (original)
+++ team/file/mf-attributes/bridges/bridge_softmix.c Wed Jul 2 06:58:12 2014
@@ -511,7 +511,7 @@
ast_mutex_lock(&sc->lock);
ast_bridge_update_talker_src_video_mode(bridge, bridge_channel->chan,
sc->video_talker.energy_average,
- frame->subclass.video.frame_ending);
+ frame->subclass.frame_ending);
ast_mutex_unlock(&sc->lock);
video_src_priority = ast_bridge_is_video_src(bridge, bridge_channel->chan);
if (video_src_priority == 1) {
Modified: team/file/mf-attributes/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_gtalk.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_gtalk.c (original)
+++ team/file/mf-attributes/channels/chan_gtalk.c Wed Jul 2 06:58:12 2014
@@ -658,10 +658,6 @@
continue;
}
- ast_rtp_codecs_payloads_set_m_type(
- ast_rtp_instance_get_codecs(tmp->rtp),
- tmp->rtp,
- atoi(codec_id));
ast_rtp_codecs_payloads_set_rtpmap_type(
ast_rtp_instance_get_codecs(tmp->rtp),
tmp->rtp,
@@ -1156,16 +1152,14 @@
what = global_capability;
}
- /* Set Frame packetization */
-// BUGBUG
-// if (i->rtp) {
-// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
-// }
-
tmpfmt = ast_format_cap_get_format(what, 0);
ast_format_cap_add(caps, tmpfmt, 0);
ast_format_cap_append_by_type(caps, i->jointcap, AST_MEDIA_TYPE_VIDEO);
ast_channel_nativeformats_set(tmp, caps);
+ if (i->rtp) {
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(i->rtp),
+ ast_format_cap_get_format_framing(caps, tmpfmt));
+ }
ao2_ref(caps, -1);
if (i->rtp) {
@@ -1375,10 +1369,6 @@
continue;
}
if (!strcmp(S_OR(iks_name(codec), ""), "vid:payload-type") && p->vrtp) {
- ast_rtp_codecs_payloads_set_m_type(
- ast_rtp_instance_get_codecs(p->vrtp),
- p->vrtp,
- atoi(codec_id));
ast_rtp_codecs_payloads_set_rtpmap_type(
ast_rtp_instance_get_codecs(p->vrtp),
p->vrtp,
@@ -1387,10 +1377,6 @@
codec_name,
0);
} else {
- ast_rtp_codecs_payloads_set_m_type(
- ast_rtp_instance_get_codecs(p->rtp),
- p->rtp,
- atoi(codec_id));
ast_rtp_codecs_payloads_set_rtpmap_type(
ast_rtp_instance_get_codecs(p->rtp),
p->rtp,
Modified: team/file/mf-attributes/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_h323.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_h323.c (original)
+++ team/file/mf-attributes/channels/chan_h323.c Wed Jul 2 06:58:12 2014
@@ -1046,11 +1046,17 @@
if (pvt->dtmf_pt[1] > 0)
ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, pvt->dtmf_pt[1], "audio", "cisco-telephone-event", 0);
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- if (pvt->peercapability)
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, &pvt->peer_prefs);
-#endif
+ if (pvt->peercapability) {
+ unsigned int framing = UINT_MAX;
+
+ for (i = 0; i < AST_CODEC_PREF_SIZE; ++i) {
+ if (pvt->peer_prefs.framing[i]) {
+ framing = MIN(framing, pvt->peer_prefs.framing[i]);
+ }
+ }
+
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(pvt->rtp), framing);
+ }
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
ast_jb_configure(pvt->owner, &global_jbconf);
@@ -2129,13 +2135,14 @@
/* Change native format to reflect information taken from OLC/OLCAck */
nativeformats_changed = 0;
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
- struct ast_rtp_payload_type rtptype = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(pvt->rtp), pt);
- if (rtptype.asterisk_format) {
- if (pvt->nativeformats != ast_format_compatibility_format2bitfield(&rtptype.format)) {
- pvt->nativeformats = ast_format_compatibility_format2bitfield(&rtptype.format);
+ struct ast_rtp_payload_type *rtptype = ast_rtp_codecs_get_payload(ast_rtp_instance_get_codecs(pvt->rtp), pt);
+ if (rtptype && rtptype->asterisk_format) {
+ if (pvt->nativeformats != ast_format_compatibility_format2bitfield(&rtptype->format)) {
+ pvt->nativeformats = ast_format_compatibility_format2bitfield(&rtptype->format);
nativeformats_changed = 1;
}
}
+ ao2_cleanup(rtptype);
} else if (h323debug)
ast_log(LOG_NOTICE, "Payload type is unknown, formats isn't changed\n");
@@ -2603,25 +2610,29 @@
if (h323debug) {
int i;
struct ast_format *fmt;
- for (i = 0; i < 32; ++i) {
+ for (i = 0; i < AST_CODEC_PREF_SIZE; ++i) {
if (!prefs->order[i])
break;
ast_debug(1, "prefs[%d]=%s\n", i, ast_format_get_name(ast_codec_pref_index(prefs, i, &fmt)));
}
}
if (pvt->rtp) {
- if (pvt->options.autoframing) {
- ast_debug(2, "Autoframing option set, using peer's packetization settings\n");
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, &pvt->peer_prefs);
-#endif
- } else {
- ast_debug(2, "Autoframing option not set, ignoring peer's packetization settings\n");
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(pvt->rtp), pvt->rtp, &pvt->options.prefs);
-#endif
+ struct ast_codec_pref *framing_prefs = pvt->options.autoframing ? &pvt->peer_prefs : &pvt->options.prefs;
+ int i;
+ unsigned int framing = UINT_MAX;
+
+ for (i = 0; i < AST_CODEC_PREF_SIZE; ++i) {
+ if (framing_prefs->framing[i]) {
+ framing = MIN(framing, framing_prefs->framing[i]);
+ }
+ }
+
+ if (framing != UINT_MAX && pvt->options.autoframing) {
+ ast_debug(2, "Autoframing option set, using peer's packetization settings (%d)\n", framing);
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(pvt->rtp), framing);
+ } else if (framing != UINT_MAX) {
+ ast_debug(2, "Autoframing option not set, ignoring peer's packetization settings (%d)\n", framing);
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(pvt->rtp), framing);
}
}
}
Modified: team/file/mf-attributes/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_iax2.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_iax2.c (original)
+++ team/file/mf-attributes/channels/chan_iax2.c Wed Jul 2 06:58:12 2014
@@ -1887,8 +1887,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_format_cap_get_framing(cap, fmt));
+ ast_codec_pref_append(pref, fmt, ast_format_cap_get_format_framing(cap, fmt));
ao2_ref(fmt, -1);
}
@@ -4626,8 +4625,7 @@
for (i = 0; i < ast_format_cap_count(ast_channel_nativeformats(c)); i++) {
struct ast_format *format = ast_format_cap_get_format(
ast_channel_nativeformats(c), i);
-
- ast_codec_pref_prepend(&ourprefs, format, ast_format_cap_get_framing(ast_channel_nativeformats(c), format), 1);
+ ast_codec_pref_prepend(&ourprefs, format, ast_format_cap_get_format_framing(ast_channel_nativeformats(c), format), 1);
ao2_ref(format, -1);
}
}
@@ -4660,8 +4658,7 @@
for (i = 0; i < ast_format_cap_count(ast_channel_nativeformats(c)); i++) {
struct ast_format *tmpfmt = ast_format_cap_get_format(
ast_channel_nativeformats(c), i);
-
- ast_codec_pref_prepend(&ourprefs, tmpfmt, ast_format_cap_get_framing(ast_channel_nativeformats(c), tmpfmt), 1);
+ ast_codec_pref_prepend(&ourprefs, tmpfmt, ast_format_cap_get_format_framing(ast_channel_nativeformats(c), tmpfmt), 1);
ao2_ref(tmpfmt, -1);
}
}
@@ -6592,7 +6589,7 @@
if (fr->af.frametype == AST_FRAME_VIDEO) {
iax2_format tmpfmt = ast_format_compatibility_format2bitfield(fr->af.subclass.format);
- tmpfmt |= fr->af.subclass.video.frame_ending ? 0x1LL : 0;
+ tmpfmt |= fr->af.subclass.frame_ending ? 0x1LL : 0;
fh->csub = compress_subclass(tmpfmt | ((tmpfmt & 0x1LL) << 6));
} else if (fr->af.frametype == AST_FRAME_VOICE) {
fh->csub = compress_subclass(ast_format_compatibility_format2bitfield(fr->af.subclass.format));
@@ -6651,7 +6648,7 @@
vh = (struct ast_iax2_video_hdr *)(fr->af.data.ptr - sizeof(struct ast_iax2_video_hdr));
vh->zeros = 0;
vh->callno = htons(0x8000 | fr->callno);
- vh->ts = htons((fr->ts & 0x7FFF) | (fr->af.subclass.video.frame_ending ? 0x8000 : 0));
+ vh->ts = htons((fr->ts & 0x7FFF) | (fr->af.subclass.frame_ending ? 0x8000 : 0));
fr->datalen = fr->af.datalen + sizeof(struct ast_iax2_video_hdr);
fr->data = vh;
fr->retries = -1;
@@ -10106,7 +10103,7 @@
if (f.frametype == AST_FRAME_VIDEO) {
f.subclass.format = ast_format_compatibility_bitfield2format(uncompress_subclass(fh->csub & ~0x40));
if ((fh->csub >> 6) & 0x1) {
- f.subclass.video.frame_ending = 1;
+ f.subclass.frame_ending = 1;
}
} else if (f.frametype == AST_FRAME_VOICE) {
f.subclass.format = ast_format_compatibility_bitfield2format(uncompress_subclass(fh->csub));
@@ -11702,7 +11699,7 @@
f.frametype = AST_FRAME_VIDEO;
if (iaxs[fr->callno]->videoformat > 0) {
if (ntohs(vh->ts) & 0x8000LL) {
- f.subclass.video.frame_ending = 1;
+ f.subclass.frame_ending = 1;
}
f.subclass.format = ast_format_compatibility_bitfield2format(iaxs[fr->callno]->videoformat);
} else {
Modified: team/file/mf-attributes/channels/chan_jingle.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_jingle.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_jingle.c (original)
+++ team/file/mf-attributes/channels/chan_jingle.c Wed Jul 2 06:58:12 2014
@@ -876,15 +876,13 @@
else
what = global_capability;
- /* Set Frame packetization */
-// BUGBUG
-// if (i->rtp)
-// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
-
tmpfmt = ast_format_cap_get_format(what, 0);
ast_format_cap_add(caps, tmpfmt, 0);
ast_format_cap_append_by_type(caps, i->jointcap, AST_MEDIA_TYPE_VIDEO);
ast_channel_nativeformats_set(tmp, caps);
+ if (i->rtp) {
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(i->rtp), ast_format_cap_get_format_framing(i->cap, tmpfmt));
+ }
ao2_ref(caps, -1);
if (i->rtp) {
@@ -1084,7 +1082,6 @@
ast_copy_string(p->audio_content_name, iks_find_attrib(content, "name"), sizeof(p->audio_content_name));
while (codec) {
- ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")));
ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
@@ -1100,7 +1097,6 @@
ast_copy_string(p->video_content_name, iks_find_attrib(content, "name"), sizeof(p->video_content_name));
while (codec) {
- ast_rtp_codecs_payloads_set_m_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")));
ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp), p->rtp, atoi(iks_find_attrib(codec, "id")), "audio", iks_find_attrib(codec, "name"), 0);
codec = iks_next(codec);
}
Modified: team/file/mf-attributes/channels/chan_motif.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_motif.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_motif.c (original)
+++ team/file/mf-attributes/channels/chan_motif.c Wed Jul 2 06:58:12 2014
@@ -693,8 +693,8 @@
ast_rtp_instance_set_channel_id(session->vrtp, ast_channel_uniqueid(session->owner));
ast_channel_set_fd(session->owner, 2, ast_rtp_instance_fd(session->vrtp, 0));
ast_channel_set_fd(session->owner, 3, ast_rtp_instance_fd(session->vrtp, 1));
-// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session->vrtp), session->vrtp, &session->prefs);
-
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(session->vrtp),
+ ast_format_cap_get_framing(session->cap));
if (session->transport == JINGLE_TRANSPORT_GOOGLE_V2 && (ice = ast_rtp_instance_get_ice(session->vrtp))) {
ice->stop(session->vrtp);
}
@@ -801,14 +801,13 @@
ast_channel_nativeformats_set(chan, caps);
ao2_ref(caps, -1);
- tmpfmt = ast_format_cap_get_format(session->cap, 0);
-
if (session->rtp) {
struct ast_rtp_engine_ice *ice;
ast_channel_set_fd(chan, 0, ast_rtp_instance_fd(session->rtp, 0));
ast_channel_set_fd(chan, 1, ast_rtp_instance_fd(session->rtp, 1));
-// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(session->rtp), session->rtp, &session->prefs);
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(session->rtp),
+ ast_format_cap_get_framing(session->cap));
if (((session->transport == JINGLE_TRANSPORT_GOOGLE_V2) ||
(session->transport == JINGLE_TRANSPORT_GOOGLE_V1)) &&
@@ -824,11 +823,11 @@
ast_channel_adsicpe_set(chan, AST_ADSI_UNAVAILABLE);
+ tmpfmt = ast_format_cap_get_format(session->cap, 0);
ast_channel_set_writeformat(chan, tmpfmt);
ast_channel_set_rawwriteformat(chan, tmpfmt);
ast_channel_set_readformat(chan, tmpfmt);
ast_channel_set_rawreadformat(chan, tmpfmt);
-
ao2_ref(tmpfmt, -1);
ao2_lock(endpoint);
@@ -2093,8 +2092,6 @@
int rtp_id, rtp_clockrate;
if (!ast_strlen_zero(id) && !ast_strlen_zero(name) && (sscanf(id, "%30d", &rtp_id) == 1)) {
- ast_rtp_codecs_payloads_set_m_type(&codecs, NULL, rtp_id);
-
if (!ast_strlen_zero(clockrate) && (sscanf(clockrate, "%30d", &rtp_clockrate) == 1)) {
ast_rtp_codecs_payloads_set_rtpmap_type_rate(&codecs, NULL, rtp_id, media, name, 0, rtp_clockrate);
} else {
Modified: team/file/mf-attributes/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_sip.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_sip.c (original)
+++ team/file/mf-attributes/channels/chan_sip.c Wed Jul 2 06:58:12 2014
@@ -6106,11 +6106,8 @@
ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF, ast_test_flag(&dialog->flags[0], SIP_DTMF) == SIP_DTMF_RFC2833);
ast_rtp_instance_set_prop(dialog->rtp, AST_RTP_PROPERTY_DTMF_COMPENSATE, ast_test_flag(&dialog->flags[1], SIP_PAGE2_RFC2833_COMPENSATE));
/* Set Frame packetization */
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(dialog->rtp), dialog->rtp, &dialog->prefs);
-#endif
dialog->autoframing = peer->autoframing;
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(dialog->rtp), ast_format_cap_get_framing(dialog->caps));
}
/* XXX TODO: get fields directly from peer only as they are needed using dialog->relatedpeer */
@@ -10084,7 +10081,9 @@
int peernoncodeccapability = 0, vpeernoncodeccapability = 0, tpeernoncodeccapability = 0;
- struct ast_rtp_codecs newaudiortp = { 0, }, newvideortp = { 0, }, newtextrtp = { 0, };
+ struct ast_rtp_codecs newaudiortp = AST_RTP_CODECS_NULL_INIT;
+ struct ast_rtp_codecs newvideortp = AST_RTP_CODECS_NULL_INIT;
+ struct ast_rtp_codecs newtextrtp = AST_RTP_CODECS_NULL_INIT;
struct ast_format_cap *newjointcapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT); /* Negotiated capability */
struct ast_format_cap *newpeercapability = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
int newnoncodeccapability;
@@ -10766,7 +10765,7 @@
unsigned int framing;
tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0);
- framing = ast_format_cap_get_framing(p->jointcaps, tmp_fmt);
+ framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt);
ast_format_cap_remove_bytype(p->jointcaps, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_add(p->jointcaps, tmp_fmt, framing);
ao2_ref(tmp_fmt, -1);
@@ -10945,16 +10944,16 @@
ast_getformatname_multiple(s2, SIPBUFSIZE, ast_channel_nativeformats(p->owner)));
}
- tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0);
- framing = ast_format_cap_get_framing(p->jointcaps, tmp_fmt);
-
caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (caps) {
+ tmp_fmt = ast_format_cap_get_format(p->jointcaps, 0);
+ framing = ast_format_cap_get_format_framing(p->jointcaps, tmp_fmt);
ast_format_cap_add(caps, tmp_fmt, framing);
ast_format_cap_append_by_type(caps, vpeercapability, AST_MEDIA_TYPE_VIDEO);
ast_format_cap_append_by_type(caps, tpeercapability, AST_MEDIA_TYPE_TEXT);
ast_channel_nativeformats_set(p->owner, caps);
ao2_ref(caps, -1);
+ ao2_ref(tmp_fmt, -1);
}
ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
@@ -11246,21 +11245,11 @@
ast_debug(1, "Can't read framing from SDP: %s\n", a);
}
}
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
+
if (framing && p->autoframing) {
- struct ast_codec_pref *pref = &ast_rtp_instance_get_codecs(p->rtp)->pref;
- int codec_n;
- for (codec_n = 0; codec_n < AST_RTP_MAX_PT; codec_n++) {
- struct ast_rtp_payload_type format = ast_rtp_codecs_payload_lookup(ast_rtp_instance_get_codecs(p->rtp), codec_n);
- if (!format.asterisk_format) /* non-codec or not found */
- continue;
- ast_debug(1, "Setting framing for %s to %ld\n", ast_getformatname(&format.format), framing);
- ast_codec_pref_setsize(pref, &format.format, framing);
- }
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, pref);
- }
-#endif
+ ast_debug(1, "Setting framing to %ld\n", framing);
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(p->rtp), framing);
+ }
found = TRUE;
} else if (sscanf(a, "rtpmap: %30u %127[^/]/%30u", &codec, mimeSubtype, &sample_rate) == 3) {
/* We have a rtpmap to handle */
@@ -12960,7 +12949,7 @@
ast_format_sdp_generate(format, rtp_code, a_buf);
- framing = ast_format_cap_get_framing(p->caps, format);
+ framing = ast_format_cap_get_format_framing(p->caps, format);
if (ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
/* Indicate that we don't support VAD (G.729 annex B) */
@@ -13830,10 +13819,7 @@
if (p->rtp) {
if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
ast_debug(1, "Setting framing from config on incoming call\n");
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
-#endif
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(p->rtp), ast_format_cap_get_framing(p->caps));
}
ast_rtp_instance_activate(p->rtp);
try_suggested_sip_codec(p);
@@ -18511,13 +18497,9 @@
peer->name, of, ast_sockaddr_stringify(&p->recv));
}
- /* XXX what about p->prefs = peer->prefs; ? */
/* Set Frame packetization */
if (p->rtp) {
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &peer->prefs);
-#endif
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(p->rtp), ast_format_cap_get_framing(peer->caps));
p->autoframing = peer->autoframing;
}
@@ -18662,10 +18644,7 @@
p->rtpkeepalive = peer->rtpkeepalive;
if (!dialog_initialize_rtp(p)) {
if (p->rtp) {
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &peer->prefs);
-#endif
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(p->rtp), ast_format_cap_get_framing(peer->caps));
p->autoframing = peer->autoframing;
}
} else {
Modified: team/file/mf-attributes/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/channels/chan_skinny.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/channels/chan_skinny.c (original)
+++ team/file/mf-attributes/channels/chan_skinny.c Wed Jul 2 06:58:12 2014
@@ -2653,7 +2653,7 @@
return;
tmpfmt = ast_format_cap_get_format(l->cap, 0);
- framing = ast_format_cap_get_framing(l->cap, tmpfmt);
+ framing = ast_format_cap_get_format_framing(l->cap, tmpfmt);
req->data.openreceivechannel.conferenceId = htolel(sub->callid);
req->data.openreceivechannel.partyId = htolel(sub->callid);
@@ -3667,7 +3667,7 @@
SKINNY_DEBUG(DEBUG_AUDIO, 4, "Peerip = %s:%d\n", ast_inet_ntoa(them.sin_addr), ntohs(them.sin_port));
tmpfmt = ast_format_cap_get_format(l->cap, 0);
- framing = ast_format_cap_get_framing(l->cap, tmpfmt);
+ framing = ast_format_cap_get_format_framing(l->cap, tmpfmt);
SKINNY_DEBUG(DEBUG_AUDIO, 4, "Setting payloadType to '%s' (%d ms)\n", ast_format_get_name(tmpfmt), framing);
@@ -4790,17 +4790,14 @@
if (sub->rtp) {
ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, l->nat);
+ /* Set frame packetization */
+ ast_rtp_codecs_set_framing(ast_rtp_instance_get_codecs(sub->rtp),
+ ast_format_cap_get_framing(l->cap));
}
if (sub->vrtp) {
ast_rtp_instance_set_qos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_NAT, l->nat);
}
- /* Set Frame packetization */
- /* BUGBUG: RTP - Needs to be updated if API changes */
-#if 0
- if (sub->rtp)
- ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, &l->prefs);
-#endif
/* Create the RTP connection */
transmit_connect(d, sub);
@@ -6922,7 +6919,7 @@
SKINNY_DEBUG(DEBUG_PACKET, 4, "asterisk ipaddr = %s:%d\n", ast_inet_ntoa(us.sin_addr), ntohs(us.sin_port));
tmpfmt = ast_format_cap_get_format(l->cap, 0);
- framing = ast_format_cap_get_framing(l->cap, tmpfmt);
+ framing = ast_format_cap_get_format_framing(l->cap, tmpfmt);
SKINNY_DEBUG(DEBUG_PACKET, 4, "Setting payloadType to '%s' (%d ms)\n", ast_format_get_name(tmpfmt), framing);
Modified: team/file/mf-attributes/formats/format_h263.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/formats/format_h263.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/formats/format_h263.c (original)
+++ team/file/mf-attributes/formats/format_h263.c Wed Jul 2 06:58:12 2014
@@ -49,6 +49,8 @@
* ridiculously large). */
#define BUF_SIZE 32768 /* Four real h.263 Frames */
+#define FRAME_ENDED 0x8000
+
struct h263_desc {
unsigned int lastts;
};
@@ -77,7 +79,7 @@
if ((res = fread(&len, 1, sizeof(len), s->f)) < 1)
return NULL;
len = ntohs(len);
- mark = (len & 0x8000) ? 1 : 0;
+ mark = (len & FRAME_ENDED) ? 1 : 0;
len &= 0x7fff;
if (len > BUF_SIZE) {
ast_log(LOG_WARNING, "Length %d is too long\n", len);
@@ -91,7 +93,7 @@
}
s->fr.samples = fs->lastts; /* XXX what ? */
s->fr.datalen = len;
- s->fr.subclass.video.frame_ending = mark;
+ s->fr.subclass.frame_ending = mark;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
fs->lastts = ntohl(ts);
*whennext = fs->lastts * 4/45;
@@ -106,7 +108,7 @@
unsigned int ts;
unsigned short len;
uint32_t mark = 0;
- mark = f->subclass.video.frame_ending ? 0x8000 : 0;
+ mark = f->subclass.frame_ending ? FRAME_ENDED : 0;
ts = htonl(f->samples);
if ((res = fwrite(&ts, 1, sizeof(ts), fs->f)) != sizeof(ts)) {
ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno));
Modified: team/file/mf-attributes/formats/format_h264.c
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/formats/format_h264.c?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/formats/format_h264.c (original)
+++ team/file/mf-attributes/formats/format_h264.c Wed Jul 2 06:58:12 2014
@@ -42,6 +42,8 @@
/* Portions of the conversion code are by guido at sienanet.it */
/*! \todo Check this buf size estimate, it may be totally wrong for large frame video */
+#define FRAME_ENDED 0x8000
+
#define BUF_SIZE 4096 /* Two Real h264 Frames */
struct h264_desc {
unsigned int lastts;
@@ -69,7 +71,7 @@
if ((res = fread(&len, 1, sizeof(len), s->f)) < 1)
return NULL;
len = ntohs(len);
- mark = (len & 0x8000) ? 1 : 0;
+ mark = (len & FRAME_ENDED) ? 1 : 0;
len &= 0x7fff;
if (len > BUF_SIZE) {
ast_log(LOG_WARNING, "Length %d is too long\n", len);
@@ -83,7 +85,7 @@
}
s->fr.samples = fs->lastts;
s->fr.datalen = len;
- s->fr.subclass.video.frame_ending = mark;
+ s->fr.subclass.frame_ending = mark;
if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
fs->lastts = ntohl(ts);
*whennext = fs->lastts * 4/45;
@@ -99,7 +101,7 @@
unsigned short len;
int mark;
- mark = f->subclass.video.frame_ending ? 0x8000 : 0;
+ mark = f->subclass.frame_ending ? FRAME_ENDED : 0;
ts = htonl(f->samples);
if ((res = fwrite(&ts, 1, sizeof(ts), s->f)) != sizeof(ts)) {
ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno));
Modified: team/file/mf-attributes/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/include/asterisk/format.h?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/include/asterisk/format.h (original)
+++ team/file/mf-attributes/include/asterisk/format.h Wed Jul 2 06:58:12 2014
@@ -340,6 +340,15 @@
unsigned int ast_format_get_maximum_ms(const struct ast_format *format);
/*!
+ * \brief Get the minimum number of bytes expected in a frame for this format
+ *
+ * \param format The media format
+ *
+ * \return minimum expected bytes in a frame for this format
+ */
+unsigned int ast_format_get_minimum_bytes(const struct ast_format *format);
+
+/*!
* \brief Get the sample rate of a media format
*
* \param format The media format
Modified: team/file/mf-attributes/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/include/asterisk/format_cap.h?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/include/asterisk/format_cap.h (original)
+++ team/file/mf-attributes/include/asterisk/format_cap.h Wed Jul 2 06:58:12 2014
@@ -54,9 +54,25 @@
* \param cap The capabilities structure.
* \param framing The framing value (in milliseconds).
*
- * \note This is used if a format does not provide a framing itself.
+ * \note This is used if a format does not provide a framing itself. Note that
+ * adding subsequent formats to the \c ast_format_cap structure may
+ * override this value, if the framing they require is less than the
+ * value set by this function.
*/
void ast_format_cap_set_framing(struct ast_format_cap *cap, unsigned int framing);
+
+/*!
+ * \brief Get the global framing.
+ *
+ * \param cap The capabilities structure.
+ *
+ * \retval 0 if no formats are in the structure and no framing has been provided
+ * \retval The global framing value (in milliseconds)
+ *
+ * \note This will be the minimum framing allowed across all formats in the
+ * capabilities structure, or an overridden value
+ */
+unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap);
/*!
* \brief Add format capability to capabilities structure.
@@ -141,7 +157,7 @@
*
* \return the framing (in milliseconds)
*/
-unsigned int ast_format_cap_get_framing(const struct ast_format_cap *cap, const struct ast_format *format);
+unsigned int ast_format_cap_get_format_framing(const struct ast_format_cap *cap, const struct ast_format *format);
/*!
* \brief Remove format capability from capability structure.
Modified: team/file/mf-attributes/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/include/asterisk/frame.h?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/include/asterisk/frame.h (original)
+++ team/file/mf-attributes/include/asterisk/frame.h Wed Jul 2 06:58:12 2014
@@ -135,15 +135,13 @@
AST_FRFLAG_HAS_TIMING_INFO = (1 << 0),
};
-struct ast_frame_video {
+struct ast_frame_subclass {
+ /*! A frame specific code */
+ int integer;
+ /*! The asterisk media format */
struct ast_format *format;
+ /*! For video formats, an indication that a frame ended */
unsigned int frame_ending;
-};
-
-union ast_frame_subclass {
- int integer;
- struct ast_format *format;
- struct ast_frame_video video;
};
/*! \brief Data structure associated with a single frame of data
@@ -152,7 +150,7 @@
/*! Kind of frame */
enum ast_frame_type frametype;
/*! Subclass, frame dependent */
- union ast_frame_subclass subclass;
+ struct ast_frame_subclass subclass;
/*! Length of data */
int datalen;
/*! Number of samples in this frame */
Modified: team/file/mf-attributes/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/file/mf-attributes/include/asterisk/rtp_engine.h?view=diff&rev=417754&r1=417753&r2=417754
==============================================================================
--- team/file/mf-attributes/include/asterisk/rtp_engine.h (original)
+++ team/file/mf-attributes/include/asterisk/rtp_engine.h Wed Jul 2 06:58:12 2014
@@ -76,6 +76,7 @@
#include "asterisk/sched.h"
#include "asterisk/res_srtp.h"
#include "asterisk/stasis.h"
+#include "asterisk/vector.h"
/* Maximum number of payloads supported */
#if defined(LOW_MEMORY)
@@ -555,8 +556,15 @@
[... 1207 lines stripped ...]
More information about the svn-commits
mailing list