* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
-/** \file aac_afh.c para_server's aac audio format handler */
+/*
+ * based in parts on libfaad, Copyright (C) 2003-2005 M. Bakker,
+ * Ahead Software AG
+ */
+/** \file aac_afh.c para_server's aac audio format handler */
#include "server.cmdline.h"
#include "server.h"
{
}
-static int read_stsz(unsigned skip)
+static int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip)
+{
+ int i;
+
+ for (i = 0; i + 16 < buflen; i++) {
+ unsigned char *p = buf + i;
+ unsigned sample_count, sample_size;
+
+ if (p[0] != 's' || p[1] != 't' || p[2] != 's' || p[3] != 'z')
+ continue;
+ PARA_INFO_LOG("found stsz@%d\n", i);
+ i += 8;
+ sample_size = aac_read_int32(buf + i);
+ PARA_INFO_LOG("sample size: %d\n", sample_size);
+ i += 4;
+ sample_count = aac_read_int32(buf + i);
+ i += 4;
+ PARA_INFO_LOG("sample count: %d\n", sample_count);
+ *skip = i;
+ return sample_count;
+ }
+ PARA_WARNING_LOG("stsz not found, buflen: %d\n", buflen);
+ return -E_STSZ;
+}
+
+static int read_chunk_table(unsigned skip)
{
int ret, i;
long unsigned sum = 0;
}
-
/*
* Init m4a file and write some tech data to given pointers.
*/
} else
PARA_WARNING_LOG("no mp4ASC %s\n", "");
- ret = read_stsz(skip);
+ ret = read_chunk_table(skip);
if (ret < 0)
return ret;
*frames = num_chunks;
for (;;) {
- ret = aac_find_entry(inbuf, inbuf_len, &skip);
+ ret = aac_find_entry_point(inbuf, inbuf_len, &skip);
if (ret >= 0)
break;
ret = read(fileno(infile), inbuf, inbuf_size);
*/
static int aac_reposition_stream(long unsigned request)
{
- return -E_AAC_REPOS;
+ return 1;
+// return -E_AAC_REPOS;
}
static __must_check int para_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
return -E_FREAD;
}
-char *aac_read_chunk(long unsigned current_chunk, ssize_t *len)
+static char *aac_read_chunk(long unsigned current_chunk, ssize_t *len)
{
int ret;
size_t pos;