en50221_app_datetime.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. en50221 encoder An implementation for libdvb
  3. an implementation for the en50221 transport layer
  4. Copyright (C) 2004, 2005 Manu Abraham <abraham.manu@gmail.com>
  5. Copyright (C) 2005 Julian Scheel (julian at jusst dot de)
  6. Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
  7. This library is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU Lesser General Public License as
  9. published by the Free Software Foundation; either version 2.1 of
  10. the License, or (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __EN50221_APPLICATION_DATETIME_H__
  20. #define __EN50221_APPLICATION_DATETIME_H__
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #include <stdlib.h>
  25. #include <stdint.h>
  26. #include <libdvben50221/en50221_app_utils.h>
  27. #define EN50221_APP_DATETIME_RESOURCEID MKRID(36,1,1)
  28. /**
  29. * Type definition for enquiry - called when we receive a date/time enquiry from a CAM.
  30. *
  31. * @param arg Private argument.
  32. * @param slot_id Slot id concerned.
  33. * @param session_number Session number concerned.
  34. * @param response_interval Response interval requested by CAM.
  35. * @return 0 on success, -1 on failure.
  36. */
  37. typedef int (*en50221_app_datetime_enquiry_callback) (void *arg,
  38. uint8_t slot_id,
  39. uint16_t session_number,
  40. uint8_t response_interval);
  41. /**
  42. * Opaque type representing a datetime resource.
  43. */
  44. struct en50221_app_datetime;
  45. /**
  46. * Create an instance of the datetime resource.
  47. *
  48. * @param funcs Send functions to use.
  49. * @return Instance, or NULL on failure.
  50. */
  51. extern struct en50221_app_datetime
  52. *en50221_app_datetime_create(struct en50221_app_send_functions *funcs);
  53. /**
  54. * Destroy an instance of the datetime resource.
  55. *
  56. * @param datetime Instance to destroy.
  57. */
  58. extern void en50221_app_datetime_destroy(struct en50221_app_datetime *datetime);
  59. /**
  60. * Register the callback for when we receive a enquiry request.
  61. *
  62. * @param datetime datetime resource instance.
  63. * @param callback The callback. Set to NULL to remove the callback completely.
  64. * @param arg Private data passed as arg0 of the callback.
  65. */
  66. extern void en50221_app_datetime_register_enquiry_callback(struct en50221_app_datetime *datetime,
  67. en50221_app_datetime_enquiry_callback callback,
  68. void *arg);
  69. /**
  70. * Send the time to the CAM.
  71. *
  72. * @param datetime datetime resource instance.
  73. * @param session_number Session number to send it on.
  74. * @param utc_time UTC time in unix time format.
  75. * @param time_offset If -1, the field will not be transmitted, otherwise it is the offset between
  76. * UTC and local time in minutes.
  77. * @return 0 on success, -1 on failure.
  78. */
  79. extern int en50221_app_datetime_send(struct en50221_app_datetime *datetime,
  80. uint16_t session_number,
  81. time_t utc_time,
  82. int time_offset);
  83. /**
  84. * Pass data received for this resource into it for parsing.
  85. *
  86. * @param datetime datetime instance.
  87. * @param slot_id Slot ID concerned.
  88. * @param session_number Session number concerned.
  89. * @param resource_id Resource ID concerned.
  90. * @param data The data.
  91. * @param data_length Length of data in bytes.
  92. * @return 0 on success, -1 on failure.
  93. */
  94. extern int en50221_app_datetime_message(struct en50221_app_datetime *datetime,
  95. uint8_t slot_id,
  96. uint16_t session_number,
  97. uint32_t resource_id,
  98. uint8_t *data,
  99. uint32_t data_length);
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif