Re: [Tracker] Add support for OMA DRM Content format
- From: "Lin, Mengdong" <mengdong lin intel com>
- To: Martyn Russell <martyn lanedo com>, Aleksander Morgado <aleksander lanedo com>, Philip Van Hoof <spam pvanhoof be>
- Cc: "tracker-list gnome org" <tracker-list gnome org>
- Subject: Re: [Tracker] Add support for OMA DRM Content format
- Date: Wed, 23 Feb 2011 14:09:21 +0800
Here is my change on Tracker GStreamer extractor and it works. Is this method doable? And Can I submit a
patch for it?
For OMA DRM content format (DCF), it will try GStreamer at first. If GStreamer DRM-aware extensions are
installed, then decodebin2 can recognize the original media type and extract rich meta data. Otherwise, the
extractor will extract basic media type from the unencrypted file header, and mark it as a piece of music,
video or image. Other mime types are not recognized yet and the nie:mimeType is not changed.
static TrackerExtractData data[] = {
{ "audio/*", extract_gstreamer_audio },
{ "video/*", extract_gstreamer_video },
{ "image/*", extract_gstreamer_image },
/* Tell gstreamer to guess if mimetype guessing returns video also for audio files */
{ "image/svg+xml", extract_gstreamer_svg },
{ "video/3gpp", extract_gstreamer_guess },
{ "video/mp4", extract_gstreamer_guess },
{ "video/x-ms-asf", extract_gstreamer_guess },
+ /* DRM types */
+ { "application/vnd.oma.drm.content", extract_gstreamer_dcf},
{ NULL, NULL }
};
static void
extract_gstreamer_dcf (const gchar *uri,
TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata)
{
gint items;
tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_GUESS);
items = tracker_sparql_builder_get_length (metadata);
if(0 == items)
{
g_debug("GStreamer has not OMA-DRM-aware extensions\n");
extract_dcf_self(uri, preupdate, metadata);
}
}
/* Extract original MIME type from DCF file header, no more information can be got from the file header. */
static void
extract_dcf_self ( const gchar *uri,
TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata)
{
gchar *filename;
goffset filesize;
FILE * fp = NULL;
guchar dcf_version;
guchar content_type_len;
guchar content_uri_len;
gchar ori_mime_type[OMA_MAX_MIME_TYPE_LEN];
filename = g_filename_from_uri (uri, NULL, NULL);
filesize = tracker_file_get_size (filename);
if (filesize < 3) {
/* at least 3 bytes, version, original content MIME type length and uri length */
g_free (filename);
return;
}
fp = tracker_file_open (filename, "r", TRUE);
if(!fp) return;
if(1 != fread(&dcf_version, sizeof(gchar), 1, fp))
goto bail;
if(1 != dcf_version) goto bail; /* only support version 1.0 */
if(1 != fread(&content_type_len, sizeof(guchar), 1, fp))
goto bail;
if(1 != fread(&content_uri_len, sizeof(guchar), 1, fp))
goto bail;
memset(ori_mime_type, 0, OMA_MAX_MIME_TYPE_LEN);
if(1 != fread(&ori_mime_type, content_type_len, 1, fp))
goto bail;
tracker_sparql_builder_predicate (metadata, "a");
if(!memcmp(ori_mime_type, "audio", 5)) {
tracker_sparql_builder_object (metadata, "nmm:MusicPiece");
tracker_sparql_builder_object (metadata, "nfo:Audio");
}
else if(!memcmp(ori_mime_type, "video", 5)) {
tracker_sparql_builder_object (metadata, "nmm:Video");
}
else if(!memcmp(ori_mime_type, "image", 5)) {
tracker_sparql_builder_object (metadata, "nfo:Image");
}
/* other types are not recognized yet */
bail:
if(fp)
tracker_file_close(fp, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]