void MythCCExtractorPlayer::ProcessTeletext(uint flags)
{
    int i = 0;
    TeletextInfo::iterator ttxit = m_ttx_info.begin();
    for (; ttxit != m_ttx_info.end(); ++ttxit)
    {
        QString stream_id_str = (m_cc608_info.size() <= 1) ?
            QString("") : QString("%1.").arg(i,2,QChar('0'));

        TeletextStreamType &subs = (*ttxit).subs;
        TeletextStreamType::iterator it = subs.begin();
        for (; it != subs.end(); ++it)
        {
            if ((*it).empty())
                continue; // Skip empty subtitle streams.
            if (((kProcessFinalize & flags) == 0) && ((*it).size() <= 1))
                continue; // Leave one caption behind so it can be amended

            uint page = it.key();

            if (!(*ttxit).srtwriters[page])
            {
                int langCode = 0;
                AvFormatDecoder *avd = dynamic_cast<AvFormatDecoder *>(decoder);

                if (avd)
                    langCode = avd->GetTeletextLanguage(page);

                QString lang = iso639_key_to_str3(langCode);
                lang = iso639_is_key_undefined(langCode) ? "und" : lang;
                QString filename = QString("%1-%2.%3ttx-0x%4.srt")
                    .arg(m_baseName)
                    .arg(lang)
                    .arg(stream_id_str)
                    .arg(page, 3, 16, QChar('0'));

                (*ttxit).srtwriters[page] = new SRTWriter(
                    m_workingDir.filePath(filename));
            }

            if (!(*ttxit).srtwriters[page]->IsOpen())
            {
                (*it).clear();
                continue;
            }

            while ((*it).size() > ((kProcessFinalize & flags) ? 0 : 1))
            {
                if ((*it).front().length <= 0)
                    (*it).front().length = OneSubtitle::kDefaultLength;

                (*ttxit).srtwriters[page]->AddSubtitle(
                    (*it).front(), ++(*ttxit).subs_num[page]);
                (*it).pop_front();
            }

            (*ttxit).srtwriters[page]->Flush();
        }
    }
}
示例#2
0
void MythCCExtractorPlayer::ProcessTeletext(void)
{
    int i = 0;
    TeletextInfo::iterator ttxit = m_ttx_info.begin();
    for (; ttxit != m_ttx_info.end(); ++ttxit)
    {
        QString stream_id_str = (m_cc608_info.size() <= 1) ?
            QString("") : QString("%1.").arg(i,2,QChar('0'));

        TeletextStreamType &subs = (*ttxit).subs;
        TeletextStreamType::iterator it = subs.begin();
        for (; it != subs.end(); ++it)
        {
            if ((*it).empty())
                continue; // Skip empty subtitle streams.

            int page = it.key();

            if (!(*ttxit).srtwriters[page])
            {
                QString filename = QString("%1.%2ttx-0x%3.srt")
                    .arg(m_baseName)
                    .arg(stream_id_str)
                    .arg(page, 3, 16, QChar('0'));

                (*ttxit).srtwriters[page] = new SRTWriter(
                    m_workingDir.filePath(filename));
            }

            if (!(*ttxit).srtwriters[page]->IsOpen())
            {
                (*it).clear();
                continue;
            }

            while (!(*it).empty())
            {
                if ((*it).front().length <= 0)
                    (*it).front().length = OneSubtitle::kDefaultLength;

                (*ttxit).srtwriters[page]->AddSubtitle(
                    (*it).front(), ++(*ttxit).subs_num[page]);
                (*it).pop_front();
            }

            (*ttxit).srtwriters[page]->Flush();
        }
    }
}