EngineBase: Remove PluginDetails
This commit is contained in:
parent
c6e62b3263
commit
c3534affdb
|
@ -154,14 +154,6 @@ class Base : public QObject {
|
|||
void VolumeChanged(const uint volume);
|
||||
|
||||
protected:
|
||||
|
||||
struct PluginDetails {
|
||||
QString name;
|
||||
QString description;
|
||||
QString iconname;
|
||||
};
|
||||
using PluginDetailsList = QList<PluginDetails>;
|
||||
|
||||
EngineType type_;
|
||||
bool volume_control_;
|
||||
uint volume_;
|
||||
|
|
|
@ -402,23 +402,30 @@ EngineBase::OutputDetailsList GstEngine::GetOutputsList() const {
|
|||
|
||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
||||
|
||||
PluginDetailsList plugins = GetPluginList("Sink/Audio");
|
||||
EngineBase::OutputDetailsList ret;
|
||||
ret.reserve(plugins.count());
|
||||
for (const PluginDetails &plugin : plugins) {
|
||||
OutputDetails output;
|
||||
output.name = plugin.name;
|
||||
output.description = plugin.description;
|
||||
if (plugin.name == kAutoSink) output.iconname = "soundcard";
|
||||
else if (plugin.name == kALSASink || plugin.name == kOSS4Sink) output.iconname = "alsa";
|
||||
else if (plugin.name == kJackAudioSink) output.iconname = "jack";
|
||||
else if (plugin.name == kPulseSink) output.iconname = "pulseaudio";
|
||||
else if (plugin.name == kA2DPSink || plugin.name == kAVDTPSink) output.iconname = "bluetooth";
|
||||
else output.iconname = "soundcard";
|
||||
ret.append(output);
|
||||
OutputDetailsList outputs;
|
||||
|
||||
GstRegistry *registry = gst_registry_get();
|
||||
GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY);
|
||||
for (GList *future = features; future; future = g_list_next(future)) {
|
||||
GstElementFactory *factory = GST_ELEMENT_FACTORY(future->data);
|
||||
const gchar *metadata = gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_KLASS);
|
||||
if (strcasecmp(metadata, "Sink/Audio") == 0) {
|
||||
OutputDetails output;
|
||||
output.name = QString::fromUtf8(gst_plugin_feature_get_name(future->data));
|
||||
output.description = QString::fromUtf8(gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_DESCRIPTION));
|
||||
if (output.name == kAutoSink) output.iconname = "soundcard";
|
||||
else if (output.name == kALSASink || output.name == kOSS4Sink) output.iconname = "alsa";
|
||||
else if (output.name == kJackAudioSink) output.iconname = "jack";
|
||||
else if (output.name == kPulseSink) output.iconname = "pulseaudio";
|
||||
else if (output.name == kA2DPSink || output.name == kAVDTPSink) output.iconname = "bluetooth";
|
||||
else output.iconname = "soundcard";
|
||||
outputs << output;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
gst_plugin_feature_list_free(features);
|
||||
|
||||
return outputs;
|
||||
|
||||
}
|
||||
|
||||
|
@ -426,8 +433,8 @@ bool GstEngine::ValidOutput(const QString &output) {
|
|||
|
||||
EnsureInitialized();
|
||||
|
||||
PluginDetailsList plugins = GetPluginList("Sink/Audio");
|
||||
return std::any_of(plugins.begin(), plugins.end(), [output](const PluginDetails &plugin) { return plugin.name == output; });
|
||||
const OutputDetailsList output_details = GetOutputsList();
|
||||
return std::any_of(output_details.begin(), output_details.end(), [output](const OutputDetails &output_detail) { return output_detail.name == output; });
|
||||
|
||||
}
|
||||
|
||||
|
@ -687,36 +694,6 @@ void GstEngine::BufferingFinished() {
|
|||
|
||||
}
|
||||
|
||||
GstEngine::PluginDetailsList GstEngine::GetPluginList(const QString &classname) const {
|
||||
|
||||
const_cast<GstEngine*>(this)->EnsureInitialized();
|
||||
|
||||
PluginDetailsList ret;
|
||||
|
||||
GstRegistry *registry = gst_registry_get();
|
||||
GList *const features = gst_registry_get_feature_list(registry, GST_TYPE_ELEMENT_FACTORY);
|
||||
|
||||
GList *p = features;
|
||||
while (p) {
|
||||
GstElementFactory *factory = GST_ELEMENT_FACTORY(p->data);
|
||||
if (QString(gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_KLASS)).contains(classname)) {
|
||||
PluginDetails details;
|
||||
details.name = QString::fromUtf8(gst_plugin_feature_get_name(p->data));
|
||||
details.description = QString::fromUtf8(gst_element_factory_get_metadata(factory, GST_ELEMENT_METADATA_DESCRIPTION));
|
||||
if (details.name == "wasapi2sink" && details.description == "Stream audio to an audio capture device through WASAPI") {
|
||||
details.description += " 2";
|
||||
}
|
||||
ret << details;
|
||||
//qLog(Debug) << details.name << details.description;
|
||||
}
|
||||
p = g_list_next(p);
|
||||
}
|
||||
|
||||
gst_plugin_feature_list_free(features);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
QByteArray GstEngine::FixupUrl(const QUrl &url) {
|
||||
|
||||
EnsureInitialized();
|
||||
|
|
|
@ -123,7 +123,6 @@ class GstEngine : public Engine::Base, public GstBufferConsumer {
|
|||
void BufferingFinished();
|
||||
|
||||
private:
|
||||
PluginDetailsList GetPluginList(const QString &classname) const;
|
||||
QByteArray FixupUrl(const QUrl &url);
|
||||
|
||||
void StartFadeout();
|
||||
|
|
|
@ -219,30 +219,35 @@ qint64 VLCEngine::length_nanosec() const {
|
|||
|
||||
EngineBase::OutputDetailsList VLCEngine::GetOutputsList() const {
|
||||
|
||||
PluginDetailsList plugins = GetPluginList();
|
||||
OutputDetailsList ret;
|
||||
ret.reserve(plugins.count());
|
||||
for (const PluginDetails &plugin : plugins) {
|
||||
OutputDetails output;
|
||||
output.name = plugin.name;
|
||||
output.description = plugin.description;
|
||||
if (plugin.name == "auto") output.iconname = "soundcard";
|
||||
else if ((plugin.name == "alsa")||(plugin.name == "oss")) output.iconname = "alsa";
|
||||
else if (plugin.name== "jack") output.iconname = "jack";
|
||||
else if (plugin.name == "pulse") output.iconname = "pulseaudio";
|
||||
else if (plugin.name == "afile") output.iconname = "document-new";
|
||||
else output.iconname = "soundcard";
|
||||
ret.append(output);
|
||||
}
|
||||
OutputDetailsList outputs;
|
||||
OutputDetails output_auto;
|
||||
output_auto.name = "auto";
|
||||
output_auto.description = "Automatically detected";
|
||||
outputs << output_auto;
|
||||
|
||||
return ret;
|
||||
libvlc_audio_output_t *audio_output_list = libvlc_audio_output_list_get(instance_);
|
||||
for (libvlc_audio_output_t *audio_output = audio_output_list; audio_output; audio_output = audio_output->p_next) {
|
||||
OutputDetails output;
|
||||
output.name = QString::fromUtf8(audio_output->psz_name);
|
||||
output.description = QString::fromUtf8(audio_output->psz_description);
|
||||
if (output.name == "auto") output.iconname = "soundcard";
|
||||
else if ((output.name == "alsa")||(output.name == "oss")) output.iconname = "alsa";
|
||||
else if (output.name== "jack") output.iconname = "jack";
|
||||
else if (output.name == "pulse") output.iconname = "pulseaudio";
|
||||
else if (output.name == "afile") output.iconname = "document-new";
|
||||
else output.iconname = "soundcard";
|
||||
outputs << output;
|
||||
}
|
||||
libvlc_audio_output_list_release(audio_output_list);
|
||||
|
||||
return outputs;
|
||||
|
||||
}
|
||||
|
||||
bool VLCEngine::ValidOutput(const QString &output) {
|
||||
|
||||
PluginDetailsList plugins = GetPluginList();
|
||||
return std::any_of(plugins.begin(), plugins.end(), [output](const PluginDetails &plugin) { return plugin.name == output; });
|
||||
const OutputDetailsList output_details = GetOutputsList();
|
||||
return std::any_of(output_details.begin(), output_details.end(), [output](const OutputDetails &output_detail) { return output_detail.name == output; });
|
||||
|
||||
}
|
||||
|
||||
|
@ -324,32 +329,6 @@ void VLCEngine::StateChangedCallback(const libvlc_event_t *e, void *data) {
|
|||
|
||||
}
|
||||
|
||||
EngineBase::PluginDetailsList VLCEngine::GetPluginList() const {
|
||||
|
||||
PluginDetailsList ret;
|
||||
libvlc_audio_output_t *audio_output_list = libvlc_audio_output_list_get(instance_);
|
||||
|
||||
{
|
||||
PluginDetails details;
|
||||
details.name = "auto";
|
||||
details.description = "Automatically detected";
|
||||
ret << details;
|
||||
}
|
||||
|
||||
for (libvlc_audio_output_t *audio_output = audio_output_list; audio_output; audio_output = audio_output->p_next) {
|
||||
PluginDetails details;
|
||||
details.name = QString::fromUtf8(audio_output->psz_name);
|
||||
details.description = QString::fromUtf8(audio_output->psz_description);
|
||||
ret << details;
|
||||
//GetDevicesList(audio_output->psz_name);
|
||||
}
|
||||
|
||||
libvlc_audio_output_list_release(audio_output_list);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
void VLCEngine::GetDevicesList(const QString &output) const {
|
||||
|
||||
Q_UNUSED(output);
|
||||
|
|
|
@ -79,7 +79,6 @@ class VLCEngine : public Engine::Base {
|
|||
void AttachCallback(libvlc_event_manager_t *em, libvlc_event_type_t type, libvlc_callback_t callback);
|
||||
static void StateChangedCallback(const libvlc_event_t *e, void *data);
|
||||
|
||||
PluginDetailsList GetPluginList() const;
|
||||
void GetDevicesList(const QString &output) const;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue