qtmobility/plugins/multimedia/gstreamer/mediaplayer/qgstreamermetadataprovider.cpp
changeset 5 453da2cfceef
parent 1 2b40d63a9c3d
child 11 06b8e2af4411
equal deleted inserted replaced
4:90517678cc4f 5:453da2cfceef
    45 
    45 
    46 #include <gst/gstversion.h>
    46 #include <gst/gstversion.h>
    47 
    47 
    48 struct QGstreamerMetaDataKeyLookup
    48 struct QGstreamerMetaDataKeyLookup
    49 {
    49 {
    50     QtMedia::MetaData key;
    50     QtMediaServices::MetaData key;
    51     const char *token;
    51     const char *token;
    52 };
    52 };
    53 
    53 
    54 static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] =
    54 static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] =
    55 {
    55 {
    56     { QtMedia::Title, GST_TAG_TITLE },
    56     { QtMediaServices::Title, GST_TAG_TITLE },
    57     //{ QtMedia::SubTitle, 0 },
    57     //{ QtMediaServices::SubTitle, 0 },
    58     //{ QtMedia::Author, 0 },
    58     //{ QtMediaServices::Author, 0 },
    59     { QtMedia::Comment, GST_TAG_COMMENT },
    59     { QtMediaServices::Comment, GST_TAG_COMMENT },
    60     { QtMedia::Description, GST_TAG_DESCRIPTION },
    60     { QtMediaServices::Description, GST_TAG_DESCRIPTION },
    61     //{ QtMedia::Category, 0 },
    61     //{ QtMediaServices::Category, 0 },
    62     { QtMedia::Genre, GST_TAG_GENRE },
    62     { QtMediaServices::Genre, GST_TAG_GENRE },
    63     { QtMedia::Year, "year" },
    63     { QtMediaServices::Year, "year" },
    64     //{ QtMedia::UserRating, 0 },
    64     //{ QtMediaServices::UserRating, 0 },
    65 
    65 
    66     { QtMedia::Language, GST_TAG_LANGUAGE_CODE },
    66     { QtMediaServices::Language, GST_TAG_LANGUAGE_CODE },
    67 
    67 
    68     { QtMedia::Publisher, GST_TAG_ORGANIZATION },
    68     { QtMediaServices::Publisher, GST_TAG_ORGANIZATION },
    69     { QtMedia::Copyright, GST_TAG_COPYRIGHT },
    69     { QtMediaServices::Copyright, GST_TAG_COPYRIGHT },
    70     //{ QtMedia::ParentalRating, 0 },
    70     //{ QtMediaServices::ParentalRating, 0 },
    71     //{ QtMedia::RatingOrganisation, 0 },
    71     //{ QtMediaServices::RatingOrganisation, 0 },
    72 
    72 
    73     // Media
    73     // Media
    74     //{ QtMedia::Size, 0 },
    74     //{ QtMediaServices::Size, 0 },
    75     //{ QtMedia::MediaType, 0 },
    75     //{ QtMediaServices::MediaType, 0 },
    76     { QtMedia::Duration, GST_TAG_DURATION },
    76     { QtMediaServices::Duration, GST_TAG_DURATION },
    77 
    77 
    78     // Audio
    78     // Audio
    79     { QtMedia::AudioBitRate, GST_TAG_BITRATE },
    79     { QtMediaServices::AudioBitRate, GST_TAG_BITRATE },
    80     { QtMedia::AudioCodec, GST_TAG_AUDIO_CODEC },
    80     { QtMediaServices::AudioCodec, GST_TAG_AUDIO_CODEC },
    81     //{ QtMedia::ChannelCount, 0 },
    81     //{ QtMediaServices::ChannelCount, 0 },
    82     //{ QtMedia::SampleRate, 0 },
    82     //{ QtMediaServices::SampleRate, 0 },
    83 
    83 
    84     // Music
    84     // Music
    85     { QtMedia::AlbumTitle, GST_TAG_ALBUM },
    85     { QtMediaServices::AlbumTitle, GST_TAG_ALBUM },
    86     { QtMedia::AlbumArtist,  GST_TAG_ARTIST},
    86     { QtMediaServices::AlbumArtist,  GST_TAG_ARTIST},
    87     { QtMedia::ContributingArtist, GST_TAG_PERFORMER },
    87     { QtMediaServices::ContributingArtist, GST_TAG_PERFORMER },
    88 #if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19)
    88 #if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19)
    89     { QtMedia::Composer, GST_TAG_COMPOSER },
    89     { QtMediaServices::Composer, GST_TAG_COMPOSER },
    90 #endif
    90 #endif
    91     //{ QtMedia::Conductor, 0 },
    91     //{ QtMediaServices::Conductor, 0 },
    92     //{ QtMedia::Lyrics, 0 },
    92     //{ QtMediaServices::Lyrics, 0 },
    93     //{ QtMedia::Mood, 0 },
    93     //{ QtMediaServices::Mood, 0 },
    94     { QtMedia::TrackNumber, GST_TAG_TRACK_NUMBER },
    94     { QtMediaServices::TrackNumber, GST_TAG_TRACK_NUMBER },
    95 
    95 
    96     //{ QtMedia::CoverArtUrlSmall, 0 },
    96     //{ QtMediaServices::CoverArtUrlSmall, 0 },
    97     //{ QtMedia::CoverArtUrlLarge, 0 },
    97     //{ QtMediaServices::CoverArtUrlLarge, 0 },
    98 
    98 
    99     // Image/Video
    99     // Image/Video
   100     //{ QtMedia::Resolution, 0 },
   100     //{ QtMediaServices::Resolution, 0 },
   101     //{ QtMedia::PixelAspectRatio, 0 },
   101     //{ QtMediaServices::PixelAspectRatio, 0 },
   102 
   102 
   103     // Video
   103     // Video
   104     //{ QtMedia::VideoFrameRate, 0 },
   104     //{ QtMediaServices::VideoFrameRate, 0 },
   105     //{ QtMedia::VideoBitRate, 0 },
   105     //{ QtMediaServices::VideoBitRate, 0 },
   106     { QtMedia::VideoCodec, GST_TAG_VIDEO_CODEC },
   106     { QtMediaServices::VideoCodec, GST_TAG_VIDEO_CODEC },
   107 
   107 
   108     //{ QtMedia::PosterUrl, 0 },
   108     //{ QtMediaServices::PosterUrl, 0 },
   109 
   109 
   110     // Movie
   110     // Movie
   111     //{ QtMedia::ChapterNumber, 0 },
   111     //{ QtMediaServices::ChapterNumber, 0 },
   112     //{ QtMedia::Director, 0 },
   112     //{ QtMediaServices::Director, 0 },
   113     { QtMedia::LeadPerformer, GST_TAG_PERFORMER },
   113     { QtMediaServices::LeadPerformer, GST_TAG_PERFORMER },
   114     //{ QtMedia::Writer, 0 },
   114     //{ QtMediaServices::Writer, 0 },
   115 
   115 
   116     // Photos
   116     // Photos
   117     //{ QtMedia::CameraManufacturer, 0 },
   117     //{ QtMediaServices::CameraManufacturer, 0 },
   118     //{ QtMedia::CameraModel, 0 },
   118     //{ QtMediaServices::CameraModel, 0 },
   119     //{ QtMedia::Event, 0 },
   119     //{ QtMediaServices::Event, 0 },
   120     //{ QtMedia::Subject, 0 }
   120     //{ QtMediaServices::Subject, 0 }
   121 };
   121 };
   122 
   122 
   123 QGstreamerMetaDataProvider::QGstreamerMetaDataProvider(QGstreamerPlayerSession *session, QObject *parent)
   123 QGstreamerMetaDataProvider::QGstreamerMetaDataProvider(QGstreamerPlayerSession *session, QObject *parent)
   124     :QMetaDataControl(parent), m_session(session)
   124     :QMetaDataControl(parent), m_session(session)
   125 {
   125 {
   138 bool QGstreamerMetaDataProvider::isWritable() const
   138 bool QGstreamerMetaDataProvider::isWritable() const
   139 {
   139 {
   140     return false;
   140     return false;
   141 }
   141 }
   142 
   142 
   143 QVariant QGstreamerMetaDataProvider::metaData(QtMedia::MetaData key) const
   143 QVariant QGstreamerMetaDataProvider::metaData(QtMediaServices::MetaData key) const
   144 {
   144 {
   145     static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
   145     static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
   146 
   146 
   147     for (int i = 0; i < count; ++i) {
   147     for (int i = 0; i < count; ++i) {
   148         if (qt_gstreamerMetaDataKeys[i].key == key) {
   148         if (qt_gstreamerMetaDataKeys[i].key == key) {
   150         }
   150         }
   151     }
   151     }
   152     return QVariant();
   152     return QVariant();
   153 }
   153 }
   154 
   154 
   155 void QGstreamerMetaDataProvider::setMetaData(QtMedia::MetaData key, QVariant const &value)
   155 void QGstreamerMetaDataProvider::setMetaData(QtMediaServices::MetaData key, QVariant const &value)
   156 {
   156 {
   157     Q_UNUSED(key);
   157     Q_UNUSED(key);
   158     Q_UNUSED(value);
   158     Q_UNUSED(value);
   159 }
   159 }
   160 
   160 
   161 QList<QtMedia::MetaData> QGstreamerMetaDataProvider::availableMetaData() const
   161 QList<QtMediaServices::MetaData> QGstreamerMetaDataProvider::availableMetaData() const
   162 {
   162 {
   163     static QMap<QByteArray, QtMedia::MetaData> keysMap;
   163     static QMap<QByteArray, QtMediaServices::MetaData> keysMap;
   164     if (keysMap.isEmpty()) {
   164     if (keysMap.isEmpty()) {
   165         const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
   165         const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup);
   166         for (int i = 0; i < count; ++i) {
   166         for (int i = 0; i < count; ++i) {
   167             keysMap[QByteArray(qt_gstreamerMetaDataKeys[i].token)] = qt_gstreamerMetaDataKeys[i].key;
   167             keysMap[QByteArray(qt_gstreamerMetaDataKeys[i].token)] = qt_gstreamerMetaDataKeys[i].key;
   168         }
   168         }
   169     }
   169     }
   170 
   170 
   171     QList<QtMedia::MetaData> res;
   171     QList<QtMediaServices::MetaData> res;
   172     foreach (const QByteArray &key, m_session->tags().keys()) {
   172     foreach (const QByteArray &key, m_session->tags().keys()) {
   173         QtMedia::MetaData tag = keysMap.value(key, QtMedia::MetaData(-1));
   173         QtMediaServices::MetaData tag = keysMap.value(key, QtMediaServices::MetaData(-1));
   174         if (tag != -1)
   174         if (tag != -1)
   175             res.append(tag);
   175             res.append(tag);
   176     }
   176     }
   177 
   177 
   178     return res;
   178     return res;