Ticket #6138: 132-hdhr.20081231.trunk.2.patch
File 132-hdhr.20081231.trunk.2.patch, 107.7 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythhdhomerun/README
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/README myth.20746.0626b/mythtv/libs/libmythhdhomerun/README
1 1 /* 2 * libhdhomerun2 * README 3 3 * 4 4 * Copyright © 2005-2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 Top level include file: hdhomerun.h -
mythtv/libs/libmythhdhomerun/README.MythTV
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/README.MythTV myth.20746.0626b/mythtv/libs/libmythhdhomerun/README.MythTV
1 2 This directory contains Silicondust Engineering's hdhomerun 3 library used for communicating with the HDHomeRun hardware. 4 5 The files in this directory are released under the GNU LESSER GENERAL PUBLIC LICENSE 6 For details see the lgpl.txt file which should be located in this directory. 7 If you can not find it, it can also be seen at http://www.gnu.org/licenses/lgpl.txt -
mythtv/libs/libmythhdhomerun/hdhomerun.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun.h
1 1 /* 2 * hdhomerun _device.h2 * hdhomerun.h 3 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun_os.h" -
mythtv/libs/libmythhdhomerun/hdhomerun_channels.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_channels.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_channels.c
1 1 /* 2 * hdhomerun_channels can.c2 * hdhomerun_channels.c 3 3 * 4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" … … 24 37 struct hdhomerun_channel_entry_t { 25 38 struct hdhomerun_channel_entry_t *next; 26 39 struct hdhomerun_channel_entry_t *prev; 27 uint32_t channel_map;28 40 uint32_t frequency; 29 41 uint8_t channel_number; 30 42 char name[16]; 31 43 }; 32 44 33 struct hdhomerun_channel_map_range_t { 34 uint32_t channel_map; 45 struct hdhomerun_channel_list_t { 46 struct hdhomerun_channel_entry_t *head; 47 struct hdhomerun_channel_entry_t *tail; 48 }; 49 50 struct hdhomerun_channelmap_range_t { 35 51 uint8_t channel_range_start; 36 52 uint8_t channel_range_end; 37 53 uint32_t frequency; 38 54 uint32_t spacing; 39 55 }; 40 56 41 static const struct hdhomerun_channel_map_range_t hdhomerun_channels_map_ranges[] = { 42 {CHANNEL_MAP_US_BCAST, 2, 4, 57000000, 6000000}, 43 {CHANNEL_MAP_US_BCAST, 5, 6, 79000000, 6000000}, 44 {CHANNEL_MAP_US_BCAST, 7, 13, 177000000, 6000000}, 45 {CHANNEL_MAP_US_BCAST, 14, 69, 473000000, 6000000}, 46 47 {CHANNEL_MAP_US_CABLE, 1, 1, 75000000, 6000000}, 48 {CHANNEL_MAP_US_CABLE, 2, 4, 57000000, 6000000}, 49 {CHANNEL_MAP_US_CABLE, 5, 6, 79000000, 6000000}, 50 {CHANNEL_MAP_US_CABLE, 7, 13, 177000000, 6000000}, 51 {CHANNEL_MAP_US_CABLE, 14, 22, 123000000, 6000000}, 52 {CHANNEL_MAP_US_CABLE, 23, 94, 219000000, 6000000}, 53 {CHANNEL_MAP_US_CABLE, 95, 99, 93000000, 6000000}, 54 {CHANNEL_MAP_US_CABLE, 100, 136, 651000000, 6000000}, 55 56 {CHANNEL_MAP_US_HRC, 1, 1, 73753600, 6000300}, 57 {CHANNEL_MAP_US_HRC, 2, 4, 55752700, 6000300}, 58 {CHANNEL_MAP_US_HRC, 5, 6, 79753900, 6000300}, 59 {CHANNEL_MAP_US_HRC, 7, 13, 175758700, 6000300}, 60 {CHANNEL_MAP_US_HRC, 14, 22, 121756000, 6000300}, 61 {CHANNEL_MAP_US_HRC, 23, 94, 217760800, 6000300}, 62 {CHANNEL_MAP_US_HRC, 95, 99, 91754500, 6000300}, 63 {CHANNEL_MAP_US_HRC, 100, 136, 649782400, 6000300}, 64 65 {CHANNEL_MAP_US_IRC, 1, 1, 75012500, 6000000}, 66 {CHANNEL_MAP_US_IRC, 2, 4, 57012500, 6000000}, 67 {CHANNEL_MAP_US_IRC, 5, 6, 81012500, 6000000}, 68 {CHANNEL_MAP_US_IRC, 7, 13, 177012500, 6000000}, 69 {CHANNEL_MAP_US_IRC, 14, 22, 123012500, 6000000}, 70 {CHANNEL_MAP_US_IRC, 23, 41, 219012500, 6000000}, 71 {CHANNEL_MAP_US_IRC, 42, 42, 333025000, 6000000}, 72 {CHANNEL_MAP_US_IRC, 43, 94, 339012500, 6000000}, 73 {CHANNEL_MAP_US_IRC, 95, 97, 93012500, 6000000}, 74 {CHANNEL_MAP_US_IRC, 98, 99, 111025000, 6000000}, 75 {CHANNEL_MAP_US_IRC, 100, 136, 651012500, 6000000}, 76 77 {CHANNEL_MAP_UK_BCAST, 21, 68, 474000000, 8000000}, 78 {CHANNEL_MAP_NZ_BCAST, 25, 62, 506000000, 8000000}, 79 80 {0, 0, 0, 0, 0} 57 struct hdhomerun_channelmap_record_t { 58 const char *channelmap_prefix; 59 const char *channelmap; 60 const struct hdhomerun_channelmap_range_t *range_list; 61 const char *channelmap_scan_group; 62 const char *countrycodes; 63 }; 64 65 /* AU antenna channels. Channels {0, 1, 2, 6, 7, 8, 9, 9A} are numbered {2, 3, 4, 5, 6, 7, 8, 9} by the HDHomeRun. */ 66 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_au_bcast[] = { 67 { 2, 2, 48500000, 7000000}, 68 { 3, 4, 59500000, 7000000}, 69 { 5, 12, 177500000, 7000000}, 70 { 28, 69, 529500000, 7000000}, 71 { 0, 0, 0, 0} 72 }; 73 74 /* AU cable channels. TBD. */ 75 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_au_cable[] = { 76 { 0, 0, 0, 0} 77 }; 78 79 /* EU antenna channels. */ 80 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_eu_bcast[] = { 81 { 2, 4, 50500000, 7000000}, 82 { 5, 12, 177500000, 7000000}, 83 { 21, 69, 474000000, 8000000}, 84 { 0, 0, 0, 0} 85 }; 86 87 /* EU cable channels. Channels do not have simple numbers - the HDHomeRun uses its own numbering scheme (subject to change). */ 88 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_eu_cable[] = { 89 { 6, 7, 113000000, 8000000}, 90 { 9, 100, 138000000, 8000000}, 91 { 0, 0, 0, 0} 81 92 }; 82 93 83 static struct hdhomerun_channel_entry_t *hdhomerun_channel_list_head = NULL; 84 static struct hdhomerun_channel_entry_t *hdhomerun_channel_list_tail = NULL; 94 /* US antenna channels. */ 95 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_bcast[] = { 96 { 2, 4, 57000000, 6000000}, 97 { 5, 6, 79000000, 6000000}, 98 { 7, 13, 177000000, 6000000}, 99 { 14, 69, 473000000, 6000000}, 100 { 0, 0, 0, 0} 101 }; 102 103 /* US cable channels. */ 104 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_cable[] = { 105 { 2, 4, 57000000, 6000000}, 106 { 5, 6, 79000000, 6000000}, 107 { 7, 13, 177000000, 6000000}, 108 { 14, 22, 123000000, 6000000}, 109 { 23, 94, 219000000, 6000000}, 110 { 95, 99, 93000000, 6000000}, 111 {100, 135, 651000000, 6000000}, 112 { 0, 0, 0, 0} 113 }; 114 115 /* US cable channels (HRC). */ 116 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_hrc[] = { 117 { 2, 4, 55752700, 6000300}, 118 { 5, 6, 79753900, 6000300}, 119 { 7, 13, 175758700, 6000300}, 120 { 14, 22, 121756000, 6000300}, 121 { 23, 94, 217760800, 6000300}, 122 { 95, 99, 91754500, 6000300}, 123 {100, 135, 649782400, 6000300}, 124 { 0, 0, 0, 0} 125 }; 85 126 86 uint32_t hdhomerun_channel_entry_channel_map(struct hdhomerun_channel_entry_t *entry) 127 /* US cable channels (IRC). */ 128 static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_irc[] = { 129 { 2, 4, 57012500, 6000000}, 130 { 5, 6, 81012500, 6000000}, 131 { 7, 13, 177012500, 6000000}, 132 { 14, 22, 123012500, 6000000}, 133 { 23, 41, 219012500, 6000000}, 134 { 42, 42, 333025000, 6000000}, 135 { 43, 94, 339012500, 6000000}, 136 { 95, 97, 93012500, 6000000}, 137 { 98, 99, 111025000, 6000000}, 138 {100, 135, 651012500, 6000000}, 139 { 0, 0, 0, 0} 140 }; 141 142 static const struct hdhomerun_channelmap_record_t hdhomerun_channelmap_table[] = { 143 {"au", "au-bcast", hdhomerun_channelmap_range_au_bcast, "au-bcast", "AU"}, 144 {"au", "au-cable", hdhomerun_channelmap_range_au_cable, "au-cable", "AU"}, 145 {"eu", "eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", "EU"}, 146 {"eu", "eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", "EU"}, 147 {"tw", "tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"}, 148 {"tw", "tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"}, 149 {"us", "us-bcast", hdhomerun_channelmap_range_us_bcast, "us-bcast", "CA US"}, 150 {"us", "us-cable", hdhomerun_channelmap_range_us_cable, "us-cable us-hrc us-irc", "CA US"}, 151 {"us", "us-hrc", hdhomerun_channelmap_range_us_hrc , "us-cable us-hrc us-irc", "CA US"}, 152 {"us", "us-irc", hdhomerun_channelmap_range_us_irc, "us-cable us-hrc us-irc", "CA US"}, 153 {NULL, NULL, NULL, NULL, NULL} 154 }; 155 156 const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode) 87 157 { 88 return entry->channel_map; 158 const struct hdhomerun_channelmap_record_t *record = hdhomerun_channelmap_table; 159 while (record->channelmap) { 160 if (strstr(record->countrycodes, countrycode)) { 161 return record->channelmap_prefix; 162 } 163 record++; 164 } 165 166 return "eu"; 167 } 168 169 const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap) 170 { 171 const struct hdhomerun_channelmap_record_t *record = hdhomerun_channelmap_table; 172 while (record->channelmap) { 173 if (strstr(channelmap, record->channelmap)) { 174 return record->channelmap_scan_group; 175 } 176 record++; 177 } 178 179 return NULL; 89 180 } 90 181 91 182 uint8_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry) … … const char *hdhomerun_channel_entry_name 103 194 return entry->name; 104 195 } 105 196 106 st atic const char *hdhomerun_channel_map_name(uint32_t channel_map)197 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(struct hdhomerun_channel_list_t *channel_list) 107 198 { 108 switch (channel_map) { 109 case CHANNEL_MAP_US_BCAST: 110 return "us-bcast"; 111 case CHANNEL_MAP_US_CABLE: 112 return "us-cable"; 113 case CHANNEL_MAP_US_HRC: 114 return "us-hrc"; 115 case CHANNEL_MAP_US_IRC: 116 return "us-irc"; 117 case CHANNEL_MAP_UK_BCAST: 118 return "uk-bcast"; 119 case CHANNEL_MAP_NZ_BCAST: 120 return "nz-bcast"; 121 default: 122 return "unknown"; 123 } 199 return channel_list->head; 124 200 } 125 201 126 st atic void hdhomerun_channel_list_build_insert(struct hdhomerun_channel_entry_t *entry)202 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(struct hdhomerun_channel_list_t *channel_list) 127 203 { 128 struct hdhomerun_channel_entry_t *prev = NULL; 129 struct hdhomerun_channel_entry_t *next = hdhomerun_channel_list_head; 130 131 while (next) { 132 if (next->frequency > entry->frequency) { 133 break; 134 } 135 136 prev = next; 137 next = next->next; 138 } 139 140 entry->prev = prev; 141 entry->next = next; 142 143 if (prev) { 144 prev->next = entry; 145 } else { 146 hdhomerun_channel_list_head = entry; 147 } 148 149 if (next) { 150 next->prev = entry; 151 } else { 152 hdhomerun_channel_list_tail = entry; 153 } 204 return channel_list->tail; 154 205 } 155 206 156 st atic void hdhomerun_channel_list_build_range(const struct hdhomerun_channel_map_range_t *range)207 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry) 157 208 { 158 uint8_t channel_number; 159 for (channel_number = range->channel_range_start; channel_number <= range->channel_range_end; channel_number++) { 160 struct hdhomerun_channel_entry_t *entry = (struct hdhomerun_channel_entry_t *)calloc(1, sizeof(struct hdhomerun_channel_entry_t)); 161 if (!entry) { 162 return; 163 } 164 165 entry->channel_map = range->channel_map; 166 entry->channel_number = channel_number; 167 entry->frequency = range->frequency + ((uint32_t)(channel_number - range->channel_range_start) * range->spacing); 168 entry->frequency = (entry->frequency / FREQUENCY_RESOLUTION) * FREQUENCY_RESOLUTION; 169 sprintf(entry->name, "%s:%u", hdhomerun_channel_map_name(entry->channel_map), entry->channel_number); 170 171 hdhomerun_channel_list_build_insert(entry); 172 } 209 return entry->next; 173 210 } 174 211 175 st atic void hdhomerun_channel_list_build(void)212 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry) 176 213 { 177 const struct hdhomerun_channel_map_range_t *range = hdhomerun_channels_map_ranges; 178 while (range->channel_map) { 179 hdhomerun_channel_list_build_range(range); 180 range++; 181 } 214 return entry->prev; 182 215 } 183 216 184 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(uint32_t channel_map)217 uint32_t hdhomerun_channel_list_total_count(struct hdhomerun_channel_list_t *channel_list) 185 218 { 186 if (!hdhomerun_channel_list_head) { 187 hdhomerun_channel_list_build(); 188 } 219 uint32_t count = 0; 189 220 190 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_ head;221 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_list); 191 222 while (entry) { 192 if (entry->channel_map & channel_map) { 193 return entry; 194 } 195 196 entry = entry->next; 223 count++; 224 entry = hdhomerun_channel_list_next(channel_list, entry); 197 225 } 198 226 199 return NULL;227 return count; 200 228 } 201 229 202 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(uint32_t channel_map)230 uint32_t hdhomerun_channel_list_frequency_count(struct hdhomerun_channel_list_t *channel_list) 203 231 { 204 if (!hdhomerun_channel_list_head) { 205 hdhomerun_channel_list_build(); 206 } 232 uint32_t count = 0; 233 uint32_t last_frequency = 0; 207 234 208 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_ tail;235 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_list); 209 236 while (entry) { 210 if (entry->channel_map & channel_map) { 211 return entry; 237 if (entry->frequency != last_frequency) { 238 last_frequency = entry->frequency; 239 count++; 212 240 } 213 241 214 entry = entry->prev;242 entry = hdhomerun_channel_list_next(channel_list, entry); 215 243 } 216 244 217 return NULL; 245 return count; 246 } 247 248 uint32_t hdhomerun_channel_frequency_truncate(uint32_t frequency) 249 { 250 return (frequency / FREQUENCY_RESOLUTION) * FREQUENCY_RESOLUTION; 218 251 } 219 252 220 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(uint32_t channel_map, struct hdhomerun_channel_entry_t *entry)253 uint32_t hdhomerun_channel_number_to_frequency(struct hdhomerun_channel_list_t *channel_list, uint8_t channel_number) 221 254 { 222 entry = entry->next;255 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_list); 223 256 while (entry) { 224 if (entry->channel_ map & channel_map) {225 return entry ;257 if (entry->channel_number == channel_number) { 258 return entry->frequency; 226 259 } 227 260 228 entry = entry->next;261 entry = hdhomerun_channel_list_next(channel_list, entry); 229 262 } 230 263 231 return NULL;264 return 0; 232 265 } 233 266 234 struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(uint32_t channel_map, struct hdhomerun_channel_entry_t *entry)267 uint8_t hdhomerun_channel_frequency_to_number(struct hdhomerun_channel_list_t *channel_list, uint32_t frequency) 235 268 { 236 entry = entry->prev; 269 frequency = hdhomerun_channel_frequency_truncate(frequency); 270 271 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_list); 237 272 while (entry) { 238 if (entry->channel_map & channel_map) { 239 return entry; 273 if (entry->frequency == frequency) { 274 return entry->channel_number; 275 } 276 if (entry->frequency > frequency) { 277 return 0; 240 278 } 241 279 242 entry = entry->prev;280 entry = hdhomerun_channel_list_next(channel_list, entry); 243 281 } 244 282 245 return NULL;283 return 0; 246 284 } 247 285 248 uint32_t hdhomerun_channel_list_total_count(uint32_t channel_map)286 static void hdhomerun_channel_list_build_insert(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry) 249 287 { 250 uint32_t count = 0; 288 struct hdhomerun_channel_entry_t *prev = NULL; 289 struct hdhomerun_channel_entry_t *next = channel_list->head; 251 290 252 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_map); 253 while (entry) { 254 count++; 255 entry = hdhomerun_channel_list_next(channel_map, entry); 291 while (next) { 292 if (next->frequency > entry->frequency) { 293 break; 294 } 295 296 prev = next; 297 next = next->next; 256 298 } 257 299 258 return count; 300 entry->prev = prev; 301 entry->next = next; 302 303 if (prev) { 304 prev->next = entry; 305 } else { 306 channel_list->head = entry; 307 } 308 309 if (next) { 310 next->prev = entry; 311 } else { 312 channel_list->tail = entry; 313 } 259 314 } 260 315 261 uint32_t hdhomerun_channel_list_frequency_count(uint32_t channel_map)316 static void hdhomerun_channel_list_build_range(struct hdhomerun_channel_list_t *channel_list, const char *channelmap, const struct hdhomerun_channelmap_range_t *range) 262 317 { 263 uint32_t count = 0; 264 uint32_t last_frequency = 0; 265 266 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_map); 267 while (entry) { 268 if (entry->frequency != last_frequency) { 269 last_frequency = entry->frequency; 270 count++; 318 uint8_t channel_number; 319 for (channel_number = range->channel_range_start; channel_number <= range->channel_range_end; channel_number++) { 320 struct hdhomerun_channel_entry_t *entry = (struct hdhomerun_channel_entry_t *)calloc(1, sizeof(struct hdhomerun_channel_entry_t)); 321 if (!entry) { 322 return; 271 323 } 272 324 273 entry = hdhomerun_channel_list_next(channel_map, entry); 274 } 325 entry->channel_number = channel_number; 326 entry->frequency = range->frequency + ((uint32_t)(channel_number - range->channel_range_start) * range->spacing); 327 entry->frequency = hdhomerun_channel_frequency_truncate(entry->frequency); 328 sprintf(entry->name, "%s:%u", channelmap, entry->channel_number); 275 329 276 return count; 330 hdhomerun_channel_list_build_insert(channel_list, entry); 331 } 277 332 } 278 333 279 uint32_t hdhomerun_channel_number_to_frequency(uint32_t channel_map, uint8_t channel_number)334 static void hdhomerun_channel_list_build_ranges(struct hdhomerun_channel_list_t *channel_list, const struct hdhomerun_channelmap_record_t *record) 280 335 { 281 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_map); 282 while (entry) { 283 if (entry->channel_number == channel_number) { 284 return entry->frequency; 285 } 336 const struct hdhomerun_channelmap_range_t *range = record->range_list; 337 while (range->frequency) { 338 hdhomerun_channel_list_build_range(channel_list, record->channelmap, range); 339 range++; 340 } 341 } 286 342 287 entry = hdhomerun_channel_list_next(channel_map, entry); 343 void hdhomerun_channel_list_destroy(struct hdhomerun_channel_list_t *channel_list) 344 { 345 while (channel_list->head) { 346 struct hdhomerun_channel_entry_t *entry = channel_list->head; 347 channel_list->head = entry->next; 348 free(entry); 288 349 } 289 350 290 return 0;351 free(channel_list); 291 352 } 292 353 293 uint8_t hdhomerun_channel_frequency_to_number(uint32_t channel_map, uint32_t frequency)354 struct hdhomerun_channel_list_t *hdhomerun_channel_list_create(const char *channelmap) 294 355 { 295 frequency = (frequency / FREQUENCY_RESOLUTION) * FREQUENCY_RESOLUTION; 356 struct hdhomerun_channel_list_t *channel_list = (struct hdhomerun_channel_list_t *)calloc(1, sizeof(struct hdhomerun_channel_list_t)); 357 if (!channel_list) { 358 return NULL; 359 } 296 360 297 struct hdhomerun_channel_entry_t *entry = hdhomerun_channel_list_first(channel_map); 298 while (entry) { 299 if (entry->frequency == frequency) { 300 return entry->channel_number; 301 } 302 if (entry->frequency > frequency) { 303 return 0; 361 const struct hdhomerun_channelmap_record_t *record = hdhomerun_channelmap_table; 362 while (record->channelmap) { 363 if (!strstr(channelmap, record->channelmap)) { 364 record++; 365 continue; 304 366 } 305 367 306 entry = hdhomerun_channel_list_next(channel_map, entry); 368 hdhomerun_channel_list_build_ranges(channel_list, record); 369 record++; 307 370 } 308 371 309 return 0; 372 if (!channel_list->head) { 373 free(channel_list); 374 return NULL; 375 } 376 377 return channel_list; 310 378 } -
mythtv/libs/libmythhdhomerun/hdhomerun_channels.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_channels.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_channels.h
1 1 /* 2 2 * hdhomerun_channels.h 3 3 * 4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 #define CHANNEL_MAP_US_BCAST (1 << 0) 21 #define CHANNEL_MAP_US_CABLE (1 << 1) 22 #define CHANNEL_MAP_US_HRC (1 << 2) 23 #define CHANNEL_MAP_US_IRC (1 << 3) 24 #define CHANNEL_MAP_US_ALL (CHANNEL_MAP_US_BCAST | CHANNEL_MAP_US_CABLE | CHANNEL_MAP_US_HRC | CHANNEL_MAP_US_IRC) 25 26 #define CHANNEL_MAP_UK_BCAST (1 << 4) 27 #define CHANNEL_MAP_NZ_BCAST (1 << 5) 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 28 36 29 37 struct hdhomerun_channel_entry_t; 38 struct hdhomerun_channel_list_t; 39 40 extern LIBTYPE const char *hdhomerun_channelmap_convert_countrycode_to_channelmap_prefix(const char *countrycode); 41 extern LIBTYPE const char *hdhomerun_channelmap_get_channelmap_scan_group(const char *channelmap); 30 42 31 extern LIBTYPE uint32_t hdhomerun_channel_entry_channel_map(struct hdhomerun_channel_entry_t *entry);32 43 extern LIBTYPE uint8_t hdhomerun_channel_entry_channel_number(struct hdhomerun_channel_entry_t *entry); 33 44 extern LIBTYPE uint32_t hdhomerun_channel_entry_frequency(struct hdhomerun_channel_entry_t *entry); 34 45 extern LIBTYPE const char *hdhomerun_channel_entry_name(struct hdhomerun_channel_entry_t *entry); 35 46 36 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(uint32_t channel_map); 37 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(uint32_t channel_map); 38 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(uint32_t channel_map, struct hdhomerun_channel_entry_t *entry); 39 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(uint32_t channel_map, struct hdhomerun_channel_entry_t *entry); 40 extern LIBTYPE uint32_t hdhomerun_channel_list_total_count(uint32_t channel_map); 41 extern LIBTYPE uint32_t hdhomerun_channel_list_frequency_count(uint32_t channel_map); 47 extern LIBTYPE struct hdhomerun_channel_list_t *hdhomerun_channel_list_create(const char *channelmap); 48 extern LIBTYPE void hdhomerun_channel_list_destroy(struct hdhomerun_channel_list_t *channel_list); 42 49 43 extern LIBTYPE uint32_t hdhomerun_channel_number_to_frequency(uint32_t channel_map, uint8_t channel_number); 44 extern LIBTYPE uint8_t hdhomerun_channel_frequency_to_number(uint32_t channel_map, uint32_t frequency); 50 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_first(struct hdhomerun_channel_list_t *channel_list); 51 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_last(struct hdhomerun_channel_list_t *channel_list); 52 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_next(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry); 53 extern LIBTYPE struct hdhomerun_channel_entry_t *hdhomerun_channel_list_prev(struct hdhomerun_channel_list_t *channel_list, struct hdhomerun_channel_entry_t *entry); 54 extern LIBTYPE uint32_t hdhomerun_channel_list_total_count(struct hdhomerun_channel_list_t *channel_list); 55 extern LIBTYPE uint32_t hdhomerun_channel_list_frequency_count(struct hdhomerun_channel_list_t *channel_list); 56 57 extern LIBTYPE uint32_t hdhomerun_channel_frequency_truncate(uint32_t frequency); 58 extern LIBTYPE uint32_t hdhomerun_channel_number_to_frequency(struct hdhomerun_channel_list_t *channel_list, uint8_t channel_number); 59 extern LIBTYPE uint8_t hdhomerun_channel_frequency_to_number(struct hdhomerun_channel_list_t *channel_list, uint32_t frequency); 60 61 #ifdef __cplusplus 62 } 63 #endif -
mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.c
1 1 /* 2 2 * hdhomerun_channelscan.c 3 3 * 4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" 21 34 22 35 struct hdhomerun_channelscan_t { 23 36 struct hdhomerun_device_t *hd; 24 uint32_t channel_map;25 uint32_t options;26 37 uint32_t scanned_channels; 38 struct hdhomerun_channel_list_t *channel_list; 27 39 struct hdhomerun_channel_entry_t *next_channel; 28 40 }; 29 41 30 struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, uint32_t channel_map, uint32_t options)42 struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, const char *channelmap) 31 43 { 32 44 struct hdhomerun_channelscan_t *scan = (struct hdhomerun_channelscan_t *)calloc(1, sizeof(struct hdhomerun_channelscan_t)); 33 45 if (!scan) { … … struct hdhomerun_channelscan_t *channels 35 47 } 36 48 37 49 scan->hd = hd; 38 scan->channel_map = channel_map;39 scan->options = options;40 50 41 if (scan->options & HDHOMERUN_CHANNELSCAN_OPTION_REVERSE) {42 scan->next_channel = hdhomerun_channel_list_last(channel_map);43 } else {44 scan->next_channel = hdhomerun_channel_list_first(channel_map);51 scan->channel_list = hdhomerun_channel_list_create(channelmap); 52 if (!scan->channel_list) { 53 free(scan); 54 return NULL; 45 55 } 46 56 57 scan->next_channel = hdhomerun_channel_list_last(scan->channel_list); 47 58 return scan; 48 59 } 49 60 … … void channelscan_destroy(struct hdhomeru 52 63 free(scan); 53 64 } 54 65 55 static struct hdhomerun_channel_entry_t *channelscan_advance_channel_internal(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channel_entry_t *entry)56 {57 if (scan->options & HDHOMERUN_CHANNELSCAN_OPTION_REVERSE) {58 return hdhomerun_channel_list_prev(scan->channel_map, entry);59 } else {60 return hdhomerun_channel_list_next(scan->channel_map, entry);61 }62 }63 64 66 static int channelscan_execute_find_lock(struct hdhomerun_channelscan_t *scan, uint32_t frequency, struct hdhomerun_channelscan_result_t *result) 65 67 { 66 68 /* Set channel. */ … … static int channelscan_execute_find_lock 100 102 return 1; 101 103 } 102 104 105 static void channelscan_extract_name(struct hdhomerun_channelscan_program_t *program, const char *line) 106 { 107 /* Find start of name. */ 108 const char *start = strchr(line, ' '); 109 if (!start) { 110 return; 111 } 112 start++; 113 114 start = strchr(start, ' '); 115 if (!start) { 116 return; 117 } 118 start++; 119 120 /* Find end of name. */ 121 const char *end = strstr(start, " ("); 122 if (!end) { 123 end = strchr(line, 0); 124 } 125 126 if (end <= start) { 127 return; 128 } 129 130 /* Extract name. */ 131 size_t length = (size_t)(end - start); 132 if (length > sizeof(program->name) - 1) { 133 length = sizeof(program->name) - 1; 134 } 135 136 strncpy(program->name, start, length); 137 program->name[length] = 0; 138 } 139 103 140 static int channelscan_execute_detect_programs(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result, int *pchanged) 104 141 { 105 142 *pchanged = FALSE; … … static int channelscan_execute_detect_pr 129 166 130 167 unsigned int program_number; 131 168 unsigned int virtual_major, virtual_minor; 132 if (sscanf(line, "%u: %u.%u %7s", &program_number, &virtual_major, &virtual_minor, program.name) != 4) { 133 if (sscanf(line, "%u: %u.%u", &program_number, &virtual_major, &virtual_minor) != 3) { 134 continue; 135 } 169 if (sscanf(line, "%u: %u.%u", &program_number, &virtual_major, &virtual_minor) != 3) { 170 continue; 136 171 } 137 172 138 173 program.program_number = program_number; 139 174 program.virtual_major = virtual_major; 140 175 program.virtual_minor = virtual_minor; 141 176 142 if (program.name[0] == '(') { 143 memset(program.name, 0, sizeof(program.name)); 144 } 177 channelscan_extract_name(&program, line); 145 178 146 179 program.type = HDHOMERUN_CHANNELSCAN_PROGRAM_NORMAL; 147 180 if (strstr(line, "(no data)")) { … … int channelscan_advance(struct hdhomerun 186 219 187 220 /* Combine channels with same frequency. */ 188 221 result->frequency = hdhomerun_channel_entry_frequency(entry); 189 result->channel_map = hdhomerun_channel_entry_channel_map(entry);190 strcpy(result->channel_str, hdhomerun_channel_entry_name(entry));222 strncpy(result->channel_str, hdhomerun_channel_entry_name(entry), sizeof(result->channel_str) - 1); 223 result->channel_str[sizeof(result->channel_str) - 1] = 0; 191 224 192 225 while (1) { 193 entry = channelscan_advance_channel_internal(scan, entry);226 entry = hdhomerun_channel_list_prev(scan->channel_list, entry); 194 227 if (!entry) { 195 228 scan->next_channel = NULL; 196 229 break; … … int channelscan_advance(struct hdhomerun 203 236 204 237 char *ptr = strchr(result->channel_str, 0); 205 238 sprintf(ptr, ", %s", hdhomerun_channel_entry_name(entry)); 206 result->channel_map |= hdhomerun_channel_entry_channel_map(entry);207 239 } 208 240 209 241 return 1; … … int channelscan_detect(struct hdhomerun_ 222 254 return 1; 223 255 } 224 256 225 /* Refine channel map. */226 if ((scan->options & HDHOMERUN_CHANNELSCAN_OPTION_REFINE_CHANNEL_MAP) && (result->status.symbol_error_quality == 100)) {227 scan->channel_map = result->channel_map;228 229 /* Fixup next channel. */230 struct hdhomerun_channel_entry_t *entry = scan->next_channel;231 if (entry && (hdhomerun_channel_entry_channel_map(entry) & scan->channel_map) == 0) {232 scan->next_channel = channelscan_advance_channel_internal(scan, entry);233 }234 }235 236 257 /* Detect programs. */ 237 258 result->program_count = 0; 238 259 … … uint8_t channelscan_get_progress(struct 278 299 uint32_t frequency = hdhomerun_channel_entry_frequency(entry); 279 300 280 301 while (1) { 281 entry = channelscan_advance_channel_internal(scan, entry);302 entry = hdhomerun_channel_list_prev(scan->channel_list, entry); 282 303 if (!entry) { 283 304 break; 284 305 } -
mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_channelscan.h
1 1 /* 2 2 * hdhomerun_channelscan.h 3 3 * 4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2007-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 20 37 #define HDHOMERUN_CHANNELSCAN_PROGRAM_NORMAL 0 21 38 #define HDHOMERUN_CHANNELSCAN_PROGRAM_NODATA 1 22 39 #define HDHOMERUN_CHANNELSCAN_PROGRAM_CONTROL 2 23 40 #define HDHOMERUN_CHANNELSCAN_PROGRAM_ENCRYPTED 3 24 41 25 #define HDHOMERUN_CHANNELSCAN_OPTION_REVERSE (1 << 0)26 #define HDHOMERUN_CHANNELSCAN_OPTION_REFINE_CHANNEL_MAP (1 << 1)27 28 42 struct hdhomerun_channelscan_t; 29 43 30 extern LIBTYPE struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, uint32_t channel_map, uint32_t options);44 extern LIBTYPE struct hdhomerun_channelscan_t *channelscan_create(struct hdhomerun_device_t *hd, const char *channelmap); 31 45 extern LIBTYPE void channelscan_destroy(struct hdhomerun_channelscan_t *scan); 32 46 33 47 extern LIBTYPE int channelscan_advance(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result); 34 48 extern LIBTYPE int channelscan_detect(struct hdhomerun_channelscan_t *scan, struct hdhomerun_channelscan_result_t *result); 35 49 extern LIBTYPE uint8_t channelscan_get_progress(struct hdhomerun_channelscan_t *scan); 50 51 #ifdef __cplusplus 52 } 53 #endif -
mythtv/libs/libmythhdhomerun/hdhomerun_config.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_config.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_config.c
1 1 /* 2 2 * hdhomerun_config.c 3 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" 21 34 35 /* 36 * The console output format should be set to UTF-8, however in XP and Vista this breaks batch file processing. 37 * Attempting to restore on exit fails to restore if the program is terminated by the user. 38 * Solution - set the output format each printf. 39 */ 40 #if defined(__WINDOWS__) 41 #define printf console_printf 42 #define vprintf console_vprintf 43 #endif 44 22 45 static const char *appname; 23 46 24 47 struct hdhomerun_device_t *hd; … … static int cmd_get(const char *item) 131 154 return 1; 132 155 } 133 156 134 static int cmd_set (const char *item, const char *value)157 static int cmd_set_internal(const char *item, const char *value) 135 158 { 136 159 char *ret_error; 137 160 if (hdhomerun_device_set_var(hd, item, value, NULL, &ret_error) < 0) { … … static int cmd_set(const char *item, con 147 170 return 1; 148 171 } 149 172 173 static int cmd_set(const char *item, const char *value) 174 { 175 if (strcmp(value, "-") == 0) { 176 char *buffer = NULL; 177 size_t pos = 0; 178 179 while (1) { 180 buffer = (char *)realloc(buffer, pos + 1024); 181 if (!buffer) { 182 fprintf(stderr, "out of memory\n"); 183 return -1; 184 } 185 186 int size = fread(buffer + pos, 1, 1024, stdin); 187 pos += size; 188 189 if (size < 1024) { 190 break; 191 } 192 } 193 194 buffer[pos] = 0; 195 196 int ret = cmd_set_internal(item, buffer); 197 198 free(buffer); 199 return ret; 200 } 201 202 return cmd_set_internal(item, value); 203 } 204 150 205 static void cmd_scan_printf(FILE *fp, const char *fmt, ...) 151 206 { 152 207 va_list ap; … … static int cmd_scan(const char *tuner_st 175 230 return -1; 176 231 } 177 232 178 uint32_t channel_map = hdhomerun_device_model_channel_map_all(hd);179 if ( channel_map == 0) {180 fprintf(stderr, "failed to detect channel_map set\n");233 char *channelmap; 234 if (hdhomerun_device_get_tuner_channelmap(hd, &channelmap) <= 0) { 235 fprintf(stderr, "failed to query channelmap from device\n"); 181 236 return -1; 182 237 } 183 238 184 if (hdhomerun_device_channelscan_init(hd, channel_map, 0) <= 0) { 239 const char *channelmap_scan_group = hdhomerun_channelmap_get_channelmap_scan_group(channelmap); 240 if (!channelmap_scan_group) { 241 fprintf(stderr, "unknown channelmap '%s'\n", channelmap); 242 return -1; 243 } 244 245 if (hdhomerun_device_channelscan_init(hd, channelmap_scan_group) <= 0) { 185 246 fprintf(stderr, "failed to initialize channel scan\n"); 186 247 return -1; 187 248 } … … static void cmd_save_abort(int junk) 238 299 struct hdhomerun_video_stats_t stats; 239 300 hdhomerun_device_get_video_stats(hd, &stats); 240 301 hdhomerun_device_stream_stop(hd); 302 hdhomerun_device_destroy(hd); 241 303 242 304 fprintf(stderr, "\n"); 243 305 fprintf(stderr, "-- Video statistics --\n"); … … static int cmd_save(const char *tuner_st 257 319 return -1; 258 320 } 259 321 260 FILE *fp = NULL; 261 262 if (strcmp(filename, "-") == 0) { 322 FILE *fp; 323 if (strcmp(filename, "null") == 0) { 324 fp = NULL; 325 } else if (strcmp(filename, "-") == 0) { 263 326 fp = stdout; 264 } else if (strcmp(filename, "null") != 0){327 } else { 265 328 fp = fopen(filename, "wb"); 266 267 329 if (!fp) { 268 330 fprintf(stderr, "unable to create file %s\n", filename); 269 331 return -1; 270 332 } 271 333 } 272 334 273 signal(SIGINT, cmd_save_abort);274 signal(SIGPIPE, cmd_save_abort);275 276 335 int ret = hdhomerun_device_stream_start(hd); 277 336 if (ret <= 0) { 278 337 fprintf(stderr, "unable to start stream\n"); 279 fclose(fp);280 338 return ret; 281 339 } 282 340 341 signal(SIGINT, cmd_save_abort); 342 signal(SIGPIPE, cmd_save_abort); 343 283 344 struct hdhomerun_video_stats_t stats_old, stats_cur; 284 345 hdhomerun_device_get_video_stats(hd, &stats_old); 285 346 … … static int cmd_save(const char *tuner_st 294 355 } 295 356 296 357 if (fp) { 297 fwrite(ptr, 1, actual_size, fp); 358 if (fwrite(ptr, 1, actual_size, fp) != actual_size) { 359 fprintf(stderr, "error writing output\n"); 360 return -1; 361 } 298 362 } 299 363 300 364 uint64_t current_time = getcurrenttime(); … … static int main_cmd(int argc, char *argv 413 477 static int main_internal(int argc, char *argv[]) 414 478 { 415 479 #if defined(__WINDOWS__) 480 /* Initialize network socket support. */ 416 481 WORD wVersionRequested = MAKEWORD(2, 0); 417 482 WSADATA wsaData; 418 483 WSAStartup(wVersionRequested, &wsaData); -
mythtv/libs/libmythhdhomerun/hdhomerun_control.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_control.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_control.c
1 1 /* 2 2 * hdhomerun_control.c 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" … … int hdhomerun_control_send_recv(struct h 276 289 return hdhomerun_control_send_recv_internal(cs, tx_pkt, rx_pkt, type, HDHOMERUN_CONTROL_RECV_TIMEOUT); 277 290 } 278 291 279 static int hdhomerun_control_get_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror)292 static int hdhomerun_control_get_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror) 280 293 { 281 294 struct hdhomerun_pkt_t *tx_pkt = &cs->tx_pkt; 282 295 struct hdhomerun_pkt_t *rx_pkt = &cs->rx_pkt; … … static int hdhomerun_control_get_set(str 285 298 hdhomerun_pkt_reset(tx_pkt); 286 299 287 300 int name_len = (int)strlen(name) + 1; 301 if (tx_pkt->end + 3 + name_len > tx_pkt->limit) { 302 return -1; 303 } 288 304 hdhomerun_pkt_write_u8(tx_pkt, HDHOMERUN_TAG_GETSET_NAME); 289 305 hdhomerun_pkt_write_var_length(tx_pkt, name_len); 290 306 hdhomerun_pkt_write_mem(tx_pkt, (const void *)name, name_len); 291 307 292 308 if (value) { 293 309 int value_len = (int)strlen(value) + 1; 310 if (tx_pkt->end + 3 + value_len > tx_pkt->limit) { 311 return -1; 312 } 294 313 hdhomerun_pkt_write_u8(tx_pkt, HDHOMERUN_TAG_GETSET_VALUE); 295 314 hdhomerun_pkt_write_var_length(tx_pkt, value_len); 296 315 hdhomerun_pkt_write_mem(tx_pkt, (const void *)value, value_len); 297 316 } 298 317 318 if (lockkey != 0) { 319 if (tx_pkt->end + 6 > tx_pkt->limit) { 320 return -1; 321 } 322 hdhomerun_pkt_write_u8(tx_pkt, HDHOMERUN_TAG_GETSET_LOCKKEY); 323 hdhomerun_pkt_write_var_length(tx_pkt, 4); 324 hdhomerun_pkt_write_u32(tx_pkt, lockkey); 325 } 326 299 327 /* Send/Recv. */ 300 328 if (hdhomerun_control_send_recv_internal(cs, tx_pkt, rx_pkt, HDHOMERUN_TYPE_GETSET_REQ, HDHOMERUN_CONTROL_RECV_TIMEOUT) < 0) { 301 329 return -1; … … static int hdhomerun_control_get_set(str 341 369 342 370 int hdhomerun_control_get(struct hdhomerun_control_sock_t *cs, const char *name, char **pvalue, char **perror) 343 371 { 344 return hdhomerun_control_get_set(cs, name, NULL, pvalue, perror);372 return hdhomerun_control_get_set(cs, name, NULL, 0, pvalue, perror); 345 373 } 346 374 347 375 int hdhomerun_control_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror) 348 376 { 349 return hdhomerun_control_get_set(cs, name, value, pvalue, perror); 377 return hdhomerun_control_get_set(cs, name, value, 0, pvalue, perror); 378 } 379 380 int hdhomerun_control_set_with_lockkey(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror) 381 { 382 return hdhomerun_control_get_set(cs, name, value, lockkey, pvalue, perror); 350 383 } 351 384 352 385 int hdhomerun_control_upgrade(struct hdhomerun_control_sock_t *cs, FILE *upgrade_file) -
mythtv/libs/libmythhdhomerun/hdhomerun_control.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_control.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_control.h
1 1 /* 2 2 * hdhomerun_control.h 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 #ifdef __cplusplus 20 33 extern "C" { … … extern LIBTYPE int hdhomerun_control_sen 83 96 */ 84 97 extern LIBTYPE int hdhomerun_control_get(struct hdhomerun_control_sock_t *cs, const char *name, char **pvalue, char **perror); 85 98 extern LIBTYPE int hdhomerun_control_set(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, char **pvalue, char **perror); 99 extern LIBTYPE int hdhomerun_control_set_with_lockkey(struct hdhomerun_control_sock_t *cs, const char *name, const char *value, uint32_t lockkey, char **pvalue, char **perror); 86 100 87 101 /* 88 102 * Upload new firmware to the device. -
mythtv/libs/libmythhdhomerun/hdhomerun_debug.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_debug.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_debug.c
1 1 /* 2 2 * hdhomerun_debug.c 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 /* … … void hdhomerun_debug_vprintf(struct hdho 240 253 char *end = message->buffer + sizeof(message->buffer) - 2; 241 254 *end = 0; 242 255 243 time_t t = time(NULL); 244 strftime(ptr, end - ptr, "%Y%m%d-%H:%M:%S ", localtime(&t)); 245 ptr = strchr(ptr, 0); 256 /* 257 * Timestamp. 258 */ 259 time_t current_time = time(NULL); 260 ptr += strftime(ptr, end - ptr, "%Y%m%d-%H:%M:%S ", localtime(¤t_time)); 261 if (ptr > end) { 262 ptr = end; 263 } 246 264 265 /* 266 * Debug prefix. 267 */ 247 268 pthread_mutex_lock(&dbg->print_lock); 248 269 249 270 if (dbg->prefix) { 250 snprintf(ptr, end - ptr, "%s ", dbg->prefix); 251 ptr = strchr(ptr, 0); 271 int len = snprintf(ptr, end - ptr, "%s ", dbg->prefix); 272 len = (len <= 0) ? 0 : len; 273 ptr += len; 274 if (ptr > end) { 275 ptr = end; 276 } 252 277 } 253 278 254 279 pthread_mutex_unlock(&dbg->print_lock); 255 280 256 vsnprintf(ptr, end - ptr, fmt, args); 257 258 ptr = strchr(ptr, 0) - 1; 259 if (*ptr++ != '\n') { 260 strcpy(ptr, "\n"); 261 } 262 281 /* 282 * Message text. 283 */ 284 int len = vsnprintf(ptr, end - ptr, fmt, args); 285 len = (len < 0) ? 0 : len; /* len does not include null */ 286 ptr += len; 287 if (ptr > end) { 288 ptr = end; 289 } 290 291 /* 292 * Force newline. 293 */ 294 if ((ptr[-1] != '\n') && (ptr + 1 <= end)) { 295 *ptr++ = '\n'; 296 } 297 298 /* 299 * Force NULL. 300 */ 301 if (ptr + 1 > end) { 302 ptr = end - 1; 303 } 304 *ptr++ = 0; 305 306 /* 307 * Enqueue. 308 */ 263 309 pthread_mutex_lock(&dbg->queue_lock); 264 310 265 311 message->prev = NULL; -
mythtv/libs/libmythhdhomerun/hdhomerun_debug.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_debug.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_debug.h
1 1 /* 2 2 * hdhomerun_debug.h 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 /* -
mythtv/libs/libmythhdhomerun/hdhomerun_device.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_device.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_device.c
1 1 /* 2 2 * hdhomerun_device.c 3 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" … … struct hdhomerun_device_t { 25 38 struct hdhomerun_debug_t *dbg; 26 39 struct hdhomerun_channelscan_t *scan; 27 40 unsigned int tuner; 41 uint32_t lockkey; 28 42 char name[32]; 29 43 char model[32]; 30 44 }; … … static uint32_t hdhomerun_device_get_sta 275 289 return (uint32_t)value; 276 290 } 277 291 292 static bool_t hdhomerun_device_get_tuner_status_lock_is_bcast(struct hdhomerun_tuner_status_t *status) 293 { 294 if (strcmp(status->lock_str, "8vsb") == 0) { 295 return TRUE; 296 } 297 if (strncmp(status->lock_str, "t8", 2) == 0) { 298 return TRUE; 299 } 300 if (strncmp(status->lock_str, "t7", 2) == 0) { 301 return TRUE; 302 } 303 if (strncmp(status->lock_str, "t6", 2) == 0) { 304 return TRUE; 305 } 306 307 return FALSE; 308 } 309 278 310 uint32_t hdhomerun_device_get_tuner_status_ss_color(struct hdhomerun_tuner_status_t *status) 279 311 { 280 312 unsigned int ss_yellow_min; 281 313 unsigned int ss_green_min; 282 314 283 if (strstr(status->lock_str, "8vsb")) { 315 if (!status->lock_supported) { 316 return HDHOMERUN_STATUS_COLOR_NEUTRAL; 317 } 318 319 if (hdhomerun_device_get_tuner_status_lock_is_bcast(status)) { 284 320 ss_yellow_min = 50; /* -30dBmV */ 285 321 ss_green_min = 75; /* -15dBmV */ 286 } else if (strstr(status->lock_str, "qam64")) { 287 ss_yellow_min = 80; /* -12dBmV */ 288 ss_green_min = 90; /* -6dBmV */ 289 } else if (strstr(status->lock_str, "qam256")) { 322 } else { 290 323 ss_yellow_min = 80; /* -12dBmV */ 291 324 ss_green_min = 90; /* -6dBmV */ 292 } else {293 return HDHOMERUN_STATUS_COLOR_NEUTRAL;294 325 } 295 326 296 327 if (status->signal_strength >= ss_green_min) { … … uint32_t hdhomerun_device_get_tuner_stat 305 336 306 337 uint32_t hdhomerun_device_get_tuner_status_snq_color(struct hdhomerun_tuner_status_t *status) 307 338 { 308 if (status->signal_to_noise_quality >= 60) {339 if (status->signal_to_noise_quality >= 70) { 309 340 return HDHOMERUN_STATUS_COLOR_GREEN; 310 341 } 311 if (status->signal_to_noise_quality >= 40) {342 if (status->signal_to_noise_quality >= 50) { 312 343 return HDHOMERUN_STATUS_COLOR_YELLOW; 313 344 } 314 345 … … int hdhomerun_device_get_tuner_plotsampl 461 492 return 1; 462 493 } 463 494 495 int hdhomerun_device_get_tuner_lockkey_owner(struct hdhomerun_device_t *hd, char **powner) 496 { 497 char name[32]; 498 sprintf(name, "/tuner%u/lockkey", hd->tuner); 499 return hdhomerun_control_get(hd->cs, name, powner, NULL); 500 } 501 464 502 int hdhomerun_device_get_ir_target(struct hdhomerun_device_t *hd, char **ptarget) 465 503 { 466 504 return hdhomerun_control_get(hd->cs, "/ir/target", ptarget, NULL); … … int hdhomerun_device_set_tuner_channel(s 499 537 { 500 538 char name[32]; 501 539 sprintf(name, "/tuner%u/channel", hd->tuner); 502 return hdhomerun_control_set (hd->cs, name, channel, NULL, NULL);540 return hdhomerun_control_set_with_lockkey(hd->cs, name, channel, hd->lockkey, NULL, NULL); 503 541 } 504 542 505 543 int hdhomerun_device_set_tuner_channelmap(struct hdhomerun_device_t *hd, const char *channelmap) 506 544 { 507 545 char name[32]; 508 546 sprintf(name, "/tuner%u/channelmap", hd->tuner); 509 return hdhomerun_control_set (hd->cs, name, channelmap, NULL, NULL);547 return hdhomerun_control_set_with_lockkey(hd->cs, name, channelmap, hd->lockkey, NULL, NULL); 510 548 } 511 549 512 550 int hdhomerun_device_set_tuner_filter(struct hdhomerun_device_t *hd, const char *filter) 513 551 { 514 552 char name[32]; 515 553 sprintf(name, "/tuner%u/filter", hd->tuner); 516 return hdhomerun_control_set (hd->cs, name, filter, NULL, NULL);554 return hdhomerun_control_set_with_lockkey(hd->cs, name, filter, hd->lockkey, NULL, NULL); 517 555 } 518 556 519 557 static int hdhomerun_device_set_tuner_filter_by_array_append(char **pptr, char *end, uint16_t range_begin, uint16_t range_end) … … int hdhomerun_device_set_tuner_filter_by 578 616 /* Remove trailing space. */ 579 617 if (ptr > filter) { 580 618 ptr--; 581 *ptr = 0;582 619 } 620 *ptr = 0; 583 621 584 622 return hdhomerun_device_set_tuner_filter(hd, filter); 585 623 } … … int hdhomerun_device_set_tuner_program(s 588 626 { 589 627 char name[32]; 590 628 sprintf(name, "/tuner%u/program", hd->tuner); 591 return hdhomerun_control_set (hd->cs, name, program, NULL, NULL);629 return hdhomerun_control_set_with_lockkey(hd->cs, name, program, hd->lockkey, NULL, NULL); 592 630 } 593 631 594 632 int hdhomerun_device_set_tuner_target(struct hdhomerun_device_t *hd, const char *target) 595 633 { 596 634 char name[32]; 597 635 sprintf(name, "/tuner%u/target", hd->tuner); 598 return hdhomerun_control_set (hd->cs, name, target, NULL, NULL);636 return hdhomerun_control_set_with_lockkey(hd->cs, name, target, hd->lockkey, NULL, NULL); 599 637 } 600 638 601 639 int hdhomerun_device_set_tuner_target_to_local_protocol(struct hdhomerun_device_t *hd, const char *protocol) … … int hdhomerun_device_set_var(struct hdho 645 683 return hdhomerun_control_set(hd->cs, name, value, pvalue, perror); 646 684 } 647 685 686 int hdhomerun_device_tuner_lockkey_request(struct hdhomerun_device_t *hd) 687 { 688 uint32_t new_lockkey = (uint32_t)getcurrenttime(); 689 690 char name[32]; 691 sprintf(name, "/tuner%u/lockkey", hd->tuner); 692 693 char new_lockkey_str[64]; 694 sprintf(new_lockkey_str, "%u", (unsigned int)new_lockkey); 695 696 int ret = hdhomerun_control_set_with_lockkey(hd->cs, name, new_lockkey_str, hd->lockkey, NULL, NULL); 697 if (ret <= 0) { 698 hd->lockkey = 0; 699 return ret; 700 } 701 702 hd->lockkey = new_lockkey; 703 return ret; 704 } 705 706 int hdhomerun_device_tuner_lockkey_release(struct hdhomerun_device_t *hd) 707 { 708 if (hd->lockkey == 0) { 709 return 1; 710 } 711 712 char name[32]; 713 sprintf(name, "/tuner%u/lockkey", hd->tuner); 714 int ret = hdhomerun_control_set_with_lockkey(hd->cs, name, "none", hd->lockkey, NULL, NULL); 715 716 hd->lockkey = 0; 717 return ret; 718 } 719 648 720 int hdhomerun_device_wait_for_lock(struct hdhomerun_device_t *hd, struct hdhomerun_tuner_status_t *status) 649 721 { 650 722 /* Wait for up to 2.5 seconds for lock. */ … … void hdhomerun_device_stream_stop(struct 708 780 hdhomerun_device_set_tuner_target(hd, "none"); 709 781 } 710 782 711 int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, uint32_t channel_map, uint32_t options)783 int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, const char *channelmap) 712 784 { 713 785 if (hd->scan) { 714 786 channelscan_destroy(hd->scan); 715 787 } 716 788 717 hd->scan = channelscan_create(hd, channel _map, options);789 hd->scan = channelscan_create(hd, channelmap); 718 790 if (!hd->scan) { 719 791 return -1; 720 792 } … … const char *hdhomerun_device_get_model_s 787 859 return NULL; 788 860 } 789 861 if (ret == 0) { 790 strcpy(hd->model, "hdhomerun_atsc"); 791 return hd->model; 862 model_str = "hdhomerun_atsc"; 792 863 } 793 864 794 strcpy(hd->model, model_str); 795 return hd->model; 796 } 865 strncpy(hd->model, model_str, sizeof(hd->model) - 1); 866 hd->model[sizeof(hd->model) - 1] = 0; 797 867 798 uint32_t hdhomerun_device_model_channel_map_all(struct hdhomerun_device_t *hd) 799 { 800 return hdhomerun_device_model_channel_map_antenna(hd) | hdhomerun_device_model_channel_map_cable(hd); 801 } 802 803 uint32_t hdhomerun_device_model_channel_map_antenna(struct hdhomerun_device_t *hd) 804 { 805 const char *model = hdhomerun_device_get_model_str(hd); 806 if (!model) { 807 return 0; 808 } 809 810 if (strstr(model, "atsc")) { 811 return CHANNEL_MAP_US_BCAST; 812 } 813 814 if (strstr(model, "dvbt")) { 815 return CHANNEL_MAP_UK_BCAST | CHANNEL_MAP_NZ_BCAST; 816 } 817 818 return 0; 819 } 820 821 uint32_t hdhomerun_device_model_channel_map_cable(struct hdhomerun_device_t *hd) 822 { 823 const char *model = hdhomerun_device_get_model_str(hd); 824 if (!model) { 825 return 0; 826 } 827 828 if (strstr(model, "atsc")) { 829 return CHANNEL_MAP_US_CABLE | CHANNEL_MAP_US_HRC | CHANNEL_MAP_US_IRC; 830 } 831 832 return 0; 868 return hd->model; 833 869 } 834 870 835 871 int hdhomerun_device_upgrade(struct hdhomerun_device_t *hd, FILE *upgrade_file) 836 872 { 873 hdhomerun_control_set(hd->cs, "/tuner0/lockkey", "force", NULL, NULL); 837 874 hdhomerun_control_set(hd->cs, "/tuner0/channel", "none", NULL, NULL); 875 876 hdhomerun_control_set(hd->cs, "/tuner1/lockkey", "force", NULL, NULL); 838 877 hdhomerun_control_set(hd->cs, "/tuner1/channel", "none", NULL, NULL); 878 839 879 return hdhomerun_control_upgrade(hd->cs, upgrade_file); 840 880 } 841 881 -
mythtv/libs/libmythhdhomerun/hdhomerun_device.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_device.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_device.h
1 1 /* 2 2 * hdhomerun_device.h 3 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #ifdef __cplusplus … … extern "C" { 28 41 #define HDHOMERUN_STATUS_COLOR_NEUTRAL 0xFFFFFFFF 29 42 #define HDHOMERUN_STATUS_COLOR_RED 0xFFFF0000 30 43 #define HDHOMERUN_STATUS_COLOR_YELLOW 0xFFFFFF00 31 #define HDHOMERUN_STATUS_COLOR_GREEN 0xFF00 800044 #define HDHOMERUN_STATUS_COLOR_GREEN 0xFF00C000 32 45 33 46 #define HDHOMERUN_TARGET_PROTOCOL_UDP "udp" 34 47 #define HDHOMERUN_TARGET_PROTOCOL_RTP "rtp" … … extern LIBTYPE int hdhomerun_device_get_ 112 125 extern LIBTYPE int hdhomerun_device_get_tuner_program(struct hdhomerun_device_t *hd, char **pprogram); 113 126 extern LIBTYPE int hdhomerun_device_get_tuner_target(struct hdhomerun_device_t *hd, char **ptarget); 114 127 extern LIBTYPE int hdhomerun_device_get_tuner_plotsample(struct hdhomerun_device_t *hd, struct hdhomerun_plotsample_t **psamples, size_t *pcount); 128 extern LIBTYPE int hdhomerun_device_get_tuner_lockkey_owner(struct hdhomerun_device_t *hd, char **powner); 115 129 extern LIBTYPE int hdhomerun_device_get_ir_target(struct hdhomerun_device_t *hd, char **ptarget); 116 130 extern LIBTYPE int hdhomerun_device_get_lineup_location(struct hdhomerun_device_t *hd, char **plocation); 117 131 extern LIBTYPE int hdhomerun_device_get_version(struct hdhomerun_device_t *hd, char **pversion_str, uint32_t *pversion_num); … … extern LIBTYPE uint32_t hdhomerun_device 121 135 extern LIBTYPE uint32_t hdhomerun_device_get_tuner_status_seq_color(struct hdhomerun_tuner_status_t *status); 122 136 123 137 extern LIBTYPE const char *hdhomerun_device_get_model_str(struct hdhomerun_device_t *hd); 124 extern LIBTYPE uint32_t hdhomerun_device_model_channel_map_all(struct hdhomerun_device_t *hd);125 extern LIBTYPE uint32_t hdhomerun_device_model_channel_map_antenna(struct hdhomerun_device_t *hd);126 extern LIBTYPE uint32_t hdhomerun_device_model_channel_map_cable(struct hdhomerun_device_t *hd);127 138 128 139 /* 129 140 * Set operations. … … extern LIBTYPE int hdhomerun_device_get_ 166 177 extern LIBTYPE int hdhomerun_device_set_var(struct hdhomerun_device_t *hd, const char *name, const char *value, char **pvalue, char **perror); 167 178 168 179 /* 180 * Tuner locking. 181 * 182 * The hdhomerun_device_tuner_lockkey_request function is used to obtain a lock 183 * or to verify that the hdhomerun_device object still holds the lock. 184 * Returns 1 if the lock request was successful and the lock was obtained. 185 * Returns 0 if the lock request was rejected. 186 * Returns -1 if a communication error occurs. 187 * 188 * The hdhomerun_device_tuner_lockkey_release function is used to release a 189 * previously held lock. If locking is used then this function must be called 190 * before destroying the hdhomerun_device object. 191 */ 192 extern LIBTYPE int hdhomerun_device_tuner_lockkey_request(struct hdhomerun_device_t *hd); 193 extern LIBTYPE int hdhomerun_device_tuner_lockkey_release(struct hdhomerun_device_t *hd); 194 195 /* 169 196 * Wait for tuner lock after channel change. 170 197 * 171 198 * The hdhomerun_device_wait_for_lock function is used to detect/wait for a lock vs no lock indication … … extern LIBTYPE void hdhomerun_device_str 202 229 /* 203 230 * Channel scan API. 204 231 */ 205 extern LIBTYPE int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, uint32_t channel_map, uint32_t options);232 extern LIBTYPE int hdhomerun_device_channelscan_init(struct hdhomerun_device_t *hd, const char *channelmap); 206 233 extern LIBTYPE int hdhomerun_device_channelscan_advance(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result); 207 234 extern LIBTYPE int hdhomerun_device_channelscan_detect(struct hdhomerun_device_t *hd, struct hdhomerun_channelscan_result_t *result); 208 235 extern LIBTYPE uint8_t hdhomerun_device_channelscan_get_progress(struct hdhomerun_device_t *hd); -
mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.c
1 1 /* 2 2 * hdhomerun_dhcp.c 3 3 * 4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" -
mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_dhcp.h
1 1 /* 2 2 * hdhomerun_dhcp.h 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #ifdef __cplusplus -
mythtv/libs/libmythhdhomerun/hdhomerun_discover.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_discover.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_discover.c
1 1 /* 2 2 * hdhomerun_discover.c 3 3 * 4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" … … 23 36 #include <windows.h> 24 37 #include <iphlpapi.h> 25 38 #define USE_IPHLPAPI 1 39 #else 40 #include <net/if.h> 41 #include <sys/ioctl.h> 42 #ifndef _SIZEOF_ADDR_IFREQ 43 #define _SIZEOF_ADDR_IFREQ(x) sizeof(x) 26 44 #endif 27 28 #include <sys/param.h> // Defines BSD on FreeBSD and Mac OS X29 30 #if defined(__linux__) || defined(__APPLE__) || defined(BSD)31 #include <ifaddrs.h>32 #define USE_IFADDRS 133 #include <sys/select.h>34 45 #endif 35 46 36 47 #define HDHOMERUN_DISOCVER_MAX_SOCK_COUNT 16 37 48 38 49 struct hdhomerun_discover_sock_t { 39 50 int sock; 40 uint32_t broadcast_ip; 51 uint32_t local_ip; 52 uint32_t subnet_mask; 41 53 }; 42 54 43 55 struct hdhomerun_discover_t { … … struct hdhomerun_discover_t { 47 59 struct hdhomerun_pkt_t rx_pkt; 48 60 }; 49 61 50 static void hdhomerun_discover_sock_create(struct hdhomerun_discover_t *ds, uint32_t local_ip, uint32_tmask)62 static bool_t hdhomerun_discover_sock_create(struct hdhomerun_discover_t *ds, uint32_t local_ip, uint32_t subnet_mask) 51 63 { 52 64 if (ds->sock_count >= HDHOMERUN_DISOCVER_MAX_SOCK_COUNT) { 53 return ;65 return FALSE; 54 66 } 55 67 56 68 /* Create socket. */ 57 69 int sock = (int)socket(AF_INET, SOCK_DGRAM, 0); 58 70 if (sock == -1) { 59 return ;71 return FALSE; 60 72 } 61 73 62 74 /* Set timeouts. */ … … static void hdhomerun_discover_sock_crea 75 87 sock_addr.sin_port = htons(0); 76 88 if (bind(sock, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) != 0) { 77 89 close(sock); 78 return ;90 return FALSE; 79 91 } 80 92 81 93 /* Write sock entry. */ 82 94 struct hdhomerun_discover_sock_t *dss = &ds->socks[ds->sock_count++]; 83 95 dss->sock = sock; 84 dss->broadcast_ip = local_ip | ~mask; 96 dss->local_ip = local_ip; 97 dss->subnet_mask = subnet_mask; 98 99 return TRUE; 85 100 } 86 101 87 102 #if defined(USE_IPHLPAPI) … … static void hdhomerun_discover_sock_dete 125 140 126 141 free(pAdapterInfo); 127 142 } 128 #endif129 143 130 #if defined(USE_IFADDRS) 144 #else 145 131 146 static void hdhomerun_discover_sock_detect(struct hdhomerun_discover_t *ds) 132 147 { 133 struct ifaddrs *ifap; 134 if (getifaddrs(&ifap) < 0) { 148 int fd = socket(AF_INET, SOCK_DGRAM, 0); 149 if (fd == -1) { 150 return; 151 } 152 153 struct ifconf ifc; 154 uint8_t buf[8192]; 155 ifc.ifc_len = sizeof(buf); 156 ifc.ifc_buf = (char *)buf; 157 158 memset(buf, 0, sizeof(buf)); 159 160 if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) { 161 close(fd); 135 162 return; 136 163 } 137 164 138 struct ifaddrs *p = ifap; 139 while (p) { 140 struct sockaddr_in *addr_in = (struct sockaddr_in *)p->ifa_addr; 141 struct sockaddr_in *mask_in = (struct sockaddr_in *)p->ifa_netmask; 142 if (!addr_in || !mask_in) { 143 p = p->ifa_next; 165 uint8_t *ptr = (uint8_t *)ifc.ifc_req; 166 uint8_t *end = (uint8_t *)&ifc.ifc_buf[ifc.ifc_len]; 167 168 while (ptr <= end) { 169 struct ifreq *ifr = (struct ifreq *)ptr; 170 ptr += _SIZEOF_ADDR_IFREQ(*ifr); 171 172 if (ioctl(fd, SIOCGIFADDR, ifr) != 0) { 144 173 continue; 145 174 } 146 175 struct sockaddr_in *addr_in = (struct sockaddr_in *)&(ifr->ifr_addr); 147 176 uint32_t local_ip = ntohl(addr_in->sin_addr.s_addr); 148 uint32_t mask = ntohl(mask_in->sin_addr.s_addr);149 177 if (local_ip == 0) { 150 p = p->ifa_next;151 178 continue; 152 179 } 153 180 181 if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) { 182 continue; 183 } 184 struct sockaddr_in *mask_in = (struct sockaddr_in *)&(ifr->ifr_addr); 185 uint32_t mask = ntohl(mask_in->sin_addr.s_addr); 186 154 187 hdhomerun_discover_sock_create(ds, local_ip, mask); 155 p = p->ifa_next;156 188 } 157 158 freeifaddrs(ifap);159 }160 #endif161 162 163 #if !defined(USE_IPHLPAPI) && !defined(USE_IFADDRS)164 static void hdhomerun_discover_sock_detect(struct hdhomerun_discover_t *ds)165 {166 /* do nothing */167 189 } 168 190 #endif 169 191 … … static struct hdhomerun_discover_t *hdho 174 196 return NULL; 175 197 } 176 198 177 /* Detect & create sockets. */ 178 hdhomerun_discover_sock_detect(ds); 179 if (ds->sock_count == 0) { 180 hdhomerun_discover_sock_create(ds, 0, 0); 181 if (ds->sock_count == 0) { 182 free(ds); 183 return NULL; 184 } 199 /* Create a routable socket. */ 200 if (!hdhomerun_discover_sock_create(ds, 0, 0)) { 201 free(ds); 202 return NULL; 185 203 } 186 204 205 /* Detect & create local sockets. */ 206 hdhomerun_discover_sock_detect(ds); 207 187 208 /* Success. */ 188 209 return ds; 189 210 } … … static void hdhomerun_discover_destroy(s 201 222 202 223 static bool_t hdhomerun_discover_send_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, uint32_t target_ip, uint32_t device_type, uint32_t device_id) 203 224 { 204 if (target_ip == 0) {205 target_ip = dss->broadcast_ip;206 }207 208 225 struct hdhomerun_pkt_t *tx_pkt = &ds->tx_pkt; 209 226 hdhomerun_pkt_reset(tx_pkt); 210 227 … … static bool_t hdhomerun_discover_send_in 230 247 return TRUE; 231 248 } 232 249 233 static bool_t hdhomerun_discover_send (struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id)250 static bool_t hdhomerun_discover_send_wildcard_ip(struct hdhomerun_discover_t *ds, uint32_t device_type, uint32_t device_id) 234 251 { 235 252 bool_t result = FALSE; 236 253 254 /* 255 * Send subnet broadcast using each local ip socket. 256 * This will work with multiple separate 169.254.x.x interfaces. 257 */ 237 258 unsigned int i; 238 for (i = 0; i < ds->sock_count; i++) { 259 for (i = 1; i < ds->sock_count; i++) { 260 struct hdhomerun_discover_sock_t *dss = &ds->socks[i]; 261 uint32_t target_ip = dss->local_ip | ~dss->subnet_mask; 262 result |= hdhomerun_discover_send_internal(ds, dss, target_ip, device_type, device_id); 263 } 264 265 /* 266 * If no local ip sockets then fall back to sending a global broadcast letting the OS choose the interface. 267 */ 268 if (!result) { 269 struct hdhomerun_discover_sock_t *dss = &ds->socks[0]; 270 result = hdhomerun_discover_send_internal(ds, dss, 0xFFFFFFFF, device_type, device_id); 271 } 272 273 return result; 274 } 275 276 static bool_t hdhomerun_discover_send_target_ip(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id) 277 { 278 bool_t result = FALSE; 279 280 /* 281 * Send targeted packet from any local ip that is in the same subnet. 282 * This will work with multiple separate 169.254.x.x interfaces. 283 */ 284 unsigned int i; 285 for (i = 1; i < ds->sock_count; i++) { 239 286 struct hdhomerun_discover_sock_t *dss = &ds->socks[i]; 287 if ((target_ip & dss->subnet_mask) != (dss->local_ip & dss->subnet_mask)) { 288 continue; 289 } 290 240 291 result |= hdhomerun_discover_send_internal(ds, dss, target_ip, device_type, device_id); 241 292 } 242 293 294 /* 295 * If target IP does not match a local subnet then fall back to letting the OS choose the gateway interface. 296 */ 297 if (!result) { 298 struct hdhomerun_discover_sock_t *dss = &ds->socks[0]; 299 result = hdhomerun_discover_send_internal(ds, dss, target_ip, device_type, device_id); 300 } 301 243 302 return result; 244 303 } 245 304 305 static bool_t hdhomerun_discover_send(struct hdhomerun_discover_t *ds, uint32_t target_ip, uint32_t device_type, uint32_t device_id) 306 { 307 if (target_ip != 0) { 308 return hdhomerun_discover_send_target_ip(ds, target_ip, device_type, device_id); 309 } 310 311 return hdhomerun_discover_send_wildcard_ip(ds, device_type, device_id); 312 } 313 246 314 static int hdhomerun_discover_recv_internal(struct hdhomerun_discover_t *ds, struct hdhomerun_discover_sock_t *dss, struct hdhomerun_discover_device_t *result) 247 315 { 248 316 struct hdhomerun_pkt_t *rx_pkt = &ds->rx_pkt; -
mythtv/libs/libmythhdhomerun/hdhomerun_discover.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_discover.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_discover.h
1 1 /* 2 2 * hdhomerun_discover.h 3 3 * 4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2007 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 #ifdef __cplusplus 20 33 extern "C" { -
mythtv/libs/libmythhdhomerun/hdhomerun_os.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_os.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_os.h
1 1 /* 2 2 * hdhomerun_os.h 3 3 * 4 * Copyright © 2006Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #if defined(_WIN32) || defined(_WIN64) … … 22 35 #endif 23 36 24 37 #if defined(__WINDOWS__) 25 #define _WINSOCKAPI_ 26 #include <windows.h> 27 #include <winsock2.h> 28 #include <ws2tcpip.h> 29 #include <wspiapi.h> 30 #include <stdlib.h> 31 #include <stdio.h> 32 #include <stdarg.h> 33 #include <string.h> 34 #include <signal.h> 35 #include <time.h> 36 #include <sys/types.h> 37 #include <sys/timeb.h> 38 39 #else /* !defined(__WINDOWS__) */ 40 #define _FILE_OFFSET_BITS 64 41 #include <stdlib.h> 42 #include <stdio.h> 43 #include <stdarg.h> 44 #include <string.h> 45 #include <unistd.h> 46 #include <errno.h> 47 #include <fcntl.h> 48 #include <sys/types.h> 49 #include <sys/socket.h> 50 #include <sys/time.h> 51 #include <sys/timeb.h> 52 #include <sys/wait.h> 53 #include <sys/signal.h> 54 #include <netinet/in.h> 55 #include <arpa/inet.h> 56 #include <netdb.h> 57 #include <pthread.h> 38 #include "hdhomerun_os_windows.h" 39 #else 40 #include "hdhomerun_os_posix.h" 58 41 #endif 59 42 60 43 #if !defined(TRUE) … … 64 47 #if !defined(FALSE) 65 48 #define FALSE 0 66 49 #endif 67 68 #if defined(__WINDOWS__)69 70 #define LIBTYPE71 72 #if defined(DLL_IMPORT)73 #define LIBTYPE __declspec( dllexport )74 #endif75 76 #if defined(DLL_EXPORT)77 #define LIBTYPE __declspec( dllimport )78 #endif79 80 typedef int bool_t;81 typedef signed __int8 int8_t;82 typedef signed __int16 int16_t;83 typedef signed __int32 int32_t;84 typedef signed __int64 int64_t;85 typedef unsigned __int8 uint8_t;86 typedef unsigned __int16 uint16_t;87 typedef unsigned __int32 uint32_t;88 typedef unsigned __int64 uint64_t;89 typedef HANDLE pthread_t;90 typedef HANDLE pthread_mutex_t;91 92 #define socklen_t int93 #define close closesocket94 #define sock_getlasterror WSAGetLastError()95 #define sock_getlasterror_socktimeout (WSAGetLastError() == WSAETIMEDOUT)96 #define va_copy(x, y) x = y97 #define atoll _atoi6498 #define strdup _strdup99 #define strcasecmp _stricmp100 #define snprintf _snprintf101 #define fseeko _fseeki64102 #define ftello _ftelli64103 #define usleep(us) Sleep((us)/1000)104 #define sleep(sec) Sleep((sec)*1000)105 #define THREAD_FUNC_PREFIX DWORD WINAPI106 #define SIGPIPE SIGABRT107 108 static inline uint64_t getcurrenttime(void)109 {110 struct timeb tb;111 ftime(&tb);112 return ((uint64_t)tb.time * 1000) + tb.millitm;113 }114 115 static inline int setsocktimeout(int s, int level, int optname, uint64_t timeout)116 {117 int t = (int)timeout;118 return setsockopt(s, level, optname, (char *)&t, sizeof(t));119 }120 121 static inline int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg)122 {123 *tid = CreateThread(NULL, 0, start, arg, 0, NULL);124 if (!*tid) {125 return (int)GetLastError();126 }127 return 0;128 }129 130 static inline int pthread_join(pthread_t tid, void **value_ptr)131 {132 while (1) {133 DWORD ExitCode = 0;134 if (!GetExitCodeThread(tid, &ExitCode)) {135 return (int)GetLastError();136 }137 if (ExitCode != STILL_ACTIVE) {138 return 0;139 }140 }141 }142 143 extern inline void pthread_mutex_init(pthread_mutex_t *mutex, void *attr)144 {145 *mutex = CreateMutex(NULL, FALSE, NULL);146 }147 148 extern inline void pthread_mutex_lock(pthread_mutex_t *mutex)149 {150 WaitForSingleObject(*mutex, INFINITE);151 }152 153 extern inline void pthread_mutex_unlock(pthread_mutex_t *mutex)154 {155 ReleaseMutex(*mutex);156 }157 158 #else /* !defined(__WINDOWS__) */159 160 typedef int bool_t;161 162 #define LIBTYPE163 #define sock_getlasterror errno164 #define sock_getlasterror_socktimeout (errno == EAGAIN)165 #define THREAD_FUNC_PREFIX void *166 167 static inline uint64_t getcurrenttime(void)168 {169 struct timeval t;170 gettimeofday(&t, NULL);171 return ((uint64_t)t.tv_sec * 1000) + (t.tv_usec / 1000);172 }173 174 static inline int setsocktimeout(int s, int level, int optname, uint64_t timeout)175 {176 struct timeval t;177 t.tv_sec = timeout / 1000;178 t.tv_usec = (timeout % 1000) * 1000;179 return setsockopt(s, level, optname, (char *)&t, sizeof(t));180 }181 182 #endif -
mythtv/libs/libmythhdhomerun/hdhomerun_os_posix.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_os_posix.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_os_posix.h
1 /* 2 * hdhomerun_os_posix.h 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 3 of the License, or (at your option) any later version. 10 * 11 * This library 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 GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 31 */ 32 33 #define _FILE_OFFSET_BITS 64 34 #include <stdlib.h> 35 #include <stdio.h> 36 #include <stdarg.h> 37 #include <string.h> 38 #include <unistd.h> 39 #include <errno.h> 40 #include <fcntl.h> 41 #include <sys/types.h> 42 #include <sys/socket.h> 43 #include <sys/time.h> 44 #include <sys/timeb.h> 45 #include <sys/wait.h> 46 #include <sys/signal.h> 47 #include <netinet/in.h> 48 #include <arpa/inet.h> 49 #include <netdb.h> 50 #include <pthread.h> 51 52 typedef int bool_t; 53 54 #define LIBTYPE 55 #define sock_getlasterror errno 56 #define sock_getlasterror_socktimeout (errno == EAGAIN) 57 #define console_vprintf vprintf 58 #define console_printf printf 59 #define THREAD_FUNC_PREFIX void * 60 61 static inline uint64_t getcurrenttime(void) 62 { 63 struct timeval t; 64 gettimeofday(&t, NULL); 65 return ((uint64_t)t.tv_sec * 1000) + (t.tv_usec / 1000); 66 } 67 68 static inline int setsocktimeout(int s, int level, int optname, uint64_t timeout) 69 { 70 struct timeval t; 71 t.tv_sec = timeout / 1000; 72 t.tv_usec = (timeout % 1000) * 1000; 73 return setsockopt(s, level, optname, (char *)&t, sizeof(t)); 74 } -
mythtv/libs/libmythhdhomerun/hdhomerun_os_windows.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_os_windows.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_os_windows.h
1 /* 2 * hdhomerun_os_windows.h 3 * 4 * Copyright © 2006-2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 3 of the License, or (at your option) any later version. 10 * 11 * This library 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 GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 31 */ 32 33 #define _WINSOCKAPI_ 34 #include <windows.h> 35 #include <winsock2.h> 36 #include <ws2tcpip.h> 37 #include <wspiapi.h> 38 #include <stdlib.h> 39 #include <stdio.h> 40 #include <stdarg.h> 41 #include <string.h> 42 #include <signal.h> 43 #include <time.h> 44 #include <sys/types.h> 45 #include <sys/timeb.h> 46 47 #if defined(DLL_IMPORT) 48 #define LIBTYPE __declspec( dllexport ) 49 #elif defined(DLL_EXPORT) 50 #define LIBTYPE __declspec( dllimport ) 51 #else 52 #define LIBTYPE 53 #endif 54 55 typedef int bool_t; 56 typedef signed __int8 int8_t; 57 typedef signed __int16 int16_t; 58 typedef signed __int32 int32_t; 59 typedef signed __int64 int64_t; 60 typedef unsigned __int8 uint8_t; 61 typedef unsigned __int16 uint16_t; 62 typedef unsigned __int32 uint32_t; 63 typedef unsigned __int64 uint64_t; 64 typedef HANDLE pthread_t; 65 typedef HANDLE pthread_mutex_t; 66 67 #define socklen_t int 68 #define close closesocket 69 #define sock_getlasterror WSAGetLastError() 70 #define sock_getlasterror_socktimeout (WSAGetLastError() == WSAETIMEDOUT) 71 #define va_copy(x, y) x = y 72 #define atoll _atoi64 73 #define strdup _strdup 74 #define strcasecmp _stricmp 75 #define snprintf _snprintf 76 #define fseeko _fseeki64 77 #define ftello _ftelli64 78 #define THREAD_FUNC_PREFIX DWORD WINAPI 79 #define SIGPIPE SIGABRT 80 81 static inline int usleep(unsigned int us) 82 { 83 Sleep((us)/1000); 84 return 0; 85 } 86 87 static inline int sleep(unsigned int sec) 88 { 89 Sleep((sec)*1000); 90 return 0; 91 } 92 93 static inline uint64_t getcurrenttime(void) 94 { 95 struct timeb tb; 96 ftime(&tb); 97 return ((uint64_t)tb.time * 1000) + tb.millitm; 98 } 99 100 static inline int setsocktimeout(int s, int level, int optname, uint64_t timeout) 101 { 102 int t = (int)timeout; 103 return setsockopt(s, level, optname, (char *)&t, sizeof(t)); 104 } 105 106 static inline int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg) 107 { 108 *tid = CreateThread(NULL, 0, start, arg, 0, NULL); 109 if (!*tid) { 110 return (int)GetLastError(); 111 } 112 return 0; 113 } 114 115 static inline int pthread_join(pthread_t tid, void **value_ptr) 116 { 117 while (1) { 118 DWORD ExitCode = 0; 119 if (!GetExitCodeThread(tid, &ExitCode)) { 120 return (int)GetLastError(); 121 } 122 if (ExitCode != STILL_ACTIVE) { 123 return 0; 124 } 125 } 126 } 127 128 static inline void pthread_mutex_init(pthread_mutex_t *mutex, void *attr) 129 { 130 *mutex = CreateMutex(NULL, FALSE, NULL); 131 } 132 133 static inline void pthread_mutex_lock(pthread_mutex_t *mutex) 134 { 135 WaitForSingleObject(*mutex, INFINITE); 136 } 137 138 static inline void pthread_mutex_unlock(pthread_mutex_t *mutex) 139 { 140 ReleaseMutex(*mutex); 141 } 142 143 /* 144 * The console output format should be set to UTF-8, however in XP and Vista this breaks batch file processing. 145 * Attempting to restore on exit fails to restore if the program is terminated by the user. 146 * Solution - set the output format each printf. 147 */ 148 static inline void console_vprintf(const char *fmt, va_list ap) 149 { 150 UINT cp = GetConsoleOutputCP(); 151 SetConsoleOutputCP(CP_UTF8); 152 vprintf(fmt, ap); 153 SetConsoleOutputCP(cp); 154 } 155 156 static inline void console_printf(const char *fmt, ...) 157 { 158 va_list ap; 159 va_start(ap, fmt); 160 console_vprintf(fmt, ap); 161 va_end(ap); 162 } -
mythtv/libs/libmythhdhomerun/hdhomerun_pkt.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_pkt.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_pkt.c
1 1 /* 2 2 * hdhomerun_pkt.c 3 3 * 4 * Copyright © 2005-2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2005-2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" … … void hdhomerun_pkt_destroy(struct hdhome 38 51 39 52 void hdhomerun_pkt_reset(struct hdhomerun_pkt_t *pkt) 40 53 { 41 pkt->limit = pkt->buffer + sizeof(pkt->buffer) ;54 pkt->limit = pkt->buffer + sizeof(pkt->buffer) - 4; 42 55 pkt->start = pkt->buffer + 1024; 43 56 pkt->end = pkt->start; 44 57 pkt->pos = pkt->start; -
mythtv/libs/libmythhdhomerun/hdhomerun_pkt.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_pkt.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_pkt.h
1 1 /* 2 2 * hdhomerun_pkt.h 3 3 * 4 * Copyright © 2005-2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2005-2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 #ifdef __cplusplus 20 33 extern "C" { … … extern "C" { 109 122 #define HDHOMERUN_DISCOVER_UDP_PORT 65001 110 123 #define HDHOMERUN_CONTROL_TCP_PORT 65001 111 124 125 #define HDHOMERUN_MAX_PACKET_SIZE 1460 126 #define HDHOMERUN_MAX_PAYLOAD_SIZE 1452 127 112 128 #define HDHOMERUN_TYPE_DISCOVER_REQ 0x0002 113 129 #define HDHOMERUN_TYPE_DISCOVER_RPY 0x0003 114 130 #define HDHOMERUN_TYPE_GETSET_REQ 0x0004 … … extern "C" { 120 136 #define HDHOMERUN_TAG_DEVICE_ID 0x02 121 137 #define HDHOMERUN_TAG_GETSET_NAME 0x03 122 138 #define HDHOMERUN_TAG_GETSET_VALUE 0x04 139 #define HDHOMERUN_TAG_GETSET_LOCKKEY 0x15 123 140 #define HDHOMERUN_TAG_ERROR_MESSAGE 0x05 124 141 125 142 #define HDHOMERUN_DEVICE_TYPE_WILDCARD 0xFFFFFFFF -
mythtv/libs/libmythhdhomerun/hdhomerun_types.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_types.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_types.h
1 1 /* 2 2 * hdhomerun_types.h 3 3 * 4 * Copyright © 2008 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2008 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 struct hdhomerun_device_t; … … struct hdhomerun_channelscan_program_t { 38 51 uint16_t virtual_major; 39 52 uint16_t virtual_minor; 40 53 uint16_t type; 41 char name[ 8];54 char name[32]; 42 55 }; 43 56 44 57 #define HDHOMERUN_CHANNELSCAN_MAX_PROGRAM_COUNT 64 45 58 46 59 struct hdhomerun_channelscan_result_t { 47 60 char channel_str[64]; 48 uint32_t channel _map;61 uint32_t channelmap; 49 62 uint32_t frequency; 50 63 struct hdhomerun_tuner_status_t status; 51 64 int program_count; -
mythtv/libs/libmythhdhomerun/hdhomerun_video.c
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_video.c myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_video.c
1 1 /* 2 2 * hdhomerun_video.c 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 20 33 #include "hdhomerun.h" 21 34 22 35 struct hdhomerun_video_sock_t { 36 pthread_mutex_t lock; 23 37 uint8_t *buffer; 24 38 size_t buffer_size; 25 39 volatile size_t head; … … struct hdhomerun_video_sock_t { 28 42 volatile bool_t terminate; 29 43 pthread_t thread; 30 44 int sock; 45 uint32_t rtp_sequence; 31 46 struct hdhomerun_debug_t *dbg; 32 47 volatile uint32_t packet_count; 33 48 volatile uint32_t transport_error_count; … … struct hdhomerun_video_sock_t { 35 50 volatile uint32_t sequence_error_count; 36 51 volatile uint32_t overflow_error_count; 37 52 volatile uint8_t sequence[0x2000]; 38 uint32_t rtp_sequence;39 53 }; 40 54 41 55 static THREAD_FUNC_PREFIX hdhomerun_video_thread_execute(void *arg); … … struct hdhomerun_video_sock_t *hdhomerun 84 98 return NULL; 85 99 } 86 100 101 pthread_mutex_init(&vs->lock, NULL); 102 87 103 /* Reset sequence tracking. */ 88 104 hdhomerun_video_flush(vs); 89 105 … … static void hdhomerun_video_parse_rtp(st 210 226 211 227 /* restart pid sequence check */ 212 228 /* can't use memset bcs sequence is volatile */ 213 229 int i; 214 230 for (i = 0; i < sizeof(vs->sequence) / sizeof(uint8_t) ; i++) 215 231 vs->sequence[i] = 0xFF; 216 232 } … … static THREAD_FUNC_PREFIX hdhomerun_vide 250 266 return NULL; 251 267 } 252 268 269 pthread_mutex_lock(&vs->lock); 270 253 271 /* Store in ring buffer. */ 254 272 size_t head = vs->head; 255 273 uint8_t *ptr = vs->buffer + head; … … static THREAD_FUNC_PREFIX hdhomerun_vide 274 292 /* Check for buffer overflow. */ 275 293 if (head == vs->tail) { 276 294 vs->overflow_error_count++; 295 pthread_mutex_unlock(&vs->lock); 277 296 continue; 278 297 } 279 298 280 299 /* Atomic update. */ 281 300 vs->head = head; 301 302 pthread_mutex_unlock(&vs->lock); 282 303 } 283 304 284 305 return NULL; … … static THREAD_FUNC_PREFIX hdhomerun_vide 286 307 287 308 uint8_t *hdhomerun_video_recv(struct hdhomerun_video_sock_t *vs, size_t max_size, size_t *pactual_size) 288 309 { 310 pthread_mutex_lock(&vs->lock); 311 289 312 size_t head = vs->head; 290 313 size_t tail = vs->tail; 291 314 … … uint8_t *hdhomerun_video_recv(struct hdh 302 325 if (head == tail) { 303 326 vs->advance = 0; 304 327 *pactual_size = 0; 328 pthread_mutex_unlock(&vs->lock); 305 329 return NULL; 306 330 } 307 331 … … uint8_t *hdhomerun_video_recv(struct hdh 309 333 if (size == 0) { 310 334 vs->advance = 0; 311 335 *pactual_size = 0; 336 pthread_mutex_unlock(&vs->lock); 312 337 return NULL; 313 338 } 314 339 … … uint8_t *hdhomerun_video_recv(struct hdh 323 348 } 324 349 vs->advance = size; 325 350 *pactual_size = size; 326 return vs->buffer + tail; 351 uint8_t *result = vs->buffer + tail; 352 353 pthread_mutex_unlock(&vs->lock); 354 return result; 327 355 } 328 356 329 357 void hdhomerun_video_flush(struct hdhomerun_video_sock_t *vs) 330 358 { 331 /* Atomic update of tail. */ 359 pthread_mutex_lock(&vs->lock); 360 332 361 vs->tail = vs->head; 333 362 vs->advance = 0; 334 363 335 364 /* can't use memset bcs sequence is volatile */ 336 365 int i; 337 366 for (i = 0; i < sizeof(vs->sequence) / sizeof(uint8_t) ; i++) 338 367 vs->sequence[i] = 0xFF; 339 368 … … void hdhomerun_video_flush(struct hdhome 344 373 vs->network_error_count = 0; 345 374 vs->sequence_error_count = 0; 346 375 vs->overflow_error_count = 0; 376 377 pthread_mutex_unlock(&vs->lock); 347 378 } 348 379 349 380 void hdhomerun_video_debug_print_stats(struct hdhomerun_video_sock_t *vs) 350 381 { 351 hdhomerun_debug_printf(vs->dbg, "video sock: pkt=%ld net=%ld te=%ld miss=%ld drop=%ld\n", vs->packet_count, vs->network_error_count, vs->transport_error_count, vs->sequence_error_count, vs->overflow_error_count); 382 struct hdhomerun_video_stats_t stats; 383 hdhomerun_video_get_stats(vs, &stats); 384 385 hdhomerun_debug_printf(vs->dbg, "video sock: pkt=%ld net=%ld te=%ld miss=%ld drop=%ld\n", 386 stats.packet_count, stats.network_error_count, 387 stats.transport_error_count, stats.sequence_error_count, 388 stats.overflow_error_count 389 ); 352 390 } 353 391 354 392 void hdhomerun_video_get_stats(struct hdhomerun_video_sock_t *vs, struct hdhomerun_video_stats_t *stats) 355 393 { 356 394 memset(stats, 0, sizeof(struct hdhomerun_video_stats_t)); 357 395 396 pthread_mutex_lock(&vs->lock); 397 358 398 stats->packet_count = vs->packet_count; 359 399 stats->network_error_count = vs->network_error_count; 360 400 stats->transport_error_count = vs->transport_error_count; 361 401 stats->sequence_error_count = vs->sequence_error_count; 402 stats->overflow_error_count = vs->overflow_error_count; 403 404 pthread_mutex_unlock(&vs->lock); 362 405 } -
mythtv/libs/libmythhdhomerun/hdhomerun_video.h
diff -p -r -u -N -X /tmp/diff.exclude.2286 -x myth.20746.0626a -x myth.20746.0626b myth.20746.0626a/mythtv/libs/libmythhdhomerun/hdhomerun_video.h myth.20746.0626b/mythtv/libs/libmythhdhomerun/hdhomerun_video.h
1 1 /* 2 2 * hdhomerun_video.h 3 3 * 4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>.4 * Copyright © 2006 Silicondust Engineering Ltd. <www.silicondust.com>. 5 5 * 6 6 * This library is free software; you can redistribute it and/or 7 7 * modify it under the terms of the GNU Lesser General Public … … 15 15 * 16 16 * You should have received a copy of the GNU Lesser General Public 17 17 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * As a special exception to the GNU Lesser General Public License, 20 * you may link, statically or dynamically, an application with a 21 * publicly distributed version of the Library to produce an 22 * executable file containing portions of the Library, and 23 * distribute that executable file under terms of your choice, 24 * without any of the additional requirements listed in clause 4 of 25 * the GNU Lesser General Public License. 26 * 27 * By "a publicly distributed version of the Library", we mean 28 * either the unmodified Library as distributed by Silicondust, or a 29 * modified version of the Library that is distributed under the 30 * conditions defined in the GNU Lesser General Public License. 18 31 */ 19 32 #ifdef __cplusplus 20 33 extern "C" { … … struct hdhomerun_video_stats_t { 27 40 uint32_t network_error_count; 28 41 uint32_t transport_error_count; 29 42 uint32_t sequence_error_count; 43 uint32_t overflow_error_count; 30 44 }; 31 45 32 46 #define TS_PACKET_SIZE 188