Topology issue with SIP video recording

Hi,

I developed a module for video calling. Both bridged channels are SIP type.

I want to be able to record the video call. To do this, I implemented a mechanism similar to app_confbridge, that is, I create a custom channel, where I enable the video and audio methods and add it to the bridge.
So that all channels see everything, I configure the bridge with sfu mode.
All this works correctly and I have the audio and video frames to record the video call.
The problem I have is ending the call. As the topologies are not defined in the channels when I finish the bridge, I have this stack:

# 0 0x0000563526c5da9c in ast_stream_topology_get_count (topology = 0x0) at stream.c: 525
# 1 0x00007f25b6274362 in remove_destination_streams (topology = 0x0, channel_name = 0x7f25e0028332 "SIP / 1093-00000001") at bridge_softmix.c: 782
# 2 0x00007f25b62743be in sfu_topologies_on_leave (leaver = 0x7f26040103a0, participants = 0x7f26040066e0) at bridge_softmix.c: 802
# 3 0x00007f25b62744a8 in softmix_bridge_leave (bridge = 0x7f26040066b0, bridge_channel = 0x7f26040103a0) at bridge_softmix.c: 829
# 4 0x0000563526b1f89a in bridge_channel_internal_pull (bridge_channel = 0x7f26040103a0) at bridge_channel.c: 2198
# 5 0x0000563526b21d0c in bridge_channel_internal_join (bridge_channel = 0x7f26040103a0) at bridge_channel.c: 2999
# 6 0x0000563526b030a2 in bridge_channel_depart_thread (data = 0x7f26040103a0) at bridge.c: 1790
# 7 0x0000563526c7a3e9 in dummy_start (data = 0x7f260400bed0) at utils.c: 1299
# 8 0x00007f2627f6b6db in start_thread (arg = 0x7f2624797700) at pthread_create.c: 463
# 9 0x00007f26274a488f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I saw that pjsip has a method ast_request_with_stream_topology:

/* Allow either format capabilities or stream topology to be provided and adapt */
if (chan->tech->requester_with_stream_topology) {
	struct ast_stream_topology *tmp_converted_topology = NULL;

	if (!topology && request_cap) {
		/* Turn the requested capabilities into a stream topology */
		topology = tmp_converted_topology = ast_stream_topology_create_from_format_cap(request_cap);
	}

	c = chan->tech->requester_with_stream_topology(type, topology, assignedids, requestor, addr, cause);

	ast_stream_topology_free(tmp_converted_topology);

Try adding manually the topology of each channel based on the capabilities without success.
*topology = ast_stream_topology_create_from_format_cap(cap);

Some clue on how to move forward.
Thanks.

http://lists.digium.com/mailman/listinfo/asterisk-dev

#asterisk-dev on irc.freenode.net