1 /** 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef IMS_MEDIA_TRACE_H_INCLUDED 18 #define IMS_MEDIA_TRACE_H_INCLUDED 19 #include <stdint.h> 20 21 enum IM_LOG_MODE 22 { 23 kLogEnableUnknown = 0, 24 kLogEnableVerbose, 25 kLogEnableDebug, 26 kLogEnableInfo, 27 kLogEnableWarning, 28 kLogEnableError, 29 }; 30 31 enum IM_PACKET_LOG_TYPE 32 { 33 IM_PACKET_LOG_SOCKET = 1 << 0, 34 IM_PACKET_LOG_AUDIO = 1 << 1, 35 IM_PACKET_LOG_VIDEO = 1 << 2, 36 IM_PACKET_LOG_TEXT = 1 << 3, 37 IM_PACKET_LOG_RTP = 1 << 4, 38 IM_PACKET_LOG_PH = 1 << 5, 39 IM_PACKET_LOG_JITTER = 1 << 6, 40 IM_PACKET_LOG_RTCP = 1 << 7, 41 IM_PACKET_LOG_RTPSTACK = 1 << 8, 42 IM_PACKET_LOG_VIDEO_JITTER = 1 << 9 43 }; 44 45 #define IMLOGD_PACKET0(type, format) \ 46 ImsMediaTrace::IMLOGD_PACKET_ARG( \ 47 type, "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__) 48 #define IMLOGD_PACKET1(type, format, a) \ 49 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 50 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a) 51 #define IMLOGD_PACKET2(type, format, a, b) \ 52 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 53 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b) 54 #define IMLOGD_PACKET3(type, format, a, b, c) \ 55 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 56 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c) 57 #define IMLOGD_PACKET4(type, format, a, b, c, d) \ 58 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 59 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c, d) 60 #define IMLOGD_PACKET5(type, format, a, b, c, d, e) \ 61 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 62 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c, d, e) 63 #define IMLOGD_PACKET6(type, format, a, b, c, d, e, f) \ 64 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 65 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c, d, e, f) 66 #define IMLOGD_PACKET7(type, format, a, b, c, d, e, f, g) \ 67 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 68 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c, d, e, f, g) 69 #define IMLOGD_PACKET8(type, format, a, b, c, d, e, f, g, h) \ 70 ImsMediaTrace::IMLOGD_PACKET_ARG(type, "[%s:%d] " format, \ 71 ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b, c, d, e, f, g, h) 72 73 #define IMLOGI0(format) \ 74 ImsMediaTrace::IMLOGI_ARG( \ 75 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__) 76 #define IMLOGI1(format, a) \ 77 ImsMediaTrace::IMLOGI_ARG( \ 78 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a) 79 #define IMLOGI2(format, a, b) \ 80 ImsMediaTrace::IMLOGI_ARG( \ 81 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b) 82 #define IMLOGI3(format, a, b, c) \ 83 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 84 __LINE__, a, b, c) 85 #define IMLOGI4(format, a, b, c, d) \ 86 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 87 __LINE__, a, b, c, d) 88 #define IMLOGI5(format, a, b, c, d, e) \ 89 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 90 __LINE__, a, b, c, d, e) 91 #define IMLOGI6(format, a, b, c, d, e, f) \ 92 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 93 __LINE__, a, b, c, d, e, f) 94 #define IMLOGI7(format, a, b, c, d, e, f, g) \ 95 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 96 __LINE__, a, b, c, d, e, f, g) 97 #define IMLOGI8(format, a, b, c, d, e, f, g, h) \ 98 ImsMediaTrace::IMLOGI_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 99 __LINE__, a, b, c, d, e, f, g, h) 100 101 #define IMLOGD0(format) \ 102 ImsMediaTrace::IMLOGD_ARG( \ 103 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__) 104 #define IMLOGD1(format, a) \ 105 ImsMediaTrace::IMLOGD_ARG( \ 106 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a) 107 #define IMLOGD2(format, a, b) \ 108 ImsMediaTrace::IMLOGD_ARG( \ 109 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b) 110 #define IMLOGD3(format, a, b, c) \ 111 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 112 __LINE__, a, b, c) 113 #define IMLOGD4(format, a, b, c, d) \ 114 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 115 __LINE__, a, b, c, d) 116 #define IMLOGD5(format, a, b, c, d, e) \ 117 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 118 __LINE__, a, b, c, d, e) 119 #define IMLOGD6(format, a, b, c, d, e, f) \ 120 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 121 __LINE__, a, b, c, d, e, f) 122 #define IMLOGD7(format, a, b, c, d, e, f, g) \ 123 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 124 __LINE__, a, b, c, d, e, f, g) 125 #define IMLOGD8(format, a, b, c, d, e, f, g, h) \ 126 ImsMediaTrace::IMLOGD_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 127 __LINE__, a, b, c, d, e, f, g, h) 128 129 #define IMLOGW0(format) \ 130 ImsMediaTrace::IMLOGW_ARG( \ 131 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__) 132 #define IMLOGW1(format, a) \ 133 ImsMediaTrace::IMLOGW_ARG( \ 134 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a) 135 #define IMLOGW2(format, a, b) \ 136 ImsMediaTrace::IMLOGW_ARG( \ 137 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b) 138 #define IMLOGW3(format, a, b, c) \ 139 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 140 __LINE__, a, b, c) 141 #define IMLOGW4(format, a, b, c, d) \ 142 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 143 __LINE__, a, b, c, d) 144 #define IMLOGW5(format, a, b, c, d, e) \ 145 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 146 __LINE__, a, b, c, d, e) 147 #define IMLOGW6(format, a, b, c, d, e, f) \ 148 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 149 __LINE__, a, b, c, d, e, f) 150 #define IMLOGW7(format, a, b, c, d, e, f, g) \ 151 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 152 __LINE__, a, b, c, d, e, f, g) 153 #define IMLOGW8(format, a, b, c, d, e, f, g, h) \ 154 ImsMediaTrace::IMLOGW_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 155 __LINE__, a, b, c, d, e, f, g, h) 156 157 #define IMLOGE0(format) \ 158 ImsMediaTrace::IMLOGE_ARG( \ 159 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__) 160 #define IMLOGE1(format, a) \ 161 ImsMediaTrace::IMLOGE_ARG( \ 162 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a) 163 #define IMLOGE2(format, a, b) \ 164 ImsMediaTrace::IMLOGE_ARG( \ 165 "[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), __LINE__, a, b) 166 #define IMLOGE3(format, a, b, c) \ 167 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 168 __LINE__, a, b, c) 169 #define IMLOGE4(format, a, b, c, d) \ 170 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 171 __LINE__, a, b, c, d) 172 #define IMLOGE5(format, a, b, c, d, e) \ 173 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 174 __LINE__, a, b, c, d, e) 175 #define IMLOGE6(format, a, b, c, d, e, f) \ 176 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 177 __LINE__, a, b, c, d, e, f) 178 #define IMLOGE7(format, a, b, c, d, e, f, g) \ 179 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 180 __LINE__, a, b, c, d, e, f, g) 181 #define IMLOGE8(format, a, b, c, d, e, f, g, h) \ 182 ImsMediaTrace::IMLOGE_ARG("[%s:%d] " format, ImsMediaTrace::IM_StripFileName((char*)__FILE__), \ 183 __LINE__, a, b, c, d, e, f, g, h) 184 185 #define IMLOGB(a, b, c) ImsMediaTrace::IMLOGD_BINARY(a, b, c) 186 187 class ImsMediaTrace 188 { 189 public: 190 static void IMLOGD_PACKET_ARG(IM_PACKET_LOG_TYPE type, const char* format, ...); 191 static void IMSetLogMode(uint32_t mode); 192 static void IMSetDebugLogMode(uint32_t mode); 193 static uint32_t IMGetDebugLog(); 194 static void IMLOGD_ARG(const char* format, ...); 195 static void IMLOGI_ARG(const char* format, ...); 196 static void IMLOGW_ARG(const char* format, ...); 197 static void IMLOGE_ARG(const char* format, ...); 198 static char* IMTrace_Bin2String(const char* s, int length); 199 static void IMLOGD_BINARY(const char* msg, const char* s, int length); 200 static char* IM_StripFileName(char* pcFileName); 201 }; 202 203 #endif