H264Encoder.h 1.13 KB
Newer Older
xiongziliang committed
1
/*
xiongziliang committed
2
 * Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
xiongziliang committed
3
 *
4
 * This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
xiongziliang committed
5
 *
xiongziliang committed
6 7 8
 * 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.
xzl committed
9 10
 */

xiongziliang committed
11

xzl committed
12 13
#ifndef CODEC_H264ENCODER_H_
#define CODEC_H264ENCODER_H_
xiongzilaing committed
14

xzl committed
15 16 17 18 19 20 21 22 23 24
#include <cstdint>

#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#include <x264.h>
#ifdef __cplusplus
}
#endif //__cplusplus

xiongziliang committed
25
namespace mediakit {
xzl committed
26 27 28

class H264Encoder {
public:
29 30 31 32 33
    typedef struct {
        int iType;
        int iLength;
        uint8_t *pucData;
    } H264Frame;
xzl committed
34

35 36 37 38
    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);
xzl committed
39
private:
40 41 42 43
    x264_t* _pX264Handle = nullptr;
    x264_picture_t* _pPicIn = nullptr;
    x264_picture_t* _pPicOut = nullptr;
    H264Frame _aFrames[10];
xzl committed
44 45
};

xiongziliang committed
46
} /* namespace mediakit */
xzl committed
47 48

#endif /* CODEC_H264ENCODER_H_ */