diff 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
line wrap: on
line diff
--- a/src/tssplitter_lite.c	Thu Aug 16 21:57:34 2012 +0900
+++ b/src/tssplitter_lite.c	Tue Aug 21 04:21:11 2012 +0900
@@ -30,6 +30,8 @@
 #include "decoder.h"
 #include "recpt1.h"
 #include "tssplitter_lite.h"
+#include "ushare.h"
+#include "metadata.h"
 
 #ifndef AV_RB32
 #define AV_RB32(x)  ((((const uint8_t*)(x))[0] << 24) | \
@@ -52,6 +54,9 @@
 #define TSS_STREAM_TYPE_AUDIO (1)
 #define TSS_STREAM_TYPE_VIDEO (2)
 
+//global
+extern struct ushare_t *ut;
+
 /* prototypes */
 static int ReadTs(splitter *sp, ARIB_STD_B25_BUFFER *sbuf);
 static int AnalyzePat(splitter *sp, unsigned char *buf);
@@ -248,6 +253,8 @@
 		sp->program[i].cue = INT64_MAX;
 	}
 	memset(sp->pid_sid_table, 0, sizeof(int)*MAX_PID);
+	sp->filename = NULL;
+	sp->esout    = 0;
 	if ( filename != NULL ) {
 		sp->esout = 1;
 		sp->filename = filename;
@@ -282,6 +289,11 @@
 {
 	int i = 0;
 	if ( sp != NULL ) {
+		if ( sp->program != NULL )
+		{
+			free(sp->program);
+			sp->program = NULL;
+		}
 		if ( sp->pat != NULL )
 		{
 			free(sp->pat);
@@ -724,8 +736,32 @@
 
 		/* print SIDs */
 		fprintf(stderr, "Available sid = ");
-		for(k=0; k < sp->num_pmts; k++)
+		for(k=0; k < sp->num_pmts; k++) {
 			fprintf(stderr, "%d ", avail_sids[k]);
+			/* ut->channel_name にSID番号を入れる
+			 * ushare 側(TV表示上)には channel_name を表示させる
+			 * TODO 局名も含めて入れたいなぁ
+			 */
+#define CHANNEL_NAME_LENGTH (64)
+			ut->channel_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
+			if(!ut->channel_name[ut->nr_channel])
+				return TSS_NULL;
+			snprintf(ut->channel_name[ut->nr_channel],
+					CHANNEL_NAME_LENGTH,
+					"%d.ts",
+					avail_sids[k]);
+			ut->location_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
+			if(!ut->location_name[ut->nr_channel])
+				return TSS_NULL;
+			snprintf(ut->location_name[ut->nr_channel],
+					CHANNEL_NAME_LENGTH,
+					VIRTUAL_DIR "/%d.ts",
+					avail_sids[k]);
+			ut->nr_channel += 1;
+		}
+		// metadata list を作り直す
+		free_metadata_list(ut);
+		build_metadata_list(ut);
 		fprintf(stderr, "\n");
 		fprintf(stderr, "Chosen sid    =%s\n", chosen_sid);