Frustrated: Cant get Early Media to work!

Struggling with this for a long time already, running freepbx with asterisk 16.17

i have a doorstation and some linphone clients, when i press the call button, i only see video AFTER i pickup, i want to see it before i pickup
I have tested other PBX too like fusion/freeswitch, then it works… so i know its not a client side issue, but a PBX issue
its a simple setup, no trunks, all in on local lan network…, created some chan_sip extensions, enabled video, enabled correct codecs…
tried also enabling these settings below, still a no go…

image

what am i missing? thnx, much appreciated!!!
here is full log file :

INVITE sip:2002@192.168.0.168:40643;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
Max-Forwards: 70
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>
Contact: <sip:2000@192.168.0.174:5160>
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE
User-Agent: FPBX-15.0.17.34(16.17.0)
Date: Thu, 14 Oct 2021 17:21:47 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
P-Asserted-Identity: "2000" <sip:2000@192.168.0.174>
Content-Type: application/sdp
Content-Length: 470

v=0
o=root 957584624 957584624 IN IP4 192.168.0.174
s=Asterisk PBX 16.17.0
c=IN IP4 192.168.0.174
b=CT:384
t=0 0
m=audio 12778 RTP/AVP 0 8 3 111 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
m=video 19822 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 packetization-mode=1;profile-level-id=4D001F
a=sendrecv

---
[2021-10-14 17:21:47] VERBOSE[31904][C-00000003] app_dial.c: Called SIP/2002
[2021-10-14 17:21:47] VERBOSE[31904][C-00000003] chan_sip.c: 
<--- Transmitting (NAT) to 192.168.0.70:5060 --->
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.0.70:5060;branch=z9hG4bK574991794;received=192.168.0.70;rport=5060
From: "2000" <sip:2000@192.168.0.70>;tag=78128501
To: <sip:2002@192.168.0.174:5160>;tag=as44581885
Call-ID: 642356047@192.168.0.70
CSeq: 165 INVITE
Server: FPBX-15.0.17.34(16.17.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:2002@192.168.0.174:5160>
P-Asserted-Identity: "2002" <sip:2002@192.168.0.70>
Content-Length: 0


<------------>
[2021-10-14 17:21:47] VERBOSE[2267] chan_sip.c: Retransmitting #1 (NAT) to 192.168.0.168:40643:
INVITE sip:2002@192.168.0.168:40643;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
Max-Forwards: 70
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>
Contact: <sip:2000@192.168.0.174:5160>
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE
User-Agent: FPBX-15.0.17.34(16.17.0)
Date: Thu, 14 Oct 2021 17:21:47 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
P-Asserted-Identity: "2000" <sip:2000@192.168.0.174>
Content-Type: application/sdp
Content-Length: 470

v=0
o=root 957584624 957584624 IN IP4 192.168.0.174
s=Asterisk PBX 16.17.0
c=IN IP4 192.168.0.174
b=CT:384
t=0 0
m=audio 12778 RTP/AVP 0 8 3 111 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:3 GSM/8000
a=rtpmap:111 G726-32/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
m=video 19822 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 packetization-mode=1;profile-level-id=4D001F
a=sendrecv

---
[2021-10-14 17:21:47] VERBOSE[2267] chan_sip.c: 
<--- SIP read from UDP:192.168.0.168:40643 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE

<------------->
[2021-10-14 17:21:47] VERBOSE[2267] chan_sip.c: --- (6 headers 0 lines) ---
[2021-10-14 17:21:47] VERBOSE[2267] chan_sip.c: 
<--- SIP read from UDP:192.168.0.168:40643 --->
SIP/2.0 183 Session progress
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>;tag=dyuK~xp
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE
User-Agent: Linphone/4.5.3 (OnePlus 6T) LinphoneSDK/5.0.31 (tags/5.0.31^0)
Supported: replaces, outbound, gruu
Content-Type: application/sdp
Content-Length: 254

v=0
o=2002 1937 3737 IN IP4 192.168.0.168
s=Talk
c=IN IP4 192.168.0.168
t=0 0
m=audio 7078 RTP/AVP 0 8 101
a=rtpmap:101 telephone-event/8000
m=video 9078 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42801F; packetization-mode=1
<------------->
[2021-10-14 17:21:47] VERBOSE[2267] chan_sip.c: --- (10 headers 10 lines) ---
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] sip/route.c: sip_route_dump: no route/path
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Got SDP version 3737 and unique parts [2002 1937 IN IP4 192.168.0.168]
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 0
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 8
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 101
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found audio description format telephone-event for ID 101
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP video format 99
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Found video description format H264 for ID 99
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Capabilities: us - (ulaw|alaw|gsm|g726|g722|h264|mpeg4), peer - audio=(ulaw|alaw)/video=(h264)/text=(nothing), combined - (ulaw|alaw|h264)
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Peer audio RTP is at port 192.168.0.168:7078
[2021-10-14 17:21:47] VERBOSE[2267][C-00000003] chan_sip.c: Peer video RTP is at port 192.168.0.168:9078
[2021-10-14 17:21:47] VERBOSE[31904][C-00000003] app_dial.c: SIP/2002-00000005 is making progress passing it to SIP/2000-00000004
[2021-10-14 17:21:48] VERBOSE[2267] chan_sip.c: 
<--- SIP read from UDP:192.168.0.168:40643 --->
SIP/2.0 183 Session progress
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>;tag=dyuK~xp
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE
User-Agent: Linphone/4.5.3 (OnePlus 6T) LinphoneSDK/5.0.31 (tags/5.0.31^0)
Supported: replaces, outbound, gruu
Content-Type: application/sdp
Content-Length: 254

v=0
o=2002 1937 3737 IN IP4 192.168.0.168
s=Talk
c=IN IP4 192.168.0.168
t=0 0
m=audio 7078 RTP/AVP 0 8 101
a=rtpmap:101 telephone-event/8000
m=video 9078 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42801F; packetization-mode=1
<------------->
[2021-10-14 17:21:48] VERBOSE[2267] chan_sip.c: --- (10 headers 10 lines) ---
[2021-10-14 17:21:48] VERBOSE[2267][C-00000003] sip/route.c: sip_route_dump: no route/path
[2021-10-14 17:21:48] VERBOSE[2267][C-00000003] chan_sip.c: Comparing SDP version 3737 -> 3737 and unique parts [2002 1937 IN IP4 192.168.0.168] -> [2002 1937 IN IP4 192.168.0.168]
[2021-10-14 17:21:48] VERBOSE[31904][C-00000003] app_dial.c: SIP/2002-00000005 is making progress passing it to SIP/2000-00000004
[2021-10-14 17:21:49] VERBOSE[2267] chan_sip.c: 
<--- SIP read from UDP:192.168.0.168:40643 --->
SIP/2.0 200 Ok
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK50cf6913;rport
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>;tag=dyuK~xp
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 INVITE
User-Agent: Linphone/4.5.3 (OnePlus 6T) LinphoneSDK/5.0.31 (tags/5.0.31^0)
Supported: replaces, outbound, gruu
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO, PRACK, UPDATE
Contact: <sip:2002@192.168.0.168:40643;transport=udp>;expires=3600;+sip.instance="<urn:uuid:e5f09345-a52b-0097-aa78-e2b34b9a3ea0>";+org.linphone.specs="lime"
Content-Type: application/sdp
Content-Length: 254

v=0
o=2002 1937 3738 IN IP4 192.168.0.168
s=Talk
c=IN IP4 192.168.0.168
t=0 0
m=audio 7078 RTP/AVP 0 8 101
a=rtpmap:101 telephone-event/8000
m=video 9078 RTP/AVP 99
a=rtpmap:99 H264/90000
a=fmtp:99 profile-level-id=42801F; packetization-mode=1
<------------->
[2021-10-14 17:21:49] VERBOSE[2267] chan_sip.c: --- (12 headers 10 lines) ---
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Comparing SDP version 3737 -> 3738 and unique parts [2002 1937 IN IP4 192.168.0.168] -> [2002 1937 IN IP4 192.168.0.168]
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 0
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 8
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP audio format 101
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found audio description format telephone-event for ID 101
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found RTP video format 99
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Found video description format H264 for ID 99
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Capabilities: us - (ulaw|alaw|gsm|g726|g722|h264|mpeg4), peer - audio=(ulaw|alaw)/video=(h264)/text=(nothing), combined - (ulaw|alaw|h264)
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Peer audio RTP is at port 192.168.0.168:7078
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Peer video RTP is at port 192.168.0.168:9078
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] sip/route.c: sip_route_dump: route/path hop: <sip:2002@192.168.0.168:40643;transport=udp>
[2021-10-14 17:21:49] VERBOSE[2267][C-00000003] chan_sip.c: Transmitting (NAT) to 192.168.0.168:40643:
ACK sip:2002@192.168.0.168:40643;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.0.174:5160;branch=z9hG4bK44f42b66;rport
Max-Forwards: 70
From: "2000" <sip:2000@192.168.0.174:5160>;tag=as36fbff33
To: <sip:2002@192.168.0.168:40643;transport=udp>;tag=dyuK~xp
Contact: <sip:2000@192.168.0.174:5160>
Call-ID: 2dddd430209b3c4d7d2311063027a129@192.168.0.174:5160
CSeq: 102 ACK
User-Agent: FPBX-15.0.17.34(16.17.0)
Content-Length: 0


---
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] app_dial.c: SIP/2002-00000005 answered SIP/2000-00000004
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: Audio is at 15440
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: Video is at 192.168.0.174:16078
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: Adding codec ulaw to SDP
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: Adding video codec h264 to SDP
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: Adding non-codec 0x1 (telephone-event) to SDP
[2021-10-14 17:21:49] VERBOSE[31904][C-00000003] chan_sip.c: 
<--- Reliably Transmitting (NAT) to 192.168.0.70:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.70:5060;branch=z9hG4bK574991794;received=192.168.0.70;rport=5060
From: "2000" <sip:2000@192.168.0.70>;tag=78128501
To: <sip:2002@192.168.0.174:5160>;tag=as44581885
Call-ID: 642356047@192.168.0.70
CSeq: 165 INVITE
Server: FPBX-15.0.17.34(16.17.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:2002@192.168.0.174:5160>
P-Asserted-Identity: "2002" <sip:2002@192.168.0.70>
Content-Type: application/sdp
Content-Length: 370

v=0
o=root 1477218312 1477218312 IN IP4 192.168.0.174
s=Asterisk PBX 16.17.0
c=IN IP4 192.168.0.174
b=CT:384
t=0 0
m=audio 15440 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=maxptime:150
a=sendrecv
m=video 16078 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1;profile-level-id=4D001F
a=sendrecv

Can you get a pcap trace from a setup that works? This question has been asked frequently and there are many reasons why you don’t see a video when someone rings. As far as FreePBX is concerned, they also have a support forum.

I believe you need to call Progress() for early media. As it is, Asterisk is not sending media SDP until the call is answered, so the phone has nowhere to send the early media,

As Progress() is something called by the dialplan, and FreePBX has control of the dialplan, you are definitely on the wrong forum. You want https://community.freepbx.org/

Hi @EkFudrek , sure here is a capture from fusionPBX, where it works with default setup

@david551 , thnx , can you give me a hand here?
the log was indeed from a freepbx, but i want to move over to asteriks itself
its quite new to me, i dont have any dialplans, its a verry basic setup, the purpose is just for my door intercom and some sip clients…

if i move over to asterisk, where do i need to setup that progress() ? is it possible in asterisk?

if i stay with freepbx, where do i need to configure this? if i remember correcty, i didnt have a dialplan? i dont think i need it? how/where can i define that progress()?

thnx in advance!!

FreePBX generates a very large dialplan for you!

There may be an option to have FreePBX add a Progress() to its dialplan.

The raw Asterisk dialplan could be as simple as.

[default]
exten => phone,1,Progress()
same => n,Dial(PJSIP/phone)

Dropbox is making life difficult, as you used a strange file extension, not .txt, so I’ve been unable to get your full logs again, to find the actual context, extension, device name, and channel driver you are using, but the above dialplan will work with the right device configuration, and assuming the door camera can generate non-numeric SIP user names.

yeah, the dropbox is a pcap file, its a wireshark log

ok, gonna fireup my freepbx first and then try astrisk later, i think process is the same? i was reading about dialplan, i need to make a change in this file , right? “extensions_custom.conf”

and then add :

[from-internal-custom]
exten => 2000,1,Progress()
same => n,Dial(PJSIP/phone)

is that ok? So extension 2000 is in my case the doorstation, where i initiate the call from
i’m also using chan_sip, not pjsip , so i think i need to have that second line different?

i think i need something like:

[from-internal-custom]
exten => 2000,1,Progress()
same => n,Dial(SIP/2002)

so 2000 is doorstation
2002 is my client?

is that ok ?

Early media with video is also something few people use, so it’s entirely possible even with the addition of Progress that it doesn’t work properly.

1 Like

chan_sip shouldn’t be used for new installation.

phone should be whatever the phone registers as (more strictly the name of the sip.conf* section) that defines the phone (in FreePBX that will generally be the same as the extension number), and PJSIP should be SIP, if still using the legacy driver.

ok, so this should be right? extensions_custom.conf

[from-internal-custom]
exten => 2000,1,Progress()
same => n,Dial(SIP/2002)

so 2000 is doorstation, 2002 is the sip client?

@jcolp , so what do yo mean? i dont need to have above in my conf files at all? it should work out of the box? but its possible it doesnt?
i see here that it was added in some older release
https://gerrit.asterisk.org/c/asterisk/+/8398

What I’m saying is that you’re using something few, if any, people use. It is entirely possible either way that it won’t work and the issue is elsewhere.

2000 is the user part of what the doorstation sends (what it “dials”). The doorstation doesn’t need to have any extension number, as far as Asterisk is concerned, unless you want to make unsolicited calls to it. (Although it is likely to have an extension number, in FreePBX terms, there is nothing technically to stop it using allowguest, even though that is generally a bad idea for security reasons.

2002 is very definitely the SIP server in this context, but server is a term that is used very loosely, so you may think of it as a client, even though anything that receives a SIP call is always a SIP server.

Incidentally, if the doorstation only ever calls one device, and you don’t need any conditional routing, you can probably cut out the PABX entirely, although you might have to disable security features in the phone, to allow it to accept calls from multiple clients.

ok, tryng to understand all of this :slight_smile:
so my code was wrong
for now , i have 2 sip extensiosn registered
2000 = doorstation (registered)
2002 = a linphone test client (registered)

so i call from 2000 to 2002 (as a test)
later i want to try with ring groups

so it needs to be like?

[from-internal-custom]
exten => 2002,1,Progress()
same => n,Dial(SIP/2002)

is that ok?

I’ve just had a look at app_dial.c, and it looks like it drops video frames, as early media, in both directions. I think it might handle still images, but the case statements don’t catch AST_FRAME_VIDEO, and the default is to drop the frame.

However, there seems to a significant number of Asterisk users who want to interface video door phones, and I think I’ve seen people wanting early media before, so it does seem there is a demand from this, although I’m not clear whether it is from home users, who are only likely to get support from the community, or business users, for which there might be a business case for Sangoma to get involved.

In any case, for the OP, if chan_sip doesn’t already support it, it is unlikely that support will ever be added to that, even if it gets added to app_dial.

From a Sangoma perspective it’s not something we’re working on. If someone puts a review up then we’ll review it like we do all other changes.

ok, i tried above code, and it works!! finally early media on my sip client :slight_smile:

[from-internal-custom]
exten => 2002,1,Progress()
same => n,Dial(SIP/2002)

how can i change that code, so its activated for all sip clients, and not only 2002 ? is there somekind of variable i can use?

last question…can it also work for ringgroups?

thnx!!

Those are all FreePBX questions, not Asterisk ones. 2002 is acting as a SIP server.

I guess I misread app_dial if it now works, but I believe that FreePBX ring groups are Asterisk queues, so a completely different piece of code is handling the forwarding of early media.

My wireshark was not able to open your file.

yeah , but its ok, early media now works , with the addition of those 2 lines

last goal is to make it work on a group , not sure it its supported? someone any idea,

@david551 , i want to move to asterisk, that file is that i need to edit, thats the same right?
any idea how i can get this to work on a ringgroup ?

No, it is the top level extensions.conf.