Mercurial > pt1
comparison recpt1/tssplitter_lite.c @ 98:3fd15032fd3a
tweak user interface for sid:
- rename --split option as --sid
- show all available service IDs along with specified SIDs.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 10 Feb 2010 15:02:25 +0900 |
parents | 52f8e081763d |
children | 3a3f15b063e1 |
comparison
equal
deleted
inserted
replaced
97:4d201756c593 | 98:3fd15032fd3a |
---|---|
111 i=0; | 111 i=0; |
112 while( sid_list[i] != NULL ) | 112 while( sid_list[i] != NULL ) |
113 { | 113 { |
114 i++; | 114 i++; |
115 } | 115 } |
116 #if 0 | |
116 for(i=0; sid_list[i] != NULL; i++) | 117 for(i=0; sid_list[i] != NULL; i++) |
117 { | 118 { |
118 printf("sid_list[%d]=[%s].\n",i, sid_list[i]); | 119 printf("sid_list[%d]=[%s].\n",i, sid_list[i]); |
119 } | 120 } |
121 #endif | |
120 return sid_list; | 122 return sid_list; |
121 } | 123 } |
122 | 124 |
123 /** | 125 /** |
124 * 初期化処理 | 126 * 初期化処理 |
323 unsigned char* buf, // [in] 読み込んだバッファ | 325 unsigned char* buf, // [in] 読み込んだバッファ |
324 unsigned char** pat, // [out] PAT 情報(再構築後) | 326 unsigned char** pat, // [out] PAT 情報(再構築後) |
325 unsigned char* pids, // [out] 出力対象 PID 情報 | 327 unsigned char* pids, // [out] 出力対象 PID 情報 |
326 char** sid_list, // [in] 出力対象サービス ID のリスト | 328 char** sid_list, // [in] 出力対象サービス ID のリスト |
327 unsigned char* pmt_pids, // [out] サービス ID に対応する PMT の PID | 329 unsigned char* pmt_pids, // [out] サービス ID に対応する PMT の PID |
328 int* pmt_drop) // [out] 落とすPMTの数 | 330 int* pmt_drop |
331 ) // [out] 落とすPMTの数 | |
329 { | 332 { |
330 int pos[MAX_PID]; | 333 int pos[MAX_PID]; |
331 int service_id; | 334 int service_id; |
332 int i; | 335 int i, j=0, k; |
333 int size = 0; | 336 int size = 0; |
334 int pid; | 337 int pid; |
335 int result = TSS_SUCCESS; | 338 int result = TSS_SUCCESS; |
336 char **p; | 339 char **p; |
337 int sid_found; | 340 int sid_found; |
341 int avail_sids[MAX_SERVICES]; | |
338 | 342 |
339 if (NULL == *pat) | 343 if (NULL == *pat) |
340 { | 344 { |
341 /* 初期化 */ | 345 /* 初期化 */ |
342 *pmt_drop = 0; | 346 *pmt_drop = 0; |
348 /* 最終 4 バイトはCRCなので飛ばす */ | 352 /* 最終 4 バイトはCRCなので飛ばす */ |
349 for (i = 17; i < (size + 8) - 4; i = i + 4) | 353 for (i = 17; i < (size + 8) - 4; i = i + 4) |
350 { | 354 { |
351 sid_found = 0; | 355 sid_found = 0; |
352 service_id = (buf[i] << 8) + buf[i + 1]; | 356 service_id = (buf[i] << 8) + buf[i + 1]; |
357 avail_sids[j] = service_id; | |
353 p = sid_list; | 358 p = sid_list; |
354 while(*p != NULL) | 359 while(*p != NULL) |
355 { | 360 { |
356 if (service_id == atoi(*p)) | 361 if (service_id == atoi(*p)) |
357 { | 362 { |
386 *(pmt_pids+pid) = 1; | 391 *(pmt_pids+pid) = 1; |
387 *(pids+pid) = 1; | 392 *(pids+pid) = 1; |
388 pos[pid] = i; | 393 pos[pid] = i; |
389 *(pmt_drop) = *(pmt_drop)+1; | 394 *(pmt_drop) = *(pmt_drop)+1; |
390 } | 395 } |
391 } | 396 j++; |
397 } | |
398 fprintf(stderr, "Available sid = "); | |
399 for(k=0; k<j; k++) | |
400 fprintf(stderr, "%d ", avail_sids[k]); | |
401 fprintf(stderr, "\n"); | |
402 | |
403 fprintf(stderr, "Chosen sid = "); | |
404 p = sid_list; | |
405 while(*p != NULL) { | |
406 fprintf(stderr, "%s ", *p); | |
407 p++; | |
408 } | |
409 fprintf(stderr, "\n"); | |
410 | |
392 // PAT 再構築 | 411 // PAT 再構築 |
393 result = RecreatePat(buf, pat, pids, pos); | 412 result = RecreatePat(buf, pat, pids, pos); |
394 } | 413 } |
395 | 414 |
396 return(result); | 415 return(result); |