2023-08-30 16:21:18 +08:00
|
|
|
/*
|
2024-09-03 11:16:08 +08:00
|
|
|
* Copyright (C) 2020-2024 ArtInChip Technology Co. Ltd
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*
|
|
|
|
|
* Author: <jun.ma@artinchip.com>
|
|
|
|
|
* Desc: aic parser
|
|
|
|
|
*/
|
2023-08-30 16:21:18 +08:00
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "aic_mov_parser.h"
|
|
|
|
|
#include "aic_raw_parser.h"
|
2023-11-30 19:48:02 +08:00
|
|
|
#include "aic_mp3_parser.h"
|
2024-04-03 16:40:57 +08:00
|
|
|
#include "aic_wav_parser.h"
|
2024-06-04 19:00:30 +08:00
|
|
|
#ifdef AIC_MPP_AVI_DEMUX
|
|
|
|
|
#include "aic_avi_parser.h"
|
|
|
|
|
#endif
|
2024-10-30 16:50:31 +08:00
|
|
|
#ifdef AIC_MPP_FLAC_DEMUX
|
|
|
|
|
#include "aic_flac_parser.h"
|
|
|
|
|
#endif
|
2024-06-04 19:00:30 +08:00
|
|
|
|
|
|
|
|
struct aic_parser_create_tbl {
|
|
|
|
|
char file_type[7];
|
|
|
|
|
unsigned char len;
|
|
|
|
|
s32 (*parser)(unsigned char *uri, struct aic_parser **parser);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct aic_parser_create_tbl create_tbl[] = {
|
|
|
|
|
{"mov", 3, aic_mov_parser_create},
|
|
|
|
|
{"mp4", 3, aic_mov_parser_create},
|
|
|
|
|
{"264", 3, aic_raw_parser_create},
|
|
|
|
|
{"mp3", 3, aic_mp3_parser_create},
|
|
|
|
|
{"wav", 3, aic_wav_parser_create},
|
|
|
|
|
#ifdef AIC_MPP_AVI_DEMUX
|
|
|
|
|
{"avi", 3, aic_avi_parser_create},
|
|
|
|
|
#endif
|
2024-10-30 16:50:31 +08:00
|
|
|
#ifdef AIC_MPP_FLAC_DEMUX
|
|
|
|
|
{"flac", 4, aic_flac_parser_create},
|
|
|
|
|
#endif
|
2024-06-04 19:00:30 +08:00
|
|
|
};
|
2023-08-30 16:21:18 +08:00
|
|
|
s32 aic_parser_create(unsigned char *uri, struct aic_parser **parser)
|
|
|
|
|
{
|
2024-06-04 19:00:30 +08:00
|
|
|
int i = 0;
|
2023-08-30 16:21:18 +08:00
|
|
|
char* ptr = NULL;
|
2024-06-04 19:00:30 +08:00
|
|
|
int size = 0;
|
2023-08-30 16:21:18 +08:00
|
|
|
|
|
|
|
|
if (uri == NULL) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ptr = strrchr((char *)uri, '.');
|
|
|
|
|
if (ptr == NULL) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-04 19:00:30 +08:00
|
|
|
printf("parser for (%s)\n", uri);
|
|
|
|
|
|
|
|
|
|
size = sizeof(create_tbl)/sizeof(struct aic_parser_create_tbl);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) {
|
|
|
|
|
if (!strncmp(ptr+1, create_tbl[i].file_type, create_tbl[i].len)) {
|
|
|
|
|
return create_tbl[i].parser(uri, parser);
|
|
|
|
|
}
|
2023-08-30 16:21:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logw("unkown parser for (%s)", uri);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|