Example #1
0
File: parse.cpp Project: gk1/teev
void parse::rewrite_pat()
{
	if (0 == service_ids.size())
		return;

#if !USING_DVBPSI_VERSION_0
	dvbpsi_class dvbpsi;
#else
#define dvbpsi_pat_init(a, b, c, d)     dvbpsi_InitPAT(a, b, c, d)
#define dvbpsi_pat_program_add(a, b, c) dvbpsi_PATAddProgram(a, b, c)
#define dvbpsi_pat_sections_generate(a, b, c) dvbpsi_GenPATSections(b, c)
#define dvbpsi_pat_empty(a) dvbpsi_EmptyPAT(a)
#endif
	dvbpsi_pat_t pat;
	dvbpsi_psi_section_t* p_section;
	const decoded_pat_t *decoded_pat = decoders[ts_id].get_decoded_pat();

	if (rewritten_pat_ver_offset == 0x1e)
		rewritten_pat_ver_offset = 0;

	dvbpsi_pat_init(&pat, ts_id, 0x1f & (++rewritten_pat_ver_offset + decoded_pat->version), 1);

	for (map_pidtype::const_iterator iter = service_ids.begin(); iter != service_ids.end(); ++iter)
		dvbpsi_pat_program_add(&pat, iter->first, ((decoded_pat_t *) decoded_pat)->programs[iter->first]);

	p_section = dvbpsi_pat_sections_generate(dvbpsi.get_handle(), &pat, 0);
	pat_pkt[0] = 0x47;
	pat_pkt[1] = pat_pkt[2] = pat_pkt[3] = 0x00;
	writePSI(pat_pkt, p_section);
	dvbpsi_DeletePSISections(p_section);
	dvbpsi_pat_empty(&pat);
}
Example #2
0
/*****************************************************************************
* dvbpsi_pat_new
*****************************************************************************
* Allocate and Initialize a newly allocated dvbpsi_pat_t structure.
*****************************************************************************/
dvbpsi_pat_t *dvbpsi_pat_new( uint16_t i_ts_id, uint8_t i_version,
			      bool b_current_next )
{
	dvbpsi_pat_t *p_pat = (dvbpsi_pat_t *) malloc( sizeof(dvbpsi_pat_t) );
	if ( p_pat )
		dvbpsi_pat_init( p_pat, i_ts_id, i_version, b_current_next );
	return(p_pat);
}
Example #3
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;
}