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

Add audio mute feature


Signed-off-by: default avatarLeo Ma <begeekmyfriend@gmail.com>
parent 4747db9f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -73,6 +73,7 @@ public class MainActivity extends Activity implements RtmpHandler.RtmpListener,
mPublisher.setPreviewResolution(1280, 720);
mPublisher.setOutputResolution(384, 640);
mPublisher.setVideoSmoothMode();
mPublisher.startCamera();
 
btnPublish.setOnClickListener(new View.OnClickListener() {
@Override
Loading
Loading
Loading
Loading
@@ -17,11 +17,13 @@ public class SrsPublisher {
private static AcousticEchoCanceler aec;
private static AutomaticGainControl agc;
private byte[] mPcmBuffer = new byte[4096];
private byte[] mMuteBuffer = new byte[11];
private Thread aworker;
private SrsCameraView mCameraView;
private boolean sendAudioOnly = false;
private boolean sendVideoOnly = false;
private int videoFrameCount;
private long lastTimeMillis;
private double mSamplingFps;
Loading
Loading
@@ -91,11 +93,14 @@ public class SrsPublisher {
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);
mic.startRecording();
while (!Thread.interrupted()) {
int size = mic.read(mPcmBuffer, 0, mPcmBuffer.length);
if (size <= 0) {
break;
if (sendVideoOnly) {
mEncoder.onGetPcmFrame(mMuteBuffer, mMuteBuffer.length);
} else {
int size = mic.read(mPcmBuffer, 0, mPcmBuffer.length);
if (size > 0) {
mEncoder.onGetPcmFrame(mPcmBuffer, size);
}
}
mEncoder.onGetPcmFrame(mPcmBuffer, size);
}
}
});
Loading
Loading
@@ -240,6 +245,10 @@ public class SrsPublisher {
mEncoder.setVideoSmoothMode();
}
public synchronized void setSendVideoOnly(boolean flag) {
sendVideoOnly = flag;
}
public void setSendAudioOnly(boolean flag) {
sendAudioOnly = flag;
}
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