Skip to content

Commit 1342618

Browse files
committed
MT#55283 extend G729a compatibility
Change-Id: I6079d06ada8acec1771f27677f3043d34e4c9f20 (cherry picked from commit 7893b1a) (cherry picked from commit c803556)
1 parent 37b27f6 commit 1342618

File tree

3 files changed

+215
-6
lines changed

3 files changed

+215
-6
lines changed

lib/codeclib.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,13 @@ void codeclib_init(int print) {
14921492
const struct rtp_payload_type *pt = rtp_get_rfc_codec(&def->rtpname_str);
14931493
if (pt)
14941494
def->rfc_payload_type = pt->payload_type;
1495-
else
1496-
def->rfc_payload_type = -1;
1495+
else {
1496+
// special case:
1497+
if (!strcmp(def->rtpname, "G729a"))
1498+
def->rfc_payload_type = 18;
1499+
else
1500+
def->rfc_payload_type = -1;
1501+
}
14971502

14981503
if (def->codec_type && def->codec_type->def_init)
14991504
def->codec_type->def_init(def);

lib/rtplib.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,25 @@ bool rtp_payload_type_fmt_eq_nf(const struct rtp_payload_type *a, const struct r
150150
return false;
151151
if (a->channels != b->channels)
152152
return false;
153-
if (str_casecmp_str(&a->encoding, &b->encoding))
153+
if (str_casecmp_str(&a->encoding, &b->encoding)) {
154+
#ifdef WITH_TRANSCODING
155+
// last ditch effort: see if it's a botched alias name (AKA G729a)
156+
if (!a->codec_def || !b->codec_def)
157+
return false;
158+
if (a->codec_def->rfc_payload_type == -1 || b->codec_def->rfc_payload_type == -1)
159+
return false;
160+
if (a->codec_def->rfc_payload_type != b->codec_def->rfc_payload_type)
161+
return false;
162+
if (a->codec_def->codec_type != b->codec_def->codec_type)
163+
return false;
164+
if (a->codec_def->avcodec_id != b->codec_def->avcodec_id)
165+
return false;
166+
// consider them the same
167+
return true;
168+
#else
154169
return false;
170+
#endif
171+
}
155172
return true;
156173
}
157174

@@ -160,9 +177,10 @@ bool rtp_payload_type_fmt_eq_nf(const struct rtp_payload_type *a, const struct r
160177
int rtp_payload_type_fmt_cmp(const struct rtp_payload_type *a, const struct rtp_payload_type *b) {
161178
if (!rtp_payload_type_fmt_eq_nf(a, b))
162179
return -1;
163-
if (a->codec_def && a->codec_def == b->codec_def) {
164-
if (a->codec_def->format_cmp)
165-
return a->codec_def->format_cmp(a, b);
180+
if (a->codec_def && b->codec_def
181+
&& a->codec_def->format_cmp
182+
&& a->codec_def->format_cmp == b->codec_def->format_cmp) {
183+
return a->codec_def->format_cmp(a, b);
166184
}
167185
if (!a->codec_def) // ignore format of codecs we don't know
168186
return 0;

t/auto-daemon-tests.pl

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,192 @@ sub stun_succ {
693693
a=maxptime:30
694694
SDP
695695

696+
697+
new_call;
698+
699+
offer('rtpmap default mismatched G.729 annexb', { }, <<SDP);
700+
v=0
701+
o=- 13111259 1 IN IP4 1.2.3.4
702+
s=-
703+
c=IN IP4 1.2.3.4
704+
t=0 0
705+
m=audio 23874 RTP/AVP 9 8 0 18 100
706+
a=rtpmap:100 telephone-event/8000
707+
a=ptime:20
708+
----------------------------
709+
v=0
710+
o=- 13111259 1 IN IP4 1.2.3.4
711+
s=-
712+
t=0 0
713+
m=audio PORT RTP/AVP 9 8 0 18 100
714+
c=IN IP4 203.0.113.1
715+
a=rtpmap:9 G722/8000
716+
a=rtpmap:8 PCMA/8000
717+
a=rtpmap:0 PCMU/8000
718+
a=rtpmap:18 G729/8000
719+
a=rtpmap:100 telephone-event/8000
720+
a=sendrecv
721+
a=rtcp:PORT
722+
a=ptime:20
723+
SDP
724+
725+
answer('rtpmap default mismatched G.729 annexb', { }, <<SDP);
726+
v=0
727+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
728+
s=SIP call
729+
c=IN IP4 5.6.7.7
730+
t=0 0
731+
m=audio 49696 RTP/AVP 8 0 18 100
732+
a=rtpmap:8 PCMA/8000
733+
a=rtpmap:0 PCMU/8000
734+
a=rtpmap:18 G729a/8000
735+
a=rtpmap:100 telephone-event/8000
736+
a=fmtp:100 0-11
737+
a=ptime:20
738+
a=maxptime:30
739+
a=sendrecv
740+
----------------------------
741+
v=0
742+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
743+
s=SIP call
744+
t=0 0
745+
m=audio PORT RTP/AVP 8 0 18 100
746+
c=IN IP4 203.0.113.1
747+
a=rtpmap:8 PCMA/8000
748+
a=rtpmap:0 PCMU/8000
749+
a=rtpmap:18 G729a/8000
750+
a=rtpmap:100 telephone-event/8000
751+
a=fmtp:100 0-11
752+
a=sendrecv
753+
a=rtcp:PORT
754+
a=ptime:20
755+
a=maxptime:30
756+
SDP
757+
758+
new_call;
759+
760+
offer('rtpmap mismatched G.729 annexb', { }, <<SDP);
761+
v=0
762+
o=- 13111259 1 IN IP4 1.2.3.4
763+
s=-
764+
c=IN IP4 1.2.3.4
765+
t=0 0
766+
m=audio 23874 RTP/AVP 9 8 0 18 100
767+
a=rtpmap:100 telephone-event/8000
768+
a=ptime:20
769+
----------------------------
770+
v=0
771+
o=- 13111259 1 IN IP4 1.2.3.4
772+
s=-
773+
t=0 0
774+
m=audio PORT RTP/AVP 9 8 0 18 100
775+
c=IN IP4 203.0.113.1
776+
a=rtpmap:9 G722/8000
777+
a=rtpmap:8 PCMA/8000
778+
a=rtpmap:0 PCMU/8000
779+
a=rtpmap:18 G729/8000
780+
a=rtpmap:100 telephone-event/8000
781+
a=sendrecv
782+
a=rtcp:PORT
783+
a=ptime:20
784+
SDP
785+
786+
answer('rtpmap mismatched G.729 annexb', { }, <<SDP);
787+
v=0
788+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
789+
s=SIP call
790+
c=IN IP4 5.6.7.7
791+
t=0 0
792+
m=audio 49696 RTP/AVP 8 0 18 100
793+
a=rtpmap:8 PCMA/8000
794+
a=rtpmap:0 PCMU/8000
795+
a=rtpmap:18 G729a/8000
796+
a=fmtp:18 annexb=no
797+
a=rtpmap:100 telephone-event/8000
798+
a=fmtp:100 0-11
799+
a=ptime:20
800+
a=maxptime:30
801+
a=sendrecv
802+
----------------------------
803+
v=0
804+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
805+
s=SIP call
806+
t=0 0
807+
m=audio PORT RTP/AVP 8 0 18 100
808+
c=IN IP4 203.0.113.1
809+
a=rtpmap:8 PCMA/8000
810+
a=rtpmap:0 PCMU/8000
811+
a=rtpmap:18 G729a/8000
812+
a=fmtp:18 annexb=no
813+
a=rtpmap:100 telephone-event/8000
814+
a=fmtp:100 0-11
815+
a=sendrecv
816+
a=rtcp:PORT
817+
a=ptime:20
818+
a=maxptime:30
819+
SDP
820+
821+
new_call;
822+
823+
offer('actually rtpmap mismatched G.729 annexb', { }, <<SDP);
824+
v=0
825+
o=- 13111259 1 IN IP4 1.2.3.4
826+
s=-
827+
c=IN IP4 1.2.3.4
828+
t=0 0
829+
m=audio 23874 RTP/AVP 9 8 0 18 100
830+
a=rtpmap:100 telephone-event/8000
831+
a=ptime:20
832+
----------------------------
833+
v=0
834+
o=- 13111259 1 IN IP4 1.2.3.4
835+
s=-
836+
t=0 0
837+
m=audio PORT RTP/AVP 9 8 0 18 100
838+
c=IN IP4 203.0.113.1
839+
a=rtpmap:9 G722/8000
840+
a=rtpmap:8 PCMA/8000
841+
a=rtpmap:0 PCMU/8000
842+
a=rtpmap:18 G729/8000
843+
a=rtpmap:100 telephone-event/8000
844+
a=sendrecv
845+
a=rtcp:PORT
846+
a=ptime:20
847+
SDP
848+
849+
answer('actually rtpmap mismatched G.729 annexb', { }, <<SDP);
850+
v=0
851+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
852+
s=SIP call
853+
c=IN IP4 5.6.7.7
854+
t=0 0
855+
m=audio 49696 RTP/AVP 8 0 18 100
856+
a=rtpmap:8 PCMA/8000
857+
a=rtpmap:0 PCMU/8000
858+
a=rtpmap:18 G729a/8000
859+
a=fmtp:18 annexb=yes
860+
a=rtpmap:100 telephone-event/8000
861+
a=fmtp:100 0-11
862+
a=ptime:20
863+
a=maxptime:30
864+
a=sendrecv
865+
----------------------------
866+
v=0
867+
o=- 1737116508926565 1737116508926565 IN IP4 5.6.7.7
868+
s=SIP call
869+
t=0 0
870+
m=audio PORT RTP/AVP 8 0 100
871+
c=IN IP4 203.0.113.1
872+
a=rtpmap:8 PCMA/8000
873+
a=rtpmap:0 PCMU/8000
874+
a=rtpmap:100 telephone-event/8000
875+
a=fmtp:100 0-11
876+
a=sendrecv
877+
a=rtcp:PORT
878+
a=ptime:20
879+
a=maxptime:30
880+
SDP
881+
696882
}
697883

698884
new_call;

0 commit comments

Comments
 (0)