ZLMediaKit/src/Codec/H264Encoder.h

49 lines
1.1 KiB
C++
Raw Normal View History

2017-10-09 22:11:01 +08:00
/*
2020-04-04 20:30:09 +08:00
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
2017-09-27 16:20:30 +08:00
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
*
2020-04-04 20:30:09 +08:00
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
2017-04-01 16:35:56 +08:00
*/
2017-09-27 16:20:30 +08:00
2017-04-01 16:35:56 +08:00
#ifndef CODEC_H264ENCODER_H_
#define CODEC_H264ENCODER_H_
2017-04-25 11:35:41 +08:00
2017-04-01 16:35:56 +08:00
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#include <x264.h>
#ifdef __cplusplus
}
#endif //__cplusplus
2018-10-24 17:17:55 +08:00
namespace mediakit {
2017-04-01 16:35:56 +08:00
class H264Encoder {
public:
2020-03-20 11:51:24 +08:00
typedef struct {
int iType;
int iLength;
uint8_t *pucData;
} H264Frame;
2017-04-01 16:35:56 +08:00
2020-03-20 11:51:24 +08:00
H264Encoder(void);
virtual ~H264Encoder(void);
bool init(int iWidth, int iHeight, int iFps);
int inputData(char *apcYuv[3], int aiYuvLen[3], int64_t i64Pts, H264Frame **ppFrame);
2017-04-01 16:35:56 +08:00
private:
2020-03-20 11:51:24 +08:00
x264_t* _pX264Handle = nullptr;
x264_picture_t* _pPicIn = nullptr;
x264_picture_t* _pPicOut = nullptr;
H264Frame _aFrames[10];
2017-04-01 16:35:56 +08:00
};
2018-10-24 17:17:55 +08:00
} /* namespace mediakit */
2017-04-01 16:35:56 +08:00
#endif /* CODEC_H264ENCODER_H_ */