A modern, network-enabled music player platform built on Rockbox technology. rockboxd.tsiry-sandratraina.com
rust deno navidrome airplay libadwaita zig mpris snapcast mpd rockbox audio subsonic
2

Configure Feed

Select the types of activity you want to include in your feed.

rockboxd / lib / rbcodec / metadata / metadata_common.h
5.0 kB 126 lines
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * 9 * Copyright (C) 2005 Dave Chapman 10 * 11 * This program is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU General Public License 13 * as published by the Free Software Foundation; either version 2 14 * of the License, or (at your option) any later version. 15 * 16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 17 * KIND, either express or implied. 18 * 19 ****************************************************************************/ 20#include <inttypes.h> 21#include "metadata.h" 22 23/* In simulator / hosted-SDL-app builds, file descriptors for HTTP(S) streams 24 * are encoded as integers <= STREAM_HTTP_FD_BASE (-1000). Plain POSIX 25 * read() / lseek() / filesize() do not handle those values. Route all 26 * metadata I/O through the stream abstraction so that HTTP handles work 27 * identically to normal file descriptors. 28 * 29 * streamfd.h is in apps/, which is on the include path via -I$(APPSDIR) in 30 * uisimulator.make. The macros below are intentionally placed before the 31 * read_uint* macros so those expansions are also redirected. */ 32#if defined(SIMULATOR) || defined(APPLICATION) 33#include "streamfd.h" 34/* Route read() and lseek() through the stream abstraction so that HTTP(S) 35 * file descriptors (encoded as integers <= STREAM_HTTP_FD_BASE = -1000) are 36 * handled correctly by all metadata parsers. 37 * 38 * filesize() is intentionally NOT redefined here. It is also a member name 39 * of struct mp3entry (expanded via FS_PREFIX in firmware/include/file.h), so 40 * redefining it as a function-like macro would break every `id3->filesize` 41 * struct access with a "no member named 'filesize'" compiler error. 42 * 43 * Instead, metadata parsers that need a correct file size (e.g. for CBR 44 * duration estimation) must call metadata_filesize(fd), defined below. 45 * stream_filesize_fd() returns Content-Length for HTTP fds and delegates to 46 * the platform filesize() for regular fds. */ 47#ifdef read 48#undef read 49#endif 50#define read(fd, buf, n) stream_read((fd), (buf), (n)) 51#ifdef lseek 52#undef lseek 53#endif 54#define lseek(fd, off, whence) stream_lseek((fd), (off), (whence)) 55#define metadata_filesize(fd) stream_filesize_fd((fd)) 56#else 57#define metadata_filesize(fd) filesize(fd) 58#endif /* SIMULATOR || APPLICATION */ 59 60#ifdef ROCKBOX_BIG_ENDIAN 61#define IS_BIG_ENDIAN 1 62#else 63#define IS_BIG_ENDIAN 0 64#endif 65 66#define TAG_NAME_LENGTH 32 67#define TAG_VALUE_LENGTH 128 68 69#define FOURCC(a,b,c,d) ((((unsigned long)(a)) << 24) | (((unsigned long)(b)) << 16) | \ 70 (((unsigned long)(c)) << 8) | ((unsigned long)(d))) 71 72enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS }; 73 74bool read_ape_tags(int fd, struct mp3entry* id3); 75long read_vorbis_tags(int fd, struct mp3entry *id3, 76 long tag_remaining); 77 78struct ogg_file 79{ 80 int fd; 81 bool packet_ended; 82 long packet_remaining; 83}; 84 85#ifdef HAVE_ALBUMART 86int id3_unsynchronize(char* tag, int len, bool *ff_found); 87 88size_t base64_decode(const char *in, size_t in_len, unsigned char *out); 89 90bool parse_flac_album_art(unsigned char *buf, int bytes_read, enum mp3_aa_type *type, int *picframe_pos); 91 92int get_ogg_format_and_move_to_comments(int fd, unsigned char *buf); 93bool ogg_file_init(struct ogg_file* file, int fd, int type, int remaining); 94ssize_t ogg_file_read(struct ogg_file* file, void* buffer, size_t buffer_size); 95#endif 96 97int string_option(const char *option, const char *const oplist[], bool ignore_case); 98bool skip_id3v2(int fd, struct mp3entry *id3); 99long read_string(int fd, char* buf, long buf_size, int eos, long size); 100 101int read_uint8(int fd, uint8_t* buf); 102#ifdef ROCKBOX_BIG_ENDIAN 103#define read_uint16be(fd,buf) read((fd), (buf), 2) 104#define read_uint32be(fd,buf) read((fd), (buf), 4) 105#define read_uint64be(fd,buf) read((fd), (buf), 8) 106int read_uint16le(int fd, uint16_t* buf); 107int read_uint32le(int fd, uint32_t* buf); 108int read_uint64le(int fd, uint64_t* buf); 109#else 110int read_uint16be(int fd, uint16_t* buf); 111int read_uint32be(int fd, uint32_t* buf); 112int read_uint64be(int fd, uint64_t* buf); 113#define read_uint16le(fd,buf) read((fd), (buf), 2) 114#define read_uint32le(fd,buf) read((fd), (buf), 4) 115#define read_uint64le(fd,buf) read((fd), (buf), 8) 116#endif 117 118uint64_t get_uint64_le(void* buf); 119uint32_t get_long_le(void* buf); 120uint16_t get_short_le(void* buf); 121uint32_t get_long_be(void* buf); 122uint16_t get_short_be(void* buf); 123int32_t get_slong(void* buf); 124uint32_t get_itunes_int32(char* value, int count); 125long parse_tag(const char* name, char* value, struct mp3entry* id3, 126 char* buf, long buf_remaining, enum tagtype type);