gstreamer webrtcbin TURN STURN only get typ host candidate?

Olivier Crête olivier.crete at collabora.com
Thu Nov 24 05:01:07 UTC 2022


Hi,

I was going to to you to that API.

In any case, the  problem is outside of libnice, the STUN server is
never set on libnice. It seems that the async resolution of the STUN &
TURN servers never completes. I see neither of the messages in
nice.c:on_resolve_host()

Olivier

On Thu, 2022-11-24 at 11:15 +0800, 孙建希 wrote:
> nice_debug_enable(1); get log.
> 
> On Thu, Nov 24, 2022 at 10:31 AM 孙建希 <ycsunjane at gmail.com> wrote:
> > 
> > there is no libnice log:
> > 
> > g_log_set_default_handler(glib_debug, NULL);
> > 
> > void glib_debug(const gchar *log_domain, GLogLevelFlags log_level,
> > const gchar *message, gpointer user_data)
> > {
> >   g_print("jianxi: %s %d %s\n", log_domain, log_level, message);
> >   //__android_log_print (ANDROID_LOG_ERROR,"GstWebRTC", "%s %d
> > %s\n",
> > log_domain, log_level, message);
> > }
> > 
> > only print libsoup and glib GLib-GIO log.
> > 
> > gstreamer version: gstreamer-1.0-android-universal-1.21.2.tar.xz
> > 
> > On Thu, Nov 24, 2022 at 9:50 AM 孙建希 <ycsunjane at gmail.com> wrote:
> > > 
> > > android can not set environment for glib.
> > > 
> > > g_log_set_handler("libnice", G_LOG_LEVEL_MASK, glib_debug, NULL);
> > > gst_debug_set_threshold_for_name("*webrtc*", 9);
> > > 
> > > void glib_debug(const gchar *log_domain, GLogLevelFlags
> > > log_level,
> > > const gchar *message, gpointer user_data)
> > > {
> > >   g_print("%s %d %s\n", log_domain, log_level, message);
> > > }
> > > 
> > > On Thu, Nov 24, 2022 at 1:31 AM Olivier Crête
> > > <olivier.crete at collabora.com> wrote:
> > > > 
> > > > Hi,
> > > > 
> > > > Can you look at the webrtc logs (GST_DEBUG=*webrtc*:9) and
> > > > maybe even
> > > > the libnice logs G_MESSAGES_DEBUG=libnice to see if the STUN
> > > > server is
> > > > actually given down to libnice and libnice does it job
> > > > correctly ?
> > > > 
> > > > Olivier
> > > > 
> > > > On Wed, 2022-11-23 at 16:44 +0800, 孙建希 via gstreamer-devel
> > > > wrote:
> > > > > Test gstreamer webrtcbin android example, in local network
> > > > > everything
> > > > > is ok.But cross network, webrtc paused. ice send from android
> > > > > is all
> > > > > `typ host`.
> > > > > 
> > > > > ```
> > > > > Got ice server: candidate:1 1 UDP 2015363327 127.0.0.1 42258
> > > > > typ host
> > > > > index: 0
> > > > > Got ice server: candidate:2 1 TCP 1015021823 127.0.0.1 9 typ
> > > > > host
> > > > > tcptype active index: 0
> > > > > Got ice server: candidate:3 1 TCP 1010827519 127.0.0.1 36241
> > > > > typ host
> > > > > tcptype passive index: 0
> > > > > Got ice server: candidate:4 1 UDP 2015363583 10.0.2.16 40513
> > > > > typ host
> > > > > index: 0
> > > > > Got ice server: candidate:5 1 TCP 1015022079 10.0.2.16 9 typ
> > > > > host
> > > > > tcptype active index: 0
> > > > > Got ice server: candidate:6 1 TCP 1010827775 10.0.2.16 52791
> > > > > typ host
> > > > > tcptype passive index: 0
> > > > > Got ice server: candidate:7 1 UDP 2015363839 10.0.2.15 38413
> > > > > typ host
> > > > > index: 0
> > > > > Got ice server: candidate:8 1 TCP 1015022335 10.0.2.15 9 typ
> > > > > host
> > > > > tcptype active index: 0
> > > > > Got ice server: candidate:9 1 TCP 1010828031 10.0.2.15 42225
> > > > > typ host
> > > > > tcptype passive index: 0
> > > > > ```
> > > > > 
> > > > > ```
> > > > > #define STUN_SERVER " stun-server=stun://47.104.15.123:3478 "
> > > > > #define TURN_SERVER " turn-
> > > > > server=turn://jianxi:jianxi@47.104.15.123:3478 "
> > > > >   webrtc->pipe =
> > > > >       gst_parse_launch ("webrtcbin bundle-policy=max-bundle
> > > > > name=sendrecv "
> > > > >                         STUN_SERVER TURN_SERVER
> > > > > 
> > > > > ```
> > > > > 
> > > > > if set `GST_WEBRTC_ICE_TRANSPORT_POLICY_RELAY`, android will
> > > > > not send
> > > > > any ice candidate.
> > > > > 
> > > > > 
> > > > > sturn turn server is okay. Can not catch stun packet with
> > > > > wireshark.
> > > > > 
> > > > > ```
> > > > >   g_signal_connect (webrtc->webrtcbin, "on-ice-candidate",
> > > > >       G_CALLBACK (send_ice_candidate_message), webrtc);
> > > > >   g_signal_connect (webrtc->webrtcbin, "notify::ice-
> > > > > gathering-state",
> > > > >                     G_CALLBACK
> > > > > (on_ice_gathering_state_notify),
> > > > > NULL);
> > > > >   g_signal_connect (webrtc->webrtcbin, "notify::ice-
> > > > > connection-
> > > > > state",
> > > > >                     G_CALLBACK
> > > > > (on_ice_gathering_state_notify),
> > > > > NULL);
> > > > > ```
> > > > > 
> > > > > gstreamer get signal notify:
> > > > > 
> > > > > ```
> > > > > static void
> > > > > on_ice_gathering_state_notify (GstElement * webrtcbin,
> > > > > GParamSpec *
> > > > > pspec,
> > > > >                                gpointer user_data)
> > > > > {
> > > > >   GstWebRTCICEConnectionState ice_connect_state;
> > > > >   GstWebRTCICEGatheringState ice_gather_state;
> > > > >   gchar *stunser = NULL, *turnser = NULL;
> > > > >   const gchar *new_state = "unknown";
> > > > >   g_object_get (webrtcbin, "stun-server", &stunser, NULL);
> > > > >   if(stunser) {
> > > > >     gst_print("stun-server: %s\n", stunser);
> > > > >     g_free(stunser);
> > > > >   }
> > > > > 
> > > > >   g_object_get (webrtcbin, "turn-server", &turnser, NULL);
> > > > >   if(turnser) {
> > > > >     gst_print("turn-server: %s\n", turnser);
> > > > >     g_free(turnser);
> > > > >   }
> > > > > 
> > > > >   g_object_get (webrtcbin, "ice-gathering-state",
> > > > > &ice_gather_state,
> > > > > NULL);
> > > > >   g_object_get (webrtcbin, "ice-connection-state",
> > > > > &ice_connect_state, NULL);
> > > > > 
> > > > >   switch (ice_gather_state) {
> > > > >     case GST_WEBRTC_ICE_GATHERING_STATE_NEW:
> > > > >       new_state = "new";
> > > > >           break;
> > > > >     case GST_WEBRTC_ICE_GATHERING_STATE_GATHERING:
> > > > >       new_state = "gathering";
> > > > >           break;
> > > > >     case GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE:
> > > > >       new_state = "complete";
> > > > >           break;
> > > > >   }
> > > > >   gst_print ("ICE gathering state changed to %s, %d\n",
> > > > > new_state,
> > > > > ice_connect_state);
> > > > > }
> > > > > ```
> > > > > ```
> > > > > 2022-11-23 11:35:50.239  1638-5461  GLib+stdout
> > > > > org.freedesktop.gstreamer.webrtc     I  stun-server:
> > > > > stun://47.104.15.123:3478
> > > > > 2022-11-23 11:35:50.239  1638-5461  GLib+stdout
> > > > > org.freedesktop.gstreamer.webrtc     I  turn-server:
> > > > > turn://jianxi:jianxi@47.104.15.123:3478
> > > > > 2022-11-23 11:35:50.239  1638-5461  GLib+stdout
> > > > > org.freedesktop.gstreamer.webrtc     I  ICE gathering state
> > > > > changed
> > > > > to
> > > > > complete, 4
> > > > > ```
> > > > > 
> > > > > ice end is 4 `GST_WEBRTC_ICE_CONNECTION_STATE_FAILED`.
> > > > 
> > > > --
> > > > Olivier Crête
> > > > olivier.crete at collabora.com
> > > > 

-- 
Olivier Crête
olivier.crete at collabora.com



More information about the gstreamer-devel mailing list