Skip to content
Snippets Groups Projects

qt: refactor media tree/source models

Merged Romain Vimont requested to merge rom1v/vlc:media_tree_listener into master
  1. Oct 11, 2022
    • Romain Vimont's avatar
      qt: refactor media tree listener · 7cc8e707
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      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
    • Romain Vimont's avatar
      qt: avoid unnecessary smart pointer copies · b9552485
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      b9552485
    • Romain Vimont's avatar
      qt: remove unused mediaSource · 104fa8e8
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      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
    • Romain Vimont's avatar
      qt: remove unused include · baacc656
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      baacc656
    • Romain Vimont's avatar
      qt: use one "callbacks" instance per listener · eae4b0c0
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      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
    • Romain Vimont's avatar
      qt: use static free functions for C callbacks · 1a9ab8b5
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      Callbacks to be called from C should be free functions rather than class
      members.
      1a9ab8b5
    • Romain Vimont's avatar
      qt: remove unnecessary explicit destructor · 0aeafa2d
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      0aeafa2d
    • Romain Vimont's avatar
      qt: remove unused default constructor · 07fc99b9
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      07fc99b9
    • Romain Vimont's avatar
      media tree: make functions public · c808e3e8
      Romain Vimont authored and Steve Lhomme's avatar Steve Lhomme committed
      This will allow to create and handle a media tree separately from a
      media source (linked to a service discovery).
      c808e3e8
Loading