Move log message helpers to LogUtils
This class will also contain other log helpers.
This commit is contained in:
parent
50d56a9a2b
commit
2596ca02f0
5 changed files with 42 additions and 32 deletions
|
@ -338,7 +338,7 @@ public final class AudioEncoder {
|
||||||
try {
|
try {
|
||||||
return MediaCodec.createByCodecName(encoderName);
|
return MediaCodec.createByCodecName(encoderName);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Ln.e("Encoder '" + encoderName + "' for " + codec.getName() + " not found\n" + CodecUtils.buildAudioEncoderListMessage());
|
Ln.e("Encoder '" + encoderName + "' for " + codec.getName() + " not found\n" + LogUtils.buildAudioEncoderListMessage());
|
||||||
throw new ConfigurationException("Unknown encoder: " + encoderName);
|
throw new ConfigurationException("Unknown encoder: " + encoderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,34 +44,6 @@ public final class CodecUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildVideoEncoderListMessage() {
|
|
||||||
StringBuilder builder = new StringBuilder("List of video encoders:");
|
|
||||||
List<CodecUtils.DeviceEncoder> videoEncoders = CodecUtils.listVideoEncoders();
|
|
||||||
if (videoEncoders.isEmpty()) {
|
|
||||||
builder.append("\n (none)");
|
|
||||||
} else {
|
|
||||||
for (CodecUtils.DeviceEncoder encoder : videoEncoders) {
|
|
||||||
builder.append("\n --video-codec=").append(encoder.getCodec().getName());
|
|
||||||
builder.append(" --video-encoder='").append(encoder.getInfo().getName()).append("'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String buildAudioEncoderListMessage() {
|
|
||||||
StringBuilder builder = new StringBuilder("List of audio encoders:");
|
|
||||||
List<CodecUtils.DeviceEncoder> audioEncoders = CodecUtils.listAudioEncoders();
|
|
||||||
if (audioEncoders.isEmpty()) {
|
|
||||||
builder.append("\n (none)");
|
|
||||||
} else {
|
|
||||||
for (CodecUtils.DeviceEncoder encoder : audioEncoders) {
|
|
||||||
builder.append("\n --audio-codec=").append(encoder.getCodec().getName());
|
|
||||||
builder.append(" --audio-encoder='").append(encoder.getInfo().getName()).append("'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MediaCodecInfo[] getEncoders(MediaCodecList codecs, String mimeType) {
|
private static MediaCodecInfo[] getEncoders(MediaCodecList codecs, String mimeType) {
|
||||||
List<MediaCodecInfo> result = new ArrayList<>();
|
List<MediaCodecInfo> result = new ArrayList<>();
|
||||||
for (MediaCodecInfo codecInfo : codecs.getCodecInfos()) {
|
for (MediaCodecInfo codecInfo : codecs.getCodecInfos()) {
|
||||||
|
|
38
server/src/main/java/com/genymobile/scrcpy/LogUtils.java
Normal file
38
server/src/main/java/com/genymobile/scrcpy/LogUtils.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public final class LogUtils {
|
||||||
|
|
||||||
|
private LogUtils() {
|
||||||
|
// not instantiable
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildVideoEncoderListMessage() {
|
||||||
|
StringBuilder builder = new StringBuilder("List of video encoders:");
|
||||||
|
List<CodecUtils.DeviceEncoder> videoEncoders = CodecUtils.listVideoEncoders();
|
||||||
|
if (videoEncoders.isEmpty()) {
|
||||||
|
builder.append("\n (none)");
|
||||||
|
} else {
|
||||||
|
for (CodecUtils.DeviceEncoder encoder : videoEncoders) {
|
||||||
|
builder.append("\n --video-codec=").append(encoder.getCodec().getName());
|
||||||
|
builder.append(" --video-encoder='").append(encoder.getInfo().getName()).append("'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildAudioEncoderListMessage() {
|
||||||
|
StringBuilder builder = new StringBuilder("List of audio encoders:");
|
||||||
|
List<CodecUtils.DeviceEncoder> audioEncoders = CodecUtils.listAudioEncoders();
|
||||||
|
if (audioEncoders.isEmpty()) {
|
||||||
|
builder.append("\n (none)");
|
||||||
|
} else {
|
||||||
|
for (CodecUtils.DeviceEncoder encoder : audioEncoders) {
|
||||||
|
builder.append("\n --audio-codec=").append(encoder.getCodec().getName());
|
||||||
|
builder.append(" --audio-encoder='").append(encoder.getInfo().getName()).append("'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -202,7 +202,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
try {
|
try {
|
||||||
return MediaCodec.createByCodecName(encoderName);
|
return MediaCodec.createByCodecName(encoderName);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Ln.e("Encoder '" + encoderName + "' for " + codec.getName() + " not found\n" + CodecUtils.buildVideoEncoderListMessage());
|
Ln.e("Encoder '" + encoderName + "' for " + codec.getName() + " not found\n" + LogUtils.buildVideoEncoderListMessage());
|
||||||
throw new ConfigurationException("Unknown encoder: " + encoderName);
|
throw new ConfigurationException("Unknown encoder: " + encoderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,8 +359,8 @@ public final class Server {
|
||||||
CleanUp.unlinkSelf();
|
CleanUp.unlinkSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ln.i(CodecUtils.buildVideoEncoderListMessage());
|
Ln.i(LogUtils.buildVideoEncoderListMessage());
|
||||||
Ln.i(CodecUtils.buildAudioEncoderListMessage());
|
Ln.i(LogUtils.buildAudioEncoderListMessage());
|
||||||
// Just print the available encoders, do not mirror
|
// Just print the available encoders, do not mirror
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue