12f0d0f1aSopenharmony_ci/* 22f0d0f1aSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 32f0d0f1aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 42f0d0f1aSopenharmony_ci * you may not use this file except in compliance with the License. 52f0d0f1aSopenharmony_ci * You may obtain a copy of the License at 62f0d0f1aSopenharmony_ci * 72f0d0f1aSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 82f0d0f1aSopenharmony_ci * 92f0d0f1aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 102f0d0f1aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 112f0d0f1aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 122f0d0f1aSopenharmony_ci * See the License for the specific language governing permissions and 132f0d0f1aSopenharmony_ci * limitations under the License. 142f0d0f1aSopenharmony_ci */ 152f0d0f1aSopenharmony_ci 162f0d0f1aSopenharmony_ci#ifndef OHOS_DRM_LOG_H 172f0d0f1aSopenharmony_ci#define OHOS_DRM_LOG_H 182f0d0f1aSopenharmony_ci 192f0d0f1aSopenharmony_ci#include <stdio.h> 202f0d0f1aSopenharmony_ci#include <cinttypes> 212f0d0f1aSopenharmony_ci#include "hilog/log.h" 222f0d0f1aSopenharmony_ci#include "hisysevent.h" 232f0d0f1aSopenharmony_ci 242f0d0f1aSopenharmony_ci#undef LOG_DOMAIN 252f0d0f1aSopenharmony_ci#undef LOG_TAG 262f0d0f1aSopenharmony_ci#define LOG_DOMAIN 0xD002B21 272f0d0f1aSopenharmony_ci#define LOG_TAG "DRM" 282f0d0f1aSopenharmony_ci#define MAX_STRING_SIZE 256 292f0d0f1aSopenharmony_ci 302f0d0f1aSopenharmony_ci#define DRM_FILE_NAME (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) 312f0d0f1aSopenharmony_ci 322f0d0f1aSopenharmony_ci#define POINTER_MASK 0x00FFFFFF 332f0d0f1aSopenharmony_ci#define FAKE_POINTER(addr) (POINTER_MASK & reinterpret_cast<uintptr_t>(addr)) 342f0d0f1aSopenharmony_ci 352f0d0f1aSopenharmony_ci#define DECORATOR_HILOG(op, fmt, args...) \ 362f0d0f1aSopenharmony_ci do { \ 372f0d0f1aSopenharmony_ci op(LOG_CORE, "{%{public}s()-%{public}s:%{public}d}" fmt, __FUNCTION__, DRM_FILE_NAME, __LINE__, ##args); \ 382f0d0f1aSopenharmony_ci } while (0) 392f0d0f1aSopenharmony_ci 402f0d0f1aSopenharmony_ci#define DRM_DEBUG_LOG(fmt, ...) DECORATOR_HILOG(HILOG_DEBUG, fmt, ##__VA_ARGS__) 412f0d0f1aSopenharmony_ci#define DRM_ERR_LOG(fmt, ...) DECORATOR_HILOG(HILOG_ERROR, fmt, ##__VA_ARGS__) 422f0d0f1aSopenharmony_ci#define DRM_WARNING_LOG(fmt, ...) DECORATOR_HILOG(HILOG_WARN, fmt, ##__VA_ARGS__) 432f0d0f1aSopenharmony_ci#define DRM_INFO_LOG(fmt, ...) DECORATOR_HILOG(HILOG_INFO, fmt, ##__VA_ARGS__) 442f0d0f1aSopenharmony_ci#define DRM_FATAL_LOG(fmt, ...) DECORATOR_HILOG(HILOG_FATAL, fmt, ##__VA_ARGS__) 452f0d0f1aSopenharmony_ci 462f0d0f1aSopenharmony_ci#ifndef DRM_CHECK_AND_RETURN_RET_LOG 472f0d0f1aSopenharmony_ci#define DRM_CHECK_AND_RETURN_RET_LOG(cond, ret, fmt, ...) \ 482f0d0f1aSopenharmony_ci do { \ 492f0d0f1aSopenharmony_ci if (!(cond)) { \ 502f0d0f1aSopenharmony_ci DRM_ERR_LOG(fmt, ##__VA_ARGS__); \ 512f0d0f1aSopenharmony_ci return ret; \ 522f0d0f1aSopenharmony_ci } \ 532f0d0f1aSopenharmony_ci } while (0) 542f0d0f1aSopenharmony_ci#endif 552f0d0f1aSopenharmony_ci 562f0d0f1aSopenharmony_ci#ifndef DRM_CHECK_AND_RETURN_LOG 572f0d0f1aSopenharmony_ci#define DRM_CHECK_AND_RETURN_LOG(cond, fmt, ...) \ 582f0d0f1aSopenharmony_ci do { \ 592f0d0f1aSopenharmony_ci if (!(cond)) { \ 602f0d0f1aSopenharmony_ci DRM_ERR_LOG(fmt, ##__VA_ARGS__); \ 612f0d0f1aSopenharmony_ci return; \ 622f0d0f1aSopenharmony_ci } \ 632f0d0f1aSopenharmony_ci } while (0) 642f0d0f1aSopenharmony_ci#endif 652f0d0f1aSopenharmony_ci 662f0d0f1aSopenharmony_ci#ifndef DRM_CHECK_AND_CONTINUE_LOG 672f0d0f1aSopenharmony_ci#define DRM_CHECK_AND_CONTINUE_LOG(cond, fmt, ...) \ 682f0d0f1aSopenharmony_ci do { \ 692f0d0f1aSopenharmony_ci if (!(cond)) { \ 702f0d0f1aSopenharmony_ci ReleaseHandleAndKeySystemMap(handle); \ 712f0d0f1aSopenharmony_ci DRM_ERR_LOG(fmt, ##__VA_ARGS__); \ 722f0d0f1aSopenharmony_ci continue;; \ 732f0d0f1aSopenharmony_ci } \ 742f0d0f1aSopenharmony_ci } while (0) 752f0d0f1aSopenharmony_ci#endif 762f0d0f1aSopenharmony_ci 772f0d0f1aSopenharmony_ci#define POINTER_MASK 0x00FFFFFF 782f0d0f1aSopenharmony_ci#define DATA_MAX_LEN (1 * 1024 * 1024) 792f0d0f1aSopenharmony_ci#define RESPONSE_MAX_LEN (8 * 1024 * 1024) 802f0d0f1aSopenharmony_ci#define REQUEST_MAX_LEN (8 * 1024 * 1024) 812f0d0f1aSopenharmony_ci#define IV_MAX_LEN 128 822f0d0f1aSopenharmony_ci#define KEYID_MAX_LEN 128 832f0d0f1aSopenharmony_ci#define LICENSEID_MAX_LEN 128 842f0d0f1aSopenharmony_ci#define SUBSAMPLE_MAX_NUM 256 852f0d0f1aSopenharmony_ci#define HEXADECIMAL 16 862f0d0f1aSopenharmony_ci#define BASE_CONVERSION_OPERATOR 2 872f0d0f1aSopenharmony_ci#define KEY_SYSTEM_MAX_NUMBER 64 882f0d0f1aSopenharmony_ci#define KEY_SESSION_MAX_NUMBER 64 892f0d0f1aSopenharmony_ci 902f0d0f1aSopenharmony_ci#endif // OHOS_DRM_LOG_H