Compare commits
34 Commits
fix_androi
...
buffering.
Author | SHA1 | Date | |
---|---|---|---|
86c4cbcf9e | |||
7917dc313e | |||
d743e03f44 | |||
9217cfa079 | |||
5caeab5f6d | |||
33fbdc86c7 | |||
f33d37976c | |||
7dca5078e7 | |||
ab12b6c981 | |||
376201a83c | |||
60c4e886d4 | |||
ff7baad709 | |||
e712f30ceb | |||
a9d9cbf8b5 | |||
fda32928c1 | |||
710e80aa0d | |||
77e96d745b | |||
1c95043478 | |||
488991116b | |||
5c95d18beb | |||
1039f9b531 | |||
19ca02cd8f | |||
937fa704a6 | |||
7db0189f23 | |||
8b90e1d3f4 | |||
df017160ed | |||
b846d3a085 | |||
d3d955f67b | |||
8121b0b7e7 | |||
2e9d520080 | |||
1b7c9b3e1c | |||
9bed8cf3f4 | |||
72081a241b | |||
42b3d1e66e |
6
BUILD.md
6
BUILD.md
@ -268,10 +268,10 @@ install` must be run as root)._
|
|||||||
|
|
||||||
#### Option 2: Use prebuilt server
|
#### Option 2: Use prebuilt server
|
||||||
|
|
||||||
- [`scrcpy-server-v1.17`][direct-scrcpy-server]
|
- [`scrcpy-server-v1.18`][direct-scrcpy-server]
|
||||||
_(SHA-256: 11b5ad2d1bc9b9730fb7254a78efd71a8ff46b1938ff468e47a21b653a1b6725)_
|
_(SHA-256: 641c5c6beda9399dfae72d116f5ff43b5ed1059d871c9ebc3f47610fd33c51a3)_
|
||||||
|
|
||||||
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v1.17/scrcpy-server-v1.17
|
[direct-scrcpy-server]: https://github.com/Genymobile/scrcpy/releases/download/v1.18/scrcpy-server-v1.18
|
||||||
|
|
||||||
Download the prebuilt server somewhere, and specify its path during the Meson
|
Download the prebuilt server somewhere, and specify its path during the Meson
|
||||||
configuration:
|
configuration:
|
||||||
|
217
FAQ.it.md
Normal file
217
FAQ.it.md
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
_Apri le [FAQ](FAQ.md) originali e sempre aggiornate._
|
||||||
|
|
||||||
|
# Domande Frequenti (FAQ)
|
||||||
|
|
||||||
|
Questi sono i problemi più comuni riportati e i loro stati.
|
||||||
|
|
||||||
|
|
||||||
|
## Problemi di `adb`
|
||||||
|
|
||||||
|
`scrcpy` esegue comandi `adb` per inizializzare la connessione con il dispositivo. Se `adb` fallisce, scrcpy non funzionerà.
|
||||||
|
|
||||||
|
In questo caso sarà stampato questo errore:
|
||||||
|
|
||||||
|
> ERROR: "adb push" returned with value 1
|
||||||
|
|
||||||
|
Questo solitamente non è un bug di _scrcpy_, ma un problema del tuo ambiente.
|
||||||
|
|
||||||
|
Per trovare la causa, esegui:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb devices
|
||||||
|
```
|
||||||
|
|
||||||
|
### `adb` not found (`adb` non trovato)
|
||||||
|
|
||||||
|
È necessario che `adb` sia accessibile dal tuo `PATH`.
|
||||||
|
|
||||||
|
In Windows, la cartella corrente è nel tuo `PATH` e `adb.exe` è incluso nella release, perciò dovrebbe già essere pronto all'uso.
|
||||||
|
|
||||||
|
|
||||||
|
### Device unauthorized (Dispositivo non autorizzato)
|
||||||
|
|
||||||
|
Controlla [stackoverflow][device-unauthorized] (in inglese).
|
||||||
|
|
||||||
|
[device-unauthorized]: https://stackoverflow.com/questions/23081263/adb-android-device-unauthorized
|
||||||
|
|
||||||
|
|
||||||
|
### Device not detected (Dispositivo non rilevato)
|
||||||
|
|
||||||
|
> adb: error: failed to get feature set: no devices/emulators found
|
||||||
|
|
||||||
|
Controlla di aver abilitato correttamente il [debug con adb][enable-adb] (link in inglese).
|
||||||
|
|
||||||
|
Se il tuo dispositivo non è rilevato, potresti avere bisogno dei [driver][drivers] (link in inglese) (in Windows).
|
||||||
|
|
||||||
|
[enable-adb]: https://developer.android.com/studio/command-line/adb.html#Enabling
|
||||||
|
[drivers]: https://developer.android.com/studio/run/oem-usb.html
|
||||||
|
|
||||||
|
|
||||||
|
### Più dispositivi connessi
|
||||||
|
|
||||||
|
Se più dispositivi sono connessi, riscontrerai questo errore:
|
||||||
|
|
||||||
|
> adb: error: failed to get feature set: more than one device/emulator
|
||||||
|
|
||||||
|
l'identificatore del tuo dispositivo deve essere fornito:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy -s 01234567890abcdef
|
||||||
|
```
|
||||||
|
|
||||||
|
Notare che se il tuo dispositivo è connesso mediante TCP/IP, riscontrerai questo messaggio:
|
||||||
|
|
||||||
|
> adb: error: more than one device/emulator
|
||||||
|
> ERROR: "adb reverse" returned with value 1
|
||||||
|
> WARN: 'adb reverse' failed, fallback to 'adb forward'
|
||||||
|
|
||||||
|
Questo è un problema atteso (a causa di un bug di una vecchia versione di Android, vedi [#5] (link in inglese)), ma in quel caso scrcpy ripiega su un metodo differente, il quale dovrebbe funzionare.
|
||||||
|
|
||||||
|
[#5]: https://github.com/Genymobile/scrcpy/issues/5
|
||||||
|
|
||||||
|
|
||||||
|
### Conflitti tra versioni di adb
|
||||||
|
|
||||||
|
> adb server version (41) doesn't match this client (39); killing...
|
||||||
|
|
||||||
|
L'errore compare quando usi più versioni di `adb` simultaneamente. Devi trovare il programma che sta utilizzando una versione differente di `adb` e utilizzare la stessa versione dappertutto.
|
||||||
|
|
||||||
|
Puoi sovrascrivere i binari di `adb` nell'altro programma, oppure chiedere a _scrcpy_ di usare un binario specifico di `adb`, impostando la variabile d'ambiente `ADB`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set ADB=/path/to/your/adb
|
||||||
|
scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Device disconnected (Dispositivo disconnesso)
|
||||||
|
|
||||||
|
Se _scrcpy_ si interrompe con l'avviso "Device disconnected", allora la connessione `adb` è stata chiusa.
|
||||||
|
|
||||||
|
Prova con un altro cavo USB o inseriscilo in un'altra porta USB. Vedi [#281] (in inglese) e [#283] (in inglese).
|
||||||
|
|
||||||
|
[#281]: https://github.com/Genymobile/scrcpy/issues/281
|
||||||
|
[#283]: https://github.com/Genymobile/scrcpy/issues/283
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Problemi di controllo
|
||||||
|
|
||||||
|
### Mouse e tastiera non funzionano
|
||||||
|
|
||||||
|
Su alcuni dispositivi potresti dover abilitare un opzione che permette l'[input simulato][simulating input] (link in inglese). Nelle opzioni sviluppatore, abilita:
|
||||||
|
|
||||||
|
> **Debug USB (Impostazioni di sicurezza)**
|
||||||
|
> _Permetti la concessione dei permessi e la simulazione degli input mediante il debug USB_
|
||||||
|
<!--- Ho tradotto personalmente il testo sopra, non conosco esattamente il testo reale --->
|
||||||
|
|
||||||
|
[simulating input]: https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323
|
||||||
|
|
||||||
|
|
||||||
|
### I caratteri speciali non funzionano
|
||||||
|
|
||||||
|
Iniettare del testo in input è [limitato ai caratteri ASCII][text-input] (link in inglese). Un trucco permette di iniettare dei [caratteri accentati][accented-characters] (link in inglese), ma questo è tutto. Vedi [#37] (link in inglese).
|
||||||
|
|
||||||
|
[text-input]: https://github.com/Genymobile/scrcpy/issues?q=is%3Aopen+is%3Aissue+label%3Aunicode
|
||||||
|
[accented-characters]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-accented-characters
|
||||||
|
[#37]: https://github.com/Genymobile/scrcpy/issues/37
|
||||||
|
|
||||||
|
|
||||||
|
## Problemi del client
|
||||||
|
|
||||||
|
### La qualità è bassa
|
||||||
|
|
||||||
|
Se la definizione della finestra del tuo client è minore di quella del tuo dispositivo, allora potresti avere una bassa qualità di visualizzazione, specialmente individuabile nei testi (vedi [#40] (link in inglese)).
|
||||||
|
|
||||||
|
[#40]: https://github.com/Genymobile/scrcpy/issues/40
|
||||||
|
|
||||||
|
Per migliorare la qualità di ridimensionamento (downscaling), il filtro trilineare è applicato automaticamente se il renderizzatore è OpenGL e se supporta la creazione di mipmap.
|
||||||
|
|
||||||
|
In Windows, potresti voler forzare OpenGL:
|
||||||
|
|
||||||
|
```
|
||||||
|
scrcpy --render-driver=opengl
|
||||||
|
```
|
||||||
|
|
||||||
|
Potresti anche dover configurare il [comportamento di ridimensionamento][scaling behavior] (link in inglese):
|
||||||
|
|
||||||
|
> `scrcpy.exe` > Propietà > Compatibilità > Modifica impostazioni DPI elevati > Esegui l'override del comportamento di ridimensionamento DPI elevati > Ridimensionamento eseguito per: _Applicazione_.
|
||||||
|
|
||||||
|
[scaling behavior]: https://github.com/Genymobile/scrcpy/issues/40#issuecomment-424466723
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Crash del compositore KWin
|
||||||
|
|
||||||
|
In Plasma Desktop, il compositore è disabilitato mentre _scrcpy_ è in esecuzione.
|
||||||
|
|
||||||
|
Come soluzione alternativa, [disattiva la "composizione dei blocchi"][kwin] (link in inglese).
|
||||||
|
<!--- Non sono sicuro di aver tradotto correttamente la stringa di testo del pulsante --->
|
||||||
|
|
||||||
|
[kwin]: https://github.com/Genymobile/scrcpy/issues/114#issuecomment-378778613
|
||||||
|
|
||||||
|
|
||||||
|
## Crash
|
||||||
|
|
||||||
|
### Eccezione
|
||||||
|
|
||||||
|
Ci potrebbero essere molte ragioni. Una causa comune è che il codificatore hardware del tuo dispositivo non riesce a codificare alla definizione selezionata:
|
||||||
|
|
||||||
|
> ```
|
||||||
|
> ERROR: Exception on thread Thread[main,5,main]
|
||||||
|
> android.media.MediaCodec$CodecException: Error 0xfffffc0e
|
||||||
|
> ...
|
||||||
|
> Exit due to uncaughtException in main thread:
|
||||||
|
> ERROR: Could not open video stream
|
||||||
|
> INFO: Initial texture: 1080x2336
|
||||||
|
> ```
|
||||||
|
|
||||||
|
o
|
||||||
|
|
||||||
|
> ```
|
||||||
|
> ERROR: Exception on thread Thread[main,5,main]
|
||||||
|
> java.lang.IllegalStateException
|
||||||
|
> at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
|
||||||
|
> ```
|
||||||
|
|
||||||
|
Prova con una definizione inferiore:
|
||||||
|
|
||||||
|
```
|
||||||
|
scrcpy -m 1920
|
||||||
|
scrcpy -m 1024
|
||||||
|
scrcpy -m 800
|
||||||
|
```
|
||||||
|
|
||||||
|
Potresti anche provare un altro [codificatore](README.it.md#codificatore).
|
||||||
|
|
||||||
|
|
||||||
|
## Linea di comando in Windows
|
||||||
|
|
||||||
|
Alcuni utenti Windows non sono familiari con la riga di comando. Qui è descritto come aprire un terminale ed eseguire `scrcpy` con gli argomenti:
|
||||||
|
|
||||||
|
1. Premi <kbd>Windows</kbd>+<kbd>r</kbd>, questo apre una finestra di dialogo.
|
||||||
|
2. Scrivi `cmd` e premi <kbd>Enter</kbd>, questo apre un terminale.
|
||||||
|
3. Vai nella tua cartella di _scrcpy_ scrivendo (adatta il percorso):
|
||||||
|
|
||||||
|
```bat
|
||||||
|
cd C:\Users\user\Downloads\scrcpy-win64-xxx
|
||||||
|
```
|
||||||
|
|
||||||
|
e premi <kbd>Enter</kbd>
|
||||||
|
4. Scrivi il tuo comando. Per esempio:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
scrcpy --record file.mkv
|
||||||
|
```
|
||||||
|
|
||||||
|
Se pianifichi di utilizzare sempre gli stessi argomenti, crea un file `myscrcpy.bat` (abilita mostra [estensioni nomi file][show file extensions] per evitare di far confusione) contenente il tuo comando nella cartella di `scrcpy`. Per esempio:
|
||||||
|
|
||||||
|
```bat
|
||||||
|
scrcpy --prefer-text --turn-screen-off --stay-awake
|
||||||
|
```
|
||||||
|
|
||||||
|
Poi fai doppio click su quel file.
|
||||||
|
|
||||||
|
Potresti anche modificare (una copia di) `scrcpy-console.bat` o `scrcpy-noconsole.vbs` per aggiungere alcuni argomenti.
|
||||||
|
|
||||||
|
[show file extensions]: https://www.techpedia.it/14-windows/windows-10/171-visualizzare-le-estensioni-nomi-file-con-windows-10
|
10
FAQ.md
10
FAQ.md
@ -1,5 +1,7 @@
|
|||||||
# Frequently Asked Questions
|
# Frequently Asked Questions
|
||||||
|
|
||||||
|
[Read in another language](#translations)
|
||||||
|
|
||||||
Here are the common reported problems and their status.
|
Here are the common reported problems and their status.
|
||||||
|
|
||||||
|
|
||||||
@ -230,3 +232,11 @@ You could also edit (a copy of) `scrcpy-console.bat` or `scrcpy-noconsole.vbs`
|
|||||||
to add some arguments.
|
to add some arguments.
|
||||||
|
|
||||||
[show file extensions]: https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/
|
[show file extensions]: https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/
|
||||||
|
|
||||||
|
|
||||||
|
## Translations
|
||||||
|
|
||||||
|
This FAQ is available in other languages:
|
||||||
|
|
||||||
|
- [Italiano (Italiano, `it`) - v1.17](FAQ.it.md)
|
||||||
|
- [한국어 (Korean, `ko`) - v1.11](FAQ.ko.md)
|
||||||
|
742
README.it.md
Normal file
742
README.it.md
Normal file
@ -0,0 +1,742 @@
|
|||||||
|
_Apri il [README](README.md) originale e sempre aggiornato._
|
||||||
|
|
||||||
|
# scrcpy (v1.17)
|
||||||
|
|
||||||
|
Questa applicazione fornisce la visualizzazione e il controllo dei dispositivi Android collegati via USB (o [via TCP/IP][article-tcpip]). Non richiede alcun accesso _root_.
|
||||||
|
Funziona su _GNU/Linux_, _Windows_ e _macOS_.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Si concentra su:
|
||||||
|
|
||||||
|
- **leggerezza** (nativo, mostra solo lo schermo del dispositivo)
|
||||||
|
- **prestazioni** (30~60fps)
|
||||||
|
- **qualità** (1920×1080 o superiore)
|
||||||
|
- **bassa latenza** ([35~70ms][lowlatency])
|
||||||
|
- **tempo di avvio basso** (~ 1secondo per visualizzare la prima immagine)
|
||||||
|
- **non invadenza** (nulla viene lasciato installato sul dispositivo)
|
||||||
|
|
||||||
|
[lowlatency]: https://github.com/Genymobile/scrcpy/pull/646
|
||||||
|
|
||||||
|
|
||||||
|
## Requisiti
|
||||||
|
|
||||||
|
Il dispositivo Android richiede almeno le API 21 (Android 5.0).
|
||||||
|
|
||||||
|
Assiucurati di aver [attivato il debug usb][enable-adb] sul(/i) tuo(i) dispositivo(/i).
|
||||||
|
|
||||||
|
[enable-adb]: https://developer.android.com/studio/command-line/adb.html#Enabling
|
||||||
|
|
||||||
|
In alcuni dispositivi, devi anche abilitare [un'opzione aggiuntiva][control] per controllarli con tastiera e mouse.
|
||||||
|
|
||||||
|
[control]: https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323
|
||||||
|
|
||||||
|
## Ottieni l'app
|
||||||
|
|
||||||
|
<a href="https://repology.org/project/scrcpy/versions"><img src="https://repology.org/badge/vertical-allrepos/scrcpy.svg" alt="Packaging status" align="right"></a>
|
||||||
|
|
||||||
|
### Sommario
|
||||||
|
|
||||||
|
- Linux: `apt install scrcpy`
|
||||||
|
- Windows: [download](README.md#windows)
|
||||||
|
- macOS: `brew install scrcpy`
|
||||||
|
|
||||||
|
Compila dai sorgenti: [BUILD] (in inglese) ([procedimento semplificato][BUILD_simple] (in inglese))
|
||||||
|
|
||||||
|
[BUILD]: BUILD.md
|
||||||
|
[BUILD_simple]: BUILD.md#simple
|
||||||
|
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
Su Debian (_testing_ e _sid_ per ora) e Ubuntu (20.04):
|
||||||
|
|
||||||
|
```
|
||||||
|
apt install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
È disponibile anche un pacchetto [Snap]: [`scrcpy`][snap-link].
|
||||||
|
|
||||||
|
[snap-link]: https://snapstats.org/snaps/scrcpy
|
||||||
|
|
||||||
|
[snap]: https://it.wikipedia.org/wiki/Snappy_(gestore_pacchetti)
|
||||||
|
|
||||||
|
Per Fedora, è disponibile un pacchetto [COPR]: [`scrcpy`][copr-link].
|
||||||
|
|
||||||
|
[COPR]: https://fedoraproject.org/wiki/Category:Copr
|
||||||
|
[copr-link]: https://copr.fedorainfracloud.org/coprs/zeno/scrcpy/
|
||||||
|
|
||||||
|
Per Arch Linux, è disponibile un pacchetto [AUR]: [`scrcpy`][aur-link].
|
||||||
|
|
||||||
|
[AUR]: https://wiki.archlinux.org/index.php/Arch_User_Repository
|
||||||
|
[aur-link]: https://aur.archlinux.org/packages/scrcpy/
|
||||||
|
|
||||||
|
Per Gentoo, è disponibile una [Ebuild]: [`scrcpy/`][ebuild-link].
|
||||||
|
|
||||||
|
[Ebuild]: https://wiki.gentoo.org/wiki/Ebuild
|
||||||
|
[ebuild-link]: https://github.com/maggu2810/maggu2810-overlay/tree/master/app-mobilephone/scrcpy
|
||||||
|
|
||||||
|
Puoi anche [compilare l'app manualmente][BUILD] (in inglese) ([procedimento semplificato][BUILD_simple] (in inglese)).
|
||||||
|
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
Per Windows, per semplicità è disponibile un archivio precompilato con tutte le dipendenze (incluso `adb`):
|
||||||
|
|
||||||
|
- [README](README.md#windows) (Link al README originale per l'ultima versione)
|
||||||
|
|
||||||
|
È anche disponibile in [Chocolatey]:
|
||||||
|
|
||||||
|
[Chocolatey]: https://chocolatey.org/
|
||||||
|
|
||||||
|
```bash
|
||||||
|
choco install scrcpy
|
||||||
|
choco install adb # se non lo hai già
|
||||||
|
```
|
||||||
|
|
||||||
|
E in [Scoop]:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scoop install scrcpy
|
||||||
|
scoop install adb # se non lo hai già
|
||||||
|
```
|
||||||
|
|
||||||
|
[Scoop]: https://scoop.sh
|
||||||
|
|
||||||
|
Puoi anche [compilare l'app manualmente][BUILD] (in inglese).
|
||||||
|
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
L'applicazione è disponibile in [Homebrew]. Basta installarlo:
|
||||||
|
|
||||||
|
[Homebrew]: https://brew.sh/
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Serve che `adb` sia accessibile dal tuo `PATH`. Se non lo hai già:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install android-platform-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
È anche disponibile in [MacPorts], che imposta adb per te:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo port install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
[MacPorts]: https://www.macports.org/
|
||||||
|
|
||||||
|
|
||||||
|
Puoi anche [compilare l'app manualmente][BUILD] (in inglese).
|
||||||
|
|
||||||
|
|
||||||
|
## Esecuzione
|
||||||
|
|
||||||
|
Collega un dispositivo Android ed esegui:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Scrcpy accetta argomenti da riga di comando, essi sono listati con:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Funzionalità
|
||||||
|
|
||||||
|
### Configurazione di acquisizione
|
||||||
|
|
||||||
|
#### Riduci dimensione
|
||||||
|
|
||||||
|
Qualche volta è utile trasmettere un dispositvo Android ad una definizione inferiore per aumentare le prestazioni.
|
||||||
|
|
||||||
|
Per limitare sia larghezza che altezza ad un certo valore (ad es. 1024):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --max-size 1024
|
||||||
|
scrcpy -m 1024 # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
L'altra dimensione è calcolata in modo tale che il rapporto di forma del dispositivo sia preservato.
|
||||||
|
In questo esempio un dispositivo in 1920x1080 viene trasmesso a 1024x576.
|
||||||
|
|
||||||
|
|
||||||
|
#### Cambia bit-rate (velocità di trasmissione)
|
||||||
|
|
||||||
|
Il bit-rate predefinito è 8 Mbps. Per cambiare il bitrate video (ad es. a 2 Mbps):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --bit-rate 2M
|
||||||
|
scrcpy -b 2M # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Limitare il frame rate (frequenza di fotogrammi)
|
||||||
|
|
||||||
|
Il frame rate di acquisizione può essere limitato:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --max-fps 15
|
||||||
|
```
|
||||||
|
|
||||||
|
Questo è supportato ufficialmente a partire da Android 10, ma potrebbe funzionare in versioni precedenti.
|
||||||
|
|
||||||
|
#### Ritaglio
|
||||||
|
|
||||||
|
Lo schermo del dispositivo può essere ritagliato per visualizzare solo parte di esso.
|
||||||
|
|
||||||
|
Questo può essere utile, per esempio, per trasmettere solo un occhio dell'Oculus Go:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --crop 1224:1440:0:0 # 1224x1440 at offset (0,0)
|
||||||
|
```
|
||||||
|
|
||||||
|
Se anche `--max-size` è specificata, il ridimensionamento è applicato dopo il ritaglio.
|
||||||
|
|
||||||
|
|
||||||
|
#### Blocca orientamento del video
|
||||||
|
|
||||||
|
|
||||||
|
Per bloccare l'orientamento della trasmissione:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --lock-video-orientation 0 # orientamento naturale
|
||||||
|
scrcpy --lock-video-orientation 1 # 90° antiorario
|
||||||
|
scrcpy --lock-video-orientation 2 # 180°
|
||||||
|
scrcpy --lock-video-orientation 3 # 90° orario
|
||||||
|
```
|
||||||
|
|
||||||
|
Questo influisce sull'orientamento della registrazione.
|
||||||
|
|
||||||
|
|
||||||
|
La [finestra può anche essere ruotata](#rotazione) indipendentemente.
|
||||||
|
|
||||||
|
|
||||||
|
#### Codificatore
|
||||||
|
|
||||||
|
Alcuni dispositivi hanno più di un codificatore e alcuni di questi possono provocare problemi o crash. È possibile selezionare un encoder diverso:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --encoder OMX.qcom.video.encoder.avc
|
||||||
|
```
|
||||||
|
|
||||||
|
Per elencare i codificatori disponibili puoi immettere un nome di codificatore non valido e l'errore mostrerà i codificatori disponibili:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --encoder _
|
||||||
|
```
|
||||||
|
|
||||||
|
### Registrazione
|
||||||
|
|
||||||
|
È possibile registrare lo schermo durante la trasmissione:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --record file.mp4
|
||||||
|
scrcpy -r file.mkv
|
||||||
|
```
|
||||||
|
|
||||||
|
Per disabilitare la trasmissione durante la registrazione:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-display --record file.mp4
|
||||||
|
scrcpy -Nr file.mkv
|
||||||
|
# interrompere la registrazione con Ctrl+C
|
||||||
|
```
|
||||||
|
|
||||||
|
I "fotogrammi saltati" sono registrati nonostante non siano mostrati in tempo reale (per motivi di prestazioni). I fotogrammi sono _datati_ sul dispositivo, così una [variazione di latenza dei pacchetti][packet delay variation] non impatta il file registrato.
|
||||||
|
|
||||||
|
[packet delay variation]: https://en.wikipedia.org/wiki/Packet_delay_variation
|
||||||
|
|
||||||
|
|
||||||
|
### Connessione
|
||||||
|
|
||||||
|
#### Wireless
|
||||||
|
|
||||||
|
|
||||||
|
_Scrcpy_ usa `adb` per comunicare col dispositivo e `adb` può [connettersi][connect] al dispositivo mediante TCP/IP:
|
||||||
|
|
||||||
|
1. Connetti il dispositivo alla stessa rete Wi-Fi del tuo computer.
|
||||||
|
2. Trova l'indirizzo IP del tuo dispositivo in Impostazioni → Informazioni sul telefono → Stato, oppure eseguendo questo comando:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb shell ip route | awk '{print $9}'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Abilita adb via TCP/IP sul tuo dispositivo: `adb tcpip 5555`.
|
||||||
|
4. Scollega il tuo dispositivo.
|
||||||
|
5. Connetti il tuo dispositivo: `adb connect IP_DISPOSITVO:5555` _(rimpiazza `IP_DISPOSITIVO`)_.
|
||||||
|
6. Esegui `scrcpy` come al solito.
|
||||||
|
|
||||||
|
Potrebbe essere utile diminuire il bit-rate e la definizione
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --bit-rate 2M --max-size 800
|
||||||
|
scrcpy -b2M -m800 # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
[connect]: https://developer.android.com/studio/command-line/adb.html#wireless
|
||||||
|
|
||||||
|
|
||||||
|
#### Multi dispositivo
|
||||||
|
|
||||||
|
Se in `adb devices` sono listati più dispositivi, è necessario specificare il _seriale_:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --serial 0123456789abcdef
|
||||||
|
scrcpy -s 0123456789abcdef # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Se il dispositivo è collegato mediante TCP/IP:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --serial 192.168.0.1:5555
|
||||||
|
scrcpy -s 192.168.0.1:5555 # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Puoi avviare più istanze di _scrcpy_ per diversi dispositivi.
|
||||||
|
|
||||||
|
|
||||||
|
#### Avvio automativo alla connessione del dispositivo
|
||||||
|
|
||||||
|
Potresti usare [AutoAdb]:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
autoadb scrcpy -s '{}'
|
||||||
|
```
|
||||||
|
|
||||||
|
[AutoAdb]: https://github.com/rom1v/autoadb
|
||||||
|
|
||||||
|
#### Tunnel SSH
|
||||||
|
|
||||||
|
Per connettersi a un dispositivo remoto è possibile collegare un client `adb` locale ad un server `adb` remoto (assunto che entrambi stiano usando la stessa versione del protocollo _adb_):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb kill-server # termina il server adb locale su 5037
|
||||||
|
ssh -CN -L5037:localhost:5037 -R27183:localhost:27183 your_remote_computer
|
||||||
|
# tieni questo aperto
|
||||||
|
```
|
||||||
|
|
||||||
|
Da un altro terminale:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Per evitare l'abilitazione dell'apertura porte remota potresti invece forzare una "forward connection" (notare il `-L` invece di `-R`)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb kill-server # termina il server adb locale su 5037
|
||||||
|
ssh -CN -L5037:localhost:5037 -L27183:localhost:27183 your_remote_computer
|
||||||
|
# tieni questo aperto
|
||||||
|
```
|
||||||
|
|
||||||
|
Da un altro terminale:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --force-adb-forward
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Come per le connessioni wireless potrebbe essere utile ridurre la qualità:
|
||||||
|
|
||||||
|
```
|
||||||
|
scrcpy -b2M -m800 --max-fps 15
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configurazione della finestra
|
||||||
|
|
||||||
|
#### Titolo
|
||||||
|
|
||||||
|
Il titolo della finestra è il modello del dispositivo per impostazione predefinita. Esso può essere cambiato:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-title 'My device'
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Posizione e dimensione
|
||||||
|
|
||||||
|
La posizione e la dimensione iniziale della finestra può essere specificata:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-x 100 --window-y 100 --window-width 800 --window-height 600
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Senza bordi
|
||||||
|
|
||||||
|
Per disabilitare le decorazioni della finestra:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-borderless
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Sempre in primo piano
|
||||||
|
|
||||||
|
Per tenere scrcpy sempre in primo piano:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --always-on-top
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Schermo intero
|
||||||
|
|
||||||
|
L'app può essere avviata direttamente a schermo intero:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --fullscreen
|
||||||
|
scrcpy -f # versione breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Lo schermo intero può anche essere attivato/disattivato con <kbd>MOD</kbd>+<kbd>f</kbd>.
|
||||||
|
|
||||||
|
#### Rotazione
|
||||||
|
|
||||||
|
La finestra può essere ruotata:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --rotation 1
|
||||||
|
```
|
||||||
|
|
||||||
|
I valori possibili sono:
|
||||||
|
- `0`: nessuna rotazione
|
||||||
|
- `1`: 90 gradi antiorari
|
||||||
|
- `2`: 180 gradi
|
||||||
|
- `3`: 90 gradi orari
|
||||||
|
|
||||||
|
La rotazione può anche essere cambiata dinamicamente con <kbd>MOD</kbd>+<kbd>←</kbd>
|
||||||
|
_(sinistra)_ e <kbd>MOD</kbd>+<kbd>→</kbd> _(destra)_.
|
||||||
|
|
||||||
|
Notare che _scrcpy_ gestisce 3 diversi tipi di rotazione:
|
||||||
|
- <kbd>MOD</kbd>+<kbd>r</kbd> richiede al dispositvo di cambiare tra orientamento verticale (portrait) e orizzontale (landscape) (l'app in uso potrebbe rifiutarsi se non supporta l'orientamento richiesto).
|
||||||
|
- [`--lock-video-orientation`](#blocca-orientamento-del-video) cambia l'orientamento della trasmissione (l'orientamento del video inviato dal dispositivo al computer). Questo influenza la registrazione.
|
||||||
|
- `--rotation` (o <kbd>MOD</kbd>+<kbd>←</kbd>/<kbd>MOD</kbd>+<kbd>→</kbd>) ruota solo il contenuto della finestra. Questo influenza solo la visualizzazione, non la registrazione.
|
||||||
|
|
||||||
|
|
||||||
|
### Altre opzioni di trasmissione
|
||||||
|
|
||||||
|
#### "Sola lettura"
|
||||||
|
|
||||||
|
Per disabilitare i controlli (tutto ciò che può interagire col dispositivo: tasti di input, eventi del mouse, trascina e rilascia (drag&drop) file):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-control
|
||||||
|
scrcpy -n
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Schermo
|
||||||
|
|
||||||
|
Se sono disponibili più schermi, è possibile selezionare lo schermo da trasmettere:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --display 1
|
||||||
|
```
|
||||||
|
|
||||||
|
La lista degli id schermo può essere ricavata da:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb shell dumpsys display # cerca "mDisplayId=" nell'output
|
||||||
|
```
|
||||||
|
|
||||||
|
Lo schermo secondario potrebbe essere possibile controllarlo solo se il dispositivo esegue almeno Android 10 (in caso contrario è trasmesso in modalità sola lettura).
|
||||||
|
|
||||||
|
|
||||||
|
#### Mantenere sbloccato
|
||||||
|
|
||||||
|
Per evitare che il dispositivo si blocchi dopo un po' che il dispositivo è collegato:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --stay-awake
|
||||||
|
scrcpy -w
|
||||||
|
```
|
||||||
|
|
||||||
|
Lo stato iniziale è ripristinato quando scrcpy viene chiuso.
|
||||||
|
|
||||||
|
|
||||||
|
#### Spegnere lo schermo
|
||||||
|
|
||||||
|
È possibile spegnere lo schermo del dispositivo durante la trasmissione con un'opzione da riga di comando:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --turn-screen-off
|
||||||
|
scrcpy -S
|
||||||
|
```
|
||||||
|
|
||||||
|
Oppure premendo <kbd>MOD</kbd>+<kbd>o</kbd> in qualsiasi momento.
|
||||||
|
|
||||||
|
Per riaccenderlo premere <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>o</kbd>.
|
||||||
|
|
||||||
|
In Android il pulsante `POWER` (tasto di accensione) accende sempre lo schermo. Per comodità, se `POWER` è inviato via scrcpy (con click destro o con <kbd>MOD</kbd>+<kbd>p</kbd>), si forza il dispositivo a spegnere lo schermo dopo un piccolo ritardo (appena possibile).
|
||||||
|
Il pulsante fisico `POWER` continuerà ad accendere lo schermo normalmente.
|
||||||
|
|
||||||
|
Può anche essere utile evitare il blocco del dispositivo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --turn-screen-off --stay-awake
|
||||||
|
scrcpy -Sw
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Renderizzare i fotogrammi scaduti
|
||||||
|
|
||||||
|
Per minimizzare la latenza _scrcpy_ renderizza sempre l'ultimo fotogramma decodificato disponibile in maniera predefinita e tralascia quelli precedenti.
|
||||||
|
|
||||||
|
Per forzare la renderizzazione di tutti i fotogrammi (a costo di una possibile latenza superiore), utilizzare:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --render-expired-frames
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Mostrare i tocchi
|
||||||
|
|
||||||
|
Per le presentazioni può essere utile mostrare i tocchi fisici (sul dispositivo fisico).
|
||||||
|
|
||||||
|
Android fornisce questa funzionalità nelle _Opzioni sviluppatore_.
|
||||||
|
|
||||||
|
_Scrcpy_ fornisce un'opzione per abilitare questa funzionalità all'avvio e ripristinare il valore iniziale alla chiusura:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --show-touches
|
||||||
|
scrcpy -t
|
||||||
|
```
|
||||||
|
|
||||||
|
Notare che mostra solo i tocchi _fisici_ (con le dita sul dispositivo).
|
||||||
|
|
||||||
|
|
||||||
|
#### Disabilitare il salvaschermo
|
||||||
|
|
||||||
|
In maniera predefinita scrcpy non previene l'attivazione del salvaschermo del computer.
|
||||||
|
|
||||||
|
Per disabilitarlo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --disable-screensaver
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Input di controlli
|
||||||
|
|
||||||
|
#### Rotazione dello schermo del dispostivo
|
||||||
|
|
||||||
|
Premere <kbd>MOD</kbd>+<kbd>r</kbd> per cambiare tra le modalità verticale (portrait) e orizzontale (landscape).
|
||||||
|
|
||||||
|
Notare che la rotazione avviene solo se l'applicazione in primo piano supporta l'orientamento richiesto.
|
||||||
|
|
||||||
|
#### Copia-incolla
|
||||||
|
|
||||||
|
Quando gli appunti di Android cambiano, essi vengono automaticamente sincronizzati con gli appunti del computer.
|
||||||
|
|
||||||
|
Qualsiasi scorciatoia <kbd>Ctrl</kbd> viene inoltrata al dispositivo. In particolare:
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>c</kbd> copia
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>x</kbd> taglia
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>v</kbd> incolla (dopo la sincronizzazione degli appunti da computer a dispositivo)
|
||||||
|
|
||||||
|
Questo solitamente funziona nella maniera più comune.
|
||||||
|
|
||||||
|
Il comportamento reale, però, dipende dall'applicazione attiva. Per esempio _Termux_ invia SIGINT con <kbd>Ctrl</kbd>+<kbd>c</kbd>, e _K-9 Mail_ compone un nuovo messaggio.
|
||||||
|
|
||||||
|
Per copiare, tagliare e incollare in questi casi (ma è solo supportato in Android >= 7):
|
||||||
|
- <kbd>MOD</kbd>+<kbd>c</kbd> inietta `COPY`
|
||||||
|
- <kbd>MOD</kbd>+<kbd>x</kbd> inietta `CUT`
|
||||||
|
- <kbd>MOD</kbd>+<kbd>v</kbd> inietta `PASTE` (dopo la sincronizzazione degli appunti da computer a dispositivo)
|
||||||
|
|
||||||
|
In aggiunta, <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd> permette l'iniezione del testo degli appunti del computer come una sequenza di eventi pressione dei tasti. Questo è utile quando il componente non accetta l'incollaggio di testo (per esempio in _Termux_), ma questo può rompere il contenuto non ASCII.
|
||||||
|
|
||||||
|
**AVVISO:** Incollare gli appunti del computer nel dispositivo (sia con <kbd>Ctrl</kbd>+<kbd>v</kbd> che con <kbd>MOD</kbd>+<kbd>v</kbd>) copia il contenuto negli appunti del dispositivo. Come conseguenza, qualsiasi applicazione Android potrebbe leggere il suo contenuto. Dovresti evitare di incollare contenuti sensibili (come password) in questa maniera.
|
||||||
|
|
||||||
|
Alcuni dispositivi non si comportano come aspettato quando si modificano gli appunti del dispositivo a livello di codice. L'opzione `--legacy-paste` è fornita per cambiare il comportamento di <kbd>Ctrl</kbd>+<kbd>v</kbd> and <kbd>MOD</kbd>+<kbd>v</kbd> in modo tale che anch'essi iniettino il testo gli appunti del computer come una sequenza di eventi pressione dei tasti (nella stessa maniera di <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>).
|
||||||
|
|
||||||
|
#### Pizzica per zoomare (pinch-to-zoom)
|
||||||
|
|
||||||
|
Per simulare il "pizzica per zoomare": <kbd>Ctrl</kbd>+_click e trascina_.
|
||||||
|
|
||||||
|
Più precisamente, tieni premuto <kbd>Ctrl</kbd> mentre premi il pulsante sinistro. Finchè il pulsante non sarà rilasciato, tutti i movimenti del mouse ridimensioneranno e ruoteranno il contenuto (se supportato dall'applicazione) relativamente al centro dello schermo.
|
||||||
|
|
||||||
|
Concretamente scrcpy genera degli eventi di tocco addizionali di un "dito virtuale" nella posizione simmetricamente opposta rispetto al centro dello schermo.
|
||||||
|
|
||||||
|
|
||||||
|
#### Preferenze di iniezione del testo
|
||||||
|
|
||||||
|
Ci sono due tipi di [eventi][textevents] generati quando si scrive testo:
|
||||||
|
- _eventi di pressione_, segnalano che tasto è stato premuto o rilasciato;
|
||||||
|
- _eventi di testo_, segnalano che del testo è stato inserito.
|
||||||
|
|
||||||
|
In maniera predefinita le lettere sono "iniettate" usando gli eventi di pressione, in maniera tale che la tastiera si comporti come aspettato nei giochi (come accade solitamente per i tasti WASD).
|
||||||
|
|
||||||
|
Questo, però, può [causare problemi][prefertext]. Se incontri un problema del genere, puoi evitarlo con:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --prefer-text
|
||||||
|
```
|
||||||
|
|
||||||
|
(ma questo romperà il normale funzionamento della tastiera nei giochi)
|
||||||
|
|
||||||
|
[textevents]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-text-input
|
||||||
|
[prefertext]: https://github.com/Genymobile/scrcpy/issues/650#issuecomment-512945343
|
||||||
|
|
||||||
|
|
||||||
|
#### Ripetizione di tasti
|
||||||
|
|
||||||
|
In maniera predefinita tenere premuto un tasto genera una ripetizione degli eventi di pressione di tale tasto. Questo può creare problemi di performance in alcuni giochi, dove questi eventi sono inutilizzati.
|
||||||
|
|
||||||
|
Per prevenire l'inoltro ripetuto degli eventi di pressione:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-key-repeat
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Click destro e click centrale
|
||||||
|
|
||||||
|
In maniera predefinita, click destro aziona BACK (indietro) e il click centrale aziona HOME. Per disabilitare queste scorciatoie e, invece, inviare i click al dispositivo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --forward-all-clicks
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Rilascio di file
|
||||||
|
|
||||||
|
#### Installare APK
|
||||||
|
|
||||||
|
Per installare un APK, trascina e rilascia un file APK (finisce con `.apk`) nella finestra di _scrcpy_.
|
||||||
|
|
||||||
|
Non c'è alcuna risposta visiva, un log è stampato nella console.
|
||||||
|
|
||||||
|
|
||||||
|
#### Trasferimento di file verso il dispositivo
|
||||||
|
|
||||||
|
Per trasferire un file in `/sdcard/` del dispositivo trascina e rilascia un file (non APK) nella finestra di _scrcpy_.
|
||||||
|
|
||||||
|
Non c'è alcuna risposta visiva, un log è stampato nella console.
|
||||||
|
|
||||||
|
La cartella di destinazione può essere cambiata all'avvio:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --push-target=/sdcard/Download/
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Inoltro dell'audio
|
||||||
|
|
||||||
|
L'audio non è inoltrato da _scrcpy_. Usa [sndcpy].
|
||||||
|
|
||||||
|
Vedi anche la [issue #14].
|
||||||
|
|
||||||
|
[sndcpy]: https://github.com/rom1v/sndcpy
|
||||||
|
[issue #14]: https://github.com/Genymobile/scrcpy/issues/14
|
||||||
|
|
||||||
|
|
||||||
|
## Scociatoie
|
||||||
|
|
||||||
|
Nella lista seguente, <kbd>MOD</kbd> è il modificatore delle scorciatoie. In maniera predefinita è <kbd>Alt</kbd> (sinistro) o <kbd>Super</kbd> (sinistro).
|
||||||
|
|
||||||
|
Può essere cambiato usando `--shortcut-mod`. I tasti possibili sono `lctrl`, `rctrl`, `lalt`, `ralt`, `lsuper` and `rsuper` (`l` significa sinistro e `r` significa destro). Per esempio:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# usa ctrl destro per le scorciatoie
|
||||||
|
scrcpy --shortcut-mod=rctrl
|
||||||
|
|
||||||
|
# use sia "ctrl sinistro"+"alt sinistro" che "super sinistro" per le scorciatoie
|
||||||
|
scrcpy --shortcut-mod=lctrl+lalt,lsuper
|
||||||
|
```
|
||||||
|
|
||||||
|
_<kbd>[Super]</kbd> è il pulsante <kbd>Windows</kbd> o <kbd>Cmd</kbd>._
|
||||||
|
|
||||||
|
[Super]: https://it.wikipedia.org/wiki/Tasto_Windows
|
||||||
|
<!-- https://en.wikipedia.org/wiki/Super_key_(keyboard_button) è la pagina originale di Wikipedia inglese, l'ho sostituita con una simile in quello italiano -->
|
||||||
|
|
||||||
|
| Azione | Scorciatoia
|
||||||
|
| ------------------------------------------- |:-----------------------------
|
||||||
|
| Schermo intero | <kbd>MOD</kbd>+<kbd>f</kbd>
|
||||||
|
| Rotazione schermo a sinistra | <kbd>MOD</kbd>+<kbd>←</kbd> _(sinistra)_
|
||||||
|
| Rotazione schermo a destra | <kbd>MOD</kbd>+<kbd>→</kbd> _(destra)_
|
||||||
|
| Ridimensiona finestra a 1:1 (pixel-perfect) | <kbd>MOD</kbd>+<kbd>g</kbd>
|
||||||
|
| Ridimensiona la finestra per rimuovere i bordi neri | <kbd>MOD</kbd>+<kbd>w</kbd> \| _Doppio click¹_
|
||||||
|
| Premi il tasto `HOME` | <kbd>MOD</kbd>+<kbd>h</kbd> \| _Click centrale_
|
||||||
|
| Premi il tasto `BACK` | <kbd>MOD</kbd>+<kbd>b</kbd> \| _Click destro²_
|
||||||
|
| Premi il tasto `APP_SWITCH` | <kbd>MOD</kbd>+<kbd>s</kbd>
|
||||||
|
| Premi il tasto `MENU` (sblocca lo schermo) | <kbd>MOD</kbd>+<kbd>m</kbd>
|
||||||
|
| Premi il tasto `VOLUME_UP` | <kbd>MOD</kbd>+<kbd>↑</kbd> _(su)_
|
||||||
|
| Premi il tasto `VOLUME_DOWN` | <kbd>MOD</kbd>+<kbd>↓</kbd> _(giù)_
|
||||||
|
| Premi il tasto `POWER` | <kbd>MOD</kbd>+<kbd>p</kbd>
|
||||||
|
| Accendi | _Click destro²_
|
||||||
|
| Spegni lo schermo del dispositivo (continua a trasmettere) | <kbd>MOD</kbd>+<kbd>o</kbd>
|
||||||
|
| Accendi lo schermo del dispositivo | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>o</kbd>
|
||||||
|
| Ruota lo schermo del dispositivo | <kbd>MOD</kbd>+<kbd>r</kbd>
|
||||||
|
| Espandi il pannello delle notifiche | <kbd>MOD</kbd>+<kbd>n</kbd>
|
||||||
|
| Chiudi il pannello delle notifiche | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>n</kbd>
|
||||||
|
| Copia negli appunti³ | <kbd>MOD</kbd>+<kbd>c</kbd>
|
||||||
|
| Taglia negli appunti³ | <kbd>MOD</kbd>+<kbd>x</kbd>
|
||||||
|
| Sincronizza gli appunti e incolla³ | <kbd>MOD</kbd>+<kbd>v</kbd>
|
||||||
|
| Inietta il testo degli appunti del computer | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>
|
||||||
|
| Abilita/Disabilita il contatore FPS (su stdout) | <kbd>MOD</kbd>+<kbd>i</kbd>
|
||||||
|
| Pizzica per zoomare | <kbd>Ctrl</kbd>+_click e trascina_
|
||||||
|
|
||||||
|
_¹Doppio click sui bordi neri per rimuoverli._
|
||||||
|
_²Il tasto destro accende lo schermo se era spento, preme BACK in caso contrario._
|
||||||
|
_³Solo in Android >= 7._
|
||||||
|
|
||||||
|
Tutte le scorciatoie <kbd>Ctrl</kbd>+_tasto_ sono inoltrate al dispositivo, così sono gestite dall'applicazione attiva.
|
||||||
|
|
||||||
|
## Path personalizzati
|
||||||
|
|
||||||
|
Per utilizzare dei binari _adb_ specifici, configura il suo path nella variabile d'ambente `ADB`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ADB=/percorso/per/adb scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Per sovrascrivere il percorso del file `scrcpy-server`, configura il percorso in `SCRCPY_SERVER_PATH`.
|
||||||
|
|
||||||
|
## Perchè _scrcpy_?
|
||||||
|
|
||||||
|
Un collega mi ha sfidato a trovare un nome tanto impronunciabile quanto [gnirehtet].
|
||||||
|
|
||||||
|
[`strcpy`] copia una **str**ing (stringa); `scrcpy` copia uno **scr**een (schermo).
|
||||||
|
|
||||||
|
[gnirehtet]: https://github.com/Genymobile/gnirehtet
|
||||||
|
[`strcpy`]: http://man7.org/linux/man-pages/man3/strcpy.3.html
|
||||||
|
|
||||||
|
## Come compilare?
|
||||||
|
|
||||||
|
Vedi [BUILD] (in inglese).
|
||||||
|
|
||||||
|
|
||||||
|
## Problemi comuni
|
||||||
|
|
||||||
|
Vedi le [FAQ](FAQ.it.md).
|
||||||
|
|
||||||
|
|
||||||
|
## Sviluppatori
|
||||||
|
|
||||||
|
Leggi la [pagina per sviluppatori].
|
||||||
|
|
||||||
|
[pagina per sviluppatori]: DEVELOP.md
|
||||||
|
|
||||||
|
|
||||||
|
## Licenza (in inglese)
|
||||||
|
|
||||||
|
Copyright (C) 2018 Genymobile
|
||||||
|
Copyright (C) 2018-2021 Romain Vimont
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
## Articoli (in inglese)
|
||||||
|
|
||||||
|
- [Introducendo scrcpy][article-intro]
|
||||||
|
- [Scrcpy ora funziona wireless][article-tcpip]
|
||||||
|
|
||||||
|
[article-intro]: https://blog.rom1v.com/2018/03/introducing-scrcpy/
|
||||||
|
[article-tcpip]: https://www.genymotion.com/blog/open-source-project-scrcpy-now-works-wirelessly/
|
@ -112,7 +112,7 @@ scrcpy --help
|
|||||||
### 캡쳐 환경 설정
|
### 캡쳐 환경 설정
|
||||||
|
|
||||||
|
|
||||||
###사이즈 재정의
|
### 사이즈 재정의
|
||||||
|
|
||||||
가끔씩 성능을 향상시키기위해 안드로이드 디바이스를 낮은 해상도에서 미러링하는 것이 유용할 때도 있습니다.
|
가끔씩 성능을 향상시키기위해 안드로이드 디바이스를 낮은 해상도에서 미러링하는 것이 유용할 때도 있습니다.
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ scrcpy --bit-rate 2M
|
|||||||
scrcpy -b 2M # 축약 버전
|
scrcpy -b 2M # 축약 버전
|
||||||
```
|
```
|
||||||
|
|
||||||
###프레임 비율 제한
|
### 프레임 비율 제한
|
||||||
|
|
||||||
안드로이드 버전 10이상의 디바이스에서는, 다음의 명령어로 캡쳐 화면의 프레임 비율을 제한할 수 있습니다:
|
안드로이드 버전 10이상의 디바이스에서는, 다음의 명령어로 캡쳐 화면의 프레임 비율을 제한할 수 있습니다:
|
||||||
|
|
||||||
|
16
README.md
16
README.md
@ -1,4 +1,4 @@
|
|||||||
# scrcpy (v1.17)
|
# scrcpy (v1.18)
|
||||||
|
|
||||||
[Read in another language](#translations)
|
[Read in another language](#translations)
|
||||||
|
|
||||||
@ -88,10 +88,10 @@ process][BUILD_simple]).
|
|||||||
For Windows, for simplicity, a prebuilt archive with all the dependencies
|
For Windows, for simplicity, a prebuilt archive with all the dependencies
|
||||||
(including `adb`) is available:
|
(including `adb`) is available:
|
||||||
|
|
||||||
- [`scrcpy-win64-v1.17.zip`][direct-win64]
|
- [`scrcpy-win64-v1.18.zip`][direct-win64]
|
||||||
_(SHA-256: 8b9e57993c707367ed10ebfe0e1ef563c7a29d9af4a355cd8b6a52a317c73eea)_
|
_(SHA-256: 37212f5087fe6f3e258f1d44fa5c02207496b30e1d7ec442cbcf8358910a5c63)_
|
||||||
|
|
||||||
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v1.17/scrcpy-win64-v1.17.zip
|
[direct-win64]: https://github.com/Genymobile/scrcpy/releases/download/v1.18/scrcpy-win64-v1.18.zip
|
||||||
|
|
||||||
It is also available in [Chocolatey]:
|
It is also available in [Chocolatey]:
|
||||||
|
|
||||||
@ -516,7 +516,7 @@ scrcpy --display 1
|
|||||||
|
|
||||||
The list of display ids can be retrieved by:
|
The list of display ids can be retrieved by:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
adb shell dumpsys display # search "mDisplayId=" in the output
|
adb shell dumpsys display # search "mDisplayId=" in the output
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -801,7 +801,9 @@ handled by the active application.
|
|||||||
To use a specific _adb_ binary, configure its path in the environment variable
|
To use a specific _adb_ binary, configure its path in the environment variable
|
||||||
`ADB`:
|
`ADB`:
|
||||||
|
|
||||||
ADB=/path/to/adb scrcpy
|
```bash
|
||||||
|
ADB=/path/to/adb scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
To override the path of the `scrcpy-server` file, configure its path in
|
To override the path of the `scrcpy-server` file, configure its path in
|
||||||
`SCRCPY_SERVER_PATH`.
|
`SCRCPY_SERVER_PATH`.
|
||||||
@ -866,9 +868,11 @@ Read the [developers page].
|
|||||||
This README is available in other languages:
|
This README is available in other languages:
|
||||||
|
|
||||||
- [Indonesian (Indonesia, `id`) - v1.16](README.id.md)
|
- [Indonesian (Indonesia, `id`) - v1.16](README.id.md)
|
||||||
|
- [Italiano (Italiano, `it`) - v1.17](README.it.md)
|
||||||
- [日本語 (Japanese, `jp`) - v1.17](README.jp.md)
|
- [日本語 (Japanese, `jp`) - v1.17](README.jp.md)
|
||||||
- [한국어 (Korean, `ko`) - v1.11](README.ko.md)
|
- [한국어 (Korean, `ko`) - v1.11](README.ko.md)
|
||||||
- [português brasileiro (Brazilian Portuguese, `pt-BR`) - v1.17](README.pt-br.md)
|
- [português brasileiro (Brazilian Portuguese, `pt-BR`) - v1.17](README.pt-br.md)
|
||||||
|
- [Español (Spanish, `sp`) - v1.17](README.sp.md)
|
||||||
- [简体中文 (Simplified Chinese, `zh-Hans`) - v1.17](README.zh-Hans.md)
|
- [简体中文 (Simplified Chinese, `zh-Hans`) - v1.17](README.zh-Hans.md)
|
||||||
- [繁體中文 (Traditional Chinese, `zh-Hant`) - v1.15](README.zh-Hant.md)
|
- [繁體中文 (Traditional Chinese, `zh-Hant`) - v1.15](README.zh-Hant.md)
|
||||||
|
|
||||||
|
743
README.sp.md
Normal file
743
README.sp.md
Normal file
@ -0,0 +1,743 @@
|
|||||||
|
Solo se garantiza que el archivo [README](README.md) original esté actualizado.
|
||||||
|
|
||||||
|
# scrcpy (v1.17)
|
||||||
|
|
||||||
|
Esta aplicación proporciona imagen y control de un dispositivo Android conectado
|
||||||
|
por USB (o [por TCP/IP][article-tcpip]). No requiere acceso _root_.
|
||||||
|
Compatible con _GNU/Linux_, _Windows_ y _macOS_.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Sus características principales son:
|
||||||
|
|
||||||
|
- **ligero** (nativo, solo muestra la imagen del dispositivo)
|
||||||
|
- **desempeño** (30~60fps)
|
||||||
|
- **calidad** (1920×1080 o superior)
|
||||||
|
- **baja latencia** ([35~70ms][lowlatency])
|
||||||
|
- **corto tiempo de inicio** (~1 segundo para mostrar la primera imagen)
|
||||||
|
- **no intrusivo** (no se deja nada instalado en el dispositivo)
|
||||||
|
|
||||||
|
[lowlatency]: https://github.com/Genymobile/scrcpy/pull/646
|
||||||
|
|
||||||
|
|
||||||
|
## Requisitos
|
||||||
|
|
||||||
|
El dispositivo Android requiere como mínimo API 21 (Android 5.0).
|
||||||
|
|
||||||
|
Asegurate de [habilitar el adb debugging][enable-adb] en tu(s) dispositivo(s).
|
||||||
|
|
||||||
|
[enable-adb]: https://developer.android.com/studio/command-line/adb.html#Enabling
|
||||||
|
|
||||||
|
En algunos dispositivos, también necesitas habilitar [una opción adicional][control] para controlarlo con el teclado y ratón.
|
||||||
|
|
||||||
|
[control]: https://github.com/Genymobile/scrcpy/issues/70#issuecomment-373286323
|
||||||
|
|
||||||
|
|
||||||
|
## Consigue la app
|
||||||
|
|
||||||
|
<a href="https://repology.org/project/scrcpy/versions"><img src="https://repology.org/badge/vertical-allrepos/scrcpy.svg" alt="Packaging status" align="right"></a>
|
||||||
|
|
||||||
|
### Resumen
|
||||||
|
|
||||||
|
- Linux: `apt install scrcpy`
|
||||||
|
- Windows: [download](README.md#windows)
|
||||||
|
- macOS: `brew install scrcpy`
|
||||||
|
|
||||||
|
Construir desde la fuente: [BUILD] ([proceso simplificado][BUILD_simple])
|
||||||
|
|
||||||
|
[BUILD]: BUILD.md
|
||||||
|
[BUILD_simple]: BUILD.md#simple
|
||||||
|
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
En Debian (_test_ y _sid_ por ahora) y Ubuntu (20.04):
|
||||||
|
|
||||||
|
```
|
||||||
|
apt install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Hay un paquete [Snap]: [`scrcpy`][snap-link].
|
||||||
|
|
||||||
|
[snap-link]: https://snapstats.org/snaps/scrcpy
|
||||||
|
|
||||||
|
[snap]: https://en.wikipedia.org/wiki/Snappy_(package_manager)
|
||||||
|
|
||||||
|
Para Fedora, hay un paquete [COPR]: [`scrcpy`][copr-link].
|
||||||
|
|
||||||
|
[COPR]: https://fedoraproject.org/wiki/Category:Copr
|
||||||
|
[copr-link]: https://copr.fedorainfracloud.org/coprs/zeno/scrcpy/
|
||||||
|
|
||||||
|
Para Arch Linux, hay un paquete [AUR]: [`scrcpy`][aur-link].
|
||||||
|
|
||||||
|
[AUR]: https://wiki.archlinux.org/index.php/Arch_User_Repository
|
||||||
|
[aur-link]: https://aur.archlinux.org/packages/scrcpy/
|
||||||
|
|
||||||
|
Para Gentoo, hay un paquete [Ebuild]: [`scrcpy/`][ebuild-link].
|
||||||
|
|
||||||
|
[Ebuild]: https://wiki.gentoo.org/wiki/Ebuild
|
||||||
|
[ebuild-link]: https://github.com/maggu2810/maggu2810-overlay/tree/master/app-mobilephone/scrcpy
|
||||||
|
|
||||||
|
También puedes [construir la aplicación manualmente][BUILD] ([proceso simplificado][BUILD_simple]).
|
||||||
|
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
|
||||||
|
Para Windows, por simplicidad, hay un pre-compilado con todas las dependencias
|
||||||
|
(incluyendo `adb`):
|
||||||
|
|
||||||
|
- [README](README.md#windows)
|
||||||
|
|
||||||
|
También está disponible en [Chocolatey]:
|
||||||
|
|
||||||
|
[Chocolatey]: https://chocolatey.org/
|
||||||
|
|
||||||
|
```bash
|
||||||
|
choco install scrcpy
|
||||||
|
choco install adb # si aún no está instalado
|
||||||
|
```
|
||||||
|
|
||||||
|
Y en [Scoop]:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scoop install scrcpy
|
||||||
|
scoop install adb # si aún no está instalado
|
||||||
|
```
|
||||||
|
|
||||||
|
[Scoop]: https://scoop.sh
|
||||||
|
|
||||||
|
También puedes [construir la aplicación manualmente][BUILD].
|
||||||
|
|
||||||
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
La aplicación está disponible en [Homebrew]. Solo instalala:
|
||||||
|
|
||||||
|
[Homebrew]: https://brew.sh/
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Necesitarás `adb`, accesible desde `PATH`. Si aún no lo tienes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
brew install android-platform-tools
|
||||||
|
```
|
||||||
|
|
||||||
|
También está disponible en [MacPorts], que configurará el adb automáticamente:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo port install scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
[MacPorts]: https://www.macports.org/
|
||||||
|
|
||||||
|
|
||||||
|
También puedes [construir la aplicación manualmente][BUILD].
|
||||||
|
|
||||||
|
|
||||||
|
## Ejecutar
|
||||||
|
|
||||||
|
Enchufa el dispositivo Android, y ejecuta:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Acepta argumentos desde la línea de comandos, listados en:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Características
|
||||||
|
|
||||||
|
### Capturar configuración
|
||||||
|
|
||||||
|
#### Reducir la definición
|
||||||
|
|
||||||
|
A veces es útil reducir la definición de la imagen del dispositivo Android para aumentar el desempeño.
|
||||||
|
|
||||||
|
Para limitar el ancho y la altura a un valor específico (ej. 1024):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --max-size 1024
|
||||||
|
scrcpy -m 1024 # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
La otra dimensión es calculada para conservar el aspect ratio del dispositivo.
|
||||||
|
De esta forma, un dispositivo en 1920×1080 será transmitido a 1024×576.
|
||||||
|
|
||||||
|
|
||||||
|
#### Cambiar el bit-rate
|
||||||
|
|
||||||
|
El bit-rate por defecto es 8 Mbps. Para cambiar el bit-rate del video (ej. a 2 Mbps):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --bit-rate 2M
|
||||||
|
scrcpy -b 2M # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Limitar los fps
|
||||||
|
|
||||||
|
El fps puede ser limitado:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --max-fps 15
|
||||||
|
```
|
||||||
|
|
||||||
|
Es oficialmente soportado desde Android 10, pero puede funcionar en versiones anteriores.
|
||||||
|
|
||||||
|
#### Recortar
|
||||||
|
|
||||||
|
La imagen del dispositivo puede ser recortada para transmitir solo una parte de la pantalla.
|
||||||
|
|
||||||
|
Por ejemplo, puede ser útil para transmitir la imagen de un solo ojo del Oculus Go:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --crop 1224:1440:0:0 # 1224x1440 con coordenadas de origen en (0,0)
|
||||||
|
```
|
||||||
|
|
||||||
|
Si `--max-size` también está especificado, el cambio de tamaño es aplicado después de cortar.
|
||||||
|
|
||||||
|
|
||||||
|
#### Fijar la rotación del video
|
||||||
|
|
||||||
|
|
||||||
|
Para fijar la rotación de la transmisión:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --lock-video-orientation 0 # orientación normal
|
||||||
|
scrcpy --lock-video-orientation 1 # 90° contrarreloj
|
||||||
|
scrcpy --lock-video-orientation 2 # 180°
|
||||||
|
scrcpy --lock-video-orientation 3 # 90° sentido de las agujas del reloj
|
||||||
|
```
|
||||||
|
|
||||||
|
Esto afecta la rotación de la grabación.
|
||||||
|
|
||||||
|
La [ventana también puede ser rotada](#rotación) independientemente.
|
||||||
|
|
||||||
|
|
||||||
|
#### Codificador
|
||||||
|
|
||||||
|
Algunos dispositivos pueden tener más de una rotación, y algunos pueden causar problemas o errores. Es posible seleccionar un codificador diferente:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --encoder OMX.qcom.video.encoder.avc
|
||||||
|
```
|
||||||
|
|
||||||
|
Para listar los codificadores disponibles, puedes pasar un nombre de codificador inválido, el error te dará los codificadores disponibles:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --encoder _
|
||||||
|
```
|
||||||
|
|
||||||
|
### Grabación
|
||||||
|
|
||||||
|
Es posible grabar la pantalla mientras se transmite:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --record file.mp4
|
||||||
|
scrcpy -r file.mkv
|
||||||
|
```
|
||||||
|
|
||||||
|
Para grabar sin transmitir la pantalla:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-display --record file.mp4
|
||||||
|
scrcpy -Nr file.mkv
|
||||||
|
# interrumpe la grabación con Ctrl+C
|
||||||
|
```
|
||||||
|
|
||||||
|
"Skipped frames" son grabados, incluso si no son mostrados en tiempo real (por razones de desempeño). Los frames tienen _marcas de tiempo_ en el dispositivo, por lo que el "[packet delay
|
||||||
|
variation]" no impacta el archivo grabado.
|
||||||
|
|
||||||
|
[packet delay variation]: https://en.wikipedia.org/wiki/Packet_delay_variation
|
||||||
|
|
||||||
|
|
||||||
|
### Conexión
|
||||||
|
|
||||||
|
#### Inalámbrica
|
||||||
|
|
||||||
|
_Scrcpy_ usa `adb` para comunicarse con el dispositivo, y `adb` puede [conectarse] vía TCP/IP:
|
||||||
|
|
||||||
|
1. Conecta el dispositivo al mismo Wi-Fi que tu computadora.
|
||||||
|
2. Obtén la dirección IP del dispositivo, en Ajustes → Acerca del dispositivo → Estado, o ejecutando este comando:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb shell ip route | awk '{print $9}'
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Habilita adb vía TCP/IP en el dispositivo: `adb tcpip 5555`.
|
||||||
|
4. Desenchufa el dispositivo.
|
||||||
|
5. Conéctate a tu dispositivo: `adb connect IP_DEL_DISPOSITIVO:5555` _(reemplaza `IP_DEL_DISPOSITIVO`)_.
|
||||||
|
6. Ejecuta `scrcpy` con normalidad.
|
||||||
|
|
||||||
|
Podría resultar útil reducir el bit-rate y la definición:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --bit-rate 2M --max-size 800
|
||||||
|
scrcpy -b2M -m800 # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
[conectarse]: https://developer.android.com/studio/command-line/adb.html#wireless
|
||||||
|
|
||||||
|
|
||||||
|
#### Múltiples dispositivos
|
||||||
|
|
||||||
|
Si hay muchos dispositivos listados en `adb devices`, será necesario especificar el _número de serie_:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --serial 0123456789abcdef
|
||||||
|
scrcpy -s 0123456789abcdef # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Si el dispositivo está conectado por TCP/IP:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --serial 192.168.0.1:5555
|
||||||
|
scrcpy -s 192.168.0.1:5555 # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Puedes iniciar múltiples instancias de _scrcpy_ para múltiples dispositivos.
|
||||||
|
|
||||||
|
#### Autoiniciar al detectar dispositivo
|
||||||
|
|
||||||
|
Puedes utilizar [AutoAdb]:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
autoadb scrcpy -s '{}'
|
||||||
|
```
|
||||||
|
|
||||||
|
[AutoAdb]: https://github.com/rom1v/autoadb
|
||||||
|
|
||||||
|
#### Túnel SSH
|
||||||
|
|
||||||
|
Para conectarse a un dispositivo remoto, es posible conectar un cliente local de `adb` a un servidor remoto `adb` (siempre y cuando utilicen la misma versión de protocolos _adb_):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb kill-server # cierra el servidor local adb en 5037
|
||||||
|
ssh -CN -L5037:localhost:5037 -R27183:localhost:27183 your_remote_computer
|
||||||
|
# conserva este servidor abierto
|
||||||
|
```
|
||||||
|
|
||||||
|
Desde otra terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Para evitar habilitar "remote port forwarding", puedes forzar una "forward connection" (nótese el argumento `-L` en vez de `-R`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb kill-server # cierra el servidor local adb en 5037
|
||||||
|
ssh -CN -L5037:localhost:5037 -L27183:localhost:27183 your_remote_computer
|
||||||
|
# conserva este servidor abierto
|
||||||
|
```
|
||||||
|
|
||||||
|
Desde otra terminal:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --force-adb-forward
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Al igual que las conexiones inalámbricas, puede resultar útil reducir la calidad:
|
||||||
|
|
||||||
|
```
|
||||||
|
scrcpy -b2M -m800 --max-fps 15
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuración de la ventana
|
||||||
|
|
||||||
|
#### Título
|
||||||
|
|
||||||
|
Por defecto, el título de la ventana es el modelo del dispositivo. Puede ser modificado:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-title 'My device'
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Posición y tamaño
|
||||||
|
|
||||||
|
La posición y tamaño inicial de la ventana puede ser especificado:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-x 100 --window-y 100 --window-width 800 --window-height 600
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Sin bordes
|
||||||
|
|
||||||
|
Para deshabilitar el diseño de la ventana:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --window-borderless
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Siempre adelante
|
||||||
|
|
||||||
|
Para mantener la ventana de scrcpy siempre adelante:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --always-on-top
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Pantalla completa
|
||||||
|
|
||||||
|
La aplicación puede ser iniciada en pantalla completa:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --fullscreen
|
||||||
|
scrcpy -f # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Puede entrar y salir de la pantalla completa con la combinación <kbd>MOD</kbd>+<kbd>f</kbd>.
|
||||||
|
|
||||||
|
#### Rotación
|
||||||
|
|
||||||
|
Se puede rotar la ventana:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --rotation 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Los valores posibles son:
|
||||||
|
- `0`: sin rotación
|
||||||
|
- `1`: 90 grados contrarreloj
|
||||||
|
- `2`: 180 grados
|
||||||
|
- `3`: 90 grados en sentido de las agujas del reloj
|
||||||
|
|
||||||
|
La rotación también puede ser modificada con la combinación de teclas <kbd>MOD</kbd>+<kbd>←</kbd> _(izquierda)_ y <kbd>MOD</kbd>+<kbd>→</kbd> _(derecha)_.
|
||||||
|
|
||||||
|
Nótese que _scrcpy_ maneja 3 diferentes rotaciones:
|
||||||
|
- <kbd>MOD</kbd>+<kbd>r</kbd> solicita al dispositivo cambiar entre vertical y horizontal (la aplicación en uso puede rechazarlo si no soporta la orientación solicitada).
|
||||||
|
- [`--lock-video-orientation`](#fijar-la-rotación-del-video) cambia la rotación de la transmisión (la orientación del video enviado a la PC). Esto afecta a la grabación.
|
||||||
|
- `--rotation` (o <kbd>MOD</kbd>+<kbd>←</kbd>/<kbd>MOD</kbd>+<kbd>→</kbd>) rota solo el contenido de la imagen. Esto solo afecta a la imagen mostrada, no a la grabación.
|
||||||
|
|
||||||
|
|
||||||
|
### Otras opciones menores
|
||||||
|
|
||||||
|
#### Solo lectura ("Read-only")
|
||||||
|
|
||||||
|
Para deshabilitar los controles (todo lo que interactúe con el dispositivo: eventos del teclado, eventos del mouse, arrastrar y soltar archivos):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-control
|
||||||
|
scrcpy -n # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Pantalla
|
||||||
|
|
||||||
|
Si múltiples pantallas están disponibles, es posible elegir cual transmitir:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --display 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Los ids de las pantallas se pueden obtener con el siguiente comando:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb shell dumpsys display # busque "mDisplayId=" en la respuesta
|
||||||
|
```
|
||||||
|
|
||||||
|
La segunda pantalla solo puede ser manejada si el dispositivo cuenta con Android 10 (en caso contrario será transmitida en el modo solo lectura).
|
||||||
|
|
||||||
|
|
||||||
|
#### Permanecer activo
|
||||||
|
|
||||||
|
Para evitar que el dispositivo descanse después de un tiempo mientras está conectado:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --stay-awake
|
||||||
|
scrcpy -w # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
La configuración original se restaura al cerrar scrcpy.
|
||||||
|
|
||||||
|
|
||||||
|
#### Apagar la pantalla
|
||||||
|
|
||||||
|
Es posible apagar la pantalla mientras se transmite al iniciar con el siguiente comando:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --turn-screen-off
|
||||||
|
scrcpy -S # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
O presionando <kbd>MOD</kbd>+<kbd>o</kbd> en cualquier momento.
|
||||||
|
|
||||||
|
Para volver a prenderla, presione <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>o</kbd>.
|
||||||
|
|
||||||
|
En Android, el botón de `POWER` siempre prende la pantalla. Por conveniencia, si `POWER` es enviado vía scrcpy (con click-derecho o <kbd>MOD</kbd>+<kbd>p</kbd>), esto forzará a apagar la pantalla con un poco de atraso (en la mejor de las situaciones). El botón físico `POWER` seguirá prendiendo la pantalla.
|
||||||
|
|
||||||
|
También puede resultar útil para evitar que el dispositivo entre en inactividad:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --turn-screen-off --stay-awake
|
||||||
|
scrcpy -Sw # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Renderizar frames vencidos
|
||||||
|
|
||||||
|
Por defecto, para minimizar la latencia, _scrcpy_ siempre renderiza el último frame disponible decodificado, e ignora cualquier frame anterior.
|
||||||
|
|
||||||
|
Para forzar el renderizado de todos los frames (a costo de posible aumento de latencia), use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --render-expired-frames
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Mostrar clicks
|
||||||
|
|
||||||
|
Para presentaciones, puede resultar útil mostrar los clicks físicos (en el dispositivo físicamente).
|
||||||
|
|
||||||
|
Android provee esta opción en _Opciones para desarrolladores_.
|
||||||
|
|
||||||
|
_Scrcpy_ provee una opción para habilitar esta función al iniciar la aplicación y restaurar el valor original al salir:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --show-touches
|
||||||
|
scrcpy -t # versión breve
|
||||||
|
```
|
||||||
|
|
||||||
|
Nótese que solo muestra los clicks _físicos_ (con el dedo en el dispositivo).
|
||||||
|
|
||||||
|
|
||||||
|
#### Desactivar protector de pantalla
|
||||||
|
|
||||||
|
Por defecto, scrcpy no evita que el protector de pantalla se active en la computadora.
|
||||||
|
|
||||||
|
Para deshabilitarlo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --disable-screensaver
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Control
|
||||||
|
|
||||||
|
#### Rotar pantalla del dispositivo
|
||||||
|
|
||||||
|
Presione <kbd>MOD</kbd>+<kbd>r</kbd> para cambiar entre posición vertical y horizontal.
|
||||||
|
|
||||||
|
Nótese que solo rotará si la aplicación activa soporta la orientación solicitada.
|
||||||
|
|
||||||
|
#### Copiar y pegar
|
||||||
|
|
||||||
|
Cuando que el portapapeles de Android cambia, automáticamente se sincroniza al portapapeles de la computadora.
|
||||||
|
|
||||||
|
Cualquier shortcut con <kbd>Ctrl</kbd> es enviado al dispositivo. En particular:
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>c</kbd> normalmente copia
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>x</kbd> normalmente corta
|
||||||
|
- <kbd>Ctrl</kbd>+<kbd>v</kbd> normalmente pega (después de la sincronización de portapapeles entre la computadora y el dispositivo)
|
||||||
|
|
||||||
|
Esto normalmente funciona como es esperado.
|
||||||
|
|
||||||
|
Sin embargo, este comportamiento depende de la aplicación en uso. Por ejemplo, _Termux_ envía SIGINT con <kbd>Ctrl</kbd>+<kbd>c</kbd>, y _K-9 Mail_ crea un nuevo mensaje.
|
||||||
|
|
||||||
|
Para copiar, cortar y pegar, en tales casos (solo soportado en Android >= 7):
|
||||||
|
- <kbd>MOD</kbd>+<kbd>c</kbd> inyecta `COPY`
|
||||||
|
- <kbd>MOD</kbd>+<kbd>x</kbd> inyecta `CUT`
|
||||||
|
- <kbd>MOD</kbd>+<kbd>v</kbd> inyecta `PASTE` (después de la sincronización de portapapeles entre la computadora y el dispositivo)
|
||||||
|
|
||||||
|
Además, <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd> permite inyectar el texto en el portapapeles de la computadora como una secuencia de teclas. Esto es útil cuando el componente no acepta pegado de texto (por ejemplo en _Termux_), pero puede romper caracteres no pertenecientes a ASCII.
|
||||||
|
|
||||||
|
**AVISO:** Pegar de la computadora al dispositivo (tanto con <kbd>Ctrl</kbd>+<kbd>v</kbd> o <kbd>MOD</kbd>+<kbd>v</kbd>) copia el contenido al portapapeles del dispositivo. Como consecuencia, cualquier aplicación de Android puede leer su contenido. Debería evitar pegar contenido sensible (como contraseñas) de esta forma.
|
||||||
|
|
||||||
|
Algunos dispositivos no se comportan como es esperado al establecer el portapapeles programáticamente. La opción `--legacy-paste` está disponible para cambiar el comportamiento de <kbd>Ctrl</kbd>+<kbd>v</kbd> y <kbd>MOD</kbd>+<kbd>v</kbd> para que también inyecten el texto del portapapeles de la computadora como una secuencia de teclas (de la misma forma que <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>).
|
||||||
|
|
||||||
|
#### Pellizcar para zoom
|
||||||
|
|
||||||
|
Para simular "pinch-to-zoom": <kbd>Ctrl</kbd>+_click-y-mover_.
|
||||||
|
|
||||||
|
Más precisamente, mantén <kbd>Ctrl</kbd> mientras presionas botón izquierdo. Hasta que no se suelte el botón, todos los movimientos del mouse cambiarán el tamaño y rotación del contenido (si es soportado por la app en uso) respecto al centro de la pantalla.
|
||||||
|
|
||||||
|
Concretamente, scrcpy genera clicks adicionales con un "dedo virtual" en la posición invertida respecto al centro de la pantalla.
|
||||||
|
|
||||||
|
|
||||||
|
#### Preferencias de inyección de texto
|
||||||
|
|
||||||
|
Existen dos tipos de [eventos][textevents] generados al escribir texto:
|
||||||
|
- _key events_, marcando si la tecla es presionada o soltada;
|
||||||
|
- _text events_, marcando si un texto fue introducido.
|
||||||
|
|
||||||
|
Por defecto, las letras son inyectadas usando _key events_, para que el teclado funcione como es esperado en juegos (típicamente las teclas WASD).
|
||||||
|
|
||||||
|
Pero esto puede [causar problemas][prefertext]. Si encuentras tales problemas, los puedes evitar con:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --prefer-text
|
||||||
|
```
|
||||||
|
|
||||||
|
(Pero esto romperá el comportamiento del teclado en los juegos)
|
||||||
|
|
||||||
|
[textevents]: https://blog.rom1v.com/2018/03/introducing-scrcpy/#handle-text-input
|
||||||
|
[prefertext]: https://github.com/Genymobile/scrcpy/issues/650#issuecomment-512945343
|
||||||
|
|
||||||
|
|
||||||
|
#### Repetir tecla
|
||||||
|
|
||||||
|
Por defecto, mantener una tecla presionada genera múltiples _key events_. Esto puede causar problemas de desempeño en algunos juegos, donde estos eventos no tienen sentido de todos modos.
|
||||||
|
|
||||||
|
Para evitar enviar _key events_ repetidos:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --no-key-repeat
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Botón derecho y botón del medio
|
||||||
|
|
||||||
|
Por defecto, botón derecho ejecuta RETROCEDER (o ENCENDIDO) y botón del medio INICIO. Para inhabilitar estos atajos y enviar los clicks al dispositivo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --forward-all-clicks
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Arrastrar y soltar archivos
|
||||||
|
|
||||||
|
#### Instalar APKs
|
||||||
|
|
||||||
|
Para instalar un APK, arrastre y suelte el archivo APK (terminado en `.apk`) a la ventana de _scrcpy_.
|
||||||
|
|
||||||
|
No hay respuesta visual, un mensaje se escribirá en la consola.
|
||||||
|
|
||||||
|
|
||||||
|
#### Enviar archivos al dispositivo
|
||||||
|
|
||||||
|
Para enviar un archivo a `/sdcard/` en el dispositivo, arrastre y suelte un archivo (no APK) a la ventana de _scrcpy_.
|
||||||
|
|
||||||
|
No hay respuesta visual, un mensaje se escribirá en la consola.
|
||||||
|
|
||||||
|
El directorio de destino puede ser modificado al iniciar:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scrcpy --push-target=/sdcard/Download/
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Envío de Audio
|
||||||
|
|
||||||
|
_Scrcpy_ no envía el audio. Use [sndcpy].
|
||||||
|
|
||||||
|
También lea [issue #14].
|
||||||
|
|
||||||
|
[sndcpy]: https://github.com/rom1v/sndcpy
|
||||||
|
[issue #14]: https://github.com/Genymobile/scrcpy/issues/14
|
||||||
|
|
||||||
|
|
||||||
|
## Atajos
|
||||||
|
|
||||||
|
En la siguiente lista, <kbd>MOD</kbd> es el atajo modificador. Por defecto es <kbd>Alt</kbd> (izquierdo) o <kbd>Super</kbd> (izquierdo).
|
||||||
|
|
||||||
|
Se puede modificar usando `--shortcut-mod`. Las posibles teclas son `lctrl` (izquierdo), `rctrl` (derecho), `lalt` (izquierdo), `ralt` (derecho), `lsuper` (izquierdo) y `rsuper` (derecho). Por ejemplo:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# use RCtrl para los atajos
|
||||||
|
scrcpy --shortcut-mod=rctrl
|
||||||
|
|
||||||
|
# use tanto LCtrl+LAlt o LSuper para los atajos
|
||||||
|
scrcpy --shortcut-mod=lctrl+lalt,lsuper
|
||||||
|
```
|
||||||
|
|
||||||
|
_<kbd>[Super]</kbd> es generalmente la tecla <kbd>Windows</kbd> o <kbd>Cmd</kbd>._
|
||||||
|
|
||||||
|
[Super]: https://en.wikipedia.org/wiki/Super_key_(keyboard_button)
|
||||||
|
|
||||||
|
| Acción | Atajo
|
||||||
|
| ------------------------------------------- |:-----------------------------
|
||||||
|
| Alterne entre pantalla compelta | <kbd>MOD</kbd>+<kbd>f</kbd>
|
||||||
|
| Rotar pantalla hacia la izquierda | <kbd>MOD</kbd>+<kbd>←</kbd> _(izquierda)_
|
||||||
|
| Rotar pantalla hacia la derecha | <kbd>MOD</kbd>+<kbd>→</kbd> _(derecha)_
|
||||||
|
| Ajustar ventana a 1:1 ("pixel-perfect") | <kbd>MOD</kbd>+<kbd>g</kbd>
|
||||||
|
| Ajustar ventana para quitar los bordes negros| <kbd>MOD</kbd>+<kbd>w</kbd> \| _Doble click¹_
|
||||||
|
| Click en `INICIO` | <kbd>MOD</kbd>+<kbd>h</kbd> \| _Botón del medio_
|
||||||
|
| Click en `RETROCEDER` | <kbd>MOD</kbd>+<kbd>b</kbd> \| _Botón derecho²_
|
||||||
|
| Click en `CAMBIAR APLICACIÓN` | <kbd>MOD</kbd>+<kbd>s</kbd>
|
||||||
|
| Click en `MENÚ` (desbloquear pantalla) | <kbd>MOD</kbd>+<kbd>m</kbd>
|
||||||
|
| Click en `SUBIR VOLUMEN` | <kbd>MOD</kbd>+<kbd>↑</kbd> _(arriba)_
|
||||||
|
| Click en `BAJAR VOLUME` | <kbd>MOD</kbd>+<kbd>↓</kbd> _(abajo)_
|
||||||
|
| Click en `ENCENDIDO` | <kbd>MOD</kbd>+<kbd>p</kbd>
|
||||||
|
| Encendido | _Botón derecho²_
|
||||||
|
| Apagar pantalla (manteniendo la transmisión)| <kbd>MOD</kbd>+<kbd>o</kbd>
|
||||||
|
| Encender pantalla | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>o</kbd>
|
||||||
|
| Rotar pantalla del dispositivo | <kbd>MOD</kbd>+<kbd>r</kbd>
|
||||||
|
| Abrir panel de notificaciones | <kbd>MOD</kbd>+<kbd>n</kbd>
|
||||||
|
| Cerrar panel de notificaciones | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>n</kbd>
|
||||||
|
| Copiar al portapapeles³ | <kbd>MOD</kbd>+<kbd>c</kbd>
|
||||||
|
| Cortar al portapapeles³ | <kbd>MOD</kbd>+<kbd>x</kbd>
|
||||||
|
| Synchronizar portapapeles y pegar³ | <kbd>MOD</kbd>+<kbd>v</kbd>
|
||||||
|
| inyectar texto del portapapeles de la PC | <kbd>MOD</kbd>+<kbd>Shift</kbd>+<kbd>v</kbd>
|
||||||
|
| Habilitar/Deshabilitar contador de FPS (en stdout) | <kbd>MOD</kbd>+<kbd>i</kbd>
|
||||||
|
| Pellizcar para zoom | <kbd>Ctrl</kbd>+_click-y-mover_
|
||||||
|
|
||||||
|
_¹Doble click en los bordes negros para eliminarlos._
|
||||||
|
_²Botón derecho enciende la pantalla si estaba apagada, sino ejecuta RETROCEDER._
|
||||||
|
_³Solo en Android >= 7._
|
||||||
|
|
||||||
|
Todos los atajos <kbd>Ctrl</kbd>+_tecla_ son enviados al dispositivo para que sean manejados por la aplicación activa.
|
||||||
|
|
||||||
|
|
||||||
|
## Path personalizado
|
||||||
|
|
||||||
|
Para usar un binario de _adb_ en particular, configure el path `ADB` en las variables de entorno:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ADB=/path/to/adb scrcpy
|
||||||
|
```
|
||||||
|
|
||||||
|
Para sobreescribir el path del archivo `scrcpy-server`, configure el path en `SCRCPY_SERVER_PATH`.
|
||||||
|
|
||||||
|
|
||||||
|
## ¿Por qué _scrcpy_?
|
||||||
|
|
||||||
|
Un colega me retó a encontrar un nombre tan impronunciable como [gnirehtet].
|
||||||
|
|
||||||
|
[`strcpy`] copia un **str**ing; `scrcpy` copia un **scr**een.
|
||||||
|
|
||||||
|
[gnirehtet]: https://github.com/Genymobile/gnirehtet
|
||||||
|
[`strcpy`]: http://man7.org/linux/man-pages/man3/strcpy.3.html
|
||||||
|
|
||||||
|
|
||||||
|
## ¿Cómo construir (BUILD)?
|
||||||
|
|
||||||
|
Véase [BUILD] (en inglés).
|
||||||
|
|
||||||
|
|
||||||
|
## Problemas generales
|
||||||
|
|
||||||
|
Vea las [preguntas frecuentes (en inglés)](FAQ.md).
|
||||||
|
|
||||||
|
|
||||||
|
## Desarrolladores
|
||||||
|
|
||||||
|
Lea la [hoja de desarrolladores (en inglés)](DEVELOP.md).
|
||||||
|
|
||||||
|
|
||||||
|
## Licencia
|
||||||
|
|
||||||
|
Copyright (C) 2018 Genymobile
|
||||||
|
Copyright (C) 2018-2021 Romain Vimont
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
## Artículos
|
||||||
|
|
||||||
|
- [Introducing scrcpy][article-intro] (en inglés)
|
||||||
|
- [Scrcpy now works wirelessly][article-tcpip] (en inglés)
|
||||||
|
|
||||||
|
[article-intro]: https://blog.rom1v.com/2018/03/introducing-scrcpy/
|
||||||
|
[article-tcpip]: https://www.genymotion.com/blog/open-source-project-scrcpy-now-works-wirelessly/
|
@ -10,6 +10,7 @@ src = [
|
|||||||
'src/event_converter.c',
|
'src/event_converter.c',
|
||||||
'src/file_handler.c',
|
'src/file_handler.c',
|
||||||
'src/fps_counter.c',
|
'src/fps_counter.c',
|
||||||
|
'src/frame_buffer.c',
|
||||||
'src/input_manager.c',
|
'src/input_manager.c',
|
||||||
'src/opengl.c',
|
'src/opengl.c',
|
||||||
'src/receiver.c',
|
'src/receiver.c',
|
||||||
@ -20,6 +21,7 @@ src = [
|
|||||||
'src/stream.c',
|
'src/stream.c',
|
||||||
'src/tiny_xpm.c',
|
'src/tiny_xpm.c',
|
||||||
'src/video_buffer.c',
|
'src/video_buffer.c',
|
||||||
|
'src/util/log.c',
|
||||||
'src/util/net.c',
|
'src/util/net.c',
|
||||||
'src/util/process.c',
|
'src/util/process.c',
|
||||||
'src/util/str_util.c',
|
'src/util/str_util.c',
|
||||||
|
@ -193,7 +193,7 @@ It requires to lock the video orientation (see --lock-video-orientation).
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-V, \-\-verbosity " value
|
.BI "\-V, \-\-verbosity " value
|
||||||
Set the log level ("debug", "info", "warn" or "error").
|
Set the log level ("verbose", "debug", "info", "warn" or "error").
|
||||||
|
|
||||||
Default is "info" for release builds, "debug" for debug builds.
|
Default is "info" for release builds, "debug" for debug builds.
|
||||||
|
|
||||||
|
@ -81,14 +81,20 @@ show_adb_installation_msg() {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
show_adb_err_msg(enum process_result err, const char *const argv[]) {
|
show_adb_err_msg(enum process_result err, const char *const argv[]) {
|
||||||
char buf[512];
|
#define MAX_COMMAND_STRING_LEN 1024
|
||||||
|
char *buf = malloc(MAX_COMMAND_STRING_LEN);
|
||||||
|
if (!buf) {
|
||||||
|
LOGE("Failed to execute (could not allocate error message)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case PROCESS_ERROR_GENERIC:
|
case PROCESS_ERROR_GENERIC:
|
||||||
argv_to_string(argv, buf, sizeof(buf));
|
argv_to_string(argv, buf, MAX_COMMAND_STRING_LEN);
|
||||||
LOGE("Failed to execute: %s", buf);
|
LOGE("Failed to execute: %s", buf);
|
||||||
break;
|
break;
|
||||||
case PROCESS_ERROR_MISSING_BINARY:
|
case PROCESS_ERROR_MISSING_BINARY:
|
||||||
argv_to_string(argv, buf, sizeof(buf));
|
argv_to_string(argv, buf, MAX_COMMAND_STRING_LEN);
|
||||||
LOGE("Command not found: %s", buf);
|
LOGE("Command not found: %s", buf);
|
||||||
LOGE("(make 'adb' accessible from your PATH or define its full"
|
LOGE("(make 'adb' accessible from your PATH or define its full"
|
||||||
"path in the ADB environment variable)");
|
"path in the ADB environment variable)");
|
||||||
@ -98,29 +104,38 @@ show_adb_err_msg(enum process_result err, const char *const argv[]) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
process_t
|
process_t
|
||||||
adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
adb_execute(const char *serial, const char *const adb_cmd[], size_t len) {
|
||||||
const char *cmd[len + 4];
|
|
||||||
int i;
|
int i;
|
||||||
process_t process;
|
process_t process;
|
||||||
cmd[0] = get_adb_command();
|
|
||||||
|
const char **argv = malloc((len + 4) * sizeof(*argv));
|
||||||
|
if (!argv) {
|
||||||
|
return PROCESS_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
argv[0] = get_adb_command();
|
||||||
if (serial) {
|
if (serial) {
|
||||||
cmd[1] = "-s";
|
argv[1] = "-s";
|
||||||
cmd[2] = serial;
|
argv[2] = serial;
|
||||||
i = 3;
|
i = 3;
|
||||||
} else {
|
} else {
|
||||||
i = 1;
|
i = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&cmd[i], adb_cmd, len * sizeof(const char *));
|
memcpy(&argv[i], adb_cmd, len * sizeof(const char *));
|
||||||
cmd[len + i] = NULL;
|
argv[len + i] = NULL;
|
||||||
enum process_result r = process_execute(cmd, &process);
|
enum process_result r = process_execute(argv, &process);
|
||||||
if (r != PROCESS_SUCCESS) {
|
if (r != PROCESS_SUCCESS) {
|
||||||
show_adb_err_msg(r, cmd);
|
show_adb_err_msg(r, argv);
|
||||||
return PROCESS_NONE;
|
process = PROCESS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(argv);
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
#endif
|
#endif
|
||||||
" -V, --verbosity value\n"
|
" -V, --verbosity value\n"
|
||||||
" Set the log level (debug, info, warn or error).\n"
|
" Set the log level (verbose, debug, info, warn or error).\n"
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
" Default is debug.\n"
|
" Default is debug.\n"
|
||||||
#else
|
#else
|
||||||
@ -505,6 +505,11 @@ parse_display_id(const char *s, uint32_t *display_id) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_log_level(const char *s, enum sc_log_level *log_level) {
|
parse_log_level(const char *s, enum sc_log_level *log_level) {
|
||||||
|
if (!strcmp(s, "verbose")) {
|
||||||
|
*log_level = SC_LOG_LEVEL_VERBOSE;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(s, "debug")) {
|
if (!strcmp(s, "debug")) {
|
||||||
*log_level = SC_LOG_LEVEL_DEBUG;
|
*log_level = SC_LOG_LEVEL_DEBUG;
|
||||||
return true;
|
return true;
|
||||||
@ -957,7 +962,8 @@ scrcpy_parse_args(struct scrcpy_cli_args *args, int argc, char *argv[]) {
|
|||||||
if (opts->record_filename && !opts->record_format) {
|
if (opts->record_filename && !opts->record_format) {
|
||||||
opts->record_format = guess_record_format(opts->record_filename);
|
opts->record_format = guess_record_format(opts->record_filename);
|
||||||
if (!opts->record_format) {
|
if (!opts->record_format) {
|
||||||
LOGE("No format specified for \"%s\" (try with -F mkv)",
|
LOGE("No format specified for \"%s\" "
|
||||||
|
"(try with --record-format=mkv)",
|
||||||
opts->record_filename);
|
opts->record_filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "control_msg.h"
|
#include "control_msg.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -8,6 +9,52 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str_util.h"
|
#include "util/str_util.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map an enum value to a string based on an array, without crashing on an
|
||||||
|
* out-of-bounds index.
|
||||||
|
*/
|
||||||
|
#define ENUM_TO_LABEL(labels, value) \
|
||||||
|
((size_t) (value) < ARRAY_LEN(labels) ? labels[value] : "???")
|
||||||
|
|
||||||
|
#define KEYEVENT_ACTION_LABEL(value) \
|
||||||
|
ENUM_TO_LABEL(android_keyevent_action_labels, value)
|
||||||
|
|
||||||
|
#define MOTIONEVENT_ACTION_LABEL(value) \
|
||||||
|
ENUM_TO_LABEL(android_motionevent_action_labels, value)
|
||||||
|
|
||||||
|
#define SCREEN_POWER_MODE_LABEL(value) \
|
||||||
|
ENUM_TO_LABEL(screen_power_mode_labels, value)
|
||||||
|
|
||||||
|
static const char *const android_keyevent_action_labels[] = {
|
||||||
|
"down",
|
||||||
|
"up",
|
||||||
|
"multi",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *const android_motionevent_action_labels[] = {
|
||||||
|
"down",
|
||||||
|
"up",
|
||||||
|
"move",
|
||||||
|
"cancel",
|
||||||
|
"outside",
|
||||||
|
"ponter-down",
|
||||||
|
"pointer-up",
|
||||||
|
"hover-move",
|
||||||
|
"scroll",
|
||||||
|
"hover-enter"
|
||||||
|
"hover-exit",
|
||||||
|
"btn-press",
|
||||||
|
"btn-release",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *const screen_power_mode_labels[] = {
|
||||||
|
"off",
|
||||||
|
"doze",
|
||||||
|
"normal",
|
||||||
|
"doze-suspend",
|
||||||
|
"suspend",
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_position(uint8_t *buf, const struct position *position) {
|
write_position(uint8_t *buf, const struct position *position) {
|
||||||
buffer_write32be(&buf[0], position->point.x);
|
buffer_write32be(&buf[0], position->point.x);
|
||||||
@ -93,6 +140,94 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
control_msg_log(const struct control_msg *msg) {
|
||||||
|
#define LOG_CMSG(fmt, ...) LOGV("input: " fmt, ## __VA_ARGS__)
|
||||||
|
switch (msg->type) {
|
||||||
|
case CONTROL_MSG_TYPE_INJECT_KEYCODE:
|
||||||
|
LOG_CMSG("key %-4s code=%d repeat=%" PRIu32 " meta=%06lx",
|
||||||
|
KEYEVENT_ACTION_LABEL(msg->inject_keycode.action),
|
||||||
|
(int) msg->inject_keycode.keycode,
|
||||||
|
msg->inject_keycode.repeat,
|
||||||
|
(long) msg->inject_keycode.metastate);
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_INJECT_TEXT:
|
||||||
|
LOG_CMSG("text \"%s\"", msg->inject_text.text);
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT: {
|
||||||
|
int action = msg->inject_touch_event.action
|
||||||
|
& AMOTION_EVENT_ACTION_MASK;
|
||||||
|
uint64_t id = msg->inject_touch_event.pointer_id;
|
||||||
|
if (id == POINTER_ID_MOUSE || id == POINTER_ID_VIRTUAL_FINGER) {
|
||||||
|
// string pointer id
|
||||||
|
LOG_CMSG("touch [id=%s] %-4s position=%" PRIi32 ",%" PRIi32
|
||||||
|
" pressure=%g buttons=%06lx",
|
||||||
|
id == POINTER_ID_MOUSE ? "mouse" : "vfinger",
|
||||||
|
MOTIONEVENT_ACTION_LABEL(action),
|
||||||
|
msg->inject_touch_event.position.point.x,
|
||||||
|
msg->inject_touch_event.position.point.y,
|
||||||
|
msg->inject_touch_event.pressure,
|
||||||
|
(long) msg->inject_touch_event.buttons);
|
||||||
|
} else {
|
||||||
|
// numeric pointer id
|
||||||
|
#ifndef __WIN32
|
||||||
|
# define PRIu64_ PRIu64
|
||||||
|
#else
|
||||||
|
# define PRIu64_ "I64u" // Windows...
|
||||||
|
#endif
|
||||||
|
LOG_CMSG("touch [id=%" PRIu64_ "] %-4s position=%" PRIi32 ",%"
|
||||||
|
PRIi32 " pressure=%g buttons=%06lx",
|
||||||
|
id,
|
||||||
|
MOTIONEVENT_ACTION_LABEL(action),
|
||||||
|
msg->inject_touch_event.position.point.x,
|
||||||
|
msg->inject_touch_event.position.point.y,
|
||||||
|
msg->inject_touch_event.pressure,
|
||||||
|
(long) msg->inject_touch_event.buttons);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT:
|
||||||
|
LOG_CMSG("scroll position=%" PRIi32 ",%" PRIi32 " hscroll=%" PRIi32
|
||||||
|
" vscroll=%" PRIi32,
|
||||||
|
msg->inject_scroll_event.position.point.x,
|
||||||
|
msg->inject_scroll_event.position.point.y,
|
||||||
|
msg->inject_scroll_event.hscroll,
|
||||||
|
msg->inject_scroll_event.vscroll);
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON:
|
||||||
|
LOG_CMSG("back-or-screen-on %s",
|
||||||
|
KEYEVENT_ACTION_LABEL(msg->inject_keycode.action));
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_SET_CLIPBOARD:
|
||||||
|
LOG_CMSG("clipboard %s \"%s\"",
|
||||||
|
msg->set_clipboard.paste ? "paste" : "copy",
|
||||||
|
msg->set_clipboard.text);
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE:
|
||||||
|
LOG_CMSG("power mode %s",
|
||||||
|
SCREEN_POWER_MODE_LABEL(msg->set_screen_power_mode.mode));
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
||||||
|
LOG_CMSG("expand notification panel");
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL:
|
||||||
|
LOG_CMSG("expand settings panel");
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_COLLAPSE_PANELS:
|
||||||
|
LOG_CMSG("collapse panels");
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_GET_CLIPBOARD:
|
||||||
|
LOG_CMSG("get clipboard");
|
||||||
|
break;
|
||||||
|
case CONTROL_MSG_TYPE_ROTATE_DEVICE:
|
||||||
|
LOG_CMSG("rotate device");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LOG_CMSG("unknown type: %u", (unsigned) msg->type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
control_msg_destroy(struct control_msg *msg) {
|
control_msg_destroy(struct control_msg *msg) {
|
||||||
switch (msg->type) {
|
switch (msg->type) {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
||||||
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
||||||
|
|
||||||
#define POINTER_ID_MOUSE UINT64_C(-1);
|
#define POINTER_ID_MOUSE UINT64_C(-1)
|
||||||
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2);
|
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2)
|
||||||
|
|
||||||
enum control_msg_type {
|
enum control_msg_type {
|
||||||
CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
||||||
@ -84,6 +84,9 @@ struct control_msg {
|
|||||||
size_t
|
size_t
|
||||||
control_msg_serialize(const struct control_msg *msg, unsigned char *buf);
|
control_msg_serialize(const struct control_msg *msg, unsigned char *buf);
|
||||||
|
|
||||||
|
void
|
||||||
|
control_msg_log(const struct control_msg *msg);
|
||||||
|
|
||||||
void
|
void
|
||||||
control_msg_destroy(struct control_msg *msg);
|
control_msg_destroy(struct control_msg *msg);
|
||||||
|
|
||||||
|
@ -48,6 +48,10 @@ controller_destroy(struct controller *controller) {
|
|||||||
bool
|
bool
|
||||||
controller_push_msg(struct controller *controller,
|
controller_push_msg(struct controller *controller,
|
||||||
const struct control_msg *msg) {
|
const struct control_msg *msg) {
|
||||||
|
if (sc_get_log_level() <= SC_LOG_LEVEL_VERBOSE) {
|
||||||
|
control_msg_log(msg);
|
||||||
|
}
|
||||||
|
|
||||||
sc_mutex_lock(&controller->mutex);
|
sc_mutex_lock(&controller->mutex);
|
||||||
bool was_empty = cbuf_is_empty(&controller->queue);
|
bool was_empty = cbuf_is_empty(&controller->queue);
|
||||||
bool res = cbuf_push(&controller->queue, *msg);
|
bool res = cbuf_push(&controller->queue, *msg);
|
||||||
|
88
app/src/frame_buffer.c
Normal file
88
app/src/frame_buffer.c
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#include "frame_buffer.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <libavutil/avutil.h>
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
|
||||||
|
#include "util/log.h"
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_frame_buffer_init(struct sc_frame_buffer *fb) {
|
||||||
|
fb->pending_frame = av_frame_alloc();
|
||||||
|
if (!fb->pending_frame) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
fb->tmp_frame = av_frame_alloc();
|
||||||
|
if (!fb->tmp_frame) {
|
||||||
|
av_frame_free(&fb->pending_frame);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ok = sc_mutex_init(&fb->mutex);
|
||||||
|
if (!ok) {
|
||||||
|
av_frame_free(&fb->pending_frame);
|
||||||
|
av_frame_free(&fb->tmp_frame);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// there is initially no frame, so consider it has already been consumed
|
||||||
|
fb->pending_frame_consumed = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_frame_buffer_destroy(struct sc_frame_buffer *fb) {
|
||||||
|
sc_mutex_destroy(&fb->mutex);
|
||||||
|
av_frame_free(&fb->pending_frame);
|
||||||
|
av_frame_free(&fb->tmp_frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
swap_frames(AVFrame **lhs, AVFrame **rhs) {
|
||||||
|
AVFrame *tmp = *lhs;
|
||||||
|
*lhs = *rhs;
|
||||||
|
*rhs = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_frame_buffer_push(struct sc_frame_buffer *fb, const AVFrame *frame,
|
||||||
|
bool *previous_frame_skipped) {
|
||||||
|
sc_mutex_lock(&fb->mutex);
|
||||||
|
|
||||||
|
// Use a temporary frame to preserve pending_frame in case of error.
|
||||||
|
// tmp_frame is an empty frame, no need to call av_frame_unref() beforehand.
|
||||||
|
int r = av_frame_ref(fb->tmp_frame, frame);
|
||||||
|
if (r) {
|
||||||
|
LOGE("Could not ref frame: %d", r);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now that av_frame_ref() succeeded, we can replace the previous
|
||||||
|
// pending_frame
|
||||||
|
swap_frames(&fb->pending_frame, &fb->tmp_frame);
|
||||||
|
av_frame_unref(fb->tmp_frame);
|
||||||
|
|
||||||
|
if (previous_frame_skipped) {
|
||||||
|
*previous_frame_skipped = !fb->pending_frame_consumed;
|
||||||
|
}
|
||||||
|
fb->pending_frame_consumed = false;
|
||||||
|
|
||||||
|
sc_mutex_unlock(&fb->mutex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_frame_buffer_consume(struct sc_frame_buffer *fb, AVFrame *dst) {
|
||||||
|
sc_mutex_lock(&fb->mutex);
|
||||||
|
assert(!fb->pending_frame_consumed);
|
||||||
|
fb->pending_frame_consumed = true;
|
||||||
|
|
||||||
|
av_frame_move_ref(dst, fb->pending_frame);
|
||||||
|
// av_frame_move_ref() resets its source frame, so no need to call
|
||||||
|
// av_frame_unref()
|
||||||
|
|
||||||
|
sc_mutex_unlock(&fb->mutex);
|
||||||
|
}
|
44
app/src/frame_buffer.h
Normal file
44
app/src/frame_buffer.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef SC_FRAME_BUFFER_H
|
||||||
|
#define SC_FRAME_BUFFER_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "util/thread.h"
|
||||||
|
|
||||||
|
// forward declarations
|
||||||
|
typedef struct AVFrame AVFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A frame buffer holds 1 pending frame, which is the last frame received from
|
||||||
|
* the producer (typically, the decoder).
|
||||||
|
*
|
||||||
|
* If a pending frame has not been consumed when the producer pushes a new
|
||||||
|
* frame, then it is lost. The intent is to always provide access to the very
|
||||||
|
* last frame to minimize latency.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct sc_frame_buffer {
|
||||||
|
AVFrame *pending_frame;
|
||||||
|
AVFrame *tmp_frame; // To preserve the pending frame on error
|
||||||
|
|
||||||
|
sc_mutex mutex;
|
||||||
|
|
||||||
|
bool pending_frame_consumed;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_frame_buffer_init(struct sc_frame_buffer *fb);
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_frame_buffer_destroy(struct sc_frame_buffer *fb);
|
||||||
|
|
||||||
|
bool
|
||||||
|
sc_frame_buffer_push(struct sc_frame_buffer *fb, const AVFrame *frame,
|
||||||
|
bool *skipped);
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_frame_buffer_consume(struct sc_frame_buffer *fb, AVFrame *dst);
|
||||||
|
|
||||||
|
#endif
|
@ -595,8 +595,12 @@ convert_mouse_motion(const SDL_MouseMotionEvent *from, struct screen *screen,
|
|||||||
static void
|
static void
|
||||||
input_manager_process_mouse_motion(struct input_manager *im,
|
input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
const SDL_MouseMotionEvent *event) {
|
const SDL_MouseMotionEvent *event) {
|
||||||
if (!event->state) {
|
uint32_t mask = SDL_BUTTON_LMASK;
|
||||||
// do not send motion events when no button is pressed
|
if (im->forward_all_clicks) {
|
||||||
|
mask |= SDL_BUTTON_MMASK | SDL_BUTTON_RMASK;
|
||||||
|
}
|
||||||
|
if (!(event->state & mask)) {
|
||||||
|
// do not send motion events when no click is pressed
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event->which == SDL_TOUCH_MOUSEID) {
|
if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
|
@ -38,24 +38,6 @@ print_version(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_LogPriority
|
|
||||||
convert_log_level_to_sdl(enum sc_log_level level) {
|
|
||||||
switch (level) {
|
|
||||||
case SC_LOG_LEVEL_DEBUG:
|
|
||||||
return SDL_LOG_PRIORITY_DEBUG;
|
|
||||||
case SC_LOG_LEVEL_INFO:
|
|
||||||
return SDL_LOG_PRIORITY_INFO;
|
|
||||||
case SC_LOG_LEVEL_WARN:
|
|
||||||
return SDL_LOG_PRIORITY_WARN;
|
|
||||||
case SC_LOG_LEVEL_ERROR:
|
|
||||||
return SDL_LOG_PRIORITY_ERROR;
|
|
||||||
default:
|
|
||||||
assert(!"unexpected log level");
|
|
||||||
return SDL_LOG_PRIORITY_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
@ -79,8 +61,7 @@ main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogPriority sdl_log = convert_log_level_to_sdl(args.opts.log_level);
|
sc_set_log_level(args.opts.log_level);
|
||||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, sdl_log);
|
|
||||||
|
|
||||||
if (args.help) {
|
if (args.help) {
|
||||||
scrcpy_print_usage(argv[0]);
|
scrcpy_print_usage(argv[0]);
|
||||||
|
@ -216,14 +216,15 @@ av_log_callback(void *avcl, int level, const char *fmt, va_list vl) {
|
|||||||
if (priority == 0) {
|
if (priority == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char *local_fmt = malloc(strlen(fmt) + 10);
|
|
||||||
|
size_t fmt_len = strlen(fmt);
|
||||||
|
char *local_fmt = malloc(fmt_len + 10);
|
||||||
if (!local_fmt) {
|
if (!local_fmt) {
|
||||||
LOGC("Could not allocate string");
|
LOGC("Could not allocate string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// strcpy is safe here, the destination is large enough
|
memcpy(local_fmt, "[FFmpeg] ", 9); // do not write the final '\0'
|
||||||
strcpy(local_fmt, "[FFmpeg] ");
|
memcpy(local_fmt + 9, fmt, fmt_len + 1); // include '\0'
|
||||||
strcpy(local_fmt + 9, fmt);
|
|
||||||
SDL_LogMessageV(SDL_LOG_CATEGORY_VIDEO, priority, local_fmt, vl);
|
SDL_LogMessageV(SDL_LOG_CATEGORY_VIDEO, priority, local_fmt, vl);
|
||||||
free(local_fmt);
|
free(local_fmt);
|
||||||
}
|
}
|
||||||
@ -342,19 +343,29 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
stream_add_sink(&s->stream, &rec->packet_sink);
|
stream_add_sink(&s->stream, &rec->packet_sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options->display) {
|
if (options->control) {
|
||||||
if (options->control) {
|
if (!controller_init(&s->controller, s->server.control_socket)) {
|
||||||
if (!controller_init(&s->controller, s->server.control_socket)) {
|
goto end;
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
controller_initialized = true;
|
|
||||||
|
|
||||||
if (!controller_start(&s->controller)) {
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
controller_started = true;
|
|
||||||
}
|
}
|
||||||
|
controller_initialized = true;
|
||||||
|
|
||||||
|
if (!controller_start(&s->controller)) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
controller_started = true;
|
||||||
|
|
||||||
|
if (options->turn_screen_off) {
|
||||||
|
struct control_msg msg;
|
||||||
|
msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE;
|
||||||
|
msg.set_screen_power_mode.mode = SCREEN_POWER_MODE_OFF;
|
||||||
|
|
||||||
|
if (!controller_push_msg(&s->controller, &msg)) {
|
||||||
|
LOGW("Could not request 'set screen power mode'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options->display) {
|
||||||
const char *window_title =
|
const char *window_title =
|
||||||
options->window_title ? options->window_title : device_name;
|
options->window_title ? options->window_title : device_name;
|
||||||
|
|
||||||
@ -378,16 +389,6 @@ scrcpy(const struct scrcpy_options *options) {
|
|||||||
screen_initialized = true;
|
screen_initialized = true;
|
||||||
|
|
||||||
decoder_add_sink(&s->decoder, &s->screen.frame_sink);
|
decoder_add_sink(&s->decoder, &s->screen.frame_sink);
|
||||||
|
|
||||||
if (options->turn_screen_off) {
|
|
||||||
struct control_msg msg;
|
|
||||||
msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE;
|
|
||||||
msg.set_screen_power_mode.mode = SCREEN_POWER_MODE_OFF;
|
|
||||||
|
|
||||||
if (!controller_push_msg(&s->controller, &msg)) {
|
|
||||||
LOGW("Could not request 'set screen power mode'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_V4L2
|
#ifdef HAVE_V4L2
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum sc_log_level {
|
enum sc_log_level {
|
||||||
|
SC_LOG_LEVEL_VERBOSE,
|
||||||
SC_LOG_LEVEL_DEBUG,
|
SC_LOG_LEVEL_DEBUG,
|
||||||
SC_LOG_LEVEL_INFO,
|
SC_LOG_LEVEL_INFO,
|
||||||
SC_LOG_LEVEL_WARN,
|
SC_LOG_LEVEL_WARN,
|
||||||
|
@ -276,7 +276,7 @@ screen_frame_sink_push(struct sc_frame_sink *sink, const AVFrame *frame) {
|
|||||||
struct screen *screen = DOWNCAST(sink);
|
struct screen *screen = DOWNCAST(sink);
|
||||||
|
|
||||||
bool previous_frame_skipped;
|
bool previous_frame_skipped;
|
||||||
bool ok = video_buffer_push(&screen->vb, frame, &previous_frame_skipped);
|
bool ok = sc_video_buffer_push(&screen->vb, frame, &previous_frame_skipped);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ screen_init(struct screen *screen, const struct screen_params *params) {
|
|||||||
screen->fullscreen = false;
|
screen->fullscreen = false;
|
||||||
screen->maximized = false;
|
screen->maximized = false;
|
||||||
|
|
||||||
bool ok = video_buffer_init(&screen->vb);
|
bool ok = sc_video_buffer_init(&screen->vb);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
LOGE("Could not initialize video buffer");
|
LOGE("Could not initialize video buffer");
|
||||||
return false;
|
return false;
|
||||||
@ -454,7 +454,7 @@ error_destroy_window:
|
|||||||
error_destroy_fps_counter:
|
error_destroy_fps_counter:
|
||||||
fps_counter_destroy(&screen->fps_counter);
|
fps_counter_destroy(&screen->fps_counter);
|
||||||
error_destroy_video_buffer:
|
error_destroy_video_buffer:
|
||||||
video_buffer_destroy(&screen->vb);
|
sc_video_buffer_destroy(&screen->vb);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ screen_destroy(struct screen *screen) {
|
|||||||
SDL_DestroyRenderer(screen->renderer);
|
SDL_DestroyRenderer(screen->renderer);
|
||||||
SDL_DestroyWindow(screen->window);
|
SDL_DestroyWindow(screen->window);
|
||||||
fps_counter_destroy(&screen->fps_counter);
|
fps_counter_destroy(&screen->fps_counter);
|
||||||
video_buffer_destroy(&screen->vb);
|
sc_video_buffer_destroy(&screen->vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -595,7 +595,7 @@ update_texture(struct screen *screen, const AVFrame *frame) {
|
|||||||
static bool
|
static bool
|
||||||
screen_update_frame(struct screen *screen) {
|
screen_update_frame(struct screen *screen) {
|
||||||
av_frame_unref(screen->frame);
|
av_frame_unref(screen->frame);
|
||||||
video_buffer_consume(&screen->vb, screen->frame);
|
sc_video_buffer_consume(&screen->vb, screen->frame);
|
||||||
AVFrame *frame = screen->frame;
|
AVFrame *frame = screen->frame;
|
||||||
|
|
||||||
fps_counter_add_rendered_frame(&screen->fps_counter);
|
fps_counter_add_rendered_frame(&screen->fps_counter);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
|
||||||
#include "coords.h"
|
#include "coords.h"
|
||||||
|
#include "fps_counter.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "trait/frame_sink.h"
|
#include "trait/frame_sink.h"
|
||||||
#include "video_buffer.h"
|
#include "video_buffer.h"
|
||||||
@ -19,7 +20,7 @@ struct screen {
|
|||||||
bool open; // track the open/close state to assert correct behavior
|
bool open; // track the open/close state to assert correct behavior
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct video_buffer vb;
|
struct sc_video_buffer vb;
|
||||||
struct fps_counter fps_counter;
|
struct fps_counter fps_counter;
|
||||||
|
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
|
@ -235,6 +235,8 @@ enable_tunnel_any_port(struct server *server, struct sc_port_range port_range,
|
|||||||
static const char *
|
static const char *
|
||||||
log_level_to_server_string(enum sc_log_level level) {
|
log_level_to_server_string(enum sc_log_level level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
|
case SC_LOG_LEVEL_VERBOSE:
|
||||||
|
return "verbose";
|
||||||
case SC_LOG_LEVEL_DEBUG:
|
case SC_LOG_LEVEL_DEBUG:
|
||||||
return "debug";
|
return "debug";
|
||||||
case SC_LOG_LEVEL_INFO:
|
case SC_LOG_LEVEL_INFO:
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str_util.h"
|
#include "util/str_util.h"
|
||||||
|
|
||||||
static int
|
#define CMD_MAX_LEN 8192
|
||||||
|
|
||||||
|
static bool
|
||||||
build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
||||||
// Windows command-line parsing is WTF:
|
// Windows command-line parsing is WTF:
|
||||||
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
|
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
|
||||||
@ -15,9 +17,9 @@ build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
|||||||
size_t ret = xstrjoin(cmd, argv, ' ', len);
|
size_t ret = xstrjoin(cmd, argv, ' ', len);
|
||||||
if (ret >= len) {
|
if (ret >= len) {
|
||||||
LOGE("Command too long (%" PRIsizet " chars)", len - 1);
|
LOGE("Command too long (%" PRIsizet " chars)", len - 1);
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum process_result
|
enum process_result
|
||||||
@ -27,13 +29,14 @@ process_execute(const char *const argv[], HANDLE *handle) {
|
|||||||
memset(&si, 0, sizeof(si));
|
memset(&si, 0, sizeof(si));
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
|
|
||||||
char cmd[256];
|
char *cmd = malloc(CMD_MAX_LEN);
|
||||||
if (build_cmd(cmd, sizeof(cmd), argv)) {
|
if (!cmd || !build_cmd(cmd, CMD_MAX_LEN, argv)) {
|
||||||
*handle = NULL;
|
*handle = NULL;
|
||||||
return PROCESS_ERROR_GENERIC;
|
return PROCESS_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *wide = utf8_to_wide_char(cmd);
|
wchar_t *wide = utf8_to_wide_char(cmd);
|
||||||
|
free(cmd);
|
||||||
if (!wide) {
|
if (!wide) {
|
||||||
LOGC("Could not allocate wide char string");
|
LOGC("Could not allocate wide char string");
|
||||||
return PROCESS_ERROR_GENERIC;
|
return PROCESS_ERROR_GENERIC;
|
||||||
|
53
app/src/util/log.c
Normal file
53
app/src/util/log.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
static SDL_LogPriority
|
||||||
|
log_level_sc_to_sdl(enum sc_log_level level) {
|
||||||
|
switch (level) {
|
||||||
|
case SC_LOG_LEVEL_VERBOSE:
|
||||||
|
return SDL_LOG_PRIORITY_VERBOSE;
|
||||||
|
case SC_LOG_LEVEL_DEBUG:
|
||||||
|
return SDL_LOG_PRIORITY_DEBUG;
|
||||||
|
case SC_LOG_LEVEL_INFO:
|
||||||
|
return SDL_LOG_PRIORITY_INFO;
|
||||||
|
case SC_LOG_LEVEL_WARN:
|
||||||
|
return SDL_LOG_PRIORITY_WARN;
|
||||||
|
case SC_LOG_LEVEL_ERROR:
|
||||||
|
return SDL_LOG_PRIORITY_ERROR;
|
||||||
|
default:
|
||||||
|
assert(!"unexpected log level");
|
||||||
|
return SDL_LOG_PRIORITY_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum sc_log_level
|
||||||
|
log_level_sdl_to_sc(SDL_LogPriority priority) {
|
||||||
|
switch (priority) {
|
||||||
|
case SDL_LOG_PRIORITY_VERBOSE:
|
||||||
|
return SC_LOG_LEVEL_VERBOSE;
|
||||||
|
case SDL_LOG_PRIORITY_DEBUG:
|
||||||
|
return SC_LOG_LEVEL_DEBUG;
|
||||||
|
case SDL_LOG_PRIORITY_INFO:
|
||||||
|
return SC_LOG_LEVEL_INFO;
|
||||||
|
case SDL_LOG_PRIORITY_WARN:
|
||||||
|
return SC_LOG_LEVEL_WARN;
|
||||||
|
case SDL_LOG_PRIORITY_ERROR:
|
||||||
|
return SC_LOG_LEVEL_ERROR;
|
||||||
|
default:
|
||||||
|
assert(!"unexpected log level");
|
||||||
|
return SC_LOG_LEVEL_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_set_log_level(enum sc_log_level level) {
|
||||||
|
SDL_LogPriority sdl_log = log_level_sc_to_sdl(level);
|
||||||
|
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, sdl_log);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum sc_log_level
|
||||||
|
sc_get_log_level(void) {
|
||||||
|
SDL_LogPriority sdl_log = SDL_LogGetPriority(SDL_LOG_CATEGORY_APPLICATION);
|
||||||
|
return log_level_sdl_to_sc(sdl_log);
|
||||||
|
}
|
@ -1,8 +1,12 @@
|
|||||||
#ifndef LOG_H
|
#ifndef SC_LOG_H
|
||||||
#define LOG_H
|
#define SC_LOG_H
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#include <SDL2/SDL_log.h>
|
#include <SDL2/SDL_log.h>
|
||||||
|
|
||||||
|
#include "scrcpy.h"
|
||||||
|
|
||||||
#define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGI(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGI(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
@ -10,4 +14,10 @@
|
|||||||
#define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGC(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGC(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
|
|
||||||
|
void
|
||||||
|
sc_set_log_level(enum sc_log_level level);
|
||||||
|
|
||||||
|
enum sc_log_level
|
||||||
|
sc_get_log_level(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,7 +31,7 @@ sc_mutex_init(sc_mutex *mutex) {
|
|||||||
|
|
||||||
mutex->mutex = sdl_mutex;
|
mutex->mutex = sdl_mutex;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
mutex->locker = 0;
|
atomic_init(&mutex->locker, 0);
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,8 @@ sc_mutex_lock(sc_mutex *mutex) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex->locker = sc_thread_get_id();
|
atomic_store_explicit(&mutex->locker, sc_thread_get_id(),
|
||||||
|
memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
(void) r;
|
(void) r;
|
||||||
#endif
|
#endif
|
||||||
@ -62,7 +63,7 @@ void
|
|||||||
sc_mutex_unlock(sc_mutex *mutex) {
|
sc_mutex_unlock(sc_mutex *mutex) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
assert(sc_mutex_held(mutex));
|
assert(sc_mutex_held(mutex));
|
||||||
mutex->locker = 0;
|
atomic_store_explicit(&mutex->locker, 0, memory_order_relaxed);
|
||||||
#endif
|
#endif
|
||||||
int r = SDL_UnlockMutex(mutex->mutex);
|
int r = SDL_UnlockMutex(mutex->mutex);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@ -83,7 +84,9 @@ sc_thread_get_id(void) {
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
bool
|
bool
|
||||||
sc_mutex_held(struct sc_mutex *mutex) {
|
sc_mutex_held(struct sc_mutex *mutex) {
|
||||||
return mutex->locker == sc_thread_get_id();
|
sc_thread_id locker_id =
|
||||||
|
atomic_load_explicit(&mutex->locker, memory_order_relaxed);
|
||||||
|
return locker_id == sc_thread_get_id();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -112,7 +115,8 @@ sc_cond_wait(sc_cond *cond, sc_mutex *mutex) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex->locker = sc_thread_get_id();
|
atomic_store_explicit(&mutex->locker, sc_thread_get_id(),
|
||||||
|
memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
(void) r;
|
(void) r;
|
||||||
#endif
|
#endif
|
||||||
@ -127,7 +131,8 @@ sc_cond_timedwait(sc_cond *cond, sc_mutex *mutex, uint32_t ms) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex->locker = sc_thread_get_id();
|
atomic_store_explicit(&mutex->locker, sc_thread_get_id(),
|
||||||
|
memory_order_relaxed);
|
||||||
#endif
|
#endif
|
||||||
assert(r == 0 || r == SDL_MUTEX_TIMEDOUT);
|
assert(r == 0 || r == SDL_MUTEX_TIMEDOUT);
|
||||||
return r == 0;
|
return r == 0;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
#include <stdatomic.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -12,7 +13,8 @@ typedef struct SDL_mutex SDL_mutex;
|
|||||||
typedef struct SDL_cond SDL_cond;
|
typedef struct SDL_cond SDL_cond;
|
||||||
|
|
||||||
typedef int sc_thread_fn(void *);
|
typedef int sc_thread_fn(void *);
|
||||||
typedef unsigned int sc_thread_id;
|
typedef unsigned sc_thread_id;
|
||||||
|
typedef atomic_uint sc_atomic_thread_id;
|
||||||
|
|
||||||
typedef struct sc_thread {
|
typedef struct sc_thread {
|
||||||
SDL_Thread *thread;
|
SDL_Thread *thread;
|
||||||
@ -21,7 +23,7 @@ typedef struct sc_thread {
|
|||||||
typedef struct sc_mutex {
|
typedef struct sc_mutex {
|
||||||
SDL_mutex *mutex;
|
SDL_mutex *mutex;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
sc_thread_id locker;
|
sc_atomic_thread_id locker;
|
||||||
#endif
|
#endif
|
||||||
} sc_mutex;
|
} sc_mutex;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ run_v4l2_sink(void *data) {
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
sc_mutex_lock(&vs->mutex);
|
sc_mutex_lock(&vs->mutex);
|
||||||
|
|
||||||
while (!vs->stopped && vs->vb.pending_frame_consumed) {
|
while (!vs->stopped && !vs->has_frame) {
|
||||||
sc_cond_wait(&vs->cond, &vs->mutex);
|
sc_cond_wait(&vs->cond, &vs->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +121,11 @@ run_v4l2_sink(void *data) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sc_video_buffer_consume(&vs->vb, vs->frame);
|
||||||
|
vs->has_frame = false;
|
||||||
|
|
||||||
sc_mutex_unlock(&vs->mutex);
|
sc_mutex_unlock(&vs->mutex);
|
||||||
|
|
||||||
video_buffer_consume(&vs->vb, vs->frame);
|
|
||||||
bool ok = encode_and_write_frame(vs, vs->frame);
|
bool ok = encode_and_write_frame(vs, vs->frame);
|
||||||
av_frame_unref(vs->frame);
|
av_frame_unref(vs->frame);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -139,7 +141,7 @@ run_v4l2_sink(void *data) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
||||||
bool ok = video_buffer_init(&vs->vb);
|
bool ok = sc_video_buffer_init(&vs->vb);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -241,6 +243,10 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
|||||||
goto error_av_frame_free;
|
goto error_av_frame_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vs->has_frame = false;
|
||||||
|
vs->header_written = false;
|
||||||
|
vs->stopped = false;
|
||||||
|
|
||||||
LOGD("Starting v4l2 thread");
|
LOGD("Starting v4l2 thread");
|
||||||
ok = sc_thread_create(&vs->thread, run_v4l2_sink, "v4l2", vs);
|
ok = sc_thread_create(&vs->thread, run_v4l2_sink, "v4l2", vs);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
@ -248,9 +254,6 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
|
|||||||
goto error_av_packet_free;
|
goto error_av_packet_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
vs->header_written = false;
|
|
||||||
vs->stopped = false;
|
|
||||||
|
|
||||||
LOGI("v4l2 sink started to device: %s", vs->device_name);
|
LOGI("v4l2 sink started to device: %s", vs->device_name);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -272,7 +275,7 @@ error_cond_destroy:
|
|||||||
error_mutex_destroy:
|
error_mutex_destroy:
|
||||||
sc_mutex_destroy(&vs->mutex);
|
sc_mutex_destroy(&vs->mutex);
|
||||||
error_video_buffer_destroy:
|
error_video_buffer_destroy:
|
||||||
video_buffer_destroy(&vs->vb);
|
sc_video_buffer_destroy(&vs->vb);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -294,19 +297,23 @@ sc_v4l2_sink_close(struct sc_v4l2_sink *vs) {
|
|||||||
avformat_free_context(vs->format_ctx);
|
avformat_free_context(vs->format_ctx);
|
||||||
sc_cond_destroy(&vs->cond);
|
sc_cond_destroy(&vs->cond);
|
||||||
sc_mutex_destroy(&vs->mutex);
|
sc_mutex_destroy(&vs->mutex);
|
||||||
video_buffer_destroy(&vs->vb);
|
sc_video_buffer_destroy(&vs->vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
sc_v4l2_sink_push(struct sc_v4l2_sink *vs, const AVFrame *frame) {
|
sc_v4l2_sink_push(struct sc_v4l2_sink *vs, const AVFrame *frame) {
|
||||||
bool ok = video_buffer_push(&vs->vb, frame, NULL);
|
sc_mutex_lock(&vs->mutex);
|
||||||
|
|
||||||
|
bool ok = sc_video_buffer_push(&vs->vb, frame, NULL);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// signal possible change of vs->vb.pending_frame_consumed
|
vs->has_frame = true;
|
||||||
sc_cond_signal(&vs->cond);
|
sc_cond_signal(&vs->cond);
|
||||||
|
|
||||||
|
sc_mutex_unlock(&vs->mutex);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
struct sc_v4l2_sink {
|
struct sc_v4l2_sink {
|
||||||
struct sc_frame_sink frame_sink; // frame sink trait
|
struct sc_frame_sink frame_sink; // frame sink trait
|
||||||
|
|
||||||
struct video_buffer vb;
|
struct sc_video_buffer vb;
|
||||||
AVFormatContext *format_ctx;
|
AVFormatContext *format_ctx;
|
||||||
AVCodecContext *encoder_ctx;
|
AVCodecContext *encoder_ctx;
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ struct sc_v4l2_sink {
|
|||||||
sc_thread thread;
|
sc_thread thread;
|
||||||
sc_mutex mutex;
|
sc_mutex mutex;
|
||||||
sc_cond cond;
|
sc_cond cond;
|
||||||
|
bool has_frame;
|
||||||
bool stopped;
|
bool stopped;
|
||||||
bool header_written;
|
bool header_written;
|
||||||
|
|
||||||
|
@ -7,82 +7,22 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_init(struct video_buffer *vb) {
|
sc_video_buffer_init(struct sc_video_buffer *vb) {
|
||||||
vb->pending_frame = av_frame_alloc();
|
return sc_frame_buffer_init(&vb->fb);
|
||||||
if (!vb->pending_frame) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
vb->tmp_frame = av_frame_alloc();
|
|
||||||
if (!vb->tmp_frame) {
|
|
||||||
av_frame_free(&vb->pending_frame);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ok = sc_mutex_init(&vb->mutex);
|
|
||||||
if (!ok) {
|
|
||||||
av_frame_free(&vb->pending_frame);
|
|
||||||
av_frame_free(&vb->tmp_frame);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// there is initially no frame, so consider it has already been consumed
|
|
||||||
vb->pending_frame_consumed = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_destroy(struct video_buffer *vb) {
|
sc_video_buffer_destroy(struct sc_video_buffer *vb) {
|
||||||
sc_mutex_destroy(&vb->mutex);
|
sc_frame_buffer_destroy(&vb->fb);
|
||||||
av_frame_free(&vb->pending_frame);
|
|
||||||
av_frame_free(&vb->tmp_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
swap_frames(AVFrame **lhs, AVFrame **rhs) {
|
|
||||||
AVFrame *tmp = *lhs;
|
|
||||||
*lhs = *rhs;
|
|
||||||
*rhs = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_push(struct video_buffer *vb, const AVFrame *frame,
|
sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame,
|
||||||
bool *previous_frame_skipped) {
|
bool *previous_frame_skipped) {
|
||||||
sc_mutex_lock(&vb->mutex);
|
return sc_frame_buffer_push(&vb->fb, frame, previous_frame_skipped);
|
||||||
|
|
||||||
// Use a temporary frame to preserve pending_frame in case of error.
|
|
||||||
// tmp_frame is an empty frame, no need to call av_frame_unref() beforehand.
|
|
||||||
int r = av_frame_ref(vb->tmp_frame, frame);
|
|
||||||
if (r) {
|
|
||||||
LOGE("Could not ref frame: %d", r);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that av_frame_ref() succeeded, we can replace the previous
|
|
||||||
// pending_frame
|
|
||||||
swap_frames(&vb->pending_frame, &vb->tmp_frame);
|
|
||||||
av_frame_unref(vb->tmp_frame);
|
|
||||||
|
|
||||||
if (previous_frame_skipped) {
|
|
||||||
*previous_frame_skipped = !vb->pending_frame_consumed;
|
|
||||||
}
|
|
||||||
vb->pending_frame_consumed = false;
|
|
||||||
|
|
||||||
sc_mutex_unlock(&vb->mutex);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_consume(struct video_buffer *vb, AVFrame *dst) {
|
sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst) {
|
||||||
sc_mutex_lock(&vb->mutex);
|
sc_frame_buffer_consume(&vb->fb, dst);
|
||||||
assert(!vb->pending_frame_consumed);
|
|
||||||
vb->pending_frame_consumed = true;
|
|
||||||
|
|
||||||
av_frame_move_ref(dst, vb->pending_frame);
|
|
||||||
// av_frame_move_ref() resets its source frame, so no need to call
|
|
||||||
// av_frame_unref()
|
|
||||||
|
|
||||||
sc_mutex_unlock(&vb->mutex);
|
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,30 @@
|
|||||||
#ifndef VIDEO_BUFFER_H
|
#ifndef SC_VIDEO_BUFFER_H
|
||||||
#define VIDEO_BUFFER_H
|
#define SC_VIDEO_BUFFER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "fps_counter.h"
|
#include "frame_buffer.h"
|
||||||
#include "util/thread.h"
|
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
typedef struct AVFrame AVFrame;
|
typedef struct AVFrame AVFrame;
|
||||||
|
|
||||||
/**
|
struct sc_video_buffer {
|
||||||
* A video buffer holds 1 pending frame, which is the last frame received from
|
struct sc_frame_buffer fb;
|
||||||
* the producer (typically, the decoder).
|
|
||||||
*
|
|
||||||
* If a pending frame has not been consumed when the producer pushes a new
|
|
||||||
* frame, then it is lost. The intent is to always provide access to the very
|
|
||||||
* last frame to minimize latency.
|
|
||||||
*
|
|
||||||
* The producer and the consumer typically do not live in the same thread.
|
|
||||||
* That's the reason why the callback on_frame_available() does not provide the
|
|
||||||
* frame as parameter: the consumer might post an event to its own thread to
|
|
||||||
* retrieve the pending frame from there, and that frame may have changed since
|
|
||||||
* the callback if producer pushed a new one in between.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct video_buffer {
|
|
||||||
AVFrame *pending_frame;
|
|
||||||
AVFrame *tmp_frame; // To preserve the pending frame on error
|
|
||||||
|
|
||||||
sc_mutex mutex;
|
|
||||||
|
|
||||||
bool pending_frame_consumed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_init(struct video_buffer *vb);
|
sc_video_buffer_init(struct sc_video_buffer *vb);
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_destroy(struct video_buffer *vb);
|
sc_video_buffer_destroy(struct sc_video_buffer *vb);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
video_buffer_push(struct video_buffer *vb, const AVFrame *frame, bool *skipped);
|
sc_video_buffer_push(struct sc_video_buffer *vb, const AVFrame *frame,
|
||||||
|
bool *skipped);
|
||||||
|
|
||||||
void
|
void
|
||||||
video_buffer_consume(struct video_buffer *vb, AVFrame *dst);
|
sc_video_buffer_consume(struct sc_video_buffer *vb, AVFrame *dst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
BUILDDIR=build-auto
|
BUILDDIR=build-auto
|
||||||
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v1.17/scrcpy-server-v1.17
|
PREBUILT_SERVER_URL=https://github.com/Genymobile/scrcpy/releases/download/v1.18/scrcpy-server-v1.18
|
||||||
PREBUILT_SERVER_SHA256=11b5ad2d1bc9b9730fb7254a78efd71a8ff46b1938ff468e47a21b653a1b6725
|
PREBUILT_SERVER_SHA256=641c5c6beda9399dfae72d116f5ff43b5ed1059d871c9ebc3f47610fd33c51a3
|
||||||
|
|
||||||
echo "[scrcpy] Downloading prebuilt server..."
|
echo "[scrcpy] Downloading prebuilt server..."
|
||||||
wget "$PREBUILT_SERVER_URL" -O scrcpy-server
|
wget "$PREBUILT_SERVER_URL" -O scrcpy-server
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
project('scrcpy', 'c',
|
project('scrcpy', 'c',
|
||||||
version: '1.17',
|
version: '1.18',
|
||||||
meson_version: '>= 0.48',
|
meson_version: '>= 0.48',
|
||||||
default_options: [
|
default_options: [
|
||||||
'c_std=c11',
|
'c_std=c11',
|
||||||
|
@ -35,6 +35,6 @@ prepare-sdl2:
|
|||||||
SDL2-2.0.14
|
SDL2-2.0.14
|
||||||
|
|
||||||
prepare-adb:
|
prepare-adb:
|
||||||
@./prepare-dep https://dl.google.com/android/repository/platform-tools_r30.0.5-windows.zip \
|
@./prepare-dep https://dl.google.com/android/repository/platform-tools_r31.0.2-windows.zip \
|
||||||
549ba2bdc31f335eb8a504f005f77606a479cc216d6b64a3e8b64c780003661f \
|
d560cb8ded83ae04763b94632673481f14843a5969256569623cfeac82db4ba5 \
|
||||||
platform-tools
|
platform-tools
|
||||||
|
@ -6,8 +6,8 @@ android {
|
|||||||
applicationId "com.genymobile.scrcpy"
|
applicationId "com.genymobile.scrcpy"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 20
|
versionCode 11800
|
||||||
versionName "1.17"
|
versionName "1.18"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRCPY_DEBUG=false
|
SCRCPY_DEBUG=false
|
||||||
SCRCPY_VERSION_NAME=1.17
|
SCRCPY_VERSION_NAME=1.18
|
||||||
|
|
||||||
PLATFORM=${ANDROID_PLATFORM:-30}
|
PLATFORM=${ANDROID_PLATFORM:-30}
|
||||||
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-30.0.0}
|
BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-30.0.0}
|
||||||
|
@ -12,7 +12,7 @@ public final class Ln {
|
|||||||
private static final String PREFIX = "[server] ";
|
private static final String PREFIX = "[server] ";
|
||||||
|
|
||||||
enum Level {
|
enum Level {
|
||||||
DEBUG, INFO, WARN, ERROR
|
VERBOSE, DEBUG, INFO, WARN, ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Level threshold = Level.INFO;
|
private static Level threshold = Level.INFO;
|
||||||
@ -36,6 +36,13 @@ public final class Ln {
|
|||||||
return level.ordinal() >= threshold.ordinal();
|
return level.ordinal() >= threshold.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void v(String message) {
|
||||||
|
if (isEnabled(Level.VERBOSE)) {
|
||||||
|
Log.v(TAG, message);
|
||||||
|
System.out.println(PREFIX + "VERBOSE: " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void d(String message) {
|
public static void d(String message) {
|
||||||
if (isEnabled(Level.DEBUG)) {
|
if (isEnabled(Level.DEBUG)) {
|
||||||
Log.d(TAG, message);
|
Log.d(TAG, message);
|
||||||
|
@ -47,12 +47,13 @@ public class ContentProvider implements Closeable {
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("PrivateApi")
|
||||||
private Method getCallMethod() throws NoSuchMethodException {
|
private Method getCallMethod() throws NoSuchMethodException {
|
||||||
if (callMethod == null) {
|
if (callMethod == null) {
|
||||||
try {
|
try {
|
||||||
@SuppressLint("PrivateApi")
|
|
||||||
Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
|
Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
|
||||||
callMethod = provider.getClass().getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
|
callMethod = provider.getClass().getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 0;
|
||||||
} catch (NoSuchMethodException | ClassNotFoundException e0) {
|
} catch (NoSuchMethodException | ClassNotFoundException e0) {
|
||||||
// old versions
|
// old versions
|
||||||
try {
|
try {
|
||||||
@ -73,6 +74,7 @@ public class ContentProvider implements Closeable {
|
|||||||
return callMethod;
|
return callMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("PrivateApi")
|
||||||
private Object getAttributionSource()
|
private Object getAttributionSource()
|
||||||
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
if (attributionSource == null) {
|
if (attributionSource == null) {
|
||||||
@ -102,7 +104,8 @@ public class ContentProvider implements Closeable {
|
|||||||
default:
|
default:
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
||||||
break;
|
break;
|
||||||
} return (Bundle) method.invoke(provider, args);
|
}
|
||||||
|
return (Bundle) method.invoke(provider, args);
|
||||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
|
||||||
Ln.e("Could not invoke method", e);
|
Ln.e("Could not invoke method", e);
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user