Mercurial > libavformat.hg
annotate mpegtsenc.c @ 5397:6016c9643d95 libavformat
slif aka "SoftLab MPEG-2 I-frames Codec" support.
Flipping one bit still is popular it seems as a means to create a new codec.
fixes issue1469.
author | michael |
---|---|
date | Tue, 01 Dec 2009 02:07:46 +0000 |
parents | 95a0faec0218 |
children | 7c8ef3adb42e |
rev | line source |
---|---|
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
1 /* |
1415
3b00fb8ef8e4
replace coder/decoder file description in libavformat by muxer/demuxer
aurel
parents:
1358
diff
changeset
|
2 * MPEG2 transport stream (aka DVB) muxer |
4251
77e0c7511d41
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
4220
diff
changeset
|
3 * Copyright (c) 2003 Fabrice Bellard |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
4 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
5 * This file is part of FFmpeg. |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
6 * |
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
11 * |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
16 * |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
1358
0899bfe4105c
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
1169
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
887
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
20 */ |
3286 | 21 |
4201
7d2f3f1b68d8
Fix build: Add intreadwrite.h and bswap.h #includes where necessary.
diego
parents:
3719
diff
changeset
|
22 #include "libavutil/bswap.h" |
3286 | 23 #include "libavutil/crc.h" |
4211
5e5654752973
set pts and dts of pes packets exactly according to specs
bcoudurier
parents:
4209
diff
changeset
|
24 #include "libavcodec/mpegvideo.h" |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
25 #include "avformat.h" |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
26 #include "mpegts.h" |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
27 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
28 /* write DVB SI sections */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
29 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
30 /*********************************************/ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
31 /* mpegts section writer */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
32 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
33 typedef struct MpegTSSection { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
34 int pid; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
35 int cc; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
36 void (*write_packet)(struct MpegTSSection *s, const uint8_t *packet); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
37 void *opaque; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
38 } MpegTSSection; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
39 |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
40 typedef struct MpegTSService { |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
41 MpegTSSection pmt; /* MPEG2 pmt table context */ |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
42 int sid; /* service ID */ |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
43 char *name; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
44 char *provider_name; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
45 int pcr_pid; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
46 int pcr_packet_count; |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
47 int pcr_packet_period; |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
48 } MpegTSService; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
49 |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
50 typedef struct MpegTSWrite { |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
51 MpegTSSection pat; /* MPEG2 pat table */ |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
52 MpegTSSection sdt; /* MPEG2 sdt table context */ |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
53 MpegTSService **services; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
54 int sdt_packet_count; |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
55 int sdt_packet_period; |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
56 int pat_packet_count; |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
57 int pat_packet_period; |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
58 int nb_services; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
59 int onid; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
60 int tsid; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
61 uint64_t cur_pcr; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
62 int mux_rate; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
63 } MpegTSWrite; |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
64 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
65 /* NOTE: 4 bytes must be left at the end for the crc32 */ |
1124
d3aff2c607f9
Add const to (mostly) char* and make some functions static, which aren't used
diego
parents:
996
diff
changeset
|
66 static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
67 { |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
68 MpegTSWrite *ts = ((AVFormatContext*)s->opaque)->priv_data; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
69 unsigned int crc; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
70 unsigned char packet[TS_PACKET_SIZE]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
71 const unsigned char *buf_ptr; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
72 unsigned char *q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
73 int first, b, len1, left; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
74 |
2893 | 75 crc = bswap_32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, buf, len - 4)); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
76 buf[len - 4] = (crc >> 24) & 0xff; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
77 buf[len - 3] = (crc >> 16) & 0xff; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
78 buf[len - 2] = (crc >> 8) & 0xff; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
79 buf[len - 1] = (crc) & 0xff; |
885 | 80 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
81 /* send each packet */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
82 buf_ptr = buf; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
83 while (len > 0) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
84 first = (buf == buf_ptr); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
85 q = packet; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
86 *q++ = 0x47; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
87 b = (s->pid >> 8); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
88 if (first) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
89 b |= 0x40; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
90 *q++ = b; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
91 *q++ = s->pid; |
3419 | 92 *q++ = 0x10 | s->cc; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
93 s->cc = (s->cc + 1) & 0xf; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
94 if (first) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
95 *q++ = 0; /* 0 offset */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
96 len1 = TS_PACKET_SIZE - (q - packet); |
885 | 97 if (len1 > len) |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
98 len1 = len; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
99 memcpy(q, buf_ptr, len1); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
100 q += len1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
101 /* add known padding data */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
102 left = TS_PACKET_SIZE - (q - packet); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
103 if (left > 0) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
104 memset(q, 0xff, left); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
105 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
106 s->write_packet(s, packet); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
107 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
108 buf_ptr += len1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
109 len -= len1; |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
110 |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
111 ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
112 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
113 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
114 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
115 static inline void put16(uint8_t **q_ptr, int val) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
116 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
117 uint8_t *q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
118 q = *q_ptr; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
119 *q++ = val >> 8; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
120 *q++ = val; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
121 *q_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
122 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
123 |
1124
d3aff2c607f9
Add const to (mostly) char* and make some functions static, which aren't used
diego
parents:
996
diff
changeset
|
124 static int mpegts_write_section1(MpegTSSection *s, int tid, int id, |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
125 int version, int sec_num, int last_sec_num, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
126 uint8_t *buf, int len) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
127 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
128 uint8_t section[1024], *q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
129 unsigned int tot_len; |
885 | 130 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
131 tot_len = 3 + 5 + len + 4; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
132 /* check if not too big */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
133 if (tot_len > 1024) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
134 return -1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
135 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
136 q = section; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
137 *q++ = tid; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
138 put16(&q, 0xb000 | (len + 5 + 4)); /* 5 byte header + 4 byte CRC */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
139 put16(&q, id); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
140 *q++ = 0xc1 | (version << 1); /* current_next_indicator = 1 */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
141 *q++ = sec_num; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
142 *q++ = last_sec_num; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
143 memcpy(q, buf, len); |
885 | 144 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
145 mpegts_write_section(s, section, tot_len); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
146 return 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
147 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
148 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
149 /*********************************************/ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
150 /* mpegts writer */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
151 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
152 #define DEFAULT_PMT_START_PID 0x1000 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
153 #define DEFAULT_START_PID 0x0100 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
154 #define DEFAULT_PROVIDER_NAME "FFmpeg" |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
155 #define DEFAULT_SERVICE_NAME "Service01" |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
156 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
157 /* default network id, transport stream and service identifiers */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
158 #define DEFAULT_ONID 0x0001 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
159 #define DEFAULT_TSID 0x0001 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
160 #define DEFAULT_SID 0x0001 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
161 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
162 /* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
163 #define DEFAULT_PES_HEADER_FREQ 16 |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
164 #define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170) |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
165 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
166 /* we retransmit the SI info at this rate */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
167 #define SDT_RETRANS_TIME 500 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
168 #define PAT_RETRANS_TIME 100 |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
169 #define PCR_RETRANS_TIME 20 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
170 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
171 typedef struct MpegTSWriteStream { |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
172 struct MpegTSService *service; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
173 int pid; /* stream associated pid */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
174 int cc; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
175 int payload_index; |
4915 | 176 int first_pts_check; ///< first pts check needed |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
177 int64_t payload_pts; |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
178 int64_t payload_dts; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
179 uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE]; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
180 } MpegTSWriteStream; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
181 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
182 static void mpegts_write_pat(AVFormatContext *s) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
183 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
184 MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
185 MpegTSService *service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
186 uint8_t data[1012], *q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
187 int i; |
885 | 188 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
189 q = data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
190 for(i = 0; i < ts->nb_services; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
191 service = ts->services[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
192 put16(&q, service->sid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
193 put16(&q, 0xe000 | service->pmt.pid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
194 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
195 mpegts_write_section1(&ts->pat, PAT_TID, ts->tsid, 0, 0, 0, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
196 data, q - data); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
197 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
198 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
199 static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
200 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
201 // MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
202 uint8_t data[1012], *q, *desc_length_ptr, *program_info_length_ptr; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
203 int val, stream_type, i; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
204 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
205 q = data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
206 put16(&q, 0xe000 | service->pcr_pid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
207 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
208 program_info_length_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
209 q += 2; /* patched after */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
210 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
211 /* put program info here */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
212 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
213 val = 0xf000 | (q - program_info_length_ptr - 2); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
214 program_info_length_ptr[0] = val >> 8; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
215 program_info_length_ptr[1] = val; |
885 | 216 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
217 for(i = 0; i < s->nb_streams; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
218 AVStream *st = s->streams[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
219 MpegTSWriteStream *ts_st = st->priv_data; |
4525 | 220 AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL,0); |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
221 switch(st->codec->codec_id) { |
313
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
222 case CODEC_ID_MPEG1VIDEO: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
223 case CODEC_ID_MPEG2VIDEO: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
224 stream_type = STREAM_TYPE_VIDEO_MPEG2; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
225 break; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
226 case CODEC_ID_MPEG4: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
227 stream_type = STREAM_TYPE_VIDEO_MPEG4; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
228 break; |
313
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
229 case CODEC_ID_H264: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
230 stream_type = STREAM_TYPE_VIDEO_H264; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
231 break; |
3716 | 232 case CODEC_ID_DIRAC: |
233 stream_type = STREAM_TYPE_VIDEO_DIRAC; | |
234 break; | |
313
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
235 case CODEC_ID_MP2: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
236 case CODEC_ID_MP3: |
160
9bde37b1a5ce
try to filter _all_ PATs if no SDT could be found patch by (<gbazin at altern dot org>)
michaelni
parents:
152
diff
changeset
|
237 stream_type = STREAM_TYPE_AUDIO_MPEG1; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
238 break; |
313
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
239 case CODEC_ID_AAC: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
240 stream_type = STREAM_TYPE_AUDIO_AAC; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
241 break; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
242 case CODEC_ID_AC3: |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
243 stream_type = STREAM_TYPE_AUDIO_AC3; |
622892a75ddb
support more codecs in MPEG-TS patch by (mru at kth dot se (M«©ns Rullg«©rd))
michael
parents:
250
diff
changeset
|
244 break; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
245 default: |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
246 stream_type = STREAM_TYPE_PRIVATE_DATA; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
247 break; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
248 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
249 *q++ = stream_type; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
250 put16(&q, 0xe000 | ts_st->pid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
251 desc_length_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
252 q += 2; /* patched after */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
253 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
254 /* write optional descriptors here */ |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
255 switch(st->codec->codec_type) { |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
256 case CODEC_TYPE_AUDIO: |
4525 | 257 if (lang && strlen(lang->value) == 3) { |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
258 *q++ = 0x0a; /* ISO 639 language descriptor */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
259 *q++ = 4; |
4525 | 260 *q++ = lang->value[0]; |
261 *q++ = lang->value[1]; | |
262 *q++ = lang->value[2]; | |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
263 *q++ = 0; /* undefined type */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
264 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
265 break; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
266 case CODEC_TYPE_SUBTITLE: |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
267 { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
268 const char *language; |
4525 | 269 language = lang && strlen(lang->value)==3 ? lang->value : "eng"; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
270 *q++ = 0x59; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
271 *q++ = 8; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
272 *q++ = language[0]; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
273 *q++ = language[1]; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
274 *q++ = language[2]; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
275 *q++ = 0x10; /* normal subtitles (0x20 = if hearing pb) */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
276 put16(&q, 1); /* page id */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
277 put16(&q, 1); /* ancillary page id */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
278 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
279 break; |
3716 | 280 case CODEC_TYPE_VIDEO: |
281 if (stream_type == STREAM_TYPE_VIDEO_DIRAC) { | |
282 *q++ = 0x05; /*MPEG-2 registration descriptor*/ | |
283 *q++ = 4; | |
284 *q++ = 'd'; | |
285 *q++ = 'r'; | |
286 *q++ = 'a'; | |
287 *q++ = 'c'; | |
288 } | |
289 break; | |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
290 } |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
291 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
292 val = 0xf000 | (q - desc_length_ptr - 2); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
293 desc_length_ptr[0] = val >> 8; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
294 desc_length_ptr[1] = val; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
295 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
296 mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
297 data, q - data); |
885 | 298 } |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
299 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
300 /* NOTE: str == NULL is accepted for an empty string */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
301 static void putstr8(uint8_t **q_ptr, const char *str) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
302 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
303 uint8_t *q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
304 int len; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
305 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
306 q = *q_ptr; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
307 if (!str) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
308 len = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
309 else |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
310 len = strlen(str); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
311 *q++ = len; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
312 memcpy(q, str, len); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
313 q += len; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
314 *q_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
315 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
316 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
317 static void mpegts_write_sdt(AVFormatContext *s) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
318 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
319 MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
320 MpegTSService *service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
321 uint8_t data[1012], *q, *desc_list_len_ptr, *desc_len_ptr; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
322 int i, running_status, free_ca_mode, val; |
885 | 323 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
324 q = data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
325 put16(&q, ts->onid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
326 *q++ = 0xff; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
327 for(i = 0; i < ts->nb_services; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
328 service = ts->services[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
329 put16(&q, service->sid); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
330 *q++ = 0xfc | 0x00; /* currently no EIT info */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
331 desc_list_len_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
332 q += 2; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
333 running_status = 4; /* running */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
334 free_ca_mode = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
335 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
336 /* write only one descriptor for the service name and provider */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
337 *q++ = 0x48; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
338 desc_len_ptr = q; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
339 q++; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
340 *q++ = 0x01; /* digital television service */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
341 putstr8(&q, service->provider_name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
342 putstr8(&q, service->name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
343 desc_len_ptr[0] = q - desc_len_ptr - 1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
344 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
345 /* fill descriptor length */ |
885 | 346 val = (running_status << 13) | (free_ca_mode << 12) | |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
347 (q - desc_list_len_ptr - 2); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
348 desc_list_len_ptr[0] = val >> 8; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
349 desc_list_len_ptr[1] = val; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
350 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
351 mpegts_write_section1(&ts->sdt, SDT_TID, ts->tsid, 0, 0, 0, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
352 data, q - data); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
353 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
354 |
885 | 355 static MpegTSService *mpegts_add_service(MpegTSWrite *ts, |
356 int sid, | |
357 const char *provider_name, | |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
358 const char *name) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
359 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
360 MpegTSService *service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
361 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
362 service = av_mallocz(sizeof(MpegTSService)); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
363 if (!service) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
364 return NULL; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
365 service->pmt.pid = DEFAULT_PMT_START_PID + ts->nb_services - 1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
366 service->sid = sid; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
367 service->provider_name = av_strdup(provider_name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
368 service->name = av_strdup(name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
369 service->pcr_pid = 0x1fff; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
370 dynarray_add(&ts->services, &ts->nb_services, service); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
371 return service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
372 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
373 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
374 static void section_write_packet(MpegTSSection *s, const uint8_t *packet) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
375 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
376 AVFormatContext *ctx = s->opaque; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
1838
diff
changeset
|
377 put_buffer(ctx->pb, packet, TS_PACKET_SIZE); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
378 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
379 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
380 static int mpegts_write_header(AVFormatContext *s) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
381 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
382 MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
383 MpegTSWriteStream *ts_st; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
384 MpegTSService *service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
385 AVStream *st; |
4525 | 386 AVMetadataTag *title; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
387 int i, total_bit_rate; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
388 const char *service_name; |
4216
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
389 uint64_t sdt_size, pat_pmt_size, pos; |
885 | 390 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
391 ts->tsid = DEFAULT_TSID; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
392 ts->onid = DEFAULT_ONID; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
393 /* allocate a single DVB service */ |
4525 | 394 title = av_metadata_get(s->metadata, "title", NULL, 0); |
395 service_name = title ? title->value : DEFAULT_SERVICE_NAME; | |
885 | 396 service = mpegts_add_service(ts, DEFAULT_SID, |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
397 DEFAULT_PROVIDER_NAME, service_name); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
398 service->pmt.write_packet = section_write_packet; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
399 service->pmt.opaque = s; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
400 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
401 ts->pat.pid = PAT_PID; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
402 ts->pat.cc = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
403 ts->pat.write_packet = section_write_packet; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
404 ts->pat.opaque = s; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
405 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
406 ts->sdt.pid = SDT_PID; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
407 ts->sdt.cc = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
408 ts->sdt.write_packet = section_write_packet; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
409 ts->sdt.opaque = s; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
410 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
411 /* assign pids to each stream */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
412 total_bit_rate = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
413 for(i = 0;i < s->nb_streams; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
414 st = s->streams[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
415 ts_st = av_mallocz(sizeof(MpegTSWriteStream)); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
416 if (!ts_st) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
417 goto fail; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
418 st->priv_data = ts_st; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
419 ts_st->service = service; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
420 ts_st->pid = DEFAULT_START_PID + i; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
421 ts_st->payload_pts = AV_NOPTS_VALUE; |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
422 ts_st->payload_dts = AV_NOPTS_VALUE; |
4915 | 423 ts_st->first_pts_check = 1; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
424 /* update PCR pid by using the first video stream */ |
885 | 425 if (st->codec->codec_type == CODEC_TYPE_VIDEO && |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
426 service->pcr_pid == 0x1fff) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
427 service->pcr_pid = ts_st->pid; |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
428 total_bit_rate += st->codec->bit_rate; |
4951
a9842f362bbb
compute total bitrate more accurately, patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4922
diff
changeset
|
429 /* PES header size */ |
a9842f362bbb
compute total bitrate more accurately, patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4922
diff
changeset
|
430 if (st->codec->codec_type == CODEC_TYPE_VIDEO || |
5219
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
431 st->codec->codec_type == CODEC_TYPE_SUBTITLE) { |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
432 /* 1 PES per frame |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
433 * 19 bytes of PES header |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
434 * on average a half TS-packet (184/2) of padding-overhead every PES */ |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
435 total_bit_rate += (19 + 184/2)*8 / av_q2d(st->codec->time_base); |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
436 } else { |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
437 /* 1 PES per DEFAULT_PES_PAYLOAD_SIZE bytes of audio data |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
438 * 14 bytes of PES header |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
439 * on average a half TS-packet (184/2) of padding-overhead every PES */ |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
440 total_bit_rate += (14 + 184/2) * |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
441 st->codec->bit_rate / DEFAULT_PES_PAYLOAD_SIZE; |
583eb737b1c4
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
bcoudurier
parents:
5115
diff
changeset
|
442 } |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
443 } |
885 | 444 |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
445 /* if no video stream, use the first stream as PCR */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
446 if (service->pcr_pid == 0x1fff && s->nb_streams > 0) { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
447 ts_st = s->streams[0]->priv_data; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
448 service->pcr_pid = ts_st->pid; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
449 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
450 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
451 if (total_bit_rate <= 8 * 1024) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
452 total_bit_rate = 8 * 1024; |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
453 service->pcr_packet_period = (total_bit_rate * PCR_RETRANS_TIME) / |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
454 (TS_PACKET_SIZE * 8 * 1000); |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
455 ts->sdt_packet_period = (total_bit_rate * SDT_RETRANS_TIME) / |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
456 (TS_PACKET_SIZE * 8 * 1000); |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
457 ts->pat_packet_period = (total_bit_rate * PAT_RETRANS_TIME) / |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
458 (TS_PACKET_SIZE * 8 * 1000); |
4216
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
459 |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
460 ts->mux_rate = 1; // avoid div by 0 |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
461 |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
462 /* write info at the start of the file, so that it will be fast to |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
463 find them */ |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
464 pos = url_ftell(s->pb); |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
465 mpegts_write_sdt(s); |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
466 sdt_size = url_ftell(s->pb) - pos; |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
467 pos = url_ftell(s->pb); |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
468 mpegts_write_pat(s); |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
469 for(i = 0; i < ts->nb_services; i++) { |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
470 mpegts_write_pmt(s, ts->services[i]); |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
471 } |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
472 pat_pmt_size = url_ftell(s->pb) - pos; |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
473 |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
474 total_bit_rate += |
4912
f718560a7763
fix total bitrate computation, based on patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4525
diff
changeset
|
475 total_bit_rate * 4 / TS_PACKET_SIZE + /* TS header size */ |
f718560a7763
fix total bitrate computation, based on patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4525
diff
changeset
|
476 SDT_RETRANS_TIME * 8 * sdt_size / 1000 + /* SDT size */ |
f718560a7763
fix total bitrate computation, based on patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4525
diff
changeset
|
477 PAT_RETRANS_TIME * 8 * pat_pmt_size / 1000 + /* PAT+PMT size */ |
f718560a7763
fix total bitrate computation, based on patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4525
diff
changeset
|
478 PCR_RETRANS_TIME * 8 * 8 / 1000; /* PCR size */ |
4216
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
479 |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
480 av_log(s, AV_LOG_DEBUG, "muxrate %d freq sdt %d pat %d\n", |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
481 total_bit_rate, ts->sdt_packet_period, ts->pat_packet_period); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
482 |
4215 | 483 if (s->mux_rate) |
484 ts->mux_rate = s->mux_rate; | |
485 else | |
486 ts->mux_rate = total_bit_rate; | |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
487 |
4216
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
488 // adjust pcr |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
489 ts->cur_pcr /= ts->mux_rate; |
de2177071c01
calculate pat, pmt and sdt exact size and adjust total bitrate
bcoudurier
parents:
4215
diff
changeset
|
490 |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
1838
diff
changeset
|
491 put_flush_packet(s->pb); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
492 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
493 return 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
494 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
495 fail: |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
496 for(i = 0;i < s->nb_streams; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
497 st = s->streams[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
498 av_free(st->priv_data); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
499 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
500 return -1; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
501 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
502 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
503 /* send SDT, PAT and PMT tables regulary */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
504 static void retransmit_si_info(AVFormatContext *s) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
505 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
506 MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
507 int i; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
508 |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
509 if (++ts->sdt_packet_count == ts->sdt_packet_period) { |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
510 ts->sdt_packet_count = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
511 mpegts_write_sdt(s); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
512 } |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
513 if (++ts->pat_packet_count == ts->pat_packet_period) { |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
514 ts->pat_packet_count = 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
515 mpegts_write_pat(s); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
516 for(i = 0; i < ts->nb_services; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
517 mpegts_write_pmt(s, ts->services[i]); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
518 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
519 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
520 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
521 |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
522 static void write_pts(uint8_t *q, int fourbits, int64_t pts) |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
523 { |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
524 int val; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
525 |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
526 val = fourbits << 4 | (((pts >> 30) & 0x07) << 1) | 1; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
527 *q++ = val; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
528 val = (((pts >> 15) & 0x7fff) << 1) | 1; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
529 *q++ = val >> 8; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
530 *q++ = val; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
531 val = (((pts) & 0x7fff) << 1) | 1; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
532 *q++ = val >> 8; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
533 *q++ = val; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
534 } |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
535 |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
536 /* NOTE: pes_data contains all the PES packet */ |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
537 static void mpegts_write_pes(AVFormatContext *s, AVStream *st, |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
538 const uint8_t *payload, int payload_size, |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
539 int64_t pts, int64_t dts) |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
540 { |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
541 MpegTSWriteStream *ts_st = st->priv_data; |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
542 MpegTSWrite *ts = s->priv_data; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
543 uint8_t buf[TS_PACKET_SIZE]; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
544 uint8_t *q; |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
545 int val, is_start, len, header_len, write_pcr, private_code, flags; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
546 int afc_len, stuffing_len; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
547 int64_t pcr = -1; /* avoid warning */ |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
548 |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
549 is_start = 1; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
550 while (payload_size > 0) { |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
551 retransmit_si_info(s); |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
552 |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
553 write_pcr = 0; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
554 if (ts_st->pid == ts_st->service->pcr_pid) { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
555 ts_st->service->pcr_packet_count++; |
885 | 556 if (ts_st->service->pcr_packet_count >= |
5115
640c875b3bfe
rename freq to period which is more correct, patch by Niobos, niobos dot be at gmail dot com
bcoudurier
parents:
4952
diff
changeset
|
557 ts_st->service->pcr_packet_period) { |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
558 ts_st->service->pcr_packet_count = 0; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
559 write_pcr = 1; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
560 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
561 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
562 |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
563 /* prepare packet header */ |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
564 q = buf; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
565 *q++ = 0x47; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
566 val = (ts_st->pid >> 8); |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
567 if (is_start) |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
568 val |= 0x40; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
569 *q++ = val; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
570 *q++ = ts_st->pid; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
571 *q++ = 0x10 | ts_st->cc | (write_pcr ? 0x20 : 0); |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
572 ts_st->cc = (ts_st->cc + 1) & 0xf; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
573 if (write_pcr) { |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
574 // add 11, pcr references the last byte of program clock reference base |
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
575 pcr = ts->cur_pcr + (4+7)*8*90000LL / ts->mux_rate; |
4214 | 576 if (dts != AV_NOPTS_VALUE && dts < pcr) |
577 av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n"); | |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
578 *q++ = 7; /* AFC length */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
579 *q++ = 0x10; /* flags: PCR present */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
580 *q++ = pcr >> 25; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
581 *q++ = pcr >> 17; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
582 *q++ = pcr >> 9; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
583 *q++ = pcr >> 1; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
584 *q++ = (pcr & 1) << 7; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
585 *q++ = 0; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
586 } |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
587 if (is_start) { |
3716 | 588 int pes_extension = 0; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
589 /* write PES header */ |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
590 *q++ = 0x00; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
591 *q++ = 0x00; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
592 *q++ = 0x01; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
593 private_code = 0; |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
594 if (st->codec->codec_type == CODEC_TYPE_VIDEO) { |
3716 | 595 if (st->codec->codec_id == CODEC_ID_DIRAC) { |
596 *q++ = 0xfd; | |
597 } else | |
598 *q++ = 0xe0; | |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
599 } else if (st->codec->codec_type == CODEC_TYPE_AUDIO && |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
600 (st->codec->codec_id == CODEC_ID_MP2 || |
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
601 st->codec->codec_id == CODEC_ID_MP3)) { |
885 | 602 *q++ = 0xc0; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
603 } else { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
604 *q++ = 0xbd; |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
605 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) { |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
606 private_code = 0x20; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
607 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
608 } |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
609 header_len = 0; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
610 flags = 0; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
611 if (pts != AV_NOPTS_VALUE) { |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
612 header_len += 5; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
613 flags |= 0x80; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
614 } |
4913 | 615 if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
616 header_len += 5; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
617 flags |= 0x40; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
618 } |
3716 | 619 if (st->codec->codec_type == CODEC_TYPE_VIDEO && |
620 st->codec->codec_id == CODEC_ID_DIRAC) { | |
621 /* set PES_extension_flag */ | |
622 pes_extension = 1; | |
623 flags |= 0x01; | |
624 | |
625 /* | |
626 * One byte for PES2 extension flag + | |
627 * one byte for extension length + | |
628 * one byte for extension id | |
629 */ | |
630 header_len += 3; | |
631 } | |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
632 len = payload_size + header_len + 3; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
633 if (private_code != 0) |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
634 len++; |
4921
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
635 if (len > 0xffff) |
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
636 len = 0; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
637 *q++ = len >> 8; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
638 *q++ = len; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
639 val = 0x80; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
640 /* data alignment indicator is required for subtitle data */ |
820
feca73904e67
changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents:
785
diff
changeset
|
641 if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
642 val |= 0x04; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
643 *q++ = val; |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
644 *q++ = flags; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
645 *q++ = header_len; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
646 if (pts != AV_NOPTS_VALUE) { |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
647 write_pts(q, flags >> 6, pts); |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
648 q += 5; |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
649 } |
4913 | 650 if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
651 write_pts(q, 1, dts); |
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
652 q += 5; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
653 } |
3716 | 654 if (pes_extension && st->codec->codec_id == CODEC_ID_DIRAC) { |
655 flags = 0x01; /* set PES_extension_flag_2 */ | |
656 *q++ = flags; | |
657 *q++ = 0x80 | 0x01; /* marker bit + extension length */ | |
658 /* | |
659 * Set the stream id extension flag bit to 0 and | |
660 * write the extended stream id | |
661 */ | |
662 *q++ = 0x00 | 0x60; | |
663 } | |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
664 if (private_code != 0) |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
665 *q++ = private_code; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
666 is_start = 0; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
667 } |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
668 /* header size */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
669 header_len = q - buf; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
670 /* data len */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
671 len = TS_PACKET_SIZE - header_len; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
672 if (len > payload_size) |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
673 len = payload_size; |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
674 stuffing_len = TS_PACKET_SIZE - header_len - len; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
675 if (stuffing_len > 0) { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
676 /* add stuffing with AFC */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
677 if (buf[3] & 0x20) { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
678 /* stuffing already present: increase its size */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
679 afc_len = buf[4] + 1; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
680 memmove(buf + 4 + afc_len + stuffing_len, |
885 | 681 buf + 4 + afc_len, |
785
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
682 header_len - (4 + afc_len)); |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
683 buf[4] += stuffing_len; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
684 memset(buf + 4 + afc_len, 0xff, stuffing_len); |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
685 } else { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
686 /* add stuffing */ |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
687 memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4); |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
688 buf[3] |= 0x20; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
689 buf[4] = stuffing_len - 1; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
690 if (stuffing_len >= 2) { |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
691 buf[5] = 0x00; |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
692 memset(buf + 6, 0xff, stuffing_len - 2); |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
693 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
694 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
695 } |
e277d8928f49
buggy PCR output (just to keep HW decoders happy) - audio and subtitle language support - 'title' stream field sets the service name - fixed TS packet stuffing code - support for subtitle PES packets
bellard
parents:
693
diff
changeset
|
696 memcpy(buf + TS_PACKET_SIZE - len, payload, len); |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
697 payload += len; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
698 payload_size -= len; |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
1838
diff
changeset
|
699 put_buffer(s->pb, buf, TS_PACKET_SIZE); |
4209
020395b83a14
compute pcr more accurately, regression tests need update
bcoudurier
parents:
4201
diff
changeset
|
700 ts->cur_pcr += TS_PACKET_SIZE*8*90000LL/ts->mux_rate; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
701 } |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
1838
diff
changeset
|
702 put_flush_packet(s->pb); |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
703 } |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
704 |
468 | 705 static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
706 { |
468 | 707 AVStream *st = s->streams[pkt->stream_index]; |
4914 | 708 int len, size = pkt->size; |
468 | 709 uint8_t *buf= pkt->data; |
4219
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
710 uint8_t *data= NULL; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
711 MpegTSWriteStream *ts_st = st->priv_data; |
4212 | 712 const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE); |
4220 | 713 int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE; |
714 | |
715 if (pkt->pts != AV_NOPTS_VALUE) | |
716 pts = pkt->pts + delay; | |
717 if (pkt->dts != AV_NOPTS_VALUE) | |
718 dts = pkt->dts + delay; | |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
719 |
4915 | 720 if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) { |
721 av_log(s, AV_LOG_ERROR, "first pts value must set\n"); | |
722 return -1; | |
723 } | |
724 ts_st->first_pts_check = 0; | |
725 | |
4921
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
726 if (st->codec->codec_id == CODEC_ID_H264) { |
4219
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
727 if (pkt->size < 5 || AV_RB32(pkt->data) != 0x0000001) { |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
728 av_log(s, AV_LOG_ERROR, "h264 bitstream malformated\n"); |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
729 return -1; |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
730 } |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
731 if (pkt->data[4] != 0x09) { // AUD NAL |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
732 data = av_malloc(pkt->size+6); |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
733 if (!data) |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
734 return -1; |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
735 memcpy(data+6, pkt->data, pkt->size); |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
736 AV_WB32(data, 0x00000001); |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
737 data[4] = 0x09; |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
738 data[5] = 0xe0; // any slice type |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
739 buf = data; |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
740 size = pkt->size+6; |
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
741 } |
4211
5e5654752973
set pts and dts of pes packets exactly according to specs
bcoudurier
parents:
4209
diff
changeset
|
742 } |
5e5654752973
set pts and dts of pes packets exactly according to specs
bcoudurier
parents:
4209
diff
changeset
|
743 |
5306
95a0faec0218
mux all stream types except audio as one pes packet per avpacket, issue #1374
bcoudurier
parents:
5219
diff
changeset
|
744 if (st->codec->codec_type != CODEC_TYPE_AUDIO) { |
4921
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
745 // for video and subtitle, write a single pes packet |
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
746 mpegts_write_pes(s, st, buf, size, pts, dts); |
4922 | 747 av_free(data); |
4921
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
748 return 0; |
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
749 } |
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
750 |
4952
0be83fd54e7a
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4951
diff
changeset
|
751 if (ts_st->payload_pts == AV_NOPTS_VALUE) { |
0be83fd54e7a
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4951
diff
changeset
|
752 ts_st->payload_dts = dts; |
0be83fd54e7a
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4951
diff
changeset
|
753 ts_st->payload_pts = pts; |
0be83fd54e7a
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4951
diff
changeset
|
754 } |
0be83fd54e7a
simplify pes timestamps fetching, based on a patch by corp186, chasedouglas at gmail dot com
bcoudurier
parents:
4951
diff
changeset
|
755 |
4921
fa21da521576
write a single pes for video frames, some proprietary player needs it
bcoudurier
parents:
4915
diff
changeset
|
756 // audio |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
757 while (size > 0) { |
4914 | 758 len = DEFAULT_PES_PAYLOAD_SIZE - ts_st->payload_index; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
759 if (len > size) |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
760 len = size; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
761 memcpy(ts_st->payload + ts_st->payload_index, buf, len); |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
762 buf += len; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
763 size -= len; |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
764 ts_st->payload_index += len; |
4914 | 765 if (ts_st->payload_index >= DEFAULT_PES_PAYLOAD_SIZE) { |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
766 mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
767 ts_st->payload_pts, ts_st->payload_dts); |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
768 ts_st->payload_pts = AV_NOPTS_VALUE; |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
769 ts_st->payload_dts = AV_NOPTS_VALUE; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
770 ts_st->payload_index = 0; |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
771 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
772 } |
4219
3bfd8604f480
add aud nal unit if not present in h264 bitstream
bcoudurier
parents:
4217
diff
changeset
|
773 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
774 return 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
775 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
776 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
777 static int mpegts_write_end(AVFormatContext *s) |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
778 { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
779 MpegTSWrite *ts = s->priv_data; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
780 MpegTSWriteStream *ts_st; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
781 MpegTSService *service; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
782 AVStream *st; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
783 int i; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
784 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
785 /* flush current packets */ |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
786 for(i = 0; i < s->nb_streams; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
787 st = s->streams[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
788 ts_st = st->priv_data; |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
789 if (ts_st->payload_index > 0) { |
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
790 mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, |
1838
d1af40ab8ea5
write DTS, based on patch by Luca Abeni, lucabe72 email it
mru
parents:
1415
diff
changeset
|
791 ts_st->payload_pts, ts_st->payload_dts); |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
792 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
793 } |
2771
d52c718e83f9
Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents:
1838
diff
changeset
|
794 put_flush_packet(s->pb); |
885 | 795 |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
796 for(i = 0; i < ts->nb_services; i++) { |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
797 service = ts->services[i]; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
798 av_freep(&service->provider_name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
799 av_freep(&service->name); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
800 av_free(service); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
801 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
802 av_free(ts->services); |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
803 |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
804 return 0; |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
805 } |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
806 |
1167 | 807 AVOutputFormat mpegts_muxer = { |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
808 "mpegts", |
3424
7a0230981402
Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents:
3420
diff
changeset
|
809 NULL_IF_CONFIG_SMALL("MPEG-2 transport stream format"), |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
810 "video/x-mpegts", |
3420 | 811 "ts,m2t", |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
812 sizeof(MpegTSWrite), |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
813 CODEC_ID_MP2, |
250
2d4dcb1d3e21
generate correct PTS in transport stream - use mpeg2 encoder by default
bellard
parents:
241
diff
changeset
|
814 CODEC_ID_MPEG2VIDEO, |
152
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
815 mpegts_write_header, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
816 mpegts_write_packet, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
817 mpegts_write_end, |
cc03a75cbde4
mpeg ts demux uses DVB SI info and generates correct PTS info - added prototype mpeg ts mux
bellard
parents:
diff
changeset
|
818 }; |