blob: 4bbda579bc7f15669db769e12e18cf9001920939 [file] [log] [blame]
tommi@webrtc.org7c64ed22015-03-17 14:25:37 +00001/*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11// This file defines the interface for event tracing in WebRTC.
12//
13// Event log handlers are set through SetupEventTracer(). User of this API will
14// provide two function pointers to handle event tracing calls.
15//
16// * GetCategoryEnabledPtr
17// Event tracing system calls this function to determine if a particular
18// event category is enabled.
19//
20// * AddTraceEventPtr
21// Adds a tracing event. It is the user's responsibility to log the data
22// provided.
23//
24// Parameters for the above two functions are described in trace_event.h.
25
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#ifndef RTC_BASE_EVENT_TRACER_H_
27#define RTC_BASE_EVENT_TRACER_H_
tommi@webrtc.org7c64ed22015-03-17 14:25:37 +000028
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020029#include <stdio.h>
Peter Boström6f28cf02015-12-07 23:17:15 +010030
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020031namespace webrtc {
32
33typedef const unsigned char* (*GetCategoryEnabledPtr)(const char* name);
34typedef void (*AddTraceEventPtr)(char phase,
35 const unsigned char* category_enabled,
36 const char* name,
37 unsigned long long id,
38 int num_args,
39 const char** arg_names,
40 const unsigned char* arg_types,
41 const unsigned long long* arg_values,
42 unsigned char flags);
43
44// User of WebRTC can call this method to setup event tracing.
45//
46// This method must be called before any WebRTC methods. Functions
47// provided should be thread-safe.
Yves Gerey665174f2018-06-19 15:03:05 +020048void SetupEventTracer(GetCategoryEnabledPtr get_category_enabled_ptr,
49 AddTraceEventPtr add_trace_event_ptr);
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020050
51// This class defines interface for the event tracing system to call
52// internally. Do not call these methods directly.
53class EventTracer {
54 public:
Yves Gerey665174f2018-06-19 15:03:05 +020055 static const unsigned char* GetCategoryEnabled(const char* name);
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020056
Yves Gerey665174f2018-06-19 15:03:05 +020057 static void AddTraceEvent(char phase,
58 const unsigned char* category_enabled,
59 const char* name,
60 unsigned long long id,
61 int num_args,
62 const char** arg_names,
63 const unsigned char* arg_types,
64 const unsigned long long* arg_values,
65 unsigned char flags);
Henrik Kjellanderec78f1c2017-06-29 07:52:50 +020066};
67
68} // namespace webrtc
69
70namespace rtc {
71namespace tracing {
72// Set up internal event tracer.
73void SetupInternalTracer();
74bool StartInternalCapture(const char* filename);
75void StartInternalCaptureToFile(FILE* file);
76void StopInternalCapture();
77// Make sure we run this, this will tear down the internal tracing.
78void ShutdownInternalTracer();
79} // namespace tracing
80} // namespace rtc
Peter Boström6f28cf02015-12-07 23:17:15 +010081
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // RTC_BASE_EVENT_TRACER_H_