Mercurial > pt1.oyama
diff src/http.c @ 166:726fe10d9e4a
Code refactoring.
Change channel shuld be done in http_open().
Delete unnecessary code, variables.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Tue, 02 Oct 2012 21:57:40 +0900 |
parents | 5d010d0ff6a1 |
children | 27e5f99f8991 |
line wrap: on
line diff
--- 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 <sys/types.h> +#include <sys/msg.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> @@ -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) { + // $B%(%i!<;~$O%A%c%s%M%kJQ99%j%/%(%9%H$O$J$+$C$?$3$H$K$9$k(B + 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); } }