Skip to content
Snippets Groups Projects
Commit ad73ed43 authored by Leo Ma's avatar Leo Ma
Browse files

Fix record bug


It should not start recording when AV format not assigned.

Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 6cff148e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,7 +6,6 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application
Loading
Loading
Loading
Loading
@@ -116,8 +116,9 @@ public class MainActivity extends AppCompatActivity implements RtmpHandler.RtmpL
@Override
public void onClick(View v) {
if (btnRecord.getText().toString().contentEquals("record")) {
mPublisher.startRecord(recPath);
btnRecord.setText("pause");
if (mPublisher.startRecord(recPath)) {
btnRecord.setText("pause");
}
} else if (btnRecord.getText().toString().contentEquals("pause")) {
mPublisher.pauseRecord();
btnRecord.setText("resume");
Loading
Loading
Loading
Loading
@@ -112,7 +112,11 @@ public class SrsMp4Muxer {
/**
* start recording.
*/
public void record(File outputFile) {
public boolean record(File outputFile) {
if (videoFormat == null && audioFormat == null) {
return false;
}
mRecFile = outputFile;
createMovie(mRecFile);
mHandler.notifyRecordStarted(mRecFile.getPath());
Loading
Loading
@@ -145,6 +149,8 @@ public class SrsMp4Muxer {
}
});
worker.start();
return true;
}
/**
Loading
Loading
@@ -680,10 +686,12 @@ public class SrsMp4Muxer {
}
public void addTrack(MediaFormat format, boolean isAudio) {
if (isAudio) {
tracks.put(AUDIO_TRACK, new Track(tracks.size(), format, true));
} else {
tracks.put(VIDEO_TRACK, new Track(tracks.size(), format, false));
if (format != null) {
if (isAudio) {
tracks.put(AUDIO_TRACK, new Track(tracks.size(), format, true));
} else {
tracks.put(VIDEO_TRACK, new Track(tracks.size(), format, false));
}
}
}
Loading
Loading
Loading
Loading
@@ -121,10 +121,8 @@ public class SrsPublisher {
}
}
public void startRecord(String recPath) {
if (mMp4Muxer != null) {
mMp4Muxer.record(new File(recPath));
}
public boolean startRecord(String recPath) {
return mMp4Muxer != null && mMp4Muxer.record(new File(recPath));
}
public void stopRecord() {
Loading
Loading
@@ -265,15 +263,6 @@ public class SrsPublisher {
}
}
public void switchMute() {
AudioManager audioManager = (AudioManager) mCameraView.getContext().getSystemService(Context.AUDIO_SERVICE);
int oldMode = audioManager.getMode();
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
boolean isMute = !audioManager.isMicrophoneMute();
audioManager.setMicrophoneMute(isMute);
audioManager.setMode(oldMode);
}
public void setRtmpHandler(RtmpHandler handler) {
mFlvMuxer = new SrsFlvMuxer(handler);
if (mEncoder != null) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment