webrtcbin: improve some debugging output

- Put human readable names into debug strings.
- Demote some frequent rtpbin signal logging
- Don't use GST_PTR_FORMAT in g_set_error()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1664>
This commit is contained in:
Matthew Waters 2021-07-21 17:48:34 +10:00 committed by GStreamer Marge Bot
parent c02c8a85ce
commit cda81bdb1e
3 changed files with 51 additions and 28 deletions

View file

@ -2218,6 +2218,7 @@ _create_webrtc_transceiver (GstWebRTCBin * webrtc,
GstWebRTCRTPTransceiverDirection direction, guint mline, GstWebRTCKind kind,
GstCaps * codec_preferences)
{
char *dir_str = gst_webrtc_rtp_transceiver_direction_to_string (direction);
WebRTCTransceiver *trans;
GstWebRTCRTPTransceiver *rtp_trans;
GstWebRTCRTPSender *sender;
@ -2235,6 +2236,10 @@ _create_webrtc_transceiver (GstWebRTCBin * webrtc,
/* FIXME: We don't support stopping transceiver yet so they're always not stopped */
rtp_trans->stopped = FALSE;
GST_LOG_OBJECT (webrtc, "created new transceiver %" GST_PTR_FORMAT " with "
"direction %s (%d), mline %u, kind %s (%d)", rtp_trans, dir_str,
direction, mline, gst_webrtc_kind_to_string (kind), kind);
g_signal_connect_object (sender, "notify::priority",
G_CALLBACK (gst_webrtc_bin_attach_tos), webrtc, G_CONNECT_SWAPPED);
@ -2246,6 +2251,8 @@ _create_webrtc_transceiver (GstWebRTCBin * webrtc,
g_signal_emit (webrtc, gst_webrtc_bin_signals[ON_NEW_TRANSCEIVER_SIGNAL],
0, trans);
g_free (dir_str);
return trans;
}
@ -3474,10 +3481,9 @@ _create_offer_task (GstWebRTCBin * webrtc, const GstStructure * options,
if (wtrans->mline_locked && trans->mline != media_idx) {
g_set_error (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE,
"Previous negotiatied transceiver %"
GST_PTR_FORMAT " with mid %s was in mline %d but transceiver"
" has locked mline %u", trans, trans->mid, media_idx,
trans->mline);
"Previous negotiatied transceiver <%s> with mid %s was in "
"mline %d but transceiver has locked mline %u",
GST_OBJECT_NAME (trans), trans->mid, media_idx, trans->mline);
goto cancel_offer;
}
@ -3626,8 +3632,8 @@ _create_offer_task (GstWebRTCBin * webrtc, const GstStructure * options,
g_set_error (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE,
"Tranceiver %" GST_PTR_FORMAT " with mid %s has locked mline %d"
" but the whole offer only has %u sections", trans, trans->mid,
"Tranceiver <%s> with mid %s has locked mline %d but the offer "
"only has %u sections", GST_OBJECT_NAME (trans), trans->mid,
trans->mline, media_idx);
goto cancel_offer;
}
@ -4179,11 +4185,15 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options,
goto rejected;
}
if (!_update_transceiver_kind_from_caps (rtp_trans, answer_caps))
if (!_update_transceiver_kind_from_caps (rtp_trans, answer_caps)) {
GstWebRTCKind caps_kind = webrtc_kind_from_caps (answer_caps);
GST_WARNING_OBJECT (webrtc,
"Trying to change transceiver %d kind from %d to %d",
rtp_trans->mline, rtp_trans->kind,
webrtc_kind_from_caps (answer_caps));
"Trying to change kind of transceiver %" GST_PTR_FORMAT
" at m-line %d from %s (%d) to %s (%d)", trans, rtp_trans->mline,
gst_webrtc_kind_to_string (rtp_trans->kind), rtp_trans->kind,
gst_webrtc_kind_to_string (caps_kind), caps_kind);
}
answer_caps = gst_caps_make_writable (answer_caps);
for (k = 0; k < gst_caps_get_size (answer_caps); k++) {
@ -5042,15 +5052,15 @@ _update_transceiver_from_sdp_media (GstWebRTCBin * webrtc,
if (!g_strcmp0 (gst_sdp_media_get_media (media), "audio")) {
if (rtp_trans->kind == GST_WEBRTC_KIND_VIDEO)
GST_FIXME_OBJECT (webrtc,
"Updating video transceiver to audio, which isn't fully supported.");
GST_FIXME_OBJECT (webrtc, "Updating video transceiver %" GST_PTR_FORMAT
" to audio, which isn't fully supported.", rtp_trans);
rtp_trans->kind = GST_WEBRTC_KIND_AUDIO;
}
if (!g_strcmp0 (gst_sdp_media_get_media (media), "video")) {
if (rtp_trans->kind == GST_WEBRTC_KIND_AUDIO)
GST_FIXME_OBJECT (webrtc,
"Updating audio transceiver to video, which isn't fully supported.");
GST_FIXME_OBJECT (webrtc, "Updating audio transceiver %" GST_PTR_FORMAT
" to video, which isn't fully supported.", rtp_trans);
rtp_trans->kind = GST_WEBRTC_KIND_VIDEO;
}
@ -5628,19 +5638,25 @@ check_locked_mlines (GstWebRTCBin * webrtc, GstWebRTCSessionDescription * sdp,
if (rtp_trans->kind != GST_WEBRTC_KIND_UNKNOWN) {
if (!g_strcmp0 (gst_sdp_media_get_media (media), "audio") &&
rtp_trans->kind != GST_WEBRTC_KIND_AUDIO) {
char *trans_kind = gst_webrtc_kind_to_string (rtp_trans->kind);
g_set_error (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE,
"m-line %d was locked to audio, but SDP has %s media", i,
"m-line %d with transceiver <%s> was locked to %s, but SDP has "
"%s media", i, GST_OBJECT_NAME (rtp_trans), trans_kind,
gst_sdp_media_get_media (media));
g_free (trans_kind);
return FALSE;
}
if (!g_strcmp0 (gst_sdp_media_get_media (media), "video") &&
rtp_trans->kind != GST_WEBRTC_KIND_VIDEO) {
char *trans_kind = gst_webrtc_kind_to_string (rtp_trans->kind);
g_set_error (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE,
"m-line %d was locked to video, but SDP has %s media", i,
"m-line %d with transceiver <%s> was locked to %s, but SDP has "
"%s media", i, GST_OBJECT_NAME (rtp_trans), trans_kind,
gst_sdp_media_get_media (media));
g_free (trans_kind);
return FALSE;
}
}
@ -6659,7 +6675,7 @@ on_rtpbin_request_pt_map (GstElement * rtpbin, guint session_id, guint pt,
if ((ret = transport_stream_get_caps_for_pt (stream, pt)))
gst_caps_ref (ret);
GST_TRACE_OBJECT (webrtc, "Found caps %" GST_PTR_FORMAT " for pt %d in "
GST_DEBUG_OBJECT (webrtc, "Found caps %" GST_PTR_FORMAT " for pt %d in "
"session %d", ret, pt, session_id);
return ret;
@ -7234,10 +7250,15 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
GST_LOG_OBJECT (webrtc, "Using existing transceiver %" GST_PTR_FORMAT
" for mline %u", trans, serial);
if (caps) {
if (!_update_transceiver_kind_from_caps (trans, caps))
if (!_update_transceiver_kind_from_caps (trans, caps)) {
GstWebRTCKind caps_kind = webrtc_kind_from_caps (caps);
GST_WARNING_OBJECT (webrtc,
"Trying to change transceiver %d kind from %d to %d",
serial, trans->kind, webrtc_kind_from_caps (caps));
"Trying to change kind of transceiver %" GST_PTR_FORMAT
" at m-line %d from %s (%d) to %s (%d)", trans, serial,
gst_webrtc_kind_to_string (trans->kind), trans->kind,
gst_webrtc_kind_to_string (caps_kind), caps_kind);
}
}
}
pad = _create_pad_for_sdp_media (webrtc, GST_PAD_SINK, trans, serial);

View file

@ -67,6 +67,9 @@ GstCaps * _rtp_caps_from_media (const GstSDPMedia * media);
G_GNUC_INTERNAL
GstWebRTCKind webrtc_kind_from_caps (const GstCaps * caps);
#define gst_webrtc_kind_to_string(kind) _enum_value_to_string(GST_TYPE_WEBRTC_KIND, kind)
#define gst_webrtc_rtp_transceiver_direction_to_string(dir) _enum_value_to_string(GST_TYPE_WEBRTC_RTP_TRANSCEIVER_DIRECTION, dir)
G_END_DECLS
#endif /* __WEBRTC_UTILS_H__ */

View file

@ -3912,9 +3912,8 @@ GST_START_TEST (test_reject_create_offer)
gst_structure_get (s, "error", G_TYPE_ERROR, &error, NULL);
fail_unless (g_error_matches (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE));
fail_unless (g_str_match_string
("has locked mline 1 but the whole offer only has 0 sections",
error->message, FALSE));
fail_unless_equals_string (error->message,
"Tranceiver <webrtctransceiver0> with mid (null) has locked mline 1 but the offer only has 0 sections");
g_clear_error (&error);
gst_promise_unref (promise);
@ -3986,9 +3985,9 @@ GST_START_TEST (test_reject_set_description)
gst_structure_get (s, "error", G_TYPE_ERROR, &error, NULL);
fail_unless (g_error_matches (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE));
fail_unless (g_str_match_string
("m-line 0 was locked to audio, but SDP has audio media", error->message,
FALSE));
fail_unless_equals_string
(error->message,
"m-line 0 with transceiver <webrtctransceiver1> was locked to video, but SDP has audio media");
g_clear_error (&error);
fail_unless (s != NULL);
@ -4186,9 +4185,9 @@ GST_START_TEST (test_codec_preferences_negotiation_sinkpad)
gst_structure_get (s, "error", G_TYPE_ERROR, &error, NULL);
fail_unless (g_error_matches (error, GST_WEBRTC_ERROR,
GST_WEBRTC_ERROR_INTERNAL_FAILURE));
fail_unless (g_str_match_string
fail_unless_equals_string
("Caps negotiation on pad sink_0 failed against codec preferences",
error->message, FALSE));
error->message);
g_clear_error (&error);
gst_promise_unref (promise);