1 /* metaflac - Command-line FLAC metadata editor
2 * Copyright (C) 2001,2002,2003,2004 Josh Coalson
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "FLAC/assert.h"
22 #include "FLAC/metadata.h"
25 FLAC__bool do_shorthand_operation__streaminfo(const char *filename, FLAC__bool prefix_with_filename, FLAC__Metadata_Chain *chain, const Operation *operation, FLAC__bool *needs_write)
29 FLAC__StreamMetadata *block;
30 FLAC__Metadata_Iterator *iterator = FLAC__metadata_iterator_new();
33 die("out of memory allocating iterator");
35 FLAC__metadata_iterator_init(iterator, chain);
37 block = FLAC__metadata_iterator_get_block(iterator);
39 FLAC__ASSERT(0 != block);
40 FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_STREAMINFO);
42 if(prefix_with_filename)
43 printf("%s:", filename);
45 switch(operation->type) {
47 for(i = 0; i < 16; i++)
48 printf("%02x", block->data.stream_info.md5sum[i]);
51 case OP__SHOW_MIN_BLOCKSIZE:
52 printf("%u\n", block->data.stream_info.min_blocksize);
54 case OP__SHOW_MAX_BLOCKSIZE:
55 printf("%u\n", block->data.stream_info.max_blocksize);
57 case OP__SHOW_MIN_FRAMESIZE:
58 printf("%u\n", block->data.stream_info.min_framesize);
60 case OP__SHOW_MAX_FRAMESIZE:
61 printf("%u\n", block->data.stream_info.max_framesize);
63 case OP__SHOW_SAMPLE_RATE:
64 printf("%u\n", block->data.stream_info.sample_rate);
66 case OP__SHOW_CHANNELS:
67 printf("%u\n", block->data.stream_info.channels);
70 printf("%u\n", block->data.stream_info.bits_per_sample);
72 case OP__SHOW_TOTAL_SAMPLES:
74 printf("%I64u\n", block->data.stream_info.total_samples);
76 printf("%llu\n", block->data.stream_info.total_samples);
80 memcpy(block->data.stream_info.md5sum, operation->argument.streaminfo_md5.value, 16);
83 case OP__SET_MIN_BLOCKSIZE:
84 block->data.stream_info.min_blocksize = operation->argument.streaminfo_uint32.value;
87 case OP__SET_MAX_BLOCKSIZE:
88 block->data.stream_info.max_blocksize = operation->argument.streaminfo_uint32.value;
91 case OP__SET_MIN_FRAMESIZE:
92 block->data.stream_info.min_framesize = operation->argument.streaminfo_uint32.value;
95 case OP__SET_MAX_FRAMESIZE:
96 block->data.stream_info.max_framesize = operation->argument.streaminfo_uint32.value;
99 case OP__SET_SAMPLE_RATE:
100 block->data.stream_info.sample_rate = operation->argument.streaminfo_uint32.value;
103 case OP__SET_CHANNELS:
104 block->data.stream_info.channels = operation->argument.streaminfo_uint32.value;
108 block->data.stream_info.bits_per_sample = operation->argument.streaminfo_uint32.value;
111 case OP__SET_TOTAL_SAMPLES:
112 block->data.stream_info.total_samples = operation->argument.streaminfo_uint64.value;
121 FLAC__metadata_iterator_delete(iterator);