Compare commits

...

5 Commits
pr4841 ... rtmp

Author SHA1 Message Date
Romain Vimont
84be93ce3f rtmp-wip
Run: scrcpy -ra.mp4 --audio-codec=aac

(the filename is ignored, but the command line parser must be happy, and
opus is not supported by flv)
2024-04-26 10:03:19 +02:00
Romain Vimont
22d78e8a82 Fix boolean condition
Use the short-circuit operator && between booleans.
2024-04-19 12:49:03 +02:00
Romain Vimont
bcb8503b26 Handle reported camera sizes array is null
The array of sizes may be null. Handle this case gracefully.

Fixes #4852 <https://github.com/Genymobile/scrcpy/issues/4852>
2024-04-17 10:45:18 +02:00
Romain Vimont
9aa6cc71be Forbid --no-control in OTG mode
The whole purpose of OTG is to only control the device.
2024-04-16 15:50:44 +02:00
Romain Vimont
54e08b4eae Fix code style
Limit to 80 columns.
2024-04-16 15:50:41 +02:00
5 changed files with 29 additions and 11 deletions

View File

@@ -2556,9 +2556,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
if (opts->audio_playback && opts->audio_buffer == -1) {
if (opts->audio_codec == SC_CODEC_FLAC) {
// Use 50 ms audio buffer by default, but use a higher value for FLAC,
// which is not low latency (the default encoder produces blocks of
// 4096 samples, which represent ~85.333ms).
// Use 50 ms audio buffer by default, but use a higher value for
// FLAC, which is not low latency (the default encoder produces
// blocks of 4096 samples, which represent ~85.333ms).
LOGI("FLAC audio: audio buffer increased to 120 ms (use "
"--audio-buffer to set a custom value)");
opts->audio_buffer = SC_TICK_FROM_MS(120);
@@ -2598,6 +2598,11 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
}
if (otg) {
if (!opts->control) {
LOGE("--no-control is not allowed in OTG mode");
return false;
}
enum sc_keyboard_input_mode kmode = opts->keyboard_input_mode;
if (kmode != SC_KEYBOARD_INPUT_MODE_AOA
&& kmode != SC_KEYBOARD_INPUT_MODE_DISABLED) {

View File

@@ -468,7 +468,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
return;
case SDLK_DOWN:
if (shift) {
if (!repeat & down) {
if (!repeat && down) {
apply_orientation_transform(im,
SC_ORIENTATION_FLIP_180);
}
@@ -479,7 +479,7 @@ sc_input_manager_process_key(struct sc_input_manager *im,
return;
case SDLK_UP:
if (shift) {
if (!repeat & down) {
if (!repeat && down) {
apply_orientation_transform(im,
SC_ORIENTATION_FLIP_180);
}

View File

@@ -9,6 +9,8 @@
#include "util/log.h"
#include "util/str.h"
#define RTMP_URL "rtmp://localhost/live/stream"
/** Downcast packet sinks to recorder */
#define DOWNCAST_VIDEO(SINK) \
container_of(SINK, struct sc_recorder, video_packet_sink)
@@ -131,7 +133,7 @@ static bool
sc_recorder_open_output_file(struct sc_recorder *recorder) {
const char *format_name = sc_recorder_get_format_name(recorder->format);
assert(format_name);
const AVOutputFormat *format = find_muxer(format_name);
const AVOutputFormat *format = find_muxer("flv");
if (!format) {
LOGE("Could not find muxer");
return false;
@@ -143,8 +145,11 @@ sc_recorder_open_output_file(struct sc_recorder *recorder) {
return false;
}
int ret = avio_open(&recorder->ctx->pb, recorder->filename,
AVIO_FLAG_WRITE);
AVDictionary *options = NULL;
av_dict_set(&options, "listen", "1", 0); // Enable listening
int ret = avio_open2(&recorder->ctx->pb, RTMP_URL,
AVIO_FLAG_WRITE, NULL, &options);
if (ret < 0) {
LOGE("Failed to open output file: %s", recorder->filename);
avformat_free_context(recorder->ctx);

View File

@@ -127,6 +127,10 @@ public class CameraCapture extends SurfaceCapture {
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
android.util.Size[] sizes = highSpeed ? configs.getHighSpeedVideoSizes() : configs.getOutputSizes(MediaCodec.class);
if (sizes == null) {
return null;
}
Stream<android.util.Size> stream = Arrays.stream(sizes);
if (maxSize > 0) {
stream = stream.filter(it -> it.getWidth() <= maxSize && it.getHeight() <= maxSize);

View File

@@ -118,12 +118,16 @@ public final class LogUtils {
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
for (android.util.Size size : sizes) {
builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
if (sizes == null || sizes.length == 0) {
builder.append("\n (none)");
} else {
for (android.util.Size size : sizes) {
builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
}
}
android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes();
if (highSpeedSizes.length > 0) {
if (highSpeedSizes != null && highSpeedSizes.length > 0) {
builder.append("\n High speed capture (--camera-high-speed):");
for (android.util.Size size : highSpeedSizes) {
Range<Integer>[] highFpsRanges = configs.getHighSpeedVideoFpsRanges();