~ubuntu-branches/ubuntu/karmic/kaffeine/karmic

« back to all changes in this revision

Viewing changes to kaffeine/src/input/dvb/dvbsi.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2008-01-22 13:50:29 UTC
  • mfrom: (1.3.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080122135029-zc52zvfzp99m6brl
Tags: 0.8.6-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include <qdir.h>
26
26
 
27
 
#include <kmessagebox.h>
28
 
#include <klocale.h>
29
 
#include <kprocess.h>
30
27
#include <kapplication.h>
31
28
 
32
29
#include "dvbsi.h"
35
32
 
36
33
 
37
34
 
38
 
NitSection::NitSection( QPtrList<Transponder> *tp, bool *end, bool *ok, int anum, int tnum ) : DVBsection( ok, anum, tnum )
 
35
NitSection::NitSection( QPtrList<Transponder> *tp, bool *end, bool *ok, int anum, int tnum ) : KaffeineDVBsection( anum, tnum )
39
36
{
40
37
        ended = end;
41
38
        transponders = tp;
42
 
        pf[0].fd = fdDemux;
43
 
        pf[0].events = POLLIN;
44
39
        start();
45
40
}
46
41
 
55
50
 
56
51
void NitSection::stop()
57
52
{
58
 
        if ( !wait(1000) ) {
 
53
        if ( !wait(10000) ) {
59
54
                terminate();
60
55
                wait();
61
56
        }
337
332
 
338
333
 
339
334
 
340
 
DVBsi::DVBsi( bool *ok, int anum, int tnum, DvbStream *d, const QString &charset ) : DVBsection( ok, anum, tnum, charset )
 
335
DVBsi::DVBsi( bool *ok, int anum, int tnum, DvbStream *d, const QString &charset ) : KaffeineDVBsection( anum, tnum, charset )
341
336
{
342
337
        channels.setAutoDelete( true );
343
338
        transponders.setAutoDelete( true );
346
341
        adapter = anum;
347
342
        tuner = tnum;
348
343
        ns = 0;
349
 
        pf[0].fd = fdDemux;
350
 
        pf[0].events = POLLIN;
351
344
}
352
345
 
353
346
 
384
377
        ChannelDesc *desc;
385
378
        QString s;
386
379
        unsigned short tsid;
 
380
        unsigned short nid;
387
381
 
388
 
        tsid = getBits(buf,24,16);
 
382
        tsid = getBits(buf+3,0,16);
 
383
        nid = getBits(buf+8,0,16);
389
384
        length = getBits(buf,12,12);
390
385
        length -=8;
391
386
        buf +=11;
394
389
                desc = new ChannelDesc();
395
390
                channels.append( desc );
396
391
                desc->tp.tsid = tsid;
 
392
                desc->tp.nid = nid;
397
393
                desc->sid = getBits(buf,0,16);
398
394
                //desc->fta = getBits(buf,27,1 );
399
395
                loop = getBits(buf,28,12);
422
418
        int type;
423
419
        int sid;
424
420
        int i;
425
 
        int nlang=0;
426
421
        int pid=0;
427
422
        ChannelDesc *desc=0;
428
423
        QString lang;
429
424
        int ns;
430
425
        unsigned char st;
 
426
        bool audio, ac3;
 
427
 
431
428
 
432
429
        sid = getBits(buf+3,0,16);
433
430
        for ( i=indexChannels; i<(int)channels.count(); i++ ) {
458
455
        }
459
456
 
460
457
        while ( length>4 ) {
 
458
                audio=ac3=false;
461
459
                type = getBits(buf,0,8);
462
460
                pid = getBits(buf,11,13);
463
461
                if ( type==1/*mpeg1*/ || type==2/*mpeg2*/ || type==16/*mpeg4*/ || type==27/*h264*/ ) {
466
464
                        desc->vType = type;
467
465
                }
468
466
                if ( type==3 || type==4 ) {
469
 
                        if ( !desc->vpid )
470
 
                                desc->type=2;
471
 
                        nlang++;
472
 
                        if ( desc->napid<desc->maxapid ) {
473
 
                                desc->apid[(int)desc->napid].pid = pid;
474
 
                                desc->napid++;
475
 
                        }
 
467
                        audio = true;
476
468
                }
477
469
                loop = getBits(buf,28,12);
478
470
                buf +=5;
484
476
                                        break;
485
477
                                case 0x0A :
486
478
                                        lang = langDesc( buf );
487
 
                                        if ( (type==3 || type==4) && nlang<=desc->maxapid ) {
488
 
                                                desc->apid[desc->napid-1].lang = lang;
489
 
                                        }
490
479
                                        break;
491
480
                                case 0x56 :
492
481
                                        if ( type==6 )
510
499
                                        }
511
500
                                        break;
512
501
                                case 0x6a :
513
 
                                        if ( type==6 && desc->napid<desc->maxapid ) {
514
 
                                                desc->apid[(int)desc->napid].pid = pid;
515
 
                                                desc->apid[(int)desc->napid].ac3 = 1;
516
 
                                                desc->napid++;
517
 
                                                nlang++;
518
 
                                        }
 
502
                                        audio = true;
 
503
                                        ac3 = true;
519
504
                                        break;
520
505
                                default :
521
506
                                        break;
523
508
                        loop -=( getBits(buf,8,8)+2 );
524
509
                        buf +=( getBits(buf,8,8)+2 );
525
510
                }
 
511
                if ( audio && desc->napid<desc->maxapid ) {
 
512
                        if ( !desc->vpid )
 
513
                                desc->type=2;
 
514
                        desc->apid[(int)desc->napid].pid = pid;
 
515
                        if ( ac3 )
 
516
                                desc->apid[(int)desc->napid].ac3 = 1;
 
517
                        if ( !lang.isEmpty() )
 
518
                                desc->apid[(int)desc->napid].lang = lang;
 
519
                        desc->napid++;
 
520
                }
526
521
        }
527
522
 
528
523
        return true;
532
527
 
533
528
bool DVBsi::tablePAT( unsigned char *buf )
534
529
{
535
 
        int length, i;
536
 
        int sid;
537
 
        int pmt;
 
530
        int length, i, sid, tsid, pmt;
 
531
        bool got;
 
532
        ChannelDesc *desc;
538
533
 
 
534
        tsid = getBits(buf+3,0,16);
539
535
        length = getBits(buf,12,12);
540
536
        length -=5;
541
537
        buf +=8;
545
541
                pmt = getBits(buf,19,13);
546
542
                buf +=4;
547
543
                length -=4;
 
544
                got = false;
548
545
                for ( i=indexChannels; i<(int)channels.count(); i++ ) {
549
546
                        if ( channels.at( i )->sid==sid ) {
550
547
                                channels.at( i )->pmtpid = pmt;
 
548
                                got = true;
551
549
                                break;
552
550
                        }
553
551
                }
 
552
                if ( !got  && sid!=0 ) {
 
553
                        desc = new ChannelDesc();
 
554
                        channels.append( desc );
 
555
                        desc->tp.tsid = tsid;
 
556
                        desc->sid = sid;
 
557
                        desc->pmtpid = pmt;
 
558
                        desc->name = QString("TSID:%1-SID:%2").arg(tsid).arg(sid);
 
559
                }
554
560
        }
555
561
 
556
562
        return true;
639
645
                return;
640
646
 
641
647
        isRunning = false;
642
 
        if ( !wait(2000) ) {
 
648
        if ( !wait(10000) ) {
643
649
                if ( ns ) {
644
650
                        ns->stop();
645
651
                        delete ns;
702
708
        int i, j=0, k=0;
703
709
        ChannelDesc chan;
704
710
        Transponder trans;
705
 
        unsigned short tsid;
 
711
        unsigned short tsid, nid;
706
712
        bool nitEnded=true, ok;
707
713
 
708
714
        progressTransponder = 0;
760
766
                                }
761
767
                                getSection( channels.at( j )->pmtpid, 0x02, 5000, channels.at( j )->sid );    //PMTs
762
768
                                tsid = channels.at(j)->tp.tsid;
 
769
                                nid = channels.at(j)->tp.nid;
763
770
                                channels.at(j)->tp = *transponders.at(i);
764
771
                                if ( channels.at(j)->tp.tsid==0 )
765
772
                                        channels.at(j)->tp.tsid = tsid;
 
773
                                channels.at(j)->tp.nid = nid;
766
774
                                channels.at(j)->tp.snr = dvb->getSNR();
767
775
                                channels.at(j)->completed = 1;
768
776
                        }
799
807
                        }
800
808
                        getSection( channels.at( j )->pmtpid, 0x02, 5000, channels.at( j )->sid );    //PMTs
801
809
                        tsid = channels.at(j)->tp.tsid;
 
810
                        nid = channels.at(j)->tp.nid;
802
811
                        channels.at(j)->tp = trans;
803
812
                        channels.at(j)->tp.tsid = tsid;
 
813
                        channels.at(j)->tp.nid = nid;
804
814
                        channels.at(j)->tp.snr = dvb->getSNR();
805
815
                        channels.at(j)->completed = 1;
806
816
                }