Mercurial > pt1.oyama
annotate src/tssplitter_lite.h @ 179:ac23a9b417a2
Support Linux kernel version >= 3.8
Add ld opt -lm
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Fri, 03 May 2013 11:00:11 +0900 |
parents | 7d8a5bb874ad |
children | 27e5f99f8991 |
rev | line source |
---|---|
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
1 /* -*- tab-width: 4; indent-tabs-mode: t -*- */ |
118 | 2 /* vim: set ts=4 sts=4 sw=4 noexpandtab number : */ |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
3 /* tssplitter_lite.h -- split TS stream program's header. |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
4 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
5 Copyright 2009 querulous |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
6 Copyright 2010-2012 Naoya OYAMA <naoya.oyama@gmail.com> |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
7 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
8 This program is free software: you can redistribute it and/or modify |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
11 (at your option) any later version. |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
12 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
17 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
20 #ifndef _TS_SPLITTER_LITE_H_ |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
21 #define _TS_SPLITTER_LITE_H_ |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
96
diff
changeset
|
22 |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
23 #define __STDC_FORMAT_MACROS |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
24 #include <inttypes.h> |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
25 #include <unistd.h> |
121 | 26 #include <limits.h> |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
27 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
28 #define LENGTH_PACKET (188) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
29 #define MAX_PID (8192) |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
96
diff
changeset
|
30 #define MAX_SERVICES (50) |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
31 #define LENGTH_CRC_DATA (176) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
32 #define false (0) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
33 #define true (1) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
34 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
35 #define TSS_SUCCESS (0) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
36 #define TSS_ERROR (-1) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
37 #define TSS_NULL (-2) |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
96
diff
changeset
|
38 #define LENGTH_PAT_HEADER (12) |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
39 #define C_CHAR_COMMA ',' |
121 | 40 #define C_CHAR_DOT '.' |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
41 #define LENGTH_TS_HEADER (4) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
42 #define LENGTH_PES_HEADER (9) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
43 #define LENGTH_PTS (5) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
44 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
45 /* 改訂版デジタル放送教科書(上) P101 表1 ARIBでのPSI/SIの種類より参照 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
46 #define PAT (0x0000) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
47 //#define PMT /* PATによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
48 #define CAT (0x0001) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
49 #define NIT (0x0010) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
50 #define SDT (0x0011) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
51 #define BAT (0x0011) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
52 #define EIT (0x0012) /* 0x0026, 0x0027 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
53 #define RST (0x0013) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
54 #define TDT (0x0014) /* 地デジでは使用されない */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
55 #define TOT (0x0014) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
56 #define LIT (0x0020) /* またはPMTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
57 #define ERT (0x0021) /* またはPMTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
58 //#define ITT /* PMTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
59 #define PCAT (0x0022) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
60 #define BIT (0x0024) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
61 #define NBIT (0x0025) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
62 //#define ECM /* PMTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
63 //#define EMM /* CATによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
64 #define LDT (0x0025) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
65 #define DCT (0x0017) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
66 //#define DTL /* DCTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
67 #define DIT (0x001e) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
68 #define SIT (0x001f) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
69 #define SDTT (0x0023) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
70 #define CDT (0x0029) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
71 //#define DSM-CC_Section /* PMTによる間接指定 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
72 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
73 /* セクションヘッダ長 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
74 /* TS パケットに各セクションを設置する際、該当TSパケットの残サイズが |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
75 * いくつ以上あれば書き込めるかの判定に使用する。 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
76 * デコードにはあまり重要では無いかも |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
77 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
78 #define SECTION_LENGTH_PAT (8) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
79 #define SECTION_LENGTH_PMT (8) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
80 #define SECTION_LENGTH_CAT (8) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
81 #define SECTION_LENGTH_NIT (8) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
82 #define SECTION_LENGTH_BIT (8) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
83 #define SECTION_LENGTH_SDT (11) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
84 #define SECTION_LENGTH_EIT (14) /* H-EIT, M-EIT, L-EIT を示す */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
85 #define SECTION_LENGTH_SDTT (15) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
86 #define SECTION_LENGTH_CDT (13) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
87 #define SECTION_LENGTH_TOT (10) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
88 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
89 enum { |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
90 PTS_FLAG = 0x80, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
91 DTS_FLAG = 0x40, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
92 ESCR_FLAG = 0x20, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
93 ES_RATE_FLAG = 0x10, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
94 DSM_TRICK_MODE_FLAG = 0x08, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
95 COPY_INFO_FLAG = 0x04, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
96 CRC_FLAG = 0x02, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
97 EXTENSION_FLAG = 0x01 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
98 }; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
99 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
100 enum { |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
101 PES_PRIVATE_DATA_FLAG = 0x80, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
102 PACK_HEADER_FIELD_FLAG = 0x40, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
103 PROGRAM_PACKET_SEQUENCE_COUNTER = 0x20, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
104 PSTD_BUFFER_FLAG = 0x10, |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
105 PES_EXTENSION_FLAG2 = 0x01 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
106 }; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
107 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
108 /* |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
109 * PCRからSTCを生成する処理方式 |
144
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
131
diff
changeset
|
110 * 1. PCRを二つ取得するまでループ(1.から4.までは初期処理で実施すること) |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
111 * 2. ループ開始時刻(PCR)と、ループ抜けた時刻(PCR)の差分を取る |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
112 * 3. ループ開始〜終了の間に処理したパケット数を数える |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
113 * 4. (2.のPCRの進んだ時間/3.のパケット数) の計算によって、1パケットによって進むPCRを想定する |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
114 * 5. TS受信時に、1つのパケットを処理する度に4.の想定する経過時刻をPCRに足し込んでSTCとする |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
115 * 6. PCRを新規に取得したら、STCを補正(そのまま代入)する |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
116 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
117 #define MAX_VIDEO (16) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
118 #define MAX_AUDIO (32) |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
119 typedef struct _program_t |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
120 { |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
121 int64_t stc; |
122 | 122 int64_t cue; /* 録画開始時刻 */ |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
123 int pmt_packet_id; /* 該当Program(Service ID)に対応するPMT */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
124 int pmt_version; /* 該当Program(Service ID)に対応するPMTのVersion */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
125 int pcr_packet_id; /* 該当Program(Service ID)のPCRを保持するPID */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
126 int64_t pcr1; /* PCR1 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
127 int64_t pcr2; /* PCR2 */ |
122 | 128 int pcr_packet_nb; /* 直前のPCRを受信したときのパケット数 */ |
129 int packet_nb; /* 直前のProgramの処理を実施したときのパケット数 */ | |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
130 int64_t pcr_incr; /* 該当Program(Service ID)に於いて、1つのTSパケットを処理した時に経過する(と想定する時間) */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
131 int video_start; /* VODEO0を蓄積開始している? */ |
120 | 132 int64_t video_pts; /* 最後に処理したVODEO0のESのPTS */ |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
133 int video_nb; /* PMT に存在するビデオストリームの数 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
134 int audio_nb; /* PMT に存在する音声ストリームの数 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
135 int video[MAX_VIDEO]; /* PS出力する場合に使うかも */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
136 int audio[MAX_AUDIO]; /* PS出力する場合に使うかも */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
137 } program_t; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
138 /* |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
139 * program_t をサービスID分準備して、使用するイメージでいたけど、 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
140 * サービスIDの最大値は0xFFFFであるので、静的に確保すると stack が簡単に溢るので、 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
141 * 実行時に malloc とするかなぁ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
142 * 本当は必要なだけallocするのが好ましいのだけど… |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
143 */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
144 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
145 typedef struct _splitpesbuf_t |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
146 { |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
147 program_t *Program; |
120 | 148 int64_t pts; |
149 int64_t dts; | |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
150 int size; |
131
20442921bff5
change display name. modify PES buf size.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
124
diff
changeset
|
151 u_char buffer[3*1024*1024]; |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
152 } splitpesbuf_t; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
153 |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
154 typedef struct _splitesbuf_t |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
155 { |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
156 program_t *Program; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
157 int64_t pts; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
158 int64_t dts; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
159 int started; /* 該当ESが蓄積開始しているか */ |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
160 int random_access_indicator; /* TS の random_access_indicator */ |
121 | 161 int fd; /* 該当ESのfd */ |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
162 int size; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
163 u_char buffer[3*1024*1024]; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
164 } splitesbuf_t; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
165 |
122 | 166 /* PCR 共有用構造体 */ |
167 typedef struct _pcr_t | |
168 { | |
169 int pid; | |
170 int sid_nb; /* PCRを参照しているServiceID(ProgramID)の数 */ | |
171 int sid[MAX_SERVICES]; | |
172 } pcr_t; | |
173 | |
174 | |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
175 /** |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
176 * splitter構造体 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
177 */ |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
178 typedef struct splitter { |
122 | 179 char *filename; /* ファイル名を上位からもらってくるためのポインタ */ |
180 char *arg_cue; /* 引数で取得してきた録画開始時刻(HHMISS) */ | |
181 int esout; /* ES出力する? */ | |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
182 unsigned char pids[MAX_PID]; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
183 unsigned char pmt_pids[MAX_PID]; |
122 | 184 uint8_t cat_pids[MAX_PID]; |
185 uint8_t pcr_pids[MAX_PID]; /* PCRは複数ServiceID(ProgramID)で共有される */ | |
186 pcr_t pcr[MAX_SERVICES]; | |
187 int pcr_nb; | |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
188 unsigned char* pat; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
189 char** sid_list; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
190 unsigned char pat_count; |
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
191 int pmt_retain; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
192 int pmt_counter; |
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
193 int avail_pmts[MAX_SERVICES]; |
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
194 int num_pmts; |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
195 splitpesbuf_t *pesbuf[MAX_PID]; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
196 splitesbuf_t *esbuf[MAX_PID]; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
197 program_t *program; |
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
198 int pid_sid_table[MAX_PID]; /* pid to sid の変換を行うためのテーブル */ |
122 | 199 time_t time_cue; |
200 time_t time_tot; | |
201 int tot_packet_nb; /* TOT受信時のパケット受信数 */ | |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
146
diff
changeset
|
202 time_t split_start_time; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
146
diff
changeset
|
203 int split_select_finish; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
204 } splitter; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
205 |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
206 /* b25 decoder would hoard up large chank */ |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
207 typedef struct _splitbuf_t |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
208 { |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
209 int size; |
144
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
131
diff
changeset
|
210 int buffer_length; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
131
diff
changeset
|
211 u_char *buffer; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
212 } splitbuf_t; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
213 |
122 | 214 splitter* split_startup(char *sid, char *filename, char *cue_time); |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
215 int split_select(splitter *sp, ARIB_STD_B25_BUFFER *sbuf); |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
216 void split_shutdown(splitter *sp); |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
217 int split_ts(splitter *splitter, ARIB_STD_B25_BUFFER *sbuf, splitbuf_t *dbuf); |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
218 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
219 #endif |