Mercurial > pt1.oyama
annotate src/recpt1.c @ 165:3ffef0e5b80a
Add pt1_common.h
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Mon, 01 Oct 2012 21:53:24 +0900 |
parents | 7d8a5bb874ad |
children | 726fe10d9e4a |
rev | line source |
---|---|
100
aeba1988234f
support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
99
diff
changeset
|
1 /* -*- tab-width: 4; indent-tabs-mode: nil -*- */ |
122 | 2 /* vim: set ts=4 sts=4 sw=4 expandtab number : */ |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
3 #include <stdio.h> |
3 | 4 #include <fcntl.h> |
5 #include <sys/types.h> | |
6 #include <sys/stat.h> | |
7 #include <time.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <pthread.h> | |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
11 #include <math.h> |
3 | 12 #include <unistd.h> |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
13 #include <getopt.h> |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
14 #include <signal.h> |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
15 #include <errno.h> |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
16 #include <sys/time.h> |
47
edd904628e2f
a bit improved support for time format. now recpt1 recognize string such as 1h05m10s.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
43
diff
changeset
|
17 #include <ctype.h> |
61
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
18 #include <libgen.h> |
0 | 19 |
8 | 20 #include <netdb.h> |
21 #include <arpa/inet.h> | |
22 #include <netinet/in.h> | |
23 | |
3 | 24 #include <sys/ioctl.h> |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
25 #include <pt1_ioctl.h> |
0 | 26 |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
27 #include "config.h" |
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
28 #include "decoder.h" |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
29 #include "recpt1.h" |
43
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
30 #include "version.h" |
61
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
31 #include "mkpath.h" |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
32 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
33 #include <sys/ipc.h> |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
34 #include <sys/msg.h> |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
35 #include "pt1_dev.h" |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
36 #include "tssplitter_lite.h" |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
37 #include "ushare.h" |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
38 #include "trace.h" |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
39 #include "pt1_common.h" |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
40 |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
41 /* maximum write length at once */ |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
42 #define SIZE_CHANK 1316 |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
43 |
156
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
44 #define ISDB_T_NODE_LIMIT 24 // 32:ARIB limit 24:program maximum |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
45 #define ISDB_T_SLOT_LIMIT 8 |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
46 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
47 /* globals */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
48 boolean f_exit = FALSE; |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
49 struct channel_info_list *channel_list = NULL; |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
50 extern struct ushare_t *ut; |
156
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
51 char bs_channel_buf[8]; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
52 ISDB_T_FREQ_CONV_TABLE isdb_t_conv_set = { 0, CHTYPE_SATELLITE, 0, bs_channel_buf }; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
53 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
54 /* prototypes */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
55 int tune(char *channel, thread_data *tdata, char *device); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
56 int close_tuner(thread_data *tdata); |
133
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
57 static int get_device_id_by_name ( const char *name ); |
161
ade99239f234
Enable change phisical channel by DLNA.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
159
diff
changeset
|
58 void calc_cn(int fd, int type); |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
59 ISDB_T_FREQ_CONV_TABLE *searchrecoff(char *channel); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
60 |
155
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
61 static struct channel_info_list *open_list_file( |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
62 char *type, |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
63 struct channel_info_list *info_list) |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
64 { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
65 char *buf = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
66 char filename[PATH_MAX]; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
67 char *home = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
68 char *p = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
69 struct channel_info *channel_info = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
70 struct channel_info_list *channel_info_list = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
71 FILE *f = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
72 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
73 home = getenv("HOME"); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
74 snprintf(filename, PATH_MAX, "%s/.recpt1_%s", home, type); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
75 f = fopen(filename, "r"); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
76 if(!f) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
77 return channel_info_list; |
154 | 78 } |
155
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
79 if(!info_list) { |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
80 channel_info_list = malloc(sizeof(*channel_info_list)); |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
81 if(!channel_info_list) |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
82 return NULL; |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
83 channel_info_list->nr_channel = 0; |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
84 } else |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
85 channel_info_list = info_list; |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
86 while(1) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
87 buf = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
88 buf = malloc(256); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
89 if(!buf) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
90 break; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
91 if(!fgets(buf, 255, f)) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
92 free(buf); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
93 buf = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
94 break; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
95 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
96 channel_info = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
97 channel_info = malloc(sizeof(*channel_info)); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
98 if(!channel_info) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
99 break; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
100 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
101 channel_info->sid = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
102 channel_info->tp = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
103 channel_info->name = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
104 |
155
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
105 channel_info->id = channel_info_list->nr_channel; |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
106 channel_info->sid = buf; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
107 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
108 p = strchr(buf, C_CHAR_COMMA); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
109 if (p == NULL) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
110 /* FILE ERROR */ |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
111 free(channel_info); |
154 | 112 channel_info = NULL; |
113 continue; | |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
114 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
115 *p = '\0'; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
116 channel_info->tp = ++p; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
117 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
118 p = strchr(p, C_CHAR_COMMA); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
119 if (p == NULL) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
120 /* FILE ERROR */ |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
121 free(channel_info); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
122 channel_info = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
123 continue; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
124 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
125 *p = '\0'; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
126 channel_info->name = ++p; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
127 p = strchr(p, '\n'); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
128 if (p) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
129 *p = '\0'; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
130 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
131 if(channel_info_list->nr_channel < CHANNEL_MAX) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
132 channel_info_list->channel_info[channel_info_list->nr_channel] = channel_info; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
133 channel_info_list->nr_channel += 1; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
134 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
135 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
136 fclose(f); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
137 return channel_info_list; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
138 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
139 |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
140 static void close_list_file(struct channel_info_list *channel_info_list) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
141 { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
142 int i; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
143 if (!channel_info_list) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
144 return; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
145 for (i=0; i < channel_info_list->nr_channel; i++) { |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
146 free(channel_info_list->channel_info[i]->sid); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
147 channel_info_list->channel_info[i]->sid = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
148 free(channel_info_list->channel_info[i]); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
149 channel_info_list->channel_info[i] = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
150 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
151 channel_info_list->nr_channel = 0; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
152 free(channel_info_list); |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
153 channel_info_list = NULL; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
154 return; |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
155 } |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
156 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
157 /* ipc message receive */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
158 void * |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
159 mq_recv(void *t) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
160 { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
161 thread_data *tdata = (thread_data *)t; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
162 pt1_message_buf rbuf; |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
163 static char channel[16]; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
164 static char sid_list[16]; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
165 int recsec = 0, time_to_add = 0; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
166 int current_type; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
167 splitter *splitter = tdata->splitter; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
168 boolean use_splitter = splitter ? TRUE : FALSE; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
169 boolean use_dlna = tdata->streamer ? TRUE : FALSE; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
170 ISDB_T_FREQ_CONV_TABLE *table = NULL; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
171 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
172 while(1) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
173 if(msgrcv(tdata->msqid, &rbuf, MSGSZ, 1, 0) < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
174 return NULL; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
175 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
176 |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
177 sscanf(rbuf.mtext, "ch=%s t=%d e=%d i=%s", channel, &recsec, &time_to_add, sid_list); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
178 |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
179 if ((strcmp(channel, "")) && strcmp(tdata->ch, channel)) { |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
180 #if 0 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
181 /* re-initialize decoder */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
182 if(tdata->decoder) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
183 // b25_finish(tdata->decoder); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
184 b25_shutdown(tdata->decoder); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
185 tdata->decoder = b25_startup(tdata->dopt); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
186 if(!tdata->decoder) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
187 fprintf(stderr, "Cannot start b25 decoder\n"); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
188 fprintf(stderr, "Fall back to encrypted recording\n"); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
189 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
190 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
191 #endif |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
192 current_type = tdata->table->type; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
193 table = searchrecoff(channel); |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
194 if (table == NULL) { |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
195 fprintf(stderr, "Invalid Channel: %s\n", channel); |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
196 goto CHECK_TIME_TO_ADD; |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
197 } |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
198 tdata->table = table; |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
199 |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
200 /* stop stream */ |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
201 ioctl(tdata->tfd, STOP_REC, 0); |
88
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
202 |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
203 /* wait for remainder */ |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
204 while(tdata->queue->num_used > 0) { |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
205 usleep(10000); |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
206 } |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
207 } |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
208 if (use_splitter && |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
209 (strcmp(tdata->sid_list, sid_list) || |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
210 strcmp(tdata->ch, channel))) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
211 // $BJ*M}%A%c%s%M%kJQ99;~$K$O(B splitter $B$O6/@)E*$K:F5/F0$5$;$k(B |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
212 pthread_mutex_lock(&tdata->splitter_mutex); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
213 split_shutdown(splitter); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
214 splitter = split_startup(sid_list, NULL, NULL); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
215 if (splitter->sid_list == NULL) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
216 fprintf (stderr, "reader_func() splitter RESTART FAILED.\n"); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
217 tdata->splitter = NULL; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
218 pthread_mutex_unlock(&tdata->splitter_mutex); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
219 continue; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
220 } |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
221 if (tdata->streamer) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
222 pthread_mutex_lock(&tdata->stream_queue->mutex); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
223 while(1) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
224 STREAM_QUEUE_T *p_queue = tdata->stream_queue; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
225 if (p_queue->num_used == 0) |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
226 break; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
227 free(p_queue->buffer[p_queue->out]->data); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
228 p_queue->buffer[p_queue->out]->data = NULL; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
229 free(p_queue->buffer[p_queue->out]); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
230 p_queue->buffer[p_queue->out] = NULL; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
231 p_queue->out++; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
232 p_queue->out %= p_queue->size; |
88
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
233 |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
234 /* update counters */ |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
235 p_queue->num_avail++; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
236 p_queue->num_used--; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
237 } |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
238 pthread_mutex_unlock(&tdata->stream_queue->mutex); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
239 } |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
240 tdata->table = table; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
241 tdata->splitter = splitter; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
242 time(&splitter->split_start_time); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
243 strncpy(tdata->sid_list, sid_list, sizeof(tdata->sid_list)); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
244 pthread_mutex_unlock(&tdata->splitter_mutex); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
245 } |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
246 |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
247 if (strcmp(tdata->ch, channel)) { |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
248 if (tdata->table->type != current_type) { |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
249 /* re-open device */ |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
250 if(close_tuner(tdata) != 0) |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
251 return NULL; |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
252 |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
253 tune(channel, tdata, NULL); |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
254 } else { |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
255 /* SET_CHANNEL only */ |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
256 const FREQUENCY freq = { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
257 .frequencyno = tdata->table->set_freq, |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
258 .slot = tdata->table->add_freq, |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
259 }; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
260 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
261 fprintf(stderr, "Cannot tune to the specified channel\n"); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
262 tdata->ch[0] = '\0'; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
263 goto CHECK_TIME_TO_ADD; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
264 } |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
265 calc_cn(tdata->tfd, tdata->table->type); |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
266 } |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
267 /* restart recording */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
268 if(ioctl(tdata->tfd, START_REC, 0) < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
269 fprintf(stderr, "Tuner cannot start recording\n"); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
270 return NULL; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
271 } |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
272 strncpy(tdata->ch, channel, sizeof(tdata->ch)); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
273 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
274 |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
275 CHECK_TIME_TO_ADD: |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
276 if(time_to_add) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
277 tdata->recsec += time_to_add; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
278 fprintf(stderr, "Extended %d sec\n", time_to_add); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
279 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
280 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
281 if(recsec) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
282 time_t cur_time; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
283 time(&cur_time); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
284 if(cur_time - tdata->start_time > recsec) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
285 f_exit = TRUE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
286 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
287 else { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
288 tdata->recsec = recsec; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
289 fprintf(stderr, "Total recording time = %d sec\n", recsec); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
290 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
291 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
292 if(f_exit) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
293 return NULL; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
294 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
295 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
296 |
0 | 297 |
6 | 298 /* lookup frequency conversion table*/ |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
299 ISDB_T_FREQ_CONV_TABLE * |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
300 searchrecoff(char *channel) |
0 | 301 { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
302 int lp; |
0 | 303 |
159
38f79bcba50d
modified to accept capitalization.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
156
diff
changeset
|
304 if((channel[0] == 'B' || channel[0] == 'b') && |
38f79bcba50d
modified to accept capitalization.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
156
diff
changeset
|
305 (channel[1] == 'S' || channel[1] == 's')) { |
156
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
306 int node = 0; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
307 int slot = 0; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
308 char *bs_ch; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
309 |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
310 bs_ch = channel + 2; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
311 while(isdigit(*bs_ch)) { |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
312 node *= 10; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
313 node += *bs_ch++ - '0'; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
314 } |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
315 if(*bs_ch == '_' && (node&0x01) && node < ISDB_T_NODE_LIMIT) { |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
316 if(isdigit(*++bs_ch)) { |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
317 slot = *bs_ch - '0'; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
318 if(*++bs_ch == '\0' && slot < ISDB_T_SLOT_LIMIT) { |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
319 isdb_t_conv_set.set_freq = node / 2; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
320 isdb_t_conv_set.add_freq = slot; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
321 sprintf(bs_channel_buf, "BS%d_%d", node, slot); |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
322 return &isdb_t_conv_set; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
323 } |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
324 } |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
325 } |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
326 return NULL; |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
327 } |
159a729b90eb
Specify the BS channels by transponder and slot.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
155
diff
changeset
|
328 |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
329 for(lp = 0; isdb_t_conv_table[lp].parm_freq != NULL; lp++) { |
6 | 330 /* return entry number in the table when strings match and |
331 * lengths are same. */ | |
4 | 332 if((memcmp(isdb_t_conv_table[lp].parm_freq, channel, |
333 strlen(channel)) == 0) && | |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
334 (strlen(channel) == strlen(isdb_t_conv_table[lp].parm_freq))) { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
335 return &isdb_t_conv_table[lp]; |
4 | 336 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
337 } |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
338 return NULL; |
0 | 339 } |
340 | |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
341 QUEUE_T * |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
342 create_queue(size_t size) |
0 | 343 { |
4 | 344 QUEUE_T *p_queue; |
142
d65c15276b5e
Fix consume large amounts of memory.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
141
diff
changeset
|
345 int memsize = sizeof(QUEUE_T) + size * sizeof(BUFSZ*); |
0 | 346 |
4 | 347 p_queue = (QUEUE_T*)calloc(memsize, sizeof(char)); |
0 | 348 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
349 if(p_queue != NULL) { |
4 | 350 p_queue->size = size; |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
351 p_queue->num_avail = size; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
352 p_queue->num_used = 0; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
353 p_queue->in = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
354 p_queue->out = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
355 pthread_mutex_init(&p_queue->mutex, NULL); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
356 pthread_cond_init(&p_queue->cond_avail, NULL); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
357 pthread_cond_init(&p_queue->cond_used, NULL); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
358 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
359 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
360 return p_queue; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
361 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
362 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
363 STREAM_QUEUE_T * |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
364 create_stream_queue(size_t size) |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
365 { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
366 STREAM_QUEUE_T *p_queue; |
142
d65c15276b5e
Fix consume large amounts of memory.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
141
diff
changeset
|
367 int memsize = sizeof(STREAM_QUEUE_T) + size * sizeof(ARIB_STD_B25_BUFFER*); |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
368 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
369 p_queue = (STREAM_QUEUE_T*)calloc(memsize, sizeof(char)); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
370 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
371 if(p_queue != NULL) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
372 p_queue->size = size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
373 p_queue->num_avail = size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
374 p_queue->num_used = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
375 p_queue->in = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
376 p_queue->out = 0; |
4 | 377 pthread_mutex_init(&p_queue->mutex, NULL); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
378 pthread_cond_init(&p_queue->cond_avail, NULL); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
379 pthread_cond_init(&p_queue->cond_used, NULL); |
4 | 380 } |
0 | 381 |
4 | 382 return p_queue; |
0 | 383 } |
384 | |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
385 void |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
386 destroy_queue(QUEUE_T *p_queue) |
0 | 387 { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
388 if(!p_queue) |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
389 return; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
390 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
391 pthread_mutex_destroy(&p_queue->mutex); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
392 pthread_cond_destroy(&p_queue->cond_avail); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
393 pthread_cond_destroy(&p_queue->cond_used); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
394 free(p_queue); |
0 | 395 } |
396 | |
125
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
397 void |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
398 destroy_stream_queue(STREAM_QUEUE_T *p_queue) |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
399 { |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
400 if(!p_queue) |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
401 return; |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
402 |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
403 pthread_mutex_destroy(&p_queue->mutex); |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
404 pthread_cond_destroy(&p_queue->cond_avail); |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
405 pthread_cond_destroy(&p_queue->cond_used); |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
406 free(p_queue); |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
407 } |
e413158cae13
Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
124
diff
changeset
|
408 |
3 | 409 /* enqueue data. this function will block if queue is full. */ |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
410 void |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
411 enqueue(QUEUE_T *p_queue, BUFSZ *data) |
0 | 412 { |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
413 struct timeval now; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
414 struct timespec spec; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
415 |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
416 gettimeofday(&now, NULL); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
417 spec.tv_sec = now.tv_sec + 1; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
418 spec.tv_nsec = now.tv_usec * 1000; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
419 |
4 | 420 pthread_mutex_lock(&p_queue->mutex); |
421 /* entered critical section */ | |
0 | 422 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
423 /* wait while queue is full */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
424 while(p_queue->num_avail == 0) { |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
425 pthread_cond_timedwait(&p_queue->cond_avail, |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
426 &p_queue->mutex, &spec); |
25
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
427 if(f_exit) { |
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
428 pthread_mutex_unlock(&p_queue->mutex); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
429 return; |
25
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
430 } |
4 | 431 } |
0 | 432 |
4 | 433 p_queue->buffer[p_queue->in] = data; |
0 | 434 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
435 /* move position marker for input to next position */ |
4 | 436 p_queue->in++; |
437 p_queue->in %= p_queue->size; | |
0 | 438 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
439 /* update counters */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
440 p_queue->num_avail--; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
441 p_queue->num_used++; |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
442 |
4 | 443 /* leaving critical section */ |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
444 pthread_mutex_unlock(&p_queue->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
445 pthread_cond_signal(&p_queue->cond_used); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
446 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
447 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
448 /* |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
449 * stream_func()$B$N;HMQ$9$k(B enqueue() $B$O6u$-$,$J$$>l9g$K$O!"L58BBT$A$O$7$F$O$J$i$J$$!#(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
450 * $B6u$-$,$J$$>l9g$K$O!"(Bqueue$B$r=i4|2=$7$F$7$^$$!"C<Kv$X$NAw?.%G!<%?$r;E@Z$jD>$7$7$F$7$^$&J}$,%^%7!#(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
451 * $B$3$l$K$h$j!"C<Kv$X$NAw?.%G!<%?$O?tICJ,%9%-%C%W$9$k;v$K$J$k$,!"(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
452 * $B%P%C%U%!$OM-8B$G$"$j!"%9%H%j!<%`$G$"$k$N$G:F@8$5$lB3$1$k$3$H$rM%@h$9$k!#(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
453 */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
454 void |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
455 stream_enqueue(STREAM_QUEUE_T *p_queue, ARIB_STD_B25_BUFFER *data) |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
456 { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
457 struct timeval now; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
458 struct timespec spec; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
459 int i; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
460 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
461 gettimeofday(&now, NULL); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
462 spec.tv_sec = now.tv_sec + 1; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
463 spec.tv_nsec = now.tv_usec * 1000; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
464 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
465 pthread_mutex_lock(&p_queue->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
466 /* entered critical section */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
467 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
468 if (p_queue->num_avail == 0) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
469 /* stream queue $B$O0lGU$K$J$C$?$i>C5n$7$F$7$^$&(B */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
470 for ( i=0; i < p_queue->size; i++ ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
471 if ( p_queue->buffer[i] != NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
472 free(p_queue->buffer[i]->data); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
473 p_queue->buffer[i]->data = NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
474 free(p_queue->buffer[i]); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
475 p_queue->buffer[i] = NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
476 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
477 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
478 p_queue->in = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
479 p_queue->out = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
480 p_queue->num_used = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
481 p_queue->num_avail = p_queue->size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
482 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
483 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
484 p_queue->buffer[p_queue->in] = data; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
485 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
486 /* move position marker for input to next position */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
487 p_queue->in++; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
488 p_queue->in %= p_queue->size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
489 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
490 /* update counters */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
491 p_queue->num_avail--; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
492 p_queue->num_used++; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
493 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
494 /* leaving critical section */ |
4 | 495 pthread_mutex_unlock(&p_queue->mutex); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
496 pthread_cond_signal(&p_queue->cond_used); |
0 | 497 } |
498 | |
3 | 499 /* dequeue data. this function will block if queue is empty. */ |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
500 BUFSZ * |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
501 dequeue(QUEUE_T *p_queue) |
0 | 502 { |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
503 struct timeval now; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
504 struct timespec spec; |
8 | 505 BUFSZ *buffer; |
0 | 506 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
507 gettimeofday(&now, NULL); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
508 spec.tv_sec = now.tv_sec + 1; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
509 spec.tv_nsec = now.tv_usec * 1000; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
510 |
4 | 511 pthread_mutex_lock(&p_queue->mutex); |
512 /* entered the critical section*/ | |
0 | 513 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
514 /* wait while queue is empty */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
515 while(p_queue->num_used == 0) { |
27
763cf84d2dc7
fixed a bug that waited for wrong cond variable
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
26
diff
changeset
|
516 pthread_cond_timedwait(&p_queue->cond_used, |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
517 &p_queue->mutex, &spec); |
25
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
518 if(f_exit) { |
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
519 pthread_mutex_unlock(&p_queue->mutex); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
520 return NULL; |
25
011cb9337729
- avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
24
diff
changeset
|
521 } |
4 | 522 } |
0 | 523 |
4 | 524 /* take buffer address */ |
525 buffer = p_queue->buffer[p_queue->out]; | |
0 | 526 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
527 /* move position marker for output to next position */ |
4 | 528 p_queue->out++; |
529 p_queue->out %= p_queue->size; | |
0 | 530 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
531 /* update counters */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
532 p_queue->num_avail++; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
533 p_queue->num_used--; |
0 | 534 |
4 | 535 /* leaving the critical section */ |
536 pthread_mutex_unlock(&p_queue->mutex); | |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
537 pthread_cond_signal(&p_queue->cond_avail); |
134 | 538 |
539 return buffer; | |
540 } | |
541 | |
542 ARIB_STD_B25_BUFFER * | |
543 stream_dequeue(STREAM_QUEUE_T *p_queue) | |
544 { | |
545 struct timeval now; | |
546 struct timespec spec; | |
547 ARIB_STD_B25_BUFFER *buffer; | |
548 | |
549 gettimeofday(&now, NULL); | |
550 spec.tv_sec = now.tv_sec + 1; | |
551 spec.tv_nsec = now.tv_usec * 1000; | |
552 | |
553 pthread_mutex_lock(&p_queue->mutex); | |
554 /* entered the critical section*/ | |
0 | 555 |
134 | 556 /* wait while queue is empty */ |
557 while(p_queue->num_used == 0) { | |
558 pthread_cond_timedwait(&p_queue->cond_used, | |
559 &p_queue->mutex, &spec); | |
560 if(f_exit) { | |
561 pthread_mutex_unlock(&p_queue->mutex); | |
562 return NULL; | |
563 } | |
564 } | |
565 | |
566 /* take buffer address */ | |
567 buffer = p_queue->buffer[p_queue->out]; | |
568 | |
569 /* move position marker for output to next position */ | |
570 p_queue->out++; | |
571 p_queue->out %= p_queue->size; | |
572 | |
573 /* update counters */ | |
574 p_queue->num_avail++; | |
575 p_queue->num_used--; | |
576 | |
577 /* leaving the critical section */ | |
578 pthread_mutex_unlock(&p_queue->mutex); | |
579 pthread_cond_signal(&p_queue->cond_avail); | |
580 | |
4 | 581 return buffer; |
0 | 582 } |
583 | |
6 | 584 /* this function will be reader thread */ |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
585 void * |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
586 reader_func(void *p) |
0 | 587 { |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
588 thread_data *data = (thread_data *)p; |
4 | 589 QUEUE_T *p_queue = data->queue; |
590 decoder *dec = data->decoder; | |
8 | 591 int wfd = data->wfd; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
592 boolean use_b25 = dec ? TRUE : FALSE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
593 boolean use_udp = data->sock_data ? TRUE : FALSE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
594 boolean fileless = FALSE; |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
595 boolean use_splitter = data->splitter ? TRUE : FALSE; |
134 | 596 boolean use_dlna = data->streamer ? TRUE : FALSE; |
13 | 597 int sfd = -1; |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
598 pthread_t signal_thread = data->signal_thread; |
26 | 599 struct sockaddr_in *addr = NULL; |
600 BUFSZ *qbuf; | |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
601 ARIB_STD_B25_BUFFER *eqbuf; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
602 splitbuf_t splitbuf; |
26 | 603 ARIB_STD_B25_BUFFER sbuf, dbuf, buf; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
604 int code; |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
605 pt1_message_buf mbuf; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
606 int msqid; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
607 int msgflg = IPC_CREAT | 0666; |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
608 |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
609 if (use_splitter) |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
610 time(&data->splitter->split_start_time); |
4 | 611 |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
612 buf.size = 0; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
613 buf.data = NULL; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
614 splitbuf.size = 0; |
144
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
615 splitbuf.buffer_length = 0; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
616 splitbuf.buffer = NULL; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
617 |
13 | 618 if(wfd == -1) |
619 fileless = TRUE; | |
620 | |
8 | 621 if(use_udp) { |
622 sfd = data->sock_data->sfd; | |
26 | 623 addr = &data->sock_data->addr; |
8 | 624 } |
625 | |
4 | 626 while(1) { |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
627 ssize_t wc = 0; |
39
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
628 int file_err = 0; |
26 | 629 qbuf = dequeue(p_queue); |
630 /* no entry in the queue */ | |
631 if(qbuf == NULL) { | |
632 break; | |
633 } | |
13 | 634 |
26 | 635 sbuf.data = qbuf->buffer; |
636 sbuf.size = qbuf->size; | |
637 | |
638 buf = sbuf; /* default */ | |
639 | |
640 if(use_b25) { | |
641 code = b25_decode(dec, &sbuf, &dbuf); | |
85
28ba9315a30c
falls back to encrypted recording when b25_decode fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
84
diff
changeset
|
642 if(code < 0) { |
122 | 643 fprintf(stderr, "b25_decode failed (code=%d). fall back to encrypted recording.\n", code); |
644 use_b25 = FALSE; | |
85
28ba9315a30c
falls back to encrypted recording when b25_decode fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
84
diff
changeset
|
645 } |
26 | 646 else |
647 buf = dbuf; | |
648 } | |
13 | 649 |
104
afd25d9ebef6
output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
103
diff
changeset
|
650 if(use_splitter) { |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
651 pthread_mutex_lock(&data->splitter_mutex); |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
652 splitbuf.size = 0; |
144
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
653 if(splitbuf.buffer_length < buf.size && buf.size > 0) { |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
654 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
655 if(NULL == splitbuf.buffer) { |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
656 fprintf(stderr, "splitbuf.buffer realloc failed\n"); |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
657 use_splitter = FALSE; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
658 goto fin; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
659 } |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
660 splitbuf.buffer_length = buf.size; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
661 } |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
662 |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
663 while(buf.size) { |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
664 /* $BJ,N%BP>](BPID$B$NCj=P(B */ |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
665 if(data->splitter->split_select_finish != TSS_SUCCESS) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
666 data->splitter->split_select_finish = split_select(data->splitter, &buf); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
667 if(data->splitter->split_select_finish == TSS_NULL) { |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
668 /* malloc$B%(%i!<H/@8(B */ |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
669 fprintf(stderr, "split_select malloc failed\n"); |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
670 use_splitter = FALSE; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
671 goto fin; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
672 } |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
673 else if(data->splitter->split_select_finish != TSS_SUCCESS) { |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
674 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
675 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
676 */ |
122 | 677 time_t cur_time; |
678 time(&cur_time); | |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
679 if(cur_time - data->splitter->split_start_time > 4) { |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
680 fprintf(stderr, "split_select cur_time out.\n"); |
122 | 681 use_splitter = FALSE; |
682 goto fin; | |
683 } | |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
684 break; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
685 } |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
686 } |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
687 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
688 code = split_ts(data->splitter, &buf, &splitbuf); |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
689 if(code != TSS_SUCCESS) { |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
690 fprintf(stderr, "split_ts failed\n"); |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
691 break; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
692 } |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
693 |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
694 break; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
695 } /* while */ |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
696 |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
697 buf.size = splitbuf.size; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
698 buf.data = splitbuf.buffer; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
699 fin: |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
700 pthread_mutex_unlock(&data->splitter_mutex); |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
701 } /* if */ |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
702 |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
703 /* |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
704 * 2. reader_func$B2~B$E@(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
705 * 2.1 tdata->p_queue $B$+$i(B dequeue() $B$7$F%9%H%j!<%`$J%G!<%?$r<hF@$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
706 * 2.1.1 dequeue()$B$O(B tdata->p_queue->mutex $B$r(B lock/unlock $B$7$FFI$_9~$_;~$NF1;~99?7$rKI;_$7$F$$$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
707 * 2.2 tdata->stream_queue $B$K(B enqueue() $B$r<B9T$7$F(B http_stream $B$NBg85$H$9$k%G!<%?%P%C%U%!$N%3%T!<$r<B;\(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
708 * 2.2.1 http_stream$B$N%3%T!<85$H$9$k$?$a$N%P%C%U%!$r(Balloc$B$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
709 * 2.2.2 2.2.1$B$G(Balloc$B$7$?NN0h$K(B rader_func $B$,(B dequeue $B$7$?%9%H%j!<%`$J%G!<%?$r(Bmemcpy()$B$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
710 * 2.2.3 tdata->stream_queue $B$K(B 2.2.1 $B$N%]%$%s%?$r(B enqueue() $B$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
711 * 2.2.3.1 enqueue() $B$O(B tdata->stream_queue->mutex $B$r(B lock/unlock $B$7$F=q$-9~$_;~$NF1;~99?7$rKI;_$7$F$$$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
712 */ |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
713 /* |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
714 * DLNA $B$G$NJ*M}%A%c%s%M%k!&(BSID$BJQ99$N<BAu<B83(B |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
715 */ |
161
ade99239f234
Enable change phisical channel by DLNA.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
159
diff
changeset
|
716 if ( use_dlna && buf.size > 0 ) { |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
717 if (use_splitter && (ut->tp) && (ut->sid)) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
718 if (strcmp(data->ch, ut->tp) || |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
719 strcmp(data->sid_list, ut->sid)) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
720 if ((msqid = msgget((key_t)getpid(), msgflg)) < 0) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
721 // $B%(%i!<;~$O%A%c%s%M%kJQ99%j%/%(%9%H$O$J$+$C$?$3$H$K$9$k(B |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
722 // $B$J$`$J$`(B |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
723 fprintf(stderr, "msgget error.\n"); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
724 ut->tp = data->ch; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
725 free(qbuf); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
726 qbuf = NULL; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
727 ut->sid = data->sid_list; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
728 continue; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
729 } |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
730 |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
731 mbuf.mtype = 1; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
732 snprintf(mbuf.mtext, sizeof(mbuf.mtext), |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
733 "ch=%s t=%d e=%d i=%s", |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
734 ut->tp, 0, 0, ut->sid); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
735 if (msgsnd(msqid, &mbuf, strlen(mbuf.mtext)+1, IPC_NOWAIT) < 0) { |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
736 // $B%(%i!<;~$O%A%c%s%M%kJQ99%j%/%(%9%H$O$J$+$C$?$3$H$K$9$k(B |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
737 // $B$J$`$J$`(B |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
738 fprintf(stderr, "msgsend error.\n"); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
739 ut->tp = data->ch; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
740 ut->sid = data->sid_list; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
741 free(qbuf); |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
742 qbuf = NULL; |
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
743 continue; |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
744 } |
146
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
745 free(qbuf); |
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
746 qbuf = NULL; |
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
747 continue; |
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
748 } |
066f33b2213a
EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
144
diff
changeset
|
749 } |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
750 do { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
751 eqbuf = malloc(sizeof(ARIB_STD_B25_BUFFER)); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
752 if ( eqbuf == NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
753 fprintf (stderr, "Cannot malloc eqbuf memory. streaming abort.\n"); |
134 | 754 use_dlna = FALSE; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
755 break; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
756 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
757 eqbuf->data = malloc(buf.size); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
758 if ( eqbuf->data == NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
759 fprintf (stderr, "Cannot malloc eqbuf memory. streaming abort.\n"); |
134 | 760 use_dlna = FALSE; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
761 break; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
762 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
763 eqbuf->size = buf.size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
764 memcpy(eqbuf->data, buf.data, buf.size); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
765 // $B$3$A$i$b0n$l$?$i>C5n$7$F$7$^$&(B stream_enqueue() $B$r;HMQ(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
766 stream_enqueue(data->stream_queue, eqbuf); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
767 } while(0); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
768 } |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
769 |
26 | 770 if(!fileless) { |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
771 /* write data to output file */ |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
772 int size_remain = buf.size; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
773 int offset = 0; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
774 |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
775 while(size_remain > 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
776 int ws = size_remain < SIZE_CHANK ? size_remain : SIZE_CHANK; |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
777 |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
778 wc = write(wfd, buf.data + offset, ws); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
779 if(wc < 0) { |
39
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
780 perror("write"); |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
781 file_err = 1; |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
782 pthread_kill(signal_thread, |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
783 errno == EPIPE ? SIGPIPE : SIGUSR2); |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
784 break; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
785 } |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
786 size_remain -= wc; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
787 offset += wc; |
13 | 788 } |
26 | 789 } |
13 | 790 |
26 | 791 if(use_udp && sfd != -1) { |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
792 /* write data to socket */ |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
793 int size_remain = buf.size; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
794 int offset = 0; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
795 while(size_remain > 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
796 int ws = size_remain < SIZE_CHANK ? size_remain : SIZE_CHANK; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
797 wc = write(sfd, buf.data + offset, ws); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
798 if(wc < 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
799 if(errno == EPIPE) |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
800 pthread_kill(signal_thread, SIGPIPE); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
801 break; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
802 } |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
803 size_remain -= wc; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
804 offset += wc; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
805 } |
26 | 806 } |
807 | |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
808 free(qbuf); |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
809 qbuf = NULL; |
26 | 810 |
811 /* normal exit */ | |
84
1b61fd7c6fde
should just shutdown when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
81
diff
changeset
|
812 if((f_exit && !p_queue->num_used) || file_err) { |
26 | 813 |
814 buf = sbuf; /* default */ | |
13 | 815 |
816 if(use_b25) { | |
26 | 817 code = b25_finish(dec, &sbuf, &dbuf); |
818 if(code < 0) | |
819 fprintf(stderr, "b25_finish failed\n"); | |
820 else | |
821 buf = dbuf; | |
13 | 822 } |
4 | 823 |
104
afd25d9ebef6
output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
103
diff
changeset
|
824 if(use_splitter) { |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
825 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
826 code = split_ts(data->splitter, &buf, &splitbuf); |
99
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
827 if(code != TSS_SUCCESS) { |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
828 break; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
829 } |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
830 |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
831 buf.data = splitbuf.buffer; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
832 buf.size = splitbuf.size; |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
833 } |
3a3f15b063e1
now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
98
diff
changeset
|
834 |
84
1b61fd7c6fde
should just shutdown when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
81
diff
changeset
|
835 if(!fileless && !file_err) { |
26 | 836 wc = write(wfd, buf.data, buf.size); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
837 if(wc < 0) { |
39
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
838 perror("write"); |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
839 file_err = 1; |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
840 pthread_kill(signal_thread, |
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
841 errno == EPIPE ? SIGPIPE : SIGUSR2); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
842 } |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
843 } |
13 | 844 |
26 | 845 if(use_udp && sfd != -1) { |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
846 wc = write(sfd, buf.data, buf.size); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
847 if(wc < 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
848 if(errno == EPIPE) |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
849 pthread_kill(signal_thread, SIGPIPE); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
850 } |
26 | 851 } |
144
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
852 if(use_splitter) { |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
853 free(splitbuf.buffer); |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
854 splitbuf.buffer = NULL; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
855 splitbuf.buffer_length = 0; |
bf96eac4dbb1
Changed to a variable length buffer of splitbuf_t
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
142
diff
changeset
|
856 } |
13 | 857 |
26 | 858 break; |
4 | 859 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
860 } |
0 | 861 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
862 time_t cur_time; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
863 time(&cur_time); |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
864 fprintf(stderr, "Recorded %dsec\n", |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
865 (int)(cur_time - data->start_time)); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
866 |
4 | 867 return NULL; |
0 | 868 } |
869 | |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
870 /* |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
871 * 3. stream_func() $B$O(B reader_func() $B$+$i%9%H%j!<%`8~$1$K%3%T!<$5$l$?%G!<%?$r!"%9%H%j!<%`%;%C%7%g%sKh$N(Bqueue$B$K%3%T!<$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
872 * 3.1 tdata->stream_queue $B$+$i(B dequeue $B$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
873 * 3.1.1 tdata->stream_queue->mutex $B$NFI$_9~$_;~$N(B lock/unlokc $B$,H/@8$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
874 * 3.2 tdata->streamer->mutex $B$r(B lock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
875 * 3.3 $B0J2<$r(B tdata->streamer->stream_nr $B$N?t$@$1%k!<%W(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
876 * 3.3.1 tdata->streamer->stream_session[N]->is_valid $B$,M-8z$+3NG'(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
877 * 3.3.2 tdata->streamer->stream_session[N]->p_queue $B$X$N%3%T!<MQ%P%C%U%!$N(Balloc |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
878 * 3.3.3 3.1$B$G(B dequeue $B$7$?%P%C%U%!$r(B3.3.2$B$G(B alloc $B$7$?%P%C%U%!$X(B memcpy() |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
879 * 3.3.4 tdata->streamer->stream_session[N]->p_queue $B$X(B enqueue() |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
880 * 3.3.4.1 tdata->streamer->stream_session[N]->p_queue->mutex $B$N(B lock/unlock $B$,H/@8(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
881 * 3.4 tdata->streamer->mutex $B$r(B unlock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
882 * stream_func()$B$N(B lock $B$9$k$b$N$H=g=x(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
883 * #1. tdata->stream_queue->mutex $B$N(Block/unlock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
884 * #2. tdata->streamer->mutex $B$r(B lock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
885 * #2.1 tdata->streamer->stream_session[N]->p_queue->mutex $B$N(B lock/unlock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
886 * #3. tdata->streamer->mutex $B$N(B unlock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
887 * $B>e5-$K4X$7$F!"(Block/unlock$B$,I,MW$JItJ,$H!"NN0h3NJ]$H%3%T!<$NCY$a$N=hM}$H$G(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
888 * $B@Z$jJ,$1$i$l$kItJ,$K$D$$$F$O@Z$jJ,$1$F$7$^$C$?$[$&$,$$$$$+$b!#(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
889 * $B%/%j%F%#%+%k%;%/%7%g%s$O!"%]%$%s%?A`:n$@$1$H$9$k$Y$-!#(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
890 */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
891 void * |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
892 stream_func(void *p) |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
893 { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
894 thread_data *data = (thread_data *)p; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
895 STREAM_QUEUE_T *p_queue = data->stream_queue; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
896 ARIB_STD_B25_BUFFER *qbuf = NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
897 ARIB_STD_B25_BUFFER *buf; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
898 int i; |
127
5a380559a61e
modify calclate bitrate mechanism.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
126
diff
changeset
|
899 clock_gettime(CLOCK_REALTIME, &data->streamer->start); |
5a380559a61e
modify calclate bitrate mechanism.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
126
diff
changeset
|
900 data->streamer->total_byte = 0; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
901 //fprintf (stderr, "stream_func(): start.\n"); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
902 |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
903 while(1) { |
126
5dcaf3785ebe
fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
125
diff
changeset
|
904 if(f_exit) |
5dcaf3785ebe
fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
125
diff
changeset
|
905 break; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
906 // 3.1 tdata->stream_queue $B$+$i(B dequeue $B$9$k(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
907 // dequeue $B$7$?%G!<%?$O(B ARIB_STD_B25_BUFFER |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
908 qbuf = stream_dequeue(p_queue); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
909 /* no entry in the queue */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
910 if(qbuf == NULL) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
911 continue; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
912 } |
127
5a380559a61e
modify calclate bitrate mechanism.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
126
diff
changeset
|
913 data->streamer->total_byte += qbuf->size; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
914 // $B%/%j%F%#%+%k%;%/%7%g%sD9$$$N$J$s$H$+$7$?$$$J$!!D(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
915 // ToDo: memcpy $B$H$+%/%j%F%#%+%k%;%/%7%g%s$N30$K=P$9(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
916 // 3.2 tdata->streamer->mutex $B$r(B lock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
917 pthread_mutex_lock(&data->streamer->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
918 // 3.3 $B0J2<$r(B tdata->streamer->stream_nr $B$N?t$@$1%k!<%W(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
919 for ( i=0; i < data->streamer->stream_nr; i++ ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
920 // 3.3.1 tdata->streamer->stream_session[N]->is_valid $B$,M-8z$+3NG'(B |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
921 if ( data->streamer->stream_session[i] != NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
922 if ( data->streamer->stream_session[i]->is_valid ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
923 // 3.3.2 tdata->streamer->stream_session[N]->p_queue $B$X$N%3%T!<MQ%P%C%U%!$N(Balloc |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
924 buf = malloc(sizeof(ARIB_STD_B25_BUFFER)); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
925 if ( buf == NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
926 pthread_mutex_unlock(&data->streamer->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
927 log_error ("stream_func(): alloc NULL pointer. streaming abort.\n"); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
928 return NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
929 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
930 buf->data = NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
931 buf->data = malloc(qbuf->size); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
932 if ( buf->data == NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
933 log_error ("Cannot malloc buf memory. streaming session_id[%d] abort.\n", i); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
934 pthread_mutex_unlock(&data->streamer->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
935 return NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
936 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
937 // 3.3.3 3.1$B$G(B dequeue $B$7$?%P%C%U%!$r(B3.3.2$B$G(B alloc $B$7$?%P%C%U%!$X(B memcpy() |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
938 memcpy(buf->data, qbuf->data, qbuf->size); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
939 buf->size = qbuf->size; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
940 // 3.3.4 tdata->streamer->stream_session[N]->p_queue $B$X(B enqueue() |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
941 stream_enqueue(data->streamer->stream_session[i]->p_queue, buf); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
942 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
943 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
944 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
945 // 3.4 tdata->streamer->mutex $B$r(B unlock |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
946 pthread_mutex_unlock(&data->streamer->mutex); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
947 free(qbuf->data); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
948 free(qbuf); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
949 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
950 return NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
951 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
952 |
8 | 953 void |
954 show_usage(char *cmd) | |
955 { | |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
956 #ifdef HAVE_LIBARIB25 |
134 | 957 fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] [--es filename_suffix] [--start_time YYYYMMDDHHMISS] [--dlna] channel rectime destfile\n", cmd); |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
958 #else |
134 | 959 fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] [--es filename_suffix] [--start_time YYYYMMDDHHMISS] [--dlna] channel rectime destfile\n", cmd); |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
960 #endif |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
961 fprintf(stderr, "\n"); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
962 fprintf(stderr, "Remarks:\n"); |
38
3228f5cde349
recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
35
diff
changeset
|
963 fprintf(stderr, "if rectime is '-', records indefinitely.\n"); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
964 fprintf(stderr, "if destfile is '-', stdout is used for output.\n"); |
13 | 965 } |
966 | |
967 void | |
15 | 968 show_options(void) |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
969 { |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
970 fprintf(stderr, "Options:\n"); |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
971 #ifdef HAVE_LIBARIB25 |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
972 fprintf(stderr, "--b25: Decrypt using BCAS card\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
973 fprintf(stderr, " --round N: Specify round number\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
974 fprintf(stderr, " --strip: Strip null stream\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
975 fprintf(stderr, " --EMM: Instruct EMM operation\n"); |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
976 #endif |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
977 fprintf(stderr, "--udp: Turn on udp broadcasting\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
978 fprintf(stderr, " --addr hostname: Hostname or address to connect\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
979 fprintf(stderr, " --port portnumber: Port number to connect\n"); |
32
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
980 fprintf(stderr, "--device devicefile: Specify devicefile to use\n"); |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
981 fprintf(stderr, "--lnb voltage: Specify LNB voltage (0, 11, 15)\n"); |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
97
diff
changeset
|
982 fprintf(stderr, "--sid SID1,SID2,...: Specify SID number in CSV format (101,102,...)\n"); |
121 | 983 fprintf(stderr, " --es filename: Specify ES out filename prefix\n"); |
122 | 984 fprintf(stderr, " --start_time YYYYMMDDHHMISS: Specify record start datetime\n"); |
134 | 985 fprintf(stderr, "--dlna: Turn on DLNA DMS(Digital Media Server)\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
986 fprintf(stderr, "--help: Show this help\n"); |
43
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
987 fprintf(stderr, "--version: Show version\n"); |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
988 fprintf(stderr, "--list: Show channel list\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
989 } |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
990 |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
991 void |
13 | 992 show_channels(void) |
993 { | |
59
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
994 FILE *f; |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
995 char *home; |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
996 char buf[255], filename[255]; |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
997 |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
998 fprintf(stderr, "Available Channels:\n"); |
59
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
999 |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1000 home = getenv("HOME"); |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1001 sprintf(filename, "%s/.recpt1-channels", home); |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1002 f = fopen(filename, "r"); |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1003 if(f) { |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1004 while(fgets(buf, 255, f)) |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1005 fprintf(stderr, "%s", buf); |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1006 fclose(f); |
aeb885ed4e7e
recpt1 shows list of terrestrial channels if .recpt1-channels is available in the home directory.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
57
diff
changeset
|
1007 } |
151
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1008 else { |
67
18108d097707
replaced full-width colon with half-width colon in channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
63
diff
changeset
|
1009 fprintf(stderr, "13-62: Terrestrial Channels\n"); |
151
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1010 fprintf(stderr, "101ch: NHK BS1\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1011 fprintf(stderr, "102ch: NHK BS2\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1012 fprintf(stderr, "103ch: NHK BShi\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1013 fprintf(stderr, "141ch: BS Nittele\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1014 fprintf(stderr, "151ch: BS Asahi\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1015 fprintf(stderr, "161ch: BS-TBS\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1016 fprintf(stderr, "171ch: BS Japan\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1017 fprintf(stderr, "181ch: BS Fuji\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1018 fprintf(stderr, "191ch: WOWOW\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1019 fprintf(stderr, "192ch: WOWOW2\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1020 fprintf(stderr, "193ch: WOWOW3\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1021 fprintf(stderr, "200ch: Star Channel\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1022 fprintf(stderr, "211ch: BS11 Digital\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1023 fprintf(stderr, "222ch: TwellV\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1024 fprintf(stderr, "C13-C63: CATV Channels\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1025 fprintf(stderr, "CS2-CS24: CS Channels\n"); |
f7f594bf4e98
If the ~/.recpt1-channels exists, do not output hard code channel info.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
149
diff
changeset
|
1026 } |
8 | 1027 } |
1028 | |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1029 float |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1030 getsignal_isdb_s(int signal) |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1031 { |
13 | 1032 /* apply linear interpolation */ |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1033 static const float afLevelTable[] = { |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1034 24.07f, // 00 00 0 24.07dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1035 24.07f, // 10 00 4096 24.07dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1036 18.61f, // 20 00 8192 18.61dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1037 15.21f, // 30 00 12288 15.21dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1038 12.50f, // 40 00 16384 12.50dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1039 10.19f, // 50 00 20480 10.19dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1040 8.140f, // 60 00 24576 8.140dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1041 6.270f, // 70 00 28672 6.270dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1042 4.550f, // 80 00 32768 4.550dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1043 3.730f, // 88 00 34816 3.730dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1044 3.630f, // 88 FF 35071 3.630dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1045 2.940f, // 90 00 36864 2.940dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1046 1.420f, // A0 00 40960 1.420dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1047 0.000f // B0 00 45056 -0.01dB |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1048 }; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1049 |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1050 unsigned char sigbuf[4]; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1051 memset(sigbuf, '\0', sizeof(sigbuf)); |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1052 sigbuf[0] = (((signal & 0xFF00) >> 8) & 0XFF); |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1053 sigbuf[1] = (signal & 0xFF); |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1054 |
13 | 1055 /* calculate signal level */ |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1056 if(sigbuf[0] <= 0x10U) { |
13 | 1057 /* clipped maximum */ |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1058 return 24.07f; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1059 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1060 else if (sigbuf[0] >= 0xB0U) { |
13 | 1061 /* clipped minimum */ |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1062 return 0.0f; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1063 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1064 else { |
13 | 1065 /* linear interpolation */ |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1066 const float fMixRate = |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1067 (float)(((unsigned short)(sigbuf[0] & 0x0FU) << 8) | |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1068 (unsigned short)sigbuf[0]) / 4096.0f; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1069 return afLevelTable[sigbuf[0] >> 4] * (1.0f - fMixRate) + |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1070 afLevelTable[(sigbuf[0] >> 4) + 0x01U] * fMixRate; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1071 } |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1072 } |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1073 |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1074 void |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1075 calc_cn(int fd, int type) |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1076 { |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1077 int rc ; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1078 double P ; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1079 double CNR; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1080 |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1081 if(ioctl(fd, GET_SIGNAL_STRENGTH, &rc) < 0) { |
62
c6a5c844c7fd
make some messages go stderr instead of stdout.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
61
diff
changeset
|
1082 fprintf(stderr, "Tuner Select Error\n"); |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1083 return ; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1084 } |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1085 |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1086 if(type == CHTYPE_GROUND) { |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1087 P = log10(5505024/(double)rc) * 10; |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1088 CNR = (0.000024 * P * P * P * P) - (0.0016 * P * P * P) + |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1089 (0.0398 * P * P) + (0.5491 * P)+3.0965; |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1090 fprintf(stderr, "C/N = %fdB\n", CNR); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1091 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1092 else { |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1093 CNR = getsignal_isdb_s(rc); |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1094 fprintf(stderr, "C/N = %fdB\n", CNR); |
11
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1095 } |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1096 } |
4615eaf04415
support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
8
diff
changeset
|
1097 |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1098 void |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1099 cleanup(thread_data *tdata) |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1100 { |
134 | 1101 boolean use_dlna = tdata->streamer ? TRUE : FALSE; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1102 /* stop recording */ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1103 ioctl(tdata->tfd, STOP_REC, 0); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1104 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1105 /* xxx need mutex? */ |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1106 f_exit = TRUE; |
126
5dcaf3785ebe
fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
125
diff
changeset
|
1107 if ( use_dlna ) { |
5dcaf3785ebe
fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
125
diff
changeset
|
1108 UPnPBreak(0); |
5dcaf3785ebe
fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
125
diff
changeset
|
1109 } |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1110 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1111 pthread_cond_signal(&tdata->queue->cond_avail); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1112 pthread_cond_signal(&tdata->queue->cond_used); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1113 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1114 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1115 /* will be signal handler thread */ |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1116 void * |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1117 process_signals(void *data) |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1118 { |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1119 sigset_t waitset; |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1120 int sig; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1121 thread_data *tdata = (thread_data *)data; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1122 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1123 sigemptyset(&waitset); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1124 sigaddset(&waitset, SIGPIPE); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1125 sigaddset(&waitset, SIGINT); |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1126 sigaddset(&waitset, SIGTERM); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1127 sigaddset(&waitset, SIGUSR1); |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1128 sigaddset(&waitset, SIGUSR2); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1129 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1130 sigwait(&waitset, &sig); |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1131 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1132 switch(sig) { |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1133 case SIGPIPE: |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1134 fprintf(stderr, "\nSIGPIPE received. cleaning up...\n"); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1135 cleanup(tdata); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1136 break; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1137 case SIGINT: |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1138 fprintf(stderr, "\nSIGINT received. cleaning up...\n"); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1139 cleanup(tdata); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1140 break; |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1141 case SIGTERM: |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1142 fprintf(stderr, "\nSIGTERM received. cleaning up...\n"); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1143 cleanup(tdata); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1144 break; |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1145 case SIGUSR1: /* normal exit*/ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1146 cleanup(tdata); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1147 break; |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1148 case SIGUSR2: /* error */ |
39
b03685d25fee
recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
38
diff
changeset
|
1149 fprintf(stderr, "Detected an error. cleaning up...\n"); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1150 cleanup(tdata); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1151 break; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1152 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1153 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1154 return NULL; /* dummy */ |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1155 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1156 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1157 void |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1158 init_signal_handlers(pthread_t *signal_thread, thread_data *tdata) |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1159 { |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1160 sigset_t blockset; |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1161 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1162 sigemptyset(&blockset); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1163 sigaddset(&blockset, SIGPIPE); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1164 sigaddset(&blockset, SIGINT); |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1165 sigaddset(&blockset, SIGTERM); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1166 sigaddset(&blockset, SIGUSR1); |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1167 sigaddset(&blockset, SIGUSR2); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1168 |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1169 if(pthread_sigmask(SIG_BLOCK, &blockset, NULL)) |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1170 fprintf(stderr, "pthread_sigmask() failed.\n"); |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1171 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1172 pthread_create(signal_thread, NULL, process_signals, tdata); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1173 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1174 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1175 int |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1176 tune(char *channel, thread_data *tdata, char *device) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1177 { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1178 char **tuner; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1179 int num_devs; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1180 int lp; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1181 FREQUENCY freq; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1182 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1183 /* get channel */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1184 tdata->table = searchrecoff(channel); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1185 if(tdata->table == NULL) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1186 fprintf(stderr, "Invalid Channel: %s\n", channel); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1187 return 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1188 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1189 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1190 freq.frequencyno = tdata->table->set_freq; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1191 freq.slot = tdata->table->add_freq; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1192 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1193 /* open tuner */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1194 /* case 1: specified tuner device */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1195 if(device) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1196 tdata->tfd = open(device, O_RDONLY); |
134 | 1197 tdata->device_id = get_device_id_by_name(device); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1198 if(tdata->tfd < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1199 fprintf(stderr, "Cannot open tuner device: %s\n", device); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1200 return 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1201 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1202 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1203 /* power on LNB */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1204 if(tdata->table->type == CHTYPE_SATELLITE) { |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1205 if(ioctl(tdata->tfd, LNB_ENABLE, tdata->lnb) < 0) { |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1206 fprintf(stderr, "Power on LNB failed: %s\n", device); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1207 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1208 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1209 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1210 /* tune to specified channel */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1211 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1212 close(tdata->tfd); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1213 fprintf(stderr, "Cannot tune to the specified channel: %s\n", device); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1214 return 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1215 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1216 else { |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
1217 strncpy(tdata->ch, channel, sizeof(tdata->ch)); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1218 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1219 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1220 else { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1221 /* case 2: loop around available devices */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1222 if(tdata->table->type == CHTYPE_SATELLITE) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1223 tuner = bsdev; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1224 num_devs = NUM_BSDEV; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1225 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1226 else { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1227 tuner = isdb_t_dev; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1228 num_devs = NUM_ISDB_T_DEV; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1229 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1230 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1231 for(lp = 0; lp < num_devs; lp++) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1232 tdata->tfd = open(tuner[lp], O_RDONLY); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1233 if(tdata->tfd >= 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1234 /* power on LNB */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1235 if(tdata->table->type == CHTYPE_SATELLITE) { |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1236 if(ioctl(tdata->tfd, LNB_ENABLE, tdata->lnb) < 0) { |
89
d74bcf2d255d
do not give up if LNB ioctl failed
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
88
diff
changeset
|
1237 fprintf(stderr, "Warning: Power on LNB failed: %s\n", tuner[lp]); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1238 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1239 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1240 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1241 /* tune to specified channel */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1242 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1243 close(tdata->tfd); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1244 tdata->tfd = -1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1245 continue; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1246 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1247 |
133
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1248 tdata->device_id = get_device_id_by_name(tuner[lp]); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1249 break; /* found suitable tuner */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1250 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1251 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1252 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1253 /* all tuners cannot be used */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1254 if(tdata->tfd < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1255 fprintf(stderr, "Cannot tune to the specified channel\n"); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1256 return 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1257 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1258 else { |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
1259 strncpy(tdata->ch, channel, sizeof(tdata->ch)); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1260 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1261 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1262 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1263 /* show signal strength */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1264 calc_cn(tdata->tfd, tdata->table->type); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1265 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1266 return 0; /* success */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1267 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1268 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1269 int |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1270 parse_time(char *rectimestr, thread_data *tdata) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1271 { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1272 /* indefinite */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1273 if(!strcmp("-", rectimestr)) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1274 tdata->indefinite = TRUE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1275 tdata->recsec = -1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1276 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1277 /* colon */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1278 else if(strchr(rectimestr, ':')) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1279 int n1, n2, n3; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1280 if(sscanf(rectimestr, "%d:%d:%d", &n1, &n2, &n3) == 3) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1281 tdata->recsec = n1 * 3600 + n2 * 60 + n3; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1282 else if(sscanf(rectimestr, "%d:%d", &n1, &n2) == 2) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1283 tdata->recsec = n1 * 3600 + n2 * 60; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1284 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1285 /* HMS */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1286 else { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1287 char *tmpstr; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1288 char *p1, *p2; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1289 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1290 tmpstr = strdup(rectimestr); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1291 p1 = tmpstr; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1292 while(*p1 && !isdigit(*p1)) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1293 p1++; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1294 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1295 /* hour */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1296 if((p2 = strchr(p1, 'H')) || (p2 = strchr(p1, 'h'))) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1297 *p2 = '\0'; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1298 tdata->recsec += atoi(p1) * 3600; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1299 p1 = p2 + 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1300 while(*p1 && !isdigit(*p1)) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1301 p1++; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1302 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1303 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1304 /* minute */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1305 if((p2 = strchr(p1, 'M')) || (p2 = strchr(p1, 'm'))) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1306 *p2 = '\0'; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1307 tdata->recsec += atoi(p1) * 60; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1308 p1 = p2 + 1; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1309 while(*p1 && !isdigit(*p1)) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1310 p1++; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1311 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1312 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1313 /* second */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1314 tdata->recsec += atoi(p1); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1315 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1316 free(tmpstr); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1317 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1318 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1319 return 0; /* success */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1320 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1321 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1322 int |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1323 close_tuner(thread_data *tdata) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1324 { |
89
d74bcf2d255d
do not give up if LNB ioctl failed
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
88
diff
changeset
|
1325 int rv = 0; |
d74bcf2d255d
do not give up if LNB ioctl failed
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
88
diff
changeset
|
1326 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1327 if(tdata->table->type == CHTYPE_SATELLITE) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1328 if(ioctl(tdata->tfd, LNB_DISABLE, 0) < 0) { |
89
d74bcf2d255d
do not give up if LNB ioctl failed
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
88
diff
changeset
|
1329 rv = 1; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1330 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1331 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1332 close(tdata->tfd); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1333 |
89
d74bcf2d255d
do not give up if LNB ioctl failed
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
88
diff
changeset
|
1334 return rv; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1335 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1336 |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1337 thread_data *gp_tdata; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1338 |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1339 int |
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1340 main(int argc, char **argv) |
0 | 1341 { |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1342 time_t cur_time; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1343 pthread_t signal_thread; |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1344 pthread_t reader_thread; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1345 pthread_t stream_thread; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1346 pthread_t ipc_thread; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1347 pthread_t dlna_thread; |
4 | 1348 QUEUE_T *p_queue = create_queue(MAX_QUEUE); |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1349 STREAM_QUEUE_T *stream_queue = create_stream_queue(MAX_QUEUE); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1350 BUFSZ *bufptr; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1351 decoder *dec = NULL; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1352 splitter *splitter = NULL; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1353 static thread_data tdata; |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1354 gp_tdata = &tdata; |
8 | 1355 decoder_options dopt = { |
1356 4, /* round */ | |
1357 0, /* strip */ | |
1358 0 /* emm */ | |
1359 }; | |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1360 tdata.dopt = &dopt; |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1361 tdata.lnb = 0; |
0 | 1362 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1363 int result; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1364 int option_index; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1365 struct option long_options[] = { |
74
b6607f6e2851
good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
67
diff
changeset
|
1366 #ifdef HAVE_LIBARIB25 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1367 { "b25", 0, NULL, 'b'}, |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1368 { "B25", 0, NULL, 'b'}, |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1369 { "round", 1, NULL, 'r'}, |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1370 { "strip", 0, NULL, 's'}, |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1371 { "emm", 0, NULL, 'm'}, |
8 | 1372 { "EMM", 0, NULL, 'm'}, |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1373 #endif |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1374 { "LNB", 1, NULL, 'n'}, |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1375 { "lnb", 1, NULL, 'n'}, |
13 | 1376 { "udp", 0, NULL, 'u'}, |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1377 { "addr", 1, NULL, 'a'}, |
13 | 1378 { "port", 1, NULL, 'p'}, |
32
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1379 { "device", 1, NULL, 'd'}, |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1380 { "help", 0, NULL, 'h'}, |
43
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
1381 { "version", 0, NULL, 'v'}, |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1382 { "list", 0, NULL, 'l'}, |
98
3fd15032fd3a
tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
97
diff
changeset
|
1383 { "sid", 1, NULL, 'i'}, |
121 | 1384 { "SID", 1, NULL, 'i'}, |
1385 { "es", 1, NULL, 'e'}, | |
1386 { "ES", 1, NULL, 'e'}, | |
122 | 1387 { "start_time", 1, NULL, 'y'}, |
134 | 1388 { "dlna", 0, NULL, 'c'}, |
1389 { "DLNA", 0, NULL, 'c'}, | |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1390 {0, 0, NULL, 0} /* terminate */ |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1391 }; |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1392 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1393 boolean use_b25 = FALSE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1394 boolean use_udp = FALSE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1395 boolean fileless = FALSE; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1396 boolean use_stdout = FALSE; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1397 boolean use_splitter = FALSE; |
134 | 1398 boolean use_esout = FALSE; |
1399 boolean use_dlna = FALSE; | |
8 | 1400 char *host_to = NULL; |
1401 int port_to = 1234; | |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1402 sock_data *sockdata = NULL; |
32
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1403 char *device = NULL; |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1404 int val; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1405 char *voltage[] = {"0V", "11V", "15V"}; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1406 char *sid_list = NULL; |
121 | 1407 char *es_name_prefix = NULL; |
122 | 1408 char *start_time = NULL; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1409 |
134 | 1410 while((result = getopt_long(argc, argv, "br:smn:ua:p:d:hvli:y:c", |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1411 long_options, &option_index)) != -1) { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1412 switch(result) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1413 case 'b': |
13 | 1414 use_b25 = TRUE; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1415 fprintf(stderr, "using B25...\n"); |
8 | 1416 break; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1417 case 's': |
13 | 1418 dopt.strip = TRUE; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1419 fprintf(stderr, "enable B25 strip\n"); |
8 | 1420 break; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1421 case 'm': |
13 | 1422 dopt.emm = TRUE; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1423 fprintf(stderr, "enable B25 emm processing\n"); |
8 | 1424 break; |
13 | 1425 case 'u': |
1426 use_udp = TRUE; | |
1427 host_to = "localhost"; | |
1428 fprintf(stderr, "enable UDP broadcasting\n"); | |
1429 break; | |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1430 case 'h': |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1431 fprintf(stderr, "\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1432 show_usage(argv[0]); |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1433 fprintf(stderr, "\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1434 show_options(); |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1435 fprintf(stderr, "\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1436 show_channels(); |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1437 fprintf(stderr, "\n"); |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1438 exit(0); |
13 | 1439 break; |
43
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
1440 case 'v': |
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
1441 fprintf(stderr, "%s %s\n", argv[0], version); |
91
2b55985bbb4c
- adapt date format to driver's one
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
89
diff
changeset
|
1442 fprintf(stderr, "recorder command for PT1/2 digital tuner.\n"); |
43
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
1443 exit(0); |
9b36fdf7d5d0
show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
42
diff
changeset
|
1444 break; |
57
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1445 case 'l': |
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1446 show_channels(); |
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1447 exit(0); |
d3929562b8e7
- added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
49
diff
changeset
|
1448 break; |
13 | 1449 /* following options require argument */ |
81
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1450 case 'n': |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1451 val = atoi(optarg); |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1452 switch(val) { |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1453 case 11: |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1454 tdata.lnb = 1; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1455 break; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1456 case 15: |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1457 tdata.lnb = 2; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1458 break; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1459 default: |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1460 tdata.lnb = 0; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1461 break; |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1462 } |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1463 fprintf(stderr, "LNB = %s\n", voltage[tdata.lnb]); |
6e3bb2c0c5b6
add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
78
diff
changeset
|
1464 break; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1465 case 'r': |
8 | 1466 dopt.round = atoi(optarg); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1467 fprintf(stderr, "set round %d\n", dopt.round); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1468 break; |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1469 case 'a': |
13 | 1470 use_udp = TRUE; |
8 | 1471 host_to = optarg; |
1472 fprintf(stderr, "UDP destination address: %s\n", host_to); | |
1473 break; | |
1474 case 'p': | |
1475 port_to = atoi(optarg); | |
1476 fprintf(stderr, "UDP port: %d\n", port_to); | |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1477 break; |
32
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1478 case 'd': |
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1479 device = optarg; |
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1480 fprintf(stderr, "using device: %s\n", device); |
6004fe4f37f9
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
28
diff
changeset
|
1481 break; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1482 case 'i': |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1483 use_splitter = TRUE; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1484 sid_list = optarg; |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1485 break; |
121 | 1486 case 'e': |
134 | 1487 use_esout = TRUE; |
121 | 1488 es_name_prefix = optarg; |
1489 break; | |
122 | 1490 case 'y': |
1491 start_time = optarg; | |
1492 break; | |
134 | 1493 case 'c': |
1494 use_dlna = TRUE; | |
1495 fprintf(stderr, "enable DLNA DMS(Digital Media Server)\n"); | |
1496 break; | |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1497 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1498 } |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1499 |
8 | 1500 if(argc - optind < 3) { |
134 | 1501 if(argc - optind == 2 && |
1502 (use_udp|use_dlna|use_esout) ) { | |
1503 if ( use_udp ) { | |
1504 fprintf(stderr, "Fileless UDP broadcasting\n"); | |
1505 } | |
1506 else if ( use_dlna ) { | |
1507 fprintf(stderr, "Fileless DLNA broadcasting\n"); | |
1508 } | |
1509 else if ( use_esout ) { | |
1510 fprintf(stderr, "Fileless ES out\n"); | |
1511 } | |
1512 else { | |
1513 fprintf(stderr, "Fileless...not found...\n"); | |
1514 } | |
13 | 1515 fileless = TRUE; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1516 tdata.wfd = -1; |
13 | 1517 } |
1518 else { | |
14
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1519 fprintf(stderr, "Arguments are necessary!\n"); |
cad940a903f5
- replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
13
diff
changeset
|
1520 fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]); |
13 | 1521 return 1; |
1522 } | |
4 | 1523 } |
13 | 1524 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1525 fprintf(stderr, "pid = %d\n", getpid()); |
34
3f2487de156e
should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
33
diff
changeset
|
1526 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1527 /* tune */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1528 if(tune(argv[optind], &tdata, device) != 0) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1529 return 1; |
47
edd904628e2f
a bit improved support for time format. now recpt1 recognize string such as 1h05m10s.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
43
diff
changeset
|
1530 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1531 /* set recsec */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1532 if(parse_time(argv[optind + 1], &tdata) != 0) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1533 return 1; |
48
c8051f6da2ab
now recpt1 accepts formats like 1:20:05 (hh:mm:ss) or 1:20 (hh:mm).
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
47
diff
changeset
|
1534 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1535 /* open output file */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1536 char *destfile = argv[optind + 2]; |
38
3228f5cde349
recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
35
diff
changeset
|
1537 if(destfile && !strcmp("-", destfile)) { |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1538 use_stdout = TRUE; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1539 tdata.wfd = 1; /* stdout */ |
38
3228f5cde349
recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
35
diff
changeset
|
1540 } |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1541 else { |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1542 if(!fileless) { |
61
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
1543 int status; |
63
ca419e61f7f2
fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
62
diff
changeset
|
1544 char *path = strdup(argv[optind + 2]); |
ca419e61f7f2
fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
62
diff
changeset
|
1545 char *dir = dirname(path); |
61
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
1546 status = mkpath(dir, 0777); |
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
1547 if(status == -1) |
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
1548 perror("mkpath"); |
63
ca419e61f7f2
fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
62
diff
changeset
|
1549 free(path); |
61
f1553492e8bb
ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
59
diff
changeset
|
1550 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1551 tdata.wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1552 if(tdata.wfd < 0) { |
34
3f2487de156e
should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
33
diff
changeset
|
1553 fprintf(stderr, "Cannot open output file: %s\n", |
33
f25820d90249
make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
32
diff
changeset
|
1554 argv[optind + 2]); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1555 return 1; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1556 } |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1557 } |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1558 } |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1559 |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1560 /* initialize decoder */ |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1561 if(use_b25) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1562 dec = b25_startup(&dopt); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1563 if(!dec) { |
34
3f2487de156e
should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
33
diff
changeset
|
1564 fprintf(stderr, "Cannot start b25 decoder\n"); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1565 fprintf(stderr, "Fall back to encrypted recording\n"); |
122 | 1566 use_b25 = FALSE; |
4 | 1567 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1568 } |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1569 /* initialize splitter */ |
122 | 1570 if(use_splitter) { |
1571 splitter = split_startup(sid_list, es_name_prefix, start_time); | |
1572 if(splitter->sid_list == NULL) { | |
104
afd25d9ebef6
output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
103
diff
changeset
|
1573 fprintf(stderr, "Cannot start TS splitter\n"); |
afd25d9ebef6
output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
103
diff
changeset
|
1574 return 1; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1575 } |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
1576 strncpy(tdata.sid_list, sid_list, sizeof(tdata.sid_list)); |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1577 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1578 |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1579 /* initialize DLNA */ |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1580 if(use_dlna) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1581 do { |
155
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1582 if(use_splitter && tdata.table->type == CHTYPE_GROUND) |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1583 channel_list = open_list_file("ISDB", NULL); |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1584 else { |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1585 channel_list = open_list_file("BS", NULL); |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1586 channel_list = open_list_file("CS", channel_list); |
5d010d0ff6a1
Change line number of the CSV file to be used for ID management.
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
154
diff
changeset
|
1587 } |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1588 tdata.stream_queue = stream_queue; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1589 tdata.streamer = malloc(sizeof(streamer)); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1590 if ( tdata.streamer == NULL ) { |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1591 use_dlna = FALSE; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1592 break; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1593 } |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1594 tdata.streamer->stream_nr = 0; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1595 tdata.streamer->stream_session[0] = NULL; |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1596 pthread_mutex_init(&tdata.streamer->mutex, NULL); |
164
7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
163
diff
changeset
|
1597 pthread_mutex_init(&tdata.splitter_mutex, NULL); |
134 | 1598 |
1599 pthread_create(&stream_thread, NULL, stream_func, &tdata); | |
1600 pthread_create(&dlna_thread, NULL, dlna_startup, NULL); | |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1601 } while(0); |
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1602 } |
134 | 1603 else { |
1604 tdata.streamer = NULL; | |
1605 } | |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1606 |
8 | 1607 /* initialize udp connection */ |
1608 if(use_udp) { | |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1609 sockdata = calloc(1, sizeof(sock_data)); |
8 | 1610 struct in_addr ia; |
1611 ia.s_addr = inet_addr(host_to); | |
1612 if(ia.s_addr == INADDR_NONE) { | |
1613 struct hostent *hoste = gethostbyname(host_to); | |
1614 if(!hoste) { | |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1615 perror("gethostbyname"); |
8 | 1616 return 1; |
1617 } | |
1618 ia.s_addr = *(in_addr_t*) (hoste->h_addr_list[0]); | |
1619 } | |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1620 if((sockdata->sfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1621 perror("socket"); |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1622 return 1; |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1623 } |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1624 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1625 sockdata->addr.sin_family = AF_INET; |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1626 sockdata->addr.sin_port = htons (port_to); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1627 sockdata->addr.sin_addr.s_addr = ia.s_addr; |
28
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1628 |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1629 if(connect(sockdata->sfd, (struct sockaddr *)&sockdata->addr, |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1630 sizeof(sockdata->addr)) < 0) { |
97c820e30737
limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
27
diff
changeset
|
1631 perror("connect"); |
8 | 1632 return 1; |
1633 } | |
1634 } | |
1635 | |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1636 /* prepare thread data */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1637 tdata.queue = p_queue; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1638 tdata.decoder = dec; |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1639 tdata.splitter = splitter; |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1640 tdata.sock_data = sockdata; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1641 |
33
f25820d90249
make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
32
diff
changeset
|
1642 /* spawn signal handler thread */ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1643 init_signal_handlers(&signal_thread, &tdata); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1644 |
33
f25820d90249
make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
32
diff
changeset
|
1645 /* spawn reader thread */ |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1646 tdata.signal_thread = signal_thread; |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1647 pthread_create(&reader_thread, NULL, reader_func, &tdata); |
3 | 1648 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1649 /* spawn ipc thread */ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1650 key_t key; |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1651 key = (key_t)getpid(); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1652 |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1653 if ((tdata.msqid = msgget(key, IPC_CREAT | 0666)) < 0) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1654 perror("msgget"); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1655 } |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1656 pthread_create(&ipc_thread, NULL, mq_recv, &tdata); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1657 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1658 /* start recording */ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1659 if(ioctl(tdata.tfd, START_REC, 0) < 0) { |
34
3f2487de156e
should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
33
diff
changeset
|
1660 fprintf(stderr, "Tuner cannot start recording\n"); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1661 return 1; |
4 | 1662 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1663 |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1664 fprintf(stderr, "Recording...\n"); |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1665 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1666 time(&tdata.start_time); |
0 | 1667 |
4 | 1668 /* read from tuner */ |
1669 while(1) { | |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1670 if(f_exit) |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1671 break; |
26 | 1672 |
4 | 1673 time(&cur_time); |
1674 bufptr = malloc(sizeof(BUFSZ)); | |
88
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1675 if(!bufptr) { |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1676 f_exit = TRUE; |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1677 break; |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1678 } |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1679 bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE); |
4 | 1680 if(bufptr->size <= 0) { |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1681 if((cur_time - tdata.start_time) >= tdata.recsec && !tdata.indefinite) { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1682 f_exit = TRUE; |
4 | 1683 enqueue(p_queue, NULL); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1684 break; |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1685 } |
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1686 else { |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1687 free(bufptr); |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1688 bufptr = NULL; |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1689 continue; |
4 | 1690 } |
1691 } | |
1692 enqueue(p_queue, bufptr); | |
0 | 1693 |
4 | 1694 /* stop recording */ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1695 time(&cur_time); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1696 if((cur_time - tdata.start_time) >= tdata.recsec && !tdata.indefinite) { |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1697 ioctl(tdata.tfd, STOP_REC, 0); |
4 | 1698 /* read remaining data */ |
1699 while(1) { | |
1700 bufptr = malloc(sizeof(BUFSZ)); | |
88
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1701 if(!bufptr) { |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1702 f_exit = TRUE; |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1703 break; |
59065b569eec
improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
87
diff
changeset
|
1704 } |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1705 bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE); |
4 | 1706 if(bufptr->size <= 0) { |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1707 f_exit = TRUE; |
4 | 1708 enqueue(p_queue, NULL); |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1709 break; |
163
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1710 } else { |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1711 free(bufptr); |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1712 bufptr = NULL; |
57eae2aec60d
improve-channel-switching.patch.(https://gist.github.com/890635)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
162
diff
changeset
|
1713 break; |
4 | 1714 } |
1715 enqueue(p_queue, bufptr); | |
1716 } | |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1717 break; |
4 | 1718 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1719 } |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1720 //fprintf (stderr, "main() break?.\n"); |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1721 |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1722 /* delete message queue*/ |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1723 msgctl(tdata.msqid, IPC_RMID, NULL); |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1724 |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1725 pthread_kill(signal_thread, SIGUSR1); |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1726 |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1727 /* wait for threads */ |
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1728 pthread_join(reader_thread, NULL); |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1729 pthread_join(stream_thread, NULL); |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1730 pthread_join(signal_thread, NULL); |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1731 pthread_join(ipc_thread, NULL); |
134 | 1732 if ( use_dlna ) { |
1733 pthread_join(dlna_thread, NULL); | |
152
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
1734 if ( channel_list ) |
30e91361506a
EXPERIMENTAL: Enable change phisical channel by DLNA.(ISDB-T only)
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
151
diff
changeset
|
1735 close_list_file(channel_list); |
134 | 1736 } |
24
f2cce7becf52
fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
21
diff
changeset
|
1737 |
4 | 1738 /* close tuner */ |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1739 if(close_tuner(&tdata) != 0) |
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1740 return 1; |
0 | 1741 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1742 /* release queue */ |
4 | 1743 destroy_queue(p_queue); |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1744 |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1745 /* close output file */ |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1746 if(!use_stdout) |
78
5a0126d8af17
landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
74
diff
changeset
|
1747 close(tdata.wfd); |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1748 |
16
ecb85bde67b1
added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
15
diff
changeset
|
1749 /* free socket data */ |
18
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1750 if(use_udp) { |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1751 close(sockdata->sfd); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1752 free(sockdata); |
84ff6ef710ea
- support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
17
diff
changeset
|
1753 } |
8 | 1754 |
4 | 1755 /* release decoder */ |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1756 if(use_b25) { |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1757 b25_shutdown(dec); |
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1758 } |
96
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1759 if(use_splitter) { |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1760 split_shutdown(splitter); |
52f8e081763d
add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
91
diff
changeset
|
1761 } |
2
8ac7c59fefc9
added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
1
diff
changeset
|
1762 |
5
97fd2315114e
- now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
4
diff
changeset
|
1763 return 0; |
0 | 1764 } |
124
9c7bc6c0327e
Add DLNA server function test. (from uShare project)
naoyan@johnstown.minaminoshima.org
parents:
122
diff
changeset
|
1765 |
133
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1766 static int |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1767 get_device_id_by_name |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1768 ( const char *name ) |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1769 { |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1770 int i = -1; |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1771 if ( name != NULL ) { |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1772 if( ! strncmp(name, DEVICE_NAME_BASE, strlen(DEVICE_NAME_BASE) ) ) { |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1773 i = atoi(name+strlen(DEVICE_NAME_BASE)); |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1774 } |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1775 } |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1776 return i; |
0db6ccf0fe31
modify DLNA display name & UUID
Naoya OYAMA <naoya.oyama@gmail.com>
parents:
127
diff
changeset
|
1777 } |