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 #if !defined(FILLP_TYPES_ERR_OK_INVALID) 263 #define ERR_OK 0 264 #endif 265 #endif 266 #define FILLP_OK ERR_OK 267 #define FILLP_NULL 0 268 #define ERR_NULLPTR (-1) /* NULL Point Error */ 269 #define ERR_NOBUFS (-2) /* No buf/item to malloc */ 270 #define FILLP_ERR_CONN (-3) /* connection err */ 271 #define ERR_PARAM (-4) /* EINVAL */ 272 #define ERR_NORES (-5) /* No resource */ 273 #define ERR_FAILURE (-7) /* general sem init failures and socket init failures */ 274 #define ERR_FEATURE_MACRO_NOT_ENABLED (-10) 275 #define FILLP_ERR_VAL (-13) 276 #define ERR_CONNREFUSED (-14) 277 #define ERR_NO_SOCK (-200) 278 #define ERR_NO_REBIND (-201) 279 #define ERR_EAGAIN (-205) 280 #define ERR_NO_SYS_SOCK (-207) 281 #define FILLP_ERR_ISCONN (-208) 282 #define FILLP_ERR_EALREADY (-209) 283 #define ERR_CONN_TIMEOUT (-300) 284 #define ERR_ADP_SYS_CALLBACK_NOT_REGISTERED (-303) 285 #define ERR_SOCK_TYPE_ERR (-306) 286 #define ERR_SYSTEM_MEMORY_FAILURE (-308) 287 #define ERR_STACK_ALREADY_INITIALD (-402) 288 #define ERR_UNDERCLOSURE (-500) /* ft socket is already under closure */ 289 #define ERR_WRONGSTATE (-501) /* api is invoked in wrong connection state */ 290 #define ERR_NONBLOCK_UNDERCONNECT (-503) 291 #define ERR_EINPROGRESS (-504) 292 #define ERR_FT_SOCKET_INVALID (-506) 293 #define ERR_TRACE_OBJ_TYPE_INVALID (-507) 294 #define ERR_STACK_NOT_INITED (-518) /* Stack is not in ACTIVE state */ 295 #define ERR_HMAC_SHA2_DIGEST_MISMATCH (-519) 296 #define ERR_STALE_COOKIE_ERROR (-520) 297 #define ERR_COOKIE_PORT_MISMATCH (-521) 298 #define ERR_REMOTE_REJECT_OR_CLOSE (-522) 299 #define ERR_NON_FATAL (-523) 300 #define ERR_REMOTE_REJECT_VERSION (-524) 301 #define ERR_COMM (-1000) /* general error */ 302 #define ERR_SOCK_BIND (-1001) /* bind failed */ 303 #ifdef FILLP_WIN32 304 #ifndef ERROR_WAS_LOCKED 305 /* WinError.h: 717717 (0x2CD) {Page Locked} One of the pages to lock was already locked */ 306 #define ERROR_WAS_LOCKED 0x2CD 307 #endif /* #ifndef ERROR_WAS_LOCKED */ 308 #endif /* #ifdef FILLP_WIN32 */ 309 310 #ifdef FILLP_LINUX 311 #define FILLP_EAGAIN EAGAIN 312 #define FILLP_EWOULDBLOCK FILLP_EAGAIN 313 #define FILLP_EINPROGRESS EINPROGRESS 314 #define FILLP_EINVAL EINVAL 315 #define FILLP_EBADF EBADF 316 #define FILLP_ENOMEM ENOMEM 317 #define FILLP_EPIPE EPIPE 318 #define FILLP_EFAULT EFAULT 319 #define FILLP_ENOTCONN ENOTCONN 320 #define FILLP_ECONNRESET ECONNRESET 321 #define FILLP_ENODATA ENODATA 322 #define FILLP_ENOBUFS ENOBUFS 323 #define FILLP_ETIMEDOUT ETIMEDOUT 324 #define FILLP_ECONNREFUSED ECONNREFUSED 325 #define FILLP_EPROTOTYPE EPROTOTYPE 326 #define FILLP_ENOPROTOOPT ENOPROTOOPT 327 #define FILLP_EPROTONOSUPPORT EPROTONOSUPPORT 328 #define FILLP_ESOCKTNOSUPPORT ESOCKTNOSUPPORT 329 #define FILLP_EOPNOTSUPP EOPNOTSUPP 330 #define FILLP_EPFNOSUPPORT EPFNOSUPPORT 331 #define FILLP_EAFNOSUPPORT EAFNOSUPPORT 332 #define FILLP_EADDRINUSE EADDRINUSE 333 #define FILLP_EBUSY EBUSY 334 #define FILLP_ENOTSOCK ENOTSOCK 335 #define FILLP_EISCONN EISCONN 336 #define FILLP_ENOENT ENOENT 337 #define FILLP_EEXIST EEXIST 338 #define FILLP_EMFILE EMFILE 339 #define FILLP_EALREADY EALREADY 340 341 #elif defined(FILLP_WIN32) 342 #define FILLP_EAGAIN WSAEWOULDBLOCK 343 #define FILLP_EWOULDBLOCK FILLP_EAGAIN 344 #define FILLP_EINPROGRESS WSAEINPROGRESS 345 #define FILLP_EINVAL WSAEINVAL 346 #define FILLP_EBADF WSAEBADF 347 #define FILLP_ENOMEM WSA_NOT_ENOUGH_MEMORY 348 #define FILLP_EPIPE WSAENOTCONN 349 #define FILLP_EFAULT WSAEFAULT 350 #define FILLP_ENOTCONN WSAENOTCONN 351 #define FILLP_ECONNRESET WSAECONNRESET 352 #define FILLP_ENODATA WSAENOMORE 353 #define FILLP_ENOBUFS WSAENOBUFS 354 #define FILLP_ETIMEDOUT WSAETIMEDOUT 355 #define FILLP_ECONNREFUSED WSAECONNREFUSED 356 #define FILLP_EPROTOTYPE WSAEPROTOTYPE 357 #define FILLP_ENOPROTOOPT WSAENOPROTOOPT 358 #define FILLP_EPROTONOSUPPORT WSAEPROTONOSUPPORT 359 #define FILLP_ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT 360 #define FILLP_EOPNOTSUPP WSAEOPNOTSUPP 361 #define FILLP_EPFNOSUPPORT WSAEPFNOSUPPORT 362 #define FILLP_EAFNOSUPPORT WSAEAFNOSUPPORT 363 #define FILLP_EADDRINUSE WSAEADDRINUSE 364 #define FILLP_EBUSY ERROR_WAS_LOCKED 365 #define FILLP_ENOTSOCK WSAENOTSOCK 366 #define FILLP_EISCONN WSAEISCONN 367 #define FILLP_ENOENT WSANO_DATA 368 #define FILLP_EEXIST WSAEALREADY 369 #define FILLP_EMFILE WSAEMFILE 370 #define FILLP_EALREADY WSAEALREADY 371 #endif 372 373 #define FILLP_SIZE_T size_t 374 #if defined(FILLP_LINUX) 375 376 #define FILLP_ATOMIC 377 378 /** 379 * Provides the data to store atomic operations value. 380 */ 381 #ifdef FILLP_ATOMIC 382 #ifdef FILLP_LW_LITEOS 383 typedef atomic_t SysArchAtomic; 384 #else 385 typedef struct { 386 volatile FILLP_INT counter; /* Indicates the counter to store atomic operations value. */ 387 #ifdef FILLP_64BIT_ALIGN 388 FILLP_UINT32 reserve; 389 #endif 390 } AtomicT; 391 typedef AtomicT SysArchAtomic; 392 #endif 393 #endif /* FILLP_ATOMIC */ 394 395 #ifndef FILLP_MAC 396 typedef struct { 397 FILLP_INT counter; 398 pthread_mutex_t mutex; 399 pthread_cond_t cond; 400 } SemT; 401 #define SYS_ARCH_SEM SemT 402 #endif 403 404 #ifdef FILLP_MAC 405 #define SYS_ARCH_SEM semaphore_t 406 #endif 407 408 #if defined(FILLP_LW_LITEOS) 409 typedef struct InnerSysArchRwSem { 410 pthread_mutex_t readMutex; 411 pthread_mutex_t writeMutex; 412 volatile int readCount; 413 } SYS_ARCH_RW_SEM; 414 415 #else 416 #define SYS_ARCH_RW_SEM pthread_rwlock_t 417 #endif 418 #elif defined(FILLP_WIN32) 419 420 typedef volatile FILLP_INT SysArchAtomic; 421 422 /** 423 * Provides a semaphore. 424 */ 425 #define SYS_ARCH_SEM HANDLE 426 typedef struct InnerSysArchRwSem { 427 volatile FILLP_ULONG sem; /* Indicates a semaphore. */ 428 } SYS_ARCH_RW_SEM; 429 #else 430 # error "system atomic function need to define !!!" 431 #endif 432 433 typedef struct sockaddr FILLP_SOCKADDR; 434 435 /** 436 * Provides thread parameters. 437 */ 438 struct ThreadParam { 439 void (*func)(void *param); /* Indicates a pointer to the spunge main thread function. */ 440 void *param; /* Indicates a pointer to the spunge instance. */ 441 }; 442 443 /** 444 * Provides the FillP debug level values. 445 */ 446 typedef enum { 447 FILLP_DBG_LVL_DEBUG = 1, /* Indicates the FillP debug level. */ 448 FILLP_DBG_LVL_DETAIL, /* Indicates the FillP debug details. */ 449 FILLP_DBG_LVL_INFO, /* Indicates the FillP debug information. */ 450 FILLP_DBG_LVL_WARNING, /* Indicates the FillP debug level warning. */ 451 FILLP_DBG_LVL_ERROR, /* Indicates the FillP debug level error. */ 452 FILLP_DBG_LVL_BUTT, /* Indicates the end of the enum. */ 453 FILLP_DBG_LVL_HELP, 454 FILLP_DBG_LVL_SHOWDATA, 455 FILLP_DBG_LVL_SHOWLEVEL, 456 } FillpDebugLevel; 457 458 /** 459 * Provides the debug type values. 460 */ 461 typedef enum { 462 /* Provides information about all other debug commands which a developer can use. */ 463 FILLP_DBG_HELP, 464 /* Provides all runtime error/warning/info logs, based on the level 465 * set by developer/debugger(FILLP_DBGCMD_SET_PRINT_LEVEL) */ 466 FILLP_DBG_PRINT, 467 /* Provides information on the existing level for run time debug information set by the developer. */ 468 FILLP_DBG_SHOW_LEVEL, 469 /* Provides function trace information, if enabled by the developer. */ 470 FILLP_DBG_FUNC_TRACE, 471 /* Provides information requested by the developer using debug interface. */ 472 FILLP_DBG_SHOW_DATA, 473 /* Provides all the product/user related log information. */ 474 FILLP_DBG_LOG 475 } FillpDebugType; 476 477 typedef enum { 478 FILLP_PACK_STATE_NORMAL = 1, 479 FILLP_PACK_STATE_ENLARGE, 480 FILLP_PACK_STATE_KEEP_ALIVE 481 } FillpPackSendState; 482 483 /** 484 * @ingroup FillPDebug 485 * @brief 486 * This callback is use for debug send. 487 * 488 * @param[in] debugType @ref FillpDebugType 489 * @param[in] debugLvl @ref FillpDebugLevel 490 * @param[in] debugId Indicates the file and line information. 491 * @param[in] format Specifies the actual message. 492 * 493 * @return 494 * On success : FILLP_SUCCESS 495 * On failure : FILLP_FAILURE 496 */ 497 typedef void (*FillpDebugSendFunc)(IN FILLP_UINT32 debugType, IN FILLP_UINT32 debugLvl, 498 IN FILLP_UINT32 debugId, IN FILLP_CHAR *format, ...); 499 500 /** 501 * Provides information about LM callback function. 502 */ 503 typedef struct { 504 FillpDebugSendFunc debugCallbackFunc; /* Registers debug information output callback function. */ 505 } FillpLmCallbackFunc; 506 507 /** 508 * @ingroup FillPDebug 509 * @brief 510 * Sets the debug log level. 511 * 512 * @param[in] logLevel Defines the log level. Refer @ref FillpDebugLevel. 513 * @return 514 * FILLP_SUCCESS on success, otherwise error codes. 515 */ 516 extern FILLP_INT32 DLL_API FillpApiSetDebugLogLevel(IN FILLP_UINT8 logLevel); 517 518 /** 519 * @ingroup FillPDebug 520 * @brief 521 * Sets the log enable/disable status for different modules. 522 * 523 * @param[in] logModules ORed values of all the modules for which log needs to 524 * be enabled. If set to 0xFFFFFFFF, then it is enabled for all the modules. 525 * @return 526 * FILLP_SUCCESS on success, otherwise error codes. 527 */ 528 extern FILLP_UINT32 DLL_API FillpApiConfigLogModules(IN FILLP_ULLONG logModules); 529 530 /** 531 * @ingroup Callbacks 532 * @brief 533 * This callback is used to info APP that fillp socket is about to close and destroy, so APP 534 * can do something before fillp socket destroy. 535 * 536 * @param[in] udpSock udp socket fd 537 * @param[in] localAddr Indicates the local socket address 538 * @param[in] peerAddr Indicates the peer socket address 539 * 540 * @return 541 * void 542 */ 543 typedef void (*FillpSockCloseCbkFunc)(IN FILLP_INT udpSock, IN struct sockaddr *localAddr, 544 IN struct sockaddr *peerAddr); 545 546 /** 547 * Structure of app callback functions. 548 */ 549 typedef struct { 550 FillpSockCloseCbkFunc fillpSockCloseCbkFunc; /* Registers fillp socket close callback function. */ 551 } FillpAppCallbackFunc; 552 553 typedef void (*FillpEventPollCbFunc)(void *argEpInfo, int fd, int event); 554 555 enum { 556 NONE, 557 VIDEO_I, 558 VIDEO_P, 559 VIDEO_MAX = 50, 560 AUDIO = VIDEO_MAX + 1, 561 AUDIO_MAX = 100, 562 }; 563 564 #define FRAME_INFO_BITMAP_SLICE_END 0x00000001 /* last data of the slice */ 565 #define FRAME_INFO_BITMAP_FRAME_END 0x00000002 /* last data of the frame, 566 * when set, the SLICE_END or the LAYER_END no need to set */ 567 #define FRAME_INFO_BITMAP_LAYER_END 0x00000004 /* last data of the layer */ 568 569 struct FrameInfo { 570 FILLP_INT frameType; /* I or P frame */ 571 FILLP_INT seqNum; /* frame sequence number, different slice or layer data has the same sequence, 572 * range [0 ~ 2147483647] */ 573 FILLP_INT subSeqNum; /* slice number of the frame, started at 0 of a new slice */ 574 FILLP_INT level; /* level of the scalable video coding, 0: basic level, 1: extend level 1, 2: extend level 2 */ 575 FILLP_SLONG timestamp; /* time of the frame in codec, us. it's optional and value 0 means no time got */ 576 FILLP_UINT32 bitMap; 577 }; 578 579 /** 580 * the event type 581 */ 582 typedef enum { 583 FT_EVT_FRAME_STATS, 584 FT_EVT_TRAFFIC_DATA, 585 FT_EVT_MAX, 586 } FtEnumEventType; 587 588 typedef enum { 589 FILLP_FRAME_COST_LT10MS = 0, 590 FILLP_FRAME_COST_LT30MS, 591 FILLP_FRAME_COST_LT50MS, 592 FILLP_FRAME_COST_LT75MS, 593 FILLP_FRAME_COST_LT100MS, 594 FILLP_FRAME_COST_LT120MS, 595 FILLP_FRAME_COST_GE120MS, 596 FILLP_FRAME_COST_MAX, 597 } FillpFrameCost; 598 599 typedef enum { 600 FILLP_FRAME_BIT_RATE_LT3M = 0, 601 FILLP_FRAME_BIT_RATE_LT6M, 602 FILLP_FRAME_BIT_RATE_LT10M, 603 FILLP_FRAME_BIT_RATE_LT20M, 604 FILLP_FRAME_BIT_RATE_LT30M, 605 FILLP_FRAME_BIT_RATE_GE30M, 606 FILLP_FRAME_BIT_RATE_MAX, 607 } FillpFrameBitRate; 608 609 typedef struct { 610 FILLP_UINT32 costTimeStatsCnt[FILLP_FRAME_COST_MAX]; 611 FILLP_UINT32 sendBitRateStatsCnt[FILLP_FRAME_BIT_RATE_MAX]; 612 } FillpFrameSendStats; 613 614 #define FILLP_TRAFFIC_LEN 32 615 typedef struct { 616 FILLP_UCHAR stats[FILLP_TRAFFIC_LEN]; 617 } FillpTrafficInfo; 618 619 /** 620 * Structure of event callback information. 621 */ 622 typedef struct { 623 FtEnumEventType evt; 624 union { 625 FillpFrameSendStats frameSendStats; 626 FillpTrafficInfo trafficData; 627 FILLP_UINT32 reserved; 628 } info; 629 } FtEventCbkInfo; 630 631 /** 632 * @ingroup fillpevt 633 * @brief This callback is used to info APP when some events occur. 634 * 635 * @param[in] fd Indicates a socket created by the FtSocket API. 636 * @param[in] info Pointer to event callback information FtEventCbkInfo. 637 * 638 * @return 639 * On Success : returns 0 640 * On Failure : returns -1 641 */ 642 typedef FILLP_INT (*FillpEvtCbkFunc)(IN FILLP_INT fd, IN FILLP_CONST FtEventCbkInfo *info); 643 644 #define FILLP_DFX_EVENT_NAME_LEN 33 645 646 typedef enum { 647 FILLP_DFX_EVENT_TYPE_FAULT, 648 FILLP_DFX_EVENT_TYPE_STATISTIC, 649 FILLP_DFX_EVENT_TYPE_SECURITY, 650 FILLP_DFX_EVENT_TYPE_BEHAVIOR, 651 } FillpDfxEvtType; 652 653 typedef enum { 654 FILLP_DFX_EVENT_LEVEL_CRITICAL, 655 FILLP_DFX_EVENT_LEVEL_MINOR, 656 } FillpDfxEventLevel; 657 658 typedef enum { 659 FILLP_DFX_PARAM_TYPE_BOOL, 660 FILLP_DFX_PARAM_TYPE_UINT8, 661 FILLP_DFX_PARAM_TYPE_UINT16, 662 FILLP_DFX_PARAM_TYPE_INT32, 663 FILLP_DFX_PARAM_TYPE_UINT32, 664 FILLP_DFX_PARAM_TYPE_UINT64, 665 FILLP_DFX_PARAM_TYPE_FLOAT, 666 FILLP_DFX_PARAM_TYPE_DOUBLE, 667 FILLP_DFX_PARAM_TYPE_STRING 668 } FillpDfxEventParamType; 669 670 typedef struct { 671 FillpDfxEventParamType type; 672 FILLP_CHAR paramName[FILLP_DFX_EVENT_NAME_LEN]; 673 union { 674 FILLP_UINT8 u8v; 675 FILLP_UINT16 u16v; 676 FILLP_INT32 i32v; 677 FILLP_UINT32 u32v; 678 FILLP_ULLONG u64v; 679 float f; 680 double d; 681 FILLP_CHAR str[FILLP_DFX_EVENT_NAME_LEN]; 682 } val; 683 } FillpDfxEventParam; 684 685 typedef struct { 686 FILLP_CHAR eventName[FILLP_DFX_EVENT_NAME_LEN]; 687 FillpDfxEvtType type; 688 FillpDfxEventLevel level; 689 FILLP_UINT32 paramNum; 690 FillpDfxEventParam *paramArray; 691 } FillpDfxEvent; 692 693 /** 694 * @ingroup fillpevt 695 * @brief report dstream event 696 * 697 * @param[in] softObj any useful message to FillpDfxEventCb 698 * @param[in] info event detail 699 */ 700 typedef void (*FillpDfxEventCb)(void *softObj, const FillpDfxEvent *info); 701 702 /** 703 * @ingroup fillpevt 704 * @brief function to printf data. 705 * 706 * @param[in] softObj any useful message to FillpDfxDumpFunc 707 * @param[in] data dump string to print 708 * @param[in] len lenth of data 709 */ 710 typedef void (*FillpDfxDumpFunc)(void *softObj, const FILLP_CHAR *data, FILLP_UINT32 len); 711 712 #ifdef __cplusplus 713 } 714 #endif 715 716 #endif 717 718