Ejemplo n.º 1
0
/*****************************************************************************
 * main
 *****************************************************************************/
int main(int i_argc, char* pa_argv[])
{
  int i_fd;
  uint8_t data[188];
  dvbpsi_handle h_dvbpsi;
  int b_ok;

  if(i_argc != 2)
    return 1;

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

  h_dvbpsi = dvbpsi_AttachPAT(DumpPAT, NULL);

  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_PushPacket(h_dvbpsi, data);
    b_ok = ReadPacket(i_fd, data);
  }

  dvbpsi_DetachPAT(h_dvbpsi);

  return 0;
}
Ejemplo n.º 2
0
/*****************************************************************************
 * Entry point
 *****************************************************************************/
int main( int i_argc, char **pp_argv )
{
    uint8_t *p_buffer;

    if ( i_argc < 2 || i_argc > 3 || !strcmp( pp_argv[1], "-" ) )
    {
        fprintf( stderr, "Usage: get_pcr_pid <input ts> [<program number>]\n" );
        exit(EXIT_FAILURE);
    }

    if ( (i_fd = open( pp_argv[1], O_RDONLY )) == -1 )
    {
        fprintf( stderr, "open(%s) failed (%s)\n", pp_argv[1],
                 strerror(errno) );
        exit(EXIT_FAILURE);
    }

    if ( i_argc == 3 )
        i_program = strtol( pp_argv[2], NULL, 0 );

    p_pat_dvbpsi_fd = dvbpsi_AttachPAT( PATCallback, NULL );
    if ( p_pat_dvbpsi_fd == NULL )
        goto out;

    p_buffer = malloc( TS_SIZE * READ_ONCE );
    if ( p_buffer == NULL )
        goto out;

    for ( ; ; )
    {
        int i;
        ssize_t i_ret;

        if ( (i_ret = read( i_fd, p_buffer, TS_SIZE * READ_ONCE )) < 0 )
        {
            fprintf( stderr, "read error (%s)\n", strerror(errno) );
            break;
        }
        if ( i_ret == 0 )
        {
            fprintf( stderr, "end of file reached\n" );
            break;
        }

        for ( i = 0; i < i_ret / TS_SIZE; i++ )
        {
            TSHandle( p_buffer + TS_SIZE * i );
            i_ts_read++;
        }
    }
    free( p_buffer );

out:
    if ( p_pat_dvbpsi_fd ) dvbpsi_DetachPAT( p_pat_dvbpsi_fd );
    close( i_fd );
    fprintf( stderr, "no PAT/PMT found\n" );

    return EXIT_FAILURE;
}
Ejemplo n.º 3
0
int main (int argc, char **argv)
{
	workerthread hworker = workerthread_new(10);

	conn* tsconn = join(TEST_LIVE_STREAM_ADDR, TEST_LIVE_STREAM_PORT);
	tsconn->hdvbpsi = dvbpsi_AttachPAT(receive_pat, tsconn);
	workerthread_put_task(hworker, (void(*)(void*))receive_avstream, tsconn, NULL);

	for(;;) {
		sleep(1);
	}
	dvbpsi_DetachPAT(tsconn->hdvbpsi);

	return 0;
}
Ejemplo n.º 4
0
void CDVDDemuxSMD::Start()
{
  if(m_bStarted)
    return;

  CLog::Log(LOGINFO, "CDVDDemuxSMD::Start");

  if(!m_pInput)
  {
    CLog::Log(LOGERROR, "CDVDDemuxSMD::Start m_pInput is NULL");
    return;
  }

  if (m_pInput->IsStreamType(DVDSTREAM_TYPE_TV))
  {
    int channelIndex;
    CDVDInputStream::IChannel* input = dynamic_cast<CDVDInputStream::IChannel*>(m_pInput);

    if (!input)
    {
      CLog::Log(LOGERROR, "CDVDDemuxSMD::Start input NULL");
      return;
    }

    channelIndex = input->GetProgramId();
    DvbChannelPtr channel = DVBManager::GetInstance().GetChannels().GetChannelByIndex(channelIndex);
    m_nProgramNumber = channel->GetServiceId();
    m_nVideoPID = channel->GetVideoPid();
    const std::vector<DvbAudioInfo>& audioInfo = channel->GetAudioPids();
    if(audioInfo.size() > 0)
      m_nAudioPID = audioInfo[0].pid;
    else
      CLog::Log(LOGWARNING, "CDVDDemuxSMD::Start no audio found in DVB stream");

    dvbpsiPAT = dvbpsi_AttachPAT(PATCallBack, this);
    dvbpsiPMT = NULL;
    m_pmtPid = 0;
  }

  AddPidFilter(PAT_PID);

  m_videoStats.Start();
  m_audioStats.Start();

  m_lastPatStopWatch.StartZero();

  m_bStarted = true;
}
Ejemplo n.º 5
0
bool scan_session_Push( scan_session_t *p_scan, block_t *p_block )
{
    if( p_block->i_buffer < 188 || p_block->p_buffer[0] != 0x47 )
    {
        block_Release( p_block );
        return false;
    }

    /* */
    const int i_pid = ( (p_block->p_buffer[1]&0x1f)<<8) | p_block->p_buffer[2];
    if( i_pid == 0x00 )
    {
        if( !p_scan->pat )
            p_scan->pat = dvbpsi_AttachPAT( (dvbpsi_pat_callback)PATCallBack, p_scan );

        if( p_scan->pat )
            dvbpsi_PushPacket( p_scan->pat, p_block->p_buffer );
    }
    else if( i_pid == 0x11 )
    {
        if( !p_scan->sdt )
            p_scan->sdt = dvbpsi_AttachDemux( (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan );

        if( p_scan->sdt )
            dvbpsi_PushPacket( p_scan->sdt, p_block->p_buffer );
    }
    else if( i_pid == p_scan->i_nit_pid )
    {
#ifdef DVBPSI_USE_NIT
        if( !p_scan->nit )
            p_scan->nit = dvbpsi_AttachDemux( (dvbpsi_demux_new_cb_t)PSINewTableCallBack, p_scan );

        if( p_scan->nit )
            dvbpsi_PushPacket( p_scan->nit, p_block->p_buffer );
#endif
    }

    block_Release( p_block );

    return p_scan->p_pat && p_scan->p_sdt && 
#ifdef DVBPSI_USE_NIT
        p_scan->p_nit;
#else
        true;
#endif
}
Ejemplo n.º 6
0
DvbPatLoader::DvbPatLoader()
{
  m_dvbpsi = dvbpsi_AttachPAT(PATCallBack, this);
  m_fd = -1;
}