Ticket #11242: forced.patch

File forced.patch, 4.8 KB (added by Jim Stichnoth <stichnot@…>, 7 years ago)
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index f6c7d7b..8d2c8b5 100644
    a b void AvFormatDecoder::ScanRawTextCaptions(int av_stream_index) 
    16901690    AVDictionaryEntry *metatag =
    16911691        av_dict_get(ic->streams[av_stream_index]->metadata, "language", NULL,
    16921692                    0);
     1693    bool forced =
     1694      ic->streams[av_stream_index]->disposition & AV_DISPOSITION_FORCED;
    16931695    int lang = metatag ? get_canonical_lang(metatag->value) :
    16941696                         iso639_str3_to_key("und");
    16951697    LOG(VB_PLAYBACK, LOG_INFO, LOC +
    16961698        QString("Text Subtitle track #%1 is A/V stream #%2 "
    1697                 "and is in the %3 language(%4).")
     1699                "and is in the %3 language(%4), forced=%5.")
    16981700                    .arg(tracks[kTrackTypeRawText].size()).arg(av_stream_index)
    1699                     .arg(iso639_key_toName(lang)).arg(lang));
    1700     StreamInfo si(av_stream_index, lang, 0, 0, 0);
     1701                    .arg(iso639_key_toName(lang)).arg(lang).arg(forced));
     1702    StreamInfo si(av_stream_index, lang, 0, 0, 0, false, false, forced);
    17011703    tracks[kTrackTypeRawText].push_back(si);
    17021704}
    17031705
    QString AvFormatDecoder::GetTrackDesc(uint type, uint trackNo) const 
    36593661
    36603662    bool forced = tracks[type][trackNo].forced;
    36613663    int lang_key = tracks[type][trackNo].language;
     3664    QString forcedString = forced ? QObject::tr(" (forced)") : "";
    36623665    if (kTrackTypeAudio == type)
    36633666    {
    36643667        if (ringBuffer->IsDVD())
    QString AvFormatDecoder::GetTrackDesc(uint type, uint trackNo) const 
    37123715
    37133716        return QObject::tr("Subtitle") + QString(" %1: %2%3")
    37143717            .arg(trackNo + 1).arg(iso639_key_toName(lang_key))
    3715             .arg(forced ? QObject::tr(" (forced)") : "");
     3718            .arg(forcedString);
     3719    }
     3720    else if (forced && kTrackTypeRawText == type)
     3721    {
     3722        return DecoderBase::GetTrackDesc(type, trackNo) + forcedString;
    37163723    }
    37173724    else
    37183725    {
  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 795b345..64e48f9 100644
    a b void MythPlayer::VideoStart(void) 
    22682268        }
    22692269#endif // USING_MHEG
    22702270
    2271         SetCaptionsEnabled(captionsEnabledbyDefault, false);
     2271        // If there is a forced text subtitle track (which is possible
     2272        // in e.g. a .mkv container), and forced subtitles are
     2273        // allowed, then start playback with that subtitle track
     2274        // selected.  Otherwise, use the frontend settings to decide
     2275        // which captions/subtitles (if any) to enable at startup.
     2276        // TODO: modify the fix to #10735 to use this approach
     2277        // instead.
     2278        bool hasForcedTextTrack = false;
     2279        uint forcedTrackNumber = 0;
     2280        if (GetAllowForcedSubtitles())
     2281        {
     2282            uint numTextTracks = decoder->GetTrackCount(kTrackTypeRawText);
     2283            for (uint i = 0; !hasForcedTextTrack && i < numTextTracks; ++i)
     2284            {
     2285                if (decoder->GetTrackInfo(kTrackTypeRawText, i).forced)
     2286                {
     2287                    hasForcedTextTrack = true;
     2288                    forcedTrackNumber = i;
     2289                }
     2290            }
     2291        }
     2292        if (hasForcedTextTrack)
     2293            SetTrack(kTrackTypeRawText, forcedTrackNumber);
     2294        else
     2295            SetCaptionsEnabled(captionsEnabledbyDefault, false);
     2296
    22722297        osdLock.unlock();
    22732298    }
    22742299
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index a03205b..4e7e7d7 100644
    a b void TV::FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd, 
    1114611146            osd->DialogAddButton(tr("Disable Subtitles"), ACTION_DISABLESUBS);
    1114711147        else if (have_subs && !enabled)
    1114811148            osd->DialogAddButton(tr("Enable Subtitles"), ACTION_ENABLESUBS);
    11149         if (!av_tracks.empty())
     11149        if (!av_tracks.empty() || !text_tracks.empty())
    1115011150        {
    1115111151            if (forcedon)
    1115211152            {
    void TV::FillOSDMenuSubtitles(const PlayerContext *ctx, OSD *osd, 
    1115811158                osd->DialogAddButton(tr("Enable Forced Subtitles"),
    1115911159                                     ACTION_ENABLEFORCEDSUBS);
    1116011160            }
    11161             osd->DialogAddButton(tr("Select Subtitle"),
    11162                                  "DIALOG_MENU_AVSUBTITLES_0",
    11163                                  true, selected == "AVSUBTITLES");
     11161            if (!av_tracks.empty())
     11162                osd->DialogAddButton(tr("Select Subtitle"),
     11163                                     "DIALOG_MENU_AVSUBTITLES_0",
     11164                                     true, selected == "AVSUBTITLES");
    1116411165        }
    1116511166        if (havetext || !text_tracks.empty())
    1116611167        {