Skip to content

Commit

Permalink
Fixes #10820. Add iso-639 language code to teletext and dvb subtitles…
Browse files Browse the repository at this point in the history
… extracted by mythccextractor.

When an ISO-639 language code is not found the string "und" is used instead.

Signed-off-by: Daniel Kristjansson <danielk@cuymedia.net>
  • Loading branch information
gradhika authored and daniel-kristjansson committed Jun 12, 2012
1 parent 5c047f4 commit 9b514c4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
12 changes: 12 additions & 0 deletions mythtv/libs/libmythtv/avformatdecoder.cpp
Expand Up @@ -2240,7 +2240,19 @@ void AvFormatDecoder::DoFastForwardSeek(long long desiredFrame, bool &needflush)
DecoderBase::DoFastForwardSeek(desiredFrame, needflush);
return;
}
///Returns TeleText language
int AvFormatDecoder::GetTeletextLanguage(uint lang_idx) const
{
for (uint i = 0; i < (uint) tracks[kTrackTypeTeletextCaptions].size(); i++)
{
if (tracks[kTrackTypeTeletextCaptions][i].language_index == lang_idx)
{
return tracks[kTrackTypeTeletextCaptions][i].language;
}
}

return iso639_str3_to_key("und");
}
/// Returns DVD Subtitle language
int AvFormatDecoder::GetSubtitleLanguage(uint subtitle_index, uint stream_index)
{
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/avformatdecoder.h
Expand Up @@ -176,6 +176,7 @@ class AvFormatDecoder : public DecoderBase
virtual bool SetVideoByComponentTag(int tag);

// Stream language info
virtual int GetTeletextLanguage(uint lang_idx) const;
virtual int GetSubtitleLanguage(uint subtitle_index, uint stream_index);
virtual int GetCaptionLanguage(TrackTypes trackType, int service_num);
virtual int GetAudioLanguage(uint audio_index, uint stream_index);
Expand Down
31 changes: 25 additions & 6 deletions mythtv/libs/libmythtv/mythccextractorplayer.cpp
Expand Up @@ -364,7 +364,7 @@ void MythCCExtractorPlayer::Process608Captions(uint flags)

QString lang = iso639_key_to_str3(langCode);
lang = iso639_is_key_undefined(langCode) ? "und" : lang;

QString service_key = QString("cc%1").arg(idx + 1);
QString filename = QString("%1.%2%3-%4.%5.srt")
.arg(m_baseName).arg(stream_id_str).arg("608")
Expand Down Expand Up @@ -558,7 +558,7 @@ void MythCCExtractorPlayer::IngestTeletext(void)
to_string_list(*subpage));
}
}

(*ttxit).reader->ClearUpdatedPages();
}
}
Expand All @@ -579,12 +579,21 @@ void MythCCExtractorPlayer::ProcessTeletext(void)
if ((*it).empty())
continue; // Skip empty subtitle streams.

int page = it.key();
uint page = it.key();

if (!(*ttxit).srtwriters[page])
{
QString filename = QString("%1.%2ttx-0x%3.srt")
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'));

Expand Down Expand Up @@ -646,7 +655,7 @@ void MythCCExtractorPlayer::IngestDVBSubtitles(void)
subtitles->buffers.pop_front();

const QSize v_size =
QSize(GetVideoSize().width()*4, GetVideoSize().height()*4);
QSize(GetVideoSize().width()*4, GetVideoSize().height()*4);
QImage sub_pict(v_size, QImage::Format_ARGB32);
sub_pict.fill(0);

Expand Down Expand Up @@ -715,9 +724,19 @@ void MythCCExtractorPlayer::ProcessDVBSubtitles(uint flags)
{
// Process (DVB) subtitle streams.
DVBSubInfo::iterator subit = m_dvbsub_info.begin();
int subtitleStreamCount = 0;
for (; subit != m_dvbsub_info.end(); ++subit)
{
QString dir_name = QString(m_baseName + ".dvb-%1").arg(subit.key());
int langCode = 0;
AvFormatDecoder *avd = dynamic_cast<AvFormatDecoder *>(decoder);
int idx = subit.key();
if (avd)
langCode = avd->GetSubtitleLanguage(subtitleStreamCount, idx);
subtitleStreamCount++;

QString lang = iso639_key_to_str3(langCode);
lang = iso639_is_key_undefined(langCode) ? "und" : lang;
QString dir_name = QString(m_baseName + "-%1.dvb-%2").arg(lang).arg(subit.key());
if (!m_workingDir.exists(dir_name) && !m_workingDir.mkdir(dir_name))
{
LOG(VB_GENERAL, LOG_ERR, QString("Can't create directory '%1'")
Expand Down

0 comments on commit 9b514c4

Please sign in to comment.