-
-
Notifications
You must be signed in to change notification settings - Fork 902
Description
Describe the bug
Non-monotonic DTS errors occur on the media server side for AAC audio streams after reTry() reconnection. During normal streaming, timestamps are correct. The issue only appears when the connection drops and reTry() re-establishes it. The server reports that audio frame DTS values go backwards by ~1000-1700 units (approximately 20-40ms at 48kHz).
This happens because during the disconnect period, the encoder continues producing frames that queue up in the send buffer. When reTry() reconnects, some of these queued frames (with older timestamps) are sent after frames that were already delivered to the server via the TCP buffer before the disconnect was detected.
To Reproduce
- Start screen streaming using
GenericStreamwithMixAudioSource(internal audio + microphone) - Use default
TimestampMode.CLOCK - During active streaming, simulate a network interruption (e.g. toggle airplane mode briefly)
- Let
reTry()reconnect automatically - Observe server logs showing Non-monotonic DTS errors for AAC audio
Expected behavior
After reTry() reconnection, audio DTS timestamps should remain monotonically increasing. The send queue should either be flushed or timestamps should be adjusted to avoid sending stale frames with timestamps older than what the server already received.
Screenshots/Logs
[aost#0:1/aac] Non-monotonic DTS; previous: 1140290, current: 1138629; changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:1/aac] Non-monotonic DTS; previous: 1140291, current: 1138800; changing to 1140292. This may result in incorrect timestamps in the output file.
[aost#0:1/aac] Non-monotonic DTS; previous: 1140292, current: 1139059; changing to 1140293. This may result in incorrect timestamps in the output file.
Smartphone
- Library version: 2.6.7
- Device:
- OS:
- Media server:
- Class used:
GenericStream
Additional context
Audio configuration:
genericStream.prepareAudio(
sampleRate = 48000,
isStereo = true,
bitrate = 128000,
echoCanceler = true,
noiseSuppressor = true
)Audio source: MixAudioSource(mediaProjection) mixing internal audio + microphone.
Retry mechanism:
genericStream.getStreamClient().setReTries(7)
// In onConnectionFailed:
genericStream.getStreamClient().reTry(delay, reason, null)Smartphone (please complete the following information):
- Library version: 2.6.7
- Device: Samsung A56
- OS: Android 16
- Media server: Internal headend (don't know about techstack)
- Class used: GenericStream
Additional context
Headend logs:
[aost#0:1/aac @ 0x61c9ce932f80] Non-monotonic DTS; previous: 1140290, current: 1138629; [aost#0:1/aac @ 0x61c9ce932f80] changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:7/aac @ 0x61c9cf761700] Non-monotonic DTS; previous: 1140290, current: 1138629; [aost#0:7/aac @ 0x61c9cf761700] changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:1/aac @ 0x61c9ce932f80] Non-monotonic DTS; previous: 1140291, current: 1138800; [aost#0:1/aac @ 0x61c9ce932f80] changing to 1140292. This may result in incorrect timestamps in the output file.
[aost#0:5/aac @ 0x61c9cf75b5c0] Non-monotonic DTS; previous: 1140290, current: 1138629; [aost#0:5/aac @ 0x61c9cf75b5c0] changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:7/aac @ 0x61c9cf761700] Non-monotonic DTS; previous: 1140291, current: 1138800; [aost#0:7/aac @ 0x61c9cf761700] changing to 1140292. This may result in incorrect timestamps in the output file.
[aost#0:11/aac @ 0x61c9cf90d000] Non-monotonic DTS; previous: 1140290, current: 1138629; [aost#0:11/aac @ 0x61c9cf90d000] changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:3/aac @ 0x61c9cf755180] Non-monotonic DTS; previous: 1140290, current: 1138629; changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:3/aac @ 0x61c9cf755180] Non-monotonic DTS; previous: 1140291, current: 1138800; [aost#0:3/aac @ 0x61c9cf755180] changing to 1140292. This may result in incorrect timestamps in the output file.
[aost#0:9/aac @ 0x61c9cf903e40] Non-monotonic DTS; previous: 1140290, current: 1138629; changing to 1140291. This may result in incorrect timestamps in the output file.
[aost#0:3/aac @ 0x61c9cf755180] Non-monotonic DTS; previous: 1140292, current: 1139059; changing to 1140293. This may result in incorrect timestamps in the output file.
[aost#0:9/aac @ 0x61c9cf903e40] Non-monotonic DTS; previous: 1140291, current: 1138800; changing to 1140292. This may result in incorrect timestamps in the output file.