Lorenzo, Thanks for replying.
I understand and I have one opinion.
I think the core of this issue is that ps->publisher becomes NULL before the (publisher stream) ps is freed.
In the commit below, the janus_videoroom_publisher_stream_destroy() function was added, and when removing participant->streams_byid, ps->publisher is set to NULL. I assume there must be a reason for this.
I’m wondering if it can be handled using either method ① or ②.
① Add a janus_refcount_decrease(&ps->publisher->ref) call inside janus_videoroom_publisher_stream_free.
→ It is possible to access ps->publisher until the (publisher stream) ps is freed.
② When removing publisher->streams_byid, only perform janus_refcount_decrease.
→ In janus_videoroom_publisher_free, janus_videoroom_publisher_stream_destroy is executed via
g_list_free_full(p->streams, (GDestroyNotify)(janus_videoroom_publisher_stream_destroy));
No, free must only free stuff. Crossed references are already dealt in different ways.
The destroy callback function already only uses the refcount decrease. I don’t know what version you’re looking at, but I don’t see any g_list_free_full in janus_videoroom_publisher_stream_destroy. Stuff is only freed if a refcount decrease brings the reference count to 0.
g_list_free_full in janus_videoroom_publisher_free() function.
When a publisher is freed, all its streams are deleted through the janus_videoroom_publisher_stream_destroy() function."
janus_videoroom_publisher_free() {
....
/* Get rid of all the streams */
g_list_free_full(p->streams, (GDestroyNotify)(janus_videoroom_publisher_stream_destroy));
...
}