|
|
|
@ -62,6 +62,10 @@ public class AndroidMuxer {
|
|
|
|
|
throw new IllegalStateException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mMuxer == null) {
|
|
|
|
|
throw new IllegalStateException("mMuxer is null");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
synchronized (mMuxer) {
|
|
|
|
|
int track = mMuxer.addTrack(trackFormat);
|
|
|
|
|
mVideoFormat = trackFormat;
|
|
|
|
@ -79,7 +83,7 @@ public class AndroidMuxer {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writeSampleData(int trackIndex, ByteBuffer encodedData, MediaCodec.BufferInfo bufferInfo) {
|
|
|
|
|
if (mNumReleases != 0) {
|
|
|
|
|
if (mNumReleases != 0 || mMuxer == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
synchronized (mMuxer) {
|
|
|
|
@ -101,20 +105,24 @@ public class AndroidMuxer {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean release() {
|
|
|
|
|
synchronized (mMuxer) {
|
|
|
|
|
if (++mNumReleases == mNumTracks) {
|
|
|
|
|
stopMuxer();
|
|
|
|
|
return true;
|
|
|
|
|
if (mMuxer != null) {
|
|
|
|
|
synchronized (mMuxer) {
|
|
|
|
|
if (++mNumReleases == mNumTracks) {
|
|
|
|
|
stopMuxer();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void stopMuxer() {
|
|
|
|
|
mMuxer.stop();
|
|
|
|
|
mMuxer.release();
|
|
|
|
|
if (mStartRecordTime > 0 && mStartRecordTime < System.currentTimeMillis() && !TextUtils.isEmpty(mCurrentPath)) {
|
|
|
|
|
insertToDB(mStartRecordTime, mCurrentPath);
|
|
|
|
|
if (mMuxer != null) {
|
|
|
|
|
mMuxer.stop();
|
|
|
|
|
mMuxer.release();
|
|
|
|
|
if (mStartRecordTime > 0 && mStartRecordTime < System.currentTimeMillis() && !TextUtils.isEmpty(mCurrentPath)) {
|
|
|
|
|
insertToDB(mStartRecordTime, mCurrentPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|