Changeset 19689


Ignore:
Timestamp:
01/20/13 06:30:19 (11 years ago)
Author:
obi
Message:

[titan] tithek add cache playback (10mb/180s)

Location:
titan
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/tithek/tithek.h

    r19659 r19689  
    970970}
    971971
     972void cacheplay(char* link)
     973{
     974        struct skin* load = getscreen("loadingproz");
     975        struct skin* proztext = getscreennode(load, "proztext");
     976
     977        drawscreen(load, 0, 0);
     978        int port = 80, count = 0;
     979        off64_t size = 0;
     980        char* host = NULL, *pos = NULL, *path = NULL, *file = NULL, *tmpstr = NULL;
     981        host = string_replace("http://", "", (char*)link, 0);
     982
     983        if(host != NULL)
     984                pos = strchr(host, '/');
     985        if(pos != NULL)
     986        {
     987                pos[0] = '\0';
     988                path = pos + 1;
     989        }
     990
     991        file = ostrcat("/media/hdd/.cache.tithek.stream.flv", NULL, 0, 0);
     992
     993        printf("host: %s\n",host);
     994        printf("port: %d\n",port);
     995        printf("path: %s\n",path);
     996                               
     997        if(ostrstr(host, ":") != NULL)
     998        {
     999                host = oregex("http://(.*):.*", link);
     1000                port = atoi(oregex("http://.*:(.*)/.*", link));
     1001        }
     1002
     1003        printf("host: %s\n",host);
     1004        printf("port: %d\n",port);
     1005        printf("path: %s\n",path);
     1006        printf("file: %s\n",file);
     1007       
     1008        struct download* dnode = NULL;
     1009        dnode = calloc(1, sizeof(struct download));
     1010        if(dnode == NULL)
     1011        {
     1012                err("no mem");
     1013                return;
     1014        }               
     1015        dnode->host = host;
     1016        dnode->page = path;
     1017        dnode->port = port;
     1018        dnode->filename = file;
     1019        dnode->auth = NULL;
     1020        dnode->connfd = -1;
     1021        dnode->ret = -1;
     1022       
     1023        addtimer(&gethttpstruct, START, 1000, 1, (void*)dnode, NULL, NULL);
     1024               
     1025        while(count < 120 || size >= 10000000)
     1026        {
     1027                sleep(1);
     1028                count++;
     1029                if(file_exist(file))
     1030                        size = getfilesize(file);
     1031
     1032                int proz = 0;
     1033                int proz1 = size * 100 / 10000000;
     1034                printf("size (%dprozent)\n", proz1);
     1035
     1036                int proz2 = count * 100 / 120;
     1037                printf("time (%dprozent)\n", proz2);
     1038               
     1039                if(proz1 > proz2)
     1040                        proz = proz1;
     1041                else
     1042                        proz = proz2;
     1043               
     1044                printf("cacheing...(%lldkb) (%dprozent)\n", size / 1024, proz);
     1045                if(size >= 10000000)
     1046                        break;
     1047                if(count >= 120)
     1048                        break;
     1049               
     1050                tmpstr = ostrcat(_("please wait..."), " (", 0, 0);
     1051                tmpstr = ostrcat(tmpstr, oitoa(proz), 0, 1);
     1052                tmpstr = ostrcat(tmpstr, "%)", 1, 0);
     1053                clearscreen(load);
     1054                changetext(proztext, tmpstr);
     1055                drawscreen(load, 0, 0);
     1056                free(tmpstr), tmpstr = NULL;
     1057        }
     1058
     1059        screenplay(file, 2, 0);
     1060        sockclose(&dnode->connfd);
     1061        free(dnode); dnode = NULL;
     1062
     1063        tmpstr = ostrcat(tmpstr, _("Remove Cachefile ?"), 1, 0);
     1064        tmpstr = ostrcat(tmpstr, "\n\n", 1, 0);
     1065        tmpstr = ostrcat(tmpstr, file, 1, 0);
     1066       
     1067        if(textbox(_("Message"), tmpstr, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
     1068        {
     1069                unlink(file);
     1070        }
     1071        free(tmpstr), tmpstr = NULL;
     1072        free(file), file = NULL;
     1073        free(host), host = NULL;
     1074}
     1075
    9721076void submenu(struct skin* listbox, struct skin* load)
    9731077{
     
    10511155                if(tmpstr1 != NULL)
    10521156                {
    1053                         if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
    1054                                 screenplay(tmpstr1, 2, 0);                             
     1157                        if(!ostrncmp("http://", tmpstr1, 7))
     1158                        {
     1159                                char* keyconf = NULL;
     1160                                char* skintitle = "Choice Playback";
     1161                                struct menulist* mlist = NULL, *mbox = NULL;
     1162                                addmenulist(&mlist, "Streaming Playback (default)", NULL, NULL, 0, 0);
     1163                                addmenulist(&mlist, "Caching Playback", NULL, NULL, 0, 0);
     1164                                mbox = menulistbox(mlist, NULL, skintitle, NULL, NULL, 1, 0);
     1165                                if(mbox != NULL) keyconf = mbox->name;
     1166                                if(ostrcmp(keyconf, "Streaming Playback (default)") == 0)
     1167                                {
     1168                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
     1169                                                screenplay(tmpstr1, 2, 0);
     1170                                }
     1171                                else if(ostrcmp(keyconf, "Caching Playback") == 0)
     1172                                {
     1173                                        if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
     1174                                                cacheplay(tmpstr1);
     1175                                }
     1176                        }
     1177                        else if(textbox(_("Message"), _("Start playback"), _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 600, 200, 0, 0) == 1)
     1178                                screenplay(tmpstr1, 2, 0);
    10551179                }
    10561180                else
  • titan/skins/tithek/skin.xml

    r19573 r19689  
    2828<node name="b3" text="Screensaver" picmem="skin/key_green_30x30.png"   textposx="40" valign="middle" fontcol="black" fontsize="25" posx="205" posy="670" width="300" height="30">
    2929</screen>
     30
     31<screen bgcol=-2 fontsize=50 fontcol=fontcol text="" name=loadingproz posx=0 posy=center halign=center width=100% height=70>
     32<node name="proztext" text="please wait..." fontcol=fontcol fontsize="50" posx="0" posy="0" width="840" height="50" valign="middle" halign="center">
     33</screen>
  • titan/titan/header.h

    r19681 r19689  
    175175char* gethttpreal(char* host, char* page, int port, char* filename, char* auth, struct download* dnode, int redirect, char* header, long* clen, int flag);
    176176int sockreceive(int *fd, unsigned char* data, int count, int timeout);
     177void gethttpstruct(struct stimerthread* timernode, struct download* node, int flag);
    177178
    178179//numinput.h
Note: See TracChangeset for help on using the changeset viewer.