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