1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 Mohamed Tarek
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "bytestream.h"
28 #define MAX_EXTRADATA_SIZE 16
29 #define DATA_HEADER_SIZE 18
30 #define PACKET_HEADER_SIZE 12
39 typedef struct rm_packet
41 uint8_t *frames
[100]; /* Pointers to ordered audio frames in buffer */
45 uint16_t stream_number
;
49 uint8_t data
[30000]; /* Reordered data. No malloc, hence the size */
53 typedef struct rm_context
59 int audio_stream_num
; /*< Stream number for audio packets*/
60 int audio_pkt_cnt
; /* Output packet counter*/
62 /* Stream Variables */
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 */
72 enum codecs codec_type
;
82 uint32_t extradata_size
;
83 uint8_t codec_extradata
[MAX_EXTRADATA_SIZE
];
87 int real_parse_header(int fd
, RMContext
*rmctx
);
89 /* Get a (sub_packet_h*frames_per_packet) number of audio frames from a memory buffer */
90 int rm_get_packet(uint8_t **src
,RMContext
*rmctx
, RMPacket
*pkt
);
95 void advance_buffer(uint8_t **buf
, int val
);
97 /* Get a (sub_packet_h*frames_per_packet) number of audio frames from a file descriptor */
98 void rm_get_packet_fd(int fd
,RMContext
*rmctx
, RMPacket
*pkt
);