Exemple #1
0
gboolean
ghb_queue_add(signal_user_data_t *ud, GValue *settings, gint batch)
{
    // Add settings to the queue
    gint titleindex;
    gint titlenum;
    
    g_debug("queue_add ()");
    if (!validate_settings(ud, settings, batch))
    {
        return FALSE;
    }

    if (ud->queue == NULL)
        ud->queue = ghb_array_value_new(32);
    // Make a copy of current settings to be used for the new job
    ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
    ghb_settings_set_int(settings, "job_unique_id", 0);
    titleindex = ghb_settings_combo_int(settings, "title");
    titlenum = ghb_get_title_number(titleindex);
    ghb_settings_set_int(settings, "titlenum", titlenum);
    ghb_array_append(ud->queue, settings);
    add_to_queue_list(ud, settings, NULL);
    ghb_save_queue(ud->queue);
    ghb_update_pending(ud);

    return TRUE;
}
Exemple #2
0
G_MODULE_EXPORT void
subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *subsettings;

    ghb_widget_to_setting(ud->settings, widget);
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        if (ghb_settings_get_boolean(ud->settings, "SubtitleSrtEnable"))
        {
            ghb_settings_set_int(subsettings, "SubtitleSource", SRTSUB);
        }
        else
        {
            int track, source;

            track = ghb_settings_get_int(subsettings, "SubtitleTrack");
            source = ghb_subtitle_track_source(ud->settings, track);
            ghb_settings_set_int(subsettings, "SubtitleSource", source);
        }
        subtitle_set_track_description(ud->settings, subsettings);
        subtitle_update_dialog_widgets(ud, subsettings);
        ghb_subtitle_list_refresh_selected(ud);
        ghb_live_reset(ud);
    }
}
Exemple #3
0
static void
x264_update_deblock(signal_user_data_t *ud, const gchar *xval)
{
    int avalue, bvalue;
    gchar *end;
    gchar *val;
    gchar *bval = NULL;

    if (xval == NULL) return;
    val = g_strdup(xval);
    bvalue = avalue = 0;
    if (val != NULL)
    {
        gchar *pos = strchr(val, ',');
        if (pos != NULL)
        {
            bval = pos + 1;
            *pos = 0;
        }
        avalue = (int)g_strtod(val, &end);
        if (bval != NULL)
        {
            bvalue = (int)g_strtod(bval, &end);
        }
    }
    g_free(val);
    ghb_settings_set_int(ud->x264_priv, "x264_deblock_alpha", avalue);
    ghb_settings_set_int(ud->x264_priv, "x264_deblock_beta", bvalue);
}
Exemple #4
0
static void
x264_update_int(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    gint ival;

    if (val == NULL) return;
    ival = g_strtod (val, NULL);
    ghb_settings_set_int(ud->x264_priv, name, ival);
}
Exemple #5
0
G_MODULE_EXPORT void
subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *subsettings;

    g_debug("subtitle_track_changed_cb()");
    ghb_widget_to_setting(ud->settings, widget);
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        gint track, source;

        ghb_widget_to_setting(subsettings, widget);
        track = ghb_settings_get_int(subsettings, "SubtitleTrack");
        source = ghb_subtitle_track_source(ud->settings, track);
        ghb_settings_set_int(subsettings, "SubtitleSource", source);
        subtitle_set_track_description(ud->settings, subsettings);
        subtitle_update_dialog_widgets(ud, subsettings);
        ghb_subtitle_list_refresh_selected(ud);
        ghb_live_reset(ud);
    }
}
Exemple #6
0
static GValue*  subtitle_add_track(
    signal_user_data_t *ud,
    GValue *settings,
    const hb_title_t *title,
    int track,
    int mux,
    gboolean default_track,
    gboolean srt,
    gboolean *burned)
{
    int source = 0;

    if (track >= 0 && !srt)
    {
        hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track);
        source = subtitle->source;
    }
    else if (srt)
    {
        source = SRTSUB;
    }

    if (*burned && !hb_subtitle_can_pass(source, mux))
    {
        // Can only burn one.  Skip others that must be burned.
        return NULL;
    }

    GValue *subsettings = ghb_dict_value_new();
    ghb_settings_set_int(subsettings, "SubtitleTrack", track);
    ghb_settings_set_int(subsettings, "SubtitleSource", source);

    // Set default SRT settings
    gchar *pref_lang, *dir, *filename;

    pref_lang = ghb_settings_get_string(settings, "PreferredLanguage");
    ghb_settings_set_string(subsettings, "SrtLanguage", pref_lang);
    g_free(pref_lang);

    ghb_settings_set_string(subsettings, "SrtCodeset", "UTF-8");

    dir = ghb_settings_get_string(ud->prefs, "SrtDir");
    filename = g_strdup_printf("%s/none", dir);
    ghb_settings_set_string(subsettings, "SrtFile", filename);
    g_free(dir);
    g_free(filename);

    ghb_settings_set_int(subsettings, "SrtOffset", 0);

    subtitle_set_track_description(settings, subsettings);

    if (!hb_subtitle_can_pass(source, mux))
    {
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", TRUE);
        *burned = TRUE;
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE);
    }
    if (track == -1)
    {
        // Foreign audio search "track"
        ghb_settings_set_boolean(subsettings, "SubtitleForced", TRUE);
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleForced", FALSE);
    }
    if (default_track)
    {
        ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", TRUE);
    }
    else
    {
        ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE);
    }
    subtitle_add_to_settings(settings, subsettings);

    return subsettings;
}
Exemple #7
0
G_MODULE_EXPORT void 
queue_drag_cb(
    GtkTreeView *dstwidget, 
    GdkDragContext *dc, 
    gint x, gint y, 
    GtkSelectionData *selection_data, 
    guint info, guint t, 
    signal_user_data_t *ud)
{
    GtkTreePath *path = NULL;
    //GtkTreeModel *model;
    GtkTreeViewDropPosition pos;
    GtkTreeIter dstiter, srciter;
    gint *indices, row;
    GValue *js;
    
    GtkTreeModel *dstmodel = gtk_tree_view_get_model(dstwidget);
            
    g_debug("queue_drag_cb ()");
    // This doesn't work here for some reason...
    // gtk_tree_view_get_drag_dest_row(dstwidget, &path, &pos);
    gtk_tree_view_get_dest_row_at_pos (dstwidget, x, y, &path, &pos);
    // This little hack is needed because attempting to drop after
    // the last item gives us no path or pos.
    if (path == NULL)
    {
        gint n_children;

        n_children = gtk_tree_model_iter_n_children(dstmodel, NULL);
        if (n_children)
        {
            pos = GTK_TREE_VIEW_DROP_AFTER;
            path = gtk_tree_path_new_from_indices(n_children-1, -1);
        }
        else
        {
            pos = GTK_TREE_VIEW_DROP_BEFORE;
            path = gtk_tree_path_new_from_indices(0, -1);
        }
    }
    if (path)
    {
        if (gtk_tree_path_get_depth(path) > 1)
            gtk_tree_path_up(path);
        if (gtk_tree_model_get_iter (dstmodel, &dstiter, path))
        {
            GtkTreeIter iter;
            GtkTreeView *srcwidget;
            GtkTreeModel *srcmodel;
            GtkTreeSelection *select;
            GtkTreePath *srcpath = NULL;
            GtkTreePath *dstpath = NULL;

            srcwidget = GTK_TREE_VIEW(gtk_drag_get_source_widget(dc));
            //srcmodel = gtk_tree_view_get_model(srcwidget);
            select = gtk_tree_view_get_selection (srcwidget);
            gtk_tree_selection_get_selected (select, &srcmodel, &srciter);

            srcpath = gtk_tree_model_get_path (srcmodel, &srciter);
            indices = gtk_tree_path_get_indices(srcpath);
            row = indices[0];
            gtk_tree_path_free(srcpath);
            js = ghb_array_get_nth(ud->queue, row);

            switch (pos)
            {
                case GTK_TREE_VIEW_DROP_BEFORE:
                case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE:
                    gtk_tree_store_insert_before (GTK_TREE_STORE (dstmodel), 
                                                    &iter, NULL, &dstiter);
                    break;

                case GTK_TREE_VIEW_DROP_AFTER:
                case GTK_TREE_VIEW_DROP_INTO_OR_AFTER:
                    gtk_tree_store_insert_after (GTK_TREE_STORE (dstmodel), 
                                                    &iter, NULL, &dstiter);
                    break;

                default:
                    break;
            }
            // Reset job to pending
            ghb_settings_set_int(js, "job_status", GHB_QUEUE_PENDING);
            add_to_queue_list(ud, js, &iter);

            dstpath = gtk_tree_model_get_path (dstmodel, &iter);
            indices = gtk_tree_path_get_indices(dstpath);
            row = indices[0];
            gtk_tree_path_free(dstpath);
            ghb_array_insert(ud->queue, row, js);

            srcpath = gtk_tree_model_get_path (srcmodel, &srciter);
            indices = gtk_tree_path_get_indices(srcpath);
            row = indices[0];
            gtk_tree_path_free(srcpath);
            ghb_array_remove(ud->queue, row);
            gtk_tree_store_remove (GTK_TREE_STORE (srcmodel), &srciter);
            ghb_save_queue(ud->queue);
        }
        gtk_tree_path_free(path);
    }
}
Exemple #8
0
gboolean
ghb_reload_queue(signal_user_data_t *ud)
{
    GValue *queue;
    gint unfinished = 0;
    gint count, ii;
    gint pid;
    gint status;
    GValue *settings;
    gchar *message;

    g_debug("ghb_reload_queue");

find_pid:
    pid = ghb_find_pid_file();
    if (pid < 0)
        return FALSE;

    queue = ghb_load_old_queue(pid);
    ghb_remove_old_queue_file(pid);
    // Look for unfinished entries
    count = ghb_array_len(queue);
    for (ii = 0; ii < count; ii++)
    {
        settings = ghb_array_get_nth(queue, ii);
        status = ghb_settings_get_int(settings, "job_status");
        if (status != GHB_QUEUE_DONE && status != GHB_QUEUE_CANCELED)
        {
            unfinished++;
        }
    }
    if (!unfinished)
        goto find_pid;

    if (unfinished)
    {
        message = g_strdup_printf(
                    "You have %d unfinished job%s in a saved queue.\n\n"
                    "Would you like to reload %s?",
                    unfinished, 
                    (unfinished > 1) ? "s" : "",
                    (unfinished > 1) ? "them" : "it");
        if (ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "No", "Yes"))
        {
            GtkWidget *widget = GHB_WIDGET (ud->builder, "queue_window");
            gtk_widget_show (widget);
            widget = GHB_WIDGET (ud->builder, "show_queue");
            gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(widget), TRUE);

            ud->queue = queue;
            // First get rid of any old items we don't want
            for (ii = count-1; ii >= 0; ii--)
            {
                settings = ghb_array_get_nth(queue, ii);
                status = ghb_settings_get_int(settings, "job_status");
                if (status == GHB_QUEUE_DONE || status == GHB_QUEUE_CANCELED)
                {
                    GValue *old = ghb_array_get_nth(queue, ii);
                    ghb_value_free(old);
                    ghb_array_remove(queue, ii);
                }
            }
            count = ghb_array_len(queue);
            for (ii = 0; ii < count; ii++)
            {
                settings = ghb_array_get_nth(queue, ii);
                ghb_settings_set_int(settings, "job_unique_id", 0);
                ghb_settings_set_int(settings, "job_status", GHB_QUEUE_PENDING);
                add_to_queue_list(ud, settings, NULL);
            }
            ghb_queue_buttons_grey(ud);
            ghb_save_queue(ud->queue);
        }
        else
        {
            ghb_value_free(queue);
        }
        g_free(message);
    }
    return FALSE;
}
void
ghb_set_pref_audio_settings(gint titleindex, GValue *settings)
{
    gint track;
    gchar *source_lang;
    hb_audio_config_t *aconfig;
    GHashTable *track_indices;
    gint mux;

    const GValue *pref_audio;
    const GValue *audio, *drc, *gain, *enable_qual;
    gint acodec, bitrate, mix;
    gdouble rate, quality;
    gint count, ii, list_count;
    
    g_debug("set_pref_audio");
    mux = ghb_settings_combo_int(settings, "FileFormat");
    track_indices = g_hash_table_new_full(g_int_hash, g_int_equal, 
                        free_audio_hash_key_value, free_audio_hash_key_value);
    // Clear the audio list
    ghb_clear_audio_list_settings(settings);

    // Find "best" audio based on audio preferences
    if (!ghb_settings_get_boolean(settings, "AudioDUB"))
    {
        source_lang = g_strdup(ghb_get_source_audio_lang(titleindex, 0));
    }
    else
    {
        source_lang = ghb_settings_get_string(settings, "PreferredLanguage");
    }

    pref_audio = ghb_settings_get_value(settings, "AudioList");

    list_count = 0;
    count = ghb_array_len(pref_audio);
    for (ii = 0; ii < count; ii++)
    {
        gint select_acodec;
        gint fallback;

        audio = ghb_array_get_nth(pref_audio, ii);
        acodec = ghb_settings_combo_int(audio, "AudioEncoder");
        fallback = ghb_select_fallback(settings, mux, acodec);
        gint copy_mask = ghb_get_copy_mask(settings);
        select_acodec = ghb_select_audio_codec(mux, NULL, acodec, fallback, copy_mask);
        bitrate = ghb_settings_combo_int(audio, "AudioBitrate");
        rate = ghb_settings_combo_double(audio, "AudioSamplerate");
        mix = ghb_settings_combo_int(audio, "AudioMixdown");
        drc = ghb_settings_get_value(audio, "AudioTrackDRCSlider");
        gain = ghb_settings_get_value(audio, "AudioTrackGain");
        enable_qual = ghb_settings_get_value(audio, "AudioTrackQualityEnable");
        quality = ghb_settings_get_double(audio, "AudioTrackQuality");
        // If there are multiple audios using the same codec, then
        // select sequential tracks for each.  The hash keeps track 
        // of the tracks used for each codec.
        track = ghb_find_audio_track(titleindex, source_lang, 
                                select_acodec, fallback, track_indices);
        // Check to see if:
        // 1. pref codec is passthru
        // 2. source codec is not passthru
        // 3. next pref is enabled
        aconfig = ghb_get_scan_audio_info(titleindex, track);
        if (aconfig && ghb_audio_is_passthru (acodec))
        {
            // HB_ACODEC_* are bit fields.  Treat acodec as mask
            if (!(aconfig->in.codec & select_acodec & HB_ACODEC_PASS_MASK))
            {
                if (acodec != HB_ACODEC_AUTO_PASS)
                    acodec = fallback;
                // If we can't substitute the passthru with a suitable
                // encoder and
                // If there's more audio to process, or we've already
                // placed one in the list, then we can skip this one
                if (!(select_acodec & fallback) && 
                    ((ii + 1 < count) || (list_count != 0)))
                {
                    // Skip this audio
                    acodec = 0;
                }
            }
            else
            {
                select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG;
            }
        }
        if (titleindex >= 0 && track < 0)
            acodec = 0;
        if (acodec != 0)
        {
            GValue *asettings = ghb_dict_value_new();
            ghb_settings_set_int(asettings, "AudioTrack", track);
            ghb_settings_set_string(asettings, "AudioEncoder", 
                ghb_lookup_combo_string("AudioEncoder", ghb_int_value(acodec)));
            ghb_settings_set_value(asettings, "AudioEncoderActual", 
                                    ghb_lookup_audio_encoder_value(select_acodec));
            ghb_settings_set_value(asettings, "AudioTrackQualityEnable", enable_qual);
            ghb_settings_set_double(asettings, "AudioTrackQuality", quality);

            // This gets set autimatically if the codec is passthru
            ghb_settings_set_string(asettings, "AudioBitrate",
                ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate)));
            ghb_settings_set_string(asettings, "AudioSamplerate",
                ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(rate)));
            mix = ghb_get_best_mix( aconfig, select_acodec, mix);
            ghb_settings_set_string(asettings, "AudioMixdown",
                ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
            ghb_settings_set_value(asettings, "AudioTrackDRCSlider", drc);
            ghb_settings_set_value(asettings, "AudioTrackGain", gain);
            ghb_sanitize_audio(settings, asettings);
            ghb_add_audio_to_settings(settings, asettings);
        }
    }
    g_free(source_lang);
    g_hash_table_destroy(track_indices);
}