Skip to content

Commit

Permalink
Reorganize server packages
Browse files Browse the repository at this point in the history
There are now a lot of classes in the server, reorganize them into
subpackages.
  • Loading branch information
rom1v committed Jul 11, 2024
1 parent 80ca7b1 commit e84db29
Show file tree
Hide file tree
Showing 67 changed files with 205 additions and 71 deletions.
5 changes: 5 additions & 0 deletions server/build_without_gradle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ cd "$SERVER_DIR/src/main/aidl"

SRC=( \
com/genymobile/scrcpy/*.java \
com/genymobile/scrcpy/audio/*.java \
com/genymobile/scrcpy/control/*.java \
com/genymobile/scrcpy/device/*.java \
com/genymobile/scrcpy/util/*.java \
com/genymobile/scrcpy/video/*.java \
com/genymobile/scrcpy/wrappers/*.java \
)

Expand Down
5 changes: 5 additions & 0 deletions server/src/main/java/com/genymobile/scrcpy/CleanUp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.genymobile.scrcpy;

import com.genymobile.scrcpy.device.Device;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.Settings;
import com.genymobile.scrcpy.util.SettingsException;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/java/com/genymobile/scrcpy/Options.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package com.genymobile.scrcpy;

import com.genymobile.scrcpy.audio.AudioCodec;
import com.genymobile.scrcpy.audio.AudioSource;
import com.genymobile.scrcpy.device.Size;
import com.genymobile.scrcpy.util.CodecOption;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.video.CameraAspectRatio;
import com.genymobile.scrcpy.video.CameraFacing;
import com.genymobile.scrcpy.video.VideoCodec;
import com.genymobile.scrcpy.video.VideoSource;

import android.graphics.Rect;

import java.util.List;
Expand Down
21 changes: 21 additions & 0 deletions server/src/main/java/com/genymobile/scrcpy/Server.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
package com.genymobile.scrcpy;

import com.genymobile.scrcpy.audio.AudioCapture;
import com.genymobile.scrcpy.audio.AudioCodec;
import com.genymobile.scrcpy.audio.AudioEncoder;
import com.genymobile.scrcpy.audio.AudioRawRecorder;
import com.genymobile.scrcpy.control.ControlChannel;
import com.genymobile.scrcpy.control.Controller;
import com.genymobile.scrcpy.control.DeviceMessage;
import com.genymobile.scrcpy.device.ConfigurationException;
import com.genymobile.scrcpy.device.DesktopConnection;
import com.genymobile.scrcpy.device.Device;
import com.genymobile.scrcpy.device.Streamer;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.LogUtils;
import com.genymobile.scrcpy.util.Settings;
import com.genymobile.scrcpy.util.SettingsException;
import com.genymobile.scrcpy.video.CameraCapture;
import com.genymobile.scrcpy.video.ScreenCapture;
import com.genymobile.scrcpy.video.SurfaceCapture;
import com.genymobile.scrcpy.video.SurfaceEncoder;
import com.genymobile.scrcpy.video.VideoSource;

import android.os.BatteryManager;
import android.os.Build;

Expand Down
2 changes: 2 additions & 0 deletions server/src/main/java/com/genymobile/scrcpy/Workarounds.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.genymobile.scrcpy;

import com.genymobile.scrcpy.util.Ln;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Application;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

import com.genymobile.scrcpy.FakeContext;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.Workarounds;
import com.genymobile.scrcpy.wrappers.ServiceManager;

import android.annotation.SuppressLint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

/**
* Exception thrown if audio capture failed on Android 11 specifically because the running App (shell) was not in foreground.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

import com.genymobile.scrcpy.util.Codec;

import android.media.MediaFormat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

import com.genymobile.scrcpy.AsyncProcessor;
import com.genymobile.scrcpy.util.Codec;
import com.genymobile.scrcpy.util.CodecOption;
import com.genymobile.scrcpy.util.CodecUtils;
import com.genymobile.scrcpy.device.ConfigurationException;
import com.genymobile.scrcpy.util.IO;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.LogUtils;
import com.genymobile.scrcpy.device.Streamer;

import android.annotation.TargetApi;
import android.media.MediaCodec;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

import com.genymobile.scrcpy.AsyncProcessor;
import com.genymobile.scrcpy.util.IO;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.device.Streamer;

import android.media.MediaCodec;
import android.os.Build;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.audio;

import android.media.MediaRecorder;

Expand All @@ -18,7 +18,7 @@ int value() {
return value;
}

static AudioSource findByName(String name) {
public static AudioSource findByName(String name) {
for (AudioSource audioSource : AudioSource.values()) {
if (name.equals(audioSource.name)) {
return audioSource;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import android.net.LocalSocket;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.device.Position;

/**
* Union of all supported event types, identified by their {@code type}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.util.Binary;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.device.Position;

import java.io.EOFException;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.genymobile.scrcpy;

package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.AsyncProcessor;
import com.genymobile.scrcpy.CleanUp;
import com.genymobile.scrcpy.device.Device;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.device.Point;
import com.genymobile.scrcpy.device.Position;
import com.genymobile.scrcpy.wrappers.InputManager;
import com.genymobile.scrcpy.wrappers.ServiceManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

public final class DeviceMessage {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.util.Ln;

import java.io.IOException;
import java.util.concurrent.ArrayBlockingQueue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.StringUtils;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.device.Point;

public class Pointer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.device.Point;

import android.view.MotionEvent;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.control;

import com.genymobile.scrcpy.util.Ln;

import android.os.Build;
import android.os.HandlerThread;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

public class ConfigurationException extends Exception {
public ConfigurationException(String message) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import com.genymobile.scrcpy.control.ControlChannel;
import com.genymobile.scrcpy.util.IO;
import com.genymobile.scrcpy.util.StringUtils;

import android.net.LocalServerSocket;
import android.net.LocalSocket;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import com.genymobile.scrcpy.Options;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.util.LogUtils;
import com.genymobile.scrcpy.video.ScreenInfo;
import com.genymobile.scrcpy.wrappers.ClipboardManager;
import com.genymobile.scrcpy.wrappers.DisplayControl;
import com.genymobile.scrcpy.wrappers.InputManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

public final class DisplayInfo {
private final int displayId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import android.graphics.Rect;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.device;

import com.genymobile.scrcpy.audio.AudioCodec;
import com.genymobile.scrcpy.util.Codec;
import com.genymobile.scrcpy.util.IO;

import android.media.MediaCodec;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

public final class Binary {
private Binary() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

public interface Codec {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import com.genymobile.scrcpy.audio.AudioCodec;
import com.genymobile.scrcpy.video.VideoCodec;

import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import java.io.IOException;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import android.os.Handler;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import com.genymobile.scrcpy.BuildConfig;

import android.system.ErrnoException;
import android.system.Os;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import android.util.Log;

Expand All @@ -19,7 +19,7 @@ public final class Ln {
private static final PrintStream CONSOLE_OUT = new PrintStream(new FileOutputStream(FileDescriptor.out));
private static final PrintStream CONSOLE_ERR = new PrintStream(new FileOutputStream(FileDescriptor.err));

enum Level {
public enum Level {
VERBOSE, DEBUG, INFO, WARN, ERROR
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import com.genymobile.scrcpy.device.DisplayInfo;
import com.genymobile.scrcpy.device.Size;
import com.genymobile.scrcpy.wrappers.DisplayManager;
import com.genymobile.scrcpy.wrappers.ServiceManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

import com.genymobile.scrcpy.wrappers.ContentProvider;
import com.genymobile.scrcpy.wrappers.ServiceManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

public class SettingsException extends Exception {
private static String createMessage(String method, String table, String key, String value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.util;

public final class StringUtils {
private StringUtils() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.video;

public final class CameraAspectRatio {
private static final float SENSOR = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.genymobile.scrcpy;
package com.genymobile.scrcpy.video;

import com.genymobile.scrcpy.util.HandlerExecutor;
import com.genymobile.scrcpy.util.Ln;
import com.genymobile.scrcpy.device.Size;
import com.genymobile.scrcpy.wrappers.ServiceManager;

import android.annotation.SuppressLint;
Expand Down
Loading

0 comments on commit e84db29

Please sign in to comment.