1 #ifndef LIVE_DTV_PLUGIN_API_H_ 2 #define LIVE_DTV_PLUGIN_API_H_ 3 4 #include <stdint.h> 5 6 struct dtv_streamer; 7 8 struct dtv_plugin { 9 uint32_t version; 10 11 /** 12 * get_transport_types() - Retrieve a list of supported transport types. 13 * 14 * Return: A NULL-terminated list of supported transport types. 15 */ 16 const char** (*get_transport_types)(void); 17 18 /** 19 * get_streamer_count() - Get number of streamers that can be created. 20 * 21 * Return: The number of streamers that can be created. 22 */ 23 int (*get_streamer_count)(void); 24 25 /** 26 * validate() - Check if transport description is valid. 27 * @transport_desc: NULL-terminated transport description in json format. 28 * 29 * Return: 1 if valid, 0 otherwise. 30 */ 31 int (*validate)(const char* transport_desc); 32 33 /** 34 * create_streamer() - Create a streamer object. 35 * 36 * Return: A pointer to a new streamer object. 37 */ 38 struct dtv_streamer* (*create_streamer)(void); 39 40 /** 41 * destroy_streamer() - Free a streamer object and all associated resources. 42 * @st: Pointer to a streamer object 43 */ 44 void (*destroy_streamer)(struct dtv_streamer* streamer); 45 46 /** 47 * set_property() - Set a key/value pair property. 48 * @streamer: Pointer to a streamer object (may be NULL for plugin-wide properties). 49 * @key: NULL-terminated property name. 50 * @value: Property value. 51 * @size: Property value size. 52 * 53 * Return: 0 if success, -1 otherwise. 54 */ 55 int (*set_property)(struct dtv_streamer* streamer, const char* key, const void* value, 56 size_t size); 57 58 /** 59 * get_property() - Get a property's value. 60 * @streamer: Pointer to a streamer (may be NULL for plugin-wide properties). 61 * @key: NULL-terminated property name. 62 * @value: Property value. 63 * @size: Property value size. 64 * 65 * Return: >= 0 if success, -1 otherwise. 66 * 67 * If size is 0, get_property will return the size needed to hold the value. 68 */ 69 int (*get_property)(struct dtv_streamer* streamer, const char* key, void* value, size_t size); 70 71 /** 72 * add_pid() - Add a TS filter on a given pid. 73 * @streamer: The streamer that outputs the TS. 74 * @pid: The pid to add to the TS output. 75 * 76 * Return: 0 if success, -1 otherwise. 77 * 78 * This function is optional but can be useful if a hardware remux is 79 * available. 80 */ 81 int (*add_pid)(struct dtv_streamer* streamer, int pid); 82 83 /** 84 * remove_pid() - Remove a TS filter on a given pid. 85 * @streamer: The streamer that outputs the TS. 86 * @pid: The pid to remove from the TS output. 87 * 88 * Return: 0 if success, -1 otherwise. 89 * 90 * This function is optional. 91 */ 92 int (*remove_pid)(struct dtv_streamer* streamer, int pid); 93 94 /** 95 * open_stream() - Open a stream from a transport description. 96 * @streamer: The streamer which will handle the stream. 97 * @transport_desc: NULL-terminated transport description in json format. 98 * 99 * The streamer will allocate the resources and make the appropriate 100 * connections to handle this transport. 101 * This function returns a file descriptor that can be polled for events. 102 * 103 * Return: A file descriptor if success, -1 otherwise. 104 */ 105 int (*open_stream)(struct dtv_streamer* streamer, const char* transport_desc); 106 107 /** 108 * close_stream() - Release an open stream. 109 * @streamer: The streamer from which the stream should be released. 110 */ 111 void (*close_stream)(struct dtv_streamer* streamer); 112 113 /** 114 * read_stream() - Read stream data. 115 * @streamer: The streamer to read from. 116 * @buf: The destination buffer. 117 * @count: The number of bytes to read. 118 * @timeout_ms: Timeout in ms. 119 * 120 * Return: The number of bytes read, -1 if error. 121 */ 122 ssize_t (*read_stream)(struct dtv_streamer* streamer, void* buf, size_t count, int timeout_ms); 123 }; 124 125 struct dtv_plugin_event { 126 int id; 127 char data[0]; 128 }; 129 130 enum { 131 DTV_PLUGIN_EVENT_SIGNAL_LOST = 1, 132 DTV_PLUGIN_EVENT_SIGNAL_READY, 133 }; 134 135 #define PROPERTY_STATISTICS "statistics" 136 137 #endif // LIVE_DTV_PLUGIN_API_H_ 138