1 /* EasyTAG - tag editor for audio files
2 * Copyright (C) 2014 Abhinav Jangda <abhijangda@hotmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #include "config.h" /* For definition of ENABLE_OPUS */
20
21 #ifdef ENABLE_OPUS
22
23 #include <glib/gi18n.h>
24 #include <opus/opus.h>
25 #include <vorbis/codec.h>
26
27 #include "opus_tag.h"
28 #include "opus_header.h"
29 #include "ogg_tag.h"
30 #include "et_core.h"
31 #include "misc.h"
32 #include "picture.h"
33 #include "setting.h"
34 #include "charset.h"
35
36 #define MULTIFIELD_SEPARATOR " - "
37
38 /*
39 * et_opus_tag_read_file_tag:
40 * @filename: file from which to read tags
41 * @FileTag: File_Tag to read tag into
42 * @error: a GError or %NULL
43 *
44 * Read file tags and store into File_Tag.
45 *
46 * Returns: %TRUE if successful otherwise %FALSE
47 */
48 gboolean
et_opus_tag_read_file_tag(GFile * gfile,File_Tag * FileTag,GError ** error)49 et_opus_tag_read_file_tag (GFile *gfile, File_Tag *FileTag,
50 GError **error)
51 {
52 OggOpusFile *file;
53 const OpusTags *tags;
54
55 g_return_val_if_fail (gfile != NULL && FileTag != NULL, FALSE);
56 g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
57
58 file = et_opus_open_file (gfile, error);
59
60 if (!file)
61 {
62 g_assert (error == NULL || *error != NULL);
63 return FALSE;
64 }
65
66 tags = op_tags (file, 0);
67
68 /* The cast is safe according to the opusfile documentation. */
69 et_add_file_tags_from_vorbis_comments ((vorbis_comment *)tags, FileTag);
70
71 op_free (file);
72
73 g_assert (error == NULL || *error == NULL);
74 return TRUE;
75 }
76
77 #endif
78