« clib/dvb_ts_lib/descriptors/parse_desc_ancillary_data.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_bouquet_name.c »
| 1 | /* | ||||||||||||||||||
| 2 | * parse_desc_announcement_support.c | ||||||||||||||||||
| 3 | * | ||||||||||||||||||
| 4 | * Created by: si_desc.pl | ||||||||||||||||||
| 5 | * Created on: 20-May-2011 | ||||||||||||||||||
| 6 | * Author: sdprice1 | ||||||||||||||||||
| 7 | */ | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | // VERSION = 1.00 | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | /*=============================================================================================*/ | ||||||||||||||||||
| 13 | // USES | ||||||||||||||||||
| 14 | /*=============================================================================================*/ | ||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | #include <stdio.h> | ||||||||||||||||||
| 17 | #include <stdlib.h> | ||||||||||||||||||
| 18 | #include <unistd.h> | ||||||||||||||||||
| 19 | #include <string.h> | ||||||||||||||||||
| 20 | #include <errno.h> | ||||||||||||||||||
| 21 | #include <ctype.h> | ||||||||||||||||||
| 22 | #include <fcntl.h> | ||||||||||||||||||
| 23 | #include <inttypes.h> | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | #include "parse_desc_announcement_support.h" | ||||||||||||||||||
| 26 | #include "descriptors/parse_desc.h" | ||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | /*=============================================================================================*/ | ||||||||||||||||||
| 29 | // CONSTANTS | ||||||||||||||||||
| 30 | /*=============================================================================================*/ | ||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | /*=============================================================================================*/ | ||||||||||||||||||
| 33 | // MACROS | ||||||||||||||||||
| 34 | /*=============================================================================================*/ | ||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | /*=============================================================================================*/ | ||||||||||||||||||
| 37 | // FUNCTIONS | ||||||||||||||||||
| 38 | /*=============================================================================================*/ | ||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | /* ----------------------------------------------------------------------- */ | ||||||||||||||||||
| 41 | // | ||||||||||||||||||
| 42 | // announcement_support_descriptor(){ | ||||||||||||||||||
| 43 | // descriptor_tag 8 uimsbf | ||||||||||||||||||
| 44 | // descriptor_length 8 uimsbf | ||||||||||||||||||
| 45 | // announcement_support_indicator 16 bslbf | ||||||||||||||||||
| 46 | // for (i=0; i<N; i++){ | ||||||||||||||||||
| 47 | // announcement_type 4 uimsbf | ||||||||||||||||||
| 48 | // reserved_future_use 1 bslbf | ||||||||||||||||||
| 49 | // reference_type 3 uimsbf | ||||||||||||||||||
| 50 | // if (reference_type == 0x01 | ||||||||||||||||||
| 51 | // original_network_id 16 uimsbf | ||||||||||||||||||
| 52 | // transport_stream_id 16 uimsbf | ||||||||||||||||||
| 53 | // service_id 16 uimsbf | ||||||||||||||||||
| 54 | // component_tag__ 8 uimsbf | ||||||||||||||||||
| 55 | // } | ||||||||||||||||||
| 56 | // } | ||||||||||||||||||
| 57 | // } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | /* ----------------------------------------------------------------------- */ | ||||||||||||||||||
| 61 | 0 | void print_announcement_support(struct Descriptor_announcement_support *asd, int level) | |||||||||||||||||
| 62 | { | ||||||||||||||||||
| 63 | struct list_head *item, *safe; | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 0 | printf(" Descriptor: announcement_support [0x%02x]\n", asd->descriptor_tag) ; | |||||||||||||||||
| 66 | 0 | printf(" Length: %d\n", asd->descriptor_length) ; | |||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | 0 | printf(" announcement_support_indicator = %d\n", asd->announcement_support_indicator) ; | |||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 0 | ▶ | list_for_each_safe(item,safe,&asd->asd_array) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 71 | 0 | struct ASD_entry *asd_entry = list_entry(item, struct ASD_entry, next); | |||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | // ASD entry | ||||||||||||||||||
| 74 | 0 | printf(" -ASD entry-\n") ; | |||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | 0 | printf(" announcement_type = %d\n", asd_entry->announcement_type) ; | |||||||||||||||||
| 77 | 0 | printf(" reference_type = %d\n", asd_entry->reference_type) ; | |||||||||||||||||
| 78 | 0 | ▶ | if (asd_entry->reference_type == 0x1 || asd_entry->reference_type == 0x2 || asd_entry->reference_type == 0x3 ) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 79 | { | ||||||||||||||||||
| 80 | 0 | printf(" original_network_id = %d\n", asd_entry->original_network_id) ; | |||||||||||||||||
| 81 | 0 | printf(" transport_stream_id = %d\n", asd_entry->transport_stream_id) ; | |||||||||||||||||
| 82 | 0 | printf(" service_id = %d\n", asd_entry->service_id) ; | |||||||||||||||||
| 83 | 0 | printf(" component_tag = %d\n", asd_entry->component_tag) ; | |||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | } | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | 0 | } | |||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | /* ----------------------------------------------------------------------- */ | ||||||||||||||||||
| 91 | 0 | struct Descriptor *parse_announcement_support(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||||||||||
| 92 | { | ||||||||||||||||||
| 93 | struct Descriptor_announcement_support *asd ; | ||||||||||||||||||
| 94 | unsigned byte ; | ||||||||||||||||||
| 95 | int end_buff_len ; | ||||||||||||||||||
| 96 | |||||||||||||||||||
| 97 | 0 | asd = (struct Descriptor_announcement_support *)malloc( sizeof(*asd) ) ; | |||||||||||||||||
| 98 | 0 | memset(asd,0,sizeof(*asd)); | |||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | //== Parse data == | ||||||||||||||||||
| 101 | 0 | INIT_LIST_HEAD(&asd->next); | |||||||||||||||||
| 102 | 0 | asd->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||||||||||
| 103 | 0 | asd->descriptor_length = len ; // already extracted by parse_desc() | |||||||||||||||||
| 104 | 0 | asd->announcement_support_indicator = bits_get(bits, 16) ; | |||||||||||||||||
| 105 | |||||||||||||||||||
| 106 | 0 | INIT_LIST_HEAD(&asd->asd_array) ; | |||||||||||||||||
| 107 | 0 | end_buff_len = bits_len_calc(bits, -(asd->descriptor_length - 2) ) ; | |||||||||||||||||
| 108 | 0 | ▶ | while (bits->buff_len > end_buff_len) | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 109 | { | ||||||||||||||||||
| 110 | 0 | struct ASD_entry *asd_entry = malloc(sizeof(*asd_entry)); | |||||||||||||||||
| 111 | 0 | memset(asd_entry,0,sizeof(*asd_entry)); | |||||||||||||||||
| 112 | 0 | list_add_tail(&asd_entry->next,&asd->asd_array); | |||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | 0 | asd_entry->announcement_type = bits_get(bits, 4) ; | |||||||||||||||||
| 115 | 0 | bits_skip(bits, 1) ; | |||||||||||||||||
| 116 | 0 | asd_entry->reference_type = bits_get(bits, 3) ; | |||||||||||||||||
| 117 | 0 | ▶ | if (asd_entry->reference_type == 0x1 || asd_entry->reference_type == 0x2 || asd_entry->reference_type == 0x3 ) | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 118 | { | ||||||||||||||||||
| 119 | 0 | asd_entry->original_network_id = bits_get(bits, 16) ; | |||||||||||||||||
| 120 | 0 | asd_entry->transport_stream_id = bits_get(bits, 16) ; | |||||||||||||||||
| 121 | 0 | asd_entry->service_id = bits_get(bits, 16) ; | |||||||||||||||||
| 122 | 0 | asd_entry->component_tag = bits_get(bits, 8) ; | |||||||||||||||||
| 123 | } | ||||||||||||||||||
| 124 | |||||||||||||||||||
| 125 | } | ||||||||||||||||||
| 126 | |||||||||||||||||||
| 127 | |||||||||||||||||||
| 128 | 0 | return (struct Descriptor *)asd ; | |||||||||||||||||
| 129 | } | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | /* ----------------------------------------------------------------------- */ | ||||||||||||||||||
| 132 | 0 | void free_announcement_support(struct Descriptor_announcement_support *asd) | |||||||||||||||||
| 133 | { | ||||||||||||||||||
| 134 | struct list_head *item, *safe; | ||||||||||||||||||
| 135 | |||||||||||||||||||
| 136 | 0 | ▶ | list_for_each_safe(item,safe,&asd->asd_array) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 137 | 0 | struct ASD_entry *asd_entry = list_entry(item, struct ASD_entry, next); | |||||||||||||||||
| 138 | 0 | free(asd_entry) ; | |||||||||||||||||
| 139 | } | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | |||||||||||||||||||
| 142 | 0 | free(asd) ; | |||||||||||||||||
| 143 | 0 | } | |||||||||||||||||