+ if (audio)
+ {
+ allow_mono =
+ (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
+ (acodec & ~HB_ACODEC_LAME);
+ gint layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
+ allow_stereo =
+ ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO);
+ allow_dolby =
+ (layout == HB_INPUT_CH_LAYOUT_3F1R) ||
+ (layout == HB_INPUT_CH_LAYOUT_3F2R) ||
+ (layout == HB_INPUT_CH_LAYOUT_DOLBY);
+ allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R);
+ allow_6ch =
+ (audio->in.codec & (HB_ACODEC_AC3|HB_ACODEC_DCA)) &&
+ (acodec & ~HB_ACODEC_LAME) &&
+ (layout == HB_INPUT_CH_LAYOUT_3F2R) &&
+ (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE);
+ }
+ gboolean greater = FALSE;
+ if (mix == 0)
+ {
+ // If no mix is specified, select the best available.
+ mix = HB_AMIXDOWN_6CH;
+ }
+ if (mix == HB_AMIXDOWN_6CH)
+ {
+ greater = TRUE;
+ if (allow_6ch) return HB_AMIXDOWN_6CH;
+ }
+ if (mix == HB_AMIXDOWN_DOLBYPLII || greater)
+ {
+ greater = TRUE;
+ if (allow_dpl2) return HB_AMIXDOWN_DOLBYPLII;
+ }
+ if (mix == HB_AMIXDOWN_DOLBY || greater)
+ {
+ greater = TRUE;
+ if (allow_dolby) return HB_AMIXDOWN_DOLBY;
+ }
+ if (mix == HB_AMIXDOWN_STEREO || greater)
+ {
+ greater = TRUE;
+ if (allow_stereo) return HB_AMIXDOWN_STEREO;
+ }
+ if (mix == HB_AMIXDOWN_MONO || greater)
+ {
+ greater = TRUE;
+ if (allow_mono) return HB_AMIXDOWN_MONO;
+ }
+ if (allow_stereo) return HB_AMIXDOWN_STEREO;
+ if (allow_dolby) return HB_AMIXDOWN_DOLBY;
+ if (allow_dpl2) return HB_AMIXDOWN_DOLBYPLII;
+ if (allow_6ch) return HB_AMIXDOWN_6CH;
+ return 0;
+}
+
+// Set up the model for the combo box
+static void
+init_combo_box(GtkBuilder *builder, const gchar *name)
+{
+ GtkComboBox *combo;
+ GtkListStore *store;
+ GtkCellRenderer *cell;
+
+ g_debug("init_combo_box() %s\n", name);
+ // First modify the combobox model to allow greying out of options
+ combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ if (combo == NULL)
+ return;
+ // Store contains:
+ // 1 - String to display
+ // 2 - bool indicating whether the entry is selectable (grey or not)
+ // 3 - String that is used for presets
+ // 4 - Int value determined by backend
+ // 5 - String value determined by backend
+ store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_STRING);
+ gtk_combo_box_set_model(combo, GTK_TREE_MODEL(store));
+
+ if (GTK_WIDGET_TYPE(combo) == GTK_TYPE_COMBO_BOX)
+ {
+ gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo));
+ cell = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), cell, TRUE);
+ gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), cell,
+ "markup", 0, "sensitive", 1, NULL);
+ }
+ else
+ { // Combo box entry
+ gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo), 0);
+ }
+}
+
+static void
+audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gint count)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gint ii;
+ gchar *str;
+
+ g_debug("audio_samplerate_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ // Add an item for "Same As Source"
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "<small>Same as source</small>",
+ 1, TRUE,
+ 2, "source",
+ 3, 0.0,
+ 4, "source",
+ -1);
+ for (ii = 0; ii < count; ii++)
+ {
+ gtk_list_store_append(store, &iter);
+ str = g_strdup_printf("<small>%s</small>", rates[ii].string);
+ gtk_list_store_set(store, &iter,
+ 0, str,
+ 1, TRUE,
+ 2, rates[ii].string,
+ 3, (gdouble)rates[ii].rate,
+ 4, rates[ii].string,
+ -1);
+ g_free(str);
+ }
+}
+
+static void
+video_rate_opts_set(GtkBuilder *builder, const gchar *name, hb_rate_t *rates, gint count)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gint ii;
+
+ g_debug("video_rate_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ // Add an item for "Same As Source"
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "Same as source",
+ 1, TRUE,
+ 2, "source",
+ 3, 0.0,
+ 4, "source",
+ -1);
+ for (ii = 0; ii < count; ii++)
+ {
+ gchar *desc = "";
+ gchar *option;
+ if (strcmp(rates[ii].string, "23.976") == 0)
+ {
+ desc = "(NTSC Film)";
+ }
+ else if (strcmp(rates[ii].string, "25") == 0)
+ {
+ desc = "(PAL Film/Video)";
+ }
+ else if (strcmp(rates[ii].string, "29.97") == 0)
+ {
+ desc = "(NTSC Video)";
+ }
+ option = g_strdup_printf ("%s %s", rates[ii].string, desc);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, option,
+ 1, TRUE,
+ 2, rates[ii].string,
+ 3, (gdouble)rates[ii].rate,
+ 4, rates[ii].string,
+ -1);
+ g_free(option);
+ }
+}
+
+static void
+mix_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gint ii;
+ gchar *str;
+
+ g_debug("mix_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "<small>None</small>",
+ 1, TRUE,
+ 2, "none",
+ 3, 0.0,
+ 4, "none",
+ -1);
+ for (ii = 0; ii < hb_audio_mixdowns_count; ii++)
+ {
+ gtk_list_store_append(store, &iter);
+ str = g_strdup_printf("<small>%s</small>",
+ hb_audio_mixdowns[ii].human_readable_name);
+ gtk_list_store_set(store, &iter,
+ 0, str,
+ 1, TRUE,
+ 2, hb_audio_mixdowns[ii].short_name,
+ 3, (gdouble)hb_audio_mixdowns[ii].amixdown,
+ 4, hb_audio_mixdowns[ii].internal_name,
+ -1);
+ g_free(str);
+ }
+}
+
+static void
+srt_codeset_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gint ii;
+
+ g_debug("srt_codeset_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ for (ii = 0; ii < SRT_TABLE_SIZE; ii++)
+ {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, srt_codeset_table[ii],
+ 1, TRUE,
+ 2, srt_codeset_table[ii],
+ 3, (gdouble)ii,
+ 4, srt_codeset_table[ii],
+ -1);
+ }
+ GtkComboBoxEntry *cbe;
+
+ cbe = GTK_COMBO_BOX_ENTRY(GHB_WIDGET(builder, name));
+ //gtk_combo_box_entry_set_text_column(cbe, 0);
+}
+
+static void
+language_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gint ii;
+
+ g_debug("language_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
+ {
+ const gchar *lang;
+
+ if (ghb_language_table[ii].native_name[0] != 0)
+ lang = ghb_language_table[ii].native_name;
+ else
+ lang = ghb_language_table[ii].eng_name;
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, lang,
+ 1, TRUE,
+ 2, ghb_language_table[ii].iso639_2,
+ 3, (gdouble)ii,
+ 4, ghb_language_table[ii].iso639_1,
+ -1);
+ }
+}
+
+static gchar **titles = NULL;
+
+void
+title_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ hb_list_t * list = NULL;
+ hb_title_t * title = NULL;
+ gint ii;
+ gint count = 0;
+
+ g_debug("title_opts_set ()\n");
+ store = get_combo_box_store(builder, name);
+ gtk_list_store_clear(store);
+ if (h_scan != NULL)
+ {
+ list = hb_get_titles( h_scan );
+ count = hb_list_count( list );
+ if (count > 100) count = 100;
+ }
+ if (titles) g_strfreev(titles);
+ if (title_opts.map) g_free(title_opts.map);
+ if (count > 0)
+ {
+ title_opts.count = count;
+ title_opts.map = g_malloc(count*sizeof(options_map_t));
+ titles = g_malloc((count+1) * sizeof(gchar*));
+ }
+ else
+ {
+ title_opts.count = 1;
+ title_opts.map = g_malloc(sizeof(options_map_t));
+ titles = NULL;
+ }
+ if( count <= 0 )
+ {
+ // No titles. Fill in a default.
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, "No Titles",
+ 1, TRUE,
+ 2, "none",
+ 3, -1.0,
+ 4, "none",
+ -1);
+ title_opts.map[0].option = "No Titles";
+ title_opts.map[0].shortOpt = "none";
+ title_opts.map[0].ivalue = -1;
+ title_opts.map[0].svalue = "none";
+ return;
+ }
+ for (ii = 0; ii < count; ii++)
+ {
+ title = (hb_title_t*)hb_list_item(list, ii);
+ if (title->type == HB_STREAM_TYPE)
+ {
+ if (title->duration != 0)
+ {
+ titles[ii] = g_strdup_printf ("%d - %02dh%02dm%02ds - %s",
+ title->index, title->hours, title->minutes, title->seconds,
+ title->name);
+ }
+ else
+ {
+ titles[ii] = g_strdup_printf ("%d - %s",
+ title->index, title->name);
+ }
+ }
+ else
+ {
+ if (title->duration != 0)
+ {
+ titles[ii] = g_strdup_printf ("%d - %02dh%02dm%02ds",
+ title->index, title->hours, title->minutes, title->seconds);
+ }
+ else
+ {
+ titles[ii] = g_strdup_printf ("%d - Unknown Length",
+ title->index);
+ }
+ }
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, titles[ii],
+ 1, TRUE,
+ 2, titles[ii],
+ 3, (gdouble)ii,
+ 4, titles[ii],
+ -1);
+ title_opts.map[ii].option = titles[ii];
+ title_opts.map[ii].shortOpt = titles[ii];
+ title_opts.map[ii].ivalue = ii;
+ title_opts.map[ii].svalue = titles[ii];
+ }
+ titles[ii] = NULL;
+}