mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-23 04:55:04 +00:00
Extract audio recorder interface
In order to support both encoded and raw audio stream, extract a interface (very minimal, but sufficient to just start and stop). PR #3757 <https://github.com/Genymobile/scrcpy/pull/3757>
This commit is contained in:
parent
f065fee916
commit
b08684709a
3 changed files with 20 additions and 8 deletions
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
||||
public final class AudioEncoder {
|
||||
public final class AudioEncoder implements AudioRecorder {
|
||||
|
||||
private static class InputTask {
|
||||
private final int index;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package com.genymobile.scrcpy;
|
||||
|
||||
/**
|
||||
* A component able to record audio asynchronously
|
||||
*
|
||||
* The implementation is responsible to send packets.
|
||||
*/
|
||||
public interface AudioRecorder {
|
||||
void start();
|
||||
void stop();
|
||||
void join() throws InterruptedException;
|
||||
}
|
|
@ -92,7 +92,7 @@ public final class Server {
|
|||
}
|
||||
|
||||
Controller controller = null;
|
||||
AudioEncoder audioEncoder = null;
|
||||
AudioRecorder audioRecorder = null;
|
||||
|
||||
try (DesktopConnection connection = DesktopConnection.open(scid, tunnelForward, audio, control, sendDummyByte)) {
|
||||
if (options.getSendDeviceMeta()) {
|
||||
|
@ -111,8 +111,8 @@ public final class Server {
|
|||
if (audio) {
|
||||
Streamer audioStreamer = new Streamer(connection.getAudioFd(), options.getAudioCodec(), options.getSendCodecId(),
|
||||
options.getSendFrameMeta());
|
||||
audioEncoder = new AudioEncoder(audioStreamer, options.getAudioBitRate(), options.getAudioCodecOptions(), options.getAudioEncoder());
|
||||
audioEncoder.start();
|
||||
audioRecorder = new AudioEncoder(audioStreamer, options.getAudioBitRate(), options.getAudioCodecOptions(), options.getAudioEncoder());
|
||||
audioRecorder.start();
|
||||
}
|
||||
|
||||
Streamer videoStreamer = new Streamer(connection.getVideoFd(), options.getVideoCodec(), options.getSendCodecId(),
|
||||
|
@ -131,8 +131,8 @@ public final class Server {
|
|||
} finally {
|
||||
Ln.d("Screen streaming stopped");
|
||||
initThread.interrupt();
|
||||
if (audioEncoder != null) {
|
||||
audioEncoder.stop();
|
||||
if (audioRecorder != null) {
|
||||
audioRecorder.stop();
|
||||
}
|
||||
if (controller != null) {
|
||||
controller.stop();
|
||||
|
@ -140,8 +140,8 @@ public final class Server {
|
|||
|
||||
try {
|
||||
initThread.join();
|
||||
if (audioEncoder != null) {
|
||||
audioEncoder.join();
|
||||
if (audioRecorder != null) {
|
||||
audioRecorder.join();
|
||||
}
|
||||
if (controller != null) {
|
||||
controller.join();
|
||||
|
|
Loading…
Add table
Reference in a new issue