Commit 833ee6c7 authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

impl globalaudiochanneldescription stuff

parent 9619df98
......@@ -272,6 +272,10 @@ QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
int dev;
switch (type) {
case Phonon::AudioChannelType: {
list << GlobalAudioChannels::instance()->globalIndexes();
}
break;
case Phonon::AudioOutputDeviceType: {
deviceList = deviceManager()->audioOutputDevices();
for (dev = 0 ; dev < deviceList.size() ; ++dev)
......@@ -284,12 +288,6 @@ QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
list.append(deviceList[dev].id);
}
break;
case Phonon::VideoCaptureDeviceType: {
deviceList = deviceManager()->videoCaptureDevices();
for (dev = 0 ; dev < deviceList.size() ; ++dev)
list.append(deviceList[dev].id);
}
break;
case Phonon::EffectType: {
QList<EffectInfo *> effectList = effectManager()->effects();
for (int eff = 0; eff < effectList.size(); ++eff) {
......@@ -301,6 +299,12 @@ QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const
list << GlobalSubtitles::instance()->globalIndexes();
}
break;
case Phonon::VideoCaptureDeviceType: {
deviceList = deviceManager()->videoCaptureDevices();
for (dev = 0 ; dev < deviceList.size() ; ++dev)
list.append(deviceList[dev].id);
}
break;
}
return list;
......@@ -312,6 +316,12 @@ QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescripti
QList<DeviceInfo> deviceList;
switch (type) {
case Phonon::AudioChannelType: {
const AudioChannelDescription description = GlobalAudioChannels::instance()->fromIndex(index);
ret.insert("name", description.name());
ret.insert("description", description.description());
}
break;
case Phonon::AudioOutputDeviceType: {
deviceList = deviceManager()->audioOutputDevices();
if (index >= 0 && index < deviceList.size()) {
......@@ -335,19 +345,6 @@ QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescripti
}
}
break;
case Phonon::VideoCaptureDeviceType: {
deviceList = deviceManager()->videoCaptureDevices();
if (index >= 0 && index < deviceList.size()) {
ret.insert("name", deviceList[index].name);
ret.insert("description", deviceList[index].description);
ret.insert("icon", QLatin1String("camera-web"));
ret.insert("isAdvanced", deviceList[index].isAdvanced);
ret.insert("deviceAccessList", QVariant::fromValue<Phonon::DeviceAccessList>(deviceList[index].accessList));
if (deviceList[index].capabilities & DeviceInfo::AudioCapture)
ret.insert("hasaudio", true);
}
}
break;
case Phonon::EffectType: {
QList<EffectInfo *> effectList = effectManager()->effects();
if (index >= 0 && index <= effectList.size()) {
......@@ -367,6 +364,19 @@ QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescripti
ret.insert("type", description.property("type"));
}
break;
case Phonon::VideoCaptureDeviceType: {
deviceList = deviceManager()->videoCaptureDevices();
if (index >= 0 && index < deviceList.size()) {
ret.insert("name", deviceList[index].name);
ret.insert("description", deviceList[index].description);
ret.insert("icon", QLatin1String("camera-web"));
ret.insert("isAdvanced", deviceList[index].isAdvanced);
ret.insert("deviceAccessList", QVariant::fromValue<Phonon::DeviceAccessList>(deviceList[index].accessList));
if (deviceList[index].capabilities & DeviceInfo::AudioCapture)
ret.insert("hasaudio", true);
}
}
break;
}
return ret;
......
......@@ -38,12 +38,14 @@ MediaController::MediaController()
: m_player(0)
{
GlobalSubtitles::instance()->register_(this);
GlobalAudioChannels::instance()->register_(this);
resetMembers();
}
MediaController::~MediaController()
{
GlobalSubtitles::instance()->unregister_(this);
GlobalAudioChannels::instance()->unregister_(this);
}
bool MediaController::hasInterface(Interface iface) const
......@@ -206,7 +208,7 @@ void MediaController::resetMediaController()
void MediaController::resetMembers()
{
m_currentAudioChannel = Phonon::AudioChannelDescription();
m_availableAudioChannels.clear();
GlobalAudioChannels::self->clearListFor(this);
m_currentSubtitle = Phonon::SubtitleDescription();
GlobalSubtitles::instance()->clearListFor(this);
......@@ -227,17 +229,6 @@ void MediaController::resetMembers()
m_autoPlayTitles = false;
}
// Add audio channel -> in libvlc it is track, it means audio in another language
void MediaController::audioChannelAdded(int id, const QString &lang)
{
QHash<QByteArray, QVariant> properties;
properties.insert("name", lang);
properties.insert("description", "");
m_availableAudioChannels << Phonon::AudioChannelDescription(id, properties);
emit availableAudioChannelsChanged();
}
// Add title
void MediaController::titleAdded(int id, const QString &name)
{
......@@ -267,14 +258,15 @@ void MediaController::chapterAdded(int titleId, const QString &name)
void MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescription &audioChannel)
{
m_currentAudioChannel = audioChannel;
if (libvlc_audio_set_track(m_player, audioChannel.index())) {
const int localIndex = GlobalAudioChannels::instance()->localIdFor(this, audioChannel.index());
if (libvlc_audio_set_track(m_player, localIndex)) {
error() << "libVLC:" << LibVLC::errorMessage();
}
}
QList<Phonon::AudioChannelDescription> MediaController::availableAudioChannels() const
{
return m_availableAudioChannels;
return GlobalAudioChannels::instance()->listFor(this);
}
Phonon::AudioChannelDescription MediaController::currentAudioChannel() const
......@@ -285,14 +277,15 @@ Phonon::AudioChannelDescription MediaController::currentAudioChannel() const
void MediaController::refreshAudioChannels()
{
m_currentAudioChannel = Phonon::AudioChannelDescription();
m_availableAudioChannels.clear();
GlobalAudioChannels::instance()->clearListFor(this);
libvlc_track_description_t *p_info = libvlc_audio_get_track_description(m_player);
while (p_info) {
audioChannelAdded(p_info->i_id, p_info->psz_name);
GlobalAudioChannels::instance()->add(this, p_info->i_id, p_info->psz_name, "");
p_info = p_info->p_next;
}
libvlc_track_description_release(p_info);
emit availableAudioChannelsChanged();
}
// Subtitle
......@@ -314,7 +307,7 @@ void MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &subt
emit availableSubtitlesChanged();
}
} else {
int localIndex = GlobalSubtitles::instance()->localIdFor(this, subtitle.index());
const int localIndex = GlobalSubtitles::instance()->localIdFor(this, subtitle.index());
if (libvlc_video_set_spu(m_player, localIndex))
error() << "libVLC:" << LibVLC::errorMessage();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment