This commit is contained in:
JerryXiao 2023-08-17 22:56:02 +08:00
parent 477bd580e9
commit 27bd52d415
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5
9 changed files with 258 additions and 133 deletions

View file

@ -23,8 +23,8 @@ android {
} }
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_17
} }
} }

View file

@ -26,9 +26,11 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true">
<!--
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" > android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" >
-->
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -39,7 +41,6 @@
<activity <activity
android:name=".SettingsActivity" android:name=".SettingsActivity"
android:exported="false" android:exported="false"
android:launchMode="singleInstance"
android:label="@string/title_activity_settings"> android:label="@string/title_activity_settings">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"

View file

@ -2,6 +2,7 @@ package com.jerryxiao.droidcast;
import androidx.activity.result.ActivityResultLauncher; import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts; import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
@ -13,90 +14,142 @@ import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.util.Log;
import android.widget.Button; import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.pedro.rtplibrary.rtmp.RtmpDisplay; import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static final String TAG = "MainActivity";
private RtmpDisplay screenCapDisplay;
private ActivityResultLauncher<Intent> screenCapReq; private ActivityResultLauncher<Intent> screenCapReq;
private ScreenCapService screenCapService; private ScreenCapService screenCapService;
private Button startButton;
private TextView infoDisplay;
private SharedPreferences prefs; private SharedPreferences prefs;
private final ServiceConnection serviceConnection = new ServiceConnection() { private final ServiceConnection serviceConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName componentName, IBinder binder) { private void updateButtonText(boolean connected) {
MainActivity.this.screenCapService = ((ScreenCapService.MBinder)binder).getService(); Log.d(TAG, String.format("updateButtonText: %b", connected));
MainActivity.this.screenCapDisplay = MainActivity.this.screenCapService.getScreenCapDisplay();
MainActivity.this.screenCapReq.launch(MainActivity.this.screenCapDisplay.sendIntent());
MainActivity.this.screenCapService.addDisconnectCallback(() -> {
unbindService(serviceConnection);
runOnUiThread(() -> {
startButton.setText(getString(R.string.start_button));
});
MainActivity.this.screenCapService = null;
});
MainActivity.this.screenCapService.addInfoDisplayCallback((t) -> {
runOnUiThread(() -> {
MainActivity.this.infoDisplay.setText(t);
});
});
runOnUiThread(() -> { runOnUiThread(() -> {
MainActivity.this.startButton.setText(getString(R.string.stop_button)); ((Button)MainActivity.this.findViewById(R.id.startButton)).setText(connected
? getString(R.string.stop_button)
: getString(R.string.start_button));
}); });
} }
private void updateInfoDisplay(String t) {
Log.d(TAG, String.format("updateInfoDisplay: %s", t));
runOnUiThread(() -> {
((TextView)MainActivity.this.findViewById(R.id.infoDisplay)).setText(t);
});
}
public void onServiceConnected(ComponentName componentName, IBinder binder) {
Log.d(TAG, "service connected");
MainActivity.this.screenCapService = ((ScreenCapService.MBinder)binder).getService();
MainActivity.this.screenCapService.addConnectionStateCallback(this::updateButtonText);
MainActivity.this.screenCapService.addInfoDisplayCallback(this::updateInfoDisplay);
this.updateButtonText(MainActivity.this.screenCapService != null && MainActivity.this.screenCapService.isConnected());
this.updateInfoDisplay(MainActivity.this.screenCapService.getInfoDisplayText());
}
public void onServiceDisconnected(ComponentName componentName) { public void onServiceDisconnected(ComponentName componentName) {
Log.d(TAG, "service disconnected");
MainActivity.this.screenCapService.removeConnectionStateCallback(this::updateButtonText);
MainActivity.this.screenCapService.removeInfoDisplayCallback(this::updateInfoDisplay);
} }
}; };
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.d(TAG, "activity created");
this.prefs = PreferenceManager.getDefaultSharedPreferences(this); this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
setContentView(R.layout.main_activity); setContentView(R.layout.main_activity);
Map<String, String> permissionsToRequest = Collections.emptyMap();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
permissionsToRequest = new HashMap<>(Map.of("android.permission.POST_NOTIFICATIONS",
getString(R.string.permission_denied_post_notifications)));
if (checkSelfPermission("android.permission.POST_NOTIFICATIONS") != PackageManager.PERMISSION_GRANTED) { if (checkSelfPermission("android.permission.POST_NOTIFICATIONS") != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{"android.permission.POST_NOTIFICATIONS"}, 0); requestPermissions(new String[]{"android.permission.POST_NOTIFICATIONS"}, 0);
} }
} }
else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) { else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
if (checkSelfPermission("android.permission.RECORD_AUDIO") != PackageManager.PERMISSION_GRANTED) { permissionsToRequest = new HashMap<>(Map.of("android.permission.RECORD_AUDIO",
requestPermissions(new String[]{"android.permission.RECORD_AUDIO"}, 0); getString(R.string.permission_denied_record_audio)));
} }
permissionsToRequest.entrySet().removeIf(i -> checkSelfPermission(i.getKey()) == PackageManager.PERMISSION_GRANTED);
if (!permissionsToRequest.isEmpty()) {
Log.d(TAG, String.format("requesting permissions %s", String.join(" + ", permissionsToRequest.keySet().toArray(new String[0]))));
Map<String, String> finalPermissionsToRequest = permissionsToRequest;
ActivityResultLauncher<String[]> permissionReq = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), (result) -> {
result.forEach((perm, granted) -> {
if (!granted) {
Log.d(TAG, String.format("permission denied: %s", perm));
(new AlertDialog.Builder(this))
.setTitle(getText(R.string.error_title))
.setMessage(finalPermissionsToRequest.get(perm))
.setCancelable(false)
.setPositiveButton(getString(R.string.button_ok), (dialog, id) -> {})
.create()
.show();
}
});
});
permissionReq.launch(permissionsToRequest.keySet().toArray(new String[0]));
} }
this.startButton = (Button)this.findViewById(R.id.startButton);
this.infoDisplay = (TextView)this.findViewById(R.id.infoDisplay);
this.screenCapReq = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), (activityResult) -> { this.screenCapReq = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), (activityResult) -> {
int result = activityResult.getResultCode(); int result = activityResult.getResultCode();
screenCapDisplay.setIntentResult(result, activityResult.getData()); screenCapService.getScreenCapDisplay().setIntentResult(result, activityResult.getData());
if (result == RESULT_OK) { if (result == RESULT_OK) {
Log.d(TAG, "capture granted");
screenCapService.startCapture(prefs.getString("server", "")); screenCapService.startCapture(prefs.getString("server", ""));
} }
else { else {
runOnUiThread(() -> { runOnUiThread(() -> {
Toast.makeText(MainActivity.this, getText(R.string.error_capture_denied), Toast.LENGTH_SHORT).show(); Log.d(TAG, "capture denied");
(new AlertDialog.Builder(this))
.setTitle(getText(R.string.error_title))
.setMessage(getText(R.string.error_capture_denied))
.setCancelable(false)
.setPositiveButton(getString(R.string.button_ok), (dialog, id) -> {})
.create()
.show();
}); });
screenCapService.stopCapture();
} }
}); });
this.startButton.setOnClickListener((view) -> { bindService(new Intent(this, ScreenCapService.class), serviceConnection, BIND_AUTO_CREATE);
((Button)this.findViewById(R.id.startButton)).setOnClickListener((view) -> {
if (screenCapService != null) { if (screenCapService != null) {
new Thread(() -> { if (screenCapService.isConnected()) {
screenCapService.stopCapture(); Log.d(TAG, "button stop");
}).start(); new Thread(() -> { if (screenCapService.getScreenCapDisplay() != null) screenCapService.getScreenCapDisplay().stopStream(); }).start();
}
else {
Log.d(TAG, "button start");
MainActivity.this.screenCapService.createDisplay();
MainActivity.this.screenCapReq.launch(MainActivity.this.screenCapService.getScreenCapDisplay().sendIntent());
}
} }
else { else {
Intent intent = new Intent(this, ScreenCapService.class); Log.e(TAG, "service died");
bindService(intent, serviceConnection, BIND_AUTO_CREATE); (new AlertDialog.Builder(this))
.setTitle(getText(R.string.error_title))
.setMessage(getText(R.string.error_service_died))
.setCancelable(false)
.setPositiveButton(getString(R.string.button_ok), (dialog, id) -> {})
.create()
.show();
} }
}); });
Button settingsButton = (Button)this.findViewById(R.id.settingsButton); ((Button)this.findViewById(R.id.settingsButton)).setOnClickListener((view) -> {
settingsButton.setOnClickListener((view) -> { startActivity(new Intent(this, SettingsActivity.class));
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
}); });
} }
@Override
protected void onDestroy() {
super.onDestroy();
Log.d(TAG, "activity destroyed");
unbindService(serviceConnection);
this.screenCapService = null;
}
} }

View file

@ -15,6 +15,7 @@ import android.os.Binder;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
@ -26,14 +27,21 @@ import com.pedro.encoder.utils.CodecUtil;
import com.pedro.rtmp.utils.ConnectCheckerRtmp; import com.pedro.rtmp.utils.ConnectCheckerRtmp;
import com.pedro.rtplibrary.rtmp.RtmpDisplay; import com.pedro.rtplibrary.rtmp.RtmpDisplay;
import java.util.LinkedList; import java.util.HashSet;
import java.util.function.Consumer; import java.util.function.Consumer;
public class ScreenCapService extends Service { public class ScreenCapService extends Service {
private static final String TAG = "ScreenCapService";
private static final int RESOLUTION_GAP = 100000; private static final int RESOLUTION_GAP = 100000;
private final LinkedList<Runnable> disconnectCallbacks = new LinkedList<>(); private final HashSet<Consumer<Boolean>> connectionStateCallbacks = new HashSet<>();
private final LinkedList<Consumer<String>> infoDisplayCallbacks = new LinkedList<>(); private final HashSet<Consumer<String>> infoDisplayCallbacks = new HashSet<>();
private SharedPreferences prefs; private SharedPreferences prefs;
private boolean connected = false;
public boolean isConnected() {
return connected;
}
protected class MBinder extends Binder { protected class MBinder extends Binder {
public ScreenCapService getService() { public ScreenCapService getService() {
return ScreenCapService.this; return ScreenCapService.this;
@ -46,6 +54,10 @@ public class ScreenCapService extends Service {
public RtmpDisplay getScreenCapDisplay() { public RtmpDisplay getScreenCapDisplay() {
return this.screenCapDisplay; return this.screenCapDisplay;
} }
private String infoDisplayText = "";
public String getInfoDisplayText() {
return infoDisplayText;
}
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
return this.mBinder; return this.mBinder;
@ -53,70 +65,66 @@ public class ScreenCapService extends Service {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Log.d(TAG, "service created");
this.prefs = PreferenceManager.getDefaultSharedPreferences(this); this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
this.screenCapDisplay = new RtmpDisplay(this, prefs.getBoolean("use_gl", true), new ConnectCheckerRtmp() { this.infoDisplayText = getString(R.string.status_disconnected);
}
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "service destroyed");
}
protected void createDisplay() {
boolean use_gl = prefs.getBoolean("use_gl", true);
Log.d(TAG, String.format("creating display use_gl=%b", use_gl));
this.screenCapDisplay = new RtmpDisplay(this, use_gl, new ConnectCheckerRtmp() {
public void onAuthErrorRtmp() { public void onAuthErrorRtmp() {
String text = getString(R.string.status_auth_error); String text = getString(R.string.status_auth_error);
(new Handler(Looper.getMainLooper())).post(() -> { showToast(text);
Toast.makeText(ScreenCapService.this, text, Toast.LENGTH_SHORT).show(); setInfoDisplay(text);
});
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) {
stringConsumer.accept(text);
}
ScreenCapService.this.stop(); ScreenCapService.this.stop();
} }
public void onAuthSuccessRtmp() { public void onAuthSuccessRtmp() {
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) { setInfoDisplay(getString(R.string.status_auth_success));
stringConsumer.accept(getString(R.string.status_auth_success));
}
} }
public void onConnectionFailedRtmp(@NonNull String reason) { public void onConnectionFailedRtmp(@NonNull String reason) {
String text = getString(R.string.status_connection_failed_format, reason); String text = getString(R.string.status_connection_failed_format, reason);
(new Handler(Looper.getMainLooper())).post(() -> { showToast(text);
Toast.makeText(ScreenCapService.this, text, Toast.LENGTH_SHORT).show(); setInfoDisplay(text);
});
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) {
stringConsumer.accept(text);
}
ScreenCapService.this.stop(); ScreenCapService.this.stop();
} }
public void onConnectionStartedRtmp(@NonNull String rtmpUrl) { public void onConnectionStartedRtmp(@NonNull String rtmpUrl) {
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) { setInfoDisplay(getString(R.string.status_connecting, rtmpUrl));
stringConsumer.accept(getString(R.string.status_connecting)); ScreenCapService.this.connectionStateChange(true);
}
} }
public void onConnectionSuccessRtmp() { public void onConnectionSuccessRtmp() {
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) { setInfoDisplay(getString(R.string.status_connected));
stringConsumer.accept(getString(R.string.status_connected));
}
} }
public void onDisconnectRtmp() { public void onDisconnectRtmp() {
String text = getString(R.string.status_disconnected); setInfoDisplay(getString(R.string.status_disconnected));
(new Handler(Looper.getMainLooper())).post(() -> {
Toast.makeText(ScreenCapService.this, text, Toast.LENGTH_SHORT).show();
});
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) {
stringConsumer.accept(text);
}
ScreenCapService.this.stop(); ScreenCapService.this.stop();
} }
public void onNewBitrateRtmp(long bitrate) { public void onNewBitrateRtmp(long bitrate) {
synchronized (ScreenCapService.this.infoDisplayCallbacks) { setInfoDisplay(getString(R.string.status_bitrate_format, bitrate));
for (Consumer<String> stringConsumer : ScreenCapService.this.infoDisplayCallbacks) {
stringConsumer.accept(getString(R.string.status_bitrate_format, bitrate));
}
}
} }
}); });
} }
protected void startCapture(String server) { protected void startCapture(String server) {
if (this.connected) {
Log.d(TAG, "not starting capture");
return;
}
Log.d(TAG, "start capture");
startService(new Intent(this, ScreenCapService.class));
this.connected = true;
NotificationChannel notificationChannel = new NotificationChannel("notifications", "Notifications", NotificationManager.IMPORTANCE_LOW); NotificationChannel notificationChannel = new NotificationChannel("notifications", "Notifications", NotificationManager.IMPORTANCE_LOW);
notificationChannel.setDescription("Notifications"); notificationChannel.setDescription("Notifications");
getSystemService(NotificationManager.class).createNotificationChannel(notificationChannel); getSystemService(NotificationManager.class).createNotificationChannel(notificationChannel);
@ -129,7 +137,9 @@ public class ScreenCapService extends Service {
screenCapDisplay.setForce(prefs.getBoolean("software_video_encoder", false) ? CodecUtil.Force.SOFTWARE : CodecUtil.Force.FIRST_COMPATIBLE_FOUND, screenCapDisplay.setForce(prefs.getBoolean("software_video_encoder", false) ? CodecUtil.Force.SOFTWARE : CodecUtil.Force.FIRST_COMPATIBLE_FOUND,
prefs.getBoolean("software_audio_encoder", false) ? CodecUtil.Force.SOFTWARE : CodecUtil.Force.FIRST_COMPATIBLE_FOUND); prefs.getBoolean("software_audio_encoder", false) ? CodecUtil.Force.SOFTWARE : CodecUtil.Force.FIRST_COMPATIBLE_FOUND);
screenCapDisplay.setWriteChunkSize(prefs.getInt("write_chunk_size_int", 1024)); screenCapDisplay.setWriteChunkSize(prefs.getInt("write_chunk_size_int", 1024));
screenCapDisplay.setReTries(prefs.getInt("retries_int", 0));
screenCapDisplay.resizeCache(prefs.getInt("cache_size_int", 120)); screenCapDisplay.resizeCache(prefs.getInt("cache_size_int", 120));
screenCapDisplay.setLogs(prefs.getBoolean("enable_droidcast_logs", false));
if (prefs.getBoolean("use_gl", true) && prefs.getBoolean("use_force_render", true)) { if (prefs.getBoolean("use_gl", true) && prefs.getBoolean("use_force_render", true)) {
screenCapDisplay.getGlInterface().setForceRender(true); screenCapDisplay.getGlInterface().setForceRender(true);
} }
@ -150,34 +160,42 @@ public class ScreenCapService extends Service {
video_height = video_width; video_height = video_width;
video_width = tmp; video_width = tmp;
} }
Log.d(TAG, String.format("capture width %d height %d", video_width, video_height));
if (this.screenCapDisplay.prepareInternalAudio(Integer.parseInt(prefs.getString("audio_bitrate", "131072")), 48000, prefs.getBoolean("stereo_audio", true), false, false) && if (this.screenCapDisplay.prepareInternalAudio(Integer.parseInt(prefs.getString("audio_bitrate", "131072")), 48000, prefs.getBoolean("stereo_audio", true), false, false) &&
this.screenCapDisplay.prepareVideo(video_width, video_height, Integer.parseInt(prefs.getString("fps", "30")), Integer.parseInt(prefs.getString("video_bitrate", "10485760")), 0, 320, -1, -1, 2)) { this.screenCapDisplay.prepareVideo(video_width, video_height, Integer.parseInt(prefs.getString("fps", "30")), Integer.parseInt(prefs.getString("video_bitrate", "10485760")), 0, 320, -1, -1, 2)) {
this.screenCapDisplay.startStream(server); this.screenCapDisplay.startStream(server);
} }
else { else {
(new Handler(Looper.getMainLooper())).post(() -> { Log.d(TAG, "cannot prepare video audio");
Toast.makeText(ScreenCapService.this, "Cannot prepare audio and video", Toast.LENGTH_SHORT).show(); String text = getString(R.string.error_prepare_video_audio);
}); setInfoDisplay(text);
showToast(text);
this.stop(); this.stop();
} }
} }
private void stop() { private void stop() {
Log.d(TAG, "stop called");
this.connected = false;
this.stopForeground(true); this.stopForeground(true);
this.stopSelf(); this.stopSelf();
synchronized (this.disconnectCallbacks) { this.connectionStateChange(false);
while (!this.disconnectCallbacks.isEmpty()) { }
this.disconnectCallbacks.pop().run();
private void connectionStateChange(boolean connected) {
synchronized (this.connectionStateCallbacks) {
for (Consumer<Boolean> booleanConsumer : this.connectionStateCallbacks) {
try {
booleanConsumer.accept(connected);
}
catch (Throwable ignored) {}
} }
} }
synchronized (this.infoDisplayCallbacks) {
this.infoDisplayCallbacks.clear();
}
} }
protected void addDisconnectCallback(Runnable runnable) { protected void addConnectionStateCallback(Consumer<Boolean> runnable) {
synchronized (this.disconnectCallbacks) { synchronized (this.connectionStateCallbacks) {
this.disconnectCallbacks.add(runnable); this.connectionStateCallbacks.add(runnable);
} }
} }
@ -187,8 +205,33 @@ public class ScreenCapService extends Service {
} }
} }
protected void stopCapture() { protected void removeConnectionStateCallback(Consumer<Boolean> runnable) {
this.screenCapDisplay.stopStream(); synchronized (this.connectionStateCallbacks) {
this.stop(); this.connectionStateCallbacks.remove(runnable);
}
}
protected void removeInfoDisplayCallback(Consumer<String> stringConsumer) {
synchronized (this.infoDisplayCallbacks) {
this.infoDisplayCallbacks.remove(stringConsumer);
}
}
private void setInfoDisplay(String t) {
synchronized (this.infoDisplayCallbacks) {
this.infoDisplayText = t;
for (Consumer<String> stringConsumer : this.infoDisplayCallbacks) {
try {
stringConsumer.accept(t);
}
catch (Throwable ignored) {}
}
}
}
private void showToast(String text) {
(new Handler(Looper.getMainLooper())).post(() -> {
Toast.makeText(ScreenCapService.this, text, Toast.LENGTH_SHORT).show();
});
} }
} }

View file

@ -20,7 +20,7 @@ public class SettingsActivity extends AppCompatActivity {
} }
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true);
} }
} }

View file

@ -6,38 +6,50 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<Button <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/startButton"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/start_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/infoDisplay" />
<Button
android:id="@+id/settingsButton"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/settings_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/startButton" />
<TextView
android:id="@+id/infoDisplay"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="78dp" app:layout_constraintBottom_toBottomOf="parent"
android:text = "@string/status_disconnected"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.4">
<Button
android:id="@+id/startButton"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="@string/start_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/infoDisplay" />
<Button
android:id="@+id/settingsButton"
android:layout_width="128dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/settings_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/startButton" />
<TextView
android:id="@+id/infoDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:text = "@string/status_disconnected"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -8,7 +8,7 @@
<string name="resolution_title">分辨率</string> <string name="resolution_title">分辨率</string>
<string name="fps_title">每秒帧数</string> <string name="fps_title">每秒帧数</string>
<string name="opengl_title">使用OpenGL</string> <string name="opengl_title">使用OpenGL</string>
<string name="force_render_title">固定比特率替代方</string> <string name="force_render_title">非活动时低帧率替代解决办</string>
<string name="stereo_audio_title">双声道音频</string> <string name="stereo_audio_title">双声道音频</string>
<string name="screen_landscape_title">横屏</string> <string name="screen_landscape_title">横屏</string>
<string name="software_video_encoder_title">使用软件视频编码器</string> <string name="software_video_encoder_title">使用软件视频编码器</string>
@ -20,8 +20,11 @@
<string name="start_button">开始</string> <string name="start_button">开始</string>
<string name="stop_button">停止</string> <string name="stop_button">停止</string>
<string name="settings_button">设置</string> <string name="settings_button">设置</string>
<string name="error_title">发生错误</string>
<string name="error_service_died">服务终止</string>
<string name="error_prepare_video_audio">未能开始视频与音频录制</string>
<string name="error_capture_denied">录像被禁止</string> <string name="error_capture_denied">录像被禁止</string>
<string name="status_connecting">正在连接</string> <string name="status_connecting">正在连接到 %1$s</string>
<string name="status_auth_error">鉴权失败</string> <string name="status_auth_error">鉴权失败</string>
<string name="status_auth_success">鉴权成功</string> <string name="status_auth_success">鉴权成功</string>
<string name="status_connected">已连接</string> <string name="status_connected">已连接</string>
@ -29,4 +32,7 @@
<string name="status_bitrate_format">比特率: %1$d</string> <string name="status_bitrate_format">比特率: %1$d</string>
<string name="status_connection_failed_format">连接失败: %1$s</string> <string name="status_connection_failed_format">连接失败: %1$s</string>
<string name="use_device_resolution">使用设备分辨率</string> <string name="use_device_resolution">使用设备分辨率</string>
<string name="permission_denied_post_notifications">通知权限被禁止</string>
<string name="permission_denied_record_audio">录音权限被禁止在安卓12-上内录音频时这项权限是必需的</string>
<string name="button_ok"></string>
</resources> </resources>

View file

@ -25,6 +25,7 @@
<string-array name="fps_entries"> <string-array name="fps_entries">
<item>120</item> <item>120</item>
<item>60</item> <item>60</item>
<item>45</item>
<item>30</item> <item>30</item>
<item>24</item> <item>24</item>
<item>15</item> <item>15</item>
@ -32,6 +33,7 @@
<string-array name="fps_values"> <string-array name="fps_values">
<item>120</item> <item>120</item>
<item>60</item> <item>60</item>
<item>45</item>
<item>30</item> <item>30</item>
<item>24</item> <item>24</item>
<item>15</item> <item>15</item>

View file

@ -1,6 +1,6 @@
<resources> <resources>
<string name="app_name">DroidCast</string> <string name="app_name">DroidCast</string>
<string name="title_activity_settings">Settings</string> <string name="title_activity_settings">DroidCast Settings</string>
<string name="server_header">Servers</string> <string name="server_header">Servers</string>
<string name="server_title">Server</string> <string name="server_title">Server</string>
@ -8,7 +8,7 @@
<string name="resolution_title">Resolution</string> <string name="resolution_title">Resolution</string>
<string name="fps_title">FPS</string> <string name="fps_title">FPS</string>
<string name="opengl_title">Enable OpenGL</string> <string name="opengl_title">Enable OpenGL</string>
<string name="force_render_title">CBR Hack</string> <string name="force_render_title">Force Render</string>
<string name="stereo_audio_title">Stereo Audio</string> <string name="stereo_audio_title">Stereo Audio</string>
<string name="screen_landscape_title">Landscape</string> <string name="screen_landscape_title">Landscape</string>
<string name="software_video_encoder_title">Software video encoding</string> <string name="software_video_encoder_title">Software video encoding</string>
@ -21,8 +21,7 @@
<string name="start_button">Start</string> <string name="start_button">Start</string>
<string name="stop_button">Stop</string> <string name="stop_button">Stop</string>
<string name="settings_button">Settings</string> <string name="settings_button">Settings</string>
<string name="error_capture_denied">Capture permission denied</string> <string name="status_connecting">Connecting to %1$s</string>
<string name="status_connecting">Connecting</string>
<string name="status_auth_error">Auth Error</string> <string name="status_auth_error">Auth Error</string>
<string name="status_auth_success">Auth Success</string> <string name="status_auth_success">Auth Success</string>
<string name="status_connected">Connected</string> <string name="status_connected">Connected</string>
@ -31,4 +30,13 @@
<string name="status_connection_failed_format">Connection failed: %1$s</string> <string name="status_connection_failed_format">Connection failed: %1$s</string>
<string name="use_device_resolution">Use device resolution</string> <string name="use_device_resolution">Use device resolution</string>
<string name="error_title">Error</string>
<string name="error_capture_denied">Capture permission denied</string>
<string name="error_service_died">Service died</string>
<string name="error_prepare_video_audio">Cannot prepare audio and video</string>
<string name="permission_denied_post_notifications">Notification permission denied</string>
<string name="permission_denied_record_audio">Audio recording permission denied, on Android 12- this is required for internal audio recording</string>
<string name="button_ok">OK</string>
</resources> </resources>