2 * MPEG2 transport stream (aka DVB) muxer
3 * Copyright (c) 2003 Fabrice Bellard
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "libavutil/bswap.h"
23 #include "libavutil/crc.h"
24 #include "libavcodec/mpegvideo.h"
28 /* write DVB SI sections */
30 /*********************************************/
31 /* mpegts section writer */
33 typedef struct MpegTSSection
{
36 void (*write_packet
)(struct MpegTSSection
*s
, const uint8_t *packet
);
40 typedef struct MpegTSService
{
41 MpegTSSection pmt
; /* MPEG2 pmt table context */
42 int sid
; /* service ID */
47 int pcr_packet_period
;
50 typedef struct MpegTSWrite
{
51 MpegTSSection pat
; /* MPEG2 pat table */
52 MpegTSSection sdt
; /* MPEG2 sdt table context */
53 MpegTSService
**services
;
55 int sdt_packet_period
;
57 int pat_packet_period
;
65 /* NOTE: 4 bytes must be left at the end for the crc32 */
66 static void mpegts_write_section(MpegTSSection
*s
, uint8_t *buf
, int len
)
68 MpegTSWrite
*ts
= ((AVFormatContext
*)s
->opaque
)->priv_data
;
70 unsigned char packet
[TS_PACKET_SIZE
];
71 const unsigned char *buf_ptr
;
73 int first
, b
, len1
, left
;
75 crc
= bswap_32(av_crc(av_crc_get_table(AV_CRC_32_IEEE
), -1, buf
, len
- 4));
76 buf
[len
- 4] = (crc
>> 24) & 0xff;
77 buf
[len
- 3] = (crc
>> 16) & 0xff;
78 buf
[len
- 2] = (crc
>> 8) & 0xff;
79 buf
[len
- 1] = (crc
) & 0xff;
81 /* send each packet */
84 first
= (buf
== buf_ptr
);
93 s
->cc
= (s
->cc
+ 1) & 0xf;
95 *q
++ = 0; /* 0 offset */
96 len1
= TS_PACKET_SIZE
- (q
- packet
);
99 memcpy(q
, buf_ptr
, len1
);
101 /* add known padding data */
102 left
= TS_PACKET_SIZE
- (q
- packet
);
104 memset(q
, 0xff, left
);
106 s
->write_packet(s
, packet
);
111 ts
->cur_pcr
+= TS_PACKET_SIZE
*8*90000LL/ts
->mux_rate
;
115 static inline void put16(uint8_t **q_ptr
, int val
)
124 static int mpegts_write_section1(MpegTSSection
*s
, int tid
, int id
,
125 int version
, int sec_num
, int last_sec_num
,
126 uint8_t *buf
, int len
)
128 uint8_t section
[1024], *q
;
129 unsigned int tot_len
;
131 tot_len
= 3 + 5 + len
+ 4;
132 /* check if not too big */
138 put16(&q
, 0xb000 | (len
+ 5 + 4)); /* 5 byte header + 4 byte CRC */
140 *q
++ = 0xc1 | (version
<< 1); /* current_next_indicator = 1 */
145 mpegts_write_section(s
, section
, tot_len
);
149 /*********************************************/
152 #define DEFAULT_PMT_START_PID 0x1000
153 #define DEFAULT_START_PID 0x0100
154 #define DEFAULT_PROVIDER_NAME "FFmpeg"
155 #define DEFAULT_SERVICE_NAME "Service01"
157 /* default network id, transport stream and service identifiers */
158 #define DEFAULT_ONID 0x0001
159 #define DEFAULT_TSID 0x0001
160 #define DEFAULT_SID 0x0001
162 /* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
163 #define DEFAULT_PES_HEADER_FREQ 16
164 #define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
166 /* we retransmit the SI info at this rate */
167 #define SDT_RETRANS_TIME 500
168 #define PAT_RETRANS_TIME 100
169 #define PCR_RETRANS_TIME 20
171 typedef struct MpegTSWriteStream
{
172 struct MpegTSService
*service
;
173 int pid
; /* stream associated pid */
176 int first_pts_check
; ///< first pts check needed
179 uint8_t payload
[DEFAULT_PES_PAYLOAD_SIZE
];
182 static void mpegts_write_pat(AVFormatContext
*s
)
184 MpegTSWrite
*ts
= s
->priv_data
;
185 MpegTSService
*service
;
186 uint8_t data
[1012], *q
;
190 for(i
= 0; i
< ts
->nb_services
; i
++) {
191 service
= ts
->services
[i
];
192 put16(&q
, service
->sid
);
193 put16(&q
, 0xe000 | service
->pmt
.pid
);
195 mpegts_write_section1(&ts
->pat
, PAT_TID
, ts
->tsid
, 0, 0, 0,
199 static void mpegts_write_pmt(AVFormatContext
*s
, MpegTSService
*service
)
201 // MpegTSWrite *ts = s->priv_data;
202 uint8_t data
[1012], *q
, *desc_length_ptr
, *program_info_length_ptr
;
203 int val
, stream_type
, i
;
206 put16(&q
, 0xe000 | service
->pcr_pid
);
208 program_info_length_ptr
= q
;
209 q
+= 2; /* patched after */
211 /* put program info here */
213 val
= 0xf000 | (q
- program_info_length_ptr
- 2);
214 program_info_length_ptr
[0] = val
>> 8;
215 program_info_length_ptr
[1] = val
;
217 for(i
= 0; i
< s
->nb_streams
; i
++) {
218 AVStream
*st
= s
->streams
[i
];
219 MpegTSWriteStream
*ts_st
= st
->priv_data
;
220 AVMetadataTag
*lang
= av_metadata_get(st
->metadata
, "language", NULL
,0);
221 switch(st
->codec
->codec_id
) {
222 case CODEC_ID_MPEG1VIDEO
:
223 case CODEC_ID_MPEG2VIDEO
:
224 stream_type
= STREAM_TYPE_VIDEO_MPEG2
;
227 stream_type
= STREAM_TYPE_VIDEO_MPEG4
;
230 stream_type
= STREAM_TYPE_VIDEO_H264
;
233 stream_type
= STREAM_TYPE_VIDEO_DIRAC
;
237 stream_type
= STREAM_TYPE_AUDIO_MPEG1
;
240 stream_type
= STREAM_TYPE_AUDIO_AAC
;
243 stream_type
= STREAM_TYPE_AUDIO_AC3
;
246 stream_type
= STREAM_TYPE_PRIVATE_DATA
;
250 put16(&q
, 0xe000 | ts_st
->pid
);
252 q
+= 2; /* patched after */
254 /* write optional descriptors here */
255 switch(st
->codec
->codec_type
) {
256 case CODEC_TYPE_AUDIO
:
257 if (lang
&& strlen(lang
->value
) == 3) {
258 *q
++ = 0x0a; /* ISO 639 language descriptor */
260 *q
++ = lang
->value
[0];
261 *q
++ = lang
->value
[1];
262 *q
++ = lang
->value
[2];
263 *q
++ = 0; /* undefined type */
266 case CODEC_TYPE_SUBTITLE
:
268 const char *language
;
269 language
= lang
&& strlen(lang
->value
)==3 ? lang
->value
: "eng";
275 *q
++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */
276 put16(&q
, 1); /* page id */
277 put16(&q
, 1); /* ancillary page id */
280 case CODEC_TYPE_VIDEO
:
281 if (stream_type
== STREAM_TYPE_VIDEO_DIRAC
) {
282 *q
++ = 0x05; /*MPEG-2 registration descriptor*/
292 val
= 0xf000 | (q
- desc_length_ptr
- 2);
293 desc_length_ptr
[0] = val
>> 8;
294 desc_length_ptr
[1] = val
;
296 mpegts_write_section1(&service
->pmt
, PMT_TID
, service
->sid
, 0, 0, 0,
300 /* NOTE: str == NULL is accepted for an empty string */
301 static void putstr8(uint8_t **q_ptr
, const char *str
)
317 static void mpegts_write_sdt(AVFormatContext
*s
)
319 MpegTSWrite
*ts
= s
->priv_data
;
320 MpegTSService
*service
;
321 uint8_t data
[1012], *q
, *desc_list_len_ptr
, *desc_len_ptr
;
322 int i
, running_status
, free_ca_mode
, val
;
327 for(i
= 0; i
< ts
->nb_services
; i
++) {
328 service
= ts
->services
[i
];
329 put16(&q
, service
->sid
);
330 *q
++ = 0xfc | 0x00; /* currently no EIT info */
331 desc_list_len_ptr
= q
;
333 running_status
= 4; /* running */
336 /* write only one descriptor for the service name and provider */
340 *q
++ = 0x01; /* digital television service */
341 putstr8(&q
, service
->provider_name
);
342 putstr8(&q
, service
->name
);
343 desc_len_ptr
[0] = q
- desc_len_ptr
- 1;
345 /* fill descriptor length */
346 val
= (running_status
<< 13) | (free_ca_mode
<< 12) |
347 (q
- desc_list_len_ptr
- 2);
348 desc_list_len_ptr
[0] = val
>> 8;
349 desc_list_len_ptr
[1] = val
;
351 mpegts_write_section1(&ts
->sdt
, SDT_TID
, ts
->tsid
, 0, 0, 0,
355 static MpegTSService
*mpegts_add_service(MpegTSWrite
*ts
,
357 const char *provider_name
,
360 MpegTSService
*service
;
362 service
= av_mallocz(sizeof(MpegTSService
));
365 service
->pmt
.pid
= DEFAULT_PMT_START_PID
+ ts
->nb_services
- 1;
367 service
->provider_name
= av_strdup(provider_name
);
368 service
->name
= av_strdup(name
);
369 service
->pcr_pid
= 0x1fff;
370 dynarray_add(&ts
->services
, &ts
->nb_services
, service
);
374 static void section_write_packet(MpegTSSection
*s
, const uint8_t *packet
)
376 AVFormatContext
*ctx
= s
->opaque
;
377 put_buffer(ctx
->pb
, packet
, TS_PACKET_SIZE
);
380 static int mpegts_write_header(AVFormatContext
*s
)
382 MpegTSWrite
*ts
= s
->priv_data
;
383 MpegTSWriteStream
*ts_st
;
384 MpegTSService
*service
;
386 AVMetadataTag
*title
;
387 int i
, total_bit_rate
;
388 const char *service_name
;
389 uint64_t sdt_size
, pat_pmt_size
, pos
;
391 ts
->tsid
= DEFAULT_TSID
;
392 ts
->onid
= DEFAULT_ONID
;
393 /* allocate a single DVB service */
394 title
= av_metadata_get(s
->metadata
, "title", NULL
, 0);
395 service_name
= title
? title
->value
: DEFAULT_SERVICE_NAME
;
396 service
= mpegts_add_service(ts
, DEFAULT_SID
,
397 DEFAULT_PROVIDER_NAME
, service_name
);
398 service
->pmt
.write_packet
= section_write_packet
;
399 service
->pmt
.opaque
= s
;
401 ts
->pat
.pid
= PAT_PID
;
403 ts
->pat
.write_packet
= section_write_packet
;
406 ts
->sdt
.pid
= SDT_PID
;
408 ts
->sdt
.write_packet
= section_write_packet
;
411 /* assign pids to each stream */
413 for(i
= 0;i
< s
->nb_streams
; i
++) {
415 ts_st
= av_mallocz(sizeof(MpegTSWriteStream
));
418 st
->priv_data
= ts_st
;
419 ts_st
->service
= service
;
420 ts_st
->pid
= DEFAULT_START_PID
+ i
;
421 ts_st
->payload_pts
= AV_NOPTS_VALUE
;
422 ts_st
->payload_dts
= AV_NOPTS_VALUE
;
423 ts_st
->first_pts_check
= 1;
424 /* update PCR pid by using the first video stream */
425 if (st
->codec
->codec_type
== CODEC_TYPE_VIDEO
&&
426 service
->pcr_pid
== 0x1fff)
427 service
->pcr_pid
= ts_st
->pid
;
428 total_bit_rate
+= st
->codec
->bit_rate
;
429 /* PES header size */
430 if (st
->codec
->codec_type
== CODEC_TYPE_VIDEO
||
431 st
->codec
->codec_type
== CODEC_TYPE_SUBTITLE
)
432 total_bit_rate
+= 25 * 8 / av_q2d(st
->codec
->time_base
);
434 total_bit_rate
+= total_bit_rate
* 25 / DEFAULT_PES_PAYLOAD_SIZE
;
437 /* if no video stream, use the first stream as PCR */
438 if (service
->pcr_pid
== 0x1fff && s
->nb_streams
> 0) {
439 ts_st
= s
->streams
[0]->priv_data
;
440 service
->pcr_pid
= ts_st
->pid
;
443 if (total_bit_rate
<= 8 * 1024)
444 total_bit_rate
= 8 * 1024;
445 service
->pcr_packet_period
= (total_bit_rate
* PCR_RETRANS_TIME
) /
446 (TS_PACKET_SIZE
* 8 * 1000);
447 ts
->sdt_packet_period
= (total_bit_rate
* SDT_RETRANS_TIME
) /
448 (TS_PACKET_SIZE
* 8 * 1000);
449 ts
->pat_packet_period
= (total_bit_rate
* PAT_RETRANS_TIME
) /
450 (TS_PACKET_SIZE
* 8 * 1000);
452 ts
->mux_rate
= 1; // avoid div by 0
454 /* write info at the start of the file, so that it will be fast to
456 pos
= url_ftell(s
->pb
);
458 sdt_size
= url_ftell(s
->pb
) - pos
;
459 pos
= url_ftell(s
->pb
);
461 for(i
= 0; i
< ts
->nb_services
; i
++) {
462 mpegts_write_pmt(s
, ts
->services
[i
]);
464 pat_pmt_size
= url_ftell(s
->pb
) - pos
;
467 total_bit_rate
* 4 / TS_PACKET_SIZE
+ /* TS header size */
468 SDT_RETRANS_TIME
* 8 * sdt_size
/ 1000 + /* SDT size */
469 PAT_RETRANS_TIME
* 8 * pat_pmt_size
/ 1000 + /* PAT+PMT size */
470 PCR_RETRANS_TIME
* 8 * 8 / 1000; /* PCR size */
472 av_log(s
, AV_LOG_DEBUG
, "muxrate %d freq sdt %d pat %d\n",
473 total_bit_rate
, ts
->sdt_packet_period
, ts
->pat_packet_period
);
476 ts
->mux_rate
= s
->mux_rate
;
478 ts
->mux_rate
= total_bit_rate
;
481 ts
->cur_pcr
/= ts
->mux_rate
;
483 put_flush_packet(s
->pb
);
488 for(i
= 0;i
< s
->nb_streams
; i
++) {
490 av_free(st
->priv_data
);
495 /* send SDT, PAT and PMT tables regulary */
496 static void retransmit_si_info(AVFormatContext
*s
)
498 MpegTSWrite
*ts
= s
->priv_data
;
501 if (++ts
->sdt_packet_count
== ts
->sdt_packet_period
) {
502 ts
->sdt_packet_count
= 0;
505 if (++ts
->pat_packet_count
== ts
->pat_packet_period
) {
506 ts
->pat_packet_count
= 0;
508 for(i
= 0; i
< ts
->nb_services
; i
++) {
509 mpegts_write_pmt(s
, ts
->services
[i
]);
514 static void write_pts(uint8_t *q
, int fourbits
, int64_t pts
)
518 val
= fourbits
<< 4 | (((pts
>> 30) & 0x07) << 1) | 1;
520 val
= (((pts
>> 15) & 0x7fff) << 1) | 1;
523 val
= (((pts
) & 0x7fff) << 1) | 1;
528 /* NOTE: pes_data contains all the PES packet */
529 static void mpegts_write_pes(AVFormatContext
*s
, AVStream
*st
,
530 const uint8_t *payload
, int payload_size
,
531 int64_t pts
, int64_t dts
)
533 MpegTSWriteStream
*ts_st
= st
->priv_data
;
534 MpegTSWrite
*ts
= s
->priv_data
;
535 uint8_t buf
[TS_PACKET_SIZE
];
537 int val
, is_start
, len
, header_len
, write_pcr
, private_code
, flags
;
538 int afc_len
, stuffing_len
;
539 int64_t pcr
= -1; /* avoid warning */
542 while (payload_size
> 0) {
543 retransmit_si_info(s
);
546 if (ts_st
->pid
== ts_st
->service
->pcr_pid
) {
547 ts_st
->service
->pcr_packet_count
++;
548 if (ts_st
->service
->pcr_packet_count
>=
549 ts_st
->service
->pcr_packet_period
) {
550 ts_st
->service
->pcr_packet_count
= 0;
555 /* prepare packet header */
558 val
= (ts_st
->pid
>> 8);
563 *q
++ = 0x10 | ts_st
->cc
| (write_pcr
? 0x20 : 0);
564 ts_st
->cc
= (ts_st
->cc
+ 1) & 0xf;
566 // add 11, pcr references the last byte of program clock reference base
567 pcr
= ts
->cur_pcr
+ (4+7)*8*90000LL / ts
->mux_rate
;
568 if (dts
!= AV_NOPTS_VALUE
&& dts
< pcr
)
569 av_log(s
, AV_LOG_WARNING
, "dts < pcr, TS is invalid\n");
570 *q
++ = 7; /* AFC length */
571 *q
++ = 0x10; /* flags: PCR present */
576 *q
++ = (pcr
& 1) << 7;
580 int pes_extension
= 0;
581 /* write PES header */
586 if (st
->codec
->codec_type
== CODEC_TYPE_VIDEO
) {
587 if (st
->codec
->codec_id
== CODEC_ID_DIRAC
) {
591 } else if (st
->codec
->codec_type
== CODEC_TYPE_AUDIO
&&
592 (st
->codec
->codec_id
== CODEC_ID_MP2
||
593 st
->codec
->codec_id
== CODEC_ID_MP3
)) {
597 if (st
->codec
->codec_type
== CODEC_TYPE_SUBTITLE
) {
603 if (pts
!= AV_NOPTS_VALUE
) {
607 if (dts
!= AV_NOPTS_VALUE
&& pts
!= AV_NOPTS_VALUE
&& dts
!= pts
) {
611 if (st
->codec
->codec_type
== CODEC_TYPE_VIDEO
&&
612 st
->codec
->codec_id
== CODEC_ID_DIRAC
) {
613 /* set PES_extension_flag */
618 * One byte for PES2 extension flag +
619 * one byte for extension length +
620 * one byte for extension id
624 len
= payload_size
+ header_len
+ 3;
625 if (private_code
!= 0)
632 /* data alignment indicator is required for subtitle data */
633 if (st
->codec
->codec_type
== CODEC_TYPE_SUBTITLE
)
638 if (pts
!= AV_NOPTS_VALUE
) {
639 write_pts(q
, flags
>> 6, pts
);
642 if (dts
!= AV_NOPTS_VALUE
&& pts
!= AV_NOPTS_VALUE
&& dts
!= pts
) {
643 write_pts(q
, 1, dts
);
646 if (pes_extension
&& st
->codec
->codec_id
== CODEC_ID_DIRAC
) {
647 flags
= 0x01; /* set PES_extension_flag_2 */
649 *q
++ = 0x80 | 0x01; /* marker bit + extension length */
651 * Set the stream id extension flag bit to 0 and
652 * write the extended stream id
656 if (private_code
!= 0)
661 header_len
= q
- buf
;
663 len
= TS_PACKET_SIZE
- header_len
;
664 if (len
> payload_size
)
666 stuffing_len
= TS_PACKET_SIZE
- header_len
- len
;
667 if (stuffing_len
> 0) {
668 /* add stuffing with AFC */
670 /* stuffing already present: increase its size */
671 afc_len
= buf
[4] + 1;
672 memmove(buf
+ 4 + afc_len
+ stuffing_len
,
674 header_len
- (4 + afc_len
));
675 buf
[4] += stuffing_len
;
676 memset(buf
+ 4 + afc_len
, 0xff, stuffing_len
);
679 memmove(buf
+ 4 + stuffing_len
, buf
+ 4, header_len
- 4);
681 buf
[4] = stuffing_len
- 1;
682 if (stuffing_len
>= 2) {
684 memset(buf
+ 6, 0xff, stuffing_len
- 2);
688 memcpy(buf
+ TS_PACKET_SIZE
- len
, payload
, len
);
691 put_buffer(s
->pb
, buf
, TS_PACKET_SIZE
);
692 ts
->cur_pcr
+= TS_PACKET_SIZE
*8*90000LL/ts
->mux_rate
;
694 put_flush_packet(s
->pb
);
697 static int mpegts_write_packet(AVFormatContext
*s
, AVPacket
*pkt
)
699 AVStream
*st
= s
->streams
[pkt
->stream_index
];
700 int len
, size
= pkt
->size
;
701 uint8_t *buf
= pkt
->data
;
703 MpegTSWriteStream
*ts_st
= st
->priv_data
;
704 const uint64_t delay
= av_rescale(s
->max_delay
, 90000, AV_TIME_BASE
);
705 int64_t dts
= AV_NOPTS_VALUE
, pts
= AV_NOPTS_VALUE
;
707 if (pkt
->pts
!= AV_NOPTS_VALUE
)
708 pts
= pkt
->pts
+ delay
;
709 if (pkt
->dts
!= AV_NOPTS_VALUE
)
710 dts
= pkt
->dts
+ delay
;
712 if (ts_st
->first_pts_check
&& pts
== AV_NOPTS_VALUE
) {
713 av_log(s
, AV_LOG_ERROR
, "first pts value must set\n");
716 ts_st
->first_pts_check
= 0;
718 if (st
->codec
->codec_id
== CODEC_ID_H264
) {
719 if (pkt
->size
< 5 || AV_RB32(pkt
->data
) != 0x0000001) {
720 av_log(s
, AV_LOG_ERROR
, "h264 bitstream malformated\n");
723 if (pkt
->data
[4] != 0x09) { // AUD NAL
724 data
= av_malloc(pkt
->size
+6);
727 memcpy(data
+6, pkt
->data
, pkt
->size
);
728 AV_WB32(data
, 0x00000001);
730 data
[5] = 0xe0; // any slice type
736 if (st
->codec
->codec_type
== CODEC_TYPE_SUBTITLE
||
737 st
->codec
->codec_type
== CODEC_TYPE_VIDEO
) {
738 // for video and subtitle, write a single pes packet
739 mpegts_write_pes(s
, st
, buf
, size
, pts
, dts
);
744 if (ts_st
->payload_pts
== AV_NOPTS_VALUE
) {
745 ts_st
->payload_dts
= dts
;
746 ts_st
->payload_pts
= pts
;
751 len
= DEFAULT_PES_PAYLOAD_SIZE
- ts_st
->payload_index
;
754 memcpy(ts_st
->payload
+ ts_st
->payload_index
, buf
, len
);
757 ts_st
->payload_index
+= len
;
758 if (ts_st
->payload_index
>= DEFAULT_PES_PAYLOAD_SIZE
) {
759 mpegts_write_pes(s
, st
, ts_st
->payload
, ts_st
->payload_index
,
760 ts_st
->payload_pts
, ts_st
->payload_dts
);
761 ts_st
->payload_pts
= AV_NOPTS_VALUE
;
762 ts_st
->payload_dts
= AV_NOPTS_VALUE
;
763 ts_st
->payload_index
= 0;
770 static int mpegts_write_end(AVFormatContext
*s
)
772 MpegTSWrite
*ts
= s
->priv_data
;
773 MpegTSWriteStream
*ts_st
;
774 MpegTSService
*service
;
778 /* flush current packets */
779 for(i
= 0; i
< s
->nb_streams
; i
++) {
781 ts_st
= st
->priv_data
;
782 if (ts_st
->payload_index
> 0) {
783 mpegts_write_pes(s
, st
, ts_st
->payload
, ts_st
->payload_index
,
784 ts_st
->payload_pts
, ts_st
->payload_dts
);
787 put_flush_packet(s
->pb
);
789 for(i
= 0; i
< ts
->nb_services
; i
++) {
790 service
= ts
->services
[i
];
791 av_freep(&service
->provider_name
);
792 av_freep(&service
->name
);
795 av_free(ts
->services
);
800 AVOutputFormat mpegts_muxer
= {
802 NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"),