qt: refactor media tree/source models
- Oct 11, 2022
-
-
This C++ listener is actually a wrapper over a media tree listener, not a media source listener. This allows to make NetworkMediaModel independent of media sources, so that it can be reused with only a media tree not linked to a media source. NetworkDeviceModel, which still requires a media source, stores it in its listener callbacks implementation (ListenerCb).
7cc8e707 -
b9552485
-
Only NetworkDeviceModel need to expose a mediaSource. The mediaSource was forwarded to all media item, but it is never used, so remove it. This paves the way to make NetworkMediaModel independent of media sources.
104fa8e8 -
baacc656
-
For each model (NetworkDeviceModel and NetworkMediaModel), every NetworkSourceListener instance were created with the same SourceListenercb instance: +------------------+ | SourceListenerCb |-----------------------------. +------------------+ | ^ | | implements | +--------------------+ | | NetworkDeviceModel | | +--------------------+ | | m_listeners | +---+ +-----------------------+ | | ---------------| NetworkSourceListener |-| +---+ +-----------------------+ | | ---------- +-----------------------+ | +---+ `----| NetworkSourceListener |-| | -------... +-----------------------+ . +---+ . | | . +---+ To prepare storing additional data for each registration, use one SourceListenerCb instance per listener: +------------------+ | SourceListenerCb | +------------------+ ^ implements | +--------------------+ | | NetworkDeviceModel | | +--------------------+ | | m_listeners | +---+ +-----------------------+ +--------------+ | | ------------| NetworkSourceListener |--| MyListenerCb |-| +---+ +-----------------------+ +--------------+ | | ---------- +-----------------------+ +--------------+ | +---+ `-| NetworkSourceListener |--| MyListenerCb |-| | -------... +-----------------------+ +--------------+ . +---+ . | | . +---+ In practice, this will allow the SourceListenerCb (to be renamed to MediaTreeListenerCb) to only use a media tree (not a media source), and let the caller store an additional associated media source usable from the callbacks implementation. As a drawback, the MyListenerCb instance must be owned by the listener (to avoid additional complexity on the client side), but then this forces the client to always create a separate class for the listener callbacks, even when not necessary (i.e. making NetworkMediaModel "implement" SourceListenerCb is not possible anymore). Alternatives considered: 1. keep SourceListenerCb as is, but make NetworkSourceListener virtual (inheritable), so that the additional media source could be stored there. As a drawback, the SourceListenerCb methods would need to get the NetworkSourceListener instance as parameter (so yet another indirection). And having both the listener and the callbacks virtual seems odd. 2. merge SourceListenerCb into NetworkSourceListener, so that the client can just inherit and store additional private data in the same class. But this requires more changes from the existing code base.
eae4b0c0 -
Callbacks to be called from C should be free functions rather than class members.
1a9ab8b5 -
0aeafa2d
-
07fc99b9
-
This will allow to create and handle a media tree separately from a media source (linked to a service discovery).
c808e3e8
-