cherokee-1.2.101-001-patch.pdf
TRANSCRIPT
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
1/6
diff -urw cherokee-1.2.101.ori/cherokee/handler_dirlist.c cherokee-1.2.101/cherokee/
handler_dirlist.c
--- cherokee-1.2.101.ori/cherokee/handler_dirlist.c 2011-10-13 02:07:44.000000000
+0800
+++ cherokee-1.2.101/cherokee/handler_dirlist.c 2012-05-25 10:59:13.437081229 +0800
@@ -1222,7 +1222,7 @@
/* Add final result to buffer
*/
- cherokee_buffer_add_buffer (buffer, vtmp[idx_tmp]);
+ //cherokee_buffer_add_buffer (buffer, vtmp[idx_tmp]);
return ret_ok;
}
diff -urw cherokee-1.2.101.ori/cherokee/header.c cherokee-1.2.101/cherokee/header.c
--- cherokee-1.2.101.ori/cherokee/header.c 2011-10-13 02:07:44.000000000 +0800
+++ cherokee-1.2.101/cherokee/header.c 2012-06-04 10:38:25.864810868 +0800
@@ -897,6 +897,105 @@
return ret_error;
}
+/* AMBA modification */
+char *mp4link = NULL;
+char *jpglink = NULL;
+char *m3u8link = NULL;
+int ios4vf = 0;
+void nsleep(int nsec)
+{
+ struct timespec req;
+
+ req.tv_nsec = nsec;
+ req.tv_sec = 0;
+ nanosleep(&req, NULL);+}
+
+int get_defer(struct timeval *lastwrite, struct timeval *curwrite, int intervl, int
divide)
+{
+ int timediff;
+ int nsec;
+
+// fprintf(stderr, "lastwrite %d.%d\n",
+// (int)lastwrite->tv_sec, (int)lastwrite->tv_usec);
+ gettimeofday(curwrite, NULL);
+// fprintf(stderr, "curwrite %d.%d\n",
+// (int)curwrite->tv_sec, (int)curwrite->tv_usec);+ timediff = curwrite->tv_usec - lastwrite->tv_usec + ((curwrite->tv_sec -
lastwrite->tv_sec)*1000000);
+// fprintf(stderr, "timediff %d\n", timediff);
+
+ *lastwrite = *curwrite;
+
+ if (timediff
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
2/6
+ }
+
+ return (intervl - timediff)/divide;
+
+ return 0;
+}
++int wait_nextclip(int *lastclip, int *absolute_seq)
+{
+ int k;
+ FILE *srcfp;
+ FILE *dstfp;
+ char buf[1024];
+ int size = 0;
+ int mediaseq;
+
+ //fprintf(stderr, "lastclip = %d \n", *lastclip);
+ for (k = 1; k
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
3/6
+ "amba_hls-%d.ts\n", (*absolute_seq-k>0) ? (*absolute_seq-k):
(*absolute_seq-k+16));
+ }*/
+ fwrite(buf, 1, size, dstfp);
+ fclose(dstfp);
+
+ fprintf(stderr, " %d \n", *absolute_seq);+
+ /*if (*absolute_seq == *lastclip) {
+ fprintf( stderr, "freeze at clip %d\n", *absolute_seq);
+ }*/
+
+ *lastclip = *absolute_seq;
+
+ return 0;
+}
ret_t
cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_http_t
*error_code)@@ -908,6 +1007,13 @@
char chr_header_end;
char *begin = buffer->buf;
char *end = NULL;
+ char *tokp;
+ int k, deferus, absolute_seq = 0;
+ static int lastclip = 0, ios4_hack = 0;
+ static struct timeval lastwrite;
+ struct timeval curwrite;
+ struct timeval curtime;
+ char getpath[32];
/* Set default error code. */
@@ -959,6 +1065,59 @@
*/
switch (hdr->type) {
case header_type_request:
+ if (!jpglink)
+ goto nojpglink;
+ if (0 == strncmp("/mjpeg/amba.jpg", buffer->buf + strlen("GET "),
strlen("/mjpeg/amba.jpg"))) {
+ *(strstr(buffer->buf, "mba.jpg")) = 'a';
+ k = readlink("/tmp/mjpeg/amba.jpg", getpath, sizeof(getpath));
+ if (-1 != k) {
+ getpath[k] = '\0';+ fprintf(stderr, "%s \n", getpath );
+ unlink("/tmp/mjpeg/aaba.jpg");
+ symlink(getpath, "/tmp/mjpeg/aaba.jpg");
+ }
+ }
+nojpglink:
+ if (!mp4link)
+ goto nomp4link;
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
4/6
+ if (0 == strncmp(mp4link, buffer->buf + strlen("GET "), strlen(mp4link)))
{
+ wait_nextclip(&lastclip, &absolute_seq);
+ }
+nomp4link:
+ if (!m3u8link)
+ goto nosmoothout;+ snprintf(getpath, sizeof(getpath) - 1, "%s", buffer->buf + strlen("GET
"));
+ if (NULL != (tokp = strchr(getpath, ' ')))
+ *tokp='\0';
+ fprintf(stderr, "%s\n", getpath);
+ if ( (ios4vf) && (0 == strncmp("/live/amba_hls-", getpath, strlen("/live/
amba_hls-"))) &&
+ (strstr(getpath, ".ts")) ) {
+ deferus = get_defer(&lastwrite, &curwrite, 500*1000, 10);
+ if (ios4_hack > 0) {
+ fprintf(stderr, "ios4_hack %d\n", ios4_hack);
+ if (deferus > 0) {
+ fprintf(stderr, "sleep %d ms\n\n", deferus/100);+ for (k = 1; k buf, "mba.m3u8")) = 'a';
+ if(ios4vf) {
+ gettimeofday(&curtime, NULL);
+ k = curtime.tv_sec - lastwrite.tv_sec;+ if (k > 2) {
+ if (ios4_hack
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
5/6
-
+extern char *mp4link;
+extern char *jpglink;
+extern char *m3u8link;
+extern int ios4vf;
static cherokee_server_t *srv = NULL;
static char *config_file = NULL;static char *document_root = NULL;
@@ -262,6 +265,10 @@
{
printf (APP_NAME "\n"
"Usage: cherokee [options]\n\n"
+ " -j, --jpglink Enable jpg link support\n"
+ " -s, --smooth-out Enable http get smooth-out\n"
+ " -m, --mp4link Enable mp4 link support\n"
+ " -o, --ios4vf Enable ios4 vf support\n"
" -h, --help Print this help\n"
" -V, --version Print version and exit\n"
" -t, --test Just test configuration file\n"
@@ -291,13 +298,17 @@ {"test", no_argument, NULL, 't'},
{"print-server-info", no_argument, NULL, 'i'},
{"admin_child", no_argument, NULL, 'a'},
+ {"jpglink", no_argument, NULL, 'j'},
+ {"mp4link", no_argument, NULL, 'm'},
+ {"ios4vf", no_argument, NULL, 'o'},
+ {"smooth-out", no_argument, NULL, 's'},
{"port", required_argument, NULL, 'p'},
{"documentroot", required_argument, NULL, 'r'},
{"config", required_argument, NULL, 'C'},
{NULL, 0, NULL, 0}
};
- while ((c = getopt_long(argc, argv, "hVdtiap:r:C:", long_options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "hVdtiap:r:C:msoj", long_options, NULL)) !=
-1) {
switch(c) {
case 'C':
free (config_file);
@@ -326,6 +337,18 @@
case 'V':
printf (APP_NAME " " PACKAGE_VERSION "\n" APP_COPY_NOTICE);
return ret_eof;
+ case 'j':
+ jpglink = strdup("/mjpeg/amba.jpg");
+ break;+ case 'm':
+ mp4link = strdup("/live/amba.mp4");
+ break;
+ case 's':
+ m3u8link = strdup("/live/amba.m3u8");
+ break;
+ case 'o':
+ ios4vf = 1;
-
7/23/2019 cherokee-1.2.101-001-patch.pdf
6/6
+ break;
case 'h':
case '?':
default: