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