annotate recpt1/tssplitter_lite.c @ 125:a910b49dfbee

work in progress improvement: - fix bugs around cond_timedwait - try to avoid sticking in PMT analysis
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 21 Feb 2012 15:46:04 +0900
parents 38091ff0c8ed
children 8e0f7191b92e
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 -*- */
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
2 /* tssplitter_lite.c -- split TS stream.
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
3
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
4 Copyright 2009 querulous
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
5 Copyright 2010 Naoya OYAMA <naoya.oyama@gmail.com>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
6
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
7 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
8 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
9 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
10 (at your option) any later version.
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
12 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
13 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
14 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
15 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
16
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
17 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
18 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
19
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 #include <stdlib.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
21 #include <stdio.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
22 #include <string.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
23 #include <ctype.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25 #include <fcntl.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26 #include <sys/stat.h>
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
27 #include "decoder.h"
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28 #include "recpt1.h"
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 #include "tssplitter_lite.h"
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
31 /* prototypes */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
32 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
33 static int AnalyzePat(splitter *sp, unsigned char *buf);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
34 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
35 static char** AnalyzeSid(char *sid);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
36 static int AnalyzePmt(splitter *sp, unsigned char *buf);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
37 static int GetCrc32(unsigned char *data, int len);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
38 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
39
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 * サービスID解析
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
43 static char** AnalyzeSid(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44 char* sid) // [in] サービスID(カンマ区切りテキスト)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
45 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
46 int i = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
47 char** sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
48 char* p;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49 int CommaNum = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
50
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 /* sid は次の形式の引数を許容する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52 /* 指定無し */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 /* SID[0] */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54 /* 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
55
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 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
58 while(*p != '\0')
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
59 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60 if( *p == C_CHAR_COMMA ){
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
61 CommaNum++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
63 p++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
64 }
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 /* sid_listの数はカンマの数+2(NULL止めするから) */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
67 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
68 if ( sid_list == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
69 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
70 fprintf(stderr, "AnalyzeSid() malloc error.\n");
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72 }
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 /* sidが空である場合 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
75 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
76 if ( strlen(p) == 0 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 sid_list[0] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
79 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
80 }
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 if ( CommaNum == 0 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 sid_list[0] = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86 sid_list[1] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
88 }
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 i=0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
92 p = sid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93 /* 文字列端に到達するか、カンマ数が数えた数に達したら終了 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
94 while((*p != '\0') || i < CommaNum)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
95 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
96 /* 現在の処理位置をsid_list[i]にセット */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 /* このタイミングの p は
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
98 * ・sid先頭
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99 * ・[,]の次の文字
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100 * いずれかであるので p を sid_list[i] に代入してよい
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102 sid_list[i] = p;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
103 i++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
105 /* 最初に現れる[,]をNULL文字で置換する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106 p = strchr(p, C_CHAR_COMMA);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
107 if ( p == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 {
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 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112 *p = '\0';
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113 /* 処理位置をNULLで置換した文字の次の位置に設定する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
114 p++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
115 }
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 /* 最後のsid_list[n]はNULLポインタで止める */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118 sid_list[i] = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120 i=0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121 while( sid_list[i] != NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
123 i++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
124 }
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
125 #if 0
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126 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
127 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128 printf("sid_list[%d]=[%s].\n",i, sid_list[i]);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129 }
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
130 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131 return sid_list;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
132 }
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 splitter* split_startup(
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
138 char *sid // [in] サービスID(引数で指定した文字列)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139 )
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 splitter* sp;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
142 sp = malloc(sizeof(splitter));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 if ( sp == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145 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
146 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 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
149 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
150
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 sp->sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
152 sp->pat = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
153 sp->sid_list = AnalyzeSid(sid);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
154 if ( sp->sid_list == NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
155 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
156 free(sp);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157 return NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
158 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 sp->pat_count = 0xFF;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
160 sp->pmt_retain = -1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
161 sp->pmt_counter = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
163 return sp;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
165
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
166 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 * 落とすPIDを確定させる
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
168 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
169 int split_select(
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
170 splitter *sp, // [in/out] splitter構造体
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171 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
172 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
174 int result;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
175 // TS解析
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
176 result = ReadTs(sp, sbuf);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
177
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178 return result;
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
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
181 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
182 * 終了処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
184 void split_shutdown(splitter* sp)
96
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 if ( sp != NULL ) {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
187 if ( sp->pat != NULL )
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 free(sp->pat);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190 sp->pat = NULL;
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->sid_list != NULL )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
193 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
194 free(sp->sid_list);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
195 sp->sid_list = NULL;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
197 free(sp);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
198 sp = 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 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
201
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 * TS 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205 * 対象のチャンネル番号のみの PAT の再構築と出力対象 PID の抽出を行う
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
206 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
207 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
208 {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
209 #if 0
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
210 unsigned char **pat, // [out] PAT 情報(再構築後)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
211 unsigned char* pids, // [out] 出力対象 PID 情報
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
212 char** sid_list, // [in] 出力対象サービス ID のリスト
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
213 unsigned char* pmt_pids, // [in] 出力対象PIDのPMT PID
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
214 , // [in] pt1_drvの入力TS
101
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
215 int* pmt_retain, // [in] 残すべきPMTの数
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
216 int* pmt_counter // [out] 残したPMTの数
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
217 #endif
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
218
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
219 int length = sbuf->size;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
220 int pid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
221 int result = TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
222 int index;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
223
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224 index = 0;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
225 while(length - index - LENGTH_PACKET > 0) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
226 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
227 // PAT
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
228 if(0x0000 == pid) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
229 result = AnalyzePat(sp, sbuf->data + index);
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
230 if(result != TSS_SUCCESS) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
231 /* 下位の関数内部でmalloc error発生 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
232 return result;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
233 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
234 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
235
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236 // PMT
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
237 /* 残すpmt_pidである場合には、pmtに書かれている
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
238 * 残すべきPCR/AUDIO/VIDEO PIDを取得する */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
239 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
240 /* この中にはPMT毎に一度しか入らないようにしておく */
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
241 result = AnalyzePmt(sp, sbuf->data + index);
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
242 if(result != TSS_SUCCESS) {
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
243 return result;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
244 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
245 sp->pmt_pids[pid]++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
246 sp->pmt_counter += 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
248 /* 録画する全てのPMTについて、中にあるPCR/AUDIO/VIDEOのPIDを
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
249 * 得る */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
250 /* pmt_counter と pmt_retain が一致する場合に条件は満たされる */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
251 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
252 result = TSS_SUCCESS;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
255 else {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
256 result = TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
257 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 index += LENGTH_PACKET;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
259 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
260
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
261 return(result);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
262 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
263
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 * TS 分離処理
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 int split_ts(
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
268 splitter *splitter, // [in] splitterパラメータ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
269 ARIB_STD_B25_BUFFER *sbuf, // [in] 入力TS
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
270 splitbuf_t *dbuf // [out] 出力TS
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
271 )
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
272 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
273 int pid;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
274 unsigned char *sptr, *dptr;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
275 int s_offset = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
276 int d_offset = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
277
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
278 /* 初期化 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
279 dbuf->size = 0;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
280 if (sbuf->size < 0) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
281 return TSS_ERROR;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
282 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
283
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
284 sptr = sbuf->data;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
285 dptr = dbuf->buffer;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
286
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
287 while(sbuf->size > s_offset) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
288 pid = GetPid(sptr + s_offset + 1);
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
289 switch(pid) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
290
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
291 // PAT
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
292 case 0x0000:
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
293 // 巡回カウンタカウントアップ
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
294 if(0xFF == splitter->pat_count) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
295 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
296 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
297 else {
101
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
298 splitter->pat_count += 1;
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
299 if(0 == splitter->pat_count % 0x10) {
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
300 splitter->pat_count -= 0x10;
3f7288b0672c fix calculation for continuity counter
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
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 splitter->pat[3] = splitter->pat_count;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
304
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
305 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
306 d_offset += LENGTH_PACKET;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
307 dbuf->size += LENGTH_PACKET;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
308 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
309 default:
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
310 /* pids[pid] が 1 は残すパケットなので書き込む */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
311 if(1 == splitter->pids[pid]) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
312 memcpy(dptr + d_offset, sptr + s_offset, LENGTH_PACKET);
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
313 d_offset += LENGTH_PACKET;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
314 dbuf->size += LENGTH_PACKET;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
315 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
316 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
317 } /* switch */
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
318
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
319 s_offset += LENGTH_PACKET;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
320 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
321
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
322 return(TSS_SUCCESS);
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
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
325 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
326 * PAT 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
327 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
328 * PAT を解析し、出力対象チャンネルが含まれているかチェックを行い、PAT を再構築する
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
329 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
330 static int AnalyzePat(splitter *sp, unsigned char *buf)
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
331 #if 0
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
332 unsigned char* buf, // [in] 読み込んだバッファ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
333 unsigned char** pat, // [out] PAT 情報(再構築後)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
334 unsigned char* pids, // [out] 出力対象 PID 情報
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
335 char** sid_list, // [in] 出力対象サービス ID のリスト
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
336 unsigned char* pmt_pids, // [out] サービス ID に対応する PMT の PID
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
337 int* pmt_retain // [out] 残すPMTの数
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
338 )
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
339 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
340 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
341 int pos[MAX_PID];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
342 int service_id;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
343 int i, j, k;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
344 int size = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
345 int pid;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
346 int result = TSS_SUCCESS;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
347 char **p;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
348 int sid_found = FALSE;
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
349 int avail_sids[MAX_SERVICES];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
350
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
351 unsigned char *pat = sp->pat;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
352 unsigned char *pids = sp->pids;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
353 char **sid_list = sp->sid_list;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
354 unsigned char *pmt_pids = sp->pmt_pids;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
355
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
356 char chosen_sid[512];
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
357 chosen_sid[0] = '\0';
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
358
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
359 if(pat == NULL) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
360 /* 初期化 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
361 sp->pmt_retain = 0;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
362 memset(pos, 0, sizeof(pos));
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
363 size = buf[7];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
364
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
365 /* prescan SID/PMT */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
366 for(i = 17, j = 0; i < (size + 8) - 4; i = i + 4, j++) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
367 avail_sids[j] = (buf[i] << 8) + buf[i+1];
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
368 sp->avail_pmts[j] = GetPid(&buf[i+2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
369 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
370 sp->num_pmts = j;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
371
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
372 // 対象チャンネル判定
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
373 /* size + 8 = パケット全長 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
374 /* 最終 4 バイトはCRCなので飛ばす */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
375 for(i = 17; i < (size + 8) - 4; i = i + 4) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
376
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
377 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
378 p = sid_list;
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 while(*p) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
381 if(service_id == atoi(*p)) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
382 /* 録画対象の pmt_pids は 1 とする */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
383 /* 録画対象の pmt の pids は 1 とする */
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
384 pid = GetPid(&buf[i + 2]);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
385 *(pmt_pids+pid) = 1;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
386 *(pids+pid) = 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
387 pos[pid] = i;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
388 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
389 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
390 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
391 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
392 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
393 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
394 else if(!strcasecmp(*p, "hd") || !strcasecmp(*p, "sd1")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
395 /* hd/sd1 指定時には1番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
396 if(service_id == avail_sids[0]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
397 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
398 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
399 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
400 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
401 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
402 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
403 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
404 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
405 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
406 continue;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
407 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
408 else if(!strcasecmp(*p, "sd2")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
409 /* sd2 指定時には2番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
410 if(service_id == avail_sids[1]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
411 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
412 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
413 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
414 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
415 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
416 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
417 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
418 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
419 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
420 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
421 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
422 else if(!strcasecmp(*p, "sd3")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
423 /* sd3 指定時には3番目のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
424 if(service_id == avail_sids[2]) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
425 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
426 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
427 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
428 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
429 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
430 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
431 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
432 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
433 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
434 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
435 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
436 else if(!strcasecmp(*p, "1seg")) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
437 /* 1seg 指定時には PMTPID=0x1FC8 のサービスを保存する */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
438 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
439 if(pid == 0x1FC8) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
440 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
441 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
442 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
443 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
444 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
445 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
446 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
447 p++;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
448 continue;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
449 }
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
450 else if(!strcasecmp(*p, "all")) {
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
451 /* all指定時には全保存する */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
452 pid = GetPid(&buf[i + 2]);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
453 *(pmt_pids+pid) = 1;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
454 *(pids+pid) = 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
455 pos[pid] = i;
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
456 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
457 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
458 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
459 break;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
460 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
461
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
462 p++;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
463 } /* while */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
464 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
465
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
466 /* 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
467 if(*sid_list && !sid_found) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
468 for(i = 17; i < (size + 8) - 4; i = i + 4) {
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
469 service_id = (buf[i] << 8) + buf[i+1];
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
470 pid = GetPid(&buf[i + 2]);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
471 *(pmt_pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
472 *(pids+pid) = 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
473 pos[pid] = i;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
474 sid_found = TRUE;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
475 sp->pmt_retain += 1;
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
476 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
477 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
478 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
479
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
480 /* print SIDs */
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
481 fprintf(stderr, "Available sid = ");
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
482 for(k=0; k < sp->num_pmts; k++)
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
483 fprintf(stderr, "%d ", avail_sids[k]);
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
484 fprintf(stderr, "\n");
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
485 fprintf(stderr, "Chosen sid =%s\n", chosen_sid);
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
486
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
487 #if 0
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
488 /* print PMTs */
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
489 fprintf(stderr, "Available PMT = ");
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
490 for(k=0; k < sp->num_pmts; k++)
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
491 fprintf(stderr, "%d ", sp->avail_pmts[k]);
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
492 fprintf(stderr, "\n");
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
493 #endif
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 96
diff changeset
494
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
495 // PAT 再構築
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
496 result = RecreatePat(sp, buf, pos);
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
497 #if 0
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
498 int tc;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
499 for(tc=0; tc<188; tc++)
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
500 fprintf(stderr, "%02x ", *(pat+tc));
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
501 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
502 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
503
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
504 return(result);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
505 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
506
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
507 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
508 * PAT 再構築処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
509 *
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
510 * PMT から出力対象チャンネル以外のチャンネル情報を削除し、PAT を再構築する
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
511 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
512 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
513 #if 0
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
514 unsigned char* buf, // [in] 読み込んだバッファ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
515 unsigned char** pat, // [out] PAT 情報(再構築後)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
516 unsigned char* pids, // [out] 出力対象 PID 情報
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
517 int *pos) // [in] 取得対象 PMT のバッファ中の位置
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
518 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
519 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
520 unsigned char y[LENGTH_CRC_DATA];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
521 int crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
522 int i;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
523 int j;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
524 int pos_i;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
525 int pid_num = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
526
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
527 // CRC 計算のためのデータ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
528 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
529 // チャンネルによって変わらない部分
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
530 for (i = 0; i < LENGTH_PAT_HEADER; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
531 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
532 y[i] = buf[i + 5];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
533 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
534 // チャンネルによって変わる部分
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
535 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
536 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
537 if(pos[i] != 0)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
538 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
539 /* buf[pos_i] を y にコピー(抽出したPIDの数) */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
540 pos_i = pos[i];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
541 for (j = 0; j < 4; j++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
542 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
543 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
544 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
545 pid_num++;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
546 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
547 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
548 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
549 /* パケットサイズ計算 */
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
550 y[2] = pid_num * 4 + 0x0d;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
551 // CRC 計算
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
552 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
553
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
554 // PAT 再構成
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
555 sp->pat = (unsigned char*)malloc(LENGTH_PACKET);
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
556 if(sp->pat == NULL)
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
557 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
558 fprintf(stderr, "RecreatePat() malloc error.\n");
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
559 return(TSS_NULL);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
560 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
561 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
562 for (i = 0; i < 5; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
563 {
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
564 (sp->pat)[i] = buf[i];
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
565 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
566 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
567 {
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
568 (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
569 }
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
570 (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
571 (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
572 (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
573 (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
574
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
575 return(TSS_SUCCESS);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
576 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
577
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
578 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
579 * PMT 解析処理
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
580 *
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
581 * PMT を解析し、保存対象の PID を特定する
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
582 */
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
583 static int AnalyzePmt(splitter *sp, unsigned char *buf)
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
584 #if 0
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
585 unsigned char* buf, // [in] 読み込んだバッファ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
586 unsigned char* pids) // [out] 出力対象 PID 情報
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
587 #endif
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
588 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
589 unsigned char Nall;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
590 unsigned char N;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
591 int pcr;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
592 int epid;
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
593 int retry_count = 0;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
594
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
595 Nall = ((buf[6] & 0x0F) << 4) + buf[7];
112
38091ff0c8ed add a workaround for stucking on AnalyzePmt().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 107
diff changeset
596 if(Nall > LENGTH_PACKET)
38091ff0c8ed add a workaround for stucking on AnalyzePmt().
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 107
diff changeset
597 Nall = LENGTH_PACKET - 8; /* xxx workaround --yaz */
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 // PCR
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
600 pcr = GetPid(&buf[13]);
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
601 sp->pids[pcr] = 1;
96
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 N = ((buf[15] & 0x0F) << 4) + buf[16] + 16 + 1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
604
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
605 // ECM
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
606 int p = 17;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
607 while(p < N) {
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
608 uint32_t ca_pid;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
609 uint32_t tag;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
610 uint32_t len;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
611
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
612 tag = buf[p];
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
613 len = buf[p+1];
107
1ccbe20c4ce5 fix ECM more
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 106
diff changeset
614 p += 2;
106
12b9192becaa avoid infinite loop. length in the first descriptor loop can be zero.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 104
diff changeset
615
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
616 if(tag == 0x09 && len >= 4 && p+len <= N) {
107
1ccbe20c4ce5 fix ECM more
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 106
diff changeset
617 ca_pid = ((buf[p+2] << 8) | buf[p+3]) & 0x1fff;
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
618 sp->pids[ca_pid] = 1;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
619 }
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
620 p += len;
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
621 }
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 101
diff changeset
622
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
623 // ES PID
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
624 while (N < Nall + 8 - 4)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
625 {
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
626 // ストリーム種別が 0x0D(type D)は出力対象外
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
627 if (0x0D != buf[N])
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
628 {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
629 epid = GetPid(&buf[N + 1]);
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
630
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
631 sp->pids[epid] = 1;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
632 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
633 N += 4 + (((buf[N + 3]) & 0x0F) << 4) + buf[N + 4] + 1;
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
634 retry_count++;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
635 if(retry_count > Nall) {
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
636 return TSS_ERROR;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 112
diff changeset
637 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
638 }
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 return TSS_SUCCESS;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
641 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
642
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 * CRC 計算
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
645 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
646 static int GetCrc32(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
647 unsigned char* data, // [in] CRC 計算対象データ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
648 int len) // [in] CRC 計算対象データ長
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 int crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
651 int i, j;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
652 int c;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
653 int bit;
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 crc = 0xFFFFFFFF;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
656 for (i = 0; i < len; i++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
657 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
658 char x;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
659 x = data[i];
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
660
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
661 for (j = 0; j < 8; j++)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
662 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
663
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
664 bit = (x >> (7 - j)) & 0x1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
665
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
666 c = 0;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
667 if (crc & 0x80000000)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
668 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
669 c = 1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
670 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
671
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
672 crc = crc << 1;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
673
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
674 if (c ^ bit)
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
675 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
676 crc ^= 0x04C11DB7;
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 crc &= 0xFFFFFFFF;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
680 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
681 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
682
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
683 return crc;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
684 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
685
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
686 /**
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
687 * PID 取得
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
688 */
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
689 static int GetPid(
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
690 unsigned char* data) // [in] 取得対象データのポインタ
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
691 {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
692 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
693 }