g_free(sig_data);
}
-static void __webrtcbin_on_negotiation_needed(GstElement *webrtcbin, gpointer user_data)
+static void __webrtcbin_on_negotiation_needed_cb(GstElement *webrtcbin, gpointer user_data)
{
webrtc_s *webrtc = (webrtc_s *)user_data;
LOG_DEBUG("<<< end of the callback");
}
-static void __webrtcbin_on_ice_candidate(GstElement *webrtcbin, guint mlineindex, gchar *candidate, gpointer user_data)
+static void __webrtcbin_on_ice_candidate_cb(GstElement *webrtcbin, guint mlineindex, gchar *candidate, gpointer user_data)
{
webrtc_s *webrtc = (webrtc_s *)user_data;
gchar *_candidate;
free(_param_candidate);
}
+static void __webrtcbin_peer_connection_state_cb(GstElement *webrtcbin, GParamSpec * pspec, gpointer user_data)
+{
+ webrtc_s *webrtc = (webrtc_s *)user_data;
+ GstWebRTCPeerConnectionState peer_connection_state;
+ const gchar *new_state = "UNKNOWN";
+
+ RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ g_object_get(webrtcbin, "connection-state", &peer_connection_state, NULL);
+
+ switch (peer_connection_state) {
+ case GST_WEBRTC_PEER_CONNECTION_STATE_NEW:
+ new_state = "NEW";
+ break;
+ case GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTING:
+ new_state = "CONNECTING";
+ break;
+ case GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTED:
+ new_state = "CONNECTED";
+ break;
+ case GST_WEBRTC_PEER_CONNECTION_STATE_DISCONNECTED:
+ new_state = "DISCONNECTED";
+ break;
+ case GST_WEBRTC_PEER_CONNECTION_STATE_FAILED:
+ new_state = "FAILED";
+ break;
+ case GST_WEBRTC_PEER_CONNECTION_STATE_CLOSED:
+ new_state = "CLOSED";
+ break;
+ }
+
+ LOG_DEBUG("[PeerConnectionState] is changed to [%s]", new_state);
+}
+
+static void __webrtcbin_signaling_state_cb(GstElement *webrtcbin, GParamSpec * pspec, gpointer user_data)
+{
+ webrtc_s *webrtc = (webrtc_s *)user_data;
+ GstWebRTCSignalingState signaling_state;
+ const gchar *new_state = "UNKNOWN";
+
+ RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ g_object_get(webrtcbin, "signaling-state", &signaling_state, NULL);
+
+ switch (signaling_state) {
+ case GST_WEBRTC_SIGNALING_STATE_STABLE:
+ new_state = "STABLE";
+ break;
+ case GST_WEBRTC_SIGNALING_STATE_CLOSED:
+ new_state = "CLOSED";
+ break;
+ case GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER:
+ new_state = "HAVE_LOCAL_OFFER";
+ break;
+ case GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER:
+ new_state = "HAVE_REMOTE_OFFER";
+ break;
+ case GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_PRANSWER:
+ new_state = "HAVE_LOCAL_PRANSWER";
+ break;
+ case GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_PRANSWER:
+ new_state = "HAVE_REMOTE_PRANSWER";
+ break;
+ }
+
+ LOG_DEBUG("[SignalingState] is changed to [%s]", new_state);
+}
+
+static void __webrtcbin_ice_gathering_state_cb(GstElement *webrtcbin, GParamSpec * pspec, gpointer user_data)
+{
+ webrtc_s *webrtc = (webrtc_s *)user_data;
+ GstWebRTCICEGatheringState ice_gathering_state;
+ const gchar *new_state = "UNKNOWN";
+
+ RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ g_object_get(webrtcbin, "ice-gathering-state", &ice_gathering_state, NULL);
+
+ switch (ice_gathering_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;
+ }
+
+ LOG_DEBUG("[IceGatheringState] is changed to [%s]", new_state);
+}
+
+static void __webrtcbin_ice_connection_state_cb(GstElement *webrtcbin, GParamSpec * pspec, gpointer user_data)
+{
+ webrtc_s *webrtc = (webrtc_s *)user_data;
+ GstWebRTCICEConnectionState ice_connection_state;
+ const gchar *new_state = "UNKNOWN";
+
+ RET_IF(webrtcbin == NULL, "webrtcbin is NULL");
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ g_object_get(webrtcbin, "ice-connection-state", &ice_connection_state, NULL);
+
+ switch (ice_connection_state) {
+ case GST_WEBRTC_ICE_CONNECTION_STATE_NEW:
+ new_state = "NEW";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_CHECKING:
+ new_state = "CHECKING";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_CONNECTED:
+ new_state = "CONNECTED";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED:
+ new_state = "COMPLETED";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_FAILED:
+ new_state = "FAILED";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_DISCONNECTED:
+ new_state = "DISCONNECTED";
+ break;
+ case GST_WEBRTC_ICE_CONNECTION_STATE_CLOSED:
+ new_state = "CLOSED";
+ break;
+ }
+
+ LOG_DEBUG("[IceConnectionState] is changed to [%s]", new_state);
+}
+
int _gst_build_pipeline(webrtc_s *webrtc)
{
RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
LOG_ERROR("failed to create webrtcbin");
goto error;
}
- __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "on-negotiation-needed", G_CALLBACK(__webrtcbin_on_negotiation_needed), webrtc);
- __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "on-ice-candidate", G_CALLBACK(__webrtcbin_on_ice_candidate), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "on-negotiation-needed", G_CALLBACK(__webrtcbin_on_negotiation_needed_cb), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "on-ice-candidate", G_CALLBACK(__webrtcbin_on_ice_candidate_cb), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "notify::connection-state", G_CALLBACK(__webrtcbin_peer_connection_state_cb), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "notify::signaling-state", G_CALLBACK(__webrtcbin_signaling_state_cb), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "notify::ice-gathering-state", G_CALLBACK(__webrtcbin_ice_gathering_state_cb), webrtc);
+ __connect_and_append_signal(&webrtc->signals, webrtc->gst.webrtcbin, "notify::ice-connection-state", G_CALLBACK(__webrtcbin_ice_connection_state_cb), webrtc);
if (!gst_bin_add(GST_BIN(webrtc->gst.pipeline), webrtc->gst.webrtcbin)) {
LOG_ERROR("failed to gst_bin_add(), [%s] -> [%s] pipeline", GST_ELEMENT_NAME(webrtc->gst.webrtcbin), GST_ELEMENT_NAME(webrtc->gst.pipeline));