1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/*****************************************************************
* gmerlin - a general purpose multimedia framework and applications
*
* Copyright (c) 2001 - 2024 Members of the Gmerlin project
* http://github.com/bplaum
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* *****************************************************************/
#ifndef HTTPSERVER_PRIV_H_INCLUDED
#define HTTPSERVER_PRIV_H_INCLUDED
#include <gmerlin/websocket.h>
#include <gmerlin/lpcm_handler.h>
// #include <gmerlin/plug_handler.h>
/* Playlist handler */
typedef struct bg_http_playlist_handler_s bg_http_playlist_handler_t;
typedef struct bg_backend_proxy_s bg_backend_proxy_t;
typedef struct
{
bg_http_handler_t func;
int protocols;
char * path;
void * data;
} http_handler_t;
typedef struct client_thread_s
{
bg_http_connection_t conn;
void * priv;
pthread_t th;
void (*cleanup)(void * priv);
void (*thread_func)(bg_http_connection_t * conn, void * priv);
int stopped;
pthread_mutex_t stopped_mutex;
} client_thread_t;
#define NUM_HEADERS 16
typedef struct
{
char * uri;
int64_t offset;
gavl_buffer_t buf;
} header_t;
struct bg_http_server_s
{
bg_http_connection_t req; // Used for all requests
/* Config stuff */
int max_ka_sockets;
int port;
char * bind_addr;
/* */
bg_http_keepalive_t * ka;
gavl_socket_address_t * addr;
gavl_socket_address_t * remote_addr;
char * root_url;
char * root_file;
int fd;
http_handler_t * handlers;
int num_handlers;
int handlers_alloc;
pthread_mutex_t handlers_mutex;
const char * server_string;
gavl_timer_t * timer;
bg_parameter_info_t * params;
bg_media_dirs_t * dirs;
/* Client threads */
client_thread_t ** threads;
int threads_alloc;
int num_threads;
pthread_mutex_t threads_mutex;
bg_mdb_t * mdb;
header_t headers[NUM_HEADERS];
int num_headers;
bg_http_playlist_handler_t * playlist_handler;
// bg_backend_proxy_t ** backend_proxies;
// int num_backend_proxies;
// int backend_proxies_alloc;
bg_lpcm_handler_t * lpcmhandler;
// bg_plug_handler_t * plughandler;
gavl_array_t static_dirs;
};
//int bg_http_playlist_handler_ping(bg_http_playlist_handler_t * h);
void bg_http_server_init_playlist_handler(bg_http_server_t * srv);
void bg_http_playlist_handler_destroy(bg_http_playlist_handler_t * h);
void bg_http_server_init_mediafile_handler(bg_http_server_t * s);
void bg_http_server_init_cover_handler(bg_http_server_t * s);
void bg_http_server_free_header(header_t *);
#endif // HTTPSERVER_PRIV_H_INCLUDED
|