123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- // FFmpegWriter.h: interface for the FFmpegWriter class.
- #pragma once
- #ifdef _WIN32
- #ifndef INT64_C
- #define INT64_C(c) (c##LL)
- #define UINT64_C(c) (c##UL)
- #endif
- #endif
- #ifdef __cplusplus
- extern "C"
- {
- #define __STDC_CONSTANT_MACROS
- #endif // __cplusplus
- #include <libavutil/avassert.h>
- #include <libavutil/channel_layout.h>
- #include <libavutil/opt.h>
- #include <libavutil/mathematics.h>
- #include <libavutil/timestamp.h>
- #include <libavformat/avformat.h>
- #include <libswscale/swscale.h>
- #include <libswresample/swresample.h>
- #include <libavutil/pixdesc.h>
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- #include "ByteBuffer.h"
- typedef struct OutputStream_t OutputStream;
- class LogApi
- {
- public:
- virtual void Debug(const char* fmt, ...) = 0;
- virtual void vDebug(const char* str, va_list list) = 0;
- };
- class FFmpegWriter
- {
- public:
- FFmpegWriter(LogApi* pLogAPI) {m_pLogApi = pLogAPI; m_video_st = NULL; m_audio_st = NULL; m_outfmt = NULL; m_formatctx = NULL;
- m_audio_codec = NULL; m_video_codec = NULL; m_bhave_video = false; m_bhave_audio = false; m_audio_input_buffer = NULL; m_bstart = false;}
- ~FFmpegWriter() {}
- private://内部成员变量
- OutputStream *m_video_st;
- OutputStream *m_audio_st;
- AVOutputFormat* m_outfmt;
- AVFormatContext* m_formatctx;
- AVCodec* m_audio_codec;
- AVCodec* m_video_codec;
- int m_bhave_video;
- int m_bhave_audio;
- AVPixelFormat m_input_pix_fmt;
- LogApi* m_pLogApi;
- ByteBuffer* m_audio_input_buffer;
- void Close();
- bool m_bstart;
- public:
- bool InitWriter(char* filename, int width, int height, int colorbit, int nfps,
- int nSamplePsec, int nchannels, int nBitPerSample, int nmaxspacing, int nquality, int nOutBitRate, int iAudioType);
- bool StartWrite();
- bool StopWrite();
- bool ReceiveAudioData(unsigned char* pData, unsigned long ulen);
- bool ReceiveVideoData(unsigned char* pData, unsigned long ulen);
- };
|