Repository navigation
feat: per-slot Turn in the camera settings, H.264/H.265 turned by the decoder (#201) #225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
compot-dev
wants to merge
6
commits into
v2
Choose a base branch
from
feat/rotate-201
base: v2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e94ac24
feat: ?rotate= turns H.264/H.265 too, by the decoder (KEY_ROTATION, #…
compot-dev c2dab1b
feat: per-slot Turn and Mirror in the camera settings, for H.264/H.26…
compot-dev 7fc37d6
chore: version 2.18 (2.17 is #220)
compot-dev 7ba271d
fix: snapshots and screenshots follow the decoder's turn; no mirror f…
compot-dev 056c794
fix: snapshots and screenshots copy the turned picture as is, PixelCo…
compot-dev 22f4d0a
fix: the turn is set before any frame of a connection, the Turn row s…
compot-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,8 @@ public class Decoder extends Activity | |
| private final String[] mHosts = new String[CAM_COUNT]; | ||
| /** RTP transport per slot (#67): TCP, UDP or Auto (UDP with fallback to TCP). */ | ||
| private final Transport.Mode[] mTransports = new Transport.Mode[CAM_COUNT]; | ||
| /** Per slot (#201): degrees counter-clockwise, -1 for Auto (from the URL). */ | ||
| private final int[] mRotates = new int[CAM_COUNT]; | ||
| private int mActive; | ||
| private volatile String mHost; | ||
| private String mVersion; | ||
|
|
@@ -209,7 +211,13 @@ protected void onCreate(Bundle savedInstanceState) { | |
|
|
||
| // --- Create managers --- | ||
| videoDecoder = new MediaCodecManager(new MediaCodecManager.Listener() { | ||
| @Override public void onResolutionChanged(int w, int h) { updateResolution(w, h); } | ||
| @Override public void onResolutionChanged(int w, int h) { | ||
| // The decoder turns the picture (#201): a quarter turn swaps its sides | ||
| RtspClient c = rtspClient; | ||
| int r = c != null ? c.rotate() : 0; | ||
| if (r == 90 || r == 270) updateResolution(h, w); | ||
| else updateResolution(w, h); | ||
| } | ||
| @Override public void onDecoderStarted() { removeClearOverlay(); } | ||
| @Override public void onDecoderFailed() {} | ||
| }); | ||
|
|
@@ -396,7 +404,7 @@ public void onToggleQuad() { | |
| if (configured) { | ||
| // A probe of this camera ends first: some take one client only (#100) | ||
| streamProbes.willShow(mHost); | ||
| rtspClient.configure(mHost, mUserAgent, mTransports[mActive]); | ||
| configureClient(); | ||
| startListener(); | ||
| rtspClient.start(); | ||
| } | ||
|
|
@@ -580,7 +588,9 @@ private void restartClean() { | |
| } | ||
|
|
||
| @Override | ||
| public void onShowSettings() { menuManager.showUrlEditor(mActive, mHosts, mTransports); } | ||
| public void onShowSettings() { | ||
| menuManager.showUrlEditor(mActive, mHosts, mTransports, mRotates); | ||
| } | ||
|
|
||
| @Override | ||
| public void onWebUI() { menuManager.startBrowser(mHost); } | ||
|
|
@@ -590,8 +600,16 @@ private void restartClean() { | |
|
|
||
| // ====================== Video lifecycle ====================== | ||
|
|
||
| /** The single view's client for the active slot, with the slot's turn (#201). */ | ||
| private void configureClient() { | ||
| rtspClient.configure(mHost, mUserAgent, mTransports[mActive]); | ||
| rtspClient.setSlotTurn(mRotates[mActive]); | ||
| } | ||
|
|
||
| private void createDecoder() { | ||
| videoDecoder.setSurface(mVideoSurface); | ||
| RtspClient c = rtspClient; | ||
| videoDecoder.setRotation(c != null ? c.rotate() : 0); | ||
| videoDecoder.createDecoder(codecH265); | ||
|
Comment on lines
+611
to
613
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Reconnects can leave video unturned createDecoder() and the grid decode path capture rotate() when creating a codec, but RtspSession.connect() temporarily resets URL-derived rotation to zero before the new stream description arrives. If a queued frame creates a decoder during that interval, the later description restores the rotation value without recreating the H.264/H.265 decoder, so that decoder keeps the wrong turn. Agent Prompt
|
||
| } | ||
|
|
||
|
|
@@ -631,6 +649,7 @@ private void loadSettings() { | |
| mUnreadable[i] = url == null && stored != null ? stored : null; | ||
| // Auto for a slot that has never stored one (#112) | ||
| mTransports[i] = Transport.Mode.stored(pref.getString("transport_" + i, null)); | ||
| mRotates[i] = pref.getInt("rotate_" + i, -1); | ||
| // Plain URLs from older versions are re-saved encrypted right away | ||
| if (credentials.needsMigration(stored)) { | ||
| if (migrate == null) migrate = pref.edit(); | ||
|
|
@@ -693,6 +712,7 @@ private void saveSettings() { | |
| edit.putString("host_" + i, | ||
| credentials.sealForSlot(mHosts[i], mUnreadable[i], DEFAULT_URL)); | ||
| edit.putString("transport_" + i, mTransports[i].name()); | ||
| edit.putInt("rotate_" + i, mRotates[i]); | ||
| } | ||
| edit.apply(); | ||
|
|
||
|
|
@@ -715,7 +735,7 @@ private void saveSettings() { | |
|
|
||
| // A probe of this camera ends first: some take one client only (#100) | ||
| streamProbes.willShow(mHost); | ||
| rtspClient.configure(mHost, mUserAgent, mTransports[mActive]); | ||
| configureClient(); | ||
| startListener(); | ||
| rtspClient.start(); | ||
| } | ||
|
|
@@ -1002,6 +1022,7 @@ private void createQuadCells() { | |
| Transport.Mode mode = i == U_CELL ? Transport.Mode.UDP : mTransports[i]; | ||
| quadCells[i] = new QuadCell(i, url, mode, quadViews[i], framePool, mUserAgent, | ||
| index -> runOnUiThread(() -> removeQuadOverlay(index))); | ||
| quadCells[i].setSlotTurn(i < CAM_COUNT ? mRotates[i] : -1); | ||
| quadCells[i].start(); | ||
| } | ||
| quadAudio = getSharedPreferences("settings", MODE_PRIVATE).getInt("quad_audio", -1); | ||
|
|
@@ -1603,8 +1624,8 @@ private Map<String, Object> debugState() { | |
| if (jl != null) single.put("jieli", jl); | ||
| Map<String, Object> hb = rtspClient != null ? rtspClient.heartbeatStats() : null; | ||
| if (hb != null) single.put("heartbeat", hb); | ||
| // MJPEG turned counter-clockwise, "size" is the turned one (#200) | ||
| int rotate = rtspClient != null && rtspClient.isJpeg() ? rtspClient.rotate() : 0; | ||
| // Turned counter-clockwise, "size" is the turned one (#200, #201) | ||
| int rotate = rtspClient != null ? rtspClient.rotate() : 0; | ||
| if (rotate != 0) single.put("rotate", rotate); | ||
| m.put("single", single); | ||
| } | ||
|
|
@@ -2600,7 +2621,7 @@ private void startStreams() { | |
| if (configured) { | ||
| // A probe of this camera ends first: some take one client only (#100) | ||
| streamProbes.willShow(mHost); | ||
| rtspClient.configure(mHost, mUserAgent, mTransports[mActive]); | ||
| configureClient(); | ||
| startListener(); | ||
| rtspClient.start(); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Older android streams get the wrong fit
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools