Skip to content

Default naive seek datetimes to system timezone for RTSP/HTTP catchup#425

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-clock-branch-issue
Draft

Default naive seek datetimes to system timezone for RTSP/HTTP catchup#425
Copilot wants to merge 4 commits intomainfrom
copilot/fix-clock-branch-issue

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

playseek/catchup requests without an explicit client timezone were being parsed as UTC. On non-UTC deployments this caused recent local-time seeks to miss the RTSP Range: clock= path and fall back to upstream query passthrough.

  • Timezone fallback semantics

    • Change naive seek datetime parsing (yyyyMMddHHmmss, naive ISO 8601) to default to the daemon's system timezone when the client does not provide a timezone via User-Agent.
    • Keep explicit-timezone inputs unchanged:
      • Unix timestamps
      • yyyyMMddHHmmssGMT
      • ISO 8601 with Z or ±HH:MM
  • RTSP recent-seek behavior

    • Recent local-time playseek values now resolve to the correct UTC instant before the < 1 hour check.
    • This restores the intended RTSP behavior:
      • strip recent seek params from the upstream RTSP URL
      • send PLAY Range: clock=<utc>-
  • Shared seek conversion path

    • Apply the same fallback to the shared HTTP/RTSP seek conversion logic so upstream HTTP proxy requests also convert naive local datetimes consistently.
  • E2E coverage

    • Add a reproducer for the original failure: daemon running under a non-UTC system timezone, client omits timezone, recent playseek should still trigger RTSP Range: clock=.
    • Add adjacent HTTP coverage for the same naive-datetime conversion path.
    • Isolate timezone-sensitive tests by passing TZ only to the child rtp2httpd process.
  • Docs

    • Update the Chinese time-processing guide to document system-timezone fallback for naive datetimes when the client does not send timezone information.

Example of the corrected behavior:

# client request (no TZ in User-Agent, naive local datetime input)
GET /.../catchup?playseek=20260323183140-20260323183835

# before on non-UTC systems
DESCRIBE rtsp://upstream/...?...&playseek=20260323183140-20260323183835
PLAY ...                       # no Range: clock

# after
DESCRIBE rtsp://upstream/...   # recent seek stripped from RTSP URL
PLAY ...
Range: clock=20260323T103140Z-
Original prompt

This section details on the original issue you should resolve

<issue_title>v3.12.0-alpha.1 无法触发 Range: clock</issue_title>
<issue_description>网页端测试一小时内回看,不知为何日志里没看见有走 clock 分支,回看正常。

18:38:45 INFO [Worker 0] New client 192.168.96.100:15699 requested URL: /%E5%A4%AE%E8%A7%86/CCTV-5%E4%BD%93%E8%82%B2/catchup?playseek=20260323183140-20260323183835 (method: GET)
18:38:45 INFO [Worker 0] Service matched: 央视/CCTV-5体育/catchup
18:38:45 DEBUG [Worker 0] Creating RTSP service with merged URL: rtsp://10.255.4.140/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835&r2h-seek-name=playseek
18:38:45 DEBUG [Worker 0] Found r2h-seek-name parameter: playseek
18:38:45 DEBUG [Worker 0] Using explicitly specified seek parameter name: playseek
18:38:45 DEBUG [Worker 0] Found valid playseek parameter: 20260323183140-20260323183835
18:38:45 DEBUG [Worker 0] Parsed RTSP URL: rtsp://10.255.4.140/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********
18:38:45 DEBUG [Worker 0] Parsed playseek parameter: 20260323183140-20260323183835
18:38:45 DEBUG [Worker 0] Timezone: No TZ marker in User-Agent
18:38:45 DEBUG [Worker 0] Parsed seek - begin='20260323183140', end='20260323183835'
18:38:45 DEBUG [Worker 0] Timezone: yyyyMMddHHmmss '20260323183140' (TZ offset 0) + seek offset 0 = '20260323183140'
18:38:45 DEBUG [Worker 0] Converted begin time '20260323183140' to UTC '20260323183140'
18:38:45 DEBUG [Worker 0] Timezone: yyyyMMddHHmmss '20260323183835' (TZ offset 0) + seek offset 0 = '20260323183835'
18:38:45 DEBUG [Worker 0] Converted end time '20260323183835' to UTC '20260323183835'
18:38:45 DEBUG [Worker 0] UTC seek parameter: '20260323183140-20260323183835'
18:38:45 DEBUG [Worker 0] RTSP: Parsed URL - host=10.255.4.140, port=554, path=/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835
18:38:45 DEBUG [Worker 0] RTSP: Connection to 10.255.4.140:554 in progress (async)
18:38:45 DEBUG [Worker 0] RTSP: Socket registered with poller for connection completion
18:38:45 DEBUG [Worker 0] RTSP: Async connection initiated, state=1
18:38:45 INFO [Worker 0] RTSP: Connected to 10.255.4.140:554
18:38:45 DEBUG [Worker 0] RTSP: Connection to 10.255.4.140:554 completed successfully
18:38:45 DEBUG [Worker 0] RTSP: Prepared request:
OPTIONS rtsp://10.255.4.140/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835 RTSP/1.0
CSeq: 1
User-Agent: CTC RTSP 1.0

18:38:45 DEBUG [Worker 0] RTSP: Request sent completely (462 bytes)
18:38:45 DEBUG [Worker 0] RTSP: Request sent completely, waiting for response
18:38:45 DEBUG [Worker 0] RTSP: Server supports GET_PARAMETER for keepalive
18:38:45 DEBUG [Worker 0] RTSP: Server advertised methods: DESCRIBE, SETUP, PLAY, PAUSE, TEARDOWN, SET_PARAMETER, GET_PARAMETER, OPTIONS
18:38:45 DEBUG [Worker 0] RTSP: Received complete header:
RTSP/1.0 200 OK
Public: DESCRIBE, SETUP, PLAY, PAUSE, TEARDOWN, SET_PARAMETER, GET_PARAMETER, OPTIONS
Date: Mon, 23 Mar 2026 10:38:45 GMT
CSeq: 1
Server: HWServer/1.0.0.1

18:38:45 DEBUG [Worker 0] RTSP: Prepared request:
DESCRIBE rtsp://10.255.4.140/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835 RTSP/1.0
CSeq: 2
User-Agent: CTC RTSP 1.0
Accept: application/sdp

18:38:45 DEBUG [Worker 0] RTSP: Request sent completely (488 bytes)
18:38:45 DEBUG [Worker 0] RTSP: Request sent completely, waiting for response
18:38:45 DEBUG [Worker 0] RTSP: Received redirect response 302
18:38:45 DEBUG [Worker 0] RTSP: Handling redirect to: rtsp://10.255.9.151:554/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835&from=3&hms_devid=492&online=1774262325
18:38:45 DEBUG [Worker 0] RTSP: Parsed URL - host=10.255.9.151, port=554, path=/PLTV/88888888/224/3221225726/10000100000000060000000000247037_0.smil?rrsip=10.255.13.139&zoneoffset=480&icpid=-1&limitflux=-1&limitdur=-1&tenantId=8601&GuardEncType=2&accountinfo=********&playseek=20260323183140-20260323183835&from=3&hms_devid=492&online=1774262325
18:38:45 DEBUG [Worker 0] RTSP: Connection to 10.255.9.151:554 in progress (async)
18:38:45 DEBUG [Worker 0] RTSP: Sock...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes stackia/rtp2httpd#424

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/stackia/rtp2httpd/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits March 23, 2026 11:19
Copilot AI changed the title [WIP] Fix issue with triggering clock branch in v3.12.0-alpha.1 Default naive seek datetimes to system timezone for RTSP/HTTP catchup Mar 23, 2026
Copilot AI requested a review from stackia March 23, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants