</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox63">
+ <object class="GtkAlignment" id="alignment61">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">4</property>
- <child>
- <placeholder/>
- </child>
+ <property name="yscale">0</property>
+ <property name="left_padding">12</property>
+ <property name="top_padding">6</property>
+ <property name="bottom_padding">6</property>
<child>
- <placeholder/>
+ <object class="GtkCheckButton" id="AddCC">
+ <property name="label" translatable="yes">Add Closed Captions when available</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="pref_changed_cb"/>
+ </object>
</child>
</object>
<packing>
<child type="tab">
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
- <property name="label" translatable="yes">Audio</property>
+ <property name="label" translatable="yes">Audio/Subtitles</property>
</object>
<packing>
<property name="position">1</property>
#include "settings.h"
#include "callbacks.h"
#include "subtitlehandler.h"
+#include "audiohandler.h"
#include "x264handler.h"
#include "preview.h"
#include "values.h"
return name;
}
+gchar*
+ghb_subtitle_track_lang(signal_user_data_t *ud, gint track)
+{
+ gint titleindex;
+
+ titleindex = ghb_settings_combo_int(ud->settings, "title");
+ if (titleindex < 0)
+ goto fail;
+ if (track == -1)
+ return ghb_get_user_audio_lang(ud, titleindex, 0);
+ if (track < 0)
+ goto fail;
+
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_subtitle_t * sub;
+
+ if (h_scan == NULL)
+ goto fail;
+
+ list = hb_get_titles( h_scan );
+ if( !hb_list_count( list ) )
+ {
+ /* No valid title, stop right there */
+ goto fail;
+ }
+ title = hb_list_item( list, titleindex );
+ if (title == NULL) // Bad titleindex
+ goto fail;
+ sub = hb_list_item( title->list_subtitle, track);
+ if (sub != NULL)
+ return g_strdup(sub->iso639_2);
+
+fail:
+ return g_strdup("und");
+}
gint
ghb_get_title_number(gint titleindex)
return -2;
}
+gint
+ghb_find_cc_track(gint titleindex)
+{
+ hb_list_t * list;
+ hb_title_t * title;
+ hb_subtitle_t * subtitle;
+ gint count, ii;
+
+ g_debug("ghb_find_cc_track ()\n");
+ if (h_scan == NULL) return -2;
+ list = hb_get_titles( h_scan );
+ title = (hb_title_t*)hb_list_item( list, titleindex );
+ if (title != NULL)
+ {
+ count = hb_list_count( title->list_subtitle );
+ // Try to find an item that matches the preferred language
+ for (ii = 0; ii < count; ii++)
+ {
+ subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
+ if (subtitle->source == CC608SUB || subtitle->source == CC708SUB)
+ return ii;
+ }
+ }
+ return -2;
+}
+
gint
ghb_find_subtitle_track(
gint titleindex,
gint ghb_find_subtitle_track(
gint titleindex, const gchar *lang, GHashTable *track_indices);
gint ghb_pick_subtitle_track(signal_user_data_t *ud);
+gint ghb_find_cc_track(gint titleindex);
gint ghb_longest_title(void);
gchar* ghb_build_x264opts_string(GValue *settings);
GdkPixbuf* ghb_get_preview_image(
gint ghb_get_title_number(gint titleindex);
gint ghb_subtitle_track_source(signal_user_data_t *ud, gint track);
const char* ghb_subtitle_track_source_name(signal_user_data_t *ud, gint track);
+gchar* ghb_subtitle_track_lang(signal_user_data_t *ud, gint track);
gboolean ghb_validate_vquality(GValue *settings);
gboolean ghb_validate_audio(signal_user_data_t *ud);
</dict>
<key>Preferences</key>
<dict>
+ <key>AddCC</key>
+ <false />
<key>EncodeLogLocation</key>
<false />
<key>show_status</key>
gchar *lang, *pref_lang = NULL;
gchar *audio_lang;
gint foreign_lang_index = -1;
+ gboolean found_cc = FALSE;
const GValue *pref_subtitle;
GValue *subtitle;
// select sequential tracks for each. The hash keeps track
// of the tracks used for each language.
track = ghb_find_subtitle_track(titleindex, lang, track_indices);
+ g_free(lang);
if (track >= -1)
{
+ gint source;
GValue *dup = ghb_value_dup(subtitle);
+ lang = ghb_subtitle_track_lang(ud, track);
ghb_settings_set_int(dup, "SubtitleTrack", track);
if (foreign_lang_index < 0 && pref_lang != NULL &&
strcmp(lang, pref_lang) == 0)
ghb_settings_take_value(dup, "SubtitleDefaultTrack",
ghb_boolean_value_new(TRUE));
}
+ source = ghb_subtitle_track_source(ud, track);
+ if (source == CC608SUB || source == CC708SUB)
+ found_cc = TRUE;
ghb_add_subtitle(ud, dup);
jj++;
}
}
if (foreign_lang_index < 0 && pref_lang != NULL)
{
+ // Subtitle for foreign language audio not added yet
GValue *settings;
gboolean burn;
ghb_subtitle_exclusive_default(ud, foreign_lang_index);
ghb_log("adding subtitle for foreign language audio: %s", audio_lang);
}
+ if (ghb_settings_get_boolean(ud->settings, "AddCC") && !found_cc)
+ {
+ // Subtitle for foreign language audio not added yet
+ GValue *settings;
+
+ track = ghb_find_cc_track(titleindex);
+ if (track >= 0)
+ {
+ settings = ghb_dict_value_new();
+ ghb_settings_set_int(settings, "SubtitleTrack", track);
+ ghb_settings_take_value(settings, "SubtitleForced",
+ ghb_boolean_value_new(FALSE));
+ ghb_settings_take_value(settings, "SubtitleBurned",
+ ghb_boolean_value_new(FALSE));
+ ghb_settings_take_value(settings, "SubtitleDefaultTrack",
+ ghb_boolean_value_new(FALSE));
+
+ ghb_add_subtitle(ud, settings);
+ ghb_log("adding Closed Captions: %s", audio_lang);
+ }
+ }
if (pref_lang != NULL)
g_free(pref_lang);
if (audio_lang != NULL)