comparison src/tssplitter_lite.c @ 146:066f33b2213a

EXPERIMENTAL: Select a particular program from multi-channel.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Tue, 21 Aug 2012 04:21:11 +0900
parents e72dd5e8d53f
children a9f60d56d673
comparison
equal deleted inserted replaced
145:4e39ce051c57 146:066f33b2213a
28 #include <math.h> 28 #include <math.h>
29 #include <time.h> 29 #include <time.h>
30 #include "decoder.h" 30 #include "decoder.h"
31 #include "recpt1.h" 31 #include "recpt1.h"
32 #include "tssplitter_lite.h" 32 #include "tssplitter_lite.h"
33 #include "ushare.h"
34 #include "metadata.h"
33 35
34 #ifndef AV_RB32 36 #ifndef AV_RB32
35 #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ 37 #define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \
36 (((const uint8_t*)(x))[1] << 16) | \ 38 (((const uint8_t*)(x))[1] << 16) | \
37 (((const uint8_t*)(x))[2] << 8) | \ 39 (((const uint8_t*)(x))[2] << 8) | \
49 #endif 51 #endif
50 #define MAX_SERVICE_ID ( 0xffff ) 52 #define MAX_SERVICE_ID ( 0xffff )
51 #define LIST_DECIMAL "0123456789" 53 #define LIST_DECIMAL "0123456789"
52 #define TSS_STREAM_TYPE_AUDIO (1) 54 #define TSS_STREAM_TYPE_AUDIO (1)
53 #define TSS_STREAM_TYPE_VIDEO (2) 55 #define TSS_STREAM_TYPE_VIDEO (2)
56
57 //global
58 extern struct ushare_t *ut;
54 59
55 /* prototypes */ 60 /* prototypes */
56 static int ReadTs(splitter *sp, ARIB_STD_B25_BUFFER *sbuf); 61 static int ReadTs(splitter *sp, ARIB_STD_B25_BUFFER *sbuf);
57 static int AnalyzePat(splitter *sp, unsigned char *buf); 62 static int AnalyzePat(splitter *sp, unsigned char *buf);
58 static int RecreatePat(splitter *sp, unsigned char *buf, int *pos); 63 static int RecreatePat(splitter *sp, unsigned char *buf, int *pos);
246 sp->program[i].pmt_version = -1; 251 sp->program[i].pmt_version = -1;
247 /* cue は最大値で初期化(CUE <= STCとなると録画開始するため) */ 252 /* cue は最大値で初期化(CUE <= STCとなると録画開始するため) */
248 sp->program[i].cue = INT64_MAX; 253 sp->program[i].cue = INT64_MAX;
249 } 254 }
250 memset(sp->pid_sid_table, 0, sizeof(int)*MAX_PID); 255 memset(sp->pid_sid_table, 0, sizeof(int)*MAX_PID);
256 sp->filename = NULL;
257 sp->esout = 0;
251 if ( filename != NULL ) { 258 if ( filename != NULL ) {
252 sp->esout = 1; 259 sp->esout = 1;
253 sp->filename = filename; 260 sp->filename = filename;
254 } 261 }
255 if ( arg_cue != NULL ) { 262 if ( arg_cue != NULL ) {
280 */ 287 */
281 void split_shutdown(splitter* sp) 288 void split_shutdown(splitter* sp)
282 { 289 {
283 int i = 0; 290 int i = 0;
284 if ( sp != NULL ) { 291 if ( sp != NULL ) {
292 if ( sp->program != NULL )
293 {
294 free(sp->program);
295 sp->program = NULL;
296 }
285 if ( sp->pat != NULL ) 297 if ( sp->pat != NULL )
286 { 298 {
287 free(sp->pat); 299 free(sp->pat);
288 sp->pat = NULL; 300 sp->pat = NULL;
289 } 301 }
722 } 734 }
723 } 735 }
724 736
725 /* print SIDs */ 737 /* print SIDs */
726 fprintf(stderr, "Available sid = "); 738 fprintf(stderr, "Available sid = ");
727 for(k=0; k < sp->num_pmts; k++) 739 for(k=0; k < sp->num_pmts; k++) {
728 fprintf(stderr, "%d ", avail_sids[k]); 740 fprintf(stderr, "%d ", avail_sids[k]);
741 /* ut->channel_name にSID番号を入れる
742 * ushare 側(TV表示上)には channel_name を表示させる
743 * TODO 局名も含めて入れたいなぁ
744 */
745 #define CHANNEL_NAME_LENGTH (64)
746 ut->channel_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
747 if(!ut->channel_name[ut->nr_channel])
748 return TSS_NULL;
749 snprintf(ut->channel_name[ut->nr_channel],
750 CHANNEL_NAME_LENGTH,
751 "%d.ts",
752 avail_sids[k]);
753 ut->location_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
754 if(!ut->location_name[ut->nr_channel])
755 return TSS_NULL;
756 snprintf(ut->location_name[ut->nr_channel],
757 CHANNEL_NAME_LENGTH,
758 VIRTUAL_DIR "/%d.ts",
759 avail_sids[k]);
760 ut->nr_channel += 1;
761 }
762 // metadata list を作り直す
763 free_metadata_list(ut);
764 build_metadata_list(ut);
729 fprintf(stderr, "\n"); 765 fprintf(stderr, "\n");
730 fprintf(stderr, "Chosen sid =%s\n", chosen_sid); 766 fprintf(stderr, "Chosen sid =%s\n", chosen_sid);
731 767
732 #if 0 768 #if 0
733 /* print PMTs */ 769 /* print PMTs */