Ejemplo n.º 1
0
static inline bool handle_Init( demux_t *p_demux, dvbpsi_t **handle )
{
    *handle = dvbpsi_new( &dvbpsi_messages, DVBPSI_MSG_DEBUG );
    if( !*handle )
        return false;
    (*handle)->p_sys = (void *) p_demux;
    return true;
}
Ejemplo n.º 2
0
/*****************************************************************************
 * main
 *****************************************************************************/
int main(int i_argc, char* pa_argv[])
{
    int i_fd;
    int ret = 1;
    uint8_t data[188];
    dvbpsi_t *p_dvbpsi;
    bool b_ok;

    if(i_argc != 2)
        return 1;

    i_fd = open(pa_argv[1], 0);
    if (i_fd < 0)
        return 1;

    p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG);
    if (p_dvbpsi == NULL)
        goto out;

    if (!dvbpsi_chain_demux_new(p_dvbpsi, NewSubtable, DelSubtable, NULL))
        goto out;

    b_ok = ReadPacket(i_fd, data);

    while(b_ok)
    {
        uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
        if(i_pid == 0x11)
            dvbpsi_packet_push(p_dvbpsi, data);
        b_ok = ReadPacket(i_fd, data);
    }

    ret = 0;

out:
    if (p_dvbpsi)
    {
        if (!dvbpsi_chain_demux_delete(p_dvbpsi))
            ret = 1;
        dvbpsi_delete(p_dvbpsi);
    }
    close(i_fd);
    return ret;
}
Ejemplo n.º 3
0
/*****************************************************************************
 * main
 *****************************************************************************/
int main(int argc, char *argv[])
{
	AStdData *fp = Stdin;
	AStdFile _fp;
	uint8_t  data[188];
	dvbpsi_t *p_dvbpsi;
	bool b_ok;

	(void)DumpDescriptors;

	if (argc > 1) {
		if (_fp.open(argv[1], "rb")) fp = &_fp;
		else {
			fprintf(stderr, "Failed to open file '%s' for reading\n", argv[1]);
			exit(1);
		}
	}

	p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_WARN);
	if (p_dvbpsi) {
		if (dvbpsi_AttachDemux(p_dvbpsi, newsubtable, NULL)) {
			b_ok = ReadPacket(*fp, data, sizeof(data));

			while (b_ok)
			{
				uint16_t pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
				if (pid == 0x12) dvbpsi_packet_push(p_dvbpsi, data);
				b_ok = ReadPacket(*fp, data, sizeof(data));
			}

			dvbpsi_DetachDemux(p_dvbpsi);
		}
		else fprintf(stderr, "Failed to attach demux to dvbpsi handler\n");

		dvbpsi_delete(p_dvbpsi);
	}
	else fprintf(stderr, "Failed to create new dvbpsi handler\n");

	_fp.close();

	return 0;
}
Ejemplo n.º 4
0
/*****************************************************************************
 * main
 *****************************************************************************/
int main(int i_argc, char* pa_argv[])
{
  int i_fd;
  uint8_t data[188];
  dvbpsi_t *p_dvbpsi;
  bool b_ok;

  if (i_argc != 2)
      return 1;

  i_fd = open(pa_argv[1], 0);
  if (i_fd < 0)
      return 1;

  p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG);
  if (p_dvbpsi == NULL)
      goto out;

  if (!dvbpsi_pat_attach(p_dvbpsi, DumpPAT, NULL))
      goto out;

  b_ok = ReadPacket(i_fd, data);

  while(b_ok)
  {
    uint16_t i_pid = ((uint16_t)(data[1] & 0x1f) << 8) + data[2];
    if(i_pid == 0x0)
      dvbpsi_packet_push(p_dvbpsi, data);
    b_ok = ReadPacket(i_fd, data);
  }

out:
  if (p_dvbpsi)
  {
    dvbpsi_pat_detach(p_dvbpsi);
    dvbpsi_delete(p_dvbpsi);
  }
  close(i_fd);

  return 0;
}
Ejemplo n.º 5
0
/*****************************************************************************
 * main
 *****************************************************************************/
int main(int i_argc, char* pa_argv[])
{
  uint8_t packet[188];
  dvbpsi_pat_t pat;
  dvbpsi_psi_section_t* p_section1, * p_section2;
  dvbpsi_psi_section_t* p_section3, * p_section4;
  dvbpsi_psi_section_t* p_section5, * p_section6;
  int i;

  dvbpsi_t *p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG);
  if (p_dvbpsi == NULL)
      return 1;

  /* PAT generation */
  dvbpsi_pat_init(&pat, 1, 0, 0);
  dvbpsi_pat_program_add(&pat, 0, 0x12);
  dvbpsi_pat_program_add(&pat, 1, 0x42);
  dvbpsi_pat_program_add(&pat, 2, 0x21);
  dvbpsi_pat_program_add(&pat, 3, 0x24);
  for(i = 4; i < 43; i++)
    dvbpsi_pat_program_add(&pat, i, i);

  p_section1 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 4);
  pat.b_current_next = 1;
  p_section2 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 8);

  pat.i_version = 1;

  pat.b_current_next = 0;
  p_section3 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 16);
  pat.b_current_next = 1;
  p_section4 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 300);

  pat.i_version = 2;

  pat.b_current_next = 0;
  p_section5 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 16);
  pat.b_current_next = 1;
  p_section6 = dvbpsi_pat_sections_generate(p_dvbpsi, &pat, 16);

  /* TS packets generation */
  packet[0] = 0x47;
  packet[1] = packet[2] = 0x00;
  packet[3] = 0x00;

  writePSI(packet, p_section1);
  writePSI(packet, p_section2);
  writePSI(packet, p_section3);
  writePSI(packet, p_section4);
  writePSI(packet, p_section5);
  writePSI(packet, p_section6);

  dvbpsi_DeletePSISections(p_section1);
  dvbpsi_DeletePSISections(p_section2);
  dvbpsi_DeletePSISections(p_section3);
  dvbpsi_DeletePSISections(p_section4);
  dvbpsi_DeletePSISections(p_section5);
  dvbpsi_DeletePSISections(p_section6);

  dvbpsi_pat_empty(&pat);

  dvbpsi_delete(p_dvbpsi);
  return 0;
}