~ubuntu-branches/ubuntu/utopic/mpd/utopic-proposed

« back to all changes in this revision

Viewing changes to src/icy_metadata.h

  • Committer: Package Import Robot
  • Author(s): Steve Kowalik
  • Date: 2013-11-12 18:17:40 UTC
  • mfrom: (2.2.36 sid)
  • Revision ID: package-import@ubuntu.com-20131112181740-72aa4zihehoobedp
Tags: 0.18.3-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - Add libmp3lame-dev to Build-Depends, and enable LAME.
  - Read the user for the daemon from the config file in the init script.
  - Move avahi-daemon from Suggests to Recommends.
  - Added apport hook to include user configuration file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2003-2011 The Music Player Daemon Project
3
 
 * http://www.musicpd.org
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (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 ICY_METADATA_H
21
 
#define ICY_METADATA_H
22
 
 
23
 
#include <stdbool.h>
24
 
#include <stddef.h>
25
 
 
26
 
struct icy_metadata {
27
 
        size_t data_size, data_rest;
28
 
 
29
 
        size_t meta_size, meta_position;
30
 
        char *meta_data;
31
 
 
32
 
        struct tag *tag;
33
 
};
34
 
 
35
 
/**
36
 
 * Initialize a disabled icy_metadata object.
37
 
 */
38
 
static inline void
39
 
icy_clear(struct icy_metadata *im)
40
 
{
41
 
        im->data_size = 0;
42
 
}
43
 
 
44
 
/**
45
 
 * Initialize an enabled icy_metadata object with the specified
46
 
 * data_size (from the icy-metaint HTTP response header).
47
 
 */
48
 
static inline void
49
 
icy_start(struct icy_metadata *im, size_t data_size)
50
 
{
51
 
        im->data_size = im->data_rest = data_size;
52
 
        im->meta_size = 0;
53
 
        im->tag = NULL;
54
 
}
55
 
 
56
 
/**
57
 
 * Resets the icy_metadata.  Call this after rewinding the stream.
58
 
 */
59
 
void
60
 
icy_reset(struct icy_metadata *im);
61
 
 
62
 
void
63
 
icy_deinit(struct icy_metadata *im);
64
 
 
65
 
/**
66
 
 * Checks whether the icy_metadata object is enabled.
67
 
 */
68
 
static inline bool
69
 
icy_defined(const struct icy_metadata *im)
70
 
{
71
 
        return im->data_size > 0;
72
 
}
73
 
 
74
 
/**
75
 
 * Evaluates data.  Returns the number of bytes of normal data which
76
 
 * can be read by the caller, but not more than "length".  If the
77
 
 * return value is smaller than "length", the caller should invoke
78
 
 * icy_meta().
79
 
 */
80
 
size_t
81
 
icy_data(struct icy_metadata *im, size_t length);
82
 
 
83
 
/**
84
 
 * Reads metadata from the stream.  Returns the number of bytes
85
 
 * consumed.  If the return value is smaller than "length", the caller
86
 
 * should invoke icy_data().
87
 
 */
88
 
size_t
89
 
icy_meta(struct icy_metadata *im, const void *data, size_t length);
90
 
 
91
 
static inline struct tag *
92
 
icy_tag(struct icy_metadata *im)
93
 
{
94
 
        struct tag *tag = im->tag;
95
 
        im->tag = NULL;
96
 
        return tag;
97
 
}
98
 
 
99
 
#endif