1 #ifndef DDCI_H 2 #define DDCI_H 3 #include "adapter.h" 4 #include "pmt.h" 5 #include "tables.h" 6 7 // number of pids for each ddci adapter to be stored in the mapping table 8 #define MAX_CHANNELS_ON_CI 4 9 #define PIDS_FOR_ADAPTER 128 10 #define MAX_CA_PIDS 20 11 12 #define DDCI_BUFFER (100000 * 188) 13 14 // keeps PMT informations for the channels that are enabled on this ddci_device 15 typedef struct ddci_pmt { 16 int id; 17 int ver; 18 int pcr_pid; 19 char cc; 20 } ddci_pmt_t; 21 22 typedef struct ddci_device { 23 SMutex mutex; 24 int enabled; 25 int id; 26 int fd; 27 int channels; 28 int max_channels; 29 ddci_pmt_t pmt[MAX_CHANNELS_ON_CI + 1]; 30 int cat_processed; 31 int capid[MAX_CA_PIDS + 1]; 32 int ncapid; 33 unsigned char *out; 34 int ro[MAX_ADAPTERS], wo; // read offset per adapter 35 uint64_t last_pat, last_pmt; 36 int tid, ver; 37 char pat_cc; 38 SHashTable mapping; 39 } ddci_device_t; 40 41 // Use a hash table to store mapping_table entries 42 // the key is ad << 16 | pid to be able to search faster 43 // based on this key. This key is needed mostly for processing CAT, PMT, PAT 44 // to map from pids in original tables to destination ones. 45 typedef struct ddci_mapping_table { 46 int ad; 47 int pid; 48 int ddci_pid; 49 int ddci; 50 char rewrite; 51 int pmt[MAX_CHANNELS_ON_CI + 1]; 52 int npmt; 53 int filter_id; 54 int pid_added; 55 } ddci_mapping_table_t; 56 57 typedef struct ddci_channel { 58 struct SDDCI { 59 uint8_t ddci; 60 uint64_t blacklisted_until; 61 } ddci[MAX_ADAPTERS]; 62 int ddcis; 63 int pos; 64 int sid; 65 char name[50]; 66 char locked; 67 } Sddci_channel; 68 69 void find_ddci_adapter(adapter **a); 70 void ddci_init(); 71 int add_pid_mapping_table(int ad, int pid, int pmt, ddci_device_t *d, 72 int force_add_pid); 73 int push_ts_to_adapter(adapter *ad, unsigned char *b, int new_pid, int *ad_pos); 74 int push_ts_to_ddci_buffer(ddci_device_t *d, unsigned char *b, int len); 75 void set_pid_ts(unsigned char *b, int pid); 76 int ddci_process_ts(adapter *ad, ddci_device_t *d); 77 int ddci_create_pat(ddci_device_t *d, uint8_t *b); 78 int ddci_create_pmt(ddci_device_t *d, SPMT *pmt, uint8_t *new_pmt, int pmt_size, 79 int ver, int pcr_pid); 80 ddci_mapping_table_t *get_pid_mapping_allddci(int ad, int pid); 81 void save_channels(SHashTable *ch, char *file); 82 void load_channels(SHashTable *ch, char *file); 83 int ddci_process_pmt(adapter *ad, SPMT *pmt); 84 void blacklist_pmt_for_ddci(SPMT *pmt, int ddid); 85 int ddci_del_pmt(adapter *ad, SPMT *spmt); 86 #endif 87