• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* flac - Command-line FLAC encoder/decoder
2  * Copyright (C) 2000-2009  Josh Coalson
3  * Copyright (C) 2011-2016  Xiph.Org Foundation
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef flac__foreign_metadata_h
21 #define flac__foreign_metadata_h
22 
23 #ifdef HAVE_CONFIG_H
24 #  include <config.h>
25 #endif
26 
27 #include "FLAC/metadata.h"
28 #include "utils.h"
29 #include "share/compat.h"
30 
31 /* WATCHOUT: these enums are used to index internal arrays */
32 typedef enum {
33 	FOREIGN_BLOCK_TYPE__AIFF = 0, /* for AIFF and AIFF-C */
34 	FOREIGN_BLOCK_TYPE__RIFF = 1, /* for WAVE and RF64 */
35 	FOREIGN_BLOCK_TYPE__WAVE64 = 2  /* only for Sony's flavor */
36 } foreign_block_type_t;
37 
38 typedef struct {
39 	/* for encoding, this will be the offset in the WAVE/AIFF file of the chunk */
40 	/* for decoding, this will be the offset in the FLAC file of the chunk data inside the APPLICATION block */
41 	FLAC__off_t offset;
42 	/* size is the actual size in bytes of the chunk to be stored/recreated. */
43 	/* It includes the 8 bytes of chunk type and size, and any padding byte for alignment. */
44 	/* For 'data'/'SSND' chunks, the size does not include the actual sound or padding bytes */
45 	/* because these are not stored, they are recreated from the compressed FLAC stream. */
46 	/* So for RIFF 'data', size is 8, and for AIFF 'SSND', size is 8 + 8 + ssnd_offset_size */
47 	/* 32 bit size is OK because we only care about the non-sound data and FLAC metadata */
48 	/* only supports a few megs anyway. */
49 	FLAC__uint32 size;
50 } foreign_block_t;
51 
52 typedef struct {
53 	foreign_block_type_t type; /* currently we don't support multiple foreign types in a stream (and maybe never will) */
54 	foreign_block_t *blocks;
55 	size_t num_blocks;
56 	size_t format_block; /* block number of 'fmt ' or 'COMM' chunk */
57 	size_t audio_block; /* block number of 'data' or 'SSND' chunk */
58 	FLAC__bool is_rf64; /* always false if type!=RIFF */
59 	FLAC__uint32 ssnd_offset_size; /* 0 if type!=AIFF */
60 } foreign_metadata_t;
61 
62 foreign_metadata_t *flac__foreign_metadata_new(foreign_block_type_t type);
63 
64 void flac__foreign_metadata_delete(foreign_metadata_t *fm);
65 
66 FLAC__bool flac__foreign_metadata_read_from_aiff(foreign_metadata_t *fm, const char *filename, const char **error);
67 FLAC__bool flac__foreign_metadata_read_from_wave(foreign_metadata_t *fm, const char *filename, const char **error);
68 FLAC__bool flac__foreign_metadata_read_from_wave64(foreign_metadata_t *fm, const char *filename, const char **error);
69 FLAC__bool flac__foreign_metadata_write_to_flac(foreign_metadata_t *fm, const char *infilename, const char *outfilename, const char **error);
70 
71 FLAC__bool flac__foreign_metadata_read_from_flac(foreign_metadata_t *fm, const char *filename, const char **error);
72 FLAC__bool flac__foreign_metadata_write_to_iff(foreign_metadata_t *fm, const char *infilename, const char *outfilename, FLAC__off_t offset1, FLAC__off_t offset2, FLAC__off_t offset3, const char **error);
73 
74 #endif
75