Commit c83093b7 authored by Elbin Pallimalil's avatar Elbin Pallimalil Committed by Trever Fischer
Browse files

Fix metadata emission for http urls.

REVIEWBOARD:101595
BUG:272243
FIXED-IN:4.6.1
parent 18cacbe8
......@@ -40,6 +40,7 @@ Pipeline::Pipeline(QObject *parent)
: QObject(parent)
, m_bufferPercent(0)
, m_isStream(false)
, m_isHttpUrl(false)
, m_installer(new PluginInstaller(this))
, m_resetting(false)
{
......@@ -144,6 +145,7 @@ void Pipeline::setSource(const Phonon::MediaSource &source, bool reset)
m_seeking = false;
m_installer->reset();
m_resumeAfterInstall = false;
m_isHttpUrl = false;
m_metaData.clear();
debug() << "New source:" << source.mrl();
......@@ -152,6 +154,8 @@ void Pipeline::setSource(const Phonon::MediaSource &source, bool reset)
case MediaSource::Url:
case MediaSource::LocalFile:
gstUri = source.mrl().toEncoded();
if(source.mrl().scheme() == QLatin1String("http"))
m_isHttpUrl = true;
break;
case MediaSource::Invalid:
emit errorMessage("Invalid source specified", Phonon::FatalError);
......@@ -547,6 +551,8 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
{
Q_UNUSED(bus)
Pipeline *that = static_cast<Pipeline*>(data);
bool isStream = that->m_isStream || that->m_isHttpUrl;
GstTagList* tag_list = 0;
gst_message_parse_tag(msg, &tag_list);
if (tag_list) {
......@@ -562,7 +568,7 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
// have a commonly available tag (ORGANIZATION) or we have a
// change in title
bool fake_it =
(that->m_isStream
(isStream
&& ((!newTags.contains("TITLE")
&& newTags.contains("ORGANIZATION"))
|| (newTags.contains("TITLE")
......@@ -578,7 +584,7 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
QList<QString> keys = newTags.keys();
for (QList<QString>::iterator i = keys.begin(); i != keys.end(); ++i) {
QString key = *i;
if (that->m_isStream) {
if (isStream) {
// If we're streaming, we need to remove data in m_metaData
// in order to stop it filling up indefinitely (as it's a multimap)
that->m_metaData.remove(key);
......@@ -601,19 +607,13 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
that->m_metaData.insert("MUSICBRAINZ_DISCID", newTags.value("MUSICBRAINZ-DISCID"));
}
// For radio streams, if we get a metadata update where the title changes, we assume everything else is invalid.
// If we don't already have a title, we don't do anything since we're actually just appending new data into that.
if (that->m_isStream && oldMap.contains("TITLE") && that->m_metaData.value("TITLE") != oldMap.value("TITLE")) {
that->m_metaData.clear();
}
//debug() << this << "Meta tags found";
if (oldMap != that->m_metaData) {
// This is a bit of a hack to ensure that stream metadata is
// returned. We get as much as we can from the Shoutcast server's
// StreamTitle= header. If further info is decoded from the stream
// itself later, then it will overwrite this info.
if (that->m_isStream && fake_it) {
if (fake_it) {
that->m_metaData.remove("ALBUM");
that->m_metaData.remove("ARTIST");
......@@ -659,7 +659,8 @@ gboolean Pipeline::cb_tag(GstBus *bus, GstMessage *msg, gpointer data)
// If not, this needs fixed in mediaobject.cpp.
guint kbps;
g_object_get(that->m_pipeline, "connection-speed", &kbps, NULL);
if (that->m_currentSource.discType() == Phonon::Cd || kbps != 0)
// This hack does not work now.
// if (that->m_currentSource.discType() == Phonon::Cd || kbps != 0)
emit that->metaDataChanged(that->m_metaData);
}
}
......
......@@ -124,6 +124,7 @@ class Pipeline : public QObject
bool m_resumeAfterInstall;
// Determines if we're using an QIODevice stream
bool m_isStream;
bool m_isHttpUrl;
QMultiMap<QString, QString> m_metaData;
QList<MediaController::NavigationMenu> m_menus;
Phonon::MediaSource m_currentSource;
......
Markdown is supported
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