Exemplo n.º 1
0
Arquivo: 708.cpp Projeto: MrMdR/julapy
void do_708 (const unsigned char *data, int datalength)
{
    /* Note: The data has this format: 
        1 byte for cc_valid        
        1 byte for cc_type
        2 bytes for the actual data */
    if (!debug_708)
        return;
        
    for (int i=0;i<datalength;i+=4)
    {
        unsigned char cc_valid=data[i];
        unsigned char cc_type=data[i+1];    

        switch (cc_type)
        {
            case 2:
                // printf ("708: DTVCC Channel Packet Data\n");
                if (cc_valid==0) // This ends the previous packet
                    process_current_packet();
                else
                {
                    if (current_packet_length>253) 
                    {
                        printf ("Warning: Legal packet size exceeded, data not added.\n");
                    }
                    else
                    {
                        current_packet[current_packet_length++]=data[i+2];
                        current_packet[current_packet_length++]=data[i+3];
                    }
                }
                break;
            case 3:                
                // printf ("708: DTVCC Channel Packet Start\n");
                process_current_packet();
                if (cc_valid)
                {
                    if (current_packet_length>253) 
                    {
                        printf ("Warning: Legal packet size exceeded, data not added.\n");
                    }
                    else
                    {
                        current_packet[current_packet_length++]=data[i+2];
                        current_packet[current_packet_length++]=data[i+3];
                    }
                }
                break;
            default:                
                fatal (EXIT_BUG_BUG, "708: shouldn't be here - cc_type: %d\n", cc_type);
        }
    }        
}
Exemplo n.º 2
0
void decode_708 (const unsigned char *data, int datalength, cc708_service_decoder* decoders)
{
  /* Note: The data has this format:
        1 byte for cc_valid and cc_type
        2 bytes for the actual data */
  for (int i=0; i<datalength; i+=3)
  {
    unsigned char cc_valid=data[i] & 0x04;
    unsigned char cc_type=data[i] & 0x03;

    switch (cc_type)
    {
    case 0:
      // only use 608 as fallback
      if (!decoders[0].parent->m_seen708)
        decode_cc(decoders[0].parent->m_cc608decoder, (uint8_t*)data+i, 3);
      break;
    case 2:
      if (cc_valid==0) // This ends the previous packet if complete
      {
        if (check_current_packet_complete(decoders))
        {
          process_current_packet(decoders);
        }
      }
      else
      {
        if (decoders[0].parent->m_current_packet_length < 254)
        {
          decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+1];
          decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+2];
        }
      }
      break;
    case 3:
      process_current_packet(decoders);
      if (cc_valid)
      {
        if (decoders[0].parent->m_current_packet_length < 128)
        {
          decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+1];
          decoders[0].parent->m_current_packet[decoders[0].parent->m_current_packet_length++]=data[i+2];
        }
      }
      break;
    default:
      break;
    }
  }
}