Mercurial > pt1.oyama
annotate src/tssplitter_lite.h @ 185:7a0f498af035 default tip
Fix a race condition.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Wed, 14 May 2014 22:43:57 +0900 |
parents | dc0d3addfd18 |
children |
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> |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
26 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
27 #define LENGTH_PACKET (188) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
28 #define MAX_PID (8192) |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
96
diff
changeset
|
29 #define MAX_SERVICES (50) |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
30 #define LENGTH_CRC_DATA (176) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
31 #define false (0) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
32 #define true (1) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
33 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
34 #define TSS_SUCCESS (0) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
35 #define TSS_ERROR (-1) |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
36 #define TSS_NULL (-2) |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
96
diff
changeset
|
37 #define LENGTH_PAT_HEADER (12) |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
38 #define C_CHAR_COMMA ',' |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
39 #define SECTION_CONTINUE (1) |
119
4e7aaa72e158
ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
118
diff
changeset
|
40 |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
41 typedef struct pmt_version { |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
42 int pid; |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
43 int version; |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
44 int packet; |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
45 } pmt_version; |
122 | 46 |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
47 /** |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
48 * splitter構造体 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
49 */ |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
50 typedef struct splitter { |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
51 unsigned char pids[MAX_PID]; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
52 unsigned char pmt_pids[MAX_PID]; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
53 unsigned char* pat; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
54 char** sid_list; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
55 unsigned char pat_count; |
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
56 int pmt_retain; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
57 int pmt_counter; |
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
58 int avail_pmts[MAX_SERVICES]; |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
59 pmt_version pmt_version[MAX_SERVICES]; |
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
60 int num_pmts; |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
61 uint16_t section_remain[MAX_PID]; // セクション残りバイト数 |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
62 uint8_t packet_seq[MAX_PID]; // 巡回カウンタ |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
146
diff
changeset
|
63 time_t split_start_time; |
184
dc0d3addfd18
Fix a bug that failed to DLNA streaming. cosmetic changes.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
183
diff
changeset
|
64 int split_select_finish; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
65 } splitter; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
66 |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
67 typedef struct _splitbuf_t |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
68 { |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
69 u_char* buffer; |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
70 int buffer_size; |
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
71 int buffer_filled; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
72 } splitbuf_t; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
73 |
183
27e5f99f8991
Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
164
diff
changeset
|
74 splitter* split_startup(char *sid); |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
75 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
|
76 void split_shutdown(splitter *sp); |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
77 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
|
78 |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff
changeset
|
79 #endif |