Skip to content

clock: add context handling

Thomas Guillem requested to merge tguillem/vlc:clock-context-id.2 into master

On top of !5626 (merged) (The first 5 aout: commits should be reviewed on !5626 (merged))

Supersedes !5144 (closed)

The plan was to replace uint32_t clock_id with ancillaries. An attempt has been made here !5473 (closed). But, passing uint32_t or ancillaries is almost the same complexity. Lot of questions:

  • How do you cross all packetizers modules ?
  • Lot of modules can't pass a context alongside a PTS (avcodec and videotoolbox can, but not the others). This mean that you need a common code that match a PTS with the ancillary, making the ability to forward it across block a little useless.

So here is a simpler version:

  • A new clock context is created when a PCR discontinuity is triggered from the input clock
  • The previous clock context will be kept alive until all output has updated a PTS matching the newest clock context.
  • The clock will choose the best context by comparing the output PTS with the context PCR. The PTS need to be higher and the closest to the PCR.
  • It is possible to get the usedclock context id when converting a PTS. This is used by both video and audio output to handle a PTS discontinuity.

Sample with a PCR discontinuity: https://streams.videolan.org/issues/26378/intentional_pcr_discontinuity-short.ts

Log with the new branch when the discontinuity occurs (clock-master=input).

[00007fb91cc022e0] ts demux warning: discontinuity received 0x1 instead of 0xa (pid=1515)
[000055faee17f1c0] main input warning: clock gap, unexpected stream discontinuity
[000055faee17f1c0] main input warning: feeding synchro with a new reference point trying to recover from clock gap
[00007fb91cc0c690] [clock] main generic: clock(video/1515): using old clock_id: 0 for update (1989757801)
[00007fb91cc022e0] ts demux warning: discontinuity indicator (pid=2515) 
[00007fb91cc0c690] [clock] main generic: clock(audio/2515): using old clock_id: 0 for convert (1990917356)
[00007fb91cc0b130] h264 packetizer debug: found NAL_SPS (id=0)
[00007fb91cc0c690] [clock] main generic: clock(audio/2515): using main clock_id: 1 for convert (30000145)
[000055faee0ec6c0] main audio output debug: discontinuity: at 30000145 us, draining output
[00007fb91cc022e0] ts demux warning: discontinuity received 0x2 instead of 0xe (pid=0)
[00007fb91cc022e0] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 14) for PID 0
[00007fb91cc022e0] ts demux debug: PATCallBack called
[00007fb91cc022e0] ts demux warning: discontinuity received 0x2 instead of 0x4 (pid=515)
[00007fb91cc022e0] ts demux error: libdvbpsi error (PSI decoder): TS discontinuity (received 2, expected 4) for PID 515
[00007fb91cc022e0] ts demux debug: PMTCallBack called for program 185
[00007fb91cc0c690] [clock] main generic: clock(video/1515): using main clock_id: 1 for convert (30367034)
[000055faee0ec6c0] main audio output debug: discontinuity: flushing output
[000055faee0ec6c0] pulse audio output debug: write index corrupt
[000055faee0ec6c0] main audio output debug: discontinuity: playing back 41 blocks for a total length of 874653 us
[000055faee0ec6c0] pulse audio output debug: deferring start (313472 us)
[000055faee0ec6c0] pulse audio output debug: deferring start (313450 us)
[000055faee0ec6c0] pulse audio output debug: deferring start (313444 us)
[000055faee0ec6c0] pulse audio output debug: deferring start (313438 us)
[000055faee0ec6c0] pulse audio output debug: deferring start (313189 us)
...
[000055faee0ec6c0] pulse audio output debug: deferring start (313184 us)
[000055faee0ec6c0] pulse audio output debug: deferring start (313178 us)
[000055faee0ec6c0] pulse audio output debug: started
[00007fb90c0939e0] main video output debug: Using a new clock context (1), flusing static filters
[00007fb91cc0c690] [clock] main generic: clock(video/1515): using main clock_id: 1 for update (30367034)
[00007fb91cc0c690] [clock] main generic: clock(video/1515): unused clock_id: 0
[00007fb91cc0c690] [clock] main generic: clock(audio/2515): using main clock_id: 1 for update (30096292)
[00007fb91cc0c690] [clock] main generic: clock(audio/2515): unused clock_id: 0 (removed)
Edited by Thomas Guillem

Merge request reports

Loading