Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] ts problem



ok, so I have managed to tune properly, and have a ts coming out of
/dev/dvb/adapter0/dvr0, but there is something odd about it.

./streamtype /tmp/stream.ts
streamtype
TS_STREAM
SIZE: 279x4081
FRAMERATE: 23.976
DUNNO
MPEG0

or other random values...
streamtype
TS_STREAM
SIZE: 4095x4095
DUNNO
MPEG0

It doesnt seem to have any video data...

Am I configuring the mux incorrectly?

I cant build the docs from cvs - has anyone got a copy of the pdf from
the NEWSTRUCT api (I get a ghostscript error).

Program as below:

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>

#define FRONTEND "/dev/dvb/adapter0/frontend0"
#define DEMUX "/dev/dvb/adapter0/demux0"
#define DVR "/dev/dvb/adapter0/dvr0"

#define READSIZE (188 * 10)

static int freqs[] = {
  505833333, /* MUX 1 */
  481833333, /* MUX 2 */
  561833333, /* MUX A */
  529833333, /* MUX B */
  578166667, /* MUX C */
  537833333, /* MUX D */
};

int main(int argc, char ** argv) {
  struct dvb_frontend_info info;
  struct dvb_frontend_parameters frontend;
  struct dmx_pes_filter_params pesfilter;
  int fd, fdd, fdts;
  uint16_t strength, snr;
  uint32_t ber;
  fe_status_t status;
  int buffersize = 64 * 1024;
  char buffer[READSIZE];
  int pid = 0;
  int ret;

  int mux = 1;
  uint32_t frequency = freqs[mux];
  fe_spectral_inversion_t inversion = INVERSION_OFF;
  fe_bandwidth_t bandwidth = BANDWIDTH_8_MHZ;
  fe_code_rate_t coderateHP = (mux >= 3) ? FEC_3_4 : FEC_2_3;
  fe_code_rate_t coderateLP = FEC_NONE;
  fe_modulation_t modulation = (mux >= 3) ? QAM_16 : QAM_64;
  fe_transmit_mode_t transmission = TRANSMISSION_MODE_2K;
  fe_guard_interval_t guard = GUARD_INTERVAL_1_32;
  fe_hierarchy_t hierarchy = HIERARCHY_NONE;


  if ((fd = open (FRONTEND, O_RDWR)) < 0) {
    perror ("frontend open failed");
    return -1;
  }
  
  ioctl (fd, FE_GET_INFO, &info);

  fprintf(stderr, "card found: %s\n", info.name);

  if (info.type != FE_OFDM)
    fprintf(stderr, "warning: this program understands DVB-T best\n");

  frontend.frequency = frequency;
  frontend.inversion = inversion;
  frontend.u.ofdm.bandwidth = bandwidth;
  frontend.u.ofdm.code_rate_HP = coderateHP;
  frontend.u.ofdm.code_rate_LP = coderateLP;
  frontend.u.ofdm.constellation = modulation;
  frontend.u.ofdm.transmission_mode = transmission;
  frontend.u.ofdm.guard_interval = guard;
  frontend.u.ofdm.hierarchy_information = hierarchy;

  fprintf (stderr, "tuning to %i Hz\n", frontend.frequency);
  
  if (ioctl(fd, FE_SET_FRONTEND, &frontend) < 0) {
    perror("ioctl FE_SET_FRONTEND failed");
    close(fd);
    return -1;
  }

  usleep(1000000);

  ioctl(fd, FE_READ_SIGNAL_STRENGTH, &strength);
  ioctl(fd, FE_READ_SNR, &snr);
  ioctl(fd, FE_READ_BER, &ber);

  fprintf(stderr, "signal strength %d SNR %d error %d\n", strength, snr, ber);

  ioctl(fd, FE_READ_STATUS, &status);
  if (status & FE_HAS_LOCK)
    fprintf(stderr, "FE_HAS_LOCK\n");
  else
    fprintf(stderr, "no lock...\n");

  if ((fdd = open(DEMUX, O_RDWR)) < 0) {
   perror ("demux open failed");
   return -1;
  }

  if (ioctl(fdd, DMX_SET_BUFFER_SIZE, buffersize) == -1)
    perror("DMX_SET_BUFFER_SIZE failed");

  pesfilter.pid = pid; // ?
  pesfilter.input = DMX_IN_FRONTEND;
  pesfilter.output = DMX_OUT_TS_TAP;
  pesfilter.pes_type = DMX_PES_VIDEO;
  pesfilter.flags = DMX_IMMEDIATE_START;

  if (ioctl(fdd, DMX_SET_PES_FILTER, &pesfilter) == -1) {
    fprintf(stderr, "DMX_SET_PES_FILTER failed "
	    "(PID = 0x%04x): %d %m\n", pid, errno);
    return -1;
  }

  if ((fdts = open(DVR, O_RDONLY)) < 0) {
   perror ("dvr open failed");
   return -1;
  }

  while ((ret = read(fdts, buffer, READSIZE)) > 0) {
    write(STDOUT_FILENO, buffer, ret);
    if (ret != READSIZE)
      fprintf(stderr, "%d ", ret);
  }

  return 0;
}


-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index