gth-metadata-provider-gstreamer.c 2.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  GThumb
 *
 *  Copyright (C) 2009 Free Software Foundation, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
 */

#include <config.h>
#include <glib.h>
#include <gthumb.h>
#include "gstreamer-utils.h"
#include "gth-metadata-provider-gstreamer.h"


30
static GthMetadataProviderClass *parent_class = NULL;
31
32


33
34
35
36
37
38
39
40
41
42
static gboolean
gth_metadata_provider_gstreamer_can_read (GthMetadataProvider  *self,
				          const char           *mime_type,
				          char                **attribute_v)
{
	if (! _g_content_type_is_a (mime_type, "audio/*")
	    && ! _g_content_type_is_a (mime_type, "video/*"))
	{
		return FALSE;
	}
43

44
45
	return _g_file_attributes_matches_any_v ("general::title,"
						 "general::format,"
46
47
48
49
						 "general::dimensions,"
						 "audio-video::*",
					         attribute_v);
}
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74


static void
gth_metadata_provider_gstreamer_read (GthMetadataProvider *self,
				      GthFileData         *file_data,
				      const char          *attributes)
{
	if (! g_content_type_is_a (gth_file_data_get_mime_type (file_data), "audio/*")
	    && ! g_content_type_is_a (gth_file_data_get_mime_type (file_data), "video/*"))
	{
		return;
	}

	/* this function is executed in a secondary thread, so calling
	 * slow sync functions is not a problem. */

	gstreamer_read_metadata_from_file (file_data->file, file_data->info, NULL);
}


static void
gth_metadata_provider_gstreamer_class_init (GthMetadataProviderGstreamerClass *klass)
{
	parent_class = g_type_class_peek_parent (klass);

75
	GTH_METADATA_PROVIDER_CLASS (klass)->can_read = gth_metadata_provider_gstreamer_can_read;
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
	GTH_METADATA_PROVIDER_CLASS (klass)->read = gth_metadata_provider_gstreamer_read;
}


GType
gth_metadata_provider_gstreamer_get_type (void)
{
	static GType type = 0;

	if (! type) {
		GTypeInfo type_info = {
			sizeof (GthMetadataProviderGstreamerClass),
			NULL,
			NULL,
			(GClassInitFunc) gth_metadata_provider_gstreamer_class_init,
			NULL,
			NULL,
			sizeof (GthMetadataProviderGstreamer),
			0,
95
			(GInstanceInitFunc) NULL
96
97
98
99
100
101
102
103
104
105
		};

		type = g_type_register_static (GTH_TYPE_METADATA_PROVIDER,
					       "GthMetadataProviderGstreamer",
					       &type_info,
					       0);
	}

	return type;
}