rtmp2: rtmpconnection: Use GST_*_OBJECT logging

GstRtmpConnection isn't a GstObject with a name or path, but we still
get the GObject's type and address.
This commit is contained in:
Jan Alexander Steffens (heftig) 2020-01-27 15:27:28 +01:00 committed by GStreamer Merge Bot
parent 424c593871
commit baad4fd91b

View file

@ -323,7 +323,7 @@ cancel_all_commands (GstRtmpConnection * self)
for (l = self->transactions; l; l = g_list_next (l)) { for (l = self->transactions; l; l = g_list_next (l)) {
Transaction *cc = l->data; Transaction *cc = l->data;
GST_LOG ("calling transaction callback %s", GST_LOG_OBJECT (self, "calling transaction callback %s",
GST_DEBUG_FUNCPTR_NAME (cc->func)); GST_DEBUG_FUNCPTR_NAME (cc->func));
cc->func ("<cancelled>", NULL, cc->user_data); cc->func ("<cancelled>", NULL, cc->user_data);
} }
@ -332,7 +332,7 @@ cancel_all_commands (GstRtmpConnection * self)
for (l = self->expected_commands; l; l = g_list_next (l)) { for (l = self->expected_commands; l; l = g_list_next (l)) {
ExpectedCommand *cc = l->data; ExpectedCommand *cc = l->data;
GST_LOG ("calling expected command callback %s", GST_LOG_OBJECT (self, "calling expected command callback %s",
GST_DEBUG_FUNCPTR_NAME (cc->func)); GST_DEBUG_FUNCPTR_NAME (cc->func));
cc->func ("<cancelled>", NULL, cc->user_data); cc->func ("<cancelled>", NULL, cc->user_data);
} }
@ -344,7 +344,7 @@ void
gst_rtmp_connection_close (GstRtmpConnection * self) gst_rtmp_connection_close (GstRtmpConnection * self)
{ {
if (self->thread != g_thread_self ()) { if (self->thread != g_thread_self ()) {
GST_ERROR ("Called from wrong thread"); GST_ERROR_OBJECT (self, "Called from wrong thread");
} }
g_cancellable_cancel (self->cancellable); g_cancellable_cancel (self->cancellable);
@ -409,7 +409,7 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data)
guint oldsize; guint oldsize;
GError *error = NULL; GError *error = NULL;
GST_TRACE ("input ready"); GST_TRACE_OBJECT (sc, "input ready");
oldsize = sc->input_bytes->len; oldsize = sc->input_bytes->len;
g_byte_array_set_size (sc->input_bytes, oldsize + READ_SIZE); g_byte_array_set_size (sc->input_bytes, oldsize + READ_SIZE);
@ -424,16 +424,17 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data)
if (error->domain == G_IO_ERROR && (code == G_IO_ERROR_WOULD_BLOCK || if (error->domain == G_IO_ERROR && (code == G_IO_ERROR_WOULD_BLOCK ||
code == G_IO_ERROR_TIMED_OUT || code == G_IO_ERROR_AGAIN)) { code == G_IO_ERROR_TIMED_OUT || code == G_IO_ERROR_AGAIN)) {
/* should retry */ /* should retry */
GST_DEBUG ("read IO error %d %s, continuing", code, error->message); GST_DEBUG_OBJECT (sc, "read IO error %d %s, continuing",
code, error->message);
g_error_free (error); g_error_free (error);
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
GST_ERROR ("read error: %s %d %s", g_quark_to_string (error->domain), GST_ERROR_OBJECT (sc, "read error: %s %d %s",
code, error->message); g_quark_to_string (error->domain), code, error->message);
g_error_free (error); g_error_free (error);
} else if (ret == 0) { } else if (ret == 0) {
GST_INFO ("read EOF"); GST_INFO_OBJECT (sc, "read EOF");
} }
if (ret <= 0) { if (ret <= 0) {
@ -441,7 +442,7 @@ gst_rtmp_connection_input_ready (GInputStream * is, gpointer user_data)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
GST_TRACE ("read %" G_GSIZE_FORMAT " bytes", ret); GST_TRACE_OBJECT (sc, "read %" G_GSIZE_FORMAT " bytes", ret);
sc->total_input_bytes += ret; sc->total_input_bytes += ret;
sc->bytes_since_ack += ret; sc->bytes_since_ack += ret;
@ -487,7 +488,7 @@ gst_rtmp_connection_emit_error (GstRtmpConnection * self)
return; return;
} }
GST_INFO ("connection error"); GST_INFO_OBJECT (self, "connection error");
self->error = TRUE; self->error = TRUE;
cancel_all_commands (self); cancel_all_commands (self);
@ -509,9 +510,9 @@ gst_rtmp_connection_write_bytes_done (GObject * obj,
res = gst_rtmp_output_stream_write_all_bytes_finish (os, result, &error); res = gst_rtmp_output_stream_write_all_bytes_finish (os, result, &error);
if (!res) { if (!res) {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
GST_INFO ("write cancelled"); GST_INFO_OBJECT (self, "write cancelled");
} else { } else {
GST_ERROR ("write error: %s", error->message); GST_ERROR_OBJECT (self, "write error: %s", error->message);
} }
gst_rtmp_connection_emit_error (self); gst_rtmp_connection_emit_error (self);
g_error_free (error); g_error_free (error);
@ -519,7 +520,7 @@ gst_rtmp_connection_write_bytes_done (GObject * obj,
return; return;
} }
GST_LOG ("write completed"); GST_LOG_OBJECT (self, "write completed");
gst_rtmp_connection_start_write (self); gst_rtmp_connection_start_write (self);
g_object_unref (self); g_object_unref (self);
} }
@ -540,11 +541,11 @@ gst_rtmp_connection_try_read (GstRtmpConnection * connection)
len = connection->input_bytes->len; len = connection->input_bytes->len;
if (len < need) { if (len < need) {
GST_TRACE ("got %u < %u bytes, need more", len, need); GST_TRACE_OBJECT (connection, "got %u < %u bytes, need more", len, need);
return; return;
} }
GST_TRACE ("got %u >= %u bytes, proceeding", len, need); GST_TRACE_OBJECT (connection, "got %u >= %u bytes, proceeding", len, need);
gst_rtmp_connection_do_read (connection); gst_rtmp_connection_do_read (connection);
} }
@ -646,44 +647,47 @@ gst_rtmp_connection_handle_protocol_control (GstRtmpConnection * connection,
GstRtmpProtocolControl pc; GstRtmpProtocolControl pc;
if (!gst_rtmp_message_parse_protocol_control (buffer, &pc)) { if (!gst_rtmp_message_parse_protocol_control (buffer, &pc)) {
GST_ERROR ("can't parse protocol control message"); GST_ERROR_OBJECT (connection, "can't parse protocol control message");
return; return;
} }
GST_LOG ("got protocol control message %d:%s", pc.type, GST_LOG_OBJECT (connection, "got protocol control message %d:%s", pc.type,
gst_rtmp_message_type_get_nick (pc.type)); gst_rtmp_message_type_get_nick (pc.type));
switch (pc.type) { switch (pc.type) {
case GST_RTMP_MESSAGE_TYPE_SET_CHUNK_SIZE: case GST_RTMP_MESSAGE_TYPE_SET_CHUNK_SIZE:
GST_INFO ("new chunk size %" G_GUINT32_FORMAT, pc.param); GST_INFO_OBJECT (connection, "new chunk size %" G_GUINT32_FORMAT,
pc.param);
connection->in_chunk_size = pc.param; connection->in_chunk_size = pc.param;
break; break;
case GST_RTMP_MESSAGE_TYPE_ABORT_MESSAGE: case GST_RTMP_MESSAGE_TYPE_ABORT_MESSAGE:
GST_ERROR ("unimplemented: chunk abort, stream_id = %" G_GUINT32_FORMAT, GST_ERROR_OBJECT (connection, "unimplemented: chunk abort, stream_id = %"
pc.param); G_GUINT32_FORMAT, pc.param);
break; break;
case GST_RTMP_MESSAGE_TYPE_ACKNOWLEDGEMENT: case GST_RTMP_MESSAGE_TYPE_ACKNOWLEDGEMENT:
/* We don't really send ack requests that we care about, so ignore */ /* We don't really send ack requests that we care about, so ignore */
GST_DEBUG ("acknowledgement %" G_GUINT32_FORMAT, pc.param); GST_DEBUG_OBJECT (connection, "acknowledgement %" G_GUINT32_FORMAT,
pc.param);
break; break;
case GST_RTMP_MESSAGE_TYPE_WINDOW_ACK_SIZE: case GST_RTMP_MESSAGE_TYPE_WINDOW_ACK_SIZE:
GST_INFO ("window ack size: %" G_GUINT32_FORMAT, pc.param); GST_INFO_OBJECT (connection, "window ack size: %" G_GUINT32_FORMAT,
pc.param);
connection->in_window_ack_size = pc.param; connection->in_window_ack_size = pc.param;
break; break;
case GST_RTMP_MESSAGE_TYPE_SET_PEER_BANDWIDTH: case GST_RTMP_MESSAGE_TYPE_SET_PEER_BANDWIDTH:
GST_FIXME ("set peer bandwidth: %" G_GUINT32_FORMAT ", %" GST_FIXME_OBJECT (connection, "set peer bandwidth: %" G_GUINT32_FORMAT
G_GUINT32_FORMAT, pc.param, pc.param2); ", %" G_GUINT32_FORMAT, pc.param, pc.param2);
/* FIXME this is not correct, but close enough */ /* FIXME this is not correct, but close enough */
gst_rtmp_connection_request_window_size (connection, pc.param); gst_rtmp_connection_request_window_size (connection, pc.param);
break; break;
default: default:
GST_ERROR ("unimplemented protocol control type %d:%s", pc.type, GST_ERROR_OBJECT (connection, "unimplemented protocol control type %d:%s",
gst_rtmp_message_type_get_nick (pc.type)); pc.type, gst_rtmp_message_type_get_nick (pc.type));
break; break;
} }
} }
@ -695,11 +699,11 @@ gst_rtmp_connection_handle_user_control (GstRtmpConnection * connection,
GstRtmpUserControl uc; GstRtmpUserControl uc;
if (!gst_rtmp_message_parse_user_control (buffer, &uc)) { if (!gst_rtmp_message_parse_user_control (buffer, &uc)) {
GST_ERROR ("can't parse user control message"); GST_ERROR_OBJECT (connection, "can't parse user control message");
return; return;
} }
GST_LOG ("got user control message %d:%s", uc.type, GST_LOG_OBJECT (connection, "got user control message %d:%s", uc.type,
gst_rtmp_user_control_type_get_nick (uc.type)); gst_rtmp_user_control_type_get_nick (uc.type));
switch (uc.type) { switch (uc.type) {
@ -707,37 +711,41 @@ gst_rtmp_connection_handle_user_control (GstRtmpConnection * connection,
case GST_RTMP_USER_CONTROL_TYPE_STREAM_EOF: case GST_RTMP_USER_CONTROL_TYPE_STREAM_EOF:
case GST_RTMP_USER_CONTROL_TYPE_STREAM_DRY: case GST_RTMP_USER_CONTROL_TYPE_STREAM_DRY:
case GST_RTMP_USER_CONTROL_TYPE_STREAM_IS_RECORDED: case GST_RTMP_USER_CONTROL_TYPE_STREAM_IS_RECORDED:
GST_INFO ("stream %u got %s", uc.param, GST_INFO_OBJECT (connection, "stream %u got %s", uc.param,
gst_rtmp_user_control_type_get_nick (uc.type)); gst_rtmp_user_control_type_get_nick (uc.type));
g_signal_emit (connection, signals[SIGNAL_STREAM_CONTROL], 0, g_signal_emit (connection, signals[SIGNAL_STREAM_CONTROL], 0,
uc.type, uc.param); uc.type, uc.param);
break; break;
case GST_RTMP_USER_CONTROL_TYPE_SET_BUFFER_LENGTH: case GST_RTMP_USER_CONTROL_TYPE_SET_BUFFER_LENGTH:
GST_FIXME ("ignoring set buffer length: %" G_GUINT32_FORMAT ", %" GST_FIXME_OBJECT (connection, "ignoring set buffer length: %"
G_GUINT32_FORMAT " ms", uc.param, uc.param2); G_GUINT32_FORMAT ", %" G_GUINT32_FORMAT " ms", uc.param, uc.param2);
break; break;
case GST_RTMP_USER_CONTROL_TYPE_PING_REQUEST: case GST_RTMP_USER_CONTROL_TYPE_PING_REQUEST:
GST_DEBUG ("ping request: %" G_GUINT32_FORMAT, uc.param); GST_DEBUG_OBJECT (connection, "ping request: %" G_GUINT32_FORMAT,
uc.param);
gst_rtmp_connection_send_ping_response (connection, uc.param); gst_rtmp_connection_send_ping_response (connection, uc.param);
break; break;
case GST_RTMP_USER_CONTROL_TYPE_PING_RESPONSE: case GST_RTMP_USER_CONTROL_TYPE_PING_RESPONSE:
GST_DEBUG ("ignoring ping response: %" G_GUINT32_FORMAT, uc.param); GST_DEBUG_OBJECT (connection,
"ignoring ping response: %" G_GUINT32_FORMAT, uc.param);
break; break;
case GST_RTMP_USER_CONTROL_TYPE_BUFFER_EMPTY: case GST_RTMP_USER_CONTROL_TYPE_BUFFER_EMPTY:
GST_LOG ("ignoring buffer empty: %" G_GUINT32_FORMAT, uc.param); GST_LOG_OBJECT (connection, "ignoring buffer empty: %" G_GUINT32_FORMAT,
uc.param);
break; break;
case GST_RTMP_USER_CONTROL_TYPE_BUFFER_READY: case GST_RTMP_USER_CONTROL_TYPE_BUFFER_READY:
GST_LOG ("ignoring buffer ready: %" G_GUINT32_FORMAT, uc.param); GST_LOG_OBJECT (connection, "ignoring buffer ready: %" G_GUINT32_FORMAT,
uc.param);
break; break;
default: default:
GST_ERROR ("unimplemented user control type %d:%s", uc.type, GST_ERROR_OBJECT (connection, "unimplemented user control type %d:%s",
gst_rtmp_user_control_type_get_nick (uc.type)); uc.type, gst_rtmp_user_control_type_get_nick (uc.type));
break; break;
} }
} }
@ -774,16 +782,18 @@ gst_rtmp_connection_handle_cm (GstRtmpConnection * sc, GstBuffer * buffer)
if (!isfinite (transaction_id) || transaction_id < 0 || if (!isfinite (transaction_id) || transaction_id < 0 ||
transaction_id > G_MAXUINT) { transaction_id > G_MAXUINT) {
GST_WARNING ("Server sent command \"%s\" with extreme transaction ID %.0f", GST_WARNING_OBJECT (sc,
"Server sent command \"%s\" with extreme transaction ID %.0f",
GST_STR_NULL (command_name), transaction_id); GST_STR_NULL (command_name), transaction_id);
} else if (transaction_id > sc->transaction_count) { } else if (transaction_id > sc->transaction_count) {
GST_WARNING ("Server sent command \"%s\" with unused transaction ID " GST_WARNING_OBJECT (sc,
"(%.0f > %u)", GST_STR_NULL (command_name), transaction_id, "Server sent command \"%s\" with unused transaction ID (%.0f > %u)",
sc->transaction_count); GST_STR_NULL (command_name), transaction_id, sc->transaction_count);
sc->transaction_count = transaction_id; sc->transaction_count = transaction_id;
} }
GST_DEBUG ("got control message \"%s\" transaction %.0f size %" GST_DEBUG_OBJECT (sc,
"got control message \"%s\" transaction %.0f size %"
G_GUINT32_FORMAT, GST_STR_NULL (command_name), transaction_id, G_GUINT32_FORMAT, GST_STR_NULL (command_name), transaction_id,
meta->size); meta->size);
@ -798,7 +808,7 @@ gst_rtmp_connection_handle_cm (GstRtmpConnection * sc, GstBuffer * buffer)
continue; continue;
} }
GST_LOG ("calling transaction callback %s", GST_LOG_OBJECT (sc, "calling transaction callback %s",
GST_DEBUG_FUNCPTR_NAME (t->func)); GST_DEBUG_FUNCPTR_NAME (t->func));
sc->transactions = g_list_remove_link (sc->transactions, l); sc->transactions = g_list_remove_link (sc->transactions, l);
t->func (command_name, args, t->user_data); t->func (command_name, args, t->user_data);
@ -806,14 +816,14 @@ gst_rtmp_connection_handle_cm (GstRtmpConnection * sc, GstBuffer * buffer)
break; break;
} }
} else { } else {
GST_WARNING ("Server sent response \"%s\" without transaction", GST_WARNING_OBJECT (sc, "Server sent response \"%s\" without transaction",
GST_STR_NULL (command_name)); GST_STR_NULL (command_name));
} }
} else { } else {
GList *l; GList *l;
if (transaction_id != 0) { if (transaction_id != 0) {
GST_FIXME ("Server sent command \"%s\" expecting reply", GST_FIXME_OBJECT (sc, "Server sent command \"%s\" expecting reply",
GST_STR_NULL (command_name)); GST_STR_NULL (command_name));
} }
@ -828,7 +838,7 @@ gst_rtmp_connection_handle_cm (GstRtmpConnection * sc, GstBuffer * buffer)
continue; continue;
} }
GST_LOG ("calling expected command callback %s", GST_LOG_OBJECT (sc, "calling expected command callback %s",
GST_DEBUG_FUNCPTR_NAME (ec->func)); GST_DEBUG_FUNCPTR_NAME (ec->func));
sc->expected_commands = g_list_remove_link (sc->expected_commands, l); sc->expected_commands = g_list_remove_link (sc->expected_commands, l);
ec->func (command_name, args, ec->user_data); ec->func (command_name, args, ec->user_data);
@ -917,10 +927,11 @@ gst_rtmp_connection_send_command (GstRtmpConnection * connection,
gsize size; gsize size;
if (connection->thread != g_thread_self ()) { if (connection->thread != g_thread_self ()) {
GST_ERROR ("Called from wrong thread"); GST_ERROR_OBJECT (connection, "Called from wrong thread");
} }
GST_DEBUG ("Sending command '%s' on stream id %" G_GUINT32_FORMAT, GST_DEBUG_OBJECT (connection,
"Sending command '%s' on stream id %" G_GUINT32_FORMAT,
command_name, stream_id); command_name, stream_id);
if (response_command) { if (response_command) {
@ -928,7 +939,7 @@ gst_rtmp_connection_send_command (GstRtmpConnection * connection,
transaction_id = ++connection->transaction_count; transaction_id = ++connection->transaction_count;
GST_LOG ("Registering %s for transid %.0f", GST_LOG_OBJECT (connection, "Registering %s for transid %.0f",
GST_DEBUG_FUNCPTR_NAME (response_command), transaction_id); GST_DEBUG_FUNCPTR_NAME (response_command), transaction_id);
t = transaction_new (transaction_id, response_command, user_data); t = transaction_new (transaction_id, response_command, user_data);
@ -960,9 +971,9 @@ gst_rtmp_connection_expect_command (GstRtmpConnection * connection,
g_return_if_fail (command_name); g_return_if_fail (command_name);
g_return_if_fail (!is_command_response (command_name)); g_return_if_fail (!is_command_response (command_name));
GST_LOG ("Registering %s for stream id %" G_GUINT32_FORMAT GST_LOG_OBJECT (connection,
" name \"%s\"", GST_DEBUG_FUNCPTR_NAME (response_command), "Registering %s for stream id %" G_GUINT32_FORMAT " name \"%s\"",
stream_id, command_name); GST_DEBUG_FUNCPTR_NAME (response_command), stream_id, command_name);
ec = expected_command_new (stream_id, command_name, response_command, ec = expected_command_new (stream_id, command_name, response_command,
user_data); user_data);