PageRenderTime 68ms CodeModel.GetById 23ms RepoModel.GetById 14ms app.codeStats 0ms

/nxtvepg-2.8.1/epgctl/epgacqsrv.h

#
C Header | 196 lines | 143 code | 24 blank | 29 comment | 0 complexity | c2eac96105544cf8a7d739e5842c0793 MD5 | raw file
Possible License(s): AGPL-3.0, AGPL-1.0
  1. /*
  2. * Nextview EPG network acquisition server
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License Version 2 as
  6. * published by the Free Software Foundation. You find a copy of this
  7. * license in the file COPYRIGHT in the root directory of this release.
  8. *
  9. * THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
  10. * BUT WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
  11. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. *
  15. * Description: see according C source file.
  16. *
  17. * Author: Tom Zoerner
  18. *
  19. * $Id: epgacqsrv.h,v 1.12 2008/08/10 19:38:40 tom Exp tom $
  20. */
  21. #ifndef __EPGACQSRV_H
  22. #define __EPGACQSRV_H
  23. #include "epgdb/epgnetio.h"
  24. #include "epgdb/epgdbsav.h"
  25. #include "epgdb/epgdbmerge.h"
  26. #include "epgctl/epgctxctl.h"
  27. #include "epgctl/epgacqctl.h"
  28. #ifdef WIN32
  29. #include <winsock2.h>
  30. #endif
  31. // ---------------------------------------------------------------------------
  32. // Structure for acq stats reports
  33. //
  34. #define STATS_REQ_BITS_HIST 0x01 // full acq stats
  35. #define STATS_REQ_BITS_TSC_REQ 0x02 // timescale for req. CNIs only
  36. #define STATS_REQ_BITS_TSC_ALL 0x04 // timescale for all CNIs
  37. #define STATS_REQ_BITS_VPS_PDC_REQ 0x08 // forward VPS/PDC CNI and PIL
  38. #define STATS_REQ_BITS_VPS_PDC_UPD 0x10 // forward the next new VPS/PDC reading
  39. #define STATS_IND_INVALID_VPS_PDC 0xFF
  40. typedef enum
  41. {
  42. EPGDB_STATS_UPD_TYPE_MINIMAL,
  43. EPGDB_STATS_UPD_TYPE_INITIAL,
  44. EPGDB_STATS_UPD_TYPE_UPDATE,
  45. } EPGDB_STATS_UPD_TYPE;
  46. typedef struct MSG_STRUCT_STATS_IND_STRUCT
  47. {
  48. union
  49. {
  50. void * pNext;
  51. #if defined (USE_32BIT_COMPAT)
  52. uint8_t resv_align0[8]; // 64-bit pointer size
  53. #endif
  54. } p;
  55. EPGDB_STATS_UPD_TYPE type;
  56. bool aiFollows;
  57. uint8_t resv_align1[3];
  58. EPGACQ_DESCR descr;
  59. union
  60. {
  61. struct
  62. {
  63. EPGDB_BLOCK_COUNT count[2];
  64. uint32_t nowMaxAcqNetCount;
  65. EPG_ACQ_VPS_PDC vpsPdc;
  66. time32_t lastAiTime;
  67. time32_t resv_align2; // 64-bit alignment
  68. } minimal;
  69. struct
  70. {
  71. EPG_ACQ_STATS stats;
  72. EPG_ACQ_VPS_PDC vpsPdc;
  73. time32_t resv_align3; // 64-bit alignment
  74. } initial;
  75. struct
  76. {
  77. EPGDB_BLOCK_COUNT count[2];
  78. EPGDB_ACQ_AI_STATS ai;
  79. TTX_DEC_STATS ttx_dec;
  80. TTX_GRAB_STATS grabTtxStats;
  81. EPG_STREAM_STATS stream;
  82. EPG_ACQ_VPS_PDC vpsPdc;
  83. EPGDB_HIST hist;
  84. uint16_t histIdx;
  85. uint32_t nowMaxAcqRepCount;
  86. uint32_t nowMaxAcqNetCount;
  87. time32_t lastStatsUpdate;
  88. } update;
  89. } u;
  90. } MSG_STRUCT_STATS_IND;
  91. // ----------------------------------------------------------------------------
  92. // Declaration of messages
  93. //
  94. typedef struct
  95. {
  96. uchar magic[MAGIC_STR_LEN]; // magic string to identify the requested service
  97. uint16_t endianMagic; // distinguish big/little endian client
  98. uint8_t reserved[62]; // reserved for future additions
  99. } MSG_STRUCT_CONNECT_REQ;
  100. typedef struct
  101. {
  102. uchar magic[MAGIC_STR_LEN]; // magic string to identify the provided service
  103. uint16_t endianMagic; // distinguish big/little endian server
  104. uint32_t blockCompatVersion; // version of EPG database block format
  105. uint32_t protocolCompatVersion; // protocol version
  106. uint32_t swVersion; // software version (informative only)
  107. int32_t daemon_pid;
  108. uint8_t use_utf8; // compile switch USE_UTF8
  109. uint8_t use_32_bit_compat; // compile switch USE_32BIT_COMPAT
  110. uint8_t reserved[60-2]; // reserved for future additions
  111. } MSG_STRUCT_CONNECT_CNF;
  112. typedef struct
  113. {
  114. uint32_t cniCount; // number of valid CNIs in list (0 allowed)
  115. uint32_t provCnis[MAX_MERGED_DB_COUNT]; // list of requested provider CNIs
  116. time32_t dumpStartTimes[MAX_MERGED_DB_COUNT]; // client-side time of last db update
  117. uint32_t statsReqBits; // extent of acq stats requested by the GUI
  118. } MSG_STRUCT_FORWARD_REQ;
  119. typedef struct
  120. {
  121. uint32_t cniCount; // copy of REQ msg (to identify the reply): number of CNIs
  122. uint32_t provCnis[MAX_MERGED_DB_COUNT]; // copy of REQ msg: list of requested provider CNIs
  123. } MSG_STRUCT_FORWARD_CNF;
  124. typedef struct
  125. {
  126. uint32_t cni; // CNI of the db acq is currently working for
  127. } MSG_STRUCT_FORWARD_IND;
  128. typedef struct
  129. {
  130. uint32_t cni; // CNI of the dumped db
  131. } MSG_STRUCT_DUMP_IND;
  132. typedef struct
  133. {
  134. uint32_t statsReqBits; // extent of acq stats (handled by upper layers only)
  135. } MSG_STRUCT_STATS_REQ;
  136. typedef struct
  137. {
  138. EPG_ACQ_VPS_PDC vpsPdc;
  139. } MSG_STRUCT_VPS_PDC_IND;
  140. typedef struct
  141. {
  142. uint32_t mtime;
  143. } MSG_STRUCT_DB_UPD_IND;
  144. typedef union
  145. {
  146. MSG_STRUCT_CONNECT_REQ con_req;
  147. MSG_STRUCT_CONNECT_CNF con_cnf;
  148. MSG_STRUCT_FORWARD_REQ fwd_req;
  149. MSG_STRUCT_FORWARD_CNF fwd_cnf;
  150. MSG_STRUCT_FORWARD_IND fwd_ind;
  151. MSG_STRUCT_DUMP_IND dump_ind;
  152. MSG_STRUCT_STATS_REQ stats_req;
  153. MSG_STRUCT_STATS_IND stats_ind;
  154. MSG_STRUCT_VPS_PDC_IND vps_pdc_ind;
  155. MSG_STRUCT_DB_UPD_IND db_upd_ind;
  156. } EPGDBSRV_MSG_BODY;
  157. // ----------------------------------------------------------------------------
  158. // Declaration of the service interface functions
  159. //
  160. void EpgAcqServer_Init( bool have_tty );
  161. bool EpgAcqServer_Listen( void );
  162. void EpgAcqServer_SetMaxConn( uint max_conn );
  163. void EpgAcqServer_SetAddress( bool do_tcp_ip, const char * pIpStr, const char * pPort );
  164. void EpgAcqServer_SetProvider( uint cni );
  165. void EpgAcqServer_SetVpsPdc( bool change );
  166. void EpgAcqServer_TriggerStats( void );
  167. void EpgAcqServer_TriggerDbUpdate( time_t mtime );
  168. void EpgAcqServer_Destroy( void );
  169. sint EpgAcqServer_GetFdSet( fd_set * rd, fd_set * wr );
  170. void EpgAcqServer_HandleSockets( fd_set * rd, fd_set * wr );
  171. void EpgAcqServer_AddBlock( EPGDB_CONTEXT * dbc, EPGDB_BLOCK * pNewBlock );
  172. #endif // __EPGACQSRV_H