mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-18 20:40:43 +01:00
transcoder: Separate suitable element search from creation
Split best element type search from Transcoder::CreateElementForMimeType into new FindBestElementForMimeType method. This will allow the setting dialog to determine the encoder element type before the pipeline is built.
This commit is contained in:
parent
57a6fe4f20
commit
a98035d635
@ -77,15 +77,13 @@ struct SuitableElement {
|
|||||||
int rank_;
|
int rank_;
|
||||||
};
|
};
|
||||||
|
|
||||||
GstElement* Transcoder::CreateElementForMimeType(const QString& element_type,
|
SuitableElement Transcoder::FindBestElementForMimeType(
|
||||||
const QString& mime_type,
|
const QString& element_type, const QString& mime_type) {
|
||||||
GstElement* bin) {
|
if (element_type.isEmpty() || mime_type.isEmpty()) return SuitableElement();
|
||||||
if (mime_type.isEmpty()) return nullptr;
|
|
||||||
|
|
||||||
// HACK: Force mp4mux because it doesn't set any useful src caps
|
// HACK: Force mp4mux because it doesn't set any useful src caps
|
||||||
if (mime_type == "audio/mp4") {
|
if (mime_type == "audio/mp4") {
|
||||||
LogLine(QString("Using '%1' (rank %2)").arg("mp4mux").arg(-1));
|
return SuitableElement("mp4mux", -1);
|
||||||
return CreateElement("mp4mux", bin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of all the suitable elements we find and figure out which
|
// Keep track of all the suitable elements we find and figure out which
|
||||||
@ -136,11 +134,21 @@ GstElement* Transcoder::CreateElementForMimeType(const QString& element_type,
|
|||||||
gst_plugin_feature_list_free(features);
|
gst_plugin_feature_list_free(features);
|
||||||
gst_caps_unref(target_caps);
|
gst_caps_unref(target_caps);
|
||||||
|
|
||||||
if (suitable_elements_.isEmpty()) return nullptr;
|
if (suitable_elements_.isEmpty()) return SuitableElement();
|
||||||
|
|
||||||
// Sort by rank
|
// Sort by rank
|
||||||
std::sort(suitable_elements_.begin(), suitable_elements_.end());
|
std::sort(suitable_elements_.begin(), suitable_elements_.end());
|
||||||
const SuitableElement& best = suitable_elements_.last();
|
return suitable_elements_.last();
|
||||||
|
}
|
||||||
|
|
||||||
|
GstElement* Transcoder::CreateElementForMimeType(const QString& element_type,
|
||||||
|
const QString& mime_type,
|
||||||
|
GstElement* bin) {
|
||||||
|
SuitableElement best = FindBestElementForMimeType(element_type, mime_type);
|
||||||
|
if (best.name_.isEmpty()) {
|
||||||
|
LogLine(tr("Suitable element not found"));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));
|
LogLine(QString("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
#include "engines/gstpipelinebase.h"
|
#include "engines/gstpipelinebase.h"
|
||||||
|
|
||||||
|
struct SuitableElement;
|
||||||
|
|
||||||
struct TranscoderPreset {
|
struct TranscoderPreset {
|
||||||
TranscoderPreset() : type_(Song::Type_Unknown) {}
|
TranscoderPreset() : type_(Song::Type_Unknown) {}
|
||||||
TranscoderPreset(Song::FileType type, const QString& name,
|
TranscoderPreset(Song::FileType type, const QString& name,
|
||||||
@ -135,6 +137,9 @@ class Transcoder : public QObject {
|
|||||||
GstElement* bin = nullptr);
|
GstElement* bin = nullptr);
|
||||||
void SetElementProperties(const QString& name, GObject* element);
|
void SetElementProperties(const QString& name, GObject* element);
|
||||||
|
|
||||||
|
static SuitableElement FindBestElementForMimeType(const QString& element_type,
|
||||||
|
const QString& mime_type);
|
||||||
|
|
||||||
static void NewPadCallback(GstElement*, GstPad* pad, gpointer data);
|
static void NewPadCallback(GstElement*, GstPad* pad, gpointer data);
|
||||||
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg,
|
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
Loading…
Reference in New Issue
Block a user