1 /*
2  *  TV headend - Bouquets
3  *  Copyright (C) 2014 Jaroslav Kysela
4  *
5  *  This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation, either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef BOUQUET_H_
20 #define BOUQUET_H_
21 
22 #include "idnode.h"
23 #include "htsmsg.h"
24 #include "service.h"
25 #include "channels.h"
26 
27 typedef struct bouquet {
28   idnode_t bq_id;
29   RB_ENTRY(bouquet) bq_link;
30 
31   int           bq_saveflag;
32   int           bq_in_load;
33 
34   int           bq_shield;
35   int           bq_enabled;
36   int           bq_rescan;
37   int           bq_maptoch;
38   int           bq_mapnolcn;
39   int           bq_mapnoname;
40   int           bq_mapradio;
41   int           bq_mapencrypted;
42   int           bq_mapmergename;
43   int           bq_chtag;
44   int           bq_chtag_type_tags;
45   int           bq_chtag_provider_tags;
46   int           bq_chtag_network_tags;
47   channel_tag_t*bq_chtag_ptr;
48   const char   *bq_chtag_waiting;
49   char         *bq_name;
50   char         *bq_ext_url;
51   int           bq_ssl_peer_verify;
52   int           bq_ext_url_period;
53   char         *bq_src;
54   char         *bq_comment;
55   idnode_set_t *bq_services;
56   idnode_set_t *bq_active_services;
57   htsmsg_t     *bq_services_waiting;
58   uint32_t      bq_services_seen;
59   uint32_t      bq_lcn_offset;
60 
61   /* fastscan bouquet helpers */
62   int           bq_fastscan_nit;
63   int           bq_fastscan_sdt;
64   void         *bq_fastscan_bi;
65 
66   void         *bq_download;
67 
68 } bouquet_t;
69 
70 typedef RB_HEAD(,bouquet) bouquet_tree_t;
71 
72 extern bouquet_tree_t bouquets;
73 
74 extern const idclass_t bouquet_class;
75 
76 /**
77  *
78  */
79 
80 htsmsg_t * bouquet_class_get_list(void *o, const char *lang);
81 
82 bouquet_t * bouquet_create(const char *uuid, htsmsg_t *conf,
83                            const char *name, const char *src);
84 
85 void bouquet_delete(bouquet_t *bq);
86 
87 void bouquet_destroy_by_service(service_t *t, int delconf);
88 void bouquet_destroy_by_channel_tag(channel_tag_t *ct);
89 
90 void bouquet_notify_service_enabled(service_t *t);
91 
92 static inline bouquet_t *
bouquet_find_by_uuid(const char * uuid)93 bouquet_find_by_uuid(const char *uuid)
94   { return (bouquet_t *)idnode_find(uuid, &bouquet_class, NULL); }
95 
96 bouquet_t * bouquet_find_by_source(const char *name, const char *src, int create);
97 
98 void bouquet_map_to_channels(bouquet_t *bq);
99 void bouquet_notify_channels(bouquet_t *bq);
100 void bouquet_add_service(bouquet_t *bq, service_t *s, uint64_t lcn, const char *tag);
101 void bouquet_completed(bouquet_t *bq, uint32_t seen);
102 void bouquet_change_comment(bouquet_t *bq, const char *comment, int replace);
103 void bouquet_scan(bouquet_t *bq);
104 void bouquet_detach(channel_t *ch);
105 
106 uint64_t bouquet_get_channel_number(bouquet_t *bq, service_t *t);
107 
108 /**
109  *
110  */
111 
112 void bouquet_init(void);
113 void bouquet_service_resolve(void);
114 void bouquet_done(void);
115 
116 #endif /* BOUQUET_H_ */
117