# HG changeset patch # User Naoya OYAMA # Date 1349182660 -32400 # Node ID 726fe10d9e4adbebb52042efd4a11aceee6dd473 # Parent 3ffef0e5b80af77427776797360a75128e963745 Code refactoring. Change channel shuld be done in http_open(). Delete unnecessary code, variables. diff -r 3ffef0e5b80a -r 726fe10d9e4a src/http.c --- a/src/http.c Mon Oct 01 21:53:24 2012 +0900 +++ b/src/http.c Tue Oct 02 21:57:40 2012 +0900 @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -46,6 +47,7 @@ #include "mime.h" #include "recpt1.h" #include "tssplitter_lite.h" +#include "pt1_common.h" #define PROTOCOL_TYPE_PRE_SZ 11 /* for the str length of "http-get:*:" */ #define PROTOCOL_TYPE_SUFF_SZ 2 /* for the str length of ":*" */ @@ -109,28 +111,16 @@ upnp_id = atoi (strrchr (filename, '/') + 1); entry = upnp_get_entry (ut, upnp_id); - if (ut->nr_channel == 0) { - if (!strcmp (filename, STREAM_LOCATION)) { - log_verbose ("http_get_info, stream location found.\n"); - info->is_readable = 1; - info->file_length = get_streaming_length(); - info->last_modified = time(NULL); - info->is_directory = 0; - info->content_type = ixmlCloneDOMString ("video/mpeg"); - return 0; - } - } else { - for (i=0; i < ut->nr_channel; i++) { - if (!strcmp(filename, ut->location_name[i])) { - log_verbose ("http_get_info, stream location found [%s].\n", filename); - info->is_readable = 1; - info->file_length = get_streaming_length(); - info->last_modified = time(NULL); - info->is_directory = 0; - info->content_type = ixmlCloneDOMString ("video/mpeg"); - return 0; - } - } + for (i=0; i < ut->channel_list->nr_channel; i++) { + if (!strcmp(filename, ut->channel_list->channel_info[i]->sid)) { + log_verbose ("http_get_info, stream location found [%s].\n", filename); + info->is_readable = 1; + info->file_length = get_streaming_length(); + info->last_modified = time(NULL); + info->is_directory = 0; + info->content_type = ixmlCloneDOMString ("video/mpeg"); + return 0; + } } if (!strcmp (filename, CDS_LOCATION)) { @@ -342,7 +332,9 @@ int i, fd, upnp_id = 0; extern thread_data *gp_tdata; thread_data *tdata = gp_tdata; - int channel_length = 0; + pt1_message_buf mbuf; + int msqid; + int msgflg = IPC_CREAT | 0666; if (!filename) return NULL; @@ -378,9 +370,21 @@ */ for (i=0; i < ut->channel_list->nr_channel; i++) { if (atoi(entry->fullpath) == ut->channel_list->channel_info[i]->id) { - ut->sid = ut->channel_list->channel_info[i]->sid; - ut->tp = ut->channel_list->channel_info[i]->tp; - return get_file_stream (ut->sid, tdata); + if ((msqid = msgget((key_t)getpid(), msgflg)) < 0) { + // エラー時はチャンネル変更リクエストはなかったことにする + fprintf(stderr, "msgget error.\n"); + } + mbuf.mtype = 1; + snprintf(mbuf.mtext, sizeof(mbuf.mtext), + "ch=%s t=%d e=%d i=%s", + ut->channel_list->channel_info[i]->tp, + 0, + 0, + ut->channel_list->channel_info[i]->sid); + if (msgsnd(msqid, &mbuf, strlen(mbuf.mtext)+1, IPC_NOWAIT) < 0) { + fprintf(stderr, "msgsend error.\n"); + } + return get_file_stream (ut->channel_list->channel_info[i]->sid, tdata); } } diff -r 3ffef0e5b80a -r 726fe10d9e4a src/recpt1.c --- a/src/recpt1.c Mon Oct 01 21:53:24 2012 +0900 +++ b/src/recpt1.c Tue Oct 02 21:57:40 2012 +0900 @@ -602,9 +602,6 @@ splitbuf_t splitbuf; ARIB_STD_B25_BUFFER sbuf, dbuf, buf; int code; - pt1_message_buf mbuf; - int msqid; - int msgflg = IPC_CREAT | 0666; if (use_splitter) time(&data->splitter->split_start_time); @@ -714,39 +711,6 @@ * DLNA での物理チャンネル・SID変更の実装実験 */ if ( use_dlna && buf.size > 0 ) { - if (use_splitter && (ut->tp) && (ut->sid)) { - if (strcmp(data->ch, ut->tp) || - strcmp(data->sid_list, ut->sid)) { - if ((msqid = msgget((key_t)getpid(), msgflg)) < 0) { - // エラー時はチャンネル変更リクエストはなかったことにする - // なむなむ - fprintf(stderr, "msgget error.\n"); - ut->tp = data->ch; - free(qbuf); - qbuf = NULL; - ut->sid = data->sid_list; - continue; - } - - mbuf.mtype = 1; - snprintf(mbuf.mtext, sizeof(mbuf.mtext), - "ch=%s t=%d e=%d i=%s", - ut->tp, 0, 0, ut->sid); - if (msgsnd(msqid, &mbuf, strlen(mbuf.mtext)+1, IPC_NOWAIT) < 0) { - // エラー時はチャンネル変更リクエストはなかったことにする - // なむなむ - fprintf(stderr, "msgsend error.\n"); - ut->tp = data->ch; - ut->sid = data->sid_list; - free(qbuf); - qbuf = NULL; - continue; - } - free(qbuf); - qbuf = NULL; - continue; - } - } do { eqbuf = malloc(sizeof(ARIB_STD_B25_BUFFER)); if ( eqbuf == NULL ) { diff -r 3ffef0e5b80a -r 726fe10d9e4a src/ushare.c --- a/src/ushare.c Mon Oct 01 21:53:24 2012 +0900 +++ b/src/ushare.c Tue Oct 02 21:57:40 2012 +0900 @@ -125,23 +125,11 @@ ut->daemon = false; ut->override_iconv_err = false; ut->cfg_file = NULL; + ut->channel_list = channel_list; pthread_mutex_init (&ut->termination_mutex, NULL); pthread_cond_init (&ut->termination_cond, NULL); -#define MAX_CHANNELS 512 - ut->channel_name = malloc(sizeof(char*)*MAX_CHANNELS); - if (!ut->channel_name) - return NULL; - ut->location_name = malloc(sizeof(char*)*MAX_CHANNELS); - if (!ut->location_name) - return NULL; - ut->request_channel[0] = '\0'; - ut->nr_channel = 0; - ut->channel_list = channel_list; - ut->sid = NULL; - ut->tp = NULL; - return ut; } diff -r 3ffef0e5b80a -r 726fe10d9e4a src/ushare.h --- a/src/ushare.h Mon Oct 01 21:53:24 2012 +0900 +++ b/src/ushare.h Tue Oct 02 21:57:40 2012 +0900 @@ -123,13 +123,7 @@ char *cfg_file; pthread_mutex_t termination_mutex; pthread_cond_t termination_cond; - char **channel_name; - char **location_name; - char request_channel[64]; - int nr_channel; struct channel_info_list *channel_list; - char *sid; - char *tp; }; struct action_event_t {