projects
/
rtmpclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'dev' v0.3.0
[rtmpclient.git]
/
app
/
src
/
main
/
jni
/
FfmpegHelper.cpp
diff --git
a/app/src/main/jni/FfmpegHelper.cpp
b/app/src/main/jni/FfmpegHelper.cpp
index
1df52e5
..
71d7064
100644
(file)
--- a/
app/src/main/jni/FfmpegHelper.cpp
+++ b/
app/src/main/jni/FfmpegHelper.cpp
@@
-7,6
+7,7
@@
FfmpegHelper* FfmpegHelper::singleton = NULL;
bool FfmpegHelper::isInit = false;
FfmpegHelper* FfmpegHelper::singleton = NULL;
bool FfmpegHelper::isInit = false;
+bool FfmpegHelper::isEncoderReady = false;
FfmpegHelper::FfmpegHelper(JavaVM *vm, jclass cls)
FfmpegHelper::FfmpegHelper(JavaVM *vm, jclass cls)
@@
-79,6
+80,7
@@
void FfmpegHelper::init()
FLOGE("avformat_network_init, error:%s(%d)", av_err2str(ret), ret);
}
isInit = true;
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)
}
int FfmpegHelper::initEncoder(int width, int height, const char* outpath)
@@
-146,12
+148,17
@@
int FfmpegHelper::initEncoder(int width, int height, const char* outpath)
}
startTime = av_gettime();
frameCnt = 0;
}
startTime = av_gettime();
frameCnt = 0;
+ isEncoderReady = true;
return 0;
}
int FfmpegHelper::processFrame(uint8_t* data)
{
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 ret = 0;
int y_length = pWidth * pHeight;
pFrameYUV = av_frame_alloc();
@@
-229,13
+236,18
@@
int FfmpegHelper::processFrame(uint8_t* data)
int FfmpegHelper::close()
{
int FfmpegHelper::close()
{
- if(vStream)
+ if(vStream)
{
avcodec_close(vStream->codec);
avcodec_close(vStream->codec);
+ vStream = NULL;
+ }
+
if (formatCtx){
avio_close(formatCtx->pb);
avformat_free_context(formatCtx);
if (formatCtx){
avio_close(formatCtx->pb);
avformat_free_context(formatCtx);
+ formatCtx = NULL;
}
FLOGE("<----------- FfmpegHelper::close ");
}
FLOGE("<----------- FfmpegHelper::close ");
+ isEncoderReady = false;
return 0;
}
return 0;
}