Mercurial > libavformat.hg
comparison mpegts.c @ 2128:42fe0d356a7d libavformat
make new_service() update existing info sanely
author | michael |
---|---|
date | Mon, 04 Jun 2007 11:46:59 +0000 |
parents | e70e06400158 |
children | 020f3b7f0eb0 |
comparison
equal
deleted
inserted
replaced
2127:e70e06400158 | 2128:42fe0d356a7d |
---|---|
362 } | 362 } |
363 | 363 |
364 static MpegTSService *new_service(MpegTSContext *ts, int sid, | 364 static MpegTSService *new_service(MpegTSContext *ts, int sid, |
365 char *provider_name, char *name) | 365 char *provider_name, char *name) |
366 { | 366 { |
367 MpegTSService *service; | 367 MpegTSService *service=NULL; |
368 int i; | |
368 | 369 |
369 #ifdef DEBUG_SI | 370 #ifdef DEBUG_SI |
370 av_log(ts->stream, AV_LOG_DEBUG, "new_service: " | 371 av_log(ts->stream, AV_LOG_DEBUG, "new_service: " |
371 "sid=0x%04x provider='%s' name='%s'\n", | 372 "sid=0x%04x provider='%s' name='%s'\n", |
372 sid, provider_name, name); | 373 sid, provider_name, name); |
373 #endif | 374 #endif |
374 | 375 |
375 service = av_mallocz(sizeof(MpegTSService)); | 376 for(i=0; i<ts->nb_services; i++) |
376 if (!service) | 377 if(ts->services[i]->sid == sid) |
377 return NULL; | 378 service= ts->services[i]; |
379 | |
380 if(!service){ | |
381 service = av_mallocz(sizeof(MpegTSService)); | |
382 if (!service) | |
383 return NULL; | |
384 dynarray_add(&ts->services, &ts->nb_services, service); | |
385 } | |
378 service->sid = sid; | 386 service->sid = sid; |
379 service->provider_name = provider_name; | 387 assert((!provider_name) == (!name)); |
380 service->name = name; | 388 if(name){ |
381 dynarray_add(&ts->services, &ts->nb_services, service); | 389 av_free(service->provider_name); |
390 av_free(service-> name); | |
391 service->provider_name = provider_name; | |
392 service-> name = name; | |
393 } | |
382 return service; | 394 return service; |
383 } | 395 } |
384 | 396 |
385 static void pmt_cb(void *opaque, const uint8_t *section, int section_len) | 397 static void pmt_cb(void *opaque, const uint8_t *section, int section_len) |
386 { | 398 { |