annotate libmpdemux/mpeg_packetizer.c @ 21306:df74299363e8

Sync with FFmpeg changes for (de)muxer registration.
author diego
date Mon, 27 Nov 2006 13:19:34 +0000
parents 181ec6001b0e
children f7151c256b72
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
1 /*
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
2 * Copyright (C) 2006 Benjamin Zores
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
3 * Set of helper routines for building MPEG 1/2 PS/PES packets.
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
4 *
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
5 * Based on various code bororwed from vo_mpegpes/vo_dxr2 :
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
6 * (C) 2000 Ralph Metzler <ralph@convergence.de>
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
7 * Marcus Metzler <marcus@convergence.de>
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
8 * Gerard Lantau
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
9 *
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
13 * (at your option) any later version.
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
14 *
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
18 * GNU General Public License for more details.
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
19 *
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
21 * along with this program; if not, write to the Free Software Foundation,
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
23 */
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
24
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
25 #include <unistd.h>
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
26 #include <string.h>
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
27 #include <inttypes.h>
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
28
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
29 #include "mp_msg.h"
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
30 #include "mpeg_packetizer.h"
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
31
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
32 #define PES_MAX_SIZE 2048
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
33
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
34 static unsigned char pes_header[PES_MAX_SIZE];
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
35
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
36 static unsigned char ps2_header[] = {
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
37 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x04, 0x00,
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
38 0x04, 0x01, 0x01, 0x86, 0xa3, 0xf8
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
39 };
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
40
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
41
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
42 static unsigned char ps1_header[] = {
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
43 0x00, 0x00, 0x01, 0xba, 0x21, 0x00,
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
44 0xb9, 0x37, 0x83, 0x80, 0xc3, 0x51,
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
45 };
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
46
19149
73d8ea32ebb8 cosmetics: comments and reindentation asked by gxben
nicodvb
parents: 19148
diff changeset
47 /* Send MPEG <type> PES packet */
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
48 static int
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
49 send_mpeg_pes_packet_ll(unsigned char *data, int len, int id, uint64_t pts,
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
50 int type, unsigned char *header, int header_len,
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
51 int align4, int my_write (unsigned char *data, int len))
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
52 {
19240
77d29dd9b08e ptslen was set to 5 even when no pts==0
nicodvb
parents: 19152
diff changeset
53 int ptslen = (pts ? 5 : 0);
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
54 int n = 0;
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
55 int idx, plen;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
56 int hdr;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
57
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
58 mp_msg (MSGT_HEADER, MSGL_DBG2,
19152
a28bcc898ab4 display the right MPEG packet type
ben
parents: 19149
diff changeset
59 "MPEG%d PES packet: 0x%x => %lu \n", type, id, pts);
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
60 memset (pes_header, '\0', PES_MAX_SIZE);
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
61
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
62 /* startcode */
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
63 pes_header[0] = 0;
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
64 pes_header[1] = 0;
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
65 pes_header[2] = 0x01;
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
66 pes_header[3] = id; /* stream id */
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
67
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
68 while (len > 0)
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
69 {
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
70 int payload_size = len; /* data + PTS */
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
71 if(type == 2)
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
72 hdr = 3;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
73 else
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
74 hdr = (ptslen ? 0 : 1);
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
75 if (6 + hdr + ptslen + payload_size + header_len > PES_MAX_SIZE)
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
76 payload_size = PES_MAX_SIZE - 6 - hdr - ptslen - header_len;
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
77 if(align4)
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
78 payload_size &= ~3;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
79
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
80 /* construct PES header: packetize */
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
81 plen = payload_size + hdr + ptslen + header_len;
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
82 pes_header[4] = plen >> 8;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
83 pes_header[5] = plen & 255;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
84 idx = 6;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
85
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
86 if (ptslen)
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
87 {
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
88 int x;
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
89
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
90 if(type == 2)
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
91 {
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
92 pes_header[idx++] = 0x81;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
93 pes_header[idx++] = 0x80;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
94 pes_header[idx++] = ptslen;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
95 }
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
96
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
97 /* presentation time stamp */
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
98 x = (0x02 << 4) | (((pts >> 30) & 0x07) << 1) | 1;
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
99 pes_header[idx++] = x;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
100
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
101 x = ((((pts >> 15) & 0x7fff) << 1) | 1);
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
102 pes_header[idx++] = x >>8;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
103 pes_header[idx++] = x & 255;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
104
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
105 x = (((pts & 0x7fff) << 1) | 1);
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
106 pes_header[idx++] = x >> 8;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
107 pes_header[idx++] = x & 255;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
108 }
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
109 else
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
110 {
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
111 if(type == 2)
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
112 {
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
113 pes_header[idx++] = 0x81;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
114 pes_header[idx++] = 0x00;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
115 pes_header[idx++] = 0x00;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
116 }
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
117 else
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
118 pes_header[idx++] = 0x0f;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
119 }
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
120
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
121 if(header_len)
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
122 {
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
123 memcpy(&pes_header[idx], header, header_len);
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
124 idx += header_len;
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
125 }
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
126
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
127 my_write (pes_header, idx);
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
128 n = my_write (data, payload_size);
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
129
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
130 len -= n;
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
131 data += n;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
132 ptslen = 0; /* store PTS only once, at first packet! */
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
133 if(align4 && len < 4)
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
134 break;
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
135 }
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
136
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
137 return n;
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
138 }
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
139
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
140 int
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
141 send_mpeg_pes_packet (unsigned char *data, int len, int id, uint64_t pts,
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
142 int type, int my_write (unsigned char *data, int len))
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
143 {
20116
rathann
parents: 19244
diff changeset
144 return send_mpeg_pes_packet_ll(data, len, id, pts, type, NULL, 0, 0, my_write);
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
145 }
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
146
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
147
19149
73d8ea32ebb8 cosmetics: comments and reindentation asked by gxben
nicodvb
parents: 19148
diff changeset
148 /* Send MPEG <type> PS packet */
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
149 int
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
150 send_mpeg_ps_packet(unsigned char *data, int len, int id, uint64_t pts, int type,
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
151 int my_write (unsigned char *data, int len))
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
152 {
19148
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
153 if(type == 2)
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
154 my_write (ps2_header, sizeof (ps2_header));
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
155 else
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
156 my_write (ps1_header, sizeof (ps1_header));
3b839a8d297a simplified mpeg packetizer used by hw mpeg decoders/vo - first round
nicodvb
parents: 19141
diff changeset
157 return send_mpeg_pes_packet (data, len, id, pts, type, my_write);
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
158 }
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
159
19149
73d8ea32ebb8 cosmetics: comments and reindentation asked by gxben
nicodvb
parents: 19148
diff changeset
160 /* Send MPEG 2 LPCM packet */
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
161 int
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
162 send_mpeg_lpcm_packet(unsigned char* data, int len,
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
163 int id, uint64_t pts, int freq_id,
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
164 int my_write (unsigned char *data, int len))
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
165 {
19243
73443b22df17 final cleanup: implemented send_mpeg_pes_packet() and send_mpeg_lpcm_packet() using new send_mpeg_pes_packet_ll()
nicodvb
parents: 19240
diff changeset
166 unsigned char header[7] = {0xA0, 0x07, 0x00, 0x04, 0x0C, 1 | (freq_id << 4), 0x80};
19244
5e5d323b1934 re-added forgotten return in send_mpeg_lpcm_packet()
nicodvb
parents: 19243
diff changeset
167 return send_mpeg_pes_packet_ll(data, len, 0xBD, pts, 2, header, sizeof(header), 1, my_write);
19141
6e6ca469073b moved mpeg_packetizer helpers to libmpdemux
ben
parents:
diff changeset
168 }