FfmpegHelper* FfmpegHelper::singleton = NULL;
bool FfmpegHelper::isInit = false;
+bool FfmpegHelper::isEncoderReady = false;
FfmpegHelper::FfmpegHelper(JavaVM *vm, jclass cls)
FLOGE("avformat_network_init, error:%s(%d)", av_err2str(ret), ret);
}
isInit = true;
+ isEncoderReady = false;
}
int FfmpegHelper::initEncoder(int width, int height, const char* outpath)
}
startTime = av_gettime();
frameCnt = 0;
+ isEncoderReady = true;
return 0;
}
int FfmpegHelper::processFrame(uint8_t* data)
{
+ if(!isEncoderReady){
+ FLOGE("processFrame - isEncoderReady is false.");
+ return -1;
+ }
int ret = 0;
int y_length = pWidth * pHeight;
pFrameYUV = av_frame_alloc();
int FfmpegHelper::close()
{
- if(vStream)
+ if(vStream){
avcodec_close(vStream->codec);
+ vStream = NULL;
+ }
+
if (formatCtx){
avio_close(formatCtx->pb);
avformat_free_context(formatCtx);
+ formatCtx = NULL;
}
FLOGE("<----------- FfmpegHelper::close ");
+ isEncoderReady = false;
return 0;
}