Changeset 21072


Ignore:
Timestamp:
04/16/13 22:37:05 (11 years ago)
Author:
nit
Message:

[titan] update linked channel

Location:
titan/titan
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/eit.h

    r19319 r21072  
    776776        }
    777777        m_unlock(&status.epgmutex, 4);
     778
     779        deloldlinkedchannel();
    778780}
    779781
     
    953955                        transponderid = transponderid | ((uint64_t)2 << 32);
    954956
    955                 if(getlinkedchannel(chnode, serviceid, transponderid) == NULL)
    956                         addlinkedchannel(chnode, serviceid, transponderid, NULL);
     957                if(getlinkedchannel(chnode, serviceid, transponderid, epgnode->starttime, epgnode->endtime) == NULL)
     958                        addlinkedchannel(chnode, serviceid, transponderid, epgnode->starttime, epgnode->endtime, NULL);
    957959        }
    958960}
  • titan/titan/header.h

    r20952 r21072  
    807807
    808808//linkedchannel.h
    809 struct linkedchannel* addlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, struct linkedchannel* last);
     809struct linkedchannel* addlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, time_t starttime, time_t endtime, struct linkedchannel* last);
    810810void freelinkedchannel(struct channel* chnode);
    811811void screenlinkedchannel();
    812 struct linkedchannel* getlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid);
     812struct linkedchannel* getlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, time_t starttime, time_t endtime);
     813void dellinkedchannel(struct channel* chnode, struct linkedchannel* lnode, int flag);
     814void deloldlinkedchannel();
    813815
    814816//zap.h
  • titan/titan/linkedchannel.h

    r18431 r21072  
    22#define LINKEDCHANNEL_H
    33
    4 struct linkedchannel* getlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid)
     4struct linkedchannel* getlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, time_t starttime, time_t endtime)
    55{
    66        if(chnode == NULL) return NULL;
     
    1111        while(node != NULL)
    1212        {
    13                 if(node->serviceid == serviceid && node->transponderid == transponderid)
     13                if(node->serviceid == serviceid && node->transponderid == transponderid && node->starttime == starttime && node->endtime == endtime)
    1414                {
    1515                        m_unlock(&status.linkedchannelmutex, 14);
     
    4242void screenlinkedchannel()
    4343{
    44         int rcret = 0, treffer = 0;
     44        int rcret = 0, treffer = 0, akttime = 0;
    4545        struct skin* linkedchannel = getscreen("linkedchannel");
    4646        struct skin* listbox = getscreennode(linkedchannel, "listbox");
     
    5959        addscreenrc(linkedchannel, listbox);
    6060start:
     61        akttime = time(NULL);
    6162        tmp = NULL;
    6263        chnode = channel;
     
    6465        if(status.aktservice->channel != NULL)
    6566        {
    66     m_lock(&status.linkedchannelmutex, 14);
    67                 if(status.aktservice->channel->linkedchannel == NULL)
    68                 {
    69                         while(chnode != NULL)
     67                m_lock(&status.linkedchannelmutex, 14);
     68                while(chnode != NULL)
     69                {
     70                        node = chnode->linkedchannel;
     71                        while(node != NULL)
    7072                        {
    71                                 node = chnode->linkedchannel;
    72                                 while(node != NULL)
     73                                if(node->serviceid == status.aktservice->channel->serviceid && node->transponderid == status.aktservice->channel->transponderid && akttime >= node->starttime && akttime < node->endtime)
    7374                                {
    74                                         if(node->serviceid == status.aktservice->channel->serviceid && node->transponderid == status.aktservice->channel->transponderid)
    75                                         {
    76                                                 node = chnode->linkedchannel;
    77                                                 break;
    78                                         }
    79                                         node = node->next;
     75                                        node = chnode->linkedchannel;
     76                                        break;
    8077                                }
    81                                 if(node != NULL) break;
    82                                 chnode = chnode->next;
     78                                node = node->next;
    8379                        }
     80                        if(node != NULL) break;
     81                        chnode = chnode->next;
    8482                }
    8583
     
    8886                while(node != NULL)
    8987                {
    90                         chnode = getchannel(node->serviceid, node->transponderid);
    91                         if(chnode != NULL)
     88                        if(akttime >= node->starttime && akttime < node->endtime)
    9289                        {
    93                                 epgnode = getepgakt(chnode);
    94                                 //don't show linked channel with start/end 1day
    95                                 if(epgnode != NULL && epgnode->endtime - epgnode->starttime >= 86400)
     90                                chnode = getchannel(node->serviceid, node->transponderid);
     91                                if(chnode != NULL)
    9692                                {
    97                                         node = node->next;
    98                                         continue;
    99                                 }
    100                                 tmp = addlistbox(linkedchannel, listbox, tmp, 1);
    101                                 if(tmp != NULL)
    102                                 {
    103                                         if(chnode == status.aktservice->channel)
    104                                                 treffer = 1;
    105                                         if(treffer == 0)
    106                                                 listbox->aktline++;
    107                                         tmpstr = ostrcat(tmpstr, chnode->name, 1, 0);
    108                                         if(epgnode != NULL)
     93                                        epgnode = getepgakt(chnode);
     94                                        //don't show linked channel with start/end 1day
     95                                        if(epgnode != NULL && epgnode->endtime - epgnode->starttime >= 86400)
    10996                                        {
    110                                                 tmpstr = ostrcat(tmpstr, " - ", 1, 0);
    111                                                 if(buf != NULL)
     97                                                node = node->next;
     98                                                continue;
     99                                        }
     100                                        tmp = addlistbox(linkedchannel, listbox, tmp, 1);
     101                                        if(tmp != NULL)
     102                                        {
     103                                                if(chnode == status.aktservice->channel)
     104                                                        treffer = 1;
     105                                                if(treffer == 0)
     106                                                        listbox->aktline++;
     107                                                tmpstr = ostrcat(tmpstr, chnode->name, 1, 0);
     108                                                if(epgnode != NULL)
    112109                                                {
    113                                                         loctime = olocaltime(&epgnode->starttime);
    114                                                         ostrftime(buf, MINMALLOC, "%H:%M ", loctime);
    115                                                         free(loctime); loctime = NULL;
    116                                                         tmpstr = ostrcat(tmpstr, buf, 1, 0);
     110                                                        tmpstr = ostrcat(tmpstr, " - ", 1, 0);
     111                                                        if(buf != NULL)
     112                                                        {
     113                                                                loctime = olocaltime(&epgnode->starttime);
     114                                                                ostrftime(buf, MINMALLOC, "%H:%M ", loctime);
     115                                                                free(loctime); loctime = NULL;
     116                                                                tmpstr = ostrcat(tmpstr, buf, 1, 0);
     117                                                        }
     118                                                        tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
    117119                                                }
    118                                                 tmpstr = ostrcat(tmpstr, epgnode->title, 1, 0);
     120                                                changetext(tmp, tmpstr);
     121                                                free(tmpstr); tmpstr = NULL;
     122                                                tmp->handle = (char*)chnode;
    119123                                        }
    120                                         changetext(tmp, tmpstr);
    121                                         free(tmpstr); tmpstr = NULL;
    122                                         tmp->handle = (char*)chnode;
    123124                                }
    124125                        }
     
    128129        }
    129130
    130         if(treffer == 0) listbox->aktline = 1;
     131        if(treffer == 0)
     132        {
     133                listbox->aktline = 1;
     134                treffer = 1;
     135        }
    131136
    132137        drawscreen(linkedchannel, 0, 0);
     
    153158}
    154159
    155 struct linkedchannel* addlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, struct linkedchannel* last)
     160struct linkedchannel* addlinkedchannel(struct channel* chnode, int serviceid, uint64_t transponderid, time_t starttime, time_t endtime, struct linkedchannel* last)
    156161{
    157162        debug(1000, "in");
     
    173178        newnode->serviceid = serviceid;
    174179        newnode->transponderid = transponderid;
     180        newnode->starttime = starttime;
     181        newnode->endtime = endtime;
    175182
    176183        m_lock(&status.linkedchannelmutex, 14);
     
    202209}
    203210
     211//flag 0: lock
     212//flag 1: nolock
     213void dellinkedchannel(struct channel* chnode, struct linkedchannel* lnode, int flag)
     214{
     215        if(chnode == NULL)
     216        {
     217                debug(1000, "out-> NULL detect");
     218                return;
     219        }
     220
     221        if(flag == 0) m_lock(&status.linkedchannelmutex, 14);
     222
     223        struct linkedchannel *node = chnode->linkedchannel, *prev = chnode->linkedchannel;
     224
     225        while(node != NULL)
     226        {
     227                if(node == lnode)
     228                {
     229                        if(node == chnode->linkedchannel)
     230                                chnode->linkedchannel = node->next;
     231                        else
     232                                prev->next = node->next;
     233
     234                        free(node);
     235                        node = NULL;
     236                        break;
     237                }
     238
     239                prev = node;
     240                node = node->next;
     241        }
     242        if(flag == 0) m_unlock(&status.linkedchannelmutex, 14);
     243}
     244
    204245void freelinkedchannel(struct channel* chnode)
    205246{
     
    225266                free(prev);
    226267                prev = NULL;
    227 
    228268        }
    229269        m_unlock(&status.linkedchannelmutex, 14);
     
    231271}
    232272
     273void deloldlinkedchannel()
     274{
     275        struct channel* chnode = channel;
     276        struct linkedchannel* node = NULL;
     277
     278        m_lock(&status.linkedchannelmutex, 14);
     279        while(chnode != NULL)
     280        {
     281                if(chnode->linkedchannel != NULL)
     282                {
     283                        node = channel->linkedchannel;
     284                        while(node != NULL)
     285                        {
     286                                if(node->endtime + 60 < time(NULL))
     287                                        dellinkedchannel(chnode, node, 1);
     288                                node = node->next;
     289                        }
     290                }
     291                chnode = chnode->next;
     292        }
     293        m_unlock(&status.linkedchannelmutex, 14);
     294}
     295
    233296#endif
  • titan/titan/service.h

    r20871 r21072  
    3030        freeaudiotrack(chnode);
    3131        freesubtitle(chnode);
    32         freelinkedchannel(chnode);
    3332        freepmt(chnode);
    3433        freecadesc(chnode);
  • titan/titan/struct.h

    r20981 r21072  
    10331033        uint64_t transponderid;
    10341034        int serviceid;
     1035        time_t starttime;
     1036        time_t endtime;
    10351037        struct linkedchannel* next;
    10361038};
Note: See TracChangeset for help on using the changeset viewer.