123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #ifndef VIDEO_CODECS_VIDEO_ENCODER_H_
- #define VIDEO_CODECS_VIDEO_ENCODER_H_
- #include "precompile.h"
- #ifdef __cplusplus
- #ifdef _STDINT_H
- #undef _STDINT_H
- #endif
- #include "stdint.h"
- #ifndef INT64_C
- #define INT64_C(c) (c ## LL)
- #define UINT64_C(c) (c ## ULL)
- #endif
- extern "C" {
- #endif
- #include "../video_common/ffmpeg_api_adapter.h"
- #include "x264.h"
- #ifdef __cplusplus
- }
- #endif /* end of __cplusplus */
- #include "../videoutil.h"
- #include "video_encoder_defines.h"
- #define FAILED_VALUE -1
- #define SUCCESS_VALUE 0
- namespace video_coding {
- typedef struct _QpThresholds {
- int low;
- int high;
- }QpThresholds;
- typedef struct _EncoderInfo {
- // If this field is true, the encoder uses hardware support and different
- // thresholds will be used in CPU adaptation.
- bool is_hardware_accelerated;
- QpThresholds thresholds;
- }EncoderInfo;
- typedef struct _VideoEncoder VideoEncoder;
- VideoEncoder *video_encoder_new();
- void video_encoder_destroy(VideoEncoder *obj);
- // Initialize the encoder with the information from the codecSettings
- //
- // Input:
- // - codec_settings : Codec settings
- // - max_payload_size : The maximum size each payload is allowed
- // to have. Usually MTU - overhead.
- //
- // Return value : Set bit rate if OK
- // <0 - Errors
- int32_t video_encoder_init_encode(VideoEncoder *obj, const VideoEncoderConfig* codec_settings,
- size_t max_payload_size);
- // Free encoder memory.
- // Return value : 0 if OK, < 0 otherwise.
- int32_t video_encoder_release(VideoEncoder *obj);
- // Encode an I420 image (as a part of a video stream). The encoded image
- // will be returned to the user through the encode complete callback.
- //
- // Input:
- // - frame : Image to be encoded
- // - frame_types : Frame type to be generated by the encoder.
- //
- // Return value : 0 if OK
- // <0 - Errors
- EncodedImage *video_encoder_encode(VideoEncoder *obj, unsigned pt, const video_frame *frame, int key_frame);
- /*bitrate:目标带宽,单位:kbps */
- int32_t video_encoder_set_rates(VideoEncoder *obj, uint32_t bitrate, uint32_t framerate);
- // Returns meta-data about the encoder, such as implementation name.
- // The output of this method may change during runtime. For instance if a
- // hardware encoder fails, it may fall back to doing software encoding using
- // an implementation with different characteristics.
- int32_t video_encoder_get_encoder_info(VideoEncoder *obj, EncoderInfo *info);
- }
- #endif // API_VIDEO_CODECS_VIDEO_ENCODER_H_
|