#ifndef MEDIARECODER_H
#define MEDIARECODER_H

#include "FFmpegFunc.h"
#include <string>
#include <iostream>

class CMediaRecoder
{
public:
    CMediaRecoder();
    ~CMediaRecoder();

    bool IsRecoding();
    bool StartRecode(uint nFrameRate,uint nWidth,uint nHeight,const std::string &strFileName);
    bool RecoderPacket(AVPacket *pPacket,bool bKeyFrame);
    bool FinishRecode();

private:
    void Init();
    void UnInit();
    bool StartRecodeAndWriteHeader();
    int OpenOutPutAndAddStreams(AVFormatContext **pFmt, const char *strOutFileName, AVOutputStream **pVideoOutput);

    uint m_nFrameRate;
    uint m_nWidth;
    uint m_nHeight;
    std::string m_strFileName;

    AVFormatContext *pOutFmtCtx;
    AVOutputStream *pOutputVideoStream;
    int nVideoNextPts;
    bool m_bIsRecording;
};

#endif // MEDIARECODER_H
