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