mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-30 23:30:32 +01:00
Merge Send keyframes less often (#151)
This commit is contained in:
commit
ecf24c4ecc
2 files changed
+10
-4
No files matched your search
@@ -125,6 +125,8 @@ class GearslipRunner(
|
|||||||
@Volatile private var acksSeen = 0
|
@Volatile private var acksSeen = 0
|
||||||
@Volatile private var lastAckAt = 0L
|
@Volatile private var lastAckAt = 0L
|
||||||
@Volatile private var splitMessages = 0
|
@Volatile private var splitMessages = 0
|
||||||
|
/** Keyframes sent since the last stats line, to tell its windows with one from those without. */
|
||||||
|
@Volatile private var keyframesInWindow = 0
|
||||||
@Volatile private var resyncRequested = false
|
@Volatile private var resyncRequested = false
|
||||||
@Volatile private var resyncAttempts = 0
|
@Volatile private var resyncAttempts = 0
|
||||||
@Volatile private var lastKeyframeSentAt = 0L
|
@Volatile private var lastKeyframeSentAt = 0L
|
||||||
@@ -1402,6 +1404,7 @@ class GearslipRunner(
|
|||||||
resyncRequested = false
|
resyncRequested = false
|
||||||
resyncAttempts = 0
|
resyncAttempts = 0
|
||||||
lastKeyframeSentAt = System.currentTimeMillis()
|
lastKeyframeSentAt = System.currentTimeMillis()
|
||||||
|
keyframesInWindow++
|
||||||
}
|
}
|
||||||
// Counted before it's queued: the writer may send it and the ack come back before this
|
// Counted before it's queued: the writer may send it and the ack come back before this
|
||||||
// thread runs again, and an ack counted ahead of its frame would leave the window full.
|
// thread runs again, and an ack counted ahead of its frame would leave the window full.
|
||||||
@@ -1714,10 +1717,12 @@ class GearslipRunner(
|
|||||||
// head unit's acks, not the phone, set the frame rate.
|
// head unit's acks, not the phone, set the frame rate.
|
||||||
val waited = ackWaitMs
|
val waited = ackWaitMs
|
||||||
ackWaitMs = 0
|
ackWaitMs = 0
|
||||||
|
val keys = keyframesInWindow
|
||||||
|
keyframesInWindow = 0
|
||||||
SessionReport.stream("${"%.1f".format(fps)} fps, sent=$sent acked=$acksSeen")
|
SessionReport.stream("${"%.1f".format(fps)} fps, sent=$sent acked=$acksSeen")
|
||||||
log.i(
|
log.i(
|
||||||
"video: ${"%.1f".format(fps)} fps over 5s | sent=$sent waited=${waited}ms " +
|
"video: ${"%.1f".format(fps)} fps over 5s | sent=$sent waited=${waited}ms " +
|
||||||
"acked=$acksSeen inFlight=$inFlight split=$splitMessages " +
|
"acked=$acksSeen inFlight=$inFlight split=$splitMessages keys=$keys " +
|
||||||
"kbps=${(videoSource?.bitRate ?: 0) / 1000}",
|
"kbps=${(videoSource?.bitRate ?: 0) / 1000}",
|
||||||
)
|
)
|
||||||
adaptBitRate(fps, waited)
|
adaptBitRate(fps, waited)
|
||||||
@@ -1866,6 +1871,6 @@ class GearslipRunner(
|
|||||||
const val WITHHELD_SCREEN_MS = 5_000L
|
const val WITHHELD_SCREEN_MS = 5_000L
|
||||||
const val AUDIO_TRACE_MESSAGES = 6
|
const val AUDIO_TRACE_MESSAGES = 6
|
||||||
const val GUIDANCE_SESSION_ID = 1
|
const val GUIDANCE_SESSION_ID = 1
|
||||||
const val PERIODIC_KEYFRAME_MS = 5_000L
|
const val PERIODIC_KEYFRAME_MS = 15_000L
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +81,8 @@ class VideoSource(
|
|||||||
setInteger(MediaFormat.KEY_BIT_RATE, bitRate)
|
setInteger(MediaFormat.KEY_BIT_RATE, bitRate)
|
||||||
setInteger(MediaFormat.KEY_FRAME_RATE, frameRate)
|
setInteger(MediaFormat.KEY_FRAME_RATE, frameRate)
|
||||||
// Drops already ask for a fresh keyframe, so a long interval costs nothing in recovery
|
// Drops already ask for a fresh keyframe, so a long interval costs nothing in recovery
|
||||||
// and spares the link a big frame every second.
|
// and spares the link a big frame: a SOOEMAKA's came to 87-99 KB, against about 14 KB
|
||||||
|
// for the frames between.
|
||||||
setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL_S)
|
setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, I_FRAME_INTERVAL_S)
|
||||||
if (mode == Mode.SURFACE) {
|
if (mode == Mode.SURFACE) {
|
||||||
// A surface encoder only makes a frame when the screen changes, and many decoders
|
// A surface encoder only makes a frame when the screen changes, and many decoders
|
||||||
@@ -324,7 +325,7 @@ class VideoSource(
|
|||||||
* where real Android Auto's wireless ones do, so Wi-Fi only gets this cap.
|
* where real Android Auto's wireless ones do, so Wi-Fi only gets this cap.
|
||||||
*/
|
*/
|
||||||
const val WIRELESS_MAX_BIT_RATE = 8_000_000
|
const val WIRELESS_MAX_BIT_RATE = 8_000_000
|
||||||
const val I_FRAME_INTERVAL_S = 5
|
const val I_FRAME_INTERVAL_S = 60
|
||||||
private const val REPEAT_AFTER_US = 100_000L
|
private const val REPEAT_AFTER_US = 100_000L
|
||||||
|
|
||||||
/** (Y, Cb, Cr) - white, yellow, cyan, green, magenta, red, blue. */
|
/** (Y, Cb, Cr) - white, yellow, cyan, green, magenta, red, blue. */
|
||||||
|
|||||||
Reference in new issue
Block a user