tracer: pass the timestamp directly

Avoid the structure mashalling (and weird field naming).
This commit is contained in:
Stefan Sauer 2013-10-28 21:28:18 +01:00
parent d663b78612
commit 9d3975b5da
6 changed files with 36 additions and 40 deletions

View file

@ -4455,10 +4455,10 @@ gst_pad_push (GstPad * pad, GstBuffer * buffer)
GstFlowReturn res;
if (trace)
gst_tracer_push_buffer_pre (pad, buffer);
gst_tracer_push_buffer_pre (gst_util_get_timestamp (), pad, buffer);
res = __gst_pad_push (pad, buffer);
if (trace)
gst_tracer_push_buffer_post (pad, res);
gst_tracer_push_buffer_post (gst_util_get_timestamp (), pad, res);
return res;
}
@ -4511,10 +4511,10 @@ gst_pad_push_list (GstPad * pad, GstBufferList * list)
GstFlowReturn res;
if (trace)
gst_tracer_push_buffer_list_pre (pad, list);
gst_tracer_push_buffer_list_pre (gst_util_get_timestamp (), pad, list);
res = __gst_pad_push_list (pad, list);
if (trace)
gst_tracer_push_buffer_list_post (pad, res);
gst_tracer_push_buffer_list_post (gst_util_get_timestamp (), pad, res);
return res;
}

View file

@ -72,7 +72,7 @@ static const gchar *_quark_strings[] = {
"GstMessageDeviceAdded", "GstMessageDeviceRemoved", "device",
"uri-redirection-permanent",
"push_buffer::pre", "push_buffer::post", "push_buffer_list::pre",
"push_buffer_list::post", ".ts", "return", "pad", "buffer", "list"
"push_buffer_list::post", "return", "pad", "buffer", "list"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -124,13 +124,14 @@ gst_tracer_get_property (GObject * object, guint prop_id,
}
static void
gst_tracer_invoke (GstTracer * self, GstTracerHookId id, GstStructure * s)
gst_tracer_invoke (GstTracer * self, GstTracerHookId id, guint64 ts,
GstStructure * s)
{
GstTracerClass *klass = GST_TRACER_GET_CLASS (self);
g_return_if_fail (klass->invoke);
klass->invoke (self, id, s);
klass->invoke (self, id, ts, s);
}
/* tracing modules */
@ -284,51 +285,47 @@ gst_tracer_is_enabled (GstTracerHookId id)
}
static void
dispatch (GstTracerHookId id, GstStructure * s)
dispatch (GstTracerHookId id, guint64 ts, GstStructure * s)
{
GList *node;
for (node = tracers[id]; node; node = g_list_next (node)) {
gst_tracer_invoke (node->data, id, s);
gst_tracer_invoke (node->data, id, ts, s);
}
}
/* tracing hooks */
void
gst_tracer_push_buffer_pre (GstPad * pad, GstBuffer * buffer)
gst_tracer_push_buffer_pre (guint64 ts, GstPad * pad, GstBuffer * buffer)
{
dispatch (GST_TRACER_HOOK_ID_BUFFERS,
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_PRE),
GST_QUARK (DOT_TS), G_TYPE_UINT64, gst_util_get_timestamp (),
GST_QUARK (PAD), GST_TYPE_PAD, pad,
GST_QUARK (BUFFER), GST_TYPE_BUFFER, buffer, NULL));
}
void
gst_tracer_push_buffer_post (GstPad * pad, GstFlowReturn res)
gst_tracer_push_buffer_post (guint64 ts, GstPad * pad, GstFlowReturn res)
{
dispatch (GST_TRACER_HOOK_ID_BUFFERS,
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_POST),
GST_QUARK (DOT_TS), G_TYPE_UINT64, gst_util_get_timestamp (),
GST_QUARK (PAD), GST_TYPE_PAD, pad,
GST_QUARK (RETURN), G_TYPE_INT, res, NULL));
}
void
gst_tracer_push_buffer_list_pre (GstPad * pad, GstBufferList * list)
gst_tracer_push_buffer_list_pre (guint64 ts, GstPad * pad, GstBufferList * list)
{
dispatch (GST_TRACER_HOOK_ID_BUFFERS,
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_PRE),
GST_QUARK (DOT_TS), G_TYPE_UINT64, gst_util_get_timestamp (),
GST_QUARK (PAD), GST_TYPE_PAD, pad,
GST_QUARK (LIST), GST_TYPE_BUFFER_LIST, list, NULL));
}
void
gst_tracer_push_buffer_list_post (GstPad * pad, GstFlowReturn res)
gst_tracer_push_buffer_list_post (guint64 ts, GstPad * pad, GstFlowReturn res)
{
dispatch (GST_TRACER_HOOK_ID_BUFFERS,
dispatch (GST_TRACER_HOOK_ID_BUFFERS, ts,
gst_structure_new_id (GST_QUARK (PUSH_BUFFER_LIST_POST),
GST_QUARK (DOT_TS), G_TYPE_UINT64, gst_util_get_timestamp (),
GST_QUARK (PAD), GST_TYPE_PAD, pad,
GST_QUARK (RETURN), G_TYPE_INT, res, NULL));
}

View file

@ -81,7 +81,8 @@ struct _GstTracer {
gpointer _gst_reserved[GST_PADDING];
};
typedef void (*GstTracerInvokeFunction) (GstTracer * self, GstTracerHookId id, GstStructure *s);
typedef void (*GstTracerInvokeFunction) (GstTracer * self, GstTracerHookId id,
guint64 ts, GstStructure *s);
struct _GstTracerClass {
GstObjectClass parent_class;
@ -103,11 +104,11 @@ void _priv_gst_tracer_deinit (void);
gboolean gst_tracer_register (GstPlugin * plugin, const gchar * name, GType type);
gboolean gst_tracer_is_enabled (GstTracerHookId id);
void gst_tracer_push_buffer_pre (GstPad *pad, GstBuffer *buffer);
void gst_tracer_push_buffer_post (GstPad *pad, GstFlowReturn res);
void gst_tracer_push_buffer_list_pre (GstPad * pad, GstBufferList * list);
void gst_tracer_push_buffer_list_post (GstPad * pad, GstFlowReturn res);
void gst_tracer_push_buffer_pre (guint64 ts, GstPad *pad, GstBuffer *buffer);
void gst_tracer_push_buffer_post (guint64 ts, GstPad *pad, GstFlowReturn res);
void gst_tracer_push_buffer_list_pre (guint64 ts, GstPad * pad, GstBufferList * list);
void gst_tracer_push_buffer_list_post (guint64 ts, GstPad * pad, GstFlowReturn res);
#endif /* GST_DISABLE_GST_DEBUG */

View file

@ -35,7 +35,7 @@ G_DEFINE_TYPE_WITH_CODE (GstLogTracer, gst_log_tracer, GST_TYPE_TRACER,
_do_init);
static void gst_log_tracer_invoke (GstTracer * self, GstTracerHookId id,
GstStructure * s);
guint64 ts, GstStructure * s);
static void
gst_log_tracer_class_init (GstLogTracerClass * klass)
@ -52,7 +52,8 @@ gst_log_tracer_init (GstLogTracer * self)
}
static void
gst_log_tracer_invoke (GstTracer * self, GstTracerHookId id, GstStructure * s)
gst_log_tracer_invoke (GstTracer * self, GstTracerHookId id, guint64 ts,
GstStructure * s)
{
gchar *str = gst_structure_to_string (s);
/* TODO(ensonic): log to different categories depending on 'id'

View file

@ -453,7 +453,7 @@ do_element_stats (GstStatsTracer * self, GstPad * pad, GstClockTime elapsed1,
static void gst_stats_tracer_finalize (GObject * obj);
static void gst_stats_tracer_invoke (GstTracer * obj, GstTracerHookId id,
GstStructure * s);
guint64 ts, GstStructure * s);
static void
gst_stats_tracer_class_init (GstStatsTracerClass * klass)
@ -477,16 +477,14 @@ gst_stats_tracer_init (GstStatsTracer * self)
}
static void
do_push_buffer_pre (GstStatsTracer * self, GstStructure * s)
do_push_buffer_pre (GstStatsTracer * self, guint64 ts, GstStructure * s)
{
GstPad *pad;
GstBuffer *buffer;
GstPadStats *stats;
guint64 ts;
gst_structure_get (s,
"pad", GST_TYPE_PAD, &pad,
".ts", G_TYPE_UINT64, &ts, "buffer", GST_TYPE_BUFFER, &buffer, NULL);
"pad", GST_TYPE_PAD, &pad, "buffer", GST_TYPE_BUFFER, &buffer, NULL);
stats = get_pad_stats (self, pad);
do_pad_stats (self, pad, stats, buffer, ts);
@ -494,29 +492,28 @@ do_push_buffer_pre (GstStatsTracer * self, GstStructure * s)
}
static void
do_push_buffer_post (GstStatsTracer * self, GstStructure * s)
do_push_buffer_post (GstStatsTracer * self, guint64 ts, GstStructure * s)
{
GstPad *pad;
GstPadStats *stats;
guint64 ts;
gst_structure_get (s,
"pad", GST_TYPE_PAD, &pad, ".ts", G_TYPE_UINT64, &ts, NULL);
gst_structure_get (s, "pad", GST_TYPE_PAD, &pad, NULL);
stats = get_pad_stats (self, pad);
do_element_stats (self, pad, stats->last_ts, ts);
}
static void
gst_stats_tracer_invoke (GstTracer * obj, GstTracerHookId id, GstStructure * s)
gst_stats_tracer_invoke (GstTracer * obj, GstTracerHookId id, guint64 ts,
GstStructure * s)
{
GstStatsTracer *self = GST_STATS_TRACER_CAST (obj);
GQuark func = gst_structure_get_name_id (s);
if (func == funcs[PUSH_BUFFER_PRE])
do_push_buffer_pre (self, s);
do_push_buffer_pre (self, ts, s);
else if (func == funcs[PUSH_BUFFER_POST])
do_push_buffer_post (self, s);
do_push_buffer_post (self, ts, s);
}
static void