It's not clear for me when transcoding
and packaging
take place.
My question is:
packaging
performed on demand?Assuming you are talking about video, the simple answer is that packaging typically today is on demand as you say, using a 'Just in Time' packager or origin server.
The delivery is usually via a CDN which will cache whatever it delivers - i.e. both HLS and DASH streams, and as an added complication different bit rate versions of each segment of the HLS and DASH streams.
In the past this was further complicated by the need to encrypt differently the streams if they were using Widevine, PlayReady or FairPlay.
The move to CENC common encryption, which allows multiple DRM's use the same encryption approach, and to CMAF Media Format which allows a common format for the media segments between HLS and DASH is moving the industry towards a single format for the media itself which can be stored as one copy and encrypted and streamed as either HLS or DASH as required by the requesting device.
Some notes: