RE: Any developers working on a Android port of Tvheadend? ยป tvheadend-master-android.patch
tvheadend-master-android/Makefile 2014-04-29 12:17:17.000000000 +0900 | ||
---|---|---|
32 | 32 |
CFLAGS += -g -funsigned-char -O2 |
33 | 33 |
CFLAGS += -D_FILE_OFFSET_BITS=64 |
34 | 34 |
CFLAGS += -I${BUILDDIR} -I${ROOTDIR}/src -I${ROOTDIR} |
35 |
LDFLAGS += -lrt -ldl -lpthread -lm |
|
35 |
LDFLAGS += -ldl -lm -llog |
|
36 |
#LDFLAGS += -lrt -ldl -lpthread -lm |
|
36 | 37 | |
37 | 38 |
vpath %.c $(ROOTDIR) |
38 | 39 |
vpath %.h $(ROOTDIR) |
tvheadend-master-android/README 2014-04-29 11:02:01.000000000 +0900 | ||
---|---|---|
16 | 16 | |
17 | 17 |
$ ./configure |
18 | 18 | |
19 |
Sample configure for Android: |
|
20 | ||
21 |
$ ./configure --disable-avahi \ |
|
22 |
--disable-libav \ |
|
23 |
--enable-bundle \ |
|
24 |
--enable-android \ |
|
25 |
--arch=armeabi-v7a \ |
|
26 |
--cc=arm-linux-androideabi-gcc \ |
|
27 |
--android_toolchain=/home/jernej/Android/toolchain/android-9 |
|
28 | ||
19 | 29 |
If any dependencies are missing the configure script will complain or attempt |
20 | 30 |
to disable optional features. |
21 | 31 |
tvheadend-master-android/configure 2014-04-29 12:40:56.000000000 +0900 | ||
---|---|---|
36 | 36 |
"bundle:no" |
37 | 37 |
"dvbcsa:no" |
38 | 38 |
"kqueue:no" |
39 |
"android:no" |
|
39 | 40 |
"mpegts_dvb:auto" |
40 | 41 |
) |
41 | 42 |
tvheadend-master-android/src/descrambler/capmt.c 2014-04-29 11:04:58.000000000 +0900 | ||
---|---|---|
75 | 75 |
printf(format, __VA_ARGS__); int j; for (j = 0; j < len; ++j) printf("%02X ", buf[j]); printf("\n"); |
76 | 76 | |
77 | 77 |
#if defined(__GNUC__) && defined(__GNUC_MINOR__) |
78 |
#if !ENABLE_ANDROID |
|
78 | 79 |
#if 100*__GNUC__+__GNUC_MINOR >=403 |
79 | 80 |
#pragma GCC diagnostic ignored "-Warray-bounds" |
80 | 81 |
#endif |
81 | 82 |
#endif |
83 |
#endif |
|
82 | 84 | |
83 | 85 |
#define MAX_CA 4 |
84 | 86 |
#define MAX_INDEX 64 |
tvheadend-master-android/src/epggrab.c 2014-04-29 12:48:43.000000000 +0900 | ||
---|---|---|
16 | 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
*/ |
18 | 18 | |
19 |
#include "tvheadend.h" |
|
20 | ||
19 | 21 |
#include <errno.h> |
20 | 22 |
#include <stdlib.h> |
21 | 23 |
#include <string.h> |
22 | 24 |
#include <assert.h> |
23 | 25 |
#include <unistd.h> |
24 | 26 |
#include <sys/types.h> |
27 |
#if !ENABLE_ANDROID |
|
25 | 28 |
#include <sys/un.h> |
29 |
#endif |
|
26 | 30 |
#include <sys/socket.h> |
27 | 31 |
#include "htsmsg.h" |
28 | 32 |
#include "settings.h" |
29 |
#include "tvheadend.h" |
|
30 | 33 |
#include "queue.h" |
31 | 34 |
#include "epg.h" |
32 | 35 |
#include "epggrab.h" |
tvheadend-master-android/src/htsp_server.c 2014-04-29 11:24:37.000000000 +0900 | ||
---|---|---|
54 | 54 |
#include <sys/stat.h> |
55 | 55 |
#include <sys/types.h> |
56 | 56 |
#include <sys/socket.h> |
57 |
#if ENABLE_ANDROID |
|
58 |
#include <sys/vfs.h> |
|
59 |
#else |
|
57 | 60 |
#include <sys/statvfs.h> |
61 |
#endif |
|
58 | 62 |
#include "settings.h" |
59 | 63 |
#include <sys/time.h> |
60 | 64 | |
... | ... | |
850 | 854 |
htsp_method_getDiskSpace(htsp_connection_t *htsp, htsmsg_t *in) |
851 | 855 |
{ |
852 | 856 |
htsmsg_t *out; |
857 |
#if ENABLE_ANDROID |
|
858 |
struct statfs diskdata; |
|
859 |
#else |
|
853 | 860 |
struct statvfs diskdata; |
861 |
#endif |
|
854 | 862 |
dvr_config_t *cfg = dvr_config_find_by_name_default(""); |
855 | 863 | |
864 |
#if ENABLE_ANDROID |
|
865 |
if(statfs(cfg->dvr_storage,&diskdata) == -1) |
|
866 |
return htsp_error("Unable to stat path"); |
|
867 |
#else |
|
856 | 868 |
if(statvfs(cfg->dvr_storage,&diskdata) == -1) |
857 | 869 |
return htsp_error("Unable to stat path"); |
858 |
|
|
870 |
#endif |
|
871 | ||
859 | 872 |
out = htsmsg_create_map(); |
860 | 873 |
htsmsg_add_s64(out, "freediskspace", |
861 | 874 |
diskdata.f_bsize * (int64_t)diskdata.f_bavail); |
tvheadend-master-android/src/input/mpegts/tsfile/tsfile.c 2014-04-29 13:04:50.000000000 +0900 | ||
---|---|---|
110 | 110 |
{ |
111 | 111 |
tsfile_input_t *mi; |
112 | 112 |
mpegts_mux_t *mm; |
113 | ||
114 |
#ifdef __BIONIC__ |
|
115 |
char *uuid = NULL, *tok, *tmp = strdup(path); |
|
116 |
#else |
|
113 | 117 |
char *uuid = NULL, *tok, *tmp = strdupa(path); |
118 |
#endif |
|
114 | 119 | |
115 | 120 |
/* Pull UUID from info */ |
116 | 121 |
if ((tok = strstr(tmp, "::"))) { |
tvheadend-master-android/src/input/mpegts/tsfile/tsfile_input.c 2014-04-29 11:35:04.000000000 +0900 | ||
---|---|---|
33 | 33 | |
34 | 34 |
extern const idclass_t mpegts_input_class; |
35 | 35 | |
36 |
#if ENABLE_ANDROID |
|
37 |
extern int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); |
|
38 |
#endif |
|
36 | 39 | |
37 | 40 |
static void * |
38 | 41 |
tsfile_input_thread ( void *aux ) |
tvheadend-master-android/src/main.c 2014-04-29 11:27:59.000000000 +0900 | ||
---|---|---|
180 | 180 |
get_user_groups (const struct passwd *pw, gid_t* glist, size_t gmax) |
181 | 181 |
{ |
182 | 182 |
int num = 0; |
183 |
#if ENABLE_ANDROID |
|
184 |
return num; |
|
185 |
#else |
|
183 | 186 |
struct group *gr; |
184 | 187 |
char **mem; |
185 | 188 |
glist[num++] = pw->pw_gid; |
... | ... | |
190 | 193 |
} |
191 | 194 |
} |
192 | 195 |
return num; |
196 |
#endif |
|
193 | 197 |
} |
194 | 198 | |
195 | 199 |
/** |
... | ... | |
800 | 804 |
signal(SIGTERM, doexit); |
801 | 805 |
signal(SIGINT, doexit); |
802 | 806 | |
807 |
#if ENABLE_ANDROID |
|
808 |
sigprocmask(SIG_UNBLOCK, &set, NULL); |
|
809 |
#else |
|
803 | 810 |
pthread_sigmask(SIG_UNBLOCK, &set, NULL); |
811 |
#endif |
|
804 | 812 | |
805 | 813 |
tvhlog(LOG_NOTICE, "START", "HTS Tvheadend version %s started, " |
806 | 814 |
"running as PID:%d UID:%d GID:%d, CWD:%s CNF:%s", |
tvheadend-master-android/src/muxer.c 2014-04-29 12:56:48.000000000 +0900 | ||
---|---|---|
458 | 458 |
fsync(fd); |
459 | 459 |
/* fall through */ |
460 | 460 |
case MC_CACHE_DONTKEEP: |
461 |
#if !ENABLE_ANDROID |
|
461 | 462 |
posix_fadvise(fd, pos, size, POSIX_FADV_DONTNEED); |
463 |
#endif |
|
462 | 464 |
break; |
463 | 465 |
default: |
464 | 466 |
abort(); |
tvheadend-master-android/src/spawn.c 2014-04-29 11:35:51.000000000 +0900 | ||
---|---|---|
33 | 33 |
#include "file.h" |
34 | 34 |
#include "spawn.h" |
35 | 35 | |
36 |
#ifndef WIFCONTINUED |
|
37 |
#define WIFCONTINUED(s) ((s) == 0xffff) |
|
38 |
#endif |
|
39 | ||
36 | 40 |
extern char **environ; |
37 | 41 | |
38 | 42 |
pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER; |
tvheadend-master-android/src/timeshift/timeshift_reader.c 2014-04-29 11:47:34.000000000 +0900 | ||
---|---|---|
325 | 325 |
ts->id, (*cur_file)->path); |
326 | 326 |
*fd = open((*cur_file)->path, O_RDONLY); |
327 | 327 |
} |
328 |
#if ENABLE_ANDROID |
|
329 |
tvhtrace("timeshift", "ts %d seek to %"PRIoff_t, ts->id, (long long int)*cur_off); |
|
330 |
#else |
|
328 | 331 |
tvhtrace("timeshift", "ts %d seek to %"PRIoff_t, ts->id, *cur_off); |
332 |
#endif |
|
329 | 333 |
lseek(*fd, *cur_off, SEEK_SET); |
330 | 334 | |
331 | 335 |
/* Read msg */ |
... | ... | |
336 | 340 |
tvhlog(LOG_ERR, "timeshift", "ts %d could not read buffer", ts->id); |
337 | 341 |
return -1; |
338 | 342 |
} |
343 |
#if ENABLE_ANDROID |
|
344 |
tvhtrace("timeshift", "ts %d read msg %p (%"PRIssize_t")", |
|
345 |
ts->id, *sm, (int)r); |
|
346 |
#else |
|
339 | 347 |
tvhtrace("timeshift", "ts %d read msg %p (%"PRIssize_t")", |
340 | 348 |
ts->id, *sm, r); |
349 |
#endif |
|
341 | 350 | |
342 | 351 |
/* Incomplete */ |
343 | 352 |
if (r == 0) { |
tvheadend-master-android/src/tvheadend.h 2014-04-29 11:50:45.000000000 +0900 | ||
---|---|---|
44 | 44 | |
45 | 45 |
#include "redblack.h" |
46 | 46 | |
47 |
#if ENABLE_ANDROID |
|
48 |
#define S_IEXEC S_IXUSR |
|
49 |
#endif |
|
50 | ||
47 | 51 |
typedef struct { |
48 | 52 |
const char *name; |
49 | 53 |
const uint32_t *enabled; |
... | ... | |
507 | 511 |
return tp.tv_sec * 1000000ULL + (tp.tv_nsec / 1000); |
508 | 512 |
} |
509 | 513 | |
514 |
#if ENABLE_ANDROID |
|
515 |
static inline time_t timegm(struct tm *tm); |
|
516 | ||
517 |
time_t |
|
518 |
timegm(struct tm *tm) |
|
519 |
{ |
|
520 |
time_t ret; |
|
521 |
char *tz; |
|
522 | ||
523 |
tz = getenv("TZ"); |
|
524 |
setenv("TZ", "", 1); |
|
525 |
tzset(); |
|
526 |
ret = mktime(tm); |
|
527 |
if (tz) |
|
528 |
setenv("TZ", tz, 1); |
|
529 |
else |
|
530 |
unsetenv("TZ"); |
|
531 |
tzset(); |
|
532 |
return ret; |
|
533 |
} |
|
534 |
#endif |
|
535 | ||
510 | 536 |
int sri_to_rate(int sri); |
511 | 537 |
int rate_to_sri(int rate); |
512 | 538 |
tvheadend-master-android/src/tvhlog.c 2014-04-29 12:47:45.000000000 +0900 | ||
---|---|---|
147 | 147 |
tvhlog_process |
148 | 148 |
( tvhlog_msg_t *msg, int options, FILE **fp, const char *path ) |
149 | 149 |
{ |
150 |
#if !ENABLE_ANDROID |
|
150 | 151 |
int s; |
152 |
#endif |
|
151 | 153 |
size_t l; |
152 | 154 |
char buf[2048], t[128]; |
153 | 155 |
struct tm tm; |
... | ... | |
155 | 157 |
/* Syslog */ |
156 | 158 |
if (options & TVHLOG_OPT_SYSLOG) { |
157 | 159 |
if (options & TVHLOG_OPT_DBG_SYSLOG || msg->severity < LOG_DEBUG) { |
160 |
#if ENABLE_ANDROID |
|
161 |
__android_log_print(ANDROID_LOG_DEBUG, "tvheadend", "%s", msg->msg); |
|
162 |
#else |
|
158 | 163 |
s = msg->severity > LOG_DEBUG ? LOG_DEBUG : msg->severity; |
159 | 164 |
syslog(s, "%s", msg->msg); |
165 |
#endif |
|
160 | 166 |
} |
161 | 167 |
} |
162 | 168 | |
... | ... | |
413 | 419 |
tvhlog_trace = NULL; |
414 | 420 |
tvhlog_debug = NULL; |
415 | 421 |
tvhlog_run = 0; |
422 |
#if !ENABLE_ANDROID |
|
416 | 423 |
openlog("tvheadend", LOG_PID, LOG_DAEMON); |
424 |
#endif |
|
417 | 425 |
pthread_mutex_init(&tvhlog_mutex, NULL); |
418 | 426 |
pthread_cond_init(&tvhlog_cond, NULL); |
419 | 427 |
TAILQ_INIT(&tvhlog_queue); |
tvheadend-master-android/src/tvhlog.h 2014-04-29 12:46:17.000000000 +0900 | ||
---|---|---|
18 | 18 |
#ifndef __TVH_LOGGING_H__ |
19 | 19 |
#define __TVH_LOGGING_H__ |
20 | 20 | |
21 |
#include "config.h" |
|
22 |
#include "tvheadend.h" |
|
23 | ||
21 | 24 |
#include <sys/types.h> |
25 | ||
26 |
#if ENABLE_ANDROID |
|
27 |
#include <android/log.h> |
|
28 | ||
29 |
#define LOG_EMERG 0 /* system is unusable */ |
|
30 |
#define LOG_ALERT 1 /* action must be taken immediately */ |
|
31 |
#define LOG_CRIT 2 /* critical conditions */ |
|
32 |
#define LOG_ERR 3 /* error conditions */ |
|
33 |
#define LOG_WARNING 4 /* warning conditions */ |
|
34 |
#define LOG_NOTICE 5 /* normal but significant condition */ |
|
35 |
#define LOG_INFO 6 /* informational */ |
|
36 |
#define LOG_DEBUG 7 /* debug-level messages */ |
|
37 | ||
38 |
#else |
|
22 | 39 |
#include <sys/syslog.h> |
40 |
#endif |
|
41 | ||
23 | 42 |
#include <pthread.h> |
24 | 43 |
#include <stdarg.h> |
25 | 44 |
tvheadend-master-android/src/tvhtime.c 2014-04-29 12:50:19.000000000 +0900 | ||
---|---|---|
1 | 1 |
#define _ISOC9X_SOURCE |
2 | 2 | |
3 |
#include "tvheadend.h" |
|
4 | ||
3 | 5 |
#include <time.h> |
4 | 6 |
#include <sys/ipc.h> |
7 |
#if !ENABLE_ANDROID |
|
5 | 8 |
#include <sys/shm.h> |
9 |
#endif |
|
6 | 10 |
#include <sys/time.h> |
7 | 11 |
#include <stdio.h> |
8 | 12 |
#include <string.h> |
... | ... | |
11 | 15 |
#include <stdlib.h> |
12 | 16 | |
13 | 17 |
#include "tvhtime.h" |
14 |
#include "tvheadend.h" |
|
15 | 18 |
#include "settings.h" |
16 | 19 | |
17 | 20 |
uint32_t tvhtime_update_enabled; |
... | ... | |
46 | 49 |
int pad[10]; |
47 | 50 |
} ntp_shm_t; |
48 | 51 | |
52 |
#if !ENABLE_ANDROID |
|
49 | 53 |
static ntp_shm_t * |
50 | 54 |
ntp_shm_init ( void ) |
51 | 55 |
{ |
... | ... | |
72 | 76 | |
73 | 77 |
return shmptr; |
74 | 78 |
} |
79 |
#endif |
|
75 | 80 | |
76 | 81 |
/* |
77 | 82 |
* Update time |
... | ... | |
79 | 84 |
void |
80 | 85 |
tvhtime_update ( struct tm *tm ) |
81 | 86 |
{ |
87 |
#if !ENABLE_ANDROID |
|
82 | 88 |
time_t now; |
83 | 89 |
struct timeval tv; |
84 | 90 |
ntp_shm_t *ntp_shm; |
85 | 91 |
int64_t t1, t2; |
86 | 92 | |
87 |
tvhtrace("time", "current time is %04d/%02d/%02d %02d:%02d:%02d", |
|
93 |
tvhtrace("time", "current time is %04d/%02d/%02d %02d:%02d:%02d",
|
|
88 | 94 |
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
89 | 95 | |
90 | 96 |
/* Current and reported time */ |
... | ... | |
122 | 128 |
ntp_shm->count++; |
123 | 129 |
ntp_shm->valid = 1; |
124 | 130 |
} |
131 |
#endif |
|
125 | 132 |
} |
126 | 133 | |
127 | 134 |
/* Initialise */ |
tvheadend-master-android/src/version.c 2014-04-29 12:22:43.000000000 +0900 | ||
---|---|---|
1 |
const char *tvheadend_version = "0.0.0~unknown"; |
tvheadend-master-android/src/webui/webui.c 2014-04-29 12:08:50.000000000 +0900 | ||
---|---|---|
55 | 55 |
#include <sys/uio.h> |
56 | 56 |
#endif |
57 | 57 | |
58 |
#if ENABLE_ANDROID |
|
59 |
#include <sys/socket.h> |
|
60 |
#endif |
|
58 | 61 |
/** |
59 | 62 |
* |
60 | 63 |
*/ |
... | ... | |
961 | 964 |
file_end = st.st_size-1; |
962 | 965 |
|
963 | 966 |
range = http_arg_get(&hc->hc_args, "Range"); |
967 | ||
968 |
#if ENABLE_ANDROID |
|
969 |
if(range != NULL) |
|
970 |
sscanf(range, "bytes=%"PRId64"-%"PRId64"", (long long int *)&file_start, (long long int *)&file_end); |
|
971 |
#else |
|
964 | 972 |
if(range != NULL) |
965 | 973 |
sscanf(range, "bytes=%"PRId64"-%"PRId64"", &file_start, &file_end); |
974 |
#endif |
|
966 | 975 | |
967 | 976 |
//Sanity checks |
968 | 977 |
if(file_start < 0 || file_start >= st.st_size) { |
... | ... | |
981 | 990 | |
982 | 991 |
content_len = file_end - file_start+1; |
983 | 992 |
|
993 |
#if ENABLE_ANDROID |
|
994 |
sprintf(range_buf, "bytes %"PRId64"-%"PRId64"/%"PRId64"", |
|
995 |
(long long int)file_start, (long long int)file_end, st.st_size); |
|
996 |
#else |
|
984 | 997 |
sprintf(range_buf, "bytes %"PRId64"-%"PRId64"/%"PRId64"", |
985 | 998 |
file_start, file_end, st.st_size); |
999 |
#endif |
|
986 | 1000 | |
987 | 1001 |
if(file_start > 0) |
988 | 1002 |
lseek(fd, file_start, SEEK_SET); |
tvheadend-master-android/support/configure.inc 2014-04-29 12:15:21.000000000 +0900 | ||
---|---|---|
201 | 201 |
*dir|prefix) |
202 | 202 |
eval "$opt=$val" |
203 | 203 |
;; |
204 |
cc|cflags|arch|cpu|platform|python) |
|
204 |
cc|cflags|arch|cpu|platform|python|android_toolchain)
|
|
205 | 205 |
eval "`toupper $opt`=$val" |
206 | 206 |
;; |
207 | 207 |
enable-*) |
... | ... | |
497 | 497 |
#define PLATFORM_$(toupper ${PLATFORM}) 1 |
498 | 498 |
EOF |
499 | 499 | |
500 |
if enabled android; then |
|
501 |
cat >>${CONFIG_MK} <<EOF |
|
502 |
CFLAGS += -I${ANDROID_TOOLCHAIN}/staging/armeabi-v7a/include |
|
503 |
CFLAGS += -I${ANDROID_TOOLCHAIN}/sysroot/usr/include/ |
|
504 |
LDFLAGS += -L${ANDROID_TOOLCHAIN}/staging/armeabi-v7a/lib |
|
505 |
LDFLAGS += -L${ANDROID_TOOLCHAIN}/lib |
|
506 |
EOF |
|
507 |
else |
|
508 |
cat >>${CONFIG_MK} <<EOF |
|
509 |
LDFLAGS += -lrt -lpthread |
|
510 |
EOF |
|
511 |
fi |
|
512 | ||
500 | 513 |
# Add package config |
501 | 514 |
for pkg in ${PACKAGES[*]}; do |
502 | 515 |
cat >>"${CONFIG_MK}" <<EOF |