annotate src/tssplitter_lite.c @ 183:27e5f99f8991

Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Mon, 05 May 2014 22:08:21 +0900
parents 863ac6807ee3
children dc0d3addfd18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 -*- */
117
ac39bb18136e commit test.
naoyan@johnstown.minaminoshima.org
parents: 112
diff changeset
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.c -- split TS stream.
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
143
e72dd5e8d53f Number of samples per ADTS packet instead of 1000 and 1024.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 124
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
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 #include <stdlib.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22 #include <stdio.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 #include <string.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24 #include <ctype.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 #include <fcntl.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27 #include <sys/stat.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 #include "decoder.h"
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 #include "recpt1.h"
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30 #include "tssplitter_lite.h"
146
066f33b2213a EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 143
diff changeset
31
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
32 /* prototypes */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
33 static int ReadTs(splitter *sp, ARIB_STD_B25_BUFFER *sbuf);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
34 static int AnalyzePat(splitter *sp, unsigned char *buf);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
35 static int RecreatePat(splitter *sp, unsigned char *buf, int *pos);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
36 static char** AnalyzeSid(char *sid);
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
37 static int AnalyzePmt(splitter *sp, unsigned char *buf, unsigned char mark);
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
38 static int GetCrc32(unsigned char *data, int len);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
39 static int GetPid(unsigned char *data);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
41 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 * サービスID解析
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
44 static char** AnalyzeSid(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 char* sid) // [in] サービスID(カンマ区切りテキスト)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 int i = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 char** sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 char* p;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50 int CommaNum = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52 /* sid は次の形式の引数を許容する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 /* 指定無し */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 /* SID[0] */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 /* SID[0],SID[1],...,SID[N-1],SID[N] */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
56
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57 /*カンマの数を数える*/
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 while(*p != '\0')
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 if( *p == C_CHAR_COMMA ){
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 CommaNum++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64 p++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
66
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 /* sid_listの数はカンマの数+2(NULL止めするから) */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
68 sid_list = malloc(sizeof(char*)*(CommaNum+2));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 if ( sid_list == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 fprintf(stderr, "AnalyzeSid() malloc error.\n");
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 /* sidが空である場合 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 if ( strlen(p) == 0 )
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 sid_list[0] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
82
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
83 /* カンマ無し */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 if ( CommaNum == 0 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 sid_list[0] = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87 sid_list[1] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
91 /* カンマ区切りで複数指定時 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 i=0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 /* 文字列端に到達するか、カンマ数が数えた数に達したら終了 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 while((*p != '\0') || i < CommaNum)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 /* 現在の処理位置をsid_list[i]にセット */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98 /* このタイミングの p は
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 * ・sid先頭
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 * ・[,]の次の文字
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 * いずれかであるので p を sid_list[i] に代入してよい
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 sid_list[i] = p;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104 i++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
105
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 /* 最初に現れる[,]をNULL文字で置換する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 p = strchr(p, C_CHAR_COMMA);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 if ( p == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
110 /* カンマが見つからない場合は最後の処理対象なので終了 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 *p = '\0';
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 /* 処理位置をNULLで置換した文字の次の位置に設定する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 p++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
117
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118 /* 最後のsid_list[n]はNULLポインタで止める */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119 sid_list[i] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 i=0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 while( sid_list[i] != NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 i++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
125 }
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
126 #if 0
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127 for(i=0; sid_list[i] != NULL; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 {
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
129 printf("sid_list[%d]=[%s].\n",i, sid_list[i]);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
130 }
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
131 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
135 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136 * 初期化処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 splitter* split_startup(
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
139 char *sid // [in] サービスID(引数で指定した文字列)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
140 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 splitter* sp;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 sp = malloc(sizeof(splitter));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 if ( sp == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
146 fprintf(stderr, "split_startup malloc error.\n");
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
149 memset(sp->pids, 0, sizeof(sp->pids));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
150 memset(sp->pmt_pids, 0, sizeof(sp->pmt_pids));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 sp->sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 sp->pat = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 sp->sid_list = AnalyzeSid(sid);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 if ( sp->sid_list == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 free(sp);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 sp->pat_count = 0xFF;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
161 sp->pmt_retain = -1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162 sp->pmt_counter = 0;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
163
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
164 memset(sp->section_remain, 0U, sizeof(sp->section_remain));
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
165 memset(sp->packet_seq, 0U, sizeof(sp->packet_seq));
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
166
164
7d8a5bb874ad EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 152
diff changeset
167 sp->split_select_finish = TSS_ERROR;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
168
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 return sp;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
172 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 * 落とすPIDを確定させる
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 int split_select(
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 splitter *sp, // [in/out] splitter構造体
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177 ARIB_STD_B25_BUFFER *sbuf // [in] 入力TS
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
179 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
180 int result;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 // TS解析
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
182 result = ReadTs(sp, sbuf);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
184 return result;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
185 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
186
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
188 * 終了処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
189 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
190 void split_shutdown(splitter* sp)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
191 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192 if ( sp != NULL ) {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 if ( sp->pat != NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 free(sp->pat);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 sp->pat = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 if ( sp->sid_list != NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
199 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
200 free(sp->sid_list);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201 sp->sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
202 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
203 free(sp);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 sp = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
207
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
208 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 * TS 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
210 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 * 対象のチャンネル番号のみの PAT の再構築と出力対象 PID の抽出を行う
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
213 static int ReadTs(splitter *sp, ARIB_STD_B25_BUFFER *sbuf)
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
214 #if 0
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
215 unsigned char **pat, // [out] PAT 情報(再構築後)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
216 unsigned char* pids, // [out] 出力対象 PID 情報
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
217 char** sid_list, // [in] 出力対象サービス ID のリスト
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
218 unsigned char* pmt_pids, // [in] 出力対象PIDのPMT PID
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
219 , // [in] pt1_drvの入力TS
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
220 int* pmt_retain, // [in] 残すべきPMTの数
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
221 int* pmt_counter // [out] 残したPMTの数
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
222 #endif
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
223 {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 int length = sbuf->size;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
225 int pid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 int result = TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227 int index;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
228 int analyze_result = 0;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
229
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
230 index = 0;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
231 while(length - index - LENGTH_PACKET > 0) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
232 pid = GetPid(sbuf->data + index + 1);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233 // PAT
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
234 if(0x0000 == pid) {
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
235 result = AnalyzePat(sp, sbuf->data + index);
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
236 if(result != TSS_SUCCESS) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
237 /* 下位の関数内部でmalloc error発生 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
238 return result;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
240 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
241
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
242 // PMT
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
243 /* 残すpmt_pidである場合には、pmtに書かれている
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
244 * 残すべきPCR/AUDIO/VIDEO PIDを取得する */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
245 if(sp->pmt_pids[pid] == 1) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
246 /* この中にはPMT毎に一度しか入らないようにしておく */
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
247 analyze_result = AnalyzePmt(sp, sbuf->data + index, 1);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
248 if(TSS_SUCCESS == analyze_result) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
249 sp->pmt_pids[pid]++;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
250 sp->pmt_counter += 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
251 *(sbuf->data + index + 1) = 0xff;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
252 *(sbuf->data + index + 2) = 0xff;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
253 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
255 /* 録画する全てのPMTについて、中にあるPCR/AUDIO/VIDEOのPIDを
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
256 * 得る */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
257 /* pmt_counter と pmt_retain が一致する場合に条件は満たされる */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
258 if(sp->pmt_counter == sp->pmt_retain) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 result = TSS_SUCCESS;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
262 else {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263 result = TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
264 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
265 index += LENGTH_PACKET;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
266 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
267
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 return(result);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
270
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
271 static int RescanPID(splitter *splitter, unsigned char *buf)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
272 {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
273 int result = TSS_NULL;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
274 int i;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
275
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
276 // clear
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
277 if (splitter->pmt_counter == splitter->pmt_retain) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
278 memcpy(splitter->pids, splitter->pmt_pids, sizeof(splitter->pids));
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
279 splitter->pmt_counter = 0;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
280 memset(splitter->section_remain, 0U, sizeof(splitter->section_remain));
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
281 memset(splitter->packet_seq, 0U, sizeof(splitter->packet_seq));
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
282
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
283 fprintf(stderr, "Rescan PID \n");
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
284 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
285
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
286 if (TSS_SUCCESS == AnalyzePmt(splitter, buf, 2)) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
287 splitter->pmt_counter += 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
288 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
289
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
290 if (splitter->pmt_retain == splitter->pmt_counter) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
291 result = TSS_SUCCESS;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
292 for (i = 0; MAX_PID > i; i++) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
293 if (splitter->pids[i] > 0) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
294 splitter->pids[i] -= 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
295 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
296 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
297 fprintf(stderr, "Rescan PID End\n");
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
298 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
299
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
300 return result;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
301 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
302 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
303 * TS 分離処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
304 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
305 int split_ts(
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
306 splitter *splitter, // [in] splitterパラメータ
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
307 ARIB_STD_B25_BUFFER *sbuf, // [in] 入力TS
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
308 splitbuf_t *dbuf // [out] 出力TS
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
309 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
310 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
311 int pid;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
312 unsigned char *sptr, *dptr;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
313 int s_offset = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
314 int d_offset = 0;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
315 int result = TSS_SUCCESS;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
316 int pmts = 0;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
317 int version = 0;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
318
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
319 /* 初期化 */
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
320 dbuf->buffer_filled = 0;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
321 if (sbuf->size < 0) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
322 return TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
323 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
324
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
325 sptr = sbuf->data;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
326 dptr = dbuf->buffer;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
327
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
328 while(sbuf->size > s_offset) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
329 pid = GetPid(sptr + s_offset + 1);
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
330 switch(pid) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
331
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
332 // PAT
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
333 case 0x0000:
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
334 // 巡回カウンタカウントアップ
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
335 if(0xFF == splitter->pat_count) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
336 splitter->pat_count = splitter->pat[3];
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
337 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
338 else {
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
339 splitter->pat_count += 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
340 if(0 == splitter->pat_count % 0x10) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
341 splitter->pat_count -= 0x10;
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
342 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
343 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
344 splitter->pat[3] = splitter->pat_count;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
345
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
346 memcpy(dptr + d_offset, splitter->pat, LENGTH_PACKET);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
347 d_offset += LENGTH_PACKET;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
348 dbuf->buffer_filled += LENGTH_PACKET;
119
4e7aaa72e158 ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 117
diff changeset
349 break;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
350 default:
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
351 if(0 != splitter->pmt_pids[pid]) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
352 //PMT
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
353 if ((sptr + s_offset)[1] & 0x40) { // PES開始インジケータ
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
354 // バージョンチェック
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
355 for(pmts = 0; splitter->pmt_retain > pmts; pmts++) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
356 if (splitter->pmt_version[pmts].pid == pid) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
357 version = splitter->pmt_version[pmts].version;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
358 break;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
359 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
360 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
361 if((version != ((sptr + s_offset)[10] & 0x3e))
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
362 ||(splitter->pmt_retain != splitter->pmt_counter)) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
363 // 再チェック
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
364 result = RescanPID(splitter, sptr + s_offset);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
365 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
366 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
367 else {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
368 if (splitter->pmt_retain != splitter->pmt_counter) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
369 // 再チェック
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
370 result = RescanPID(splitter, sptr + s_offset);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
371 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
372 }
119
4e7aaa72e158 ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 117
diff changeset
373 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
374 /* pids[pid] が 1 は残すパケットなので書き込む */
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
375 if(0 != splitter->pids[pid]) {
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
376 memcpy(dptr + d_offset, sptr + s_offset, LENGTH_PACKET);
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
377 d_offset += LENGTH_PACKET;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
378 dbuf->buffer_filled += LENGTH_PACKET;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
379 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
380 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
381 } /* switch */
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
382
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
383 s_offset += LENGTH_PACKET;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
384 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
385
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
386 return result;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
387 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
388
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
389 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
390 * PAT 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
391 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
392 * PAT を解析し、出力対象チャンネルが含まれているかチェックを行い、PAT を再構築する
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
393 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
394 static int AnalyzePat(splitter *sp, unsigned char *buf)
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
395 #if 0
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
396 splitter *sp
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
397 unsigned char** pat, // [out] PAT 情報(再構築後)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
398 unsigned char* pids, // [out] 出力対象 PID 情報
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
399 char** sid_list, // [in] 出力対象サービス ID のリスト
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
400 unsigned char* pmt_pids, // [out] サービス ID に対応する PMT の PID
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
401 int* pmt_retain // [out] 残すPMTの数
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
402
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
403 unsigned char* buf, // [in] 読み込んだバッファ
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
404 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
405 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
406 int pos[MAX_PID];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
407 int service_id;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
408 int i, j, k;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
409 int size = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
410 int pid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
411 int result = TSS_SUCCESS;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
412 char **p;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
413 int sid_found = FALSE;
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
414 int avail_sids[MAX_SERVICES];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
415
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
416 unsigned char *pat = sp->pat;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
417 unsigned char *pids = sp->pids;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
418 char **sid_list = sp->sid_list;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
419 unsigned char *pmt_pids = sp->pmt_pids;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
420
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
421 char chosen_sid[512];
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
422 chosen_sid[0] = '\0';
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
423
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
424 if(pat == NULL) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
425 /* 初期化 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
426 sp->pmt_retain = 0;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
427 memset(pos, 0, sizeof(pos));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
428 size = buf[7];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
429
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
430 /* prescan SID/PMT */
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
431 for(i = 13, j = 0; i < (size + 8) - 4; i = i + 4) {
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
432
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
433 pid = GetPid(&buf[i+2]);
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
434 if(pid == 0x0010)
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
435 continue;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
436
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
437 avail_sids[j] = (buf[i] << 8) + buf[i+1];
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
438 sp->avail_pmts[j] = pid;
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
439 j++;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
440 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
441 sp->num_pmts = j;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
442
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
443 // 対象チャンネル判定
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
444 /* size + 8 = パケット全長 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
445 /* 最終 4 バイトはCRCなので飛ばす */
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
446 for(i = 13; i < (size + 8) - 4; i = i + 4) {
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
447
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
448 pid = GetPid(&buf[i+2]);
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
449 if(pid == 0x0010)
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
450 continue;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
451
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
452 service_id = (buf[i] << 8) + buf[i+1];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
453 p = sid_list;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
454
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
455 while(*p) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
456 if(service_id == atoi(*p)) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
457 /* 録画対象の pmt_pids は 1 とする */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
458 /* 録画対象の pmt の pids は 1 とする */
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
459 pid = GetPid(&buf[i + 2]);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
460 *(pmt_pids+pid) = 1;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
461 *(pids+pid) = 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
462 pos[pid] = i;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
463 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
464 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
465 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
466 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
467 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
468 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
469 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
470 else if(!strcasecmp(*p, "hd") || !strcasecmp(*p, "sd1")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
471 /* hd/sd1 指定時には1番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
472 if(service_id == avail_sids[0]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
473 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
474 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
475 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
476 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
477 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
478 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
479 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
480 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
481 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
482 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
483 continue;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
484 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
485 else if(!strcasecmp(*p, "sd2")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
486 /* sd2 指定時には2番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
487 if(service_id == avail_sids[1]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
488 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
489 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
490 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
491 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
492 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
493 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
494 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
495 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
496 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
497 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
498 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
499 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
500 else if(!strcasecmp(*p, "sd3")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
501 /* sd3 指定時には3番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
502 if(service_id == avail_sids[2]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
503 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
504 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
505 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
506 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
507 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
508 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
509 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
510 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
511 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
512 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
513 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
514 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
515 else if(!strcasecmp(*p, "1seg")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
516 /* 1seg 指定時には PMTPID=0x1FC8 のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
517 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
518 if(pid == 0x1FC8) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
519 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
520 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
521 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
522 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
523 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
524 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
525 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
526 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
527 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
528 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
529 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
530 else if(!strcasecmp(*p, "all")) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
531 /* all指定時には全保存する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
532 pid = GetPid(&buf[i + 2]);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
533 *(pmt_pids+pid) = 1;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
534 *(pids+pid) = 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
535 pos[pid] = i;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
536 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
537 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
538 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
539 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
540 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
541 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
542 else if(!strcasecmp(*p, "epg")) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
543 /* epg抽出に必要なPIDのみを保存する */
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
544 sid_found = TRUE;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
545 *(pids+0x11) = 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
546 *(pids+0x12) = 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
547 *(pids+0x26) = 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
548 *(pids+0x27) = 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
549 break;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
550 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
551
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
552 p++;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
553 } /* while */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
554 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
555
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
556 /* if sid has been specified but no sid found, fall back to all */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
557 if(*sid_list && !sid_found) {
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
558 for(i = 13; i < (size + 8) - 4; i = i + 4) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
559
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
560 pid = GetPid(&buf[i+2]);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
561 if(pid==0x0010)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
562 continue;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
563
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
564 service_id = (buf[i] << 8) + buf[i+1];
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
565 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
566 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
567 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
568 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
569 sid_found = TRUE;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
570 sp->pmt_version[sp->pmt_retain].pid = pid;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
571 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
572 sprintf(chosen_sid, "%s %d", *chosen_sid ? chosen_sid : "", service_id);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
573 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
574 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
575
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
576 /* print SIDs */
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
577 fprintf(stderr, "Available sid = ");
152
30e91361506a EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 149
diff changeset
578 for(k=0; k < sp->num_pmts; k++)
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
579 fprintf(stderr, "%d ", avail_sids[k]);
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
580 fprintf(stderr, "\n");
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
581 fprintf(stderr, "Chosen sid =%s\n", chosen_sid);
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
582
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
583 #if 1
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
584 /* print PMTs */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
585 fprintf(stderr, "Available PMT = ");
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
586 for(k=0; k < sp->num_pmts; k++)
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
587 fprintf(stderr, "0x%x ", sp->avail_pmts[k]);
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
588 fprintf(stderr, "\n");
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
589 #endif
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
590
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
591 // PAT 再構築
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
592 result = RecreatePat(sp, buf, pos);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
593 #if 0
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
594 int tc;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
595 for(tc=0; tc<188; tc++)
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
596 fprintf(stderr, "%02x ", *(sp->pat+tc));
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
597 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
598 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
599
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
600 return(result);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
601 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
602
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
603 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
604 * PAT 再構築処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
605 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
606 * PMT から出力対象チャンネル以外のチャンネル情報を削除し、PAT を再構築する
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
607 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
608 static int RecreatePat(splitter *sp, unsigned char *buf, int *pos)
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
609 #if 0
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
610 splitter *sp // [in/out]
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
611 int *pos // [in] 取得対象 PMT のバッファ中の位置
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
612 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
613 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
614 unsigned char y[LENGTH_CRC_DATA];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
615 int crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
616 int i;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
617 int j;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
618 int pos_i;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
619 int pid_num = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
620
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
621 // CRC 計算のためのデータ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
622 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
623 // チャンネルによって変わらない部分
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
624 for (i = 0; i < LENGTH_PAT_HEADER - 4; i++)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
625 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
626 y[i] = buf[i + 5];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
627 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
628
167
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
629 // NIT
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
630 y[LENGTH_PAT_HEADER-4] = 0x00;
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
631 y[LENGTH_PAT_HEADER-3] = 0x00;
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
632 y[LENGTH_PAT_HEADER-2] = 0xe0;
b21f1e823ec3 Import NIT fix patch.(http://microgroove.jp/shaolin/2010/09/a_tiny_patch_for_recpt1tssplitter_litec.html)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 164
diff changeset
633 y[LENGTH_PAT_HEADER-1] = 0x10;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
634
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
635 // チャンネルによって変わる部分
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
636 for (i = 0; i < MAX_PID; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
637 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
638 if(pos[i] != 0)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
639 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
640 /* buf[pos_i] を y にコピー(抽出したPIDの数) */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
641 pos_i = pos[i];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
642 for (j = 0; j < 4; j++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
643 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
644 y[LENGTH_PAT_HEADER + ((4*pid_num) + j)] = buf[pos_i + j];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
645 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
646 pid_num++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
647 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
648 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
649 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
650 /* パケットサイズ計算 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
651 y[2] = pid_num * 4 + 0x0d;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
652 // CRC 計算
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
653 crc = GetCrc32(y, LENGTH_PAT_HEADER + pid_num*4);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
654
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
655 // PAT 再構成
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
656 sp->pat = (unsigned char*)malloc(LENGTH_PACKET);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
657 if(sp->pat == NULL)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
658 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
659 fprintf(stderr, "RecreatePat() malloc error.\n");
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
660 return(TSS_NULL);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
661 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
662 memset(sp->pat, 0xFF, LENGTH_PACKET);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
663 for (i = 0; i < 5; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
664 {
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
665 (sp->pat)[i] = buf[i];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
666 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
667 for (i = 0; i < LENGTH_PAT_HEADER + pid_num*4; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
668 {
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
669 (sp->pat)[i + 5] = y[i];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
670 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
671 (sp->pat)[5 + LENGTH_PAT_HEADER + pid_num*4] = (crc >> 24) & 0xFF;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
672 (sp->pat)[6 + LENGTH_PAT_HEADER + pid_num*4] = (crc >> 16) & 0xFF;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
673 (sp->pat)[7 + LENGTH_PAT_HEADER + pid_num*4] = (crc >> 8) & 0xFF;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
674 (sp->pat)[8 + LENGTH_PAT_HEADER + pid_num*4] = (crc ) & 0xFF;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
675
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
676 return(TSS_SUCCESS);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
677 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
678
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
679 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
680 * PMT 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
681 *
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
682 * PMT を解析し、保存対象の PID を特定する
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
683 */
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
684 static int AnalyzePmt(splitter *sp, unsigned char *buf, unsigned char mark)
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
685 #if 0
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
686 unsigned char* buf, // [in] 読み込んだバッファ
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
687 unsigned char* pids // [out] 出力対象 PID 情報
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
688 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
689 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
690 unsigned char Nall;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
691 unsigned char N;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
692 int pcr;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
693 int epid;
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
694 int pid;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
695 int retry_count = 0;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
696 int count;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
697 int payload_offset; // offset to payload
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
698
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
699 pid = GetPid(&buf[1]);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
700 if (buf[1] & 0x40) { // PES開始インジケータ
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
701 sp->section_remain[pid] = ((buf[6] & 0x0F) << 8) + buf[7] + 3; // セクションサイズ取得(ヘッダ込)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
702 payload_offset = 5;
119
4e7aaa72e158 ES out early release version.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 117
diff changeset
703
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
704 for (count = 0; sp->pmt_retain > count; count++) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
705 if (sp->pmt_version[count].pid == pid) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
706 sp->pmt_version[count].version = buf[10] & 0x3e;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
707 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
708 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
709 // PCR, 番組情報が先頭からはみ出ることはないだろう
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
710
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
711 // PCR
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
712 pcr = GetPid(&buf[payload_offset + 8]);
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
713 sp->pids[pcr] = mark;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
714
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
715 // ECM
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
716 N = ((buf[payload_offset + 10] & 0x0F) << 8) + buf[payload_offset + 11] + payload_offset + 12; // ES情報開始点
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
717 int p = payload_offset + 12;
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
718
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
719 while(p < N) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
720 uint32_t ca_pid;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
721 uint32_t tag;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
722 uint32_t len;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
723
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
724 tag = buf[p];
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
725 len = buf[p+1];
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
726 p += 2;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
727
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
728 if(tag == 0x09 && len >= 4 && p+len <= N) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
729 ca_pid = ((buf[p+2] << 8) | buf[p+3]) & 0x1fff;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
730 sp->pids[ca_pid] = mark;
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
731 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
732 p += len;
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
733 }
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
734 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
735 else {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
736 if (sp->section_remain[pid] == 0) return TSS_ERROR; // セクション先頭が飛んでいる
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
737 if ((buf[3] & 0x0F) != ((sp->packet_seq[pid] + 1) & 0x0F)) return TSS_ERROR; // パケットカウンタが飛んだ
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
738 payload_offset = 4;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
739 N = payload_offset;
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
740 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
741 sp->packet_seq[pid] = buf[3] & 0x0F; // 巡回カウンタ
122
4009737ea899 add es output arg:
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 121
diff changeset
742
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
743 Nall = sp->section_remain[pid];
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
744 if(Nall > LENGTH_PACKET - payload_offset)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
745 Nall = LENGTH_PACKET - payload_offset;
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
746
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
747 // ES PID
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
748 while (N <= Nall + payload_offset - 5)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
749 {
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
750 // ストリーム種別が 0x0D(type D)は出力対象外
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
751 if (0x0D != buf[N])
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
752 {
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
753 epid = GetPid(&buf[N + 1]);
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
754 sp->pids[epid] = mark;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
755 }
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
756 N += 4 + (((buf[N + 3]) & 0x0F) << 8) + buf[N + 4] + 1;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
757 retry_count++;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
758 if(retry_count > Nall) {
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
759 return TSS_ERROR;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
760 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
761 }
183
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
762 sp->section_remain[pid] -= Nall;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
763
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
764 if (sp->section_remain[pid] > 0)
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
765 return SECTION_CONTINUE;
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
766 else
27e5f99f8991 Delete ES out function. Merge Yazawa's tssplitter_lite. Add liner option.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 181
diff changeset
767 return TSS_SUCCESS;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
768 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
769
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
770 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
771 * CRC 計算
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
772 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
773 static int GetCrc32(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
774 unsigned char* data, // [in] CRC 計算対象データ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
775 int len) // [in] CRC 計算対象データ長
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
776 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
777 int crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
778 int i, j;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
779 int c;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
780 int bit;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
781
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
782 crc = 0xFFFFFFFF;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
783 for (i = 0; i < len; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
784 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
785 char x;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
786 x = data[i];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
787
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
788 for (j = 0; j < 8; j++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
789 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
790 bit = (x >> (7 - j)) & 0x1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
791 c = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
792 if (crc & 0x80000000)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
793 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
794 c = 1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
795 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
796 crc = crc << 1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
797 if (c ^ bit)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
798 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
799 crc ^= 0x04C11DB7;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
800 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
801 crc &= 0xFFFFFFFF;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
802 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
803 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
804
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
805 return crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
806 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
807
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
808 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
809 * PID 取得
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
810 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
811 static int GetPid(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
812 unsigned char* data) // [in] 取得対象データのポインタ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
813 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
814 return ((data[0] & 0x1F) << 8) + data[1];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
815 }