"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/backend-vlc/vlcmediawidget.cpp" between
kaffeine-2.0.16.tar.gz and kaffeine-2.0.17.tar.gz

About: Kaffeine is a full featured Multimedia-Player for KDE (default backend is xine).

vlcmediawidget.cpp  (kaffeine-2.0.16):vlcmediawidget.cpp  (kaffeine-2.0.17)
skipping to change at line 33 skipping to change at line 33
#include <QApplication> #include <QApplication>
#include <QCursor> #include <QCursor>
#include <QMouseEvent> #include <QMouseEvent>
#include <QTimer> #include <QTimer>
#include <QMap> #include <QMap>
#include <vlc/libvlc_version.h> #include <vlc/libvlc_version.h>
#include "../configuration.h" #include "../configuration.h"
#include "vlcmediawidget.h" #include "vlcmediawidget.h"
VlcMediaWidget::VlcMediaWidget(QWidget *parent) : AbstractMediaWidget(parent), v const char *vlcEventName(int event)
lcInstance(NULL),
vlcMediaPlayer(NULL), playingDvd(false)
{ {
switch (event) {
case libvlc_MediaMetaChanged:
return "MediaMetaChanged";
case libvlc_MediaPlayerEncounteredError:
return "MediaPlayerEncounteredError";
case libvlc_MediaPlayerEndReached:
return "MediaPlayerEndReached";
case libvlc_MediaPlayerLengthChanged:
return "MediaPlayerLengthChanged";
case libvlc_MediaPlayerSeekableChanged:
return "MediaPlayerSeekableChanged";
case libvlc_MediaPlayerStopped:
return "MediaPlayerStopped";
case libvlc_MediaPlayerTimeChanged:
return "MediaPlayerTimeChanged";
case libvlc_MediaSubItemAdded:
return "MediaSubItemAdded";
case libvlc_MediaDurationChanged:
return "MediaDurationChanged";
case libvlc_MediaParsedChanged:
return "MediaParsedChanged";
case libvlc_MediaFreed:
return "MediaFreed";
case libvlc_MediaStateChanged:
return "MediaStateChanged";
case libvlc_MediaSubItemTreeAdded:
return "MediaSubItemTreeAdded";
case libvlc_MediaPlayerMediaChanged:
return "MediaPlayerMediaChanged";
case libvlc_MediaPlayerNothingSpecial:
return "MediaPlayerNothingSpecial";
case libvlc_MediaPlayerOpening:
return "MediaPlayerOpening";
case libvlc_MediaPlayerBuffering:
return "MediaPlayerBuffering";
case libvlc_MediaPlayerPlaying:
return "MediaPlayerPlaying";
case libvlc_MediaPlayerPaused:
return "MediaPlayerPaused";
case libvlc_MediaPlayerForward:
return "MediaPlayerForward";
case libvlc_MediaPlayerBackward:
return "MediaPlayerBackward";
case libvlc_MediaPlayerPositionChanged:
return "MediaPlayerPositionChanged";
case libvlc_MediaPlayerPausableChanged:
return "MediaPlayerPausableChanged";
case libvlc_MediaPlayerTitleChanged:
return "MediaPlayerTitleChanged";
case libvlc_MediaPlayerSnapshotTaken:
return "MediaPlayerSnapshotTaken";
case libvlc_MediaPlayerVout:
return "MediaPlayerVout";
case libvlc_MediaPlayerScrambledChanged:
return "MediaPlayerScrambledChanged";
case libvlc_MediaPlayerUncorked:
return "MediaPlayerUncorked";
case libvlc_MediaPlayerMuted:
return "MediaPlayerMuted";
case libvlc_MediaListItemAdded:
return "MediaListItemAdded";
case libvlc_MediaListWillAddItem:
return "MediaListWillAddItem";
case libvlc_MediaListItemDeleted:
return "MediaListItemDeleted";
case libvlc_MediaListWillDeleteItem:
return "MediaListWillDeleteItem";
case libvlc_MediaListViewItemAdded:
return "MediaListViewItemAdded";
case libvlc_MediaListViewWillAddItem:
return "MediaListViewWillAddItem";
case libvlc_MediaListViewItemDeleted:
return "MediaListViewItemDeleted";
case libvlc_MediaListViewWillDeleteItem:
return "MediaListViewWillDeleteItem";
case libvlc_MediaListPlayerPlayed:
return "MediaListPlayerPlayed";
case libvlc_MediaListPlayerNextItemSet:
return "MediaListPlayerNextItemSet";
case libvlc_MediaListPlayerStopped:
return "MediaListPlayerStopped";
case libvlc_RendererDiscovererItemAdded:
return "RendererDiscovererItemAdded";
case libvlc_RendererDiscovererItemDeleted:
return "RendererDiscovererItemDeleted";
case libvlc_VlmMediaAdded:
return "VlmMediaAdded";
case libvlc_VlmMediaRemoved:
return "VlmMediaRemoved";
case libvlc_VlmMediaChanged:
return "VlmMediaChanged";
case libvlc_VlmMediaInstanceStarted:
return "VlmMediaInstanceStarted";
case libvlc_VlmMediaInstanceStopped:
return "VlmMediaInstanceStopped";
case libvlc_VlmMediaInstanceStatusInit:
return "VlmMediaInstanceStatusInit";
case libvlc_VlmMediaInstanceStatusOpening:
return "VlmMediaInstanceStatusOpening";
case libvlc_VlmMediaInstanceStatusPlaying:
return "VlmMediaInstanceStatusPlaying";
case libvlc_VlmMediaInstanceStatusPause:
return "VlmMediaInstanceStatusPause";
case libvlc_VlmMediaInstanceStatusEnd:
return "VlmMediaInstanceStatusEnd";
case libvlc_VlmMediaInstanceStatusError:
return "VlmMediaInstanceStatusError";
#if LIBVLC_VERSION_MAJOR > 2
case libvlc_MediaPlayerAudioVolume:
return "MediaPlayerAudioVolume";
case libvlc_MediaPlayerAudioDevice:
return "MediaPlayerAudioDevice";
case libvlc_MediaListEndReached:
return "MediaListEndReached";
case libvlc_MediaPlayerChapterChanged:
return "MediaPlayerChapterChanged";
case libvlc_MediaPlayerESAdded:
return "MediaPlayerESAdded";
case libvlc_MediaPlayerESDeleted:
return "MediaPlayerESDeleted";
case libvlc_MediaPlayerESSelected:
return "MediaPlayerESSelected";
case libvlc_MediaPlayerCorked:
return "MediaPlayerCorked";
case libvlc_MediaPlayerUnmuted:
return "MediaPlayerUnmuted";
#endif
default:
return "Unknown";
}
}
VlcMediaWidget::VlcMediaWidget(QWidget *parent) : AbstractMediaWidget(parent),
timer(NULL), vlcInstance(NULL), vlcMedia(NULL), vlcMediaPlayer(NULL),
isPaused(false), playingDvd(false), urlIsAudioCd(false),
typeOfDevice(""), trackNumber(1), numTracks(1)
{
libvlc_event_e events[] = {
libvlc_MediaMetaChanged,
libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerEndReached,
libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerSeekableChanged,
libvlc_MediaPlayerStopped,
#if LIBVLC_VERSION_MAJOR > 2
libvlc_MediaPlayerESAdded,
libvlc_MediaPlayerESDeleted,
#endif
libvlc_MediaPlayerTimeChanged,
#if 0 // all other possible events
libvlc_MediaSubItemAdded,
libvlc_MediaDurationChanged,
libvlc_MediaParsedChanged,
libvlc_MediaFreed,
libvlc_MediaStateChanged,
libvlc_MediaSubItemTreeAdded,
libvlc_MediaPlayerMediaChanged,
libvlc_MediaPlayerNothingSpecial,
libvlc_MediaPlayerOpening,
libvlc_MediaPlayerBuffering,
libvlc_MediaPlayerPlaying,
libvlc_MediaPlayerPaused,
libvlc_MediaPlayerForward,
libvlc_MediaPlayerBackward,
libvlc_MediaPlayerPositionChanged,
libvlc_MediaPlayerPausableChanged,
libvlc_MediaPlayerTitleChanged,
libvlc_MediaPlayerSnapshotTaken,
libvlc_MediaPlayerVout,
libvlc_MediaPlayerScrambledChanged,
libvlc_MediaPlayerUncorked,
libvlc_MediaPlayerMuted,
libvlc_MediaListItemAdded,
libvlc_MediaListWillAddItem,
libvlc_MediaListItemDeleted,
libvlc_MediaListWillDeleteItem,
libvlc_MediaListViewItemAdded,
libvlc_MediaListViewWillAddItem,
libvlc_MediaListViewItemDeleted,
libvlc_MediaListViewWillDeleteItem,
libvlc_MediaListPlayerPlayed,
libvlc_MediaListPlayerNextItemSet,
libvlc_MediaListPlayerStopped,
libvlc_VlmMediaAdded,
libvlc_VlmMediaRemoved,
libvlc_VlmMediaChanged,
libvlc_VlmMediaInstanceStarted,
libvlc_VlmMediaInstanceStopped,
libvlc_VlmMediaInstanceStatusInit,
libvlc_VlmMediaInstanceStatusOpening,
libvlc_VlmMediaInstanceStatusPlaying,
libvlc_VlmMediaInstanceStatusPause,
libvlc_VlmMediaInstanceStatusEnd,
libvlc_VlmMediaInstanceStatusError,
#if LIBVLC_VERSION_MAJOR > 2
libvlc_MediaListEndReached,
libvlc_MediaPlayerAudioDevice,
libvlc_MediaPlayerAudioVolume,
libvlc_MediaPlayerChapterChanged,
libvlc_MediaPlayerESSelected,
libvlc_MediaPlayerCorked,
libvlc_MediaPlayerUnmuted,
libvlc_RendererDiscovererItemAdded,
libvlc_RendererDiscovererItemDeleted,
#endif /*LIBVLC_VERSION_MAJOR */
#endif
};
for (uint i = 0; i < (sizeof(events) / sizeof(events[0])); ++i)
eventType.append(events[i]);
} }
bool VlcMediaWidget::init() bool VlcMediaWidget::init()
{ {
QString args = Configuration::instance()->getLibVlcArguments(); QString args = Configuration::instance()->getLibVlcArguments();
QStringList argList; QStringList argList;
int argc = 0, size; int argc = 0, size;
argList = args.split(' ', QString::SkipEmptyParts); argList = args.split(' ', QString::SkipEmptyParts);
size = argList.size(); size = argList.size();
skipping to change at line 86 skipping to change at line 296
} }
delete[] argv; delete[] argv;
vlcMediaPlayer = libvlc_media_player_new(vlcInstance); vlcMediaPlayer = libvlc_media_player_new(vlcInstance);
if (vlcMediaPlayer == NULL) { if (vlcMediaPlayer == NULL) {
qFatal("Cannot create vlc media player %s", qPrintable(libvlc_err msg())); qFatal("Cannot create vlc media player %s", qPrintable(libvlc_err msg()));
return false; return false;
} }
libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager( eventManager = libvlc_media_player_event_manager(vlcMediaPlayer);
vlcMediaPlayer);
libvlc_event_e eventTypes[] = { libvlc_MediaPlayerEncounteredError,
libvlc_MediaPlayerEndReached, libvlc_MediaPlayerLengthChanged,
libvlc_MediaPlayerSeekableChanged, libvlc_MediaPlayerStopped,
#if LIBVLC_VERSION_MAJOR > 2
libvlc_MediaPlayerESAdded, libvlc_MediaPlayerESDeleted,
#endif
libvlc_MediaPlayerTimeChanged };
for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) { if (!registerEvents())
if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHand return false;
ler, this) != 0) {
qCCritical(logMediaWidget, "Cannot attach event handler %
d", eventTypes[i]);
return false;
}
}
timer = new QTimer(); timer = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(hideMouse())); connect(timer, SIGNAL(timeout()), this, SLOT(hideMouse()));
libvlc_media_player_set_xwindow(vlcMediaPlayer, quint32(winId())); libvlc_media_player_set_xwindow(vlcMediaPlayer, quint32(winId()));
setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_NativeWindow);
libvlc_audio_set_mute(vlcMediaPlayer, false); libvlc_audio_set_mute(vlcMediaPlayer, false);
// This is broken on qt5: the kernel/qwidget.cpp tries to repaint // This is broken on qt5: the kernel/qwidget.cpp tries to repaint
// on a wrong place, causing this warning: // on a wrong place, causing this warning:
// QWidget::paintEngine: Should no longer be called // QWidget::paintEngine: Should no longer be called
// setAttribute(Qt::WA_PaintOnScreen); // setAttribute(Qt::WA_PaintOnScreen);
return true; return true;
} }
VlcMediaWidget::~VlcMediaWidget() VlcMediaWidget::~VlcMediaWidget()
{ {
if (vlcMediaPlayer != NULL) { metadata.clear();
libvlc_media_player_release(vlcMediaPlayer); audioStreams.clear();
subtitles.clear();
subtitleId.clear();
if (timer != NULL) {
timer->stop();
delete timer;
} }
if (vlcInstance != NULL) { unregisterEvents();
if (vlcMedia != NULL)
libvlc_media_release(vlcMedia);
if (vlcInstance != NULL)
libvlc_release(vlcInstance); libvlc_release(vlcInstance);
}
if (vlcMediaPlayer != NULL)
libvlc_media_player_release(vlcMediaPlayer);
} }
VlcMediaWidget *VlcMediaWidget::createVlcMediaWidget(QWidget *parent) VlcMediaWidget *VlcMediaWidget::createVlcMediaWidget(QWidget *parent)
{ {
QScopedPointer<VlcMediaWidget> vlcMediaWidget(new VlcMediaWidget(parent)) ; QScopedPointer<VlcMediaWidget> vlcMediaWidget(new VlcMediaWidget(parent)) ;
if (!vlcMediaWidget->init()) { if (!vlcMediaWidget->init()) {
return NULL; return NULL;
} }
skipping to change at line 323 skipping to change at line 535
} }
playingDvd = true; playingDvd = true;
break; break;
case MediaSource::Dvb: case MediaSource::Dvb:
break; break;
} }
typeOfDevice = url.constData(); typeOfDevice = url.constData();
if (vlcMedia != NULL) {
libvlc_media_player_stop(vlcMediaPlayer);
libvlc_media_release(vlcMedia);
}
vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice); vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
if (urlIsAudioCd) if (urlIsAudioCd)
libvlc_media_add_option(vlcMedia, "cdda-track=1"); libvlc_media_add_option(vlcMedia, "cdda-track=1");
if (makePlay() < 0) { if (makePlay() < 0) {
stop(); stop();
return; return;
} }
setCursor(Qt::BlankCursor); setCursor(Qt::BlankCursor);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
timer->start(1000); timer->start(1000);
setMouseTracking(true); setMouseTracking(true);
} }
void VlcMediaWidget::unregisterEvents()
{
for (int i = 0; i < eventType.size(); ++i)
libvlc_event_detach(eventManager, eventType.at(i),
vlcEventHandler, this);
}
bool VlcMediaWidget::registerEvents()
{
for (int i = 0; i < eventType.size(); ++i) {
if (libvlc_event_attach(eventManager, eventType.at(i), vlcEventHa
ndler, this) != 0) {
qCCritical(logMediaWidget, "Cannot attach event handler %
d", eventType.at(i));
return false;
}
}
return true;
}
int VlcMediaWidget::makePlay() int VlcMediaWidget::makePlay()
{ {
if (vlcMedia == NULL) { if (vlcMedia == NULL) {
libvlc_media_player_stop(vlcMediaPlayer); libvlc_media_player_stop(vlcMediaPlayer);
return -1; return -1;
} }
libvlc_event_manager_t *eventManager = libvlc_media_event_manager(vlcMedi
a);
libvlc_event_e eventTypes[] = { libvlc_MediaMetaChanged };
for (uint i = 0; i < (sizeof(eventTypes) / sizeof(eventTypes[0])); ++i) {
if (libvlc_event_attach(eventManager, eventTypes[i], vlcEventHand
ler, this) != 0) {
qCWarning(logMediaWidget, "Cannot attach event handler %d
", eventTypes[i]);
}
}
libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia); libvlc_media_player_set_media(vlcMediaPlayer, vlcMedia);
libvlc_media_release(vlcMedia);
vlcMedia = NULL;
/* /*
* FIXME: This is mostly a boilerplate as, at least with vlc 3, * FIXME: This is mostly a boilerplate as, at least with vlc 3,
* this function always return -1 * this function always return -1
*/ */
if (urlIsAudioCd) if (urlIsAudioCd)
numTracks = libvlc_audio_get_track_count(vlcMediaPlayer); numTracks = libvlc_audio_get_track_count(vlcMediaPlayer);
return libvlc_media_player_play(vlcMediaPlayer); return libvlc_media_player_play(vlcMediaPlayer);
} }
skipping to change at line 386 skipping to change at line 610
else else
trackNumber++; trackNumber++;
if (numTracks > 0 && trackNumber > numTracks) if (numTracks > 0 && trackNumber > numTracks)
trackNumber = numTracks; trackNumber = numTracks;
if (trackNumber < 1) if (trackNumber < 1)
trackNumber = 1; trackNumber = 1;
strBuf += QString::number(trackNumber); strBuf += QString::number(trackNumber);
if (vlcMedia != NULL) if (vlcMedia != NULL) {
libvlc_media_player_stop(vlcMediaPlayer);
libvlc_media_release(vlcMedia); libvlc_media_release(vlcMedia);
}
vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice); vlcMedia = libvlc_media_new_location(vlcInstance, typeOfDevice);
libvlc_media_add_option(vlcMedia, strBuf.toUtf8()); libvlc_media_add_option(vlcMedia, strBuf.toUtf8());
if (makePlay() < 0) if (makePlay() < 0)
stop(); stop();
do { do {
state = libvlc_media_player_get_state (vlcMediaPlayer); state = libvlc_media_player_get_state (vlcMediaPlayer);
} while(state != libvlc_Playing && } while(state != libvlc_Playing &&
skipping to change at line 411 skipping to change at line 637
if (state != libvlc_Playing) { if (state != libvlc_Playing) {
stop(); stop();
trackNumber = oldTrackNumber; trackNumber = oldTrackNumber;
} }
} }
void VlcMediaWidget::stop() void VlcMediaWidget::stop()
{ {
libvlc_media_player_stop(vlcMediaPlayer); libvlc_media_player_stop(vlcMediaPlayer);
if (vlcMedia != NULL) {
libvlc_media_release(vlcMedia);
vlcMedia = NULL;
}
timer->stop(); timer->stop();
setCursor(Qt::BlankCursor); setCursor(Qt::BlankCursor);
setCursor(Qt::ArrowCursor); setCursor(Qt::ArrowCursor);
addPendingUpdates(PlaybackStatus); addPendingUpdates(PlaybackStatus | Metadata |
Subtitles | AudioStreams);
} }
void VlcMediaWidget::setPaused(bool paused) void VlcMediaWidget::setPaused(bool paused)
{ {
isPaused = paused; isPaused = paused;
libvlc_media_player_set_pause(vlcMediaPlayer, paused); libvlc_media_player_set_pause(vlcMediaPlayer, paused);
// we don't monitor playing / buffering / paused state changes // we don't monitor playing / buffering / paused state changes
addPendingUpdates(PlaybackStatus); addPendingUpdates(PlaybackStatus);
} }
void VlcMediaWidget::seek(int time) void VlcMediaWidget::seek(int time)
{ {
if (!seekable) if (!seekable)
return; return;
libvlc_media_player_set_time(vlcMediaPlayer, time); libvlc_media_player_set_time(vlcMediaPlayer, time);
} }
void VlcMediaWidget::setCurrentAudioStream(int currentAudioStream) void VlcMediaWidget::setCurrentAudioStream(int _currentAudioStream)
{ {
if (_currentAudioStream < 0 ||
_currentAudioStream > libvlc_audio_get_track(vlcMediaPlayer))
_currentAudioStream = 0;
// skip the 'deactivate' audio channel // skip the 'deactivate' audio channel
libvlc_audio_set_track(vlcMediaPlayer, currentAudioStream + 1); libvlc_audio_set_track(vlcMediaPlayer, _currentAudioStream + 1);
currentAudioStream = _currentAudioStream;
} }
void VlcMediaWidget::setCurrentSubtitle(int currentSubtitle) void VlcMediaWidget::setCurrentSubtitle(int currentSubtitle)
{ {
libvlc_track_description_t *tr, *track;
int requestedSubtitle = -1; int requestedSubtitle = -1;
QMap<int, int>::const_iterator i = subtitleId.constBegin(); QMap<int, int>::const_iterator i = subtitleId.constBegin();
while (i != subtitleId.constEnd()) { while (i != subtitleId.constEnd()) {
qCDebug(logVlc, "Subtitle #%d, key: %d", i.value(), i.key()); qCDebug(logVlc, "Subtitle #%d, key: %d", i.value(), i.key());
if (i.value() == currentSubtitle) { if (i.value() == currentSubtitle) {
requestedSubtitle = i.key(); requestedSubtitle = i.key();
break; break;
} }
i++; i++;
} }
qCDebug(logVlc, "Try to set subtitle #%d, id %d", currentSubtitle, reques tedSubtitle); qCDebug(logVlc, "Try to set subtitle #%d, id %d", currentSubtitle, reques tedSubtitle);
libvlc_video_set_spu(vlcMediaPlayer, requestedSubtitle); libvlc_video_set_spu(vlcMediaPlayer, requestedSubtitle);
/* Print what it was actually selected */ /* Print what it was actually selected */
libvlc_track_description_t *track = libvlc_video_get_spu_description(vlcM
ediaPlayer); tr = libvlc_video_get_spu_description(vlcMediaPlayer);
track = tr;
while (track != NULL) { while (track != NULL) {
QString subtitle = QString::fromUtf8(track->psz_name); QString subtitle = QString::fromUtf8(track->psz_name);
if (subtitle.isEmpty()) { if (subtitle.isEmpty()) {
subtitle = i18n("Subtitle %1", track->i_id); subtitle = i18n("Subtitle %1", track->i_id);
} }
if (track->i_id == requestedSubtitle) if (track->i_id == requestedSubtitle)
qCDebug(logVlc, "Subtitle set to id %d: %s", track->i_id, qPrintable(subtitle)); qCDebug(logVlc, "Subtitle set to id %d: %s", track->i_id, qPrintable(subtitle));
track = track->p_next; track = track->p_next;
} }
libvlc_track_description_list_release(track); libvlc_track_description_list_release(tr);
} }
void VlcMediaWidget::setExternalSubtitle(const QUrl &url) void VlcMediaWidget::setExternalSubtitle(const QUrl &url)
{ {
QString fname = url.toLocalFile(); QString fname = url.toLocalFile();
#if LIBVLC_VERSION_MAJOR > 2 #if LIBVLC_VERSION_MAJOR > 2
if (libvlc_media_player_add_slave(vlcMediaPlayer, if (libvlc_media_player_add_slave(vlcMediaPlayer,
libvlc_media_slave_type_subtitle, libvlc_media_slave_type_subtitle,
skipping to change at line 617 skipping to change at line 857
} }
} }
void VlcMediaWidget::updateSeekable() void VlcMediaWidget::updateSeekable()
{ {
seekable = libvlc_media_player_is_seekable(vlcMediaPlayer); seekable = libvlc_media_player_is_seekable(vlcMediaPlayer);
} }
void VlcMediaWidget::updateMetadata() void VlcMediaWidget::updateMetadata()
{ {
metadata.clear(); char *meta;
libvlc_media_t *media = libvlc_media_player_get_media(vlcMediaPlayer);
if (media != NULL) { metadata.clear();
metadata.insert(MediaWidget::Title, if (vlcMedia != NULL) {
QString::fromUtf8(libvlc_media_get_meta(media, libvlc_met QString s;
a_Title))); meta = libvlc_media_get_meta(vlcMedia, libvlc_meta_Title);
metadata.insert(MediaWidget::Artist, if (meta) {
QString::fromUtf8(libvlc_media_get_meta(media, libvlc_met metadata.insert(MediaWidget::Title, QString::fromUtf8(met
a_Artist))); a));
metadata.insert(MediaWidget::Album, free(meta);
QString::fromUtf8(libvlc_media_get_meta(media, libvlc_met }
a_Album))); meta = libvlc_media_get_meta(vlcMedia, libvlc_meta_Artist);
metadata.insert(MediaWidget::TrackNumber, if (meta) {
QString::fromUtf8(libvlc_media_get_meta(media, libvlc_met metadata.insert(MediaWidget::Artist, QString::fromUtf8(me
a_TrackNumber))); ta));
free(meta);
}
meta = libvlc_media_get_meta(vlcMedia, libvlc_meta_Album);
if (meta) {
metadata.insert(MediaWidget::Album, QString::fromUtf8(met
a));
free(meta);
}
meta = libvlc_media_get_meta(vlcMedia, libvlc_meta_TrackNumber);
if (meta) {
metadata.insert(MediaWidget::TrackNumber, QString::fromUt
f8(meta));
free(meta);
}
} }
if (urlIsAudioCd) if (urlIsAudioCd)
metadata.insert(MediaWidget::Title, metadata.insert(MediaWidget::Title,
i18n("CD track ") + QString::number(trackNumber)) ; i18n("CD track ") + QString::number(trackNumber)) ;
} }
void VlcMediaWidget::updateAudioStreams() void VlcMediaWidget::updateAudioStreams()
{ {
audioStreams.clear(); audioStreams.clear();
libvlc_track_description_t *track = libvlc_audio_get_track_description(vl libvlc_track_description_t *tr, *track;
cMediaPlayer);
tr = libvlc_audio_get_track_description(vlcMediaPlayer);
track = tr;
if (track != NULL) { if (track != NULL) {
// skip the 'deactivate' audio channel // skip the 'deactivate' audio channel
track = track->p_next; track = track->p_next;
} }
while (track != NULL) { while (track != NULL) {
QString audioStream = QString::fromUtf8(track->psz_name); QString audioStream = QString::fromUtf8(track->psz_name);
int cutBegin = (audioStream.indexOf(QLatin1Char('[')) + 1); int cutBegin = (audioStream.indexOf(QLatin1Char('[')) + 1);
skipping to change at line 666 skipping to change at line 922
} }
} }
if (audioStream.isEmpty()) { if (audioStream.isEmpty()) {
audioStream = QString::number(audioStreams.size() + 1); audioStream = QString::number(audioStreams.size() + 1);
} }
audioStreams.append(audioStream); audioStreams.append(audioStream);
track = track->p_next; track = track->p_next;
} }
libvlc_track_description_list_release(tr);
// skip the 'deactivate' audio channel // skip the 'deactivate' audio channel
currentAudioStream = (libvlc_audio_get_track(vlcMediaPlayer) - 1); currentAudioStream = (libvlc_audio_get_track(vlcMediaPlayer) - 1);
if (currentAudioStream < 0)
setCurrentAudioStream(0);
} }
void VlcMediaWidget::updateSubtitles() void VlcMediaWidget::updateSubtitles()
{ {
subtitles.clear(); libvlc_track_description_t *tr, *track;
libvlc_track_description_t *track = libvlc_video_get_spu_description(vlcM
ediaPlayer);
int i = 0; int i = 0;
subtitles.clear();
subtitleId.clear(); subtitleId.clear();
tr = libvlc_video_get_spu_description(vlcMediaPlayer);
track = tr;
if (track != NULL) { if (track != NULL) {
// skip the 'deactivate' subtitle // skip the 'deactivate' subtitle
track = track->p_next; track = track->p_next;
} }
while (track != NULL) { while (track != NULL) {
QString subtitle = QString::fromUtf8(track->psz_name); QString subtitle = QString::fromUtf8(track->psz_name);
if (subtitle.isEmpty()) { if (subtitle.isEmpty()) {
subtitle = i18n("Subtitle %1", track->i_id); subtitle = i18n("Subtitle %1", track->i_id);
} }
// 0 is reserved for "disabled" at mediawidget. So, we should // 0 is reserved for "disabled" at mediawidget. So, we should
// Start counting from 1, to match the range expected for // Start counting from 1, to match the range expected for
// currentSubtitle // currentSubtitle
subtitleId[track->i_id] = ++i; subtitleId[track->i_id] = ++i;
subtitles.append(subtitle); subtitles.append(subtitle);
qCDebug(logVlc, "Got subtitle id#%d: %s", track->i_id, qPrintable (subtitle)); qCDebug(logVlc, "Got subtitle id#%d: %s", track->i_id, qPrintable (subtitle));
track = track->p_next; track = track->p_next;
} }
libvlc_track_description_list_release(track); libvlc_track_description_list_release(tr);
// skip the 'deactivate' subtitle // skip the 'deactivate' subtitle
currentSubtitle = subtitleId.value(libvlc_video_get_spu(vlcMediaPlayer), -1); currentSubtitle = subtitleId.value(libvlc_video_get_spu(vlcMediaPlayer), -1);
} }
void VlcMediaWidget::updateTitles() void VlcMediaWidget::updateTitles()
{ {
titleCount = libvlc_media_player_get_title_count(vlcMediaPlayer); titleCount = libvlc_media_player_get_title_count(vlcMediaPlayer);
currentTitle = libvlc_media_player_get_title(vlcMediaPlayer); currentTitle = libvlc_media_player_get_title(vlcMediaPlayer);
} }
skipping to change at line 794 skipping to change at line 1057
void VlcMediaWidget::vlcEvent(const libvlc_event_t *event) void VlcMediaWidget::vlcEvent(const libvlc_event_t *event)
{ {
PendingUpdates pendingUpdatesToBeAdded = 0; PendingUpdates pendingUpdatesToBeAdded = 0;
switch (event->type) { switch (event->type) {
#if LIBVLC_VERSION_MAJOR > 2 #if LIBVLC_VERSION_MAJOR > 2
case libvlc_MediaPlayerESAdded: case libvlc_MediaPlayerESAdded:
case libvlc_MediaPlayerESDeleted: case libvlc_MediaPlayerESDeleted:
#endif #endif
case libvlc_MediaMetaChanged: case libvlc_MediaMetaChanged:
pendingUpdatesToBeAdded = Metadata | Subtitles; pendingUpdatesToBeAdded = Metadata | Subtitles | AudioStreams;
break; break;
case libvlc_MediaPlayerEncounteredError: case libvlc_MediaPlayerEncounteredError:
pendingUpdatesToBeAdded = PlaybackStatus; pendingUpdatesToBeAdded = PlaybackStatus;
break; break;
case libvlc_MediaPlayerEndReached: case libvlc_MediaPlayerEndReached:
pendingUpdatesToBeAdded = (PlaybackFinished | PlaybackStatus); pendingUpdatesToBeAdded = (PlaybackFinished | PlaybackStatus);
break; break;
case libvlc_MediaPlayerLengthChanged: case libvlc_MediaPlayerLengthChanged:
pendingUpdatesToBeAdded = CurrentTotalTime; pendingUpdatesToBeAdded = CurrentTotalTime;
break; break;
skipping to change at line 820 skipping to change at line 1083
setMouseTracking(false); setMouseTracking(false);
break; break;
case libvlc_MediaPlayerTimeChanged: case libvlc_MediaPlayerTimeChanged:
pendingUpdatesToBeAdded = CurrentTotalTime; pendingUpdatesToBeAdded = CurrentTotalTime;
break; break;
} }
if (pendingUpdatesToBeAdded != 0) { if (pendingUpdatesToBeAdded != 0) {
addPendingUpdates(pendingUpdatesToBeAdded); addPendingUpdates(pendingUpdatesToBeAdded);
} else { } else {
qCWarning(logMediaWidget, "Unknown libVLC event type %d", event-> qCWarning(logMediaWidget, "Unhandled event %s (%d)",
type); vlcEventName(event->type), event->type);
} }
} }
void VlcMediaWidget::vlcEventHandler(const libvlc_event_t *event, void *instance ) void VlcMediaWidget::vlcEventHandler(const libvlc_event_t *event, void *instance )
{ {
reinterpret_cast<VlcMediaWidget *>(instance)->vlcEvent(event); reinterpret_cast<VlcMediaWidget *>(instance)->vlcEvent(event);
} }
 End of changes. 32 change blocks. 
69 lines changed or deleted 324 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)