diff options
author | Michael Niedermayer | 2007-06-04 11:46:59 +0000 |
---|---|---|
committer | Michael Niedermayer | 2007-06-04 11:46:59 +0000 |
commit | 657ced8cdbd747946bf4a3909dacafc95a9309f4 (patch) | |
tree | 5d7b5d1ed37a74e1393c5fe20b29dac325634325 /libavformat/mpegts.c | |
parent | 0618bb1c5b402d0886724b9ef46a6871d3c8a323 (diff) |
make new_service() update existing info sanely
Originally committed as revision 9200 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/mpegts.c')
-rw-r--r-- | libavformat/mpegts.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 742b45ccd9..00cddf3eee 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -364,7 +364,8 @@ static int parse_section_header(SectionHeader *h, 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 @@ static MpegTSService *new_service(MpegTSContext *ts, int sid, 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; } |