1 /* 2 * Copyright (c) 2020-2021 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 /** 17 * @addtogroup format 18 * @{ 19 * 20 * @brief Defines format-related APIs. 21 * 22 * For example, you use this module to define custom data types and to initialize, create, 23 * destroy the muxer and demuxer, and set their parameters. Also, you can read demuxer data frames, 24 * select demuxer tracks, add muxer tracks, and write data frames into a container. 25 * 26 * @since 1.0 27 * @version 1.0 28 */ 29 30 /** 31 * @file format_type.h 32 * 33 * @brief Declares format-related structures and enumerations, including custom data types for file information, 34 * programs, information about audio and video subtitle tracks, source data types, output data types, split types, 35 * and data frames. 36 * 37 * 38 * 39 * @since 1.0 40 * @version 1.0 41 */ 42 43 #ifndef FORMAT_TYPE_H 44 #define FORMAT_TYPE_H 45 46 #include <stdint.h> 47 #include <stdbool.h> 48 #include "parameter_item.h" 49 50 #ifdef __cplusplus 51 #if __cplusplus 52 extern "C" { 53 #endif 54 #endif /* __cplusplus */ 55 56 #define FORMAT_MAX_LANGUAGE_NUM 4 /**< Indicates the number of languages in the subtitle file. */ 57 #define FORMAT_LANGUAGE_LEN 4 /**< Indicates the number of characters contained in the language description. */ 58 #define FORMAT_TITLE_LEN 64 /**< Indicates the number of title characters. */ 59 #define FORMAT_INVALID_TRACK_ID (-1) /**< Indicates an invalid track ID. */ 60 #define FORMAT_INVALID_PROGRAM_ID (-1) /**< Indicates an invalid program ID. */ 61 62 /** 63 * @brief define FormatHandle type. 64 * 65 * @since 1.0 66 * @version 1.0 67 */ 68 typedef void* FormatHandle; 69 70 /** 71 * @brief Enumerates data frame types. 72 * 73 * @since 1.0 74 * @version 1.0 75 */ 76 typedef enum { 77 FRAME_TYPE_NONE, /**< Unknown type, which can be used for transport stream (TS) packets */ 78 FRAME_TYPE_AUDIO, /**< Audio frame */ 79 FRAME_TYPE_VIDEO, /**< Video frame */ 80 FRAME_TYPE_IMAGE, /**< Image frame */ 81 FRAME_TYPE_SUB, /**< Subtitle frame */ 82 FRAME_TYPE_DATA, /**< Data */ 83 FRAME_TYPE_BUT, /**< Undefined type */ 84 } FrameType; 85 86 /** 87 * @brief Enumerates seek modes. 88 * 89 * @since 1.0 90 * @version 1.0 91 */ 92 typedef enum { 93 FORMAT_SEEK_MODE_FORWARD_KEY, /**< Seeks forwards for the keyframe closest to specified position. */ 94 FORMAT_SEEK_MODE_BACKWARD_KEY, /**< Seeks backwards for the keyframe closest to specified position. */ 95 FORMAT_SEEK_MODE_CLOSEST_KEY, /**< Seeks for the keyframe closest to specified position. */ 96 SEEK_MODE_BUT /**< Undefined mode */ 97 } FormatSeekMode; 98 99 /** 100 * @brief Enumerates audio, video, and image encoding formats. 101 * 102 * @since 1.0 103 * @version 1.0 104 */ 105 typedef enum { 106 CODEC_H264 = 0, /**< H264 or AVC */ 107 CODEC_H265, /**< H265 or HEVC */ 108 CODEC_JPEG, /**< JPEG */ 109 CODEC_AAC, /**< AAC */ 110 CODEC_G711A, /**< G711A */ 111 CODEC_G711U, /**< G711u */ 112 CODEC_PCM, /**< PCM */ 113 CODEC_MP3, /**< MP3 */ 114 CODEC_G726, /**< G726 */ 115 CODEC_OPUS, /**< OPUS */ 116 CODEC_FLAC, /**< FLAC */ 117 CODEC_VORBIS, /**< VORBIS */ 118 CODEC_APE, /**< APE */ 119 CODEC_BUT, /**< Undefined format */ 120 } CodecFormat; 121 122 /** 123 * @brief Enumerates audio sampling formats. 124 * 125 * @since 1.0 126 * @version 1.0 127 */ 128 typedef enum { 129 FORMAT_AUDIO_SAMPLE_FMT_S8 = 0, /**< 8-bit integer for a single sample */ 130 FORMAT_AUDIO_SAMPLE_FMT_S16, /**< 16-bit integer for a single sample */ 131 FORMAT_AUDIO_SAMPLE_FMT_S24, /**< 24-bit integer for a single sample */ 132 FORMAT_AUDIO_SAMPLE_FMT_S32, /**< 32-bit integer for a single sample */ 133 FORMAT_AUDIO_SAMPLE_FMT_FLOAT, /**< Single-precision floating point number for a single sample */ 134 } FormatAudioSampleFmt; 135 136 /** 137 * @brief Enumerates subtitle frame types. 138 * 139 * @since 1.0 140 * @version 1.0 141 */ 142 typedef enum { 143 HI_SVR_SUBTITLE_BITMAP = 0x0, /**< Bitmap (BMP) */ 144 HI_SVR_SUBTITLE_TEXT, /**< Text */ 145 } SubtitleFrameType; 146 147 /** 148 * @brief Defines the buffer configuration. 149 * 150 * If <b>maxSize</b> and <b>maxDurationMs</b> are valid at the same time, 151 * the smaller value is used as the upper limit for the buffer. 152 * 153 * @since 1.0 154 * @version 1.0 155 */ 156 typedef struct { 157 int64_t maxSize; /**< Maximum buffer size */ 158 int64_t maxDurationMs; /**< Maximum duration of a media file */ 159 } FormatBufferSetting; 160 161 /** 162 * @brief Defines the data frame, which is used for data transferring. 163 * 164 * @since 1.0 165 * @version 1.0 166 */ 167 typedef struct { 168 FrameType frameType; /**< Data frame type. For details, see {@link FrameType}. */ 169 uint32_t trackId; /**< Index of the track where the data frame is located */ 170 bool isKeyFrame; /**< Keyframe flag. <b>false</b>: The data frame is not a keyframe. 171 * <b>true</b>: The data frame is a keyframe. 172 */ 173 int64_t timestampUs; /**< Timestamp of a data frame, in us */ 174 int64_t durationUs; /**< Data frame duration, in us */ 175 uint8_t* data; /**< Address of the data frame buffer */ 176 uint32_t len; /**< Data frame length */ 177 uint32_t frameIndex; /**< Data frame index. For the MPF container, the value indicates 178 * the index of the sub-image frame. 179 */ 180 int64_t position; /**< Position of the data frame in the file */ 181 int32_t itemCnt; /**< Number of parameters, which can be used for information such as side data, 182 * PSSH, DRM, and HDR. 183 */ 184 ParameterItem *item; /**< Pointer to the parameter array */ 185 } FormatFrame; 186 187 /** 188 * @brief Enumerates subtitle file formats. 189 * 190 * @since 1.0 191 * @version 1.0 192 */ 193 typedef enum { 194 FORMAT_SUB_ASS = 0x0, /**< ASS */ 195 FORMAT_SUB_LRC, /**< LRC */ 196 FORMAT_SUB_SRT, /**< SRT */ 197 FORMAT_SUB_SMI, /**< SMI */ 198 FORMAT_SUB_SUB, /**< SUB */ 199 FORMAT_SUB_TXT, /**< RAW UTF-8 */ 200 FORMAT_SUB_HDMV_PGS, /**< HDMV PGS */ 201 FORMAT_SUB_DVB_SUB, /**< DVB */ 202 FORMAT_SUB_DVD_SUB, /**< DVD */ 203 FORMAT_SUB_TTML, /**< TTML */ 204 FORMAT_SUB_WEBVTT, /**< WebVTT */ 205 FORMAT_SUB_BUTT /**< Undefined format */ 206 } SubtitleFormat; 207 208 /** 209 * @brief Defines audio track information. 210 * 211 * @since 1.0 212 * @version 1.0 213 */ 214 typedef struct { 215 CodecFormat format; /**< Audio encoding format. For details, see {@link CodecFormat}. */ 216 uint32_t profile; /**< Audio encoding profile, for example, <b>0x160(WMAV1)</b> and <b>0x161 (WMAV2)</b>. */ 217 uint32_t sampleRate; /**< Audio sampling rate, for example, <b>8000</b>, <b>16000</b>, <b>24000</b>, <b>32000</b>, 218 * <b>11025</b>, <b>22050</b>, <b>441000</b>, and <b>48000</b> 219 */ 220 uint16_t sampleFmt; /**< Data storage format of one sample in an audio channel. 221 * For details, see {@link AudioSampleFmt}. 222 */ 223 uint16_t channels; /**< Number of audio channels */ 224 int32_t subStreamID; /**< ID of the subsidiary audio stream, which is used when the encoding or decoding format 225 * of the primary stream is not supported for audio rendering. 226 */ 227 uint32_t bitrate; /**< Audio and video bit rate */ 228 char language[FORMAT_LANGUAGE_LEN]; /**< Audio track language */ 229 int64_t durationMs; /**< Stream duration, in milliseconds */ 230 } AudioTrackInfo; 231 232 /** 233 * @brief Defines video track information. 234 * 235 * @since 1.0 236 * @version 1.0 237 */ 238 typedef struct { 239 CodecFormat format; /**< Video encoding format. For details, see {@link CodecFormat}. */ 240 uint16_t profile; /**< Profile */ 241 uint16_t width; /**< Width, in pixels */ 242 uint16_t height; /**< Height, in pixels*/ 243 uint16_t fpsNum; /**< Numerator of the frame rate */ 244 uint16_t fpsDen; /**< Denominator of the frame rate */ 245 uint32_t bitrate; /**< <Video bit rate, in bit/s */ 246 uint32_t rotate; /**< Video rotation angle. The value can be <b>90</b>, <b>180</b>, or <b>270</b>. 247 * The default value is <b>0</b>. 248 */ 249 int64_t durationMs; /**< Track duration, in milliseconds */ 250 }VideoTrackInfo; 251 252 /** 253 * @brief Defines image information. 254 * 255 * @since 1.0 256 * @version 1.0 257 */ 258 typedef struct { 259 CodecFormat format; /**< Image encoding format. For details, see {@link CodecFormat}. */ 260 uint16_t width; /**< Width, in pixels */ 261 uint16_t height; /**< Height, in pixels*/ 262 uint32_t rotate; /**< Image rotation angle. The value can be <b>90</b>, <b>180</b>, or <b>270</b>. 263 * The default value is <b>0</b>. 264 */ 265 uint32_t dataLength; /**< Image size */ 266 bool thumbnail; /**< Thumbnail flag */ 267 } SubImageInfo; 268 269 /** 270 * @brief Defines image stream information. 271 * 272 * @since 1.0 273 * @version 1.0 274 */ 275 typedef struct { 276 int32_t subImageNum; /**< Number of sub-images */ 277 SubImageInfo *subImageInfo; /**< Detailed information about a sub-image */ 278 } ImageTrackInfo; 279 280 /** 281 * @brief Defines subtitle stream information. 282 * 283 * @since 1.0 284 * @version 1.0 285 */ 286 typedef struct { 287 SubtitleFormat format; /**< Subtitle encoding and decoding format. For details, see {@link SubtitleFormat} */ 288 uint32_t charSet; /**< Character encoding format */ 289 char language[FORMAT_MAX_LANGUAGE_NUM][FORMAT_LANGUAGE_LEN]; /**< Subtitle language */ 290 uint16_t originalFrameWidth; /**< Width of the original image. This variable is valid for the image subtitle. */ 291 uint16_t originalFrameHeight; /**< Height of the original image. This variable is valid for the image subtitle. */ 292 } SubtitleTrackInfo; 293 294 /** 295 * @brief Enumerates track types. 296 * 297 * @since 1.0 298 * @version 1.0 299 */ 300 typedef enum { 301 TRACK_TYPE_VIDEO, /**< Video track */ 302 TRACK_TYPE_AUDIO, /**< Audio track */ 303 TRACK_TYPE_IMAGE, /**< Image track */ 304 TRACK_TYPE_SUB, /**< Subtitle track */ 305 TRACK_TYPE_DATA, /**< Data track */ 306 TRACK_TYPE_BUT, /**< Undefined track */ 307 } TrackType; 308 309 /** 310 * @brief Defines track information. 311 * 312 * @since 1.0 313 * @version 1.0 314 */ 315 typedef struct { 316 TrackType trackType; /**< Track type. For details, see {@link TrackType} */ 317 int32_t trackId; /**< Track index */ 318 union { 319 VideoTrackInfo vidTrack; /**< Video track information */ 320 AudioTrackInfo audTrack; /**< Audio track information */ 321 SubtitleTrackInfo subTrack; /**< Subtitle track information */ 322 ImageTrackInfo imgTrack; /**< Image track information */ 323 }; 324 int32_t itemCnt; /**< Number of extra track information entries */ 325 ParameterItem *item; /**< Pointer to the array of extra track information, including HDR, DRM, and CAS */ 326 } TrackInfo; 327 328 /** 329 * @brief Defines program information. 330 * 331 * @since 1.0 332 * @version 1.0 333 */ 334 typedef struct { 335 int32_t programId; /**< Program index */ 336 int64_t durationMs; /**< Program duration */ 337 uint32_t trackNum; /**< Number of tracks of the current program */ 338 TrackInfo *track; /**< Pointer to the array of current program information */ 339 } ProgramInfo; 340 341 /** 342 * @brief Defines movie file information. 343 * 344 * @since 1.0 345 * @version 1.0 346 */ 347 typedef struct { 348 char *formatName; /**< Pointer to the name of the movie file container format */ 349 uint32_t bitrate; /**< Bit rate of the movie file */ 350 uint32_t programNum; /**< Number of programs */ 351 ProgramInfo *programInfo; /**< Pointer to the array of information about the movie file program */ 352 } FileInfo; 353 354 /** 355 * @brief Enumerates flags of raw stream data. 356 * 357 * @since 1.0 358 * @version 1.0 359 */ 360 typedef enum { 361 DATA_FLAG_NONE = 0, /**< None */ 362 DATA_FLAG_SYNCFRAME = 1, /**< Synchronization frame */ 363 DATA_FLAG_CODECCONFIG = 2, /**< Codec configuration information */ 364 DATA_FLAG_EOS = 4, /**< End of a single stream */ 365 DATA_FLAG_PARTIAL_FRAME = 8, /**< Partial synchronization frame. This flag is used for multiple 366 * segments (except for the last one) into which a single frame is divided. 367 */ 368 DATA_FLAG_ENDOFFRAME = 16, /**< End of a frame. This flag is used in pair with <b>DATA_FLAG_PARTIAL_FRAME</b> for 369 * the last segment of the frame. 370 */ 371 DATA_FLAG_MUXER_DATA = 32, /**< Encapsulated data with its container */ 372 } DataFlags; 373 374 /** 375 * @brief Defines the function for reading stream data. 376 * 377 * @since 1.0 378 * @version 1.0 379 */ 380 typedef struct { 381 /** 382 * @brief Reads data from streams, save the data to the buffer pointed by <b>data</b> with the specified <b>size</b>, 383 * and returns the size of the read data and type. 384 * 385 * @param handle Indicates the pointer to the context handle. 386 * @param data Indicates the pointer to the buffer to store the read data. The memory is allocated by the caller. 387 * @param size Indicates the size of the available buffer memory. 388 * @param timeOutMs Indicates read operation wait time. The value <b>0</b> means no wait time. 389 * @param flags Indicates the pointer to the type of the read data, see {@link DataFlags}. 390 * @return Returns the size of the read data. 391 */ 392 int32_t (*ReadData)(void *handle, uint8_t *data, int32_t size, int32_t timeOutMs, DataFlags *flags); 393 394 /** 395 * @brief Obtains the size of data that can be read. 396 * 397 * Before reading data, you should call this function to check whether there is data to read. 398 * 399 * @param handle Indicates the pointer to the context handle. 400 * @return Returns the size of the read data. 401 */ 402 int32_t (*GetReadableSize)(const void *handle); 403 404 void *handle; /**< Context handle */ 405 } BufferStream; 406 407 /** 408 * @brief Enumerates types of the demuxer data source. 409 * 410 * @since 1.0 411 * @version 1.0 412 */ 413 typedef enum { 414 SOURCE_TYPE_FD = 0, /**< File descriptor */ 415 SOURCE_TYPE_URI, /**< URI, which can be a network address or a local file path */ 416 SOURCE_TYPE_STREAM, /**< Streams */ 417 SOURCE_TYPE_BUT /**< Undefined source */ 418 } SourceType; 419 420 #define URL_LEN 4096 /**< Indicates the URL length. */ 421 422 /** 423 * @brief Defines the demuxer data source. 424 * 425 * @since 1.0 426 * @version 1.0 427 */ 428 typedef struct { 429 SourceType type; /**< Data source type. For details, see {@link SourceType}. */ 430 /** 431 * @brief Defines information about different types of data sources. 432 */ 433 union { 434 int fd; /**< Local file descriptor */ 435 char url[URL_LEN]; /**< Network URI or local file path. The maximum length is specified by <b>URL_LEN</b>. */ 436 BufferStream *stream; /**< Pointer to the function for reading buffer stream data */ 437 }; 438 } FormatSource; 439 440 /** 441 * @brief Enumerates output file formats. 442 * 443 * @since 1.0 444 * @version 1.0 445 */ 446 typedef enum { 447 OUTPUT_FORMAT_MPEG_4 = 0, /**< MP4 */ 448 OUTPUT_FORMAT_TS = 1, /**< TS */ 449 OUTPUT_FORMAT_THREE_GPP = 2, /**< 3GPP */ 450 OUTPUT_FORMAT_HEIF = 3, /**< HEIF */ 451 OUTPUT_FORMAT_OGG = 4, /**< Ogg */ 452 OUTPUT_FORMAT_INVALID /**< Invalid format */ 453 } OutputFormat; 454 455 /** 456 * @brief Enumerates types of callback information. 457 * 458 * @since 1.0 459 * @version 1.0 460 */ 461 typedef enum { 462 MUXER_INFO_MAX_DURATION_APPROACHING = 0, /**< The capturing duration is reaching the threshold specified by 463 * {@link FormatMuxerSetMaxFileDuration}. This information is reported 464 * when only one second or 10% is left to reach the allowed duration. 465 */ 466 MUXER_INFO_MAX_FILESIZE_APPROACHING, /**< The captured file size is reaching the threshold specified by 467 * {@link FormatMuxerSetMaxFileSize}. This information is reported when 468 * only 100 KB or 10% is left to reach the allowed size. 469 */ 470 MUXER_INFO_MAX_DURATION_REACHED, /**< The capturing duration reached the threshold specified by 471 * {@link FormatMuxerSetMaxFileDuration}, and the capturing is ended. 472 * If the file is set by a file descriptor, the caller needs to close 473 * the file. 474 */ 475 MUXER_INFO_MAX_FILESIZE_REACHED, /**< The captured file size reached the threshold specified by 476 * {@link FormatMuxerSetMaxFileSize}, and the capturing is ended. 477 * If the file is set by a file descriptor, the caller needs to 478 * close the file. 479 */ 480 MUXER_INFO_NEXT_OUTPUT_FILE_STARTED, /**< The capturing started for the next output file. */ 481 MUXER_INFO_FILE_SPLIT_FINISHED, /**< Manual file split is completed. */ 482 MUXER_INFO_FILE_START_TIME_MS, /**< Start time of the captured file */ 483 MUXER_INFO_NEXT_FILE_FD_NOT_SET, /**< Next file fd is needed but not set */ 484 MUXER_INFO_NO_FRAME_DATA, /**< There is No frame data to send to recorder */ 485 486 DEMUXER_INFO_PREPARED = 10000, /**< The prepare function is asynchronously executed. This information 487 * is reported after the execution is complete. 488 */ 489 DEMUXER_INFO_SEEK_COMPLETE, /**< The seek function is asynchronously executed. This information is 490 * reported after the execution is complete. 491 */ 492 DEMUXER_INFO_NETWORK_DISCONNECTED, /**< The network is disconnected during network playback. */ 493 DEMUXER_INFO_NETWORK_RECONNECTED, /**< The network is automatically reconnected during network playback. */ 494 } FormatInfoType; 495 496 /** 497 * @brief Enumerates callback error types. 498 * 499 * @since 1.0 500 * @version 1.0 501 */ 502 typedef enum { 503 ERROR_CREATE_FILE_FAIL = 0, /** Create file failed */ 504 ERROR_WRITE_FILE_FAIL, /** Write file failed */ 505 ERROR_CLOSE_FILE_FAIL, /** Close file failed */ 506 ERROR_READ_DATA_ERROR, /** Read date failed */ 507 ERROR_INTERNAL_OPERATION_FAIL, /** Recoder internal operation failed, must stop recoder */ 508 ERROR_UNKNOWN /** Unknown error */ 509 } FormatErrorType; 510 511 /** 512 * @brief Enumerates muxer output types. 513 * 514 * @since 1.0 515 * @version 1.0 516 */ 517 typedef enum { 518 OUTPUT_TYPE_FD = 0, /**< File descriptor */ 519 OUTPUT_TYPE_URI, /**< Local file URI */ 520 OUTPUT_TYPE_INVALID /**< Undefined type */ 521 } OutputType; 522 523 /** 524 * @brief Defines the muxer output configuration. 525 * 526 * @since 1.0 527 * @version 1.0 528 */ 529 typedef struct { 530 OutputType type; /**< Output type. For details, see {@link OutputType}. */ 531 union { 532 int32_t fd; /**< File descriptor */ 533 char url[URL_LEN]; /**< File path. For details, see {@link URL_LEN}. */ 534 }; 535 OutputFormat format; /**< File format */ 536 } FormatOutputConfig; 537 538 /** 539 * @brief Enumerates manual split types for the muxer. 540 * 541 * @since 1.0 542 * @version 1.0 543 */ 544 typedef enum { 545 MANUAL_SPLIT_POST = 0, /**< Search forwards from the current I-frame and split the file at the closest I-frame. */ 546 MANUAL_SPLIT_PRE, /**< Search backwards from the current I-frame and split the file at the closest I-frame. */ 547 MANUAL_SPLIT_NORMAL /**< Normal split */ 548 } ManualSplitType; 549 550 /** 551 * @brief Enumerates types of the muxer source track. 552 * 553 * @since 1.0 554 * @version 1.0 555 */ 556 typedef enum { 557 TRACK_SOURCE_TYPE_VIDEO = 0, /**< Video track */ 558 TRACK_SOURCE_TYPE_AUDIO, /**< Audio track */ 559 TRACK_SOURCE_TYPE_DATA, /**< Data track */ 560 TRACK_SOURCE_TYPE_INVALID /**< Invalid type */ 561 } TrackSourceType; 562 563 /** 564 * @brief Defines information about the muxer video source. 565 * 566 * @since 1.0 567 * @version 1.0 568 */ 569 typedef struct { 570 CodecFormat codecType; /**< Video encoding type, for details, see {@link CodecFormat}. */ 571 uint32_t width; /**< Video width */ 572 uint32_t height; /**< Video height */ 573 uint32_t bitRate; /**< Encoding bit rate, in bit/s */ 574 uint32_t frameRate; /**< Encoding frame rate */ 575 float speed; /**< Video speed */ 576 uint32_t keyFrameInterval; /**< Keyframe interval */ 577 } VideoTrackSourceInfo; 578 579 /** 580 * @brief Defines information about the muxer audio source. 581 * 582 * @since 1.0 583 * @version 1.0 584 */ 585 typedef struct { 586 CodecFormat codecType; /**< Audio encoding type, for details, see {@link CodecFormat}. */ 587 uint32_t sampleRate; /**< Sampling rate */ 588 uint32_t channelCount; /**< Number of audio channels */ 589 FormatAudioSampleFmt sampleBitWidth; /**< Bit width */ 590 uint32_t samplesPerFrame; /**< Number of samples per frame */ 591 uint32_t avgBytesPerSec; /**< Average bit rate, in byte/s */ 592 } AudioTrackSourceInfo; 593 594 /** 595 * @brief Defines information about the muxer data source. 596 * 597 * @since 1.0 598 * @version 1.0 599 */ 600 typedef struct { 601 uint32_t frameRate; /**< Frame rate */ 602 uint32_t bitRate; /**< Bit rate */ 603 } DataTrackSourceInfo; 604 605 /** 606 * @brief Defines information about the muxer source. 607 * 608 * @since 1.0 609 * @version 1.0 610 */ 611 typedef struct { 612 TrackSourceType trackSourceType; /**< Stream source type. For details, see {@link TrackSourceType} */ 613 /** 614 * @brief Defines detailed information about different types of stream sources. 615 */ 616 union { 617 VideoTrackSourceInfo videoInfo; /**< Video stream. For details, see {@link VideoTrackSourceInfo}. */ 618 AudioTrackSourceInfo audioInfo; /**< Audio stream. For details, see {@link AudioTrackSourceInfo}. */ 619 DataTrackSourceInfo dataInfo; /**< Data stream. For details, see {@link DataTrackSourceInfo} */ 620 } trackSourceInfo; 621 } TrackSource; 622 623 /** 624 * @brief Indicates the pointer to the callback handle for listening the muxer. 625 * 626 * @since 1.0 627 * @version 1.0 628 */ 629 typedef void *CallbackHandle; 630 631 /** 632 * @brief Defines listener callbacks for the format. 633 */ 634 typedef struct { 635 /** Private data handle */ 636 CallbackHandle privateDataHandle; 637 638 /** 639 * @brief Called when a format error occurs during capturing. This callback is used to report the errors. 640 * 641 * @param privateDataHandle Indicates the private data handle. 642 * @param errorType Indicates the error type. For details, see {@link FormatErrorType}. 643 * @param errorCode Indicates the error code. 644 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 645 * @since 1.0 646 * @version 1.0 647 */ 648 int32_t (*OnError)(CallbackHandle privateDataHandle, int32_t errorType, int32_t errorCode); 649 650 /** 651 * @brief Called when an information event occurs during capturing. 652 * This callback is used to report capturing information. 653 * 654 * @param privateDataHandle Indicates the private data handle. 655 * @param type Indicates the information type. For details, see {@link FormatInfoType}. 656 * @param extra Indicates other information, for example, the start time position of the captured file. 657 * @return Returns <b>0</b> if the operation is successful; returns a non-zero value otherwise. 658 * @since 1.0 659 * @version 1.0 660 */ 661 int32_t (*OnInfo)(CallbackHandle privateDataHandle, int32_t type, int32_t extra); 662 } FormatCallback; 663 664 #ifdef __cplusplus 665 #if __cplusplus 666 } 667 #endif 668 #endif /* __cplusplus */ 669 670 #endif // FORMAT_TYPE_H 671 /** @} */