Mercurial > pt1.oyama
comparison src/http.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 | 2a9ac5ce2c7e |
children | a9f60d56d673 |
comparison
equal
deleted
inserted
replaced
145:4e39ce051c57 | 146:066f33b2213a |
---|---|
95 static int | 95 static int |
96 http_get_info (const char *filename, struct File_Info *info) | 96 http_get_info (const char *filename, struct File_Info *info) |
97 { | 97 { |
98 extern struct ushare_t *ut; | 98 extern struct ushare_t *ut; |
99 struct upnp_entry_t *entry = NULL; | 99 struct upnp_entry_t *entry = NULL; |
100 int upnp_id = 0; | 100 int i, upnp_id = 0; |
101 char *content_type = NULL; | 101 char *content_type = NULL; |
102 char *protocol = NULL; | 102 char *protocol = NULL; |
103 | 103 |
104 if (!filename || !info) | 104 if (!filename || !info) |
105 return -1; | 105 return -1; |
107 log_verbose ("http_get_info, filename : %s\n", filename); | 107 log_verbose ("http_get_info, filename : %s\n", filename); |
108 | 108 |
109 upnp_id = atoi (strrchr (filename, '/') + 1); | 109 upnp_id = atoi (strrchr (filename, '/') + 1); |
110 entry = upnp_get_entry (ut, upnp_id); | 110 entry = upnp_get_entry (ut, upnp_id); |
111 | 111 |
112 #if 0 | 112 if (ut->nr_channel == 0) { |
113 if ( (!strcmp (filename, STREAM_LOCATION)) || | 113 if (!strcmp (filename, STREAM_LOCATION)) { |
114 ( (entry->fullpath != NULL) && | 114 log_verbose ("http_get_info, stream location found.\n"); |
115 ( !strcmp(entry->fullpath, STREAM_LOCATION))) ) { | 115 info->is_readable = 1; |
116 #endif | 116 info->file_length = get_streaming_length(); |
117 if (!strcmp (filename, STREAM_LOCATION)) { | 117 info->last_modified = time(NULL); |
118 log_verbose ("http_get_info, stream location found.\n"); | 118 info->is_directory = 0; |
119 info->is_readable = 1; | 119 info->content_type = ixmlCloneDOMString ("video/mpeg"); |
120 info->file_length = get_streaming_length(); | 120 return 0; |
121 info->last_modified = time(NULL); | 121 } |
122 info->is_directory = 0; | 122 } else { |
123 info->content_type = ixmlCloneDOMString ("video/mpeg"); | 123 for (i=0; i < ut->nr_channel; i++) { |
124 return 0; | 124 if (!strcmp(filename, ut->location_name[i])) { |
125 log_verbose ("http_get_info, stream location found [%s].\n", filename); | |
126 info->is_readable = 1; | |
127 info->file_length = get_streaming_length(); | |
128 info->last_modified = time(NULL); | |
129 info->is_directory = 0; | |
130 info->content_type = ixmlCloneDOMString ("video/mpeg"); | |
131 return 0; | |
132 } | |
133 } | |
125 } | 134 } |
126 if (!strcmp (filename, CDS_LOCATION)) | 135 if (!strcmp (filename, CDS_LOCATION)) |
127 { | 136 { |
128 set_info_file (info, CDS_DESCRIPTION_LEN, SERVICE_CONTENT_TYPE); | 137 set_info_file (info, CDS_DESCRIPTION_LEN, SERVICE_CONTENT_TYPE); |
129 return 0; | 138 return 0; |
328 http_open (const char *filename, enum UpnpOpenFileMode mode) | 337 http_open (const char *filename, enum UpnpOpenFileMode mode) |
329 { | 338 { |
330 extern struct ushare_t *ut; | 339 extern struct ushare_t *ut; |
331 struct upnp_entry_t *entry = NULL; | 340 struct upnp_entry_t *entry = NULL; |
332 struct web_file_t *file; | 341 struct web_file_t *file; |
333 int fd, upnp_id = 0; | 342 int i, fd, upnp_id = 0; |
334 extern thread_data *gp_tdata; | 343 extern thread_data *gp_tdata; |
335 thread_data *tdata = gp_tdata; | 344 thread_data *tdata = gp_tdata; |
345 int channel_length = 0; | |
336 | 346 |
337 if (!filename) | 347 if (!filename) |
338 return NULL; | 348 return NULL; |
339 | 349 |
340 if (mode != UPNP_READ) | 350 if (mode != UPNP_READ) |
365 /* | 375 /* |
366 * 1. http_open() $B$G$O(B entry $B$,%9%H%j!<%`:F@8MQ$N$b$N$G$"$k>l9g$K!"(B | 376 * 1. http_open() $B$G$O(B entry $B$,%9%H%j!<%`:F@8MQ$N$b$N$G$"$k>l9g$K!"(B |
367 * get_file_stream()$B$r8F$S=P$7%O%s%I%i$rJV5Q$9$k(B | 377 * get_file_stream()$B$r8F$S=P$7%O%s%I%i$rJV5Q$9$k(B |
368 */ | 378 */ |
369 log_verbose ("Fullpath : %s\n", entry->fullpath); | 379 log_verbose ("Fullpath : %s\n", entry->fullpath); |
370 if (!strcmp (entry->fullpath, STREAM_LOCATION)) | 380 if (ut->nr_channel == 0) { |
371 return get_file_stream (STREAM_LOCATION, tdata); | 381 if (!strcmp (entry->fullpath, STREAM_LOCATION)) |
382 return get_file_stream (STREAM_LOCATION, tdata); | |
383 } else { | |
384 for (i=0; i < ut->nr_channel; i++) | |
385 if (!strcmp(entry->fullpath, ut->location_name[i])) { | |
386 channel_length = strspn(ut->channel_name[i], "0123456789"); | |
387 strncpy(ut->request_channel, ut->channel_name[i], channel_length); | |
388 log_verbose ("http_open: request_channel[%s].\n", ut->request_channel); | |
389 return get_file_stream (ut->location_name[i], tdata); | |
390 } | |
391 } | |
372 | 392 |
373 fd = open (entry->fullpath, O_RDONLY | O_NONBLOCK | O_SYNC | O_NDELAY); | 393 fd = open (entry->fullpath, O_RDONLY | O_NONBLOCK | O_SYNC | O_NDELAY); |
374 if (fd < 0) | 394 if (fd < 0) |
375 return NULL; | 395 return NULL; |
376 | 396 |
526 } | 546 } |
527 | 547 |
528 static int | 548 static int |
529 http_close (UpnpWebFileHandle fh) | 549 http_close (UpnpWebFileHandle fh) |
530 { | 550 { |
551 extern struct ushare_t *ut; | |
531 struct web_file_t *file = (struct web_file_t *) fh; | 552 struct web_file_t *file = (struct web_file_t *) fh; |
532 extern thread_data *gp_tdata; | 553 extern thread_data *gp_tdata; |
533 thread_data *tdata = gp_tdata; | 554 thread_data *tdata = gp_tdata; |
534 STREAM_QUEUE_T *p_queue; | 555 STREAM_QUEUE_T *p_queue; |
535 int id = 0; | 556 int id = 0; |
567 p_queue->num_used--; | 588 p_queue->num_used--; |
568 } | 589 } |
569 pthread_mutex_unlock(&p_queue->mutex); | 590 pthread_mutex_unlock(&p_queue->mutex); |
570 destroy_stream_queue(p_queue); | 591 destroy_stream_queue(p_queue); |
571 tdata->streamer->stream_session[id]->p_queue = NULL; | 592 tdata->streamer->stream_session[id]->p_queue = NULL; |
593 strcpy(ut->request_channel, "all"); | |
594 ut->nr_channel = 0; | |
572 } | 595 } |
573 break; | 596 break; |
574 default: | 597 default: |
575 log_verbose ("Unknown file type.\n"); | 598 log_verbose ("Unknown file type.\n"); |
576 break; | 599 break; |