FFmpeg
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavformat
apetagenc.c
Go to the documentation of this file.
1
/*
2
* APE tag writer
3
* Copyright (c) 2012 Paul B Mahol
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#include "
libavutil/dict.h
"
23
#include "
avio_internal.h
"
24
#include "
avformat.h
"
25
#include "
apetag.h
"
26
27
static
int
string_is_ascii
(
const
uint8_t
*str)
28
{
29
while
(*str && *str >= 0x20 && *str <= 0x7e ) str++;
30
return
!*str;
31
}
32
33
void
ff_ape_write
(
AVFormatContext
*s)
34
{
35
int64_t tag_bytes;
36
AVDictionaryEntry
*
t
=
NULL
;
37
AVIOContext
*pb = s->
pb
;
38
int
tags = 0, vlen;
39
40
tag_bytes =
avio_tell
(s->
pb
);
41
while
((t =
av_dict_get
(s->
metadata
,
""
, t,
AV_DICT_IGNORE_SUFFIX
))) {
42
if
(!
string_is_ascii
(t->
key
)) {
43
av_log
(s,
AV_LOG_WARNING
,
"Non ASCII keys are not allowed\n"
);
44
continue
;
45
}
46
47
vlen = strlen(t->
value
);
48
avio_wl32
(pb, vlen + 1);
49
avio_wl32
(pb, 0);
// flags
50
avio_put_str
(pb, t->
key
);
51
avio_put_str
(pb, t->
value
);
52
tags++;
53
}
54
tag_bytes =
avio_tell
(s->
pb
) - tag_bytes;
55
56
if
(!tags)
57
return
;
58
59
avio_write
(pb,
APE_TAG_PREAMBLE
, 8);
60
avio_wl32
(pb,
APE_TAG_VERSION
);
61
avio_wl32
(pb, tag_bytes +
APE_TAG_FOOTER_BYTES
);
62
avio_wl32
(pb, tags);
// item count
63
avio_wl32
(pb, 0);
// global flags
64
ffio_fill
(pb, 0, 8);
// reserved
65
}
Generated on Sat May 25 2013 03:58:46 for FFmpeg by
1.8.2