GStreamer: correctly get metadata from live sources.

For some unknown reason, "iradio-mode" was set to false on the
source element, which was preventing new metadata to be received
when playing live streams.

Task-number: QTBUG-37640
Change-Id: Ib90297e81e26a99c3dfc753bdcd5cbd1ee2f6764
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
Yoann Lopes
2014-03-21 19:10:23 +01:00
committed by The Qt Project
parent 0821606260
commit 464ed66119
2 changed files with 11 additions and 23 deletions

View File

@@ -162,25 +162,18 @@ void QGstreamerMetaDataProvider::updateTags()
{
QVariantMap oldTags = m_tags;
m_tags.clear();
QSet<QString> allTags = QSet<QString>::fromList(m_tags.keys());
bool changed = false;
QMapIterator<QByteArray ,QVariant> i(m_session->tags());
while (i.hasNext()) {
i.next();
//use gstreamer native keys for elements not in m_keysMap
QString key = m_keysMap.value(i.key(), i.key());
m_tags[key] = i.value();
allTags.insert(key);
}
bool changed = false;
foreach (const QString &key, allTags) {
const QVariant value = m_tags.value(key);
if (value != oldTags.value(key)) {
changed = true;
emit metaDataChanged(key, value);
}
m_tags.insert(key, i.value());
if (i.value() != oldTags.value(key)) {
changed = true;
emit metaDataChanged(key, i.value());
}
}
if (changed)

View File

@@ -987,13 +987,15 @@ bool QGstreamerPlayerSession::processBusMessage(const QGstreamerMessage &message
if (gm) {
//tag message comes from elements inside playbin, not from playbin itself
if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_TAG) {
//qDebug() << "tag message";
GstTagList *tag_list;
gst_message_parse_tag(gm, &tag_list);
m_tags.unite(QGstUtils::gstTagListToMap(tag_list));
QMap<QByteArray, QVariant> newTags = QGstUtils::gstTagListToMap(tag_list);
QMap<QByteArray, QVariant>::const_iterator it = newTags.constBegin();
for ( ; it != newTags.constEnd(); ++it)
m_tags.insert(it.key(), it.value()); // overwrite existing tags
gst_tag_list_free(tag_list);
//qDebug() << m_tags;
emit tagsChanged();
} else if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_DURATION) {
@@ -1459,13 +1461,6 @@ void QGstreamerPlayerSession::playbinNotifySource(GObject *o, GParamSpec *p, gpo
qDebug() << "Playbin source added:" << G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source));
#endif
// Turn off icecast metadata request, will be re-set if in QNetworkRequest
// (souphttpsrc docs say is false by default, but header appears in request
// @version 0.10.21)
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "iradio-mode") != 0)
g_object_set(G_OBJECT(source), "iradio-mode", FALSE, NULL);
// Set Headers
const QByteArray userAgentString("User-Agent");