diff --git a/hdhomerun_channels.c b/hdhomerun_channels.c index 6746770..9db637e 100644 --- a/hdhomerun_channels.c +++ b/hdhomerun_channels.c @@ -83,6 +83,13 @@ static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_jp_b { 0, 0, 0, 0} }; +/* TW antenna channels. */ +static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_tw_bcast[] = { + { 7, 13, 177000000, 6000000}, + { 14, 69, 473000000, 6000000}, + { 0, 0, 0, 0} +}; + /* US antenna channels. */ static const struct hdhomerun_channelmap_range_t hdhomerun_channelmap_range_us_bcast[] = { { 2, 4, 57000000, 6000000}, @@ -136,7 +143,7 @@ static const struct hdhomerun_channelmap_record_t hdhomerun_channelmap_table[] = {"au-cable", hdhomerun_channelmap_range_eu_cable, "au-cable", "AU"}, {"eu-bcast", hdhomerun_channelmap_range_eu_bcast, "eu-bcast", NULL}, {"eu-cable", hdhomerun_channelmap_range_eu_cable, "eu-cable", NULL}, - {"tw-bcast", hdhomerun_channelmap_range_us_bcast, "tw-bcast", "TW"}, + {"tw-bcast", hdhomerun_channelmap_range_tw_bcast, "tw-bcast", "TW"}, {"tw-cable", hdhomerun_channelmap_range_us_cable, "tw-cable", "TW"}, {"kr-bcast", hdhomerun_channelmap_range_us_bcast, "kr-bcast", "KR"}, diff --git a/hdhomerun_os_posix.h b/hdhomerun_os_posix.h index 386ff13..baab8e5 100644 --- a/hdhomerun_os_posix.h +++ b/hdhomerun_os_posix.h @@ -53,6 +53,10 @@ typedef struct { #define LIBHDHOMERUN_API +#if !defined(alignas) +#define alignas(n) __attribute__((aligned(n))) +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/hdhomerun_os_windows.h b/hdhomerun_os_windows.h index 932cf9c..62900e7 100644 --- a/hdhomerun_os_windows.h +++ b/hdhomerun_os_windows.h @@ -56,6 +56,14 @@ #define LIBHDHOMERUN_API #endif +#if !defined(__unused) +#define __unused __pragma(warning(suppress: 4100 4101)) +#endif + +#if !defined(alignas) && !defined(__cplusplus) +#define alignas(n) __declspec(align(n)) +#endif + typedef void (*sig_t)(int); typedef void (*thread_task_func_t)(void *arg); typedef HANDLE thread_task_t; diff --git a/hdhomerun_video.c b/hdhomerun_video.c index 9db03ca..a472634 100644 --- a/hdhomerun_video.c +++ b/hdhomerun_video.c @@ -183,15 +183,23 @@ void hdhomerun_video_leave_multicast_group(struct hdhomerun_video_sock_t *vs, ui static void hdhomerun_video_stats_ts_pkt(struct hdhomerun_video_sock_t *vs, uint8_t *ptr) { - uint16_t packet_identifier = ((uint16_t)(ptr[1] & 0x1F) << 8) | (uint16_t)ptr[2]; + uint16_t packet_identifier; + packet_identifier = (uint16_t)(ptr[1] & 0x1F) << 8; + packet_identifier |= (uint16_t)ptr[2] << 0; + + bool transport_error = (ptr[1] & 0x80) != 0; + if (transport_error) { + vs->transport_error_count++; + vs->sequence[packet_identifier] = 0xFF; + return; + } + if (packet_identifier == 0x1FFF) { return; } - bool transport_error = ptr[1] >> 7; - if (transport_error) { - vs->transport_error_count++; - vs->sequence[packet_identifier] = 0xFF; + bool payload_present = (ptr[3] & 0x10) != 0; + if (!payload_present) { return; } @@ -206,9 +214,6 @@ static void hdhomerun_video_stats_ts_pkt(struct hdhomerun_video_sock_t *vs, uint if (sequence == ((previous_sequence + 1) & 0x0F)) { return; } - if (sequence == previous_sequence) { - return; - } vs->sequence_error_count++; }