I have hikvision indoor monitor, linphone, and webrtc device (mobile app) that sits on same endpoint. That has to get early media simultaneously. The problem is after registering hikvision to server. I don’t see any early media but before i was getting in linphone app. Webrtc didn’t tested. Gemini’s answer was asterisk doesn’t support early media to multiple devices , if that is true i would like to hear from officials
[dial]
exten => _X!, 1, NoOp()
same = n , Set(BLOCK=${ODBC_getBlock(${CALLERID(num)})})
same = n , Set(BUILD=${ODBC_getBuild(${CALLERID(num)})})
same = n , Set(TARGETS=${ODBC_getUid(${EXTEN},${BLOCK},${BUILD})})
same = n , NoOp(Targets: ${TARGETS})
same = n , Set(DIAL_STR=)
same = n , Set(COUNT=1)
same = n , Set(CALL_ID=${UNIQUEID})
same = n , Set(__CALL_ID=${CALL_ID})
same = n , Set(__PUSH_UID=)
; ---------- Pass 1: ALWAYS push every target ----------
same = n(push_loop) , Set(CUR=${CUT(TARGETS,&,${COUNT})})
same = n , GotoIf($["${CUR}" = ""]?after_push)
same = n , NoOp(Always sending VoIP push to ${CUR})
same = n , System(/var/lib/asterisk/agi-bin/send_push.sh ${CUR} "Intercom" "${CALLERID(num)}" "${CALL_ID}")
same = n , Set(__PUSH_UID=${CUR})
same = n , Set(COUNT=$[${COUNT} + 1])
same = n , Goto(push_loop)
same = n(after_push) , NoOp(All pushes sent. Polling backend for READY...)
same = n , Set(WAITED=0)
same = n , Set(CURLOPT(httpheader)=call_id: ${CALL_ID})
; ---------- Pass 2: Wait Loop with Native Fallback ----------
same = n(ready_loop) , Set(RSTATUS=${CURL(XXXX)})
same = n , NoOp(Ready status: ${RSTATUS} waited=${WAITED})
same = n , GotoIf($["${RSTATUS}" = "ready"]?do_dial)
same = n , GotoIf($["${RSTATUS}" = "cancelled"]?nobody)
; Check if endpoints are already registered directly in Asterisk
same = n , Set(CHK_COUNT=1)
same = n , Set(ANY_READY=0)
same = n(chk_loop) , Set(CHK_CUR=${CUT(TARGETS,&,${CHK_COUNT})})
same = n , GotoIf($["${CHK_CUR}" = ""]?chk_done)
same = n , Set(DEV_STATE=${DEVICE_STATE(PJSIP/${CHK_CUR})})
same = n , GotoIf($["${DEV_STATE}" = "UNAVAILABLE"]?skip_chk)
same = n , Set(CHK_CONTACTS=${PJSIP_DIAL_CONTACTS(${CHK_CUR})})
same = n , GotoIf($[${LEN(${CHK_CONTACTS})} > 0]?set_ready)
same = n(skip_chk) , Set(CHK_COUNT=$[${CHK_COUNT} + 1])
same = n , Goto(chk_loop)
same = n(set_ready) , Set(ANY_READY=1)
same = n(chk_done) , GotoIf($[${ANY_READY} = 1]?do_dial)
same = n , GotoIf($[${WAITED} >= 25]?do_dial)
same = n , Wait(1)
same = n , Set(WAITED=$[${WAITED} + 1])
same = n , Goto(ready_loop)
; ---------- Dial whatever registered safely ----------
same = n(do_dial) , Set(DIAL_STR=)
same = n , Set(COUNT=1)
same = n(dial_loop) , Set(CUR=${CUT(TARGETS,&,${COUNT})})
same = n , GotoIf($["${CUR}" = ""]?after_dial)
same = n , Set(CONTACTS=${PJSIP_DIAL_CONTACTS(${CUR})})
same = n , NoOp(Contacts for ${CUR}: ${CONTACTS})
same = n , GotoIf($[${LEN(${CONTACTS})} = 0]?skip)
; Append without a leading ampersand. NOTE: must test DIAL_STR, not DI_STR —
; the typo made this always take set_first, overwriting previous targets.
same = n , GotoIf($[${LEN(${DIAL_STR})} = 0]?set_first)
same = n , Set(DIAL_STR=${DIAL_STR}&${CONTACTS})
same = n , Goto(skip)
same = n(set_first) , Set(DIAL_STR=${CONTACTS})
same = n(skip) , Set(COUNT=$[${COUNT} + 1])
same = n , Goto(dial_loop)
same = n(after_dial) , NoOp(Final safe dial string: ${DIAL_STR})
same = n , GotoIf($[${LEN(${DIAL_STR})} = 0]?nobody)
; L(30000:5000) = cap the answered call at 30s, with a warning beep 5s before.
same = n, Progress()
same = n , Dial(${DIAL_STR}, 30, L(30000:5000))
same = n , Hangup()
same = n(nobody) , NoOp(No endpoints registered after push)
same = n , Hangup()
; ---------- Hangup handler: cancel the ringing phones ----------
exten => h,1,NoOp(Hangup handler: call ${CALL_ID} uid ${PUSH_UID} answered=${DIALSTATUS})
same = n , GotoIf($["${PUSH_UID}" = ""]?end)
same = n , GotoIf($["${DIALSTATUS}" = "ANSWER"]?end)
same = n , System(/var/lib/asterisk/agi-bin/send_cancel.sh "${PUSH_UID}" "${CALL_ID}")
same = n(end) , NoOp(Hangup handler done)