00001 /* 00002 * hdhomerun_video.h 00003 * 00004 * Copyright © 2006 Silicondust USA Inc. <www.silicondust.com>. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 3 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * As a special exception to the GNU Lesser General Public License, 00020 * you may link, statically or dynamically, an application with a 00021 * publicly distributed version of the Library to produce an 00022 * executable file containing portions of the Library, and 00023 * distribute that executable file under terms of your choice, 00024 * without any of the additional requirements listed in clause 4 of 00025 * the GNU Lesser General Public License. 00026 * 00027 * By "a publicly distributed version of the Library", we mean 00028 * either the unmodified Library as distributed by Silicondust, or a 00029 * modified version of the Library that is distributed under the 00030 * conditions defined in the GNU Lesser General Public License. 00031 */ 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 struct hdhomerun_video_sock_t; 00037 00038 struct hdhomerun_video_stats_t { 00039 uint32_t packet_count; 00040 uint32_t network_error_count; 00041 uint32_t transport_error_count; 00042 uint32_t sequence_error_count; 00043 uint32_t overflow_error_count; 00044 }; 00045 00046 #define TS_PACKET_SIZE 188 00047 #define VIDEO_DATA_PACKET_SIZE (188 * 7) 00048 #define VIDEO_DATA_BUFFER_SIZE_1S (20000000 / 8) 00049 00050 #define VIDEO_RTP_DATA_PACKET_SIZE ((188 * 7) + 12) 00051 00052 /* 00053 * Create a video/data socket. 00054 * 00055 * uint16_t listen_port: Port number to listen on. Set to 0 to auto-select. 00056 * size_t buffer_size: Size of receive buffer. For 1 second of buffer use VIDEO_DATA_BUFFER_SIZE_1S. 00057 * struct hdhomerun_debug_t *dbg: Pointer to debug logging object. May be NULL. 00058 * 00059 * Returns a pointer to the newly created control socket. 00060 * 00061 * When no longer needed, the socket should be destroyed by calling hdhomerun_control_destroy. 00062 */ 00063 extern LIBTYPE struct hdhomerun_video_sock_t *hdhomerun_video_create(uint16_t listen_port, size_t buffer_size, struct hdhomerun_debug_t *dbg); 00064 extern LIBTYPE void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs); 00065 00066 /* 00067 * Get the port the socket is listening on. 00068 * 00069 * Returns 16-bit port with native endianness, or 0 on error. 00070 */ 00071 extern LIBTYPE uint16_t hdhomerun_video_get_local_port(struct hdhomerun_video_sock_t *vs); 00072 00073 /* 00074 * Read data from buffer. 00075 * 00076 * size_t max_size: The maximum amount of data to be returned. 00077 * size_t *pactual_size: The caller-supplied pactual_size value will be updated to contain the amount 00078 * of data available to the caller. 00079 * 00080 * Returns a pointer to the data, or NULL if no data is available. 00081 * The data will remain valid until another call to hdhomerun_video_recv. 00082 * 00083 * The amount of data returned will always be a multiple of VIDEO_DATA_PACKET_SIZE (1316). 00084 * Attempting to read a single TS frame (188 bytes) will not return data as it is less than 00085 * the minimum size. 00086 * 00087 * The buffer is implemented as a ring buffer. It is possible for this function to return a small 00088 * amount of data when more is available due to the wrap-around case. 00089 */ 00090 extern LIBTYPE uint8_t *hdhomerun_video_recv(struct hdhomerun_video_sock_t *vs, size_t max_size, size_t *pactual_size); 00091 00092 /* 00093 * Flush the buffer. 00094 */ 00095 extern LIBTYPE void hdhomerun_video_flush(struct hdhomerun_video_sock_t *vs); 00096 00097 /* 00098 * Debug print internal stats. 00099 */ 00100 extern LIBTYPE void hdhomerun_video_debug_print_stats(struct hdhomerun_video_sock_t *vs); 00101 extern LIBTYPE void hdhomerun_video_get_stats(struct hdhomerun_video_sock_t *vs, struct hdhomerun_video_stats_t *stats); 00102 00103 #ifdef __cplusplus 00104 } 00105 #endif
1.5.5