From 3cbb4dd435f3cee4e706a01c07b509f7327fff80 Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Tue, 13 Dec 2016 13:53:06 +0900 Subject: Adding backport patches of Qt5 to show cover art To show cover art in qtmultimedia, the backport patches(listed below) are needed. https://codereview.qt-project.org/179542 https://codereview.qt-project.org/165950 https://codereview.qt-project.org/165951 Change-Id: I638d824a3c8c4c632c4347538653830921c5e956 Signed-off-by: Tadao Tanikawa --- .../0001-GStreamer-support-cover-art.patch | 54 +++++++++++++++ ...reamer-support-date-time-type-in-metadata.patch | 51 ++++++++++++++ ...age-support-with-the-data-URL-scheme-for-.patch | 80 ++++++++++++++++++++++ recipes-qt/qt5/qtmultimedia_%.bbappend | 8 +++ 4 files changed, 193 insertions(+) create mode 100644 recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-cover-art.patch create mode 100644 recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-date-time-type-in-metadata.patch create mode 100644 recipes-qt/qt5/qtmultimedia/0001-metadata-image-support-with-the-data-URL-scheme-for-.patch (limited to 'recipes-qt') diff --git a/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-cover-art.patch b/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-cover-art.patch new file mode 100644 index 000000000..8e6449052 --- /dev/null +++ b/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-cover-art.patch @@ -0,0 +1,54 @@ +From 9bdc7c84eea0ff66c937d5f62ffed249321c3c35 Mon Sep 17 00:00:00 2001 +From: Tasuku Suzuki +Date: Sun, 24 Jul 2016 00:23:36 +0900 +Subject: [PATCH] GStreamer: support cover art + +Change-Id: I05987f578a40c23dc2eb6f3e6a7f76d11f704214 +Reviewed-by: Yoann Lopes +--- + src/gsttools/qgstutils.cpp | 16 ++++++++++++++++ + .../gstreamer/mediaplayer/qgstreamermetadataprovider.cpp | 1 + + 2 files changed, 17 insertions(+) + +diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp +index 831ba96..a2b3507 100644 +--- a/src/gsttools/qgstutils.cpp ++++ b/src/gsttools/qgstutils.cpp +@@ -141,6 +141,22 @@ static void addTagToMap(const GstTagList *list, + } + if (!map->contains("year") && year > 0) + map->insert("year", year); ++ } else if (G_VALUE_TYPE(&val) == GST_TYPE_SAMPLE) { ++ GstSample *sample = (GstSample *)g_value_get_boxed(&val); ++ GstCaps* caps = gst_sample_get_caps(sample); ++ if (caps && !gst_caps_is_empty(caps)) { ++ GstStructure *structure = gst_caps_get_structure(caps, 0); ++ const gchar *name = gst_structure_get_name(structure); ++ if (QByteArray(name).startsWith("image/")) { ++ GstBuffer *buffer = gst_sample_get_buffer(sample); ++ if (buffer) { ++ GstMapInfo info; ++ gst_buffer_map(buffer, &info, GST_MAP_READ); ++ map->insert(QByteArray(tag), QImage::fromData(info.data, info.size, name)); ++ gst_buffer_unmap(buffer, &info); ++ } ++ } ++ } + #endif + } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) { + int nom = gst_value_get_fraction_numerator(&val); +diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +index 074f8ad..01103d6 100644 +--- a/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp ++++ b/src/plugins/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp +@@ -93,6 +93,7 @@ static const QGstreamerMetaDataKeyLookup *qt_gstreamerMetaDataKeys() + + //metadataKeys->insert(0, QMediaMetaData::CoverArtUrlSmall); + //metadataKeys->insert(0, QMediaMetaData::CoverArtUrlLarge); ++ metadataKeys->insert(GST_TAG_PREVIEW_IMAGE, QMediaMetaData::CoverArtImage); + + // Image/Video + metadataKeys->insert("resolution", QMediaMetaData::Resolution); +-- +2.7.4 + diff --git a/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-date-time-type-in-metadata.patch b/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-date-time-type-in-metadata.patch new file mode 100644 index 000000000..252838fc0 --- /dev/null +++ b/recipes-qt/qt5/qtmultimedia/0001-GStreamer-support-date-time-type-in-metadata.patch @@ -0,0 +1,51 @@ +From d0ac492e3023545adad8008a3ebcac2a297dc783 Mon Sep 17 00:00:00 2001 +From: Tasuku Suzuki +Date: Sun, 24 Jul 2016 00:23:10 +0900 +Subject: [PATCH] GStreamer: support date time type in metadata + +Change-Id: Ica57abfc0a60b401be88662483d35699d4f76321 +Reviewed-by: Yoann Lopes +--- + src/gsttools/qgstutils.cpp | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/gsttools/qgstutils.cpp b/src/gsttools/qgstutils.cpp +index b5299f1..831ba96 100644 +--- a/src/gsttools/qgstutils.cpp ++++ b/src/gsttools/qgstutils.cpp +@@ -40,6 +40,7 @@ + #include "qgstutils_p.h" + + #include ++#include + #include + #include + #include +@@ -123,6 +124,24 @@ static void addTagToMap(const GstTagList *list, + if (!map->contains("year")) + map->insert("year", year); + } ++#if GST_CHECK_VERSION(1,0,0) ++ } else if (G_VALUE_TYPE(&val) == GST_TYPE_DATE_TIME) { ++ const GstDateTime *dateTime = (const GstDateTime *)g_value_get_boxed(&val); ++ int year = gst_date_time_has_year(dateTime) ? gst_date_time_get_year(dateTime) : 0; ++ int month = gst_date_time_has_month(dateTime) ? gst_date_time_get_month(dateTime) : 0; ++ int day = gst_date_time_has_day(dateTime) ? gst_date_time_get_day(dateTime) : 0; ++ if (gst_date_time_has_time(dateTime)) { ++ int hour = gst_date_time_get_hour(dateTime); ++ int minute = gst_date_time_get_minute(dateTime); ++ int second = gst_date_time_get_second(dateTime); ++ float tz = gst_date_time_get_time_zone_offset(dateTime); ++ map->insert(QByteArray(tag), QDateTime(QDate(year,month,day), QTime(hour, minute, second), QTimeZone(tz * 60 * 60))); ++ } else if (year > 0 && month > 0 && day > 0) { ++ map->insert(QByteArray(tag), QDate(year,month,day)); ++ } ++ if (!map->contains("year") && year > 0) ++ map->insert("year", year); ++#endif + } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) { + int nom = gst_value_get_fraction_numerator(&val); + int denom = gst_value_get_fraction_denominator(&val); +-- +2.7.4 + diff --git a/recipes-qt/qt5/qtmultimedia/0001-metadata-image-support-with-the-data-URL-scheme-for-.patch b/recipes-qt/qt5/qtmultimedia/0001-metadata-image-support-with-the-data-URL-scheme-for-.patch new file mode 100644 index 000000000..007e46763 --- /dev/null +++ b/recipes-qt/qt5/qtmultimedia/0001-metadata-image-support-with-the-data-URL-scheme-for-.patch @@ -0,0 +1,80 @@ +From ed61f1d932c5c6d38458fcd2e1d5d154383f017e Mon Sep 17 00:00:00 2001 +From: Tasuku Suzuki +Date: Mon, 12 Dec 2016 16:32:47 +0900 +Subject: [PATCH] metadata image support with the "data" URL scheme for QtQuick + +add posterImage, coverArtImage and thumbnailImage to metadata + +Change-Id: I10b9bae10c219ffa41506d6e6b345020790217a6 +--- + .../multimedia/qdeclarativemediametadata_p.h | 33 ++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +diff --git a/src/imports/multimedia/qdeclarativemediametadata_p.h b/src/imports/multimedia/qdeclarativemediametadata_p.h +index ede7f87..6a6a815 100644 +--- a/src/imports/multimedia/qdeclarativemediametadata_p.h ++++ b/src/imports/multimedia/qdeclarativemediametadata_p.h +@@ -51,6 +51,9 @@ + // We mean it. + // + ++#include ++#include ++#include + #include + #include + #include +@@ -153,6 +156,9 @@ class QDeclarativeMediaMetaData : public QObject + Q_PROPERTY(QVariant gpsProcessingMethod READ gpsProcessingMethod WRITE setGPSProcessingMethod NOTIFY metaDataChanged) + Q_PROPERTY(QVariant gpsAreaInformation READ gpsAreaInformation WRITE setGPSAreaInformation NOTIFY metaDataChanged) + ++ Q_PROPERTY(QVariant posterImage READ posterImage NOTIFY metaDataChanged) ++ Q_PROPERTY(QVariant coverArtImage READ coverArtImage NOTIFY metaDataChanged) ++ Q_PROPERTY(QVariant thumbnailImage READ thumbnailImage NOTIFY metaDataChanged) + public: + QDeclarativeMediaMetaData(QMediaObject *player, QObject *parent = 0) + : QObject(parent) +@@ -425,6 +431,16 @@ QT_WARNING_POP + void setGPSAreaInformation(const QVariant &information) { + setMetaData(QMediaMetaData::GPSAreaInformation, information); } + ++ QVariant posterImage() const { ++ return convertImageToUrl(m_mediaObject->metaData(QMediaMetaData::PosterImage)); ++ } ++ QVariant coverArtImage() const { ++ return convertImageToUrl(m_mediaObject->metaData(QMediaMetaData::CoverArtImage)); ++ } ++ QVariant thumbnailImage() const { ++ return convertImageToUrl(m_mediaObject->metaData(QMediaMetaData::ThumbnailImage)); ++ } ++ + Q_SIGNALS: + void metaDataChanged(); + +@@ -440,6 +456,23 @@ private: + m_writerControl->setMetaData(key, value); + } + ++ QUrl convertImageToUrl(const QVariant &variant) const ++ { ++ if (variant.type() != QVariant::Image) ++ return QUrl(); ++ ++ QImage image = variant.value(); ++ QByteArray data; ++ QBuffer buffer(&data); ++ buffer.open(QBuffer::WriteOnly); ++ QImageWriter png(&buffer, "png"); ++ if (!png.write(image)) { ++ return QUrl(); ++ } ++ buffer.close(); ++ return QUrl(QStringLiteral("data:image/png;base64,") + data.toBase64()); ++ } ++ + QMediaObject *m_mediaObject; + QMetaDataWriterControl *m_writerControl; + bool m_requestedWriterControl; +-- +2.7.4 + diff --git a/recipes-qt/qt5/qtmultimedia_%.bbappend b/recipes-qt/qt5/qtmultimedia_%.bbappend index 42fe5314f..bc4b002fd 100644 --- a/recipes-qt/qt5/qtmultimedia_%.bbappend +++ b/recipes-qt/qt5/qtmultimedia_%.bbappend @@ -1 +1,9 @@ +FILESEXTRAPATHS_append := ":${THISDIR}/${PN}" + PACKAGECONFIG_append = " gstreamer" + +SRC_URI_append = " \ + file://0001-metadata-image-support-with-the-data-URL-scheme-for-.patch \ + file://0001-GStreamer-support-date-time-type-in-metadata.patch \ + file://0001-GStreamer-support-cover-art.patch \ + " -- cgit 1.2.3-korg