summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/librm/rm.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/librm/rm.h')
-rw-r--r--lib/rbcodec/codecs/librm/rm.h102
1 files changed, 102 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/librm/rm.h b/lib/rbcodec/codecs/librm/rm.h
new file mode 100644
index 0000000000..c4a4e3a77e
--- /dev/null
+++ b/lib/rbcodec/codecs/librm/rm.h
@@ -0,0 +1,102 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2009 Mohamed Tarek
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _RM_H
22#define _RM_H
23
24#include <stdio.h>
25#include <inttypes.h>
26#include "bytestream.h"
27
28#define MAX_EXTRADATA_SIZE 16
29#define DATA_HEADER_SIZE 18
30#define PACKET_HEADER_SIZE 12
31
32enum codecs {
33 CODEC_COOK,
34 CODEC_AAC,
35 CODEC_AC3,
36 CODEC_ATRAC
37};
38
39typedef struct rm_packet
40{
41 uint8_t *frames[100]; /* Pointers to ordered audio frames in buffer */
42 uint16_t version;
43 uint16_t length;
44 uint32_t timestamp;
45 uint16_t stream_number;
46 uint8_t flags;
47
48#ifdef TEST
49 uint8_t data[30000]; /* Reordered data. No malloc, hence the size */
50#endif
51}RMPacket;
52
53typedef struct rm_context
54{
55 /* Demux Context */
56 int old_format;
57 int current_stream;
58 int remaining_len;
59 int audio_stream_num; /*< Stream number for audio packets*/
60 int audio_pkt_cnt; /* Output packet counter*/
61
62 /* Stream Variables */
63 uint32_t data_offset;
64 uint32_t duration;
65 uint32_t audiotimestamp; /* Audio packet timestamp*/
66 uint16_t sub_packet_cnt; /* Subpacket counter, used while reading */
67 uint16_t sub_packet_size, sub_packet_h, coded_framesize; /* Descrambling parameters from container */
68 uint16_t audio_framesize; /* Audio frame size from container */
69 uint16_t sub_packet_lengths[16]; /* Length of each subpacket */
70
71 /* Codec Context */
72 enum codecs codec_type;
73 uint16_t block_align;
74 uint32_t nb_packets;
75 int frame_number;
76 uint16_t sample_rate;
77 uint16_t nb_channels;
78 uint32_t bit_rate;
79 uint16_t flags;
80
81 /*codec extradata*/
82 uint32_t extradata_size;
83 uint8_t codec_extradata[MAX_EXTRADATA_SIZE];
84
85} RMContext;
86
87int real_parse_header(int fd, RMContext *rmctx);
88
89/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a memory buffer */
90int rm_get_packet(uint8_t **src,RMContext *rmctx, RMPacket *pkt);
91
92#ifdef TEST
93
94int filesize(int fd);
95void advance_buffer(uint8_t **buf, int val);
96
97/* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */
98void rm_get_packet_fd(int fd,RMContext *rmctx, RMPacket *pkt);
99
100#endif /* TEST */
101
102#endif /* _RM_H */