Skip to content

Commit 87d995d

Browse files
committed
[sillan] Modified the AIT struct to have a quick access to the service ID
Removed GPAC_HBBTV flags git-svn-id: http://svn.code.sf.net/p/gpac/code/trunk/gpac@3177 63c20433-aa62-49bd-875c-5a186b69a8fb
1 parent 2793228 commit 87d995d

File tree

4 files changed

+105
-96
lines changed

4 files changed

+105
-96
lines changed

include/gpac/carousel.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ typedef struct
4848
ABSTRACT_ES
4949
GF_M2TS_SectionFilter *sec;
5050

51+
u32 service_id;
5152
u8 table_id;
5253
Bool section_syntax_indicator;
5354
u16 section_length;
@@ -60,14 +61,23 @@ typedef struct
6061
u16 common_descriptors_length;
6162
GF_List * common_descriptors;
6263
u16 application_loop_length;
64+
GF_List * application;
65+
u32 CRC_32;
66+
67+
} GF_M2TS_AIT;
68+
69+
70+
typedef struct
71+
{
6372
u32 organisation_id;
6473
u16 application_id;
6574
u8 application_control_code;
6675
u16 application_descriptors_loop_length;
6776
GF_List * application_descriptors;
68-
u32 CRC_32;
6977

70-
} GF_M2TS_AIT;
78+
}
79+
GF_M2TS_AIT_APPLICATION;
80+
7181

7282
typedef enum {
7383
FUTURE_USE = 0x00,

include/gpac/mpegts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ struct __gf_dvb_tuner {
10501050
#endif
10511051

10521052

1053-
GF_Err TSDemux_Demux_Process(GF_M2TS_Demuxer *ts, const char *url, Bool loop);
1053+
GF_Err TSDemux_Demux_Process(GF_M2TS_Demuxer *ts, const char *url, Bool loop);
10541054
void TSDemux_SetupLive(GF_M2TS_Demuxer *ts, char *url);
10551055
void TSDemux_SetupFile(GF_M2TS_Demuxer *ts, char *url);
10561056
u32 TSDemux_DemuxRun(void *_p);

src/media_tools/carousel.c

Lines changed: 82 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
#include <gpac/carousel.h>
2626

2727

28-
GF_M2TS_ES *gf_ait_section_new()
28+
GF_M2TS_ES *gf_ait_section_new(u32 service_id)
2929
{
3030
GF_M2TS_ES *es;
3131

3232
GF_M2TS_AIT *ses;
3333
GF_SAFEALLOC(ses, GF_M2TS_AIT);
3434
es = (GF_M2TS_ES *)ses;
3535
es->flags = GF_M2TS_ES_IS_SECTION;
36+
ses->service_id = service_id;
3637
return es;
3738
}
3839

@@ -59,16 +60,17 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
5960

6061
GF_BitStream *bs;
6162
u8 temp_descriptor_tag;
62-
u32 data_shift, app_desc_data_shift;
63+
u32 data_shift, app_desc_data_shift, ait_app_data_shift;
6364
u32 nb_of_ait;
6465

6566
data_shift = 0;
6667
temp_descriptor_tag = 0;
6768
nb_of_ait = 0;
69+
ait_app_data_shift = 0;
6870
bs = gf_bs_new(data,data_size,GF_BITSTREAM_READ);
6971

7072
ait->common_descriptors = gf_list_new();
71-
ait->application_descriptors = gf_list_new();
73+
ait->application = gf_list_new();
7274

7375

7476
ait->table_id = gf_bs_read_int(bs,8);
@@ -99,21 +101,28 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
99101
gf_bs_read_int(bs,(unsigned int)ait->common_descriptors_length/8);
100102
gf_bs_read_int(bs,4);/* bit shifting */
101103
ait->application_loop_length = gf_bs_read_int(bs,12);
102-
103-
/* application loop */
104-
ait->organisation_id = gf_bs_read_int(bs,32);
105-
ait->application_id= gf_bs_read_int(bs,16);
106-
ait->application_control_code= gf_bs_read_int(bs,8);
107-
gf_bs_read_int(bs,4);/* bit shifting */
108-
ait->application_descriptors_loop_length= gf_bs_read_int(bs,12);
109104

110105
data_shift = (u32)(gf_bs_get_position(bs)) + ait->common_descriptors_length/8;
111106

112-
app_desc_data_shift = 0;
107+
while(ait_app_data_shift<ait->application_loop_length){
108+
109+
GF_M2TS_AIT_APPLICATION* application;
110+
GF_SAFEALLOC(application,GF_M2TS_AIT_APPLICATION);
111+
application->application_descriptors = gf_list_new();
113112

114-
while(app_desc_data_shift< ait->application_descriptors_loop_length){
115-
temp_descriptor_tag = gf_bs_read_int(bs,8);
116-
switch(temp_descriptor_tag){
113+
/* application loop */
114+
application->organisation_id = gf_bs_read_int(bs,32);
115+
application->application_id= gf_bs_read_int(bs,16);
116+
application->application_control_code= gf_bs_read_int(bs,8);
117+
gf_bs_read_int(bs,4);/* bit shifting */
118+
application->application_descriptors_loop_length= gf_bs_read_int(bs,12);
119+
120+
ait_app_data_shift += 9;
121+
app_desc_data_shift = 0;
122+
123+
while(app_desc_data_shift< application->application_descriptors_loop_length){
124+
temp_descriptor_tag = gf_bs_read_int(bs,8);
125+
switch(temp_descriptor_tag){
117126
case APPLICATION_DESCRIPTOR:
118127
{
119128
u64 pre_processing_pos;
@@ -135,7 +144,7 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
135144
if(pre_processing_pos+application_descriptor->descriptor_length != gf_bs_get_position(bs)){
136145
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),application_descriptor->descriptor_length));
137146
}
138-
gf_list_add(ait->application_descriptors,application_descriptor);
147+
gf_list_add(application->application_descriptors,application_descriptor);
139148
app_desc_data_shift += (2+ application_descriptor->descriptor_length);
140149
break;
141150
}
@@ -155,7 +164,7 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
155164
if(pre_processing_pos+name_descriptor->descriptor_length != gf_bs_get_position(bs)){
156165
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),name_descriptor->descriptor_length));
157166
}
158-
gf_list_add(ait->application_descriptors,name_descriptor);
167+
gf_list_add(application->application_descriptors,name_descriptor);
159168
app_desc_data_shift += (2+ name_descriptor->descriptor_length);
160169
break;
161170
}
@@ -170,61 +179,61 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
170179
protocol_descriptor->protocol_id = gf_bs_read_int(bs,16);
171180
protocol_descriptor->transport_protocol_label = gf_bs_read_int(bs,8);
172181
printf("protocol_descriptor->protocol_id %d \n",protocol_descriptor->protocol_id);
173-
182+
174183
switch(protocol_descriptor->protocol_id){
175-
case CAROUSEL:
176-
{
177-
178-
GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte;
179-
GF_SAFEALLOC(Carousel_selector_byte, GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE);
180-
Carousel_selector_byte->remote_connection = gf_bs_read_int(bs,1);
181-
gf_bs_read_int(bs,7); /* bit shifting */
182-
if(Carousel_selector_byte->remote_connection){
183-
Carousel_selector_byte->original_network_id = gf_bs_read_int(bs,16);
184-
Carousel_selector_byte->transport_stream_id = gf_bs_read_int(bs,16);
185-
Carousel_selector_byte->service_id = gf_bs_read_int(bs,16);
186-
}
187-
Carousel_selector_byte->component_tag = gf_bs_read_int(bs,8);
188-
protocol_descriptor->selector_byte = Carousel_selector_byte;
189-
break;
190-
}
191-
case TRANSPORT_HTTP:
192-
{
193-
u32 i;
194-
GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte;
195-
GF_SAFEALLOC(Transport_http_selector_byte, GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE);
196-
Transport_http_selector_byte->URL_base_length = gf_bs_read_int(bs,8);
197-
//printf("Transport_http_selector_byte->URL_base_length %d \n",Transport_http_selector_byte->URL_base_length);
198-
Transport_http_selector_byte->URL_base_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_base_length,sizeof(char));
199-
gf_bs_read_data(bs,Transport_http_selector_byte->URL_base_byte ,(u32)(Transport_http_selector_byte->URL_base_length));
200-
Transport_http_selector_byte->URL_base_byte[Transport_http_selector_byte->URL_base_length] = 0;
201-
Transport_http_selector_byte->URL_extension_count = gf_bs_read_int(bs,8);
202-
if(Transport_http_selector_byte->URL_extension_count){
203-
Transport_http_selector_byte->URL_extentions = (GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION*) gf_calloc(Transport_http_selector_byte->URL_extension_count,sizeof(GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION));
204-
for(i = 0; i < Transport_http_selector_byte->URL_extension_count;i++){
205-
Transport_http_selector_byte->URL_extentions[i].URL_extension_length = gf_bs_read_int(bs,8);
206-
Transport_http_selector_byte->URL_extentions[i].URL_extension_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_extentions[i].URL_extension_length,sizeof(char));
207-
gf_bs_read_data(bs,Transport_http_selector_byte->URL_extentions[i].URL_extension_byte,(u32)(Transport_http_selector_byte->URL_extentions[i].URL_extension_length));
208-
Transport_http_selector_byte->URL_extentions[i].URL_extension_byte[Transport_http_selector_byte->URL_extentions[i].URL_extension_length] = 0;
209-
}
210-
}
211-
protocol_descriptor->selector_byte = Transport_http_selector_byte;
212-
break;
213-
}
214-
default:
215-
{
216-
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id));
217-
}
184+
case CAROUSEL:
185+
{
186+
187+
GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE* Carousel_selector_byte;
188+
GF_SAFEALLOC(Carousel_selector_byte, GF_M2TS_OBJECT_CAROUSEL_SELECTOR_BYTE);
189+
Carousel_selector_byte->remote_connection = gf_bs_read_int(bs,1);
190+
gf_bs_read_int(bs,7); /* bit shifting */
191+
if(Carousel_selector_byte->remote_connection){
192+
Carousel_selector_byte->original_network_id = gf_bs_read_int(bs,16);
193+
Carousel_selector_byte->transport_stream_id = gf_bs_read_int(bs,16);
194+
Carousel_selector_byte->service_id = gf_bs_read_int(bs,16);
195+
}
196+
Carousel_selector_byte->component_tag = gf_bs_read_int(bs,8);
197+
protocol_descriptor->selector_byte = Carousel_selector_byte;
198+
break;
199+
}
200+
case TRANSPORT_HTTP:
201+
{
202+
u32 i;
203+
GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE* Transport_http_selector_byte;
204+
GF_SAFEALLOC(Transport_http_selector_byte, GF_M2TS_TRANSPORT_HTTP_SELECTOR_BYTE);
205+
Transport_http_selector_byte->URL_base_length = gf_bs_read_int(bs,8);
206+
//printf("Transport_http_selector_byte->URL_base_length %d \n",Transport_http_selector_byte->URL_base_length);
207+
Transport_http_selector_byte->URL_base_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_base_length,sizeof(char));
208+
gf_bs_read_data(bs,Transport_http_selector_byte->URL_base_byte ,(u32)(Transport_http_selector_byte->URL_base_length));
209+
Transport_http_selector_byte->URL_base_byte[Transport_http_selector_byte->URL_base_length] = 0;
210+
Transport_http_selector_byte->URL_extension_count = gf_bs_read_int(bs,8);
211+
if(Transport_http_selector_byte->URL_extension_count){
212+
Transport_http_selector_byte->URL_extentions = (GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION*) gf_calloc(Transport_http_selector_byte->URL_extension_count,sizeof(GF_M2TS_TRANSPORT_HTTP_URL_EXTENTION));
213+
for(i = 0; i < Transport_http_selector_byte->URL_extension_count;i++){
214+
Transport_http_selector_byte->URL_extentions[i].URL_extension_length = gf_bs_read_int(bs,8);
215+
Transport_http_selector_byte->URL_extentions[i].URL_extension_byte = (char*)gf_calloc(Transport_http_selector_byte->URL_extentions[i].URL_extension_length,sizeof(char));
216+
gf_bs_read_data(bs,Transport_http_selector_byte->URL_extentions[i].URL_extension_byte,(u32)(Transport_http_selector_byte->URL_extentions[i].URL_extension_length));
217+
Transport_http_selector_byte->URL_extentions[i].URL_extension_byte[Transport_http_selector_byte->URL_extentions[i].URL_extension_length] = 0;
218+
}
219+
}
220+
protocol_descriptor->selector_byte = Transport_http_selector_byte;
221+
break;
222+
}
223+
default:
224+
{
225+
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Protocol ID %d unsupported, ignoring the selector byte \n",protocol_descriptor->protocol_id));
226+
}
218227
}
219228
if(pre_processing_pos+protocol_descriptor->descriptor_length != gf_bs_get_position(bs)){
220229
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),protocol_descriptor->descriptor_length));
221230
}
222-
gf_list_add(ait->application_descriptors,protocol_descriptor);
231+
gf_list_add(application->application_descriptors,protocol_descriptor);
223232
app_desc_data_shift += (2+ protocol_descriptor->descriptor_length);
224233
break;
225234
}
226235
case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR:
227-
{
236+
{
228237
u64 pre_processing_pos;
229238
GF_M2TS_SIMPLE_APPLICATION_LOCATION* Simple_application_location;
230239
GF_SAFEALLOC(Simple_application_location, GF_M2TS_SIMPLE_APPLICATION_LOCATION);
@@ -237,7 +246,7 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
237246
if(pre_processing_pos+Simple_application_location->descriptor_length != gf_bs_get_position(bs)){
238247
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Simple_application_location->descriptor_length));
239248
}
240-
gf_list_add(ait->application_descriptors,Simple_application_location);
249+
gf_list_add(application->application_descriptors,Simple_application_location);
241250
app_desc_data_shift += (2+ Simple_application_location->descriptor_length);
242251
break;
243252
}
@@ -253,22 +262,25 @@ GF_Err gf_m2ts_process_ait(GF_M2TS_Demuxer *ts, GF_M2TS_AIT *ait, char *data, u
253262
if(pre_processing_pos+Application_usage->descriptor_length != gf_bs_get_position(bs)){
254263
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor data processed length error. Difference between byte shifting %d and descriptor length %d \n",(gf_bs_get_position(bs) - pre_processing_pos),Application_usage->descriptor_length));
255264
}
256-
gf_list_add(ait->application_descriptors,Application_usage);
265+
gf_list_add(application->application_descriptors,Application_usage);
257266
app_desc_data_shift += (2+ Application_usage->descriptor_length);
258267
break;
259268
}
260-
261269

262-
default:
263-
{
264-
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",temp_descriptor_tag));
270+
271+
default:
272+
{
273+
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[Process AIT] Descriptor tag %d unknown, ignoring the descriptor \n",temp_descriptor_tag));
274+
}
275+
265276
}
266277

267278
}
268-
279+
ait_app_data_shift += application->application_descriptors_loop_length;
280+
gf_list_add(ait->application,application);
269281
}
270282

271-
data_shift +=ait->application_descriptors_loop_length;
283+
data_shift +=ait->application_loop_length;
272284
ait->CRC_32 = gf_bs_read_int(bs,32);
273285
data_shift += 4;
274286

src/media_tools/mpegts.c

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424

2525
#include <gpac/mpegts.h>
2626

27-
//#define GPAC_HBBTV
28-
#ifdef GPAC_HBBTV
2927
#include <gpac/carousel.h>
30-
#endif
28+
3129

3230
#ifndef GPAC_DISABLE_MPEG2TS
3331

@@ -759,7 +757,7 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter
759757
{
760758
if (!sec->process_section) {
761759

762-
#ifdef GPAC_HBBTV
760+
763761
if ((ts->on_event && (sec->section[0]==GF_M2TS_TABLE_ID_AIT)) )
764762
{
765763
GF_M2TS_SL_PCK pck;
@@ -768,9 +766,7 @@ static void gf_m2ts_section_complete(GF_M2TS_Demuxer *ts, GF_M2TS_SectionFilter
768766
pck.stream = (GF_M2TS_ES *)ses;
769767
ts->on_event(ts, GF_M2TS_EVT_AIT_FOUND, &pck);
770768

771-
} else
772-
#endif
773-
if (ts->on_mpe_event && ((ses && (ses->flags & GF_M2TS_EVT_DVB_MPE)) || (sec->section[0]==GF_M2TS_TABLE_ID_INT)) ) {
769+
} else if (ts->on_mpe_event && ((ses && (ses->flags & GF_M2TS_EVT_DVB_MPE)) || (sec->section[0]==GF_M2TS_TABLE_ID_INT)) ) {
774770
GF_M2TS_SL_PCK pck;
775771
pck.data_len = sec->length;
776772
pck.data = sec->section;
@@ -1297,26 +1293,20 @@ static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF
12971293
}
12981294
break;
12991295

1300-
case GF_M2TS_13818_6_ANNEX_D:
1296+
13011297
case GF_M2TS_PRIVATE_SECTION:
1302-
printf("unknown private section: pid = %d \n", pid);
1303-
if (pid == GF_M2TS_TABLE_ID_AIT){
1298+
printf("unknown private section: pid = %d \n", pid);
13041299
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT found \n"));
1305-
es = gf_ait_section_new();
1300+
es = gf_ait_section_new(pmt->program->number);
13061301
((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 0);
1307-
}else{
1308-
1302+
break;
1303+
case GF_M2TS_13818_6_ANNEX_D:
13091304
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
13101305
es = (GF_M2TS_ES *)ses;
1311-
es->flags |= GF_M2TS_ES_IS_SECTION;
1312-
if (stream_type == GF_M2TS_13818_6_ANNEX_D)
1313-
printf("stream type DSM CC user private section: pid = %d \n", pid);
1314-
else
1315-
printf("unknown private section: pid = %d \n", pid);
1306+
es->flags |= GF_M2TS_ES_IS_SECTION;
1307+
printf("stream type DSM CC user private section: pid = %d \n", pid);
13161308
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
13171309
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
1318-
}
1319-
13201310
break;
13211311

13221312
case GF_M2TS_MPE_SECTIONS:
@@ -1903,9 +1893,6 @@ static void gf_m2ts_process_packet(GF_M2TS_Demuxer *ts, unsigned char *data)
19031893
} else if (hdr.pid == GF_M2TS_PID_TDT_TOT_ST) {
19041894
gf_m2ts_gather_section(ts, ts->tdt_tot_st, NULL, &hdr, data, payload_size);
19051895
} else {
1906-
#ifdef GPAC_HBBTV
1907-
//gf_m2ts_gather_section(ts, ts->ait, NULL, &hdr, data, payload_size);
1908-
#endif
19091896
/* ignore packet */
19101897
}
19111898
} else if (es->flags & GF_M2TS_ES_IS_SECTION) { /* The stream uses sections to carry its payload */

0 commit comments

Comments
 (0)