mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-19 19:15:08 +00:00
Dealing with Conflict
This commit is contained in:
parent
11f7b2995b
commit
6ea2e79052
3 changed files with 11 additions and 19 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "util/binary.h"
|
||||
#include "util/log.h"
|
||||
|
||||
#define SC_PACKET_HEADER_SIZE 16
|
||||
#define SC_PACKET_HEADER_SIZE 12
|
||||
|
||||
#define SC_PACKET_FLAG_CONFIG (UINT64_C(1) << 63)
|
||||
#define SC_PACKET_FLAG_KEY_FRAME (UINT64_C(1) << 62)
|
||||
|
@ -95,11 +95,11 @@ sc_demuxer_recv_packet(struct sc_demuxer *demuxer, AVPacket *packet) {
|
|||
// The video and audio streams contain a sequence of raw packets (as
|
||||
// provided by MediaCodec), each prefixed with a "meta" header.
|
||||
//
|
||||
// The "meta" header length is 16 bytes:
|
||||
// [. . . . . . . .|. . . .][. . . .]. . . . . . . . . . . . . . . ...
|
||||
// <-------------> <------> <------> <-----------------------------...
|
||||
// PTS packet screen raw packet
|
||||
// size orientation
|
||||
// The "meta" header length is 12 bytes:
|
||||
// [. . . . . . . .|. . . .]. . . . . . . . . . . . . . . ...
|
||||
// <-------------> <-----> <-----------------------------...
|
||||
// PTS packet raw packet
|
||||
// size
|
||||
//
|
||||
// It is followed by <packet_size> bytes containing the packet/frame.
|
||||
//
|
||||
|
@ -149,7 +149,6 @@ sc_demuxer_recv_packet(struct sc_demuxer *demuxer, AVPacket *packet) {
|
|||
}
|
||||
|
||||
packet->dts = packet->pts;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class Server {
|
|||
audioCapture = new AudioPlaybackCapture(options.getAudioDup());
|
||||
}
|
||||
|
||||
Streamer audioStreamer = new Streamer(connection.getAudioFd(), audioCodec, options.getSendCodecMeta(), options.getSendFrameMeta(), options.getDisplayId());
|
||||
Streamer audioStreamer = new Streamer(connection.getAudioFd(), audioCodec, options.getSendCodecMeta(), options.getSendFrameMeta());
|
||||
AsyncProcessor audioRecorder;
|
||||
if (audioCodec == AudioCodec.RAW) {
|
||||
audioRecorder = new AudioRawRecorder(audioCapture, audioStreamer);
|
||||
|
@ -144,7 +144,7 @@ public final class Server {
|
|||
|
||||
if (video) {
|
||||
Streamer videoStreamer = new Streamer(connection.getVideoFd(), options.getVideoCodec(), options.getSendCodecMeta(),
|
||||
options.getSendFrameMeta(), options.getDisplayId());
|
||||
options.getSendFrameMeta());
|
||||
SurfaceCapture surfaceCapture;
|
||||
if (options.getVideoSource() == VideoSource.DISPLAY) {
|
||||
NewDisplay newDisplay = options.getNewDisplay();
|
||||
|
|
|
@ -21,17 +21,15 @@ public final class Streamer {
|
|||
private final Codec codec;
|
||||
private final boolean sendCodecMeta;
|
||||
private final boolean sendFrameMeta;
|
||||
private final int displayId;
|
||||
|
||||
private final int HEADER_PACKET_SIZE = 12;
|
||||
private final ByteBuffer headerBuffer = ByteBuffer.allocate(HEADER_PACKET_SIZE);
|
||||
|
||||
public Streamer(FileDescriptor fd, Codec codec, boolean sendCodecMeta, boolean sendFrameMeta, int displayId) {
|
||||
public Streamer(FileDescriptor fd, Codec codec, boolean sendCodecMeta, boolean sendFrameMeta) {
|
||||
this.fd = fd;
|
||||
this.codec = codec;
|
||||
this.sendCodecMeta = sendCodecMeta;
|
||||
this.sendFrameMeta = sendFrameMeta;
|
||||
this.displayId = displayId;
|
||||
}
|
||||
|
||||
public Codec getCodec() {
|
||||
|
@ -79,15 +77,11 @@ public final class Streamer {
|
|||
}
|
||||
|
||||
if (sendFrameMeta) {
|
||||
int screenOrientation = getScreenOrientation();
|
||||
writeFrameMeta(fd, buffer.remaining(), pts, config, keyFrame, screenOrientation);
|
||||
writeFrameMeta(fd, buffer.remaining(), pts, config, keyFrame);
|
||||
}
|
||||
|
||||
IO.writeFully(fd, buffer);
|
||||
}
|
||||
private int getScreenOrientation() {
|
||||
return Device.getCurrentRotation(this.displayId);
|
||||
}
|
||||
|
||||
public void writePacket(ByteBuffer codecBuffer, MediaCodec.BufferInfo bufferInfo) throws IOException {
|
||||
long pts = bufferInfo.presentationTimeUs;
|
||||
|
@ -96,7 +90,7 @@ public final class Streamer {
|
|||
writePacket(codecBuffer, pts, config, keyFrame);
|
||||
}
|
||||
|
||||
private void writeFrameMeta(FileDescriptor fd, int packetSize, long pts, boolean config, boolean keyFrame, int screenOrientation) throws IOException {
|
||||
private void writeFrameMeta(FileDescriptor fd, int packetSize, long pts, boolean config, boolean keyFrame) throws IOException {
|
||||
headerBuffer.clear();
|
||||
|
||||
long ptsAndFlags;
|
||||
|
@ -111,7 +105,6 @@ public final class Streamer {
|
|||
|
||||
headerBuffer.putLong(ptsAndFlags);
|
||||
headerBuffer.putInt(packetSize);
|
||||
headerBuffer.putInt(screenOrientation);
|
||||
headerBuffer.flip();
|
||||
IO.writeFully(fd, headerBuffer);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue