Mercurial > libavformat.hg
changeset 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 |
files | mpegts.c |
diffstat | 1 files changed, 19 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mpegts.c Mon Jun 04 11:25:33 2007 +0000 +++ b/mpegts.c Mon Jun 04 11:46:59 2007 +0000 @@ -364,7 +364,8 @@ static MpegTSService *new_service(MpegTSContext *ts, int sid, char *provider_name, char *name) { - MpegTSService *service; + MpegTSService *service=NULL; + int i; #ifdef DEBUG_SI av_log(ts->stream, AV_LOG_DEBUG, "new_service: " @@ -372,13 +373,24 @@ sid, provider_name, name); #endif - service = av_mallocz(sizeof(MpegTSService)); - if (!service) - return NULL; + for(i=0; i<ts->nb_services; i++) + if(ts->services[i]->sid == sid) + service= ts->services[i]; + + if(!service){ + service = av_mallocz(sizeof(MpegTSService)); + if (!service) + return NULL; + dynarray_add(&ts->services, &ts->nb_services, service); + } service->sid = sid; - service->provider_name = provider_name; - service->name = name; - dynarray_add(&ts->services, &ts->nb_services, service); + assert((!provider_name) == (!name)); + if(name){ + av_free(service->provider_name); + av_free(service-> name); + service->provider_name = provider_name; + service-> name = name; + } return service; }