1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FILLP_TYPES_H 17 #define FILLP_TYPES_H 18 19 #ifdef FILLP_LINUX 20 21 #ifndef _GNU_SOURCE 22 #define _GNU_SOURCE 23 #endif 24 25 #ifdef FILLP_MAC 26 #include <mach/task.h> 27 #include <mach/semaphore.h> 28 #endif 29 30 #if !defined(FILLP_LW_LITEOS) 31 #ifndef __USE_GNU 32 #define __USE_GNU 33 #endif 34 #endif 35 36 #include <stdint.h> 37 #include <stdlib.h> 38 #include <stdio.h> 39 #include <sys/ioctl.h> 40 #include <fcntl.h> 41 #include <string.h> 42 #include <pthread.h> 43 44 #ifndef FILLP_MAC 45 #include <sys/prctl.h> 46 #endif 47 #include <sched.h> 48 #include <unistd.h> 49 #include <sys/time.h> 50 #if !defined(FILLP_LW_LITEOS) 51 #include <sys/socket.h> 52 #include <sys/mman.h> 53 #include <netinet/in.h> 54 #include <arpa/inet.h> 55 #include <math.h> 56 #include <sys/types.h> 57 #include <net/if.h> 58 #include <sys/syscall.h> 59 #else 60 #include "lwip/sockets.h" 61 #endif 62 63 #if !defined(FILLP_LW_LITEOS) && !defined(FILLP_MAC) 64 #include <sys/epoll.h> 65 #endif 66 67 #define FILLP_STDCALL 68 #define DLL_API __attribute__ ((visibility ("default"))) 69 #else 70 #include <WinSock2.h> 71 #include <windows.h> 72 #include <WinBase.h> 73 #include <Ws2tcpip.h> 74 #include <stdlib.h> 75 #include <string.h> 76 #include <process.h> 77 #include <windows.h> 78 #include <math.h> 79 #include <tchar.h> 80 #include <stdio.h> 81 #include <stdlib.h> 82 #pragma comment(lib, "WS2_32") 83 #ifdef DLL_SUPPORT 84 #ifdef DLL_IMPLEMENT 85 #define DLL_API __declspec(dllexport) 86 #else 87 #define DLL_API __declspec(dllimport) 88 #endif 89 #else 90 #define DLL_API 91 #endif 92 93 #define FILLP_STDCALL __stdcall 94 95 #ifndef _WINDOWS 96 #ifdef _WIN32 97 #define _WINDOWS 98 #else 99 100 #ifdef _WIN64 101 #define _WINDOWS 102 #endif 103 #endif 104 #endif 105 #endif 106 107 #ifdef __cplusplus 108 #define FILLP_NULL_PTR 0 109 #else 110 #define FILLP_NULL_PTR ((void*)0) 111 #endif /* __cplusplus */ 112 113 #ifdef __cplusplus 114 extern "C" { 115 #endif 116 117 typedef char FILLP_CHAR; 118 typedef unsigned char FILLP_UCHAR; 119 typedef signed char FILLP_INT8; 120 typedef unsigned char FILLP_UINT8; 121 typedef unsigned short FILLP_UINT16; 122 typedef signed short FILLP_INT16; 123 typedef unsigned char FILLP_BOOL; 124 typedef unsigned int FILLP_UINT; 125 typedef signed int FILLP_INT; 126 typedef unsigned long long FILLP_ULLONG; 127 typedef long long FILLP_LLONG; 128 typedef signed long FILLP_SLONG; 129 typedef unsigned long FILLP_ULONG; 130 typedef signed int FILLP_INT32; 131 typedef unsigned int FILLP_UINT32; 132 133 typedef FILLP_INT FillpErrorType; 134 typedef unsigned long DWORD; 135 136 #define FILLP_INVALID_UINT32 0xFFFFFFFF 137 #define FILLP_INVALID_INT 0x7FFFFFFF 138 #define FILLP_MAX_UNSHORT_VAL 0xFFFF /* max value of unsinged short */ 139 #define FILLP_FALSE 0 140 #define FILLP_TRUE 1 141 #define FILLP_SUCCESS 0 142 #define FILLP_FAILURE 1 143 #define FILLP_CONST const 144 #define IO /* Input and Out param */ 145 #define IN /* Input param */ 146 #define OUT /* Output param */ 147 148 #ifndef FILLP_FIONBIO 149 #define FILLP_FIONBIO 1 /* Set/Unset socket non-blocking */ 150 #endif 151 152 #define FILLP_UNUSED_PARA(para) (void)(para) 153 154 /* higher value kept so that it should not clash with linux header files */ 155 #define IPPROTO_FILLP 512 156 157 /* cmsg type used in FtSendFrame */ 158 #define FILLP_CMSG_TYPE_FRAME 0x1 159 160 /* fillp socket options */ 161 #define FILLP_PKT_DATA_OPTS_TIMESTAMP 0x01 162 #define FILLP_SOCK_SEND_CACHE_INFO 0x2 163 #define FILLP_SOCK_FC_ALG 0x03 164 #define FILLP_SOCK_DIRECTLY_SEND 0x4 165 #define FILLP_SOCK_BW_DET_ALGO 0x5 166 #define FILLP_SOCK_BW_DET_PARAMS 0x6 167 #define FILLP_SOCK_CQE_ALGO 0x7 168 #define FILLP_SOCK_CQE_PARAMS 0x8 169 #define FILLP_SOCK_MIRACAST_VIDEO_PARAMS 0x9 170 #define FILLP_SEMI_RELIABLE 0xa 171 #define FILLP_SOCK_TRAFFIC 0x10 172 173 #define FILLP_IPV6_ADDR_LEN 4 174 175 #define FILLP_ALG_BASE 0 176 #define FILLP_ALG_ONE 1 177 #define FILLP_ALG_TWO 2 178 #define FILLP_ALG_THREE 3 179 #define FILLP_ALG_MSG 4 180 181 /* define character bit */ 182 #define FILLP_SUPPORT_PACK_WITH_HRBB 0X01 /* send head receiving buffer bubble in pack packet */ 183 #define FILLP_SUPPORT_PACK_WITH_PKT_IVAR 0X02 184 185 /* Valid opcodes to issue to sys_epoll_ctl() */ 186 #define SPUNGE_EPOLL_CTL_ADD 1 187 #define SPUNGE_EPOLL_CTL_DEL 2 188 #define SPUNGE_EPOLL_CTL_MOD 3 189 190 /* Dbg ID for all files */ 191 #define FILLP_DEBUG_ID_ALL 0xFFFFFFFFFFFFFFFF /* To enable logs for all the modules */ 192 193 /** 194 * @defgroup FillpDebugCmdEn 195 * @ingroup Enums 196 * @par Prototype 197 * 198 * @datastruct SPUNGE_SHUT_RD Denotes the read close of the socket. 199 * However can continue to send data from peer socket 200 * @datastruct SPUNGE_SHUT_WR Denotes the write close of the socket. 201 * However can continue to receive data from peer socket 202 * @datastruct SPUNGE_SHUT_RDWR Denotes the read and write close of the socket. Equivalent to RST of TCP 203 */ 204 enum SpungeSockShutdownCmd { 205 SPUNGE_SHUT_RD, 206 SPUNGE_SHUT_WR, 207 SPUNGE_SHUT_RDWR, 208 }; 209 210 /** 211 * @defgroup CommonMacros 212 * @ingroup Macros 213 * @par Prototype 214 */ 215 #if defined(FILLP_LINUX) 216 #define SPUNGE_EPOLLIN EPOLLIN /* The associated file is available for read(2) operations. */ 217 #define SPUNGE_EPOLLOUT EPOLLOUT /* The associated file is available for write(2) operations. */ 218 #define SPUNGE_EPOLLERR EPOLLERR /* Error condition happened on the associat */ 219 #define SPUNGE_EPOLLET EPOLLET /* Edge trigger support */ 220 #define SPUNGE_EPOLLHUP EPOLLHUP /* Hang up happened on the associated socket */ 221 #define SPUNGE_EPOLLRDHUP EPOLLRDHUP /* Peer closed */ 222 #else 223 #define SPUNGE_EPOLLIN 0x0001 /* The associated file is available for read(2) operations. */ 224 #define SPUNGE_EPOLLOUT 0x0004 /* The associated file is available for write(2) operations. */ 225 #define SPUNGE_EPOLLERR 0x0008 /* Error condition happened on the associat */ 226 #define SPUNGE_EPOLLET (1u << 31) /* Edge trigger support */ 227 #define SPUNGE_EPOLLHUP 0x0010 /* Hang up happened on the associated socket */ 228 #define SPUNGE_EPOLLRDHUP 0x2000 /* Peer closed */ 229 #endif 230 231 #if defined(FILLP_LINUX) && !defined(FILLP_MAC) 232 #pragma pack(push, 4) 233 #else 234 #pragma pack(push, 8) 235 #endif 236 237 /** 238 * Indicates spunge epoll data. 239 */ 240 union SpungeEpollData { 241 void *ptr; /* Indicates a pointer to the epoll data. */ 242 FILLP_INT fd; /* Indicates the file descriptor. */ 243 FILLP_UINT32 u32; /* Indicates 32-bit data. */ 244 FILLP_ULLONG u64; /* Indicates 64-bit data. */ 245 }; 246 247 /** 248 * Provides spunge epoll event data. 249 */ 250 struct SpungeEpollEvent { 251 FILLP_UINT32 events; /* Indicates Epoll events. */ 252 union SpungeEpollData data; /* Indicates the user data variable. */ 253 }; 254 #pragma pack(pop) 255 256 /** 257 * @defgroup e Error Codes 258 * @ingroup Macros 259 * @par Marcos 260 */ 261 #if !defined(FILLP_LW_LITEOS) 262 #define ERR_OK 0 263 #endif 264 #define FILLP_OK ERR_OK 265 #define FILLP_NULL 0 266 #define ERR_NULLPTR (-1) /* NULL Point Error */ 267 #define ERR_NOBUFS (-2) /* No buf/item to malloc */ 268 #define FILLP_ERR_CONN (-3) /* connection err */ 269 #define ERR_PARAM (-4) /* EINVAL */ 270 #define ERR_NORES (-5) /* No resource */ 271 #define ERR_FAILURE (-7) /* general sem init failures and socket init failures */ 272 #define ERR_FEATURE_MACRO_NOT_ENABLED (-10) 273 #define FILLP_ERR_VAL (-13) 274 #define ERR_CONNREFUSED (-14) 275 #define ERR_NO_SOCK (-200) 276 #define ERR_NO_REBIND (-201) 277 #define ERR_EAGAIN (-205) 278 #define ERR_NO_SYS_SOCK (-207) 279 #define FILLP_ERR_ISCONN (-208) 280 #define FILLP_ERR_EALREADY (-209) 281 #define ERR_CONN_TIMEOUT (-300) 282 #define ERR_ADP_SYS_CALLBACK_NOT_REGISTERED (-303) 283 #define ERR_SOCK_TYPE_ERR (-306) 284 #define ERR_SYSTEM_MEMORY_FAILURE (-308) 285 #define ERR_STACK_ALREADY_INITIALD (-402) 286 #define ERR_UNDERCLOSURE (-500) /* ft socket is already under closure */ 287 #define ERR_WRONGSTATE (-501) /* api is invoked in wrong connection state */ 288 #define ERR_NONBLOCK_UNDERCONNECT (-503) 289 #define ERR_EINPROGRESS (-504) 290 #define ERR_FT_SOCKET_INVALID (-506) 291 #define ERR_TRACE_OBJ_TYPE_INVALID (-507) 292 #define ERR_STACK_NOT_INITED (-518) /* Stack is not in ACTIVE state */ 293 #define ERR_HMAC_SHA2_DIGEST_MISMATCH (-519) 294 #define ERR_STALE_COOKIE_ERROR (-520) 295 #define ERR_COOKIE_PORT_MISMATCH (-521) 296 #define ERR_REMOTE_REJECT_OR_CLOSE (-522) 297 #define ERR_NON_FATAL (-523) 298 #define ERR_REMOTE_REJECT_VERSION (-524) 299 #define ERR_COMM (-1000) /* general error */ 300 #define ERR_SOCK_BIND (-1001) /* bind failed */ 301 #ifdef FILLP_WIN32 302 #ifndef ERROR_WAS_LOCKED 303 /* WinError.h: 717717 (0x2CD) {Page Locked} One of the pages to lock was already locked */ 304 #define ERROR_WAS_LOCKED 0x2CD 305 #endif /* #ifndef ERROR_WAS_LOCKED */ 306 #endif /* #ifdef FILLP_WIN32 */ 307 308 #ifdef FILLP_LINUX 309 #define FILLP_EAGAIN EAGAIN 310 #define FILLP_EWOULDBLOCK FILLP_EAGAIN 311 #define FILLP_EINPROGRESS EINPROGRESS 312 #define FILLP_EINVAL EINVAL 313 #define FILLP_EBADF EBADF 314 #define FILLP_ENOMEM ENOMEM 315 #define FILLP_EPIPE EPIPE 316 #define FILLP_EFAULT EFAULT 317 #define FILLP_ENOTCONN ENOTCONN 318 #define FILLP_ECONNRESET ECONNRESET 319 #define FILLP_ENODATA ENODATA 320 #define FILLP_ENOBUFS ENOBUFS 321 #define FILLP_ETIMEDOUT ETIMEDOUT 322 #define FILLP_ECONNREFUSED ECONNREFUSED 323 #define FILLP_EPROTOTYPE EPROTOTYPE 324 #define FILLP_ENOPROTOOPT ENOPROTOOPT 325 #define FILLP_EPROTONOSUPPORT EPROTONOSUPPORT 326 #define FILLP_ESOCKTNOSUPPORT ESOCKTNOSUPPORT 327 #define FILLP_EOPNOTSUPP EOPNOTSUPP 328 #define FILLP_EPFNOSUPPORT EPFNOSUPPORT 329 #define FILLP_EAFNOSUPPORT EAFNOSUPPORT 330 #define FILLP_EADDRINUSE EADDRINUSE 331 #define FILLP_EBUSY EBUSY 332 #define FILLP_ENOTSOCK ENOTSOCK 333 #define FILLP_EISCONN EISCONN 334 #define FILLP_ENOENT ENOENT 335 #define FILLP_EEXIST EEXIST 336 #define FILLP_EMFILE EMFILE 337 #define FILLP_EALREADY EALREADY 338 339 #elif defined(FILLP_WIN32) 340 #define FILLP_EAGAIN WSAEWOULDBLOCK 341 #define FILLP_EWOULDBLOCK FILLP_EAGAIN 342 #define FILLP_EINPROGRESS WSAEINPROGRESS 343 #define FILLP_EINVAL WSAEINVAL 344 #define FILLP_EBADF WSAEBADF 345 #define FILLP_ENOMEM WSA_NOT_ENOUGH_MEMORY 346 #define FILLP_EPIPE WSAENOTCONN 347 #define FILLP_EFAULT WSAEFAULT 348 #define FILLP_ENOTCONN WSAENOTCONN 349 #define FILLP_ECONNRESET WSAECONNRESET 350 #define FILLP_ENODATA WSAENOMORE 351 #define FILLP_ENOBUFS WSAENOBUFS 352 #define FILLP_ETIMEDOUT WSAETIMEDOUT 353 #define FILLP_ECONNREFUSED WSAECONNREFUSED 354 #define FILLP_EPROTOTYPE WSAEPROTOTYPE 355 #define FILLP_ENOPROTOOPT WSAENOPROTOOPT 356 #define FILLP_EPROTONOSUPPORT WSAEPROTONOSUPPORT 357 #define FILLP_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 358 #define FILLP_EOPNOTSUPP WSAEOPNOTSUPP 359 #define FILLP_EPFNOSUPPORT WSAEPFNOSUPPORT 360 #define FILLP_EAFNOSUPPORT WSAEAFNOSUPPORT 361 #define FILLP_EADDRINUSE WSAEADDRINUSE 362 #define FILLP_EBUSY ERROR_WAS_LOCKED 363 #define FILLP_ENOTSOCK WSAENOTSOCK 364 #define FILLP_EISCONN WSAEISCONN 365 #define FILLP_ENOENT WSANO_DATA 366 #define FILLP_EEXIST WSAEALREADY 367 #define FILLP_EMFILE WSAEMFILE 368 #define FILLP_EALREADY WSAEALREADY 369 #endif 370 371 #define FILLP_SIZE_T size_t 372 #if defined(FILLP_LINUX) 373 374 #define FILLP_ATOMIC 375 376 /** 377 * Provides the data to store atomic operations value. 378 */ 379 #ifdef FILLP_ATOMIC 380 #ifdef FILLP_LW_LITEOS 381 typedef atomic_t SysArchAtomic; 382 #else 383 typedef struct { 384 volatile FILLP_INT counter; /* Indicates the counter to store atomic operations value. */ 385 #ifdef FILLP_64BIT_ALIGN 386 FILLP_UINT32 reserve; 387 #endif 388 } AtomicT; 389 typedef AtomicT SysArchAtomic; 390 #endif 391 #endif /* FILLP_ATOMIC */ 392 393 #ifndef FILLP_MAC 394 typedef struct { 395 FILLP_INT counter; 396 pthread_mutex_t mutex; 397 pthread_cond_t cond; 398 } SemT; 399 #define SYS_ARCH_SEM SemT 400 #endif 401 402 #ifdef FILLP_MAC 403 #define SYS_ARCH_SEM semaphore_t 404 #endif 405 406 #if defined(FILLP_LW_LITEOS) 407 typedef struct InnerSysArchRwSem { 408 pthread_mutex_t readMutex; 409 pthread_mutex_t writeMutex; 410 volatile int readCount; 411 } SYS_ARCH_RW_SEM; 412 413 #else 414 #define SYS_ARCH_RW_SEM pthread_rwlock_t 415 #endif 416 #elif defined(FILLP_WIN32) 417 418 typedef volatile FILLP_INT SysArchAtomic; 419 420 /** 421 * Provides a semaphore. 422 */ 423 #define SYS_ARCH_SEM HANDLE 424 typedef struct InnerSysArchRwSem { 425 volatile FILLP_ULONG sem; /* Indicates a semaphore. */ 426 } SYS_ARCH_RW_SEM; 427 #else 428 # error "system atomic function need to define !!!" 429 #endif 430 431 typedef struct sockaddr FILLP_SOCKADDR; 432 433 /** 434 * Provides thread parameters. 435 */ 436 struct ThreadParam { 437 void (*func)(void *param); /* Indicates a pointer to the spunge main thread function. */ 438 void *param; /* Indicates a pointer to the spunge instance. */ 439 }; 440 441 /** 442 * Provides the FillP debug level values. 443 */ 444 typedef enum { 445 FILLP_DBG_LVL_DEBUG = 1, /* Indicates the FillP debug level. */ 446 FILLP_DBG_LVL_DETAIL, /* Indicates the FillP debug details. */ 447 FILLP_DBG_LVL_INFO, /* Indicates the FillP debug information. */ 448 FILLP_DBG_LVL_WARNING, /* Indicates the FillP debug level warning. */ 449 FILLP_DBG_LVL_ERROR, /* Indicates the FillP debug level error. */ 450 FILLP_DBG_LVL_BUTT, /* Indicates the end of the enum. */ 451 FILLP_DBG_LVL_HELP, 452 FILLP_DBG_LVL_SHOWDATA, 453 FILLP_DBG_LVL_SHOWLEVEL, 454 } FillpDebugLevel; 455 456 /** 457 * Provides the debug type values. 458 */ 459 typedef enum { 460 /* Provides information about all other debug commands which a developer can use. */ 461 FILLP_DBG_HELP, 462 /* Provides all runtime error/warning/info logs, based on the level 463 * set by developer/debugger(FILLP_DBGCMD_SET_PRINT_LEVEL) */ 464 FILLP_DBG_PRINT, 465 /* Provides information on the existing level for run time debug information set by the developer. */ 466 FILLP_DBG_SHOW_LEVEL, 467 /* Provides function trace information, if enabled by the developer. */ 468 FILLP_DBG_FUNC_TRACE, 469 /* Provides information requested by the developer using debug interface. */ 470 FILLP_DBG_SHOW_DATA, 471 /* Provides all the product/user related log information. */ 472 FILLP_DBG_LOG 473 } FillpDebugType; 474 475 typedef enum { 476 FILLP_PACK_STATE_NORMAL = 1, 477 FILLP_PACK_STATE_ENLARGE, 478 FILLP_PACK_STATE_KEEP_ALIVE 479 } FillpPackSendState; 480 481 /** 482 * @ingroup FillPDebug 483 * @brief 484 * This callback is use for debug send. 485 * 486 * @param[in] debugType @ref FillpDebugType 487 * @param[in] debugLvl @ref FillpDebugLevel 488 * @param[in] debugId Indicates the file and line information. 489 * @param[in] format Specifies the actual message. 490 * 491 * @return 492 * On success : FILLP_SUCCESS 493 * On failure : FILLP_FAILURE 494 */ 495 typedef void (*FillpDebugSendFunc)(IN FILLP_UINT32 debugType, IN FILLP_UINT32 debugLvl, 496 IN FILLP_UINT32 debugId, IN FILLP_CHAR *format, ...); 497 498 /** 499 * Provides information about LM callback function. 500 */ 501 typedef struct { 502 FillpDebugSendFunc debugCallbackFunc; /* Registers debug information output callback function. */ 503 } FillpLmCallbackFunc; 504 505 /** 506 * @ingroup FillPDebug 507 * @brief 508 * Sets the debug log level. 509 * 510 * @param[in] logLevel Defines the log level. Refer @ref FillpDebugLevel. 511 * @return 512 * FILLP_SUCCESS on success, otherwise error codes. 513 */ 514 extern FILLP_INT32 DLL_API FillpApiSetDebugLogLevel(IN FILLP_UINT8 logLevel); 515 516 /** 517 * @ingroup FillPDebug 518 * @brief 519 * Sets the log enable/disable status for different modules. 520 * 521 * @param[in] logModules ORed values of all the modules for which log needs to 522 * be enabled. If set to 0xFFFFFFFF, then it is enabled for all the modules. 523 * @return 524 * FILLP_SUCCESS on success, otherwise error codes. 525 */ 526 extern FILLP_UINT32 DLL_API FillpApiConfigLogModules(IN FILLP_ULLONG logModules); 527 528 /** 529 * @ingroup Callbacks 530 * @brief 531 * This callback is used to info APP that fillp socket is about to close and destroy, so APP 532 * can do something before fillp socket destroy. 533 * 534 * @param[in] udpSock udp socket fd 535 * @param[in] localAddr Indicates the local socket address 536 * @param[in] peerAddr Indicates the peer socket address 537 * 538 * @return 539 * void 540 */ 541 typedef void (*FillpSockCloseCbkFunc)(IN FILLP_INT udpSock, IN struct sockaddr *localAddr, 542 IN struct sockaddr *peerAddr); 543 544 /** 545 * Structure of app callback functions. 546 */ 547 typedef struct { 548 FillpSockCloseCbkFunc fillpSockCloseCbkFunc; /* Registers fillp socket close callback function. */ 549 } FillpAppCallbackFunc; 550 551 typedef void (*FillpEventPollCbFunc)(void *argEpInfo, int fd, int event); 552 553 enum { 554 NONE, 555 VIDEO_I, 556 VIDEO_P, 557 VIDEO_MAX = 50, 558 AUDIO = VIDEO_MAX + 1, 559 AUDIO_MAX = 100, 560 }; 561 562 #define FRAME_INFO_BITMAP_SLICE_END 0x00000001 /* last data of the slice */ 563 #define FRAME_INFO_BITMAP_FRAME_END 0x00000002 /* last data of the frame, 564 * when set, the SLICE_END or the LAYER_END no need to set */ 565 #define FRAME_INFO_BITMAP_LAYER_END 0x00000004 /* last data of the layer */ 566 567 struct FrameInfo { 568 FILLP_INT frameType; /* I or P frame */ 569 FILLP_INT seqNum; /* frame sequence number, different slice or layer data has the same sequence, 570 * range [0 ~ 2147483647] */ 571 FILLP_INT subSeqNum; /* slice number of the frame, started at 0 of a new slice */ 572 FILLP_INT level; /* level of the scalable video coding, 0: basic level, 1: extend level 1, 2: extend level 2 */ 573 FILLP_SLONG timestamp; /* time of the frame in codec, us. it's optional and value 0 means no time got */ 574 FILLP_UINT32 bitMap; 575 }; 576 577 /** 578 * the event type 579 */ 580 typedef enum { 581 FT_EVT_FRAME_STATS, 582 FT_EVT_TRAFFIC_DATA, 583 FT_EVT_MAX, 584 } FtEnumEventType; 585 586 typedef enum { 587 FILLP_FRAME_COST_LT10MS = 0, 588 FILLP_FRAME_COST_LT30MS, 589 FILLP_FRAME_COST_LT50MS, 590 FILLP_FRAME_COST_LT75MS, 591 FILLP_FRAME_COST_LT100MS, 592 FILLP_FRAME_COST_LT120MS, 593 FILLP_FRAME_COST_GE120MS, 594 FILLP_FRAME_COST_MAX, 595 } FillpFrameCost; 596 597 typedef enum { 598 FILLP_FRAME_BIT_RATE_LT3M = 0, 599 FILLP_FRAME_BIT_RATE_LT6M, 600 FILLP_FRAME_BIT_RATE_LT10M, 601 FILLP_FRAME_BIT_RATE_LT20M, 602 FILLP_FRAME_BIT_RATE_LT30M, 603 FILLP_FRAME_BIT_RATE_GE30M, 604 FILLP_FRAME_BIT_RATE_MAX, 605 } FillpFrameBitRate; 606 607 typedef struct { 608 FILLP_UINT32 costTimeStatsCnt[FILLP_FRAME_COST_MAX]; 609 FILLP_UINT32 sendBitRateStatsCnt[FILLP_FRAME_BIT_RATE_MAX]; 610 } FillpFrameSendStats; 611 612 #define FILLP_TRAFFIC_LEN 32 613 typedef struct { 614 FILLP_UCHAR stats[FILLP_TRAFFIC_LEN]; 615 } FillpTrafficInfo; 616 617 /** 618 * Structure of event callback information. 619 */ 620 typedef struct { 621 FtEnumEventType evt; 622 union { 623 FillpFrameSendStats frameSendStats; 624 FillpTrafficInfo trafficData; 625 FILLP_UINT32 reserved; 626 } info; 627 } FtEventCbkInfo; 628 629 /** 630 * @ingroup fillpevt 631 * @brief This callback is used to info APP when some events occur. 632 * 633 * @param[in] fd Indicates a socket created by the FtSocket API. 634 * @param[in] info Pointer to event callback information FtEventCbkInfo. 635 * 636 * @return 637 * On Success : returns 0 638 * On Failure : returns -1 639 */ 640 typedef FILLP_INT (*FillpEvtCbkFunc)(IN FILLP_INT fd, IN FILLP_CONST FtEventCbkInfo *info); 641 642 #define FILLP_DFX_EVENT_NAME_LEN 33 643 644 typedef enum { 645 FILLP_DFX_EVENT_TYPE_FAULT, 646 FILLP_DFX_EVENT_TYPE_STATISTIC, 647 FILLP_DFX_EVENT_TYPE_SECURITY, 648 FILLP_DFX_EVENT_TYPE_BEHAVIOR, 649 } FillpDfxEvtType; 650 651 typedef enum { 652 FILLP_DFX_EVENT_LEVEL_CRITICAL, 653 FILLP_DFX_EVENT_LEVEL_MINOR, 654 } FillpDfxEventLevel; 655 656 typedef enum { 657 FILLP_DFX_PARAM_TYPE_BOOL, 658 FILLP_DFX_PARAM_TYPE_UINT8, 659 FILLP_DFX_PARAM_TYPE_UINT16, 660 FILLP_DFX_PARAM_TYPE_INT32, 661 FILLP_DFX_PARAM_TYPE_UINT32, 662 FILLP_DFX_PARAM_TYPE_UINT64, 663 FILLP_DFX_PARAM_TYPE_FLOAT, 664 FILLP_DFX_PARAM_TYPE_DOUBLE, 665 FILLP_DFX_PARAM_TYPE_STRING 666 } FillpDfxEventParamType; 667 668 typedef struct { 669 FillpDfxEventParamType type; 670 FILLP_CHAR paramName[FILLP_DFX_EVENT_NAME_LEN]; 671 union { 672 FILLP_UINT8 u8v; 673 FILLP_UINT16 u16v; 674 FILLP_INT32 i32v; 675 FILLP_UINT32 u32v; 676 FILLP_ULLONG u64v; 677 float f; 678 double d; 679 FILLP_CHAR str[FILLP_DFX_EVENT_NAME_LEN]; 680 } val; 681 } FillpDfxEventParam; 682 683 typedef struct { 684 FILLP_CHAR eventName[FILLP_DFX_EVENT_NAME_LEN]; 685 FillpDfxEvtType type; 686 FillpDfxEventLevel level; 687 FILLP_UINT32 paramNum; 688 FillpDfxEventParam *paramArray; 689 } FillpDfxEvent; 690 691 /** 692 * @ingroup fillpevt 693 * @brief report dstream event 694 * 695 * @param[in] softObj any useful message to FillpDfxEventCb 696 * @param[in] info event detail 697 */ 698 typedef void (*FillpDfxEventCb)(void *softObj, const FillpDfxEvent *info); 699 700 /** 701 * @ingroup fillpevt 702 * @brief function to printf data. 703 * 704 * @param[in] softObj any useful message to FillpDfxDumpFunc 705 * @param[in] data dump string to print 706 * @param[in] len lenth of data 707 */ 708 typedef void (*FillpDfxDumpFunc)(void *softObj, const FILLP_CHAR *data, FILLP_UINT32 len); 709 710 #ifdef __cplusplus 711 } 712 #endif 713 714 #endif 715 716