示例#1
0
void
truehd_reader_c::read_headers() {
  try {
    int tag_size_start = skip_id3v2_tag(*m_in);
    int tag_size_end   = id3_tag_present_at_end(*m_in);

    if (0 > tag_size_start)
      tag_size_start = 0;
    if (0 < tag_size_end)
      m_size -= tag_size_end;

    size_t init_read_len = std::min(m_size - tag_size_start, static_cast<uint64_t>(TRUEHD_READ_SIZE));

    if (m_in->read(m_chunk->get_buffer(), init_read_len) != init_read_len)
      throw mtx::input::header_parsing_x();

    m_in->setFilePointer(tag_size_start, seek_beginning);

    truehd_parser_c parser;
    parser.add_data(m_chunk->get_buffer(), init_read_len);


    auto found_truehd = false;
    auto found_ac3    = false;

    while (parser.frame_available() && (!found_truehd || !found_ac3)) {
      auto frame = parser.get_next_frame();

      if (frame->is_ac3()) {
        if (!found_ac3) {
          found_ac3    = true;
          m_ac3_header = frame->m_ac3_header;
        }

        continue;
      }

      if (!frame->is_sync())
        continue;

      m_header     = frame;
      found_truehd = true;
    }

    m_ti.m_id = 0;                  // ID for this track.

    show_demuxer_info();

  } catch (mtx::mm_io::exception &) {
    throw mtx::input::open_x();
  }
}
void
truehd_ac3_splitting_packet_converter_c::process_frames() {
  while (m_parser.frame_available()) {
    auto frame = m_parser.get_next_frame();

    if (frame->is_truehd() && m_ptzr) {
      static_cast<truehd_packetizer_c *>(m_ptzr)->process_framed(frame, m_truehd_timestamp);
      m_truehd_timestamp = -1;

    } else if (frame->is_ac3() && m_ac3_ptzr) {
      m_ac3_ptzr->process(std::make_shared<packet_t>(frame->m_data, m_ac3_timestamp));
      m_ac3_timestamp = -1;
    }
  }
}