Home | History | Annotate | Download | only in pulse
      1 #ifndef foobrowserhfoo
      2 #define foobrowserhfoo
      3 
      4 /* $Id: browser.h 1426 2007-02-13 15:35:19Z ossman $ */
      5 
      6 /***
      7   This file is part of PulseAudio.
      8 
      9   Copyright 2004-2006 Lennart Poettering
     10 
     11   PulseAudio is free software; you can redistribute it and/or modify
     12   it under the terms of the GNU Lesser General Public License as
     13   published by the Free Software Foundation; either version 2 of the
     14   License, or (at your option) any later version.
     15 
     16   PulseAudio is distributed in the hope that it will be useful, but
     17   WITHOUT ANY WARRANTY; without even the implied warranty of
     18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     19   General Public License for more details.
     20 
     21   You should have received a copy of the GNU Lesser General Public
     22   License along with PulseAudio; if not, write to the Free Software
     23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
     24   USA.
     25 ***/
     26 
     27 #include <pulse/mainloop-api.h>
     28 #include <pulse/sample.h>
     29 #include <pulse/channelmap.h>
     30 #include <pulse/cdecl.h>
     31 
     32 /** \file
     33  * An abstract interface for Zeroconf browsing of PulseAudio servers */
     34 
     35 PA_C_DECL_BEGIN
     36 
     37 /** An opaque Zeroconf service browser object */
     38 typedef struct pa_browser pa_browser;
     39 
     40 /** Opcodes for pa_browser_cb_t callbacks */
     41 typedef enum pa_browse_opcode {
     42     PA_BROWSE_NEW_SERVER = 0, /**< New server found */
     43     PA_BROWSE_NEW_SINK,       /**< New sink found */
     44     PA_BROWSE_NEW_SOURCE,     /**< New source found */
     45     PA_BROWSE_REMOVE_SERVER,  /**< Server disappeared */
     46     PA_BROWSE_REMOVE_SINK,    /**< Sink disappeared */
     47     PA_BROWSE_REMOVE_SOURCE   /**< Source disappeared */
     48 } pa_browse_opcode_t;
     49 
     50 typedef enum pa_browse_flags {
     51     PA_BROWSE_FOR_SERVERS = 1, /**< Browse for servers */
     52     PA_BROWSE_FOR_SINKS = 2, /**< Browse for sinks */
     53     PA_BROWSE_FOR_SOURCES = 4 /** Browse for sources */
     54 } pa_browse_flags_t;
     55 
     56 /** Create a new browser object on the specified main loop */
     57 pa_browser *pa_browser_new(pa_mainloop_api *mainloop);
     58 
     59 /** Same pa_browser_new, but pass additional flags parameter. */
     60 pa_browser *pa_browser_new_full(pa_mainloop_api *mainloop, pa_browse_flags_t flags, const char **error_string);
     61 
     62 /** Increase reference counter of the specified browser object */
     63 pa_browser *pa_browser_ref(pa_browser *z);
     64 
     65 /** Decrease reference counter of the specified browser object */
     66 void pa_browser_unref(pa_browser *z);
     67 
     68 /** Information about a sink/source/server found with Zeroconf */
     69 typedef struct pa_browse_info {
     70     const char *name;  /**< Unique service name; always available */
     71 
     72     const char *server; /**< Server name; always available */
     73     const char *server_version; /**< Server version string; optional */
     74     const char *user_name; /**< User name of the server process; optional */
     75     const char *fqdn; /* Server version; optional */
     76     const uint32_t *cookie;  /* Server cookie; optional */
     77 
     78     const char *device; /* Device name; always available when this information is of a sink/source */
     79     const char *description;  /* Device description; optional */
     80     const pa_sample_spec *sample_spec;  /* Sample specification of the device; optional */
     81 } pa_browse_info;
     82 
     83 /** Callback prototype */
     84 typedef void (*pa_browse_cb_t)(pa_browser *z, pa_browse_opcode_t c, const pa_browse_info *i, void *userdata);
     85 
     86 /** Set the callback pointer for the browser object */
     87 void pa_browser_set_callback(pa_browser *z, pa_browse_cb_t cb, void *userdata);
     88 
     89 /** Callback prototype for errors */
     90 typedef void (*pa_browser_error_cb_t)(pa_browser *z, const char *error_string, void *userdata);
     91 
     92 /** Set a callback function that is called whenever the browser object
     93  * becomes invalid due to an error. After this function has been
     94  * called the browser object has become invalid and should be
     95  * freed. */
     96 void pa_browser_set_error_callback(pa_browser *z, pa_browser_error_cb_t, void *userdata);
     97 
     98 PA_C_DECL_END
     99 
    100 #endif
    101