Skip to content

Commit fa3e2a0

Browse files
committed
patch scrcpy
1 parent 86bf274 commit fa3e2a0

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/adb/thirdparty/scrcpy/Scrcpy.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const PACKET_FLAG_KEY_FRAME = BigInt(1) << BigInt(62);
4747
*/
4848
interface IEmissions {
4949
frame: (data: VideoStreamFramePacket) => void
50+
/**
51+
* since Scrcpy v2.0 an extra event is emitted with the codec, width and height
52+
*/
53+
codec: (data: {codec: string, width: number, height: number}) => void
5054
config: (data: H264Configuration) => void
5155
raw: (data: Buffer) => void
5256
error: (error: Error) => void
@@ -281,10 +285,8 @@ export default class Scrcpy extends EventEmitter {
281285
args.push('app_process');
282286
args.push('/');
283287
args.push('com.genymobile.scrcpy.Server');
284-
const versionStr = this.strVersion;
285-
286288
// first args is the expected version number
287-
if (versionStr === "02.02.00") {
289+
if (this.strVersion === "02.02.00") {
288290
// V2.2 is the only version that expect a v prefix
289291
args.push("v" + this.config.version);
290292
} else {
@@ -318,7 +320,7 @@ export default class Scrcpy extends EventEmitter {
318320
// args.push(`no_control=${this.config.noControl}`);
319321
}
320322

321-
if (versionStr >= "02.04.00") {
323+
if (this.strVersion >= "02.04.00") {
322324
args.push(`video_source=display`);
323325
}
324326

@@ -349,7 +351,7 @@ export default class Scrcpy extends EventEmitter {
349351
if (clipboardAutosync !== undefined)
350352
args.push(`clipboard_autosync=${clipboardAutosync}`); // default is True
351353
//if (this.config.version >= 22) {
352-
if (versionStr >= "01.22.00") {
354+
if (this.strVersion >= "01.22.00") {
353355
const {
354356
downsizeOnError, sendDeviceMeta, sendDummyByte, rawVideoStream
355357
} = this.config;
@@ -362,7 +364,7 @@ export default class Scrcpy extends EventEmitter {
362364
if (rawVideoStream !== undefined)
363365
args.push(`raw_video_stream=${rawVideoStream}`);
364366
}
365-
if (versionStr >= "01.22.00") {
367+
if (this.strVersion >= "01.22.00") {
366368
const { cleanup } = this.config;
367369
if (cleanup !== undefined)
368370
args.push(`raw_video_stream=${cleanup}`);
@@ -574,7 +576,6 @@ export default class Scrcpy extends EventEmitter {
574576
* get resolve once capture stop
575577
*/
576578
private async startStreamWithMeta(): Promise<void> {
577-
const strVersion = this.strVersion;
578579
assert(this.videoSocket);
579580
this.videoSocket.stream.pause();
580581
await Utils.waitforReadable(this.videoSocket, 0, 'videoSocket header');
@@ -635,6 +636,8 @@ export default class Scrcpy extends EventEmitter {
635636
this.setCodec(codec);
636637
this.setWidth(width);
637638
this.setHeight(height);
639+
640+
this.emit("codec", {codec, width, height});
638641
}
639642

640643
let pts = BigInt(0);// Buffer.alloc(0);

src/adb/thirdparty/scrcpy/ScrcpyModels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export interface H264Configuration {
9797
croppedWidth: number;
9898
croppedHeight: number;
9999

100-
data: Uint8Array;
100+
data: Uint8Array; // the original data use to p[opulate this structure]
101101
}
102102

103103

0 commit comments

Comments
 (0)