openwebrtc icon indicating copy to clipboard operation
openwebrtc copied to clipboard

ERROR:owr_transport_agent.c:917:remove_existing_send_source_and_payload: assertion failed: (sinkpad)

Open xelven opened this issue 9 years ago • 20 comments

On iOS Native,

cerbero version 2015/12/4
openssl: Bump to 1.0.2e
git:4e8ec2994bb3298db37c3f84356260e86ea3e07a

when the streaming didnt connected and call below api from reset() will crash every time.

owr_media_session_set_send_source(media_session, NULL);

but when it's connected to other whatever audio or video are all fine.

crash log call stack below: https://gist.github.com/xelven/e7387e494b79a0b8090b

xelven avatar Feb 22 '16 03:02 xelven

I was want to fix it, but seems

/* Unlink the source bin */
    g_object_get(media_source, "media-type", &media_type, NULL);
    g_warn_if_fail(media_type != OWR_MEDIA_TYPE_UNKNOWN);
    if (media_type == OWR_MEDIA_TYPE_VIDEO)
        pad_name = g_strdup_printf("video_sink_%u_%u", OWR_CODEC_TYPE_NONE, stream_id);
    else
        pad_name = g_strdup_printf("audio_raw_sink_%u", stream_id);
    sinkpad = gst_element_get_static_pad(transport_agent->priv->transport_bin, pad_name);
    g_assert(sinkpad);
    g_free(pad_name);

when the streaming didn't connected the sinkpad always NULL.

it should be linked from handle_new_send_payload right? as below

name = g_strdup_printf("audio_raw_sink_%u", stream_id);
        sink_pad = gst_element_get_static_pad(encoder, "sink");
        add_pads_to_bin_and_transport_bin(sink_pad, send_input_bin,
            transport_agent->priv->transport_bin, name);

xelven avatar Feb 22 '16 03:02 xelven

and any other questions, I was avoid this crash, let it call _owr_media_session_clear_closures to clear on_send_source pointer function, it works, But when the connection are connected, after hangup the send packet still sending 10k/s as audio call. photo 16-2-22 11 21 39

I found there are owr_data_session or other session for handle it? it cloud be clean by other way?

xelven avatar Feb 22 '16 03:02 xelven

Hello @xelven, i have this problem too when hangup the call, you check the sink_pad NULL then replace it with name = g_strdup_printf("audio_raw_sink_%u", stream_id); sink_pad = gst_element_get_static_pad(encoder, "sink"); add_pads_to_bin_and_transport_bin(sink_pad, send_input_bin, transport_agent->priv->transport_bin, name); right? then g_assert new sink_pad and free it?

luiyen avatar Feb 23 '16 09:02 luiyen

@pubbus No, I can avoid this crash now, when the streaming didn't connected, just clean closures, if is been connected don't clean closures, after I tested all fine right now.

xelven avatar Feb 24 '16 03:02 xelven

and I believe call gst_element_get_static_pad get NULL. it should be a problem from GStreamer, or the method call are wrong somewhere.

xelven avatar Feb 24 '16 03:02 xelven

@xelven where i must call _owr_media_session_clear_closures? when sink_pad is NULL then call it?

luiyen avatar Feb 24 '16 03:02 luiyen

you should handle the connect status, I didn't check sink_pad is NULL. Just if has been connected then call media session set NULL otherwise call clear_closures

xelven avatar Feb 24 '16 10:02 xelven

@xelven thanks you so much, i will try it!

luiyen avatar Feb 24 '16 10:02 luiyen

@xelven i check connected by set bool status on got_remote_source, how do you check Connected status? and another question: how can i call _owr_media_session_clear_closures? must rebuild framework by cerbero, or just place it on Header file of OpenWebRTCNativeHandler. thanks you so much!

luiyen avatar Mar 04 '16 10:03 luiyen

it's depend on what is your app design, for example when you change the UI status from calling to connected. for me if I got the remote source it is.

for _owr_media_session_clear_closures this one, could you try if the status didn't connected just don't call it owr_media_session_set_send_source(media_session, NULL);

xelven avatar Mar 07 '16 03:03 xelven

@xelven thanks for your help, but i can't find _owr_media_session_clear_closures, i must declare it on OpenWebRTCNativeHandler.h then call it? or rebuild the OpenWebRTC by cerbero?

luiyen avatar Mar 07 '16 03:03 luiyen

yeah you should build you own, but if the status didn't connected just don't call it owr_media_session_set_send_source(media_session, NULL); are same way. try it first

xelven avatar Mar 07 '16 03:03 xelven

@xelven i tried not to call owr_media_session_set_send_source(media_session,NULL); when the status didn't connected and it's work. :+1:

luiyen avatar Mar 07 '16 03:03 luiyen

@pubbus : )

xelven avatar Mar 07 '16 03:03 xelven

@xelven is this something that could be added to OpenWebRTC as a proper fix?

stefanalund avatar Mar 07 '16 07:03 stefanalund

@stefanalund currently I just avoid this crash when user hangup the call. not fix that. I was take look it and I guess this is relate GStreamer somehow, But because there have more important issue on me (those ICE connection issues) right now, so I don't time to fix this, so just avoid it.

xelven avatar Mar 08 '16 01:03 xelven

I solved the issue by overwriting some methods from the OpenWebrtc framework inside the iOS project. Better would be to provide these methods using it in iOS as well.

Following stuff solves the issue in my app:

` OwrMediaType media_type; guint stream_id;

if (transport_agent) {
    media_sessions = g_object_steal_data(G_OBJECT(transport_agent), "media-sessions");
    for (item = media_sessions; item; item = item->next) {
        media_session = OWR_MEDIA_SESSION(item->data);

        OwrMediaSource *media_source = _owr_media_session_get_send_source_OVERWRITTEN(media_session);

        stream_id = get_stream_id(transport_agent, OWR_SESSION(media_session));

        g_object_get(media_source, "media-type", &media_type, NULL);
        g_warn_if_fail(media_type != OWR_MEDIA_TYPE_UNKNOWN);

        gchar *pad_name;
        if (media_type == OWR_MEDIA_TYPE_VIDEO) {
            pad_name = g_strdup_printf("video_sink_%u_%u", OWR_CODEC_TYPE_NONE, stream_id);
        }
        else {
            pad_name = g_strdup_printf("audio_raw_sink_%u", stream_id);
        }

        GstPad *sinkpad = gst_element_get_static_pad(transport_agent->priv->transport_bin, pad_name);
        g_free(pad_name);

        //FIXED Error: ERROR:owr_transport_agent.c:917:remove_existing_send_source_and_payload: assertion failed: (sinkpad)
        //@see https://github.com/EricssonResearch/openwebrtc/issues/574
        g_warn_if_fail(sinkpad != NULL);
        if(sinkpad != NULL){
            owr_media_session_set_send_source(media_session, NULL);
        }
    }
    g_list_free(media_sessions);
    g_object_unref(transport_agent);
    transport_agent = NULL;
}`

cwack-letsdev avatar May 31 '16 19:05 cwack-letsdev

Hi all! @cwack-letsdev I have used your code but It seems to have two problem.

1 - Use of undeclared identifier 'GstPad' in line: GstPad *sinkpad = gst_element_get_static_pad(...) 2 - Incomplete definition of type 'struct _OwrTransportAgentPrivate' in line: transport_agent->priv->transport_bin

How can I resolve them?

Thank You in advance

pakygta avatar Jun 09 '16 14:06 pakygta

@xelven @cwack-letsdev thanks for the workaround here.

james-huang avatar Jun 12 '16 04:06 james-huang

Hi @pakygta,

same here, you have to copy them from OpenWebrtc Framework. see also https://github.com/EricssonResearch/openwebrtc-examples/issues/128#issuecomment-225417861

cwack-letsdev avatar Jun 12 '16 16:06 cwack-letsdev