blob: 51c8cfdc49d1001f06844e8ff01eeae2e26a91fd [file] [log] [blame]
tommi@webrtc.orgb8940a22015-03-17 14:25:371/*
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
26#ifndef WEBRTC_BASE_EVENT_TRACER_H_
27#define WEBRTC_BASE_EVENT_TRACER_H_
28
Peter Boström155895c2015-12-07 22:17:1529#include <stdio.h>
30
tommi@webrtc.orgb8940a22015-03-17 14:25:3731namespace 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.
48void SetupEventTracer(
49 GetCategoryEnabledPtr get_category_enabled_ptr,
50 AddTraceEventPtr add_trace_event_ptr);
51
52// This class defines interface for the event tracing system to call
53// internally. Do not call these methods directly.
54class EventTracer {
55 public:
56 static const unsigned char* GetCategoryEnabled(
57 const char* name);
58
59 static void AddTraceEvent(
60 char phase,
61 const unsigned char* category_enabled,
62 const char* name,
63 unsigned long long id,
64 int num_args,
65 const char** arg_names,
66 const unsigned char* arg_types,
67 const unsigned long long* arg_values,
68 unsigned char flags);
69};
70
71} // namespace webrtc
72
Peter Boström155895c2015-12-07 22:17:1573namespace rtc {
74namespace tracing {
75// Set up internal event tracer.
76void SetupInternalTracer();
77bool StartInternalCapture(const char* filename);
78void StartInternalCaptureToFile(FILE* file);
79void StopInternalCapture();
80// Make sure we run this, this will tear down the internal tracing.
81void ShutdownInternalTracer();
82} // namespace tracing
83} // namespace rtc
84
tommi@webrtc.orgb8940a22015-03-17 14:25:3785#endif // WEBRTC_BASE_EVENT_TRACER_H_