messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

media.h (3166B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2024 GNUnet e.V.
      4 
      5    GNUnet is free software: you can redistribute it and/or modify it
      6    under the terms of the GNU Affero General Public License as published
      7    by the Free Software Foundation, either version 3 of the License,
      8    or (at your option) any later version.
      9 
     10    GNUnet is distributed in the hope that it will be useful, but
     11    WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Affero General Public License for more details.
     14 
     15    You should have received a copy of the GNU Affero General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18    SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 /*
     21  * @author Tobias Frisch
     22  * @file media.h
     23  */
     24 
     25 #ifndef MEDIA_H_
     26 #define MEDIA_H_
     27 
     28 #include <pipewire/pipewire.h>
     29 
     30 typedef struct MESSENGER_Application MESSENGER_Application;
     31 
     32 typedef struct MESSENGER_MediaInfo
     33 {
     34   MESSENGER_Application *app;
     35   
     36   struct {
     37     struct pw_core *core;
     38     struct pw_registry *registry;
     39     struct spa_hook core_listener;
     40 	  struct spa_hook registry_listener;
     41     struct pw_map globals;
     42     int pending;
     43   } pw;
     44 } MESSENGER_MediaInfo;
     45 
     46 typedef void
     47 (*MESSENGER_MediaNodeIterator) (void *cls,
     48                                 const char *name,
     49                                 const char *description,
     50                                 const char *media_class,
     51                                 const char *media_role);
     52 
     53 /**
     54  * Initialize a media info structure to list
     55  * pipewire nodes related to a selected
     56  * file descriptor or all available.
     57  *
     58  * @param media Media info
     59  * @param app Messenger application
     60  * @param fd File descriptor
     61  */
     62 void
     63 media_pw_init(MESSENGER_MediaInfo *media,
     64               MESSENGER_Application *app,
     65               int fd);
     66 
     67 /**
     68  * Initialize a media info structure to list
     69  * pipewire nodes for each available camera
     70  * device. 
     71  *
     72  * @param media Media info
     73  * @param app Messenger application
     74  */
     75 void
     76 media_init_camera_capturing(MESSENGER_MediaInfo *media,
     77                             MESSENGER_Application *app);
     78 
     79 /**
     80  * Initialize a media info structure to list
     81  * pipewire nodes for each available screencast
     82  * option. 
     83  *
     84  * @param media Media info
     85  * @param app Messenger application
     86  */
     87 void
     88 media_init_screen_sharing(MESSENGER_MediaInfo *media,
     89                           MESSENGER_Application *app);
     90 
     91 /**
     92  * Cleanup a media info structure with all
     93  * its internal pipewire related resources.
     94  *
     95  * @param media Media info
     96  */
     97 void
     98 media_pw_cleanup(MESSENGER_MediaInfo *media);
     99 
    100 /**
    101  * Run the main loop from pipewire to get
    102  * a current list of all nodes of a given
    103  * media info.
    104  *
    105  * @param media Media info
    106  */
    107 void
    108 media_pw_main_loop_run(MESSENGER_MediaInfo *media);
    109 
    110 /**
    111  * Iterate all pipewire nodes of a given
    112  * media info with its name, description
    113  * and role.
    114  *
    115  * @param media Media info
    116  * @param it Node iterator
    117  * @param cls Closure
    118  */
    119 void
    120 media_pw_iterate_nodes(MESSENGER_MediaInfo *media,
    121                        MESSENGER_MediaNodeIterator it,
    122                        void *cls);
    123 
    124 #endif /* MEDIA_H_ */