Commit e840de73 authored by Sam Thursfield's avatar Sam Thursfield
Browse files

Merge branch '2.3.4/libav' into tracker-miners-2.3

parents 8eaddd34 9b917f5d
Pipeline #188784 passed with stage
in 1 minute and 20 seconds
......@@ -30,6 +30,15 @@
#include <libavformat/avformat.h>
#include <libavutil/mathematics.h>
static AVDictionaryEntry *find_tag (AVFormatContext *format, AVStream *stream, const gchar *name)
{
AVDictionaryEntry *tag = av_dict_get(format->metadata, name, NULL, 0);
if (!tag) {
tag = av_dict_get(stream->metadata, name, NULL, 0);
}
return tag;
}
G_MODULE_EXPORT gboolean
tracker_extract_get_metadata (TrackerExtractInfo *info)
......@@ -81,13 +90,6 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
metadata = tracker_resource_new (NULL);
if ((tag = av_dict_get (format->metadata, "creation_time", NULL, 0))) {
content_created = tracker_date_guess (tag->value);
if (content_created) {
tracker_resource_set_string (metadata, "nie:contentCreated", content_created);
}
}
if (audio_stream) {
if (audio_stream->codec->sample_rate > 0) {
tracker_resource_set_int64 (metadata, "nfo:sampleRate", audio_stream->codec->sample_rate);
......@@ -97,7 +99,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
}
}
if (video_stream) {
if (video_stream && !(video_stream->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
tracker_resource_add_uri(metadata, "rdf:type", "nmm:Video");
if (video_stream->codec->width > 0 && video_stream->codec->height > 0) {
......@@ -139,6 +141,13 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
tracker_resource_set_int64 (metadata, "nmm:season", atoi(tag->value));
}
if ((tag = av_dict_get (format->metadata, "creation_time", NULL, 0))) {
content_created = tracker_date_guess (tag->value);
if (content_created) {
tracker_resource_set_string (metadata, "nie:contentCreated", content_created);
}
}
} else if (audio_stream) {
TrackerResource *album_artist = NULL, *performer = NULL;
char *album_artist_name = NULL;
......@@ -153,35 +162,42 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
tracker_resource_set_int64 (metadata, "nfo:duration", duration);
}
if ((tag = av_dict_get (format->metadata, "track", NULL, 0))) {
if ((tag = find_tag (format, audio_stream, "track"))) {
int track = atoi(tag->value);
if (track > 0) {
tracker_resource_set_int64 (metadata, "nmm:trackNumber", track);
}
}
if ((tag = av_dict_get (format->metadata, "album", NULL, 0))) {
if ((tag = find_tag (format, audio_stream, "album"))) {
album_title = tag->value;
}
if (album_title && (tag = av_dict_get (format->metadata, "album_artist", NULL, 0))) {
if (album_title && (tag = find_tag (format, audio_stream, "album_artist"))) {
album_artist_name = tag->value;
album_artist = tracker_extract_new_artist (album_artist_name);
}
if ((tag = av_dict_get (format->metadata, "artist", tag, 0))) {
if ((tag = find_tag (format, audio_stream, "artist"))) {
performer = tracker_extract_new_artist (tag->value);
}
if (!performer && (tag = av_dict_get (format->metadata, "performer", tag, 0))) {
if (!performer && (tag = find_tag (format, audio_stream, "performer"))) {
performer = tracker_extract_new_artist (tag->value);
}
if ((tag = av_dict_get (format->metadata, "date", NULL, 0))) {
content_created = tracker_date_guess (tag->value);
if (content_created) {
tracker_resource_set_string (metadata, "nie:contentCreated", content_created);
}
}
if (performer) {
tracker_resource_set_relation (metadata, "nmm:performer", performer);
}
if ((tag = av_dict_get (format->metadata, "composer", tag, 0))) {
if ((tag = find_tag (format, audio_stream, "composer"))) {
TrackerResource *composer = tracker_extract_new_artist (tag->value);
tracker_resource_set_relation (metadata, "nmm:composer", composer);
g_object_unref (composer);
......@@ -191,7 +207,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
int disc_number = 1;
TrackerResource *album_disc;
if ((tag = av_dict_get (format->metadata, "disc", NULL, 0))) {
if ((tag = find_tag (format, audio_stream, "disc"))) {
disc_number = atoi (tag->value);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment