« clib/dvb_ts_lib/descriptors/parse_desc_stuffing.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_telephone.c »
| 1 | /* | ||||||||||
| 2 | * parse_desc_subtitling.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_subtitling.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 | // subtitling_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 | // subtitling_type 8 bslbf | ||||||||||
| 48 | // composition_page_id 16 bslbf | ||||||||||
| 49 | // ancillary_page_id 16 bslbf | ||||||||||
| 50 | // } | ||||||||||
| 51 | // } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 55 | 0 | void print_subtitling(struct Descriptor_subtitling *sd, int level) | |||||||||
| 56 | { | ||||||||||
| 57 | struct list_head *item, *safe; | ||||||||||
| 58 | |||||||||||
| 59 | 0 | printf(" Descriptor: subtitling [0x%02x]\n", sd->descriptor_tag) ; | |||||||||
| 60 | 0 | printf(" Length: %d\n", sd->descriptor_length) ; | |||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | list_for_each_safe(item,safe,&sd->sd_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | struct SD_entry *sd_entry = list_entry(item, struct SD_entry, next); | |||||||||
| 65 | |||||||||||
| 66 | // SD entry | ||||||||||
| 67 | 0 | printf(" -SD entry-\n") ; | |||||||||
| 68 | |||||||||||
| 69 | 0 | printf(" ISO_639_language_code = %d\n", sd_entry->ISO_639_language_code) ; | |||||||||
| 70 | 0 | printf(" subtitling_type = %d\n", sd_entry->subtitling_type) ; | |||||||||
| 71 | 0 | printf(" composition_page_id = %d\n", sd_entry->composition_page_id) ; | |||||||||
| 72 | 0 | printf(" ancillary_page_id = %d\n", sd_entry->ancillary_page_id) ; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | 0 | } | |||||||||
| 76 | |||||||||||
| 77 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 78 | 0 | struct Descriptor *parse_subtitling(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||
| 79 | { | ||||||||||
| 80 | struct Descriptor_subtitling *sd ; | ||||||||||
| 81 | unsigned byte ; | ||||||||||
| 82 | int end_buff_len ; | ||||||||||
| 83 | |||||||||||
| 84 | 0 | sd = (struct Descriptor_subtitling *)malloc( sizeof(*sd) ) ; | |||||||||
| 85 | 0 | memset(sd,0,sizeof(*sd)); | |||||||||
| 86 | |||||||||||
| 87 | //== Parse data == | ||||||||||
| 88 | 0 | INIT_LIST_HEAD(&sd->next); | |||||||||
| 89 | 0 | sd->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||
| 90 | 0 | sd->descriptor_length = len ; // already extracted by parse_desc() | |||||||||
| 91 | |||||||||||
| 92 | 0 | INIT_LIST_HEAD(&sd->sd_array) ; | |||||||||
| 93 | 0 | end_buff_len = bits_len_calc(bits, -sd->descriptor_length ) ; | |||||||||
| 94 | 0 | ▶ | while (bits->buff_len > end_buff_len) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | { | ||||||||||
| 96 | 0 | struct SD_entry *sd_entry = malloc(sizeof(*sd_entry)); | |||||||||
| 97 | 0 | memset(sd_entry,0,sizeof(*sd_entry)); | |||||||||
| 98 | 0 | list_add_tail(&sd_entry->next,&sd->sd_array); | |||||||||
| 99 | |||||||||||
| 100 | 0 | sd_entry->ISO_639_language_code = bits_get(bits, 24) ; | |||||||||
| 101 | 0 | sd_entry->subtitling_type = bits_get(bits, 8) ; | |||||||||
| 102 | 0 | sd_entry->composition_page_id = bits_get(bits, 16) ; | |||||||||
| 103 | 0 | sd_entry->ancillary_page_id = bits_get(bits, 16) ; | |||||||||
| 104 | } | ||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | 0 | return (struct Descriptor *)sd ; | |||||||||
| 108 | } | ||||||||||
| 109 | |||||||||||
| 110 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 111 | 0 | void free_subtitling(struct Descriptor_subtitling *sd) | |||||||||
| 112 | { | ||||||||||
| 113 | struct list_head *item, *safe; | ||||||||||
| 114 | |||||||||||
| 115 | 0 | ▶ | list_for_each_safe(item,safe,&sd->sd_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | 0 | struct SD_entry *sd_entry = list_entry(item, struct SD_entry, next); | |||||||||
| 117 | 0 | free(sd_entry) ; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | |||||||||||
| 121 | 0 | free(sd) ; | |||||||||
| 122 | 0 | } | |||||||||