# How to get video preview?

**URL:** <https://community.asterisk.org/t/how-to-get-video-preview/92485>\
**Category:** Asterisk SIP\
**Created:** [April 29, 2022, 2:23pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485 "2022-04-29T14:23:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [April 29, 2022, 2:23pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/1 "2022-04-29T14:23:05Z")

</div>

Hi,

I want to understand how a doorphone system should be setup to get video preview.

I’m looking at [RFC 3960: Early Media and Ringing Tone Generation in the Session Initiation Protocol (SIP)](https://www.rfc-editor.org/rfc/rfc3960)

[1](https://www.rfc-editor.org/rfc/rfc3960#section-1). Introduction Early media refers to media (e.g., audio and video) that is exchanged before a particular session is accepted by the called user.

If endpoint device maker says “it follow the RFC standard”, my concern now it is asterisk is able to manage this kind of transaction?

From asterisk is only the Progress() needed in dialplan?

Thanks in advance.  
BR

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [April 29, 2022, 2:41pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/2 "2022-04-29T14:41:44Z")

</div>

The SIP RFCs only relate to the parts of the system that are using SIP. Asterisk is a back to back user agent, and the bit between them is not SIP. Looking at the source code for app\_dial, I see no support for video as early media, although I haven’t checked in enough detail to completely eliminate the possibility that it is handled by catchall code.

I have a feeling that the ARI primitives do support an early media bridge, but I’m no certain of that.

I assume you are talking of media from the doorphone, and the doorphone is the UAC, as, going against the call setup direction would also require early offer SDP (which is the more common case).

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [April 29, 2022, 2:51pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/3 "2022-04-29T14:51:48Z")

</div>

Thanks @david551 for reply, yes I’m referring to video sent from the doorphone.

I’ve tested that with differents endpoint device, someone, is able to choice the kind of signal that it need to use for preview (i.e if it choose to consider 2xx SIP for preview ) the video is correctly displayed (I know this means the call is picked up, but works fine for some usecase).

But the more I read the more I’m gettings confused: ie. 3.3. Absence of an Early Media Indicator…

Can you please point me out to what you mean with: “Asterisk is a back to back user agent, and the bit between them is not SIP”?

Thanks

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [April 29, 2022, 2:56pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/4 "2022-04-29T14:56:37Z")

</div>

Incidentally, I’m not sure why you need to leave the doorphone in an early media state, not that that will help with the early media state of the callees.

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [April 29, 2022, 3:04pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/5 "2022-04-29T15:04:54Z")

</div>

I’m trying to understand how to get video preview, my vendor doesn’t provide any help or documentation about it.

They’ve just said: have you enabled “early media and video preview” option?

I’ve googled those and just came out to “Early media” as in it’s description says  
“If the UAC receives early media from different UASs, it needs to present it to the user. On the other hand, other media types (e.g., video) can be presented to the user at the same time.”

I’m triyng to understand if I can try something on the PBX (I’m just a devop).

As you can imagine, in a doorphone system a working video preview, many times can avoid the call at all. The user see and push the open button without answering.

Thanks, BR

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [May 2, 2022, 1:36pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/6 "2022-05-02T13:36:30Z")

</div>

![image](https://global.discourse-cdn.com/asterisk/original/2X/4/4e8b25abbe58df99d8772dca6c1cdd1cd199919d.jpeg)

Can please someone say me if this sip message should be sent from the UAC and so I cannot do anything about it on PBX?

 ![why_t58_does_not_send_this_after_183](https://global.discourse-cdn.com/asterisk/original/2X/e/eb93aefb25cd2d1dcbd61a017ce3d47fd42e1f58.jpeg)

This is a working example, the doorphone call directly the phone, the phone after the 183 send backt to doorphone INFO, but trought PBX this never happens.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 2, 2022, 2:04pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/7 "2022-05-02T14:04:07Z")

</div>

It’s a response and responses can only ever sent from a UAS.

However, I would note that many people try and identify client with phones, and server, and server with PABXes, even though both of them take on both roles, depending on the direction of the call.

Also, the actual SIP RFC only contains the first paragraph:

> **[RFC 3261 - SIP: Session Initiation Protocol](https://datatracker.ietf.org/doc/html/rfc3261#section-21.1.5)**
>
> SIP: Session Initiation Protocol (RFC 3261)

and the only references to early media are with respect to Content-Disposition, which, in practice, I don’t think people use. Early media can be set on any response (or request).

Regarding the RFC 5168 INFO, it would appear that this is deprecated, in favour of RTCP, so I’d say that it is at best a MAY, not a SHOULD. The UAS doesn’t have honour this. The RFC seems to be about forcing a full retransmission of a video frame, and on a quick reading it is the frame towards the requester.

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [May 2, 2022, 2:41pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/8 "2022-05-02T14:41:41Z")

</div>

Thanks for reply, if I’ve understood:

- UAC is the doorphone
- UAS is the phone
- asterisk is the back to back user agent.

UAS maker said only:

 ![image](https://global.discourse-cdn.com/asterisk/original/2X/9/918e9a1535d8cd88fd8e4638365058cba282ab0e.png)

So to get an example of a working SIP flow to reference for video preview there’s nothing explicit in the RFC.  
The only one that can do something about it is the UAS?

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 2, 2022, 2:45pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/9 "2022-05-02T14:45:36Z")

</div>

Which UAS? Asterisk is both UAS and UAC in this call. As I already said, the bit between the UAS and the UAC is outside the scope of the SIP RFC, because it is a back to back user agent.

I seem to remember someone patching app\_dial.c, to forward video frames as early media.

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [May 2, 2022, 3:04pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/10 "2022-05-02T15:04:16Z")

</div>

UAS as “the phone”, I believed was the phone maker that should say how their product is handling the preview feature.

I’m sorry but I haven’t understood that the B2BUA is able to edit what’s going on in the transactions.

I will look to that app\_dial patch, thank you

---

<div class="post-metadata">

**Author:** ![Summer](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/summer/32/6900_2.png) [@Summer](https://community.asterisk.org/u/Summer)\
**Post date:** [May 5, 2022, 3:01pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/11 "2022-05-05T15:01:26Z")

</div>

I’m not a developer, I’ve found out this post about the topic:

> [@Group video calling in asterisk](https://community.asterisk.org/t/group-video-calling-in-asterisk/68482/6):
>
> Dial only handles early media when there is a single candidate destination. That is mainly done for the normal telephony case where you wouldn’t generally want callees to hear you before they had answered. However the test is obviously being applied to all early media not just early media in the direction where it would need to be merged. Basically this code is doing it: /\* single is set if only one destination is enabled \*/ int single = outgoing && !AST\_LIST\_NEXT(outgoing, node); which…

Found out the source file at:

> <https://github.com/asterisk/asterisk/blob/8fdc6008a443b2b59eeb31e95bc66ca97a398770/apps/app_dial.c#L1576>

Can you please tell me what edit is needed before starting to compile?

Thanks, BR

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 5, 2022, 3:17pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/12 "2022-05-05T15:17:04Z")

</div>

I didn’t notice that big of code, but note the “if (single…”. A lot of people with doorphones seem to want to call multiple destinations, which means single = false, and the code has to fall back to the original app\_dial logic, where app\_dial, itself, does the early bridging.

The function it calls takes two channels, so there can be a maximum of two channel involved in the call. I don’t know if it bridges video but it seems likely it does.

The CAN\_EARLY\_BRIDGE part is defined by:

```auto
#define CAN_EARLY_BRIDGE(flags,chan,peer) (!ast_test_flag64(flags, OPT_CALLEE_HANGUP | \
	OPT_CALLER_HANGUP | OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER | \
	OPT_CALLEE_MONITOR | OPT_CALLER_MONITOR | OPT_CALLEE_PARK | \
	OPT_CALLER_PARK | OPT_ANNOUNCE | OPT_CALLEE_MACRO | OPT_CALLEE_GOSUB) && \
	!ast_channel_audiohooks(chan) && !ast_channel_audiohooks(peer) && \
	ast_framehook_list_is_empty(ast_channel_framehooks(chan)) && ast_framehook_list_is_empty(ast_channel_framehooks(peer)))

```

Which means you can’t have any of the A, H, h, K, k, T, t, U, w, or W flags, you can’t have, probably amongst other things, MixMonitor set on either channel, and there is something about frames that is new to me.

I think it also said the caller can’t be entertained, which means you can’t have m, r, and presumably R.

---

<div class="post-metadata">

**Author:** ![NoFate](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/nofate/32/6511_2.png) [@NoFate](https://community.asterisk.org/u/NoFate)\
**Post date:** [May 5, 2022, 5:41pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/13 "2022-05-05T17:41:43Z")

</div>

@Summer =\> i was struggling with early media too, i have a doorintercom that sends video in 183 session, but my softphones never see it,… by just adding progress() it works , so i can see video + audio before picking up, but only on 1 to 1 calls …

@david551 do you think by just removing the keyword ‘single’ from that IF method, 1 to n (group calling) will work? is it that easy ??

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 5, 2022, 6:11pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/14 "2022-05-05T18:11:14Z")

</div>

> [@NoFate](#):
>
> @david551 do you think by just removing the keyword ‘single’ from that IF method, 1 to n (group calling) will work? is it that easy ??

Bridges tend to be synchronous, although my experience of them is from before the great bridge rework and introduction of the early media bridge. If it is synchronous, only the first outgoing channel will be looked at until that one answers, so it will effectively become “single”. If it is asynchronous, channels aren’t supposed to be in more than one bridge, so there is a good chance it will crash and burn, and, at best, you will get the video frames distributed randomly amongst the callees, with only one callee getting any one frame. You would also get an unholy mess or all the early media in the reverse direction being sent to the doorphone, at n times the normal frame rate.

The “single” constraint is there because things will only work in that case.

As I already said, I think someone patched the early media code in the core of app\_dial. Although I don’t think that is difficult, I’m not going to take responsibility for providing untested code, and provide any more details. It will probably take me as long as you to find the relevant thread. As far as I can see, the only real reason for not allowing it is the potentially large network bandwidth used; I think any official patch would require an option to enable it at run time.

---

<div class="post-metadata">

**Author:** ![NoFate](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/nofate/32/6511_2.png) [@NoFate](https://community.asterisk.org/u/NoFate)\
**Post date:** [May 5, 2022, 6:18pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/15 "2022-05-05T18:18:37Z")

</div>

Ah, where is that patched file? do you have a link somewhere?

I have a testserver, if i look in that “app\_dial.c” file  
Gonna remove it from here:  
line :1579 + 1548

```auto
						if (single && !caller_entertained
							&& CAN_EARLY_BRIDGE(peerflags, in, c)) {
							ast_channel_early_bridge(in, c);

```

Lets see what happens 🙂

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 5, 2022, 6:23pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/16 "2022-05-05T18:23:46Z")

</div>

> [@NoFate](#):
>
> Ah, where is that patched file? do you have a link somewhere?

As I said in my last post:

> [@david551](#):
>
> It will probably take me as long as you to find the relevant thread.

---

<div class="post-metadata">

**Author:** ![NoFate](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/nofate/32/6511_2.png) [@NoFate](https://community.asterisk.org/u/NoFate)\
**Post date:** [May 5, 2022, 6:29pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/17 "2022-05-05T18:29:16Z")

</div>

yeah, i’m already looking for a long while to have early media in group calls, never found a patched file 🙂  
But anwyay, compiling now 🙂

---

<div class="post-metadata">

**Author:** ![NoFate](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/nofate/32/6511_2.png) [@NoFate](https://community.asterisk.org/u/NoFate)\
**Post date:** [May 5, 2022, 6:42pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/18 "2022-05-05T18:42:08Z")

</div>

ok, removing single didnt work, that would be too easy 🙂  
if you ever find that patched file, lemme know!! 🙂

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [May 5, 2022, 7:26pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/19 "2022-05-05T19:26:45Z")

</div>

You would need to add code to handle AST\_FRAME\_VIDEO to the main processing. You might also need to handle AST\_CONTROL\_VIDUPDATE in the reverse direction but that might create big bandwidth problems if done naively.

---

<div class="post-metadata">

**Author:** ![NoFate](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/nofate/32/6511_2.png) [@NoFate](https://community.asterisk.org/u/NoFate)\
**Post date:** [May 5, 2022, 7:29pm UTC](https://community.asterisk.org/t/how-to-get-video-preview/92485/20 "2022-05-05T19:29:30Z")

</div>

Yeah, that’s out of my league 🙂

I need some help of a developer here

[Next page](https://community.asterisk.org/t/how-to-get-video-preview/92485.md?page=2)
