pike.git / src / modules / DVB / dvb.c

version» Context lines:

pike.git/src/modules/DVB/dvb.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: dvb.c,v 1.14 2002/11/08 12:06:19 hop Exp $ + || $Id: dvb.c,v 1.15 2002/11/09 14:07:55 grubba Exp $   */      /*    * DVB module    *    * Creator: Honza Petrous <hop@unibase.cz>    *    * Credits:    * + Tuner zapping code inspired on 'szap' app from linux DVB driver    * package
pike.git/src/modules/DVB/dvb.c:192:    return st;      }      char *mk_devname(int devno, char *basename) {       char *devname;       if((devname = malloc(sizeof(basename)+4)) == NULL)    return NULL; -  sprintf(devname, "%s%d", basename, devno); //FIXME: uncorrect for v2.0+ !! +  sprintf(devname, "%s%d", basename, devno); /* FIXME: uncorrect for v2.0+ !! */    return devname;   }         /*! @module DVB    *!    *! Implements Digital Video Broadcasting interface    *!    *! @note    *! Only Linux version is supported.
pike.git/src/modules/DVB/dvb.c:243:    if(Pike_sp[-1].type != T_INT)    Pike_error("Invalid argument 1, expected int.\n");    else    DVB->cardn = (u_short)Pike_sp[-1].u.integer;       if((devname = mk_devname(DVB->cardn, FRONTENDDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    fefd = open (devname, O_RDWR | O_NONBLOCK);    if (fefd < 0) {    DVB->cardn = -1; -  //free(devname); +  /* free(devname); */    Pike_error("Opening frontend '%s' failed.\n", devname);    }    DVB->fefd = fefd;       /* Make sure this fd gets closed on exec. */    set_close_on_exec(fefd, 1);      } /* create */      /* LNB hi/lo band switch frequency in kHz */
pike.git/src/modules/DVB/dvb.c:499:    Pike_sp--;       freq = (u_short)Pike_sp[-1].u.integer * 1000;    Pike_sp--;       satno = (u_short)Pike_sp[-1].u.integer;       if((devname = mk_devname(DVB->cardn, SECDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    secfd = open (devname, O_RDWR); -  //free(devname); +  /* free(devname); */    if (secfd == -1) {    Pike_error ("opening SEC device failed\n");    }    THREADS_ALLOW();    result = ioctl (DVB->fefd, FE_GET_INFO, &fe_info);    THREADS_DISALLOW();    if (result == -1 || fe_info.type != FE_QPSK) {    close (secfd);    Pike_error("ioctl on fefd failed\n");    }
pike.git/src/modules/DVB/dvb.c:549:       dvb_pid_t pids[7];    int cnt = 0, dmx, ret;    char *devname;       pop_n_elems(args);    if(!sl_count(DVB)) {    if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    dmx = open (devname, O_RDWR | O_NONBLOCK); -  //free(devname); +  /* free(devname); */    if (dmx < 0)    Pike_error("Opening demux failed.\n");    } else -  // FIXME: for which PMT ? +  /* FIXME: for which PMT ? */    dmx = DVB->stream->fd;    /* get the current PID settings */    THREADS_ALLOW();    ret = ioctl(dmx, DMX_GET_PES_PIDS, &pids);    THREADS_DISALLOW();    if (ret) {    Pike_error("GET PIDS failed.\n");    }       if(DVB->cardn != -1) {
pike.git/src/modules/DVB/dvb.c:730:    n = read(fd,buffer+1,length-1);    THREAD_DISALLOW();    if (n < 0)    {    perror("read error");    return -1;    }       if (cks && crc32(buffer+1,n) != 0)    { -  fprintf(stderr,"crc error\n"); //FIXME: ??? +  fprintf(stderr,"crc error\n"); /* FIXME: ??? */    continue;    }       break;    }       return n+1;   }      /*! @decl mapping analyze_pat()
pike.git/src/modules/DVB/dvb.c:762:    int fd;    int p, cnt = 0;    int pid = -1;    int dmx;    char *devname;       pop_n_elems(args);    if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    dmx = open (devname, O_RDWR | O_NONBLOCK); -  //free(devname); +  /* free(devname); */    if (dmx < 0) {    snprintf (DVB->low_errmsg, MAX_ERR_LEN, "DMX SET SECTION FILTER.\n");    push_int(0);    return;    }       /* The PAT is supposed to fit in a 184 bytes packet */    SetFilt(dmx,0,0);    do    {
pike.git/src/modules/DVB/dvb.c:876:    case IRDETO_CA_SYSTEM:    case BETA_CA_SYSTEM:    e = malloc(sizeof(struct ECMINFO));    if (e == NULL)    return;    e->system = ca_system;    e->name = irdeto_name;    e->ecm_pid = ((data[2] & 0x1f) << 8) | data[3];    e->next = st->ecminfo;    st->ecminfo = e; - // printf("Found irdeto\n"); + /* printf("Found irdeto\n"); */    break;    case NAGRA_CA_SYSTEM:    e = malloc(sizeof(struct ECMINFO));    if (e == NULL)    return;    e->system = ca_system;    e->name = nagra_name;    e->ecm_pid = ((data[2] & 0x1f) << 8) | data[3];    e->next = st->ecminfo;    st->ecminfo = e; - //fprintf(stderr,"Found nagra\n"); + /* fprintf(stderr,"Found nagra\n"); */    break;    }   #ifdef DVB_DEBUG    while(e != NULL)    printf("DEB: dvb: ecminfo: system=%s, ecm_pid=%d, id=%d\n", e->name,    e->ecm_pid, e->id);   #endif   }      /*! @decl array(mapping)|int analyze_pmt(int sid, int prognum)
pike.git/src/modules/DVB/dvb.c:926:    int dmx;    dvb_stream_data stream;    char *devname;    int cnt = 0, arr = 0;       check_all_args("DVB.dvb->analyze_pmt", args, BIT_INT, BIT_INT, 0);       if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    dmx = open (devname, O_RDWR | O_NONBLOCK); -  //free(devname); +  /* free(devname); */    if (dmx < 0) {    snprintf (DVB->low_errmsg, MAX_ERR_LEN, "DMX SET SECTION FILTER.\n");    push_int(0);    return;    }       pmt_pid = (u_short)Pike_sp[-1].u.integer;    Pike_sp--;       program_number = (u_short)Pike_sp[-1].u.integer;
pike.git/src/modules/DVB/dvb.c:966:    pnr = (buffer[4]<<8) + buffer[5];    if (pnr == program_number)    break;    }       StopFilt(dmx);    close(dmx);       if (pnr != program_number)    { - //fprintf(stderr, "Can't find PMT entry\n"); + /* fprintf(stderr, "Can't find PMT entry\n"); */    push_int(0);    return;    }       index = 11;    info_len = ((buffer[index] & 0x0F) << 8) + buffer[index+1];    index += 2;       while (info_len > 0)    {
pike.git/src/modules/DVB/dvb.c:1224:    Pike_sp--;       dvbprog = Pike_sp[-1].u.object;    Pike_sp--;    if( !dvbprog || !(dvbstor = (dvb_data *)get_storage( dvbprog, dvb_program )) )    Pike_error("This class cannot be instantiated directly\n");       if((devname = mk_devname(DVB->cardn, DEMUXDEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    fd = open (devname, O_RDWR /*| O_NONBLOCK*/); -  //free(devname); +  /* free(devname); */    if (fd < 0) {    Pike_error("Opening DEMUX failed.\n");    }    pesflt.pid = pid;    pesflt.input = DMX_IN_FRONTEND;    pesflt.output = DMX_OUT_TAP;    pesflt.pesType = ptype;    pesflt.flags = DMX_IMMEDIATE_START;   #ifdef DVB_DEBUG    printf("DEB: dvb: set_pes: PID=%d, type=%d\n", pid, ptype);
pike.git/src/modules/DVB/dvb.c:1255: Inside #if 0
   if(init_p2p(&DVBStream->p, 2048))    Pike_error("Internal error: repack size %d is out of range\n", 2048);   #endif    DVBStream->parent = dvbstor;    DVBStream->fd = fd;    DVBStream->pid = pid;    DVBStream->stype = ptype;    DVBStream->pkt.payload = pktdata;    DVBStream->pkt.payload_len = 0;    /*DVB->pesfcb[ix] = NULL;*/ -  //fcntl(DVBStream->fd, F_SETFL, O_NONBLOCK); +  /*fcntl(DVBStream->fd, F_SETFL, O_NONBLOCK);*/   #if 0    push_int(1);   #else    if(sl_add(dvbstor, DVBStream))    push_int(1);    else    push_int(0);   #endif      }
pike.git/src/modules/DVB/dvb.c:1323:    if(DVBStream->pkt.payload_len > 0)    memcpy(buf, DVBStream->pkt.payload, DVBStream->pkt.payload_len);    for(;;) {    e = 0;    THREADS_ALLOW();    ret = read(DVBStream->fd, buf + DVBStream->pkt.payload_len,    DVBStream->buflen - DVBStream->pkt.payload_len);    e = errno; /* check_threads_etc may effect errno */    THREADS_DISALLOW();    -  //check_threads_etc(); +  /* check_threads_etc(); */       if (ret > 0) {    ret += DVBStream->pkt.payload_len;    break;    }    if (ret == -1 && (e == EAGAIN || e == EINTR)) {    push_int(0);    return;    }   #if 0
pike.git/src/modules/DVB/dvb.c:1348: Inside #if 0
   push_int(-e);    return;    }   #endif    }       if(ret > 0) {    bufptr = buf;    while((cnt = dvb_pes2es(bufptr,ret,&DVBStream->pkt, 0xC0)) > 0) {   #ifdef DVB_DEBUG -  //printf("DEB: dvb: PID(%d): cnt=%d (ix: %d): pkt.len=%d (skipped: %d)\n", DVBStream->pid, cnt, ix, DVBStream->pkt.payload_len, DVBStream->pkt.skipped); +  /* printf("DEB: dvb: PID(%d): cnt=%d (ix: %d): pkt.len=%d (skipped: %d)\n", DVBStream->pid, cnt, ix, DVBStream->pkt.payload_len, DVBStream->pkt.skipped); */    if(DVBStream->pkt.skipped)    printf("PID(%d): skipped: %d\n", DVBStream->pid, DVBStream->pkt.skipped);   #endif    push_string(make_shared_binary_string((char *)DVBStream->pkt.payload,    DVBStream->pkt.payload_len));    DVBStream->pkt.payload_len = 0; /* clear internall buffer */    ix++;    bufptr += cnt;    ret -= cnt;    if(ret < 1)
pike.git/src/modules/DVB/dvb.c:1417:       if(args)    if(Pike_sp[-1].type != T_INT)    Pike_error("Invalid argument 1, expected int.\n");    else    devno = (u_short)Pike_sp[-1].u.integer;    pop_n_elems(args);    if((devname = mk_devname(devno, AUDIODEVICE)) == NULL)    Pike_error("Internal error: can't malloc buffer.\n");    DVBAudio->fd = open( devname, O_RDWR ); -  //free(devname); +  /* free(devname); */    if (DVBAudio->fd < 0) {    DVB->cardn = -1;    Pike_error("Opening audio device failed.\n");    }   }         /*! @decl int mute(int mute)    *! @decl int mute()    *!
pike.git/src/modules/DVB/dvb.c:1682:       /* dvb */    start_new_program();    ADD_STORAGE(dvb_data);    set_init_callback(init_dvb_data);    set_exit_callback(exit_dvb_data);       add_function("create", f_create, "function(int|void:void)", 0);    add_function("_sprintf", f__sprintf, "function(int,mapping|void:mixed)", 0);    add_function("tune", f_zap, "function(int,int,int|string,int,mapping|void:int)", 0); -  //add_function("set_pids", f_set_pids, "function(string,mixed:int)", 0); +  /* add_function("set_pids", f_set_pids, "function(string,mixed:int)", 0); */    add_function("get_pids", f_get_pids, "function(:mapping|int)", 0);    add_function("analyze_pat", f_parse_pat, "function(:mapping|int)", 0);    add_function("analyze_pmt", f_parse_pmt, "function(int,int:array|int)", 0);       /* Frontend */    add_function("fe_status", f_fe_status, "function(:mapping|int)", 0);    add_function("fe_info", f_fe_info, "function(:mapping|int)", 0);       add_function("stream", f_stream_attach, "function(int,function|int|void,int|void:object)", 0);