Esempio n. 1
0
bool JBEAM_TextBox::JBEAM_FindOtherContainer(QString JBEAM_box, QString listtype, int &Begin, int &End)
{
    QString pattern = "\"" + listtype + "\"\\s*:\\s*\\[";
    QRegExp re_container(pattern);

    Begin = JBEAM_box.indexOf(re_container);
    int i=Begin;
    for(; i<JBEAM_box.length(); ++i)
    {
        if(JBEAM_box.at(i) == '[') break;
    }
    Begin = i;
    int level = 1;
    ++i;
    for(;i<JBEAM_box.length();++i)
    {
        if(JBEAM_box.at(i) == '[') ++level;
        else if(JBEAM_box.at(i) == ']')
        {
             --level;
             if(level<1) break;
        }
    }
    End = i;
    return true;
}
Esempio n. 2
0
int
file_prober_c::process_output() {
  int exit_code = m_process.exitCode();

  if (2 == exit_code) {
    QMessageBox::warning(m_parent, Q(Y("Unknown file format")), Q(Y("The file is an unknown and unsupported file format.")));
    return -2;
  }

  if (3 == exit_code) {
    QString container = Q(Y("unknown"));

    int pos;
    if (!m_output.isEmpty() && ((pos = m_output[0].indexOf(Q("container:"))) >= 0))
      container = m_output[0].mid(pos + 11);

    QMessageBox::warning(m_parent, Q(Y("Unsupported file format")), Q(Y("The file is an unsupported container format (%1).")).arg(container));
    return -3;
  }

  if (0 != exit_code) {
    QMessageBox::warning(m_parent, Q(Y("Unknown error")), Q(Y("Determining the file type failed. Please make sure you have the correct mkvmerge executable selected in the settings.")));
    return -4;
  }

  QRegExp re_container(Q("File\\s.*container:\\s+([^\\[]+)"));
  QRegExp re_track(Q("Track\\s+ID\\s+(\\d+):\\s+(audio|video|subtitles|buttons)\\s+\\(([^\\)]+)\\)"));
  QRegExp re_properties(Q("\\[(.*)\\]"));

  int i;
  for (i = 0; m_output.size() > i; ++i) {
    int pos;

    if (-1 != (pos = re_container.indexIn(m_output[i]))) {
      DBG(Q("cont %1\n").arg(re_container.cap(1)));
      m_file->m_container = re_container.cap(1);

      if (-1 != re_properties.indexIn(m_output[i].mid(pos + re_container.matchedLength()))) {
        DBG(Q("  props %2\n").arg(re_properties.cap(1)));
        m_file->m_properties = unpack_properties(re_properties.cap(1));

        QHash<QString, QString>::const_iterator prop = m_file->m_properties.begin();
        while (prop != m_file->m_properties.end()) {
          DBG(Q("    %1 = %2\n").arg(prop.key()).arg(prop.value()));
          prop++;
        }
      }

    } else if (-1 != (pos = re_track.indexIn(m_output[i]))) {
      input_track_c *track = new input_track_c;
      m_file->m_tracks << track;

      DBG(Q("track id %1 type %2 codec %3\n").arg(re_track.cap(1)).arg(re_track.cap(2)).arg(re_track.cap(3)));
      track->m_tid   = re_track.cap(1).toLongLong();
      track->m_codec = re_track.cap(3);
      QString type   = re_track.cap(2);
      track->m_type  = Q("audio")     == type ? 'a'
                     : Q("video")     == type ? 'v'
                     : Q("subtitles") == type ? 's'
                     :                          'b';

      if (-1 != re_properties.indexIn(m_output[i].mid(pos + re_track.matchedLength()))) {
        DBG(Q("  props %2\n").arg(re_properties.cap(1)));
        track->m_properties = unpack_properties(re_properties.cap(1));

        QHash<QString, QString>::const_iterator prop = track->m_properties.begin();
        while (prop != track->m_properties.end()) {
          DBG(Q("    %1 = %2\n").arg(prop.key()).arg(prop.value()));
          prop++;
        }
      }
    }
  }

  return 0;
}