My question is similar to this one (How to create a custom clock for use in std::chrono functions?) but with two minor differences:
- The epoch isn't known until runtime
- There could potentially be multiple instances of the clock, each with their own epoch
The use case I'm thinking of is for video stream time. i.e. each frame in a video stream has a timestamp (pts, presentation time stamp) relative to the timestamp of the first frame. There could be multiple video streams, each with their own stream start time.
I think the epoch not being known until runtime is easy enough, just add a set_epoch function. however I'm not sure how it would be instanced where the now() function is static (which I would assume would require set_epoch to be static.)
So far I've just handled this by making the timestamp a duration instead of a time_point but that seems to be kind of an abuse of the types. It also Is that the best solution or is there a better way? I guess maybe a broader question is, is it better to use a time_point or a duration type for a timestamp? A time_point seems the natural fit, but that means you'd have to truck around the clock definition. A duration doesn't seem to fit the intended definition, but decouples it from the clock definition.