Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d75422d21 |
+3
-43
@@ -33,11 +33,6 @@ record_packet_new(const AVPacket *packet) {
|
|||||||
if (!rec) {
|
if (!rec) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// av_packet_ref() does not initialize all fields in old FFmpeg versions
|
|
||||||
// See <https://github.com/Genymobile/scrcpy/issues/707>
|
|
||||||
av_init_packet(&rec->packet);
|
|
||||||
|
|
||||||
if (av_packet_ref(&rec->packet, packet)) {
|
if (av_packet_ref(&rec->packet, packet)) {
|
||||||
SDL_free(rec);
|
SDL_free(rec);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -92,7 +87,6 @@ recorder_init(struct recorder *recorder,
|
|||||||
recorder->format = format;
|
recorder->format = format;
|
||||||
recorder->declared_frame_size = declared_frame_size;
|
recorder->declared_frame_size = declared_frame_size;
|
||||||
recorder->header_written = false;
|
recorder->header_written = false;
|
||||||
recorder->previous = NULL;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -225,22 +219,13 @@ recorder_rescale_packet(struct recorder *recorder, AVPacket *packet) {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
recorder_write(struct recorder *recorder, AVPacket *packet) {
|
recorder_write(struct recorder *recorder, AVPacket *packet) {
|
||||||
|
SDL_assert(packet->pts != AV_NOPTS_VALUE);
|
||||||
if (!recorder->header_written) {
|
if (!recorder->header_written) {
|
||||||
if (packet->pts != AV_NOPTS_VALUE) {
|
|
||||||
LOGE("The first packet is not a config packet");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool ok = recorder_write_header(recorder, packet);
|
bool ok = recorder_write_header(recorder, packet);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
recorder->header_written = true;
|
recorder->header_written = true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet->pts == AV_NOPTS_VALUE) {
|
|
||||||
// ignore config packets
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recorder_rescale_packet(recorder, packet);
|
recorder_rescale_packet(recorder, packet);
|
||||||
@@ -263,19 +248,6 @@ run_recorder(void *data) {
|
|||||||
|
|
||||||
if (recorder->stopped && queue_is_empty(&recorder->queue)) {
|
if (recorder->stopped && queue_is_empty(&recorder->queue)) {
|
||||||
mutex_unlock(recorder->mutex);
|
mutex_unlock(recorder->mutex);
|
||||||
struct record_packet *last = recorder->previous;
|
|
||||||
if (last) {
|
|
||||||
// assign an arbitrary duration to the last packet
|
|
||||||
last->packet.duration = 100000;
|
|
||||||
bool ok = recorder_write(recorder, &last->packet);
|
|
||||||
if (!ok) {
|
|
||||||
// failing to write the last frame is not very serious, no
|
|
||||||
// future frame may depend on it, so the resulting file
|
|
||||||
// will still be valid
|
|
||||||
LOGW("Could not record last packet");
|
|
||||||
}
|
|
||||||
record_packet_delete(last);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,20 +256,8 @@ run_recorder(void *data) {
|
|||||||
|
|
||||||
mutex_unlock(recorder->mutex);
|
mutex_unlock(recorder->mutex);
|
||||||
|
|
||||||
// recorder->previous is only written from this thread, no need to lock
|
bool ok = recorder_write(recorder, &rec->packet);
|
||||||
struct record_packet *previous = recorder->previous;
|
record_packet_delete(rec);
|
||||||
recorder->previous = rec;
|
|
||||||
|
|
||||||
if (!previous) {
|
|
||||||
// we just received the first packet
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we now know the duration of the previous packet
|
|
||||||
previous->packet.duration = rec->packet.pts - previous->packet.pts;
|
|
||||||
|
|
||||||
bool ok = recorder_write(recorder, &previous->packet);
|
|
||||||
record_packet_delete(previous);
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not record packet");
|
LOGE("Could not record packet");
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ struct recorder {
|
|||||||
bool stopped; // set on recorder_stop() by the stream reader
|
bool stopped; // set on recorder_stop() by the stream reader
|
||||||
bool failed; // set on packet write failure
|
bool failed; // set on packet write failure
|
||||||
struct recorder_queue queue;
|
struct recorder_queue queue;
|
||||||
|
|
||||||
// we can write a packet only once we received the next one so that we can
|
|
||||||
// set its duration (next_pts - current_pts)
|
|
||||||
// "previous" is only accessed from the recorder thread, so it does not
|
|
||||||
// need to be protected by the mutex
|
|
||||||
struct record_packet *previous;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
+1
-16
@@ -69,15 +69,6 @@ notify_stopped(void) {
|
|||||||
SDL_PushEvent(&stop_event);
|
SDL_PushEvent(&stop_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
process_config_packet(struct stream *stream, AVPacket *packet) {
|
|
||||||
if (stream->recorder && !recorder_push(stream->recorder, packet)) {
|
|
||||||
LOGE("Could not send config packet to recorder");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
process_frame(struct stream *stream, AVPacket *packet) {
|
process_frame(struct stream *stream, AVPacket *packet) {
|
||||||
if (stream->decoder && !decoder_push(stream->decoder, packet)) {
|
if (stream->decoder && !decoder_push(stream->decoder, packet)) {
|
||||||
@@ -157,13 +148,7 @@ stream_push_packet(struct stream *stream, AVPacket *packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_config) {
|
if (!is_config) {
|
||||||
// config packet
|
|
||||||
bool ok = process_config_packet(stream, packet);
|
|
||||||
if (!ok) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// data packet
|
// data packet
|
||||||
bool ok = stream_parse(stream, packet);
|
bool ok = stream_parse(stream, packet);
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ if prebuilt_server == ''
|
|||||||
build_always: true, # gradle is responsible for tracking source changes
|
build_always: true, # gradle is responsible for tracking source changes
|
||||||
output: 'scrcpy-server.jar',
|
output: 'scrcpy-server.jar',
|
||||||
command: [find_program('./scripts/build-wrapper.sh'), meson.current_source_dir(), '@OUTPUT@', get_option('buildtype')],
|
command: [find_program('./scripts/build-wrapper.sh'), meson.current_source_dir(), '@OUTPUT@', get_option('buildtype')],
|
||||||
console: true,
|
|
||||||
install: true,
|
install: true,
|
||||||
install_dir: 'share/scrcpy')
|
install_dir: 'share/scrcpy')
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public final class WindowManager {
|
|||||||
try {
|
try {
|
||||||
Class<?> cls = manager.getClass();
|
Class<?> cls = manager.getClass();
|
||||||
try {
|
try {
|
||||||
return (Integer) cls.getMethod("getRotation").invoke(manager);
|
return (Integer) manager.getClass().getMethod("getRotation").invoke(manager);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
// method changed since this commit:
|
// method changed since this commit:
|
||||||
// https://android.googlesource.com/platform/frameworks/base/+/8ee7285128c3843401d4c4d0412cd66e86ba49e3%5E%21/#F2
|
// https://android.googlesource.com/platform/frameworks/base/+/8ee7285128c3843401d4c4d0412cd66e86ba49e3%5E%21/#F2
|
||||||
|
|||||||
Reference in New Issue
Block a user