« clib/dvb_ts_lib/descriptors/parse_desc_multilingual_bouquet_name.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_multilingual_network_name.c »
| 1 | /* | ||||||||||||||
| 2 | * parse_desc_multilingual_component.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_multilingual_component.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 | // multilingual_component_descriptor(){ | ||||||||||||||
| 43 | // descriptor_tag 8 uimsbf | ||||||||||||||
| 44 | // descriptor_length 8 uimsbf | ||||||||||||||
| 45 | // component_tag 8 uimsbf | ||||||||||||||
| 46 | // for (i=0;i<N;i++) { | ||||||||||||||
| 47 | // ISO_639_language_code 24 bslbf | ||||||||||||||
| 48 | // text_description_length 8 uimsbf | ||||||||||||||
| 49 | // for (j=0;j<N;j++){ | ||||||||||||||
| 50 | // text_char 8 uimsbf | ||||||||||||||
| 51 | // } | ||||||||||||||
| 52 | // } | ||||||||||||||
| 53 | // } | ||||||||||||||
| 54 | |||||||||||||||
| 55 | |||||||||||||||
| 56 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 57 | 0 | void print_multilingual_component(struct Descriptor_multilingual_component *mcd, int level) | |||||||||||||
| 58 | { | ||||||||||||||
| 59 | struct list_head *item, *safe; | ||||||||||||||
| 60 | |||||||||||||||
| 61 | 0 | printf(" Descriptor: multilingual_component [0x%02x]\n", mcd->descriptor_tag) ; | |||||||||||||
| 62 | 0 | printf(" Length: %d\n", mcd->descriptor_length) ; | |||||||||||||
| 63 | |||||||||||||||
| 64 | 0 | printf(" component_tag = %d\n", mcd->component_tag) ; | |||||||||||||
| 65 | |||||||||||||||
| 66 | 0 | ▶ | list_for_each_safe(item,safe,&mcd->mcd_array) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 67 | 0 | struct MCD_entry *mcd_entry = list_entry(item, struct MCD_entry, next); | |||||||||||||
| 68 | |||||||||||||||
| 69 | // MCD entry | ||||||||||||||
| 70 | 0 | printf(" -MCD entry-\n") ; | |||||||||||||
| 71 | |||||||||||||||
| 72 | 0 | printf(" ISO_639_language_code = %d\n", mcd_entry->ISO_639_language_code) ; | |||||||||||||
| 73 | 0 | printf(" text_description_length = %d\n", mcd_entry->text_description_length) ; | |||||||||||||
| 74 | 0 | printf(" text_description = \"%s\"\n", mcd_entry->text_description) ; | |||||||||||||
| 75 | } | ||||||||||||||
| 76 | |||||||||||||||
| 77 | 0 | } | |||||||||||||
| 78 | |||||||||||||||
| 79 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 80 | 0 | struct Descriptor *parse_multilingual_component(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||||||
| 81 | { | ||||||||||||||
| 82 | struct Descriptor_multilingual_component *mcd ; | ||||||||||||||
| 83 | unsigned byte ; | ||||||||||||||
| 84 | int end_buff_len ; | ||||||||||||||
| 85 | |||||||||||||||
| 86 | 0 | mcd = (struct Descriptor_multilingual_component *)malloc( sizeof(*mcd) ) ; | |||||||||||||
| 87 | 0 | memset(mcd,0,sizeof(*mcd)); | |||||||||||||
| 88 | |||||||||||||||
| 89 | //== Parse data == | ||||||||||||||
| 90 | 0 | INIT_LIST_HEAD(&mcd->next); | |||||||||||||
| 91 | 0 | mcd->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||||||
| 92 | 0 | mcd->descriptor_length = len ; // already extracted by parse_desc() | |||||||||||||
| 93 | 0 | mcd->component_tag = bits_get(bits, 8) ; | |||||||||||||
| 94 | |||||||||||||||
| 95 | 0 | INIT_LIST_HEAD(&mcd->mcd_array) ; | |||||||||||||
| 96 | 0 | end_buff_len = bits_len_calc(bits, -(mcd->descriptor_length - 1) ) ; | |||||||||||||
| 97 | 0 | ▶ | while (bits->buff_len > end_buff_len) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 98 | { | ||||||||||||||
| 99 | 0 | struct MCD_entry *mcd_entry = malloc(sizeof(*mcd_entry)); | |||||||||||||
| 100 | 0 | memset(mcd_entry,0,sizeof(*mcd_entry)); | |||||||||||||
| 101 | 0 | list_add_tail(&mcd_entry->next,&mcd->mcd_array); | |||||||||||||
| 102 | |||||||||||||||
| 103 | 0 | mcd_entry->ISO_639_language_code = bits_get(bits, 24) ; | |||||||||||||
| 104 | 0 | mcd_entry->text_description_length = bits_get(bits, 8) ; | |||||||||||||
| 105 | |||||||||||||||
| 106 | 0 | end_buff_len = bits_len_calc(bits, -mcd_entry->text_description_length) ; | |||||||||||||
| 107 | 0 | mcd_entry->text_description[0] = 0 ; | |||||||||||||
| 108 | 0 | ▶ | for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_TEXT_DESCRIPTION_LEN); ++byte) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 109 | { | ||||||||||||||
| 110 | 0 | mcd_entry->text_description[byte] = bits_get(bits, 8) ; | |||||||||||||
| 111 | 0 | mcd_entry->text_description[byte+1] = 0 ; | |||||||||||||
| 112 | } | ||||||||||||||
| 113 | |||||||||||||||
| 114 | } | ||||||||||||||
| 115 | |||||||||||||||
| 116 | |||||||||||||||
| 117 | 0 | return (struct Descriptor *)mcd ; | |||||||||||||
| 118 | } | ||||||||||||||
| 119 | |||||||||||||||
| 120 | /* ----------------------------------------------------------------------- */ | ||||||||||||||
| 121 | 0 | void free_multilingual_component(struct Descriptor_multilingual_component *mcd) | |||||||||||||
| 122 | { | ||||||||||||||
| 123 | struct list_head *item, *safe; | ||||||||||||||
| 124 | |||||||||||||||
| 125 | 0 | ▶ | list_for_each_safe(item,safe,&mcd->mcd_array) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 126 | 0 | struct MCD_entry *mcd_entry = list_entry(item, struct MCD_entry, next); | |||||||||||||
| 127 | 0 | free(mcd_entry) ; | |||||||||||||
| 128 | } | ||||||||||||||
| 129 | |||||||||||||||
| 130 | |||||||||||||||
| 131 | 0 | free(mcd) ; | |||||||||||||
| 132 | 0 | } | |||||||||||||