Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions app/src/main/java/com/openipc/pixelpilot/VideoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public static String bytesToHex(byte[] bytes) {
}

private void resetApp() {
// Finalize an active recording first. System.exit() below skips every lifecycle
// callback, and the MP4 is only closed when the DVR thread exits; stopDvr() joins
// it. No-op when nothing is recording.
stopDvr();
// Restart the app
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
if (intent != null) {
Expand Down Expand Up @@ -685,6 +689,11 @@ private void setupBandwidthSubMenu(PopupMenu popup) {
* "Low latency" sets the MediaCodec low-latency and realtime-priority keys. It is on
* by default; decoders that misbehave with those keys can be put back on the stock
* pipeline here.
*
* The keys are only applied when the codec is configured, and the codec is only torn
* down when its surface goes away, not on a channel change or on VideoPlayer
* stop()/start(). So the toggle restarts the app, the same way the VR mode toggle
* does, instead of promising an "on next video start" that never comes.
*/
private void setupVideoSubMenu(PopupMenu popup) {
SubMenu videoMenu = popup.getMenu().addSubMenu("Video");
Expand All @@ -695,13 +704,13 @@ private void setupVideoSubMenu(PopupMenu popup) {
lowLatencyItem.setOnMenuItemClickListener(item -> {
boolean enabled = !item.isChecked();
item.setChecked(enabled);
// commit(), not apply(): resetApp() ends the process with System.exit()
// before an asynchronous write would be flushed.
getSharedPreferences("general", MODE_PRIVATE).edit()
.putBoolean("low_latency_decoder", enabled).apply();
videoPlayer.setLowLatency(enabled);
Toast.makeText(this, "Low latency " + (enabled ? "enabled" : "disabled")
+ ", applies on next video start.", Toast.LENGTH_SHORT).show();
.putBoolean("low_latency_decoder", enabled).commit();
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
item.setActionView(new View(this));
resetApp();
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
return false;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ static void h264_configureAMediaFormat(KeyFrameFinder& kff, AMediaFormat* format
// AMediaFormat_setInt32(format,AMEDIAFORMAT_KEY_FRAME_RATE,60);
// AVCProfileBaseline==1
// AMediaFormat_setInt32(decoder.format,AMEDIAFORMAT_KEY_PROFILE,1);
// AMediaFormat_setInt32(decoder.format,AMEDIAFORMAT_KEY_PRIORITY,0);
}

static void h265_configureAMediaFormat(KeyFrameFinder& kff, AMediaFormat* format)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public boolean isRunning() {
* Takes effect the next time the decoder is configured.
*/
public void setLowLatency(boolean enabled) {
verifyApplicationThread();
nativeSetLowLatency(nativeVideoPlayer, enabled);
}

Expand Down