aispeech: 32bit 4mic add source code
Change-Id: I65686004a3c6c031a823369180176ac1d0b986ba Signed-off-by: Sun ChuanHu <aaron.sun@rock-chips.com>
This commit is contained in:
27
rk3308/aispeech-4mic-32bit/dds_client/aimake/README
Executable file
27
rk3308/aispeech-4mic-32bit/dds_client/aimake/README
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
aimake is a mini building tool based on gnu make. it's easy to cross compile shared library or static library for ios and android.
|
||||||
|
|
||||||
|
it's green, you don't need to install it
|
||||||
|
|
||||||
|
1. requirements:
|
||||||
|
(1) gnu make, aimake was based on gnu make
|
||||||
|
(2) [optional] ios sdk, it's required if you need to build your project for ios
|
||||||
|
(3) [optional] android ndk, it's required if you need to build your project for android
|
||||||
|
|
||||||
|
2. how to use aimake?
|
||||||
|
(1) copy 'aimakefile' to your project folder
|
||||||
|
(2) modify variables in aimakfile for your compilation requirement
|
||||||
|
(4) run 'aimake' (aimake is a soft link pointing to aimake.sh)
|
||||||
|
|
||||||
|
3. how to support more target platforms
|
||||||
|
the sub-folder(ios, android) means supported target platform, and the name of sub-folder is some as target platform's name.
|
||||||
|
Every sub-folder must contains the following files:
|
||||||
|
init.mk -- initialize variables of compilation environment, e.g. CC, CXX, CFLAGS, CXXFLAGS
|
||||||
|
build_executable.mk -- specify that compile the project into executable
|
||||||
|
build_static_library.mk -- specify that compile the project into static library
|
||||||
|
build_shared_library.mk -- specify that compile the project into shared library
|
||||||
|
build_all.mk -- contains explicit rules and goals for gnu make
|
||||||
|
|
||||||
|
just enjoy it
|
||||||
|
|
||||||
|
aaashun@gmail.com
|
||||||
|
2011-09-29
|
||||||
49
rk3308/aispeech-4mic-32bit/dds_client/aimake/aimake.sh
Executable file
49
rk3308/aispeech-4mic-32bit/dds_client/aimake/aimake.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
version="0.2"
|
||||||
|
|
||||||
|
host_platform=`uname | awk -F[_0-9] '{print tolower($1)}'`
|
||||||
|
|
||||||
|
if [[ $host_platform == "darwin" ]]; then
|
||||||
|
aimake_home=`readlink $0 | sed 's/\/[^\/]*$//'`
|
||||||
|
if [[ -z $aimake_home ]]; then
|
||||||
|
aimake_home=`echo $0 | sed 's/\/[^\/]*$//'`
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
aimake_home=`readlink -f $0 | sed 's/\/[^\/]*$//'`;
|
||||||
|
fi;
|
||||||
|
|
||||||
|
supported_platforms=`ls -l $aimake_home | awk '/^d/{printf("%s%s", sp, $NF); sp=" ";}'`
|
||||||
|
|
||||||
|
aimakefile="aimakefile"
|
||||||
|
target_platform=$host_platform
|
||||||
|
timestamp=`date +20%y%m%d%H%M%S`
|
||||||
|
jobs=1
|
||||||
|
|
||||||
|
while getopts "j:t:f:h" opt; do
|
||||||
|
case $opt in
|
||||||
|
j) jobs=$OPTARG;;
|
||||||
|
f) aimakefile=$OPTARG;;
|
||||||
|
t) target_platform=$OPTARG;;
|
||||||
|
h|?) echo "usage: aimake [options] [target]"; echo ""
|
||||||
|
echo "options:"
|
||||||
|
echo " -h show this help message and exit"
|
||||||
|
echo " -j number of jobs to run simultaneously"
|
||||||
|
echo " -t target platform, support '$supported_platforms', the default is '$host_platform'"
|
||||||
|
echo " -f aimakefile, the default is 'aimakefile'"
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! [[ -d $aimake_home/$target_platform ]]; then
|
||||||
|
echo "unsupported target platform '"$target_platform"'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -f $aimakefile ]]; then
|
||||||
|
echo "'$aimakefile' does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
make -j $jobs -f $aimake_home/main.mk LOCAL_PATH=`pwd` TIMESTAMP=$timestamp TARGET_PLATFORM=$target_platform AIMAKE_VERSION=$version AIMAKE_HOME=$aimake_home AIMAKEFILE=$aimakefile "$@"
|
||||||
19
rk3308/aispeech-4mic-32bit/dds_client/aimake/aimakefile
Executable file
19
rk3308/aispeech-4mic-32bit/dds_client/aimake/aimakefile
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#
|
||||||
|
# this is a template for aimakefile
|
||||||
|
# you just need to initialize the following variables
|
||||||
|
# then you can compile your project into executable, static libarary or shared library for specific platform, e.g. ios, android, linux, darwin
|
||||||
|
#
|
||||||
|
|
||||||
|
#LOCAL_SRC_DIRS := foo
|
||||||
|
#LOCAL_SRC_DIRS_EXCULDE := foo/foo2
|
||||||
|
LOCAL_SRC_FILES := foo.c func.cpp
|
||||||
|
#LOCAL_SRC_FILES_EXCLUDE := func.cpp
|
||||||
|
|
||||||
|
LOCAL_MODULE := foo
|
||||||
|
LOCAL_CFLAGS := -w
|
||||||
|
LOCAL_CXXFLAGS := -Wall -O3
|
||||||
|
#LOCAL_LDFLAGS := -lpthread
|
||||||
|
|
||||||
|
include $(BUILD_EXECUTABLE)
|
||||||
|
#include $(BUILD_STATIC_LIBRARY)
|
||||||
|
#include $(BUILD_SHARED_LIBRARY)
|
||||||
79
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/build_all.mk
Executable file
79
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/build_all.mk
Executable file
@ -0,0 +1,79 @@
|
|||||||
|
#
|
||||||
|
# objects
|
||||||
|
#
|
||||||
|
ifneq ($(LOCAL_SRC_DIRS),)
|
||||||
|
LOCAL_SRC_FILES += $(shell find $(LOCAL_SRC_DIRS) -name "*.c" -or -name "*.cpp" -or -name "*.cc")
|
||||||
|
endif
|
||||||
|
ifneq ($(LOCAL_SRC_DIRS_EXCLUDE),)
|
||||||
|
LOCAL_SRC_FILES_EXCLUDE += $(shell find $(LOCAL_SRC_DIRS_EXCLUDE) -name "*.c" -or -name "*.cpp" -or -name "*.cc")
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(filter-out $(LOCAL_SRC_FILES_EXCLUDE), $(LOCAL_SRC_FILES))
|
||||||
|
|
||||||
|
OBJECTS = $(subst .c,.o,$(subst .cpp,.o,$(subst .cc,.o,$(LOCAL_SRC_FILES))))
|
||||||
|
|
||||||
|
#
|
||||||
|
# building targets
|
||||||
|
#
|
||||||
|
EXECUTABLE = $(LOCAL_MODULE)
|
||||||
|
SHARED_LIBRARY = lib$(LOCAL_MODULE).so
|
||||||
|
STATIC_LIBRARY = lib$(LOCAL_MODULE).a
|
||||||
|
PACKAGE = $(shell basename .t/$(LOCAL_MODULE))-$(TARGET_PLATFORM)-$(shell uname -m)-$(VERSION)-$(TIMESTAMP).tar.gz
|
||||||
|
|
||||||
|
#
|
||||||
|
# explict rules
|
||||||
|
#
|
||||||
|
%.o : %.c
|
||||||
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o : %.cc
|
||||||
|
$(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o : %.cpp
|
||||||
|
$(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: all
|
||||||
|
#
|
||||||
|
all: $(ALL)
|
||||||
|
|
||||||
|
$(EXECUTABLE) : $(OBJECTS)
|
||||||
|
$(CXX) $^ $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
$(STATIC_LIBRARY) : $(OBJECTS)
|
||||||
|
$(AR) crv $@ $^
|
||||||
|
|
||||||
|
$(SHARED_LIBRARY) : $(OBJECTS)
|
||||||
|
$(CXX) $^ $(LDFLAGS) $(LOCAL_LDFLAGS) -o $@
|
||||||
|
$(STRIP) --strip-unneeded $@
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: clean
|
||||||
|
#
|
||||||
|
clean:
|
||||||
|
rm -rf $(ALL) $(OBJECTS)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: package
|
||||||
|
#
|
||||||
|
ifeq ($(findstring package,$(MAKECMDGOALS)),package)
|
||||||
|
ifeq ($(VERSION),)
|
||||||
|
$(error require argument 'VERSION' for 'package' goal)
|
||||||
|
endif
|
||||||
|
ifeq ($(PACKAGE_RESOURCES),)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
PACKAGE_TEMP_DIR = $(PACKAGE:.tar.gz=)
|
||||||
|
package: $(PACKAGE)
|
||||||
|
$(PACKAGE): $(ALL)
|
||||||
|
@[ -e $(PACKAGE_TEMP_DIR) ] && echo "$(PACKAGE_TEMP_DIR) already exist, please delete it manually" && exit;\
|
||||||
|
rm -rf $(PACKAGE_TEMP_DIR);\
|
||||||
|
rm -rf $@;
|
||||||
|
mkdir -p $(PACKAGE_TEMP_DIR);
|
||||||
|
cp -rf -L $(ALL) $(LOCAL_PACKAGE_RESOURCES) $(PACKAGE_TEMP_DIR);
|
||||||
|
tar --exclude .svn -h -czf $@ $(PACKAGE_TEMP_DIR);
|
||||||
|
rm -rf $(PACKAGE_TEMP_DIR);
|
||||||
2
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/build_executable.mk
Executable file
2
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/build_executable.mk
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
ALL = $(EXECUTABLE)
|
||||||
|
include $(BUILD_ALL)
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
LDFLAGS := -shared $(LDFLAGS)
|
||||||
|
|
||||||
|
ALL = $(SHARED_LIBRARY)
|
||||||
|
include $(BUILD_ALL)
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
ALL = $(STATIC_LIBRARY)
|
||||||
|
include $(BUILD_ALL)
|
||||||
11
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/init.mk
Executable file
11
rk3308/aispeech-4mic-32bit/dds_client/aimake/linux/init.mk
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
CC = gcc
|
||||||
|
LD = ld
|
||||||
|
CPP = cpp
|
||||||
|
CXX = g++
|
||||||
|
AR = ar
|
||||||
|
AS = as
|
||||||
|
NM = nm
|
||||||
|
STRIP = strip
|
||||||
|
CFLAGS :=
|
||||||
|
CXXFLAGS := $(CFLAGS)
|
||||||
|
LDFLAGS := -lpthread -lrt -lm
|
||||||
7
rk3308/aispeech-4mic-32bit/dds_client/aimake/main.mk
Executable file
7
rk3308/aispeech-4mic-32bit/dds_client/aimake/main.mk
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
BUILD_STATIC_LIBRARY = $(AIMAKE_HOME)/$(TARGET_PLATFORM)/build_static_library.mk
|
||||||
|
BUILD_SHARED_LIBRARY = $(AIMAKE_HOME)/$(TARGET_PLATFORM)/build_shared_library.mk
|
||||||
|
BUILD_EXECUTABLE = $(AIMAKE_HOME)/$(TARGET_PLATFORM)/build_executable.mk
|
||||||
|
BUILD_ALL = $(AIMAKE_HOME)/$(TARGET_PLATFORM)/build_all.mk
|
||||||
|
|
||||||
|
include $(AIMAKE_HOME)/$(TARGET_PLATFORM)/init.mk
|
||||||
|
include $(AIMAKEFILE)
|
||||||
80
rk3308/aispeech-4mic-32bit/dds_client/aimake/rk3308_32/build_all.mk
Executable file
80
rk3308/aispeech-4mic-32bit/dds_client/aimake/rk3308_32/build_all.mk
Executable file
@ -0,0 +1,80 @@
|
|||||||
|
#
|
||||||
|
# objects
|
||||||
|
#
|
||||||
|
ifneq ($(LOCAL_SRC_DIRS),)
|
||||||
|
LOCAL_SRC_FILES += $(shell find $(LOCAL_SRC_DIRS) -name "*.c" -or -name "*.cpp" -or -name "*.cc")
|
||||||
|
endif
|
||||||
|
ifneq ($(LOCAL_SRC_DIRS_EXCLUDE),)
|
||||||
|
LOCAL_SRC_FILES_EXCLUDE += $(shell find $(LOCAL_SRC_DIRS_EXCLUDE) -name "*.c" -or -name "*.cpp" -or -name "*.cc")
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := $(filter-out $(LOCAL_SRC_FILES_EXCLUDE), $(LOCAL_SRC_FILES))
|
||||||
|
|
||||||
|
OBJECTS = $(subst .c,.o,$(subst .cpp,.o,$(subst .cc,.o,$(LOCAL_SRC_FILES))))
|
||||||
|
|
||||||
|
#
|
||||||
|
# building targets
|
||||||
|
#
|
||||||
|
EXECUTABLE = $(LOCAL_MODULE)
|
||||||
|
SHARED_LIBRARY = lib$(LOCAL_MODULE).so
|
||||||
|
STATIC_LIBRARY = lib$(LOCAL_MODULE).a
|
||||||
|
PACKAGE = $(LOCAL_MODULE)-$(TARGET_PLATFORM)-$(VERSION)-$(TIMESTAMP).tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# explict rules
|
||||||
|
#
|
||||||
|
%.o : %.c
|
||||||
|
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o : %.cc
|
||||||
|
$(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
%.o : %.cpp
|
||||||
|
$(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: all
|
||||||
|
#
|
||||||
|
all: $(ALL)
|
||||||
|
|
||||||
|
$(EXECUTABLE) : $(OBJECTS)
|
||||||
|
$(CXX) $^ $(LDFLAGS) $(LOCAL_LDFLAGS) -o $@
|
||||||
|
|
||||||
|
$(STATIC_LIBRARY) : $(OBJECTS)
|
||||||
|
$(AR) crv $@ $^
|
||||||
|
|
||||||
|
$(SHARED_LIBRARY) : $(OBJECTS)
|
||||||
|
$(CXX) $^ $(LDFLAGS) $(LOCAL_LDFLAGS) -o $@
|
||||||
|
$(STRIP) --strip-unneeded $@
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: clean
|
||||||
|
#
|
||||||
|
clean:
|
||||||
|
rm -rf $(EXECUTABLE) $(STATIC_LIBRARY) $(SHARED_LIBRARY) $(PACKAGE) $(OBJECTS)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# goal: package
|
||||||
|
#
|
||||||
|
ifeq ($(findstring package,$(MAKECMDGOALS)),package)
|
||||||
|
ifeq ($(VERSION),)
|
||||||
|
$(error require argument 'VERSION' for 'package' goal)
|
||||||
|
endif
|
||||||
|
ifeq ($(PACKAGE_RESOURCES),)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
PACKAGE_TEMP_DIR = $(PACKAGE:.tar.gz=)
|
||||||
|
package: $(PACKAGE)
|
||||||
|
$(PACKAGE): $(ALL)
|
||||||
|
@[ -e $(PACKAGE_TEMP_DIR) ] && echo "$(PACKAGE_TEMP_DIR) already exist, please delete it manually" && exit;\
|
||||||
|
rm -rf $(PACKAGE_TEMP_DIR);\
|
||||||
|
rm -rf $@;
|
||||||
|
mkdir -p $(PACKAGE_TEMP_DIR);
|
||||||
|
cp -rf -L $(ALL) $(LOCAL_PACKAGE_RESOURCES) $(PACKAGE_TEMP_DIR);
|
||||||
|
tar --exclude .svn -h -czf $@ $(PACKAGE_TEMP_DIR);
|
||||||
|
rm -rf $(PACKAGE_TEMP_DIR);
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
ALL = $(EXECUTABLE)
|
||||||
|
include $(BUILD_ALL)
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
LDFLAGS := -shared $(LDFLAGS)
|
||||||
|
|
||||||
|
ALL = $(SHARED_LIBRARY)
|
||||||
|
include $(BUILD_ALL)
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
LDFLAGS := -static $(LDFLAGS)
|
||||||
|
ALL = $(STATIC_LIBRARY)
|
||||||
|
include $(BUILD_ALL)
|
||||||
26
rk3308/aispeech-4mic-32bit/dds_client/aimake/rk3308_32/init.mk
Executable file
26
rk3308/aispeech-4mic-32bit/dds_client/aimake/rk3308_32/init.mk
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# RK3308 32bit linux configuration
|
||||||
|
#
|
||||||
|
RK3308_LINUX_NDK_HOME =../../../../../buildroot/output/rockchip_rk3308_32_release/host/usr
|
||||||
|
TOOLCHAINS = $(RK3308_LINUX_NDK_HOME)
|
||||||
|
PLATFORM = $(RK3308_LINUX_NDK_HOME)
|
||||||
|
LIBEXEC = $(RK3308_LINUX_NDK_HOME)/libexec/gcc/arm-rockchip-linux-gnueabihf/6.4.0/
|
||||||
|
CXX_STL = $(RK3308_LINUX_NDK_HOME)/arm-rockchip-linux-gnueabihf/include/c++/6.4.0
|
||||||
|
|
||||||
|
CC = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-gcc
|
||||||
|
LD = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-ld
|
||||||
|
CPP = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-cpp
|
||||||
|
CXX = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-c++
|
||||||
|
AR = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-ar
|
||||||
|
AS = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-as
|
||||||
|
NM = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-nm
|
||||||
|
STRIP = $(TOOLCHAINS)/bin/arm-rockchip-linux-gnueabihf-strip
|
||||||
|
|
||||||
|
|
||||||
|
#CFLAGS := -fsigned-char -mfloat-abi=softfp -mfpu=neon
|
||||||
|
CFLAGS := -fsigned-char
|
||||||
|
|
||||||
|
CXXFLAGS := $(CFLAGS) -I $(CXX_STL)
|
||||||
|
|
||||||
|
LDFLAGS := -L$(PLATFORM)/arm-rockchip-linux-gnueabihf/lib -L$(LIBEXEC) -lpthread -ldl -lrt --sysroot=$(RK3308_LINUX_NDK_HOME)/arm-rockchip-linux-gnueabihf/sysroot
|
||||||
|
|
||||||
35
rk3308/aispeech-4mic-32bit/dds_client/aimakefile
Executable file
35
rk3308/aispeech-4mic-32bit/dds_client/aimakefile
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
LOCAL_SRC_DIRS := ./components/fsm
|
||||||
|
#LOCAL_SRC_DIRS_EXCULDE :=
|
||||||
|
LOCAL_SRC_FILES := ./components/dui/dui_major_minor_multiple.c
|
||||||
|
LOCAL_SRC_FILES += ./components/json/cJSON.c
|
||||||
|
LOCAL_SRC_FILES += ./example/main.c
|
||||||
|
#LOCAL_SRC_FILES_EXCLUDE :=
|
||||||
|
#LOCAL_SRC_FILES_EXCLUDE :=
|
||||||
|
|
||||||
|
LOCAL_MODULE := dui_$(MIC_TYPE)
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := -Wall -O2
|
||||||
|
#LOCAL_CFLAGS += -DSAVE_AUDIO
|
||||||
|
ifeq ($(MIC_TYPE), fespa)
|
||||||
|
LOCAL_CFLAGS += -DWAKEUP_FESPA
|
||||||
|
else ifeq ($(MIC_TYPE), fespl)
|
||||||
|
LOCAL_CFLAGS += -DWAKEUP_FESPL
|
||||||
|
endif
|
||||||
|
LOCAL_CFLAGS += -I ./include
|
||||||
|
LOCAL_CFLAGS += -I ./components/json
|
||||||
|
LOCAL_CFLAGS += -I ./components/dui/include
|
||||||
|
LOCAL_CFLAGS += -I ./components/fsm/include
|
||||||
|
|
||||||
|
LOCAL_LDFLAGS := -lpthread
|
||||||
|
LOCAL_CXXFLAGS := -Wall -O2
|
||||||
|
|
||||||
|
ifeq ($(MIC_TYPE), fespa)
|
||||||
|
LOCAL_LDFLAGS += -L lib/rk3308_32 -ldds -lduilite_fespa -lplayer_dev -lauth_rk3308 -Wl,-rpath=./lib/rk3308_32
|
||||||
|
else ifeq ($(MIC_TYPE), fespl)
|
||||||
|
LOCAL_LDFLAGS += -L lib/rk3308_32 -ldds -lduilite_fespl -lplayer_dev -lauth_rk3308 -Wl,-rpath=./lib/rk3308_32
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
include $(BUILD_EXECUTABLE)
|
||||||
|
#include $(BUILD_STATIC_LIBRARY)
|
||||||
|
#include $(BUILD_SHARED_LIBRARY)
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/minor_wakeup.mp3
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/minor_wakeup.mp3
Executable file
Binary file not shown.
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/network_error.mp3
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/network_error.mp3
Executable file
Binary file not shown.
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/vad_start_timeout.mp3
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/audio/vad_start_timeout.mp3
Executable file
Binary file not shown.
1332
rk3308/aispeech-4mic-32bit/dds_client/components/dui/dui_major_minor_multiple.c
Executable file
1332
rk3308/aispeech-4mic-32bit/dds_client/components/dui/dui_major_minor_multiple.c
Executable file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
21
rk3308/aispeech-4mic-32bit/dds_client/components/dui/include/dui.h
Executable file
21
rk3308/aispeech-4mic-32bit/dds_client/components/dui/include/dui.h
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef DUI_H
|
||||||
|
#define DUI_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "dui_msg.h"
|
||||||
|
|
||||||
|
typedef void (*user_listen_cb)(dui_msg_t *msg);
|
||||||
|
|
||||||
|
int dui_library_init(const char *cfg, user_listen_cb listen);
|
||||||
|
|
||||||
|
void dui_start_recorder();
|
||||||
|
void dui_stop_recorder();
|
||||||
|
|
||||||
|
void dui_library_cleanup(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
100
rk3308/aispeech-4mic-32bit/dds_client/components/dui/include/dui_msg.h
Executable file
100
rk3308/aispeech-4mic-32bit/dds_client/components/dui/include/dui_msg.h
Executable file
@ -0,0 +1,100 @@
|
|||||||
|
#ifndef DUI_MSG_H
|
||||||
|
#define DUI_MSG_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
//recorder
|
||||||
|
RECORDER_CMD_START = 0,
|
||||||
|
RECORDER_CMD_STOP,
|
||||||
|
|
||||||
|
//以下消息内部使用
|
||||||
|
|
||||||
|
//player
|
||||||
|
PLAYER_CMD_PLAY,
|
||||||
|
//播放结束消息
|
||||||
|
PLAYER_INFO_PLAY_END,
|
||||||
|
//播放开始
|
||||||
|
PLAYER_INFO_PLAY,
|
||||||
|
//vad
|
||||||
|
VAD_CMD_START,
|
||||||
|
VAD_CMD_STOP,
|
||||||
|
VAD_CMD_ABORT,
|
||||||
|
//检测语音起点超时
|
||||||
|
VAD_INFO_TIMEOUT,
|
||||||
|
//检测语音起点多次超时
|
||||||
|
VAD_INFO_TIMEOUT_REPEAT,
|
||||||
|
//检测到语音起点
|
||||||
|
VAD_INFO_START,
|
||||||
|
//检测到语音结束
|
||||||
|
VAD_INFO_END,
|
||||||
|
//wakeup
|
||||||
|
WAKEUP_CMD_START,
|
||||||
|
WAKEUP_CMD_STOP,
|
||||||
|
//唤醒角度
|
||||||
|
WAKEUP_INFO_DOA,
|
||||||
|
//主唤醒词唤醒
|
||||||
|
WAKEUP_INFO_WAKEUP,
|
||||||
|
//快捷唤醒词唤醒
|
||||||
|
WAKEUP_INFO_WAKEUP_MINOR,
|
||||||
|
//dds
|
||||||
|
//收到云端识别结果
|
||||||
|
DDS_INFO_RESULT,
|
||||||
|
//多轮对话
|
||||||
|
DDS_INFO_SPEECH_CONTINUE,
|
||||||
|
//错误
|
||||||
|
DDS_INFO_ERROR,
|
||||||
|
} dui_msg_type_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
//提示音
|
||||||
|
PLAYER_MODE_PROMPT = 0,
|
||||||
|
//合成音
|
||||||
|
PLAYER_MODE_TTS,
|
||||||
|
//音频
|
||||||
|
PLAYER_MODE_AUDIO,
|
||||||
|
} player_mode_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
dui_msg_type_t type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
int dummy;
|
||||||
|
} recorder;
|
||||||
|
struct {
|
||||||
|
player_mode_t mode;
|
||||||
|
char *target;
|
||||||
|
bool need_free;
|
||||||
|
bool native;
|
||||||
|
bool end_session;
|
||||||
|
} player;
|
||||||
|
struct {
|
||||||
|
int doa;
|
||||||
|
bool major;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
//记录上一次唤醒时间
|
||||||
|
struct timeval last_major_time;
|
||||||
|
struct timeval last_minor_time;
|
||||||
|
|
||||||
|
//记录每次唤醒的时间
|
||||||
|
struct timeval cur_major_time;
|
||||||
|
struct timeval cur_minor_time;
|
||||||
|
} wakeup;
|
||||||
|
struct {
|
||||||
|
//判断如果VAD检测起点超时情况发生时,是否需要重复播放提示音
|
||||||
|
bool timeout_need_prompt;
|
||||||
|
//允许循环检测超时的次数
|
||||||
|
int timeout_prompt_count;
|
||||||
|
} vad;
|
||||||
|
};
|
||||||
|
} dui_msg_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
116
rk3308/aispeech-4mic-32bit/dds_client/components/dui/wakeup_fespa.c
Executable file
116
rk3308/aispeech-4mic-32bit/dds_client/components/dui/wakeup_fespa.c
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct timeval major_time;
|
||||||
|
struct timeval minor_time;
|
||||||
|
} wakeup_info_t;
|
||||||
|
|
||||||
|
static int wakeup_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
wakeup_info_t *info = (wakeup_info_t *)userdata;
|
||||||
|
OS_LOG_I(wakeup, "WAKEUP:%s", data);
|
||||||
|
cJSON *js = cJSON_Parse(data);
|
||||||
|
if (js) {
|
||||||
|
dui_msg_t m;
|
||||||
|
memset(&m, 0, sizeof(m));
|
||||||
|
m.wakeup.index = -1;
|
||||||
|
cJSON *major_js = cJSON_GetObjectItem(js, "major");
|
||||||
|
cJSON *word_js = cJSON_GetObjectItem(js, "wakeupWord");
|
||||||
|
m.wakeup.major = (major_js->valueint != 0) ? true : false;
|
||||||
|
if (m.wakeup.major) {
|
||||||
|
m.type = WAKEUP_INFO_WAKEUP;
|
||||||
|
m.wakeup.last_major_time = info->major_time;
|
||||||
|
gettimeofday(&m.wakeup.cur_major_time, NULL);
|
||||||
|
info->major_time = m.wakeup.cur_major_time;
|
||||||
|
} else {
|
||||||
|
m.type = WAKEUP_INFO_WAKEUP_MINOR;
|
||||||
|
m.wakeup.last_minor_time = info->minor_time;
|
||||||
|
gettimeofday(&m.wakeup.cur_minor_time, NULL);
|
||||||
|
info->minor_time = m.wakeup.cur_minor_time;
|
||||||
|
}
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < g_cfg.wakeup.word_count; i++) {
|
||||||
|
if (is_same_word(word_js->valuestring, g_cfg.wakeup.word[i])) {
|
||||||
|
m.wakeup.index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cJSON_Delete(js);
|
||||||
|
if (m.wakeup.index != -1) {
|
||||||
|
os_queue_send(process_queue, &m);
|
||||||
|
os_queue_send(user_listen_queue, &m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int beamforming_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
if (type == DUILITE_MSG_TYPE_JSON) {
|
||||||
|
} else {
|
||||||
|
#ifdef SAVE_AUDIO
|
||||||
|
fwrite(data, 1, len, output_fd);
|
||||||
|
#endif
|
||||||
|
os_stream_write(vad_stream, data, len);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int doa_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
dui_msg_t m;
|
||||||
|
memset(&m, 0, sizeof(m));
|
||||||
|
m.type = WAKEUP_INFO_DOA;
|
||||||
|
OS_LOG_I(wakeup, "DOA: %s", data);
|
||||||
|
cJSON *js = cJSON_Parse(data);
|
||||||
|
if (js) {
|
||||||
|
cJSON *doa_js = cJSON_GetObjectItem(js, "doa");
|
||||||
|
m.wakeup.doa = doa_js->valueint;
|
||||||
|
cJSON_Delete(js);
|
||||||
|
os_queue_send(user_listen_queue, &m);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wakeup_run(void *args) {
|
||||||
|
int ret;
|
||||||
|
dui_msg_t m;
|
||||||
|
wakeup_info_t info;
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
//50ms
|
||||||
|
int read_buf_size = g_cfg.recorder.channels * g_cfg.recorder.bits / 8 * g_cfg.recorder.samplerate / 20;
|
||||||
|
char *read_buf = (char *)os_malloc(read_buf_size);
|
||||||
|
assert(read_buf != NULL);
|
||||||
|
OS_LOG_I(wakeup, "%s", g_cfg.wakeup.cfg);
|
||||||
|
struct duilite_fespa *fespa_engine = duilite_fespa_new(g_cfg.wakeup.cfg);
|
||||||
|
assert(fespa_engine != NULL);
|
||||||
|
duilite_fespa_register(fespa_engine, DUILITE_CALLBACK_FESPA_WAKEUP, wakeup_callback, &info);
|
||||||
|
duilite_fespa_register(fespa_engine, DUILITE_CALLBACK_FESPA_DOA, doa_callback, NULL);
|
||||||
|
duilite_fespa_register(fespa_engine, DUILITE_CALLBACK_FESPA_BEAMFORMING, beamforming_callback, NULL);
|
||||||
|
|
||||||
|
//置位线程READY标志
|
||||||
|
os_event_group_set_bits(task_ready_ev, WAKEUP_READY_BIT);
|
||||||
|
OS_LOG_I(wakeup, "READY");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = os_queue_receive(wakeup_queue, &m);
|
||||||
|
if (ret == -1) break;
|
||||||
|
OS_LOG_I(wakeup, "%s", dui_msg_table[m.type]);
|
||||||
|
if (m.type == WAKEUP_CMD_START) {
|
||||||
|
OS_LOG_I(wakeup, "START");
|
||||||
|
//注意:duilite_fespa_start内部会清空已有数据,避免数据乱序
|
||||||
|
duilite_fespa_start(fespa_engine, g_cfg.wakeup.param);
|
||||||
|
int read_bytes;
|
||||||
|
while (1) {
|
||||||
|
read_bytes = os_stream_read(wakeup_stream, read_buf, read_buf_size);
|
||||||
|
if (read_bytes == -1) break; //录音缓冲被终止
|
||||||
|
#ifdef SAVE_AUDIO
|
||||||
|
fwrite(read_buf, 1, read_bytes, input_fd);
|
||||||
|
#endif
|
||||||
|
duilite_fespa_feed(fespa_engine, read_buf, read_bytes);
|
||||||
|
}
|
||||||
|
} else if (m.type == WAKEUP_CMD_STOP) {
|
||||||
|
os_queue_send(user_listen_queue, &m);
|
||||||
|
OS_LOG_I(wakeup, "STOP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os_free(read_buf);
|
||||||
|
duilite_fespa_delete(fespa_engine);
|
||||||
|
OS_LOG_I(wakeup, "EXIT");
|
||||||
|
}
|
||||||
113
rk3308/aispeech-4mic-32bit/dds_client/components/dui/wakeup_fespl.c
Executable file
113
rk3308/aispeech-4mic-32bit/dds_client/components/dui/wakeup_fespl.c
Executable file
@ -0,0 +1,113 @@
|
|||||||
|
typedef struct {
|
||||||
|
struct timeval major_time;
|
||||||
|
struct timeval minor_time;
|
||||||
|
} wakeup_info_t;
|
||||||
|
|
||||||
|
static int wakeup_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
wakeup_info_t *info = (wakeup_info_t *)userdata;
|
||||||
|
OS_LOG_I(wakeup, "WAKEUP:%s", data);
|
||||||
|
cJSON *js = cJSON_Parse(data);
|
||||||
|
if (js) {
|
||||||
|
dui_msg_t m;
|
||||||
|
memset(&m, 0, sizeof(m));
|
||||||
|
m.wakeup.index = -1;
|
||||||
|
cJSON *major_js = cJSON_GetObjectItem(js, "major");
|
||||||
|
cJSON *word_js = cJSON_GetObjectItem(js, "wakeupWord");
|
||||||
|
m.wakeup.major = (major_js->valueint != 0) ? true : false;
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < g_cfg.wakeup.word_count; i++) {
|
||||||
|
if (is_same_word(word_js->valuestring, g_cfg.wakeup.word[i])) {
|
||||||
|
m.wakeup.index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cJSON_Delete(js);
|
||||||
|
if (m.wakeup.index != -1) {
|
||||||
|
if (m.wakeup.major) {
|
||||||
|
m.type = WAKEUP_INFO_WAKEUP;
|
||||||
|
m.wakeup.last_major_time = info->major_time;
|
||||||
|
gettimeofday(&m.wakeup.cur_major_time, NULL);
|
||||||
|
info->major_time = m.wakeup.cur_major_time;
|
||||||
|
} else {
|
||||||
|
m.type = WAKEUP_INFO_WAKEUP_MINOR;
|
||||||
|
m.wakeup.last_minor_time = info->minor_time;
|
||||||
|
gettimeofday(&m.wakeup.cur_minor_time, NULL);
|
||||||
|
info->minor_time = m.wakeup.cur_minor_time;
|
||||||
|
}
|
||||||
|
os_queue_send(process_queue, &m);
|
||||||
|
os_queue_send(user_listen_queue, &m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int beamforming_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
if (type == DUILITE_MSG_TYPE_JSON) {
|
||||||
|
} else {
|
||||||
|
#ifdef SAVE_AUDIO
|
||||||
|
fwrite(data, 1, len, output_fd);
|
||||||
|
#endif
|
||||||
|
os_stream_write(vad_stream, data, len);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int doa_callback(void *userdata, int type, char *data, int len) {
|
||||||
|
dui_msg_t m;
|
||||||
|
memset(&m, 0, sizeof(m));
|
||||||
|
m.type = WAKEUP_INFO_DOA;
|
||||||
|
OS_LOG_I(wakeup, "DOA: %s", data);
|
||||||
|
cJSON *js = cJSON_Parse(data);
|
||||||
|
if (js) {
|
||||||
|
cJSON *doa_js = cJSON_GetObjectItem(js, "doa");
|
||||||
|
m.wakeup.doa = doa_js->valueint;
|
||||||
|
cJSON_Delete(js);
|
||||||
|
os_queue_send(user_listen_queue, &m);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wakeup_run(void *args) {
|
||||||
|
int ret;
|
||||||
|
dui_msg_t m;
|
||||||
|
wakeup_info_t info;
|
||||||
|
memset(&info, 0, sizeof(info));
|
||||||
|
//50ms
|
||||||
|
int read_buf_size = g_cfg.recorder.channels * g_cfg.recorder.bits / 8 * g_cfg.recorder.samplerate / 20;
|
||||||
|
char *read_buf = (char *)os_malloc(read_buf_size);
|
||||||
|
assert(read_buf != NULL);
|
||||||
|
struct duilite_fespl *fespl_engine = duilite_fespl_new(g_cfg.wakeup.cfg);
|
||||||
|
assert(fespl_engine != NULL);
|
||||||
|
duilite_fespl_register(fespl_engine, DUILITE_CALLBACK_FESPL_WAKEUP, wakeup_callback, &info);
|
||||||
|
duilite_fespl_register(fespl_engine, DUILITE_CALLBACK_FESPL_DOA, doa_callback, NULL);
|
||||||
|
duilite_fespl_register(fespl_engine, DUILITE_CALLBACK_FESPL_BEAMFORMING, beamforming_callback, NULL);
|
||||||
|
|
||||||
|
//置位线程READY标志
|
||||||
|
os_event_group_set_bits(task_ready_ev, WAKEUP_READY_BIT);
|
||||||
|
OS_LOG_I(wakeup, "READY");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = os_queue_receive(wakeup_queue, &m);
|
||||||
|
if (ret == -1) break;
|
||||||
|
OS_LOG_I(wakeup, "%s", dui_msg_table[m.type]);
|
||||||
|
if (m.type == WAKEUP_CMD_START) {
|
||||||
|
OS_LOG_I(wakeup, "START");
|
||||||
|
//注意:duilite_fespl_start内部会清空已有数据,避免数据乱序
|
||||||
|
duilite_fespl_start(fespl_engine, g_cfg.wakeup.param);
|
||||||
|
int read_bytes;
|
||||||
|
while (1) {
|
||||||
|
read_bytes = os_stream_read(wakeup_stream, read_buf, read_buf_size);
|
||||||
|
if (read_bytes == -1) break; //录音缓冲被终止
|
||||||
|
#ifdef SAVE_AUDIO
|
||||||
|
fwrite(read_buf, 1, read_bytes, input_fd);
|
||||||
|
#endif
|
||||||
|
duilite_fespl_feed(fespl_engine, read_buf, read_bytes);
|
||||||
|
}
|
||||||
|
} else if (m.type == WAKEUP_CMD_STOP) {
|
||||||
|
OS_LOG_I(wakeup, "STOP");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os_free(read_buf);
|
||||||
|
duilite_fespl_delete(fespl_engine);
|
||||||
|
OS_LOG_I(wakeup, "EXIT");
|
||||||
|
}
|
||||||
12
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/dui_fsm.c
Executable file
12
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/dui_fsm.c
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#include "dui_fsm.h"
|
||||||
|
|
||||||
|
void dui_fsm_handle(dui_fsm_t *self, int event, void *args) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < self->t_size; i++) {
|
||||||
|
if (event == self->t[i].event && self->cur_state == self->t[i].cur_state) {
|
||||||
|
self->t[i].action(args);
|
||||||
|
self->cur_state = self->t[i].next_state;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/dui_fsm.o
Normal file
BIN
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/dui_fsm.o
Normal file
Binary file not shown.
35
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/include/dui_fsm.h
Executable file
35
rk3308/aispeech-4mic-32bit/dds_client/components/fsm/include/dui_fsm.h
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef DUI_FSM_H
|
||||||
|
#define DUI_FSM_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//有限状态机实现
|
||||||
|
|
||||||
|
//[当前状态]下根据[触发事件]执行[动作]并进入[下一个状态]
|
||||||
|
typedef struct {
|
||||||
|
//触发事件
|
||||||
|
int event;
|
||||||
|
//当前状态
|
||||||
|
int cur_state;
|
||||||
|
//执行动作
|
||||||
|
void (*action)(void *userdata);
|
||||||
|
//下一个状态
|
||||||
|
int next_state;
|
||||||
|
} dui_fsm_transfer_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
//当前状态
|
||||||
|
int cur_state;
|
||||||
|
//状态迁移表
|
||||||
|
dui_fsm_transfer_t *t;
|
||||||
|
//状态迁移表大小
|
||||||
|
int t_size;
|
||||||
|
} dui_fsm_t;
|
||||||
|
|
||||||
|
void dui_fsm_handle(dui_fsm_t *self, int event, void *userdata);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
596
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.c
Executable file
596
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.c
Executable file
@ -0,0 +1,596 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2009 Dave Gamble
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* cJSON */
|
||||||
|
/* JSON parser in C. */
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <float.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include "cJSON.h"
|
||||||
|
|
||||||
|
static const char *ep;
|
||||||
|
|
||||||
|
const char *cJSON_GetErrorPtr(void) {return ep;}
|
||||||
|
|
||||||
|
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
||||||
|
{
|
||||||
|
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
|
||||||
|
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
||||||
|
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *(*cJSON_malloc)(size_t sz) = malloc;
|
||||||
|
static void (*cJSON_free)(void *ptr) = free;
|
||||||
|
|
||||||
|
static char* cJSON_strdup(const char* str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char* copy;
|
||||||
|
|
||||||
|
len = strlen(str) + 1;
|
||||||
|
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
||||||
|
memcpy(copy,str,len);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cJSON_InitHooks(cJSON_Hooks* hooks)
|
||||||
|
{
|
||||||
|
if (!hooks) { /* Reset hooks */
|
||||||
|
cJSON_malloc = malloc;
|
||||||
|
cJSON_free = free;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
|
||||||
|
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Internal constructor. */
|
||||||
|
static cJSON *cJSON_New_Item(void)
|
||||||
|
{
|
||||||
|
cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON));
|
||||||
|
if (node) memset(node,0,sizeof(cJSON));
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Delete a cJSON structure. */
|
||||||
|
void cJSON_Delete(cJSON *c)
|
||||||
|
{
|
||||||
|
cJSON *next;
|
||||||
|
while (c)
|
||||||
|
{
|
||||||
|
next=c->next;
|
||||||
|
if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child);
|
||||||
|
if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring);
|
||||||
|
if (c->string) cJSON_free(c->string);
|
||||||
|
cJSON_free(c);
|
||||||
|
c=next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the input text to generate a number, and populate the result into item. */
|
||||||
|
static const char *parse_number(cJSON *item,const char *num)
|
||||||
|
{
|
||||||
|
double n=0,sign=1,scale=0;int subscale=0,signsubscale=1;
|
||||||
|
|
||||||
|
if (*num=='-') sign=-1,num++; /* Has sign? */
|
||||||
|
if (*num=='0') num++; /* is zero */
|
||||||
|
if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */
|
||||||
|
if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */
|
||||||
|
if (*num=='e' || *num=='E') /* Exponent? */
|
||||||
|
{ num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */
|
||||||
|
while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */
|
||||||
|
}
|
||||||
|
|
||||||
|
n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */
|
||||||
|
|
||||||
|
item->valuedouble=n;
|
||||||
|
item->valueint=(int)n;
|
||||||
|
item->type=cJSON_Number;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render the number nicely from the given item into a string. */
|
||||||
|
static char *print_number(cJSON *item)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
double d=item->valuedouble;
|
||||||
|
if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN)
|
||||||
|
{
|
||||||
|
str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */
|
||||||
|
if (str) sprintf(str,"%d",item->valueint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)sprintf(str,"%.0f",d);
|
||||||
|
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
||||||
|
else sprintf(str,"%f",d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned parse_hex4(const char *str)
|
||||||
|
{
|
||||||
|
unsigned h=0;
|
||||||
|
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||||
|
h=h<<4;str++;
|
||||||
|
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||||
|
h=h<<4;str++;
|
||||||
|
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||||
|
h=h<<4;str++;
|
||||||
|
if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0;
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse the input text into an unescaped cstring, and populate item. */
|
||||||
|
static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||||
|
static const char *parse_string(cJSON *item,const char *str)
|
||||||
|
{
|
||||||
|
const char *ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
|
||||||
|
if (*str!='\"') {ep=str;return 0;} /* not a string! */
|
||||||
|
|
||||||
|
while (*ptr!='\"' && *ptr && ++len) if (*ptr++ == '\\') ptr++; /* Skip escaped quotes. */
|
||||||
|
|
||||||
|
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
|
||||||
|
if (!out) return 0;
|
||||||
|
|
||||||
|
ptr=str+1;ptr2=out;
|
||||||
|
while (*ptr!='\"' && *ptr)
|
||||||
|
{
|
||||||
|
if (*ptr!='\\') *ptr2++=*ptr++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
switch (*ptr)
|
||||||
|
{
|
||||||
|
case 'b': *ptr2++='\b'; break;
|
||||||
|
case 'f': *ptr2++='\f'; break;
|
||||||
|
case 'n': *ptr2++='\n'; break;
|
||||||
|
case 'r': *ptr2++='\r'; break;
|
||||||
|
case 't': *ptr2++='\t'; break;
|
||||||
|
case 'u': /* transcode utf16 to utf8. */
|
||||||
|
uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */
|
||||||
|
|
||||||
|
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */
|
||||||
|
|
||||||
|
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
|
||||||
|
{
|
||||||
|
if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */
|
||||||
|
uc2=parse_hex4(ptr+3);ptr+=6;
|
||||||
|
if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */
|
||||||
|
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
|
||||||
|
}
|
||||||
|
|
||||||
|
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
|
||||||
|
|
||||||
|
switch (len) {
|
||||||
|
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||||
|
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||||
|
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
|
||||||
|
case 1: *--ptr2 =(uc | firstByteMark[len]);
|
||||||
|
}
|
||||||
|
ptr2+=len;
|
||||||
|
break;
|
||||||
|
default: *ptr2++=*ptr; break;
|
||||||
|
}
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*ptr2=0;
|
||||||
|
if (*ptr=='\"') ptr++;
|
||||||
|
item->valuestring=out;
|
||||||
|
item->type=cJSON_String;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render the cstring provided to an escaped version that can be printed. */
|
||||||
|
static char *print_string_ptr(const char *str)
|
||||||
|
{
|
||||||
|
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
|
||||||
|
|
||||||
|
if (!str) return cJSON_strdup("");
|
||||||
|
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
|
||||||
|
|
||||||
|
out=(char*)cJSON_malloc(len+3);
|
||||||
|
if (!out) return 0;
|
||||||
|
|
||||||
|
ptr2=out;ptr=str;
|
||||||
|
*ptr2++='\"';
|
||||||
|
while (*ptr)
|
||||||
|
{
|
||||||
|
if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*ptr2++='\\';
|
||||||
|
switch (token=*ptr++)
|
||||||
|
{
|
||||||
|
case '\\': *ptr2++='\\'; break;
|
||||||
|
case '\"': *ptr2++='\"'; break;
|
||||||
|
case '\b': *ptr2++='b'; break;
|
||||||
|
case '\f': *ptr2++='f'; break;
|
||||||
|
case '\n': *ptr2++='n'; break;
|
||||||
|
case '\r': *ptr2++='r'; break;
|
||||||
|
case '\t': *ptr2++='t'; break;
|
||||||
|
default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*ptr2++='\"';*ptr2++=0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
/* Invote print_string_ptr (which is useful) on an item. */
|
||||||
|
static char *print_string(cJSON *item) {return print_string_ptr(item->valuestring);}
|
||||||
|
|
||||||
|
/* Predeclare these prototypes. */
|
||||||
|
static const char *parse_value(cJSON *item,const char *value);
|
||||||
|
static char *print_value(cJSON *item,int depth,int fmt);
|
||||||
|
static const char *parse_array(cJSON *item,const char *value);
|
||||||
|
static char *print_array(cJSON *item,int depth,int fmt);
|
||||||
|
static const char *parse_object(cJSON *item,const char *value);
|
||||||
|
static char *print_object(cJSON *item,int depth,int fmt);
|
||||||
|
|
||||||
|
/* Utility to jump whitespace and cr/lf */
|
||||||
|
static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;}
|
||||||
|
|
||||||
|
/* Parse an object - create a new root, and populate. */
|
||||||
|
cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated)
|
||||||
|
{
|
||||||
|
const char *end=0;
|
||||||
|
cJSON *c=cJSON_New_Item();
|
||||||
|
ep=0;
|
||||||
|
if (!c) return 0; /* memory fail */
|
||||||
|
|
||||||
|
end=parse_value(c,skip(value));
|
||||||
|
if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */
|
||||||
|
|
||||||
|
/* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */
|
||||||
|
if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);ep=end;return 0;}}
|
||||||
|
if (return_parse_end) *return_parse_end=end;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
/* Default options for cJSON_Parse */
|
||||||
|
cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);}
|
||||||
|
|
||||||
|
/* Render a cJSON item/entity/structure to text. */
|
||||||
|
char *cJSON_Print(cJSON *item) {return print_value(item,0,1);}
|
||||||
|
char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0);}
|
||||||
|
|
||||||
|
/* Parser core - when encountering text, process appropriately. */
|
||||||
|
static const char *parse_value(cJSON *item,const char *value)
|
||||||
|
{
|
||||||
|
if (!value) return 0; /* Fail on null. */
|
||||||
|
if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; }
|
||||||
|
if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; }
|
||||||
|
if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; }
|
||||||
|
if (*value=='\"') { return parse_string(item,value); }
|
||||||
|
if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); }
|
||||||
|
if (*value=='[') { return parse_array(item,value); }
|
||||||
|
if (*value=='{') { return parse_object(item,value); }
|
||||||
|
|
||||||
|
ep=value;return 0; /* failure. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render a value to text. */
|
||||||
|
static char *print_value(cJSON *item,int depth,int fmt)
|
||||||
|
{
|
||||||
|
char *out=0;
|
||||||
|
if (!item) return 0;
|
||||||
|
switch ((item->type)&255)
|
||||||
|
{
|
||||||
|
case cJSON_NULL: out=cJSON_strdup("null"); break;
|
||||||
|
case cJSON_False: out=cJSON_strdup("false");break;
|
||||||
|
case cJSON_True: out=cJSON_strdup("true"); break;
|
||||||
|
case cJSON_Number: out=print_number(item);break;
|
||||||
|
case cJSON_String: out=print_string(item);break;
|
||||||
|
case cJSON_Array: out=print_array(item,depth,fmt);break;
|
||||||
|
case cJSON_Object: out=print_object(item,depth,fmt);break;
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build an array from input text. */
|
||||||
|
static const char *parse_array(cJSON *item,const char *value)
|
||||||
|
{
|
||||||
|
cJSON *child;
|
||||||
|
if (*value!='[') {ep=value;return 0;} /* not an array! */
|
||||||
|
|
||||||
|
item->type=cJSON_Array;
|
||||||
|
value=skip(value+1);
|
||||||
|
if (*value==']') return value+1; /* empty array. */
|
||||||
|
|
||||||
|
item->child=child=cJSON_New_Item();
|
||||||
|
if (!item->child) return 0; /* memory fail */
|
||||||
|
value=skip(parse_value(child,skip(value))); /* skip any spacing, get the value. */
|
||||||
|
if (!value) return 0;
|
||||||
|
|
||||||
|
while (*value==',')
|
||||||
|
{
|
||||||
|
cJSON *new_item;
|
||||||
|
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||||
|
child->next=new_item;new_item->prev=child;child=new_item;
|
||||||
|
value=skip(parse_value(child,skip(value+1)));
|
||||||
|
if (!value) return 0; /* memory fail */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*value==']') return value+1; /* end of array */
|
||||||
|
ep=value;return 0; /* malformed. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render an array to text */
|
||||||
|
static char *print_array(cJSON *item,int depth,int fmt)
|
||||||
|
{
|
||||||
|
char **entries;
|
||||||
|
char *out=0,*ptr,*ret;int len=5;
|
||||||
|
cJSON *child=item->child;
|
||||||
|
int numentries=0,i=0,fail=0;
|
||||||
|
|
||||||
|
/* How many entries in the array? */
|
||||||
|
while (child) numentries++,child=child->next;
|
||||||
|
/* Explicitly handle numentries==0 */
|
||||||
|
if (!numentries)
|
||||||
|
{
|
||||||
|
out=(char*)cJSON_malloc(3);
|
||||||
|
if (out) strcpy(out,"[]");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
/* Allocate an array to hold the values for each */
|
||||||
|
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||||
|
if (!entries) return 0;
|
||||||
|
memset(entries,0,numentries*sizeof(char*));
|
||||||
|
/* Retrieve all the results: */
|
||||||
|
child=item->child;
|
||||||
|
while (child && !fail)
|
||||||
|
{
|
||||||
|
ret=print_value(child,depth+1,fmt);
|
||||||
|
entries[i++]=ret;
|
||||||
|
if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1;
|
||||||
|
child=child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we didn't fail, try to malloc the output string */
|
||||||
|
if (!fail) out=(char*)cJSON_malloc(len);
|
||||||
|
/* If that fails, we fail. */
|
||||||
|
if (!out) fail=1;
|
||||||
|
|
||||||
|
/* Handle failure. */
|
||||||
|
if (fail)
|
||||||
|
{
|
||||||
|
for (i=0;i<numentries;i++) if (entries[i]) cJSON_free(entries[i]);
|
||||||
|
cJSON_free(entries);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compose the output array. */
|
||||||
|
*out='[';
|
||||||
|
ptr=out+1;*ptr=0;
|
||||||
|
for (i=0;i<numentries;i++)
|
||||||
|
{
|
||||||
|
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
||||||
|
if (i!=numentries-1) {*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;}
|
||||||
|
cJSON_free(entries[i]);
|
||||||
|
}
|
||||||
|
cJSON_free(entries);
|
||||||
|
*ptr++=']';*ptr++=0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build an object from the text. */
|
||||||
|
static const char *parse_object(cJSON *item,const char *value)
|
||||||
|
{
|
||||||
|
cJSON *child;
|
||||||
|
if (*value!='{') {ep=value;return 0;} /* not an object! */
|
||||||
|
|
||||||
|
item->type=cJSON_Object;
|
||||||
|
value=skip(value+1);
|
||||||
|
if (*value=='}') return value+1; /* empty array. */
|
||||||
|
|
||||||
|
item->child=child=cJSON_New_Item();
|
||||||
|
if (!item->child) return 0;
|
||||||
|
value=skip(parse_string(child,skip(value)));
|
||||||
|
if (!value) return 0;
|
||||||
|
child->string=child->valuestring;child->valuestring=0;
|
||||||
|
if (*value!=':') {ep=value;return 0;} /* fail! */
|
||||||
|
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
||||||
|
if (!value) return 0;
|
||||||
|
|
||||||
|
while (*value==',')
|
||||||
|
{
|
||||||
|
cJSON *new_item;
|
||||||
|
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||||
|
child->next=new_item;new_item->prev=child;child=new_item;
|
||||||
|
value=skip(parse_string(child,skip(value+1)));
|
||||||
|
if (!value) return 0;
|
||||||
|
child->string=child->valuestring;child->valuestring=0;
|
||||||
|
if (*value!=':') {ep=value;return 0;} /* fail! */
|
||||||
|
value=skip(parse_value(child,skip(value+1))); /* skip any spacing, get the value. */
|
||||||
|
if (!value) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*value=='}') return value+1; /* end of array */
|
||||||
|
ep=value;return 0; /* malformed. */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Render an object to text. */
|
||||||
|
static char *print_object(cJSON *item,int depth,int fmt)
|
||||||
|
{
|
||||||
|
char **entries=0,**names=0;
|
||||||
|
char *out=0,*ptr,*ret,*str;int len=7,i=0,j;
|
||||||
|
cJSON *child=item->child;
|
||||||
|
int numentries=0,fail=0;
|
||||||
|
/* Count the number of entries. */
|
||||||
|
while (child) numentries++,child=child->next;
|
||||||
|
/* Explicitly handle empty object case */
|
||||||
|
if (!numentries)
|
||||||
|
{
|
||||||
|
out=(char*)cJSON_malloc(fmt?depth+4:3);
|
||||||
|
if (!out) return 0;
|
||||||
|
ptr=out;*ptr++='{';
|
||||||
|
if (fmt) {*ptr++='\n';for (i=0;i<depth-1;i++) *ptr++='\t';}
|
||||||
|
*ptr++='}';*ptr++=0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
/* Allocate space for the names and the objects */
|
||||||
|
entries=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||||
|
if (!entries) return 0;
|
||||||
|
names=(char**)cJSON_malloc(numentries*sizeof(char*));
|
||||||
|
if (!names) {cJSON_free(entries);return 0;}
|
||||||
|
memset(entries,0,sizeof(char*)*numentries);
|
||||||
|
memset(names,0,sizeof(char*)*numentries);
|
||||||
|
|
||||||
|
/* Collect all the results into our arrays: */
|
||||||
|
child=item->child;depth++;if (fmt) len+=depth;
|
||||||
|
while (child)
|
||||||
|
{
|
||||||
|
names[i]=str=print_string_ptr(child->string);
|
||||||
|
entries[i++]=ret=print_value(child,depth,fmt);
|
||||||
|
if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1;
|
||||||
|
child=child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to allocate the output string */
|
||||||
|
if (!fail) out=(char*)cJSON_malloc(len);
|
||||||
|
if (!out) fail=1;
|
||||||
|
|
||||||
|
/* Handle failure */
|
||||||
|
if (fail)
|
||||||
|
{
|
||||||
|
for (i=0;i<numentries;i++) {if (names[i]) cJSON_free(names[i]);if (entries[i]) cJSON_free(entries[i]);}
|
||||||
|
cJSON_free(names);cJSON_free(entries);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Compose the output: */
|
||||||
|
*out='{';ptr=out+1;if (fmt)*ptr++='\n';*ptr=0;
|
||||||
|
for (i=0;i<numentries;i++)
|
||||||
|
{
|
||||||
|
if (fmt) for (j=0;j<depth;j++) *ptr++='\t';
|
||||||
|
strcpy(ptr,names[i]);ptr+=strlen(names[i]);
|
||||||
|
*ptr++=':';if (fmt) *ptr++='\t';
|
||||||
|
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
|
||||||
|
if (i!=numentries-1) *ptr++=',';
|
||||||
|
if (fmt) *ptr++='\n';*ptr=0;
|
||||||
|
cJSON_free(names[i]);cJSON_free(entries[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON_free(names);cJSON_free(entries);
|
||||||
|
if (fmt) for (i=0;i<depth-1;i++) *ptr++='\t';
|
||||||
|
*ptr++='}';*ptr++=0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get Array size/item / object item. */
|
||||||
|
int cJSON_GetArraySize(cJSON *array) {cJSON *c=array->child;int i=0;while(c)i++,c=c->next;return i;}
|
||||||
|
cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array->child; while (c && item>0) item--,c=c->next; return c;}
|
||||||
|
cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object->child; while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;}
|
||||||
|
|
||||||
|
/* Utility for array list handling. */
|
||||||
|
static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;}
|
||||||
|
/* Utility for handling references. */
|
||||||
|
static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;}
|
||||||
|
|
||||||
|
/* Add item to array/object. */
|
||||||
|
void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}}
|
||||||
|
void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);}
|
||||||
|
void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));}
|
||||||
|
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
|
||||||
|
|
||||||
|
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
|
||||||
|
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
|
||||||
|
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
|
||||||
|
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
|
||||||
|
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
|
||||||
|
|
||||||
|
/* Replace array/object items with new ones. */
|
||||||
|
void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return;
|
||||||
|
newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem;
|
||||||
|
if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);}
|
||||||
|
void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}}
|
||||||
|
|
||||||
|
/* Create basic types: */
|
||||||
|
cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;}
|
||||||
|
cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;}
|
||||||
|
cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;}
|
||||||
|
cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;}
|
||||||
|
cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;}
|
||||||
|
cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;}
|
||||||
|
cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;}
|
||||||
|
cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;}
|
||||||
|
|
||||||
|
/* Create Arrays: */
|
||||||
|
cJSON *cJSON_CreateIntArray(const int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
|
cJSON *cJSON_CreateFloatArray(const float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
|
cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateNumber(numbers[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
|
cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && i<count;i++){n=cJSON_CreateString(strings[i]);if(!i)a->child=n;else suffix_object(p,n);p=n;}return a;}
|
||||||
|
|
||||||
|
/* Duplication */
|
||||||
|
cJSON *cJSON_Duplicate(cJSON *item,int recurse)
|
||||||
|
{
|
||||||
|
cJSON *newitem,*cptr,*nptr=0,*newchild;
|
||||||
|
/* Bail on bad ptr */
|
||||||
|
if (!item) return 0;
|
||||||
|
/* Create new item */
|
||||||
|
newitem=cJSON_New_Item();
|
||||||
|
if (!newitem) return 0;
|
||||||
|
/* Copy over all vars */
|
||||||
|
newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble;
|
||||||
|
if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}}
|
||||||
|
if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}}
|
||||||
|
/* If non-recursive, then we're done! */
|
||||||
|
if (!recurse) return newitem;
|
||||||
|
/* Walk the ->next chain for the child. */
|
||||||
|
cptr=item->child;
|
||||||
|
while (cptr)
|
||||||
|
{
|
||||||
|
newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */
|
||||||
|
if (!newchild) {cJSON_Delete(newitem);return 0;}
|
||||||
|
if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */
|
||||||
|
else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */
|
||||||
|
cptr=cptr->next;
|
||||||
|
}
|
||||||
|
return newitem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cJSON_Minify(char *json)
|
||||||
|
{
|
||||||
|
char *into=json;
|
||||||
|
while (*json)
|
||||||
|
{
|
||||||
|
if (*json==' ') json++;
|
||||||
|
else if (*json=='\t') json++; // Whitespace characters.
|
||||||
|
else if (*json=='\r') json++;
|
||||||
|
else if (*json=='\n') json++;
|
||||||
|
else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; // double-slash comments, to end of line.
|
||||||
|
else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} // multiline comments.
|
||||||
|
else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} // string literals, which are \" sensitive.
|
||||||
|
else *into++=*json++; // All other characters.
|
||||||
|
}
|
||||||
|
*into=0; // and null-terminate.
|
||||||
|
}
|
||||||
145
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.h
Executable file
145
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.h
Executable file
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2009 Dave Gamble
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef cJSON__h
|
||||||
|
#define cJSON__h
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* cJSON Types: */
|
||||||
|
#define cJSON_False 0
|
||||||
|
#define cJSON_True 1
|
||||||
|
#define cJSON_NULL 2
|
||||||
|
#define cJSON_Number 3
|
||||||
|
#define cJSON_String 4
|
||||||
|
#define cJSON_Array 5
|
||||||
|
#define cJSON_Object 6
|
||||||
|
|
||||||
|
#define cJSON_IsReference 256
|
||||||
|
|
||||||
|
/* The cJSON structure: */
|
||||||
|
typedef struct cJSON {
|
||||||
|
struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
|
||||||
|
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
|
||||||
|
|
||||||
|
int type; /* The type of the item, as above. */
|
||||||
|
|
||||||
|
char *valuestring; /* The item's string, if type==cJSON_String */
|
||||||
|
int valueint; /* The item's number, if type==cJSON_Number */
|
||||||
|
double valuedouble; /* The item's number, if type==cJSON_Number */
|
||||||
|
|
||||||
|
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
|
||||||
|
} cJSON;
|
||||||
|
|
||||||
|
typedef struct cJSON_Hooks {
|
||||||
|
void *(*malloc_fn)(size_t sz);
|
||||||
|
void (*free_fn)(void *ptr);
|
||||||
|
} cJSON_Hooks;
|
||||||
|
|
||||||
|
/* Supply malloc, realloc and free functions to cJSON */
|
||||||
|
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
|
||||||
|
|
||||||
|
|
||||||
|
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
|
||||||
|
extern cJSON *cJSON_Parse(const char *value);
|
||||||
|
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
|
||||||
|
extern char *cJSON_Print(cJSON *item);
|
||||||
|
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
|
||||||
|
extern char *cJSON_PrintUnformatted(cJSON *item);
|
||||||
|
/* Delete a cJSON entity and all subentities. */
|
||||||
|
extern void cJSON_Delete(cJSON *c);
|
||||||
|
|
||||||
|
/* Returns the number of items in an array (or object). */
|
||||||
|
extern int cJSON_GetArraySize(cJSON *array);
|
||||||
|
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
|
||||||
|
extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
|
||||||
|
/* Get item "string" from object. Case insensitive. */
|
||||||
|
extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
|
||||||
|
|
||||||
|
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
|
||||||
|
extern const char *cJSON_GetErrorPtr(void);
|
||||||
|
|
||||||
|
/* These calls create a cJSON item of the appropriate type. */
|
||||||
|
extern cJSON *cJSON_CreateNull(void);
|
||||||
|
extern cJSON *cJSON_CreateTrue(void);
|
||||||
|
extern cJSON *cJSON_CreateFalse(void);
|
||||||
|
extern cJSON *cJSON_CreateBool(int b);
|
||||||
|
extern cJSON *cJSON_CreateNumber(double num);
|
||||||
|
extern cJSON *cJSON_CreateString(const char *string);
|
||||||
|
extern cJSON *cJSON_CreateArray(void);
|
||||||
|
extern cJSON *cJSON_CreateObject(void);
|
||||||
|
|
||||||
|
/* These utilities create an Array of count items. */
|
||||||
|
extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
|
||||||
|
extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
|
||||||
|
extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
|
||||||
|
extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
|
||||||
|
|
||||||
|
/* Append item to the specified array/object. */
|
||||||
|
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
|
||||||
|
extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
|
||||||
|
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
|
||||||
|
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
|
||||||
|
extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
|
||||||
|
|
||||||
|
/* Remove/Detatch items from Arrays/Objects. */
|
||||||
|
extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
|
||||||
|
extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
|
||||||
|
extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
|
||||||
|
extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
|
||||||
|
|
||||||
|
/* Update array items. */
|
||||||
|
extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
|
||||||
|
extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
|
||||||
|
|
||||||
|
/* Duplicate a cJSON item */
|
||||||
|
extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
|
||||||
|
/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
|
||||||
|
need to be released. With recurse!=0, it will duplicate any children connected to the item.
|
||||||
|
The item->next and ->prev pointers are always zero on return from Duplicate. */
|
||||||
|
|
||||||
|
/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
|
||||||
|
extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
|
||||||
|
|
||||||
|
extern void cJSON_Minify(char *json);
|
||||||
|
|
||||||
|
/* Macros for creating things quickly. */
|
||||||
|
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
|
||||||
|
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
|
||||||
|
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
|
||||||
|
#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
|
||||||
|
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
|
||||||
|
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
|
||||||
|
|
||||||
|
/* When assigning an integer value, it needs to be propagated to valuedouble too. */
|
||||||
|
#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.o
Normal file
BIN
rk3308/aispeech-4mic-32bit/dds_client/components/json/cJSON.o
Normal file
Binary file not shown.
BIN
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa
Executable file
Binary file not shown.
39
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa.json
Executable file
39
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa.json
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"auth":{
|
||||||
|
"productId": "100001463",
|
||||||
|
"deviceProfile": "Yhn7W3QzXThMGBG1qgJcbCmW0hmO7HYdHcfuQPFzJhgnzWrrJhPPWYTdm5qJlpyarJqcjZqL3cXdz8fKm5nNycyZmcbGy5udy52cy8bHzsuZzJ6ZmZrLzMnd092ek5OQiN3FztPdj42Qm4qci7ab3cXdzs/Pz8/Oy8nM3dPdm5qJlpyasZ6Smt3F3Z7Oy8icnpmbms6bnsvNm87Gz83MnsqZzcicy83Iy5rN3dPdjJyQj5rdxaTdnpOT3aKC"
|
||||||
|
},
|
||||||
|
"recorder":{
|
||||||
|
"device":"4mic_loopback",
|
||||||
|
"bits":16,
|
||||||
|
"channels":5,
|
||||||
|
"samplerate":16000
|
||||||
|
},
|
||||||
|
"player":{
|
||||||
|
"device":"default"
|
||||||
|
},
|
||||||
|
"wakeup":{
|
||||||
|
"cfg":{
|
||||||
|
"aecBinPath":"./res/AEC_ch5-2-1ref_common_20180727_v0.9.4.bin",
|
||||||
|
"wakeupBinPath":"./res/wakeup_aifar_comm_20180104.bin",
|
||||||
|
"beamformingBinPath":"./res/UCA_asr_ch4-2-ch4_70mm_comm_20180412_v1.2.1.bin",
|
||||||
|
"env":"words=ni hao xiao le,ni hao xiao chi;thresh=0.34,0.3;major=1,0;",
|
||||||
|
"rollBack":200
|
||||||
|
},
|
||||||
|
"wakeupWord":["ni hao xiao le", "ni hao xiao chi"],
|
||||||
|
"wakeupAudio":["./audio/wakeup.mp3", "./audio/minor_wakeup.mp3"]
|
||||||
|
},
|
||||||
|
"vad":{
|
||||||
|
"cfg":{
|
||||||
|
"resBinPath":"./res/vad_aihome_v0.7.bin",
|
||||||
|
"pauseTime":200
|
||||||
|
},
|
||||||
|
"startTimeoutPrompt":"./audio/vad_start_timeout2.mp3"
|
||||||
|
},
|
||||||
|
"dds":{
|
||||||
|
"productId":"100001463",
|
||||||
|
"aliasKey":"prod",
|
||||||
|
"server":"ws://dds.dui.ai/dds/v1",
|
||||||
|
"deviceProfile":"Yhn7W3QzXThMGBG1qgJcbCmW0hmO7HYdHcfuQPFzJhgnzWrrJhPPWYTdm5qJlpyarJqcjZqL3cXdz8fKm5nNycyZmcbGy5udy52cy8bHzsuZzJ6ZmZrLzMnd092ek5OQiN3FztPdj42Qm4qci7ab3cXdzs/Pz8/Oy8nM3dPdm5qJlpyasZ6Smt3F3Z7Oy8icnpmbms6bnsvNm87Gz83MnsqZzcicy83Iy5rN3dPdjJyQj5rdxaTdnpOT3aKC"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa_record
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/dui_fespa_record
Executable file
Binary file not shown.
23
rk3308/aispeech-4mic-32bit/dds_client/example/main.c
Executable file
23
rk3308/aispeech-4mic-32bit/dds_client/example/main.c
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#include "dui.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
FILE *fd = fopen(argv[1], "rb");
|
||||||
|
fseek(fd, 0L, SEEK_END);
|
||||||
|
int len = ftell(fd);
|
||||||
|
char *buf = (char *)malloc(len + 1);
|
||||||
|
fseek(fd, 0L, SEEK_SET);
|
||||||
|
fread(buf, 1, len, fd);
|
||||||
|
|
||||||
|
|
||||||
|
dui_library_init(buf, NULL);
|
||||||
|
dui_start_recorder();
|
||||||
|
while (1) {
|
||||||
|
sleep(20);
|
||||||
|
}
|
||||||
|
dui_stop_recorder();
|
||||||
|
dui_library_cleanup();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/example/main.o
Normal file
BIN
rk3308/aispeech-4mic-32bit/dds_client/example/main.o
Normal file
Binary file not shown.
69
rk3308/aispeech-4mic-32bit/dds_client/example/main_vad.c
Executable file
69
rk3308/aispeech-4mic-32bit/dds_client/example/main_vad.c
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
#include "dui.h"
|
||||||
|
#include "dui_msg.h"
|
||||||
|
#include "dui_thread.h"
|
||||||
|
#include "dui_queue.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define EV_RECODER_CLOSE (1 << 0)
|
||||||
|
|
||||||
|
static dui_event_group_handle_t event;
|
||||||
|
|
||||||
|
extern dui_queue_handle_t user_listen_queue;
|
||||||
|
|
||||||
|
static void listen_cb(dui_msg_t *msg) {
|
||||||
|
dui_msg_t m;
|
||||||
|
int ret;
|
||||||
|
while (1) {
|
||||||
|
ret = dui_queue_receive(user_listen_queue, &m);
|
||||||
|
if (ret == -1) break;
|
||||||
|
if (m.type == RECORDER_CMD_STOP) {
|
||||||
|
dui_event_group_set_bits(event, EV_RECODER_CLOSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
FILE *fd = fopen(argv[1], "rb");
|
||||||
|
fseek(fd, 0L, SEEK_END);
|
||||||
|
int len = ftell(fd);
|
||||||
|
char *buf = (char *)malloc(len + 1);
|
||||||
|
fseek(fd, 0L, SEEK_SET);
|
||||||
|
fread(buf, 1, len, fd);
|
||||||
|
|
||||||
|
event = dui_event_group_create();
|
||||||
|
|
||||||
|
dui_library_init(buf, listen_cb);
|
||||||
|
fclose(fd);
|
||||||
|
dui_start_recorder();
|
||||||
|
while (1) {
|
||||||
|
int buf[64];
|
||||||
|
long frames;
|
||||||
|
while (1) {
|
||||||
|
struct timeval tv = {
|
||||||
|
.tv_usec = 50000
|
||||||
|
};
|
||||||
|
frames = -1;
|
||||||
|
fd = fopen("/sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames", "r");
|
||||||
|
if (fd) {
|
||||||
|
if (fgets(buf, sizeof(buf), fd)) {
|
||||||
|
frames = atol(buf);
|
||||||
|
}
|
||||||
|
fclose(fd);
|
||||||
|
}
|
||||||
|
if (frames > 80000) {
|
||||||
|
dui_stop_recorder();
|
||||||
|
dui_event_group_wait_bits(event, EV_RECODER_CLOSE, true, true);
|
||||||
|
system("echo 0 > /sys/module/snd_soc_rockchip_vad/parameters/voice_inactive_frames");
|
||||||
|
system("echo mem > /sys/power/state");
|
||||||
|
dui_start_recorder();
|
||||||
|
}
|
||||||
|
select(0, NULL, NULL, NULL, &tv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dui_library_cleanup();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
21
rk3308/aispeech-4mic-32bit/dds_client/include/alsa_cfg.h
Executable file
21
rk3308/aispeech-4mic-32bit/dds_client/include/alsa_cfg.h
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef ALSA_CFG_H
|
||||||
|
#define ALSA_CFG_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int samplerate;
|
||||||
|
int bits;
|
||||||
|
int channels;
|
||||||
|
int period_size;
|
||||||
|
const char *device;
|
||||||
|
}alsa_open_config_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) int playback_check_samplerate(int samplerate);
|
||||||
|
#define capture_check_samplerate(samplerate) playback_check_samplerate(samplerate)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
111
rk3308/aispeech-4mic-32bit/dds_client/include/dds.h
Executable file
111
rk3308/aispeech-4mic-32bit/dds_client/include/dds.h
Executable file
@ -0,0 +1,111 @@
|
|||||||
|
#ifndef __DDS_H__
|
||||||
|
#define __DDS_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (!(defined DDS_CALL) || !(defined DDS_IMPORT_OR_EXPORT))
|
||||||
|
#if defined _WIN32
|
||||||
|
#if defined _WIN64
|
||||||
|
#define DDS_CALL __stdcall
|
||||||
|
#else
|
||||||
|
#define DDS_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DDS_IMPLEMENTION
|
||||||
|
#define DDS_IMPORT_OR_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DDS_IMPORT_OR_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined __ANDROID__
|
||||||
|
#define DDS_CALL
|
||||||
|
#define DDS_IMPORT_OR_EXPORT
|
||||||
|
#undef JNIEXPORT
|
||||||
|
#define JNIEXPORT __attribute ((visibility("default")))
|
||||||
|
#elif defined __APPLE__
|
||||||
|
#define DDS_CALL
|
||||||
|
#define DDS_IMPORT_OR_EXPORT
|
||||||
|
#elif defined __unix__
|
||||||
|
#define DDS_CALL
|
||||||
|
#define DDS_IMPORT_OR_EXPORT __attribute ((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define DDS_CALL
|
||||||
|
#define DDS_IMPORT_OR_EXPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DDS_VERSION "DDS 0.2.12"
|
||||||
|
#define DDS_VERSION_NUM 212
|
||||||
|
|
||||||
|
/* callback event */
|
||||||
|
#define DDS_EV_OUT_RECORD_AUDIO 1
|
||||||
|
#define DDS_EV_OUT_NATIVE_CALL 2
|
||||||
|
#define DDS_EV_OUT_COMMAND 3
|
||||||
|
#define DDS_EV_OUT_MEDIA 4
|
||||||
|
#define DDS_EV_OUT_STATUS 5
|
||||||
|
#define DDS_EV_OUT_TTS 6
|
||||||
|
#define DDS_EV_OUT_ERROR 7
|
||||||
|
#define DDS_EV_OUT_ASR_RESULT 8
|
||||||
|
#define DDS_EV_OUT_DUI_RESPONSE 9
|
||||||
|
#define DDS_EV_OUT_DUI_LOGIN 10
|
||||||
|
#define DDS_EV_OUT_CINFO_RESULT 11
|
||||||
|
|
||||||
|
/* external event */
|
||||||
|
#define DDS_EV_IN_SPEECH 101
|
||||||
|
#define DDS_EV_IN_WAKEUP 102
|
||||||
|
#define DDS_EV_IN_NATIVE_RESPONSE 103
|
||||||
|
#define DDS_EV_IN_RESET 104
|
||||||
|
#define DDS_EV_IN_EXIT 105
|
||||||
|
#define DDS_EV_IN_CUSTOM_TTS_TEXT 106
|
||||||
|
#define DDS_EV_IN_AUDIO_STREAM 107
|
||||||
|
#define DDS_EV_IN_PLAYER_STATUS 108
|
||||||
|
#define DDS_EV_IN_NLU_TEXT 109
|
||||||
|
#define DDS_EV_IN_WAKEUP_WORD 110
|
||||||
|
#define DDS_EV_IN_CINFO_OPERATE 111
|
||||||
|
|
||||||
|
/* error id */
|
||||||
|
#define DDS_ERROR_BASE 1000
|
||||||
|
#define DDS_ERROR_FATAL (DDS_ERROR_BASE + 1)
|
||||||
|
#define DDS_ERROR_TIMEOUT (DDS_ERROR_BASE + 2)
|
||||||
|
#define DDS_ERROR_NETWORK (DDS_ERROR_BASE + 3)
|
||||||
|
#define DDS_ERROR_SERVER (DDS_ERROR_BASE + 4)
|
||||||
|
#define DDS_ERROR_LOGIC (DDS_ERROR_BASE + 5)
|
||||||
|
|
||||||
|
struct dds_msg;
|
||||||
|
|
||||||
|
typedef int (*dds_ev_callback)(void *userdata, struct dds_msg *msg);
|
||||||
|
|
||||||
|
struct dds_opt {
|
||||||
|
dds_ev_callback _handler;
|
||||||
|
void *userdata;
|
||||||
|
};
|
||||||
|
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_start(struct dds_msg *conf, struct dds_opt *opt);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_send(struct dds_msg *msg);
|
||||||
|
|
||||||
|
/* message pack or unpack */
|
||||||
|
DDS_IMPORT_OR_EXPORT struct dds_msg * DDS_CALL dds_msg_new();
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_delete(struct dds_msg *msg);
|
||||||
|
DDS_IMPORT_OR_EXPORT void DDS_CALL dds_msg_print(struct dds_msg *msg);
|
||||||
|
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_type(struct dds_msg *msg, int value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_integer(struct dds_msg *msg, const char *key, int value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_double(struct dds_msg *msg, const char *key, double value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_boolean(struct dds_msg *msg, const char *key, int value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_string(struct dds_msg *msg, const char *key, const char *value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_bin(struct dds_msg *msg, const char *key, const char *value, int value_len);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_set_bin_p(struct dds_msg *msg, const char *key, const char *value, int value_len);
|
||||||
|
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_type(struct dds_msg *msg, int *value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_integer(struct dds_msg *msg, const char *key, int *value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_double(struct dds_msg *msg, const char *key, double *value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_boolean(struct dds_msg *msg, const char *key, int *value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_string(struct dds_msg *msg, const char *key, char **value);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_bin(struct dds_msg *msg, const char *key, char **value, int *value_len);
|
||||||
|
DDS_IMPORT_OR_EXPORT int DDS_CALL dds_msg_get_bin_p(struct dds_msg *msg, const char *key, char **value, int *value_len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
147
rk3308/aispeech-4mic-32bit/dds_client/include/duilite.h
Executable file
147
rk3308/aispeech-4mic-32bit/dds_client/include/duilite.h
Executable file
@ -0,0 +1,147 @@
|
|||||||
|
#ifndef __DUILITE_H__
|
||||||
|
#define __DUILITE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (!(defined DUILITE_CALL) || !(defined DUILITE_IMPORT_OR_EXPORT))
|
||||||
|
#if defined _WIN32
|
||||||
|
#if defined _WIN64
|
||||||
|
#define DUILITE_CALL __stdcall
|
||||||
|
#else
|
||||||
|
#define DUILITE_CALL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DUILITE_IMPLEMENTION
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#elif defined __ANDROID__
|
||||||
|
#define DUILITE_CALL
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT
|
||||||
|
#undef JNIEXPORT
|
||||||
|
#define JNIEXPORT __attribute ((visibility("default")))
|
||||||
|
#elif defined __APPLE__
|
||||||
|
#define DUILITE_CALL
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT
|
||||||
|
#elif defined __unix__
|
||||||
|
#define DUILITE_CALL
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT __attribute ((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define DUILITE_CALL
|
||||||
|
#define DUILITE_IMPORT_OR_EXPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DUILITE_VERSION "DUILITE 0.1.4"
|
||||||
|
#define DUILITE_VERSION_NUM 104
|
||||||
|
|
||||||
|
#define DUILITE_MSG_TYPE_JSON 0
|
||||||
|
#define DUILITE_MSG_TYPE_BINARY 1
|
||||||
|
|
||||||
|
enum duilite_callback_type {
|
||||||
|
DUILITE_CALLBACK_FESPA_WAKEUP = 0,
|
||||||
|
DUILITE_CALLBACK_FESPA_DOA,
|
||||||
|
DUILITE_CALLBACK_FESPA_BEAMFORMING,
|
||||||
|
DUILITE_CALLBACK_FESPL_WAKEUP,
|
||||||
|
DUILITE_CALLBACK_FESPL_DOA,
|
||||||
|
DUILITE_CALLBACK_FESPL_BEAMFORMING
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef int (*duilite_callback)(void *userdata, int type, char *msg, int len);
|
||||||
|
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_library_load(char *cfg);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT void DUILITE_CALL duilite_library_release();
|
||||||
|
|
||||||
|
struct duilite_vad;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_vad * DUILITE_CALL duilite_vad_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_vad_start(struct duilite_vad *vad, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_vad_feed(struct duilite_vad *vad, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_vad_stop(struct duilite_vad *vad);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_vad_cancel(struct duilite_vad *vad);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_vad_delete(struct duilite_vad *vad);
|
||||||
|
|
||||||
|
struct duilite_speexenc;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_speexenc * DUILITE_CALL duilite_speexenc_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_speexenc_start(struct duilite_speexenc *speexenc, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_speexenc_feed(struct duilite_speexenc *speexenc, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_speexenc_stop(struct duilite_speexenc *speexenc);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_speexenc_delete(struct duilite_speexenc *speexenc);
|
||||||
|
|
||||||
|
struct duilite_echo;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_echo * DUILITE_CALL duilite_echo_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_echo_start(struct duilite_echo *echo, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_echo_feed(struct duilite_echo *echo, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_echo_stop(struct duilite_echo *echo);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_echo_cancel(struct duilite_echo *echo);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_echo_delete(struct duilite_echo *echo);
|
||||||
|
|
||||||
|
struct duilite_wakeup;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_wakeup * DUILITE_CALL duilite_wakeup_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_wakeup_start(struct duilite_wakeup *wakeup, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_wakeup_feed(struct duilite_wakeup *wakeup, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_wakeup_stop(struct duilite_wakeup *wakeup);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_wakeup_cancel(struct duilite_wakeup *wakeup);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_wakeup_delete(struct duilite_wakeup *wakeup);
|
||||||
|
|
||||||
|
struct duilite_cntts;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_cntts * DUILITE_CALL duilite_cntts_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_cntts_start(struct duilite_cntts *cntts, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_cntts_feed(struct duilite_cntts *cntts, char *data);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_cntts_delete(struct duilite_cntts *cntts);
|
||||||
|
|
||||||
|
struct duilite_gram;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_gram * DUILITE_CALL duilite_gram_new(char *cfg);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_gram_start(struct duilite_gram *gram, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_gram_delete(struct duilite_gram *gram);
|
||||||
|
|
||||||
|
struct duilite_asr;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_asr * DUILITE_CALL duilite_asr_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_asr_start(struct duilite_asr *asr, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_asr_feed(struct duilite_asr *asr, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_asr_stop(struct duilite_asr *asr);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_asr_cancel(struct duilite_asr *asr);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_asr_delete(struct duilite_asr *asr);
|
||||||
|
|
||||||
|
struct duilite_fespa;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_fespa * DUILITE_CALL duilite_fespa_new(char *cfg);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_register(struct duilite_fespa *fespa, int callback_type, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_start(struct duilite_fespa *fespa, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_feed(struct duilite_fespa *fespa, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_stop(struct duilite_fespa *fespa);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_set(struct duilite_fespa *fespa, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespa_delete(struct duilite_fespa *fespa);
|
||||||
|
|
||||||
|
struct duilite_fespl;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_fespl * DUILITE_CALL duilite_fespl_new(char *cfg);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_register(struct duilite_fespl *fespl, int callback_type, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_start(struct duilite_fespl *fespl, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_feed(struct duilite_fespl *fespl, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_stop(struct duilite_fespl *fespl);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_set(struct duilite_fespl *fespl, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fespl_delete(struct duilite_fespl *fespl);
|
||||||
|
|
||||||
|
struct duilite_fdm;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_fdm * DUILITE_CALL duilite_fdm_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_start(struct duilite_fdm *fdm, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_set(struct duilite_fdm *fdm, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_get(struct duilite_fdm *fdm, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_feed(struct duilite_fdm *fdm, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_stop(struct duilite_fdm *fdm);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_fdm_delete(struct duilite_fdm *fdm);
|
||||||
|
|
||||||
|
struct duilite_nr;
|
||||||
|
DUILITE_IMPORT_OR_EXPORT struct duilite_nr * DUILITE_CALL duilite_nr_new(char *cfg, duilite_callback callback, void *userdata);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_nr_start(struct duilite_nr *nr, char *param);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_nr_feed(struct duilite_nr *nr, char *data, int len);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_nr_stop(struct duilite_nr *nr);
|
||||||
|
DUILITE_IMPORT_OR_EXPORT int DUILITE_CALL duilite_nr_delete(struct duilite_nr *nr);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
25
rk3308/aispeech-4mic-32bit/dds_client/include/os_event_group.h
Executable file
25
rk3308/aispeech-4mic-32bit/dds_client/include/os_event_group.h
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef OS_EVENT_GROUP_H
|
||||||
|
#define OS_EVENT_GROUP_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef struct os_event_group* os_event_group_handle_t;
|
||||||
|
|
||||||
|
typedef uint64_t os_event_bit_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_event_group_handle_t os_event_group_create();
|
||||||
|
__attribute ((visibility("default"))) os_event_bit_t os_event_group_set_bits(os_event_group_handle_t self, os_event_bit_t bits);
|
||||||
|
__attribute ((visibility("default"))) os_event_bit_t os_event_group_wait_bits(os_event_group_handle_t self, os_event_bit_t bits, bool all, bool clear);
|
||||||
|
__attribute ((visibility("default"))) os_event_bit_t os_event_group_clear_bits(os_event_group_handle_t self, os_event_bit_t bits);
|
||||||
|
__attribute ((visibility("default"))) int os_event_group_reset_bits(os_event_group_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void os_event_group_destroy(os_event_group_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
92
rk3308/aispeech-4mic-32bit/dds_client/include/os_log.h
Executable file
92
rk3308/aispeech-4mic-32bit/dds_client/include/os_log.h
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#ifndef OS_LOG_H
|
||||||
|
#define OS_LOG_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
OS_LOG_LEVEL_DEBUG,
|
||||||
|
OS_LOG_LEVEL_INFO,
|
||||||
|
OS_LOG_LEVEL_WARNING,
|
||||||
|
OS_LOG_LEVEL_ERROR,
|
||||||
|
}os_log_level_t;
|
||||||
|
|
||||||
|
typedef void (*print_module_log_t)(void *self, const char *func, int line, os_log_level_t level, const char *message, ...);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *module;
|
||||||
|
os_log_level_t level;
|
||||||
|
print_module_log_t print;
|
||||||
|
} os_log_block_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) void os_print_module_log(void *self, const char *func, int line, os_log_level_t level, const char *message, ...);
|
||||||
|
|
||||||
|
#ifdef OS_DEBUG_LEVEL_NONE
|
||||||
|
#define os_log_init(file)
|
||||||
|
#define os_log_deinit()
|
||||||
|
#define os_log_create_module(module, level)
|
||||||
|
#define OS_LOG_D(module, message, ...)
|
||||||
|
#define OS_LOG_I(module, message, ...)
|
||||||
|
#define OS_LOG_W(module, message, ...)
|
||||||
|
#define OS_LOG_E(module, message, ...)
|
||||||
|
#else
|
||||||
|
__attribute ((visibility("default"))) int os_log_init(const char *file);
|
||||||
|
__attribute ((visibility("default"))) void os_log_deinit();
|
||||||
|
#define os_log_create_module(module, level) \
|
||||||
|
os_log_block_t os_log_block_##module = \
|
||||||
|
{ \
|
||||||
|
#module, \
|
||||||
|
(level), \
|
||||||
|
os_print_module_log \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define OS_LOG_D(module, message, ...) \
|
||||||
|
do { \
|
||||||
|
extern os_log_block_t os_log_block_##module; \
|
||||||
|
os_log_block_##module.print(&os_log_block_##module, \
|
||||||
|
__func__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_LOG_LEVEL_DEBUG, \
|
||||||
|
(message), \
|
||||||
|
##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define OS_LOG_I(module, message, ...) \
|
||||||
|
do { \
|
||||||
|
extern os_log_block_t os_log_block_##module; \
|
||||||
|
os_log_block_##module.print(&os_log_block_##module, \
|
||||||
|
__func__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_LOG_LEVEL_INFO, \
|
||||||
|
(message), \
|
||||||
|
##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define OS_LOG_W(module, message, ...) \
|
||||||
|
do { \
|
||||||
|
extern os_log_block_t os_log_block_##module; \
|
||||||
|
os_log_block_##module.print(&os_log_block_##module, \
|
||||||
|
__func__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_LOG_LEVEL_WARNING, \
|
||||||
|
(message), \
|
||||||
|
##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define OS_LOG_E(module, message, ...) \
|
||||||
|
do { \
|
||||||
|
extern os_log_block_t os_log_block_##module; \
|
||||||
|
os_log_block_##module.print(&os_log_block_##module, \
|
||||||
|
__func__, \
|
||||||
|
__LINE__, \
|
||||||
|
OS_LOG_LEVEL_ERROR, \
|
||||||
|
(message), \
|
||||||
|
##__VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_memory.h
Executable file
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_memory.h
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef OS_MEMORY_H
|
||||||
|
#define OS_MEMORY_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) void *os_malloc(size_t size);
|
||||||
|
__attribute ((visibility("default"))) void os_free(void *ptr);
|
||||||
|
__attribute ((visibility("default"))) void *os_calloc(size_t nmemb, size_t size);
|
||||||
|
__attribute ((visibility("default"))) void *os_realloc(void *ptr, size_t size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_mutex.h
Executable file
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_mutex.h
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef OS_MUTEX_H
|
||||||
|
#define OS_MUTEX_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct os_mutex* os_mutex_handle_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_mutex_handle_t os_mutex_create();
|
||||||
|
__attribute ((visibility("default"))) int os_mutex_lock(os_mutex_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_mutex_unlock(os_mutex_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void os_mutex_destroy(os_mutex_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
24
rk3308/aispeech-4mic-32bit/dds_client/include/os_queue.h
Executable file
24
rk3308/aispeech-4mic-32bit/dds_client/include/os_queue.h
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef OS_QUEUE_H
|
||||||
|
#define OS_QUEUE_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct os_queue* os_queue_handle_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_queue_handle_t os_queue_create(size_t item_count, size_t item_size);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_send(os_queue_handle_t self, const void *data);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_send_font(os_queue_handle_t self, const void *data);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_receive(os_queue_handle_t self, void *data);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_receive_back(os_queue_handle_t self, void *data);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_stop(os_queue_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_finish(os_queue_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_queue_peek(os_queue_handle_t self, void *data);
|
||||||
|
__attribute ((visibility("default"))) void os_queue_destroy(os_queue_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_semaphore.h
Executable file
17
rk3308/aispeech-4mic-32bit/dds_client/include/os_semaphore.h
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef OS_SEMAPHORE_H
|
||||||
|
#define OS_SEMAPHORE_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct os_semaphore* os_semaphore_handle_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_semaphore_handle_t os_semaphore_create();
|
||||||
|
__attribute ((visibility("default"))) int os_semaphore_take(os_semaphore_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_semaphore_give(os_semaphore_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void os_semaphore_destroy(os_semaphore_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
26
rk3308/aispeech-4mic-32bit/dds_client/include/os_stream.h
Executable file
26
rk3308/aispeech-4mic-32bit/dds_client/include/os_stream.h
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef OS_STREAM_H
|
||||||
|
#define OS_STREAM_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct os_stream* os_stream_handle_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_stream_handle_t os_stream_create(size_t size);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_start(os_stream_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_read(os_stream_handle_t self, char *data, size_t data_len);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_read2(os_stream_handle_t self, char *data, size_t data_len);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_write(os_stream_handle_t self, const char *data, size_t data_len);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_write2(os_stream_handle_t self, const char *data, size_t data_len);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_finish(os_stream_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_stop(os_stream_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_stop2(os_stream_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int os_stream_reset(os_stream_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void os_stream_destroy(os_stream_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
20
rk3308/aispeech-4mic-32bit/dds_client/include/os_thread.h
Executable file
20
rk3308/aispeech-4mic-32bit/dds_client/include/os_thread.h
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef OS_THREAD_H
|
||||||
|
#define OS_THREAD_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void (*run)(void *args);
|
||||||
|
void *args;
|
||||||
|
}os_thread_cfg_t;
|
||||||
|
|
||||||
|
typedef struct os_thread* os_thread_handle_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) os_thread_handle_t os_thread_create(os_thread_cfg_t *cfg);
|
||||||
|
__attribute ((visibility("default"))) void os_thread_exit(os_thread_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
39
rk3308/aispeech-4mic-32bit/dds_client/include/os_time.h
Executable file
39
rk3308/aispeech-4mic-32bit/dds_client/include/os_time.h
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef OS_TIME_H
|
||||||
|
#define OS_TIME_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
OS_TIME_TYPE_CLOCK,
|
||||||
|
OS_TIME_TYPE_SECOND,
|
||||||
|
OS_TIME_TYPE_MILLISECOND
|
||||||
|
} os_time_type_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
int year;
|
||||||
|
int month;
|
||||||
|
int day;
|
||||||
|
int hour;
|
||||||
|
int minute;
|
||||||
|
int second;
|
||||||
|
int millisecond;
|
||||||
|
int week;
|
||||||
|
int year_day;
|
||||||
|
} clock;
|
||||||
|
size_t second;
|
||||||
|
size_t millisecond;
|
||||||
|
};
|
||||||
|
os_time_type_t type;
|
||||||
|
}os_time_t;
|
||||||
|
|
||||||
|
int os_time_now(os_time_t *timestamp);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
12
rk3308/aispeech-4mic-32bit/dds_client/include/os_utils.h
Executable file
12
rk3308/aispeech-4mic-32bit/dds_client/include/os_utils.h
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef OS_UTILS_H
|
||||||
|
#define OS_UTILS_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) char *os_strdup(char *src);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
62
rk3308/aispeech-4mic-32bit/dds_client/include/player.h
Executable file
62
rk3308/aispeech-4mic-32bit/dds_client/include/player.h
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#ifndef PLAYER_H
|
||||||
|
#define PLAYER_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) int player_init();
|
||||||
|
|
||||||
|
typedef struct player* player_handle_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t preprocess_buf_size;
|
||||||
|
size_t decode_buf_size;
|
||||||
|
char *name;
|
||||||
|
} player_cfg_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) player_handle_t player_create(player_cfg_t *cfg);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
//本地流
|
||||||
|
PLAY_TYPE_NATIVE = 0,
|
||||||
|
//网络流
|
||||||
|
PLAY_TYPE_NETWORK,
|
||||||
|
//应用流
|
||||||
|
PLAY_TYPE_APP,
|
||||||
|
}play_type_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
play_type_t type;
|
||||||
|
char *target;
|
||||||
|
bool need_free;
|
||||||
|
|
||||||
|
//当播放PCM数据流时需要指定下面三个参数
|
||||||
|
int samplerate;
|
||||||
|
int bits;
|
||||||
|
int channels;
|
||||||
|
}play_cfg_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
//空闲状态
|
||||||
|
PLAYER_STATE_IDLE = 0,
|
||||||
|
//运行状态
|
||||||
|
PLAYER_STATE_RUNNING,
|
||||||
|
//暂停状态
|
||||||
|
PLAYER_STATE_PAUSED
|
||||||
|
}player_state_t;
|
||||||
|
|
||||||
|
__attribute ((visibility("default"))) int player_play(player_handle_t self, play_cfg_t *cfg);
|
||||||
|
__attribute ((visibility("default"))) int player_pause(player_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int player_resume(player_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int player_stop(player_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) int player_wait_idle(player_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void player_destroy(player_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void player_deinit();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
24
rk3308/aispeech-4mic-32bit/dds_client/include/recorder.h
Executable file
24
rk3308/aispeech-4mic-32bit/dds_client/include/recorder.h
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef RECORDER_H
|
||||||
|
#define RECORDER_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "alsa_cfg.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct recorder_handle* recorder_handle_t;
|
||||||
|
__attribute ((visibility("default"))) recorder_handle_t recorder_open(alsa_open_config_t *config);
|
||||||
|
__attribute ((visibility("default"))) int recorder_start(recorder_handle_t self);
|
||||||
|
//注意alsa的一帧值一个采样时刻所有通道的数据
|
||||||
|
//计算方法:
|
||||||
|
// 一帧字节数 = config->bits * config->channels / 8;
|
||||||
|
// frame_count必须为config->period_size;
|
||||||
|
__attribute ((visibility("default"))) int recorder_read(recorder_handle_t self, char *frame, size_t frame_count);
|
||||||
|
__attribute ((visibility("default"))) int recorder_stop(recorder_handle_t self);
|
||||||
|
__attribute ((visibility("default"))) void recorder_close(recorder_handle_t self);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
BIN
rk3308/aispeech-4mic-32bit/dds_client/lib/rk3308_32/libduilite_fespl.so
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/lib/rk3308_32/libduilite_fespl.so
Executable file
Binary file not shown.
BIN
rk3308/aispeech-4mic-32bit/dds_client/lib/rk3308_32/libplayer_dev.so
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/lib/rk3308_32/libplayer_dev.so
Executable file
Binary file not shown.
6
rk3308/aispeech-4mic-32bit/dds_client/readmin.txt
Executable file
6
rk3308/aispeech-4mic-32bit/dds_client/readmin.txt
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
build 32bit 2mic
|
||||||
|
./aimake/aimake.sh -t rk3308_32 MIC_TYPE=fespa clean all
|
||||||
|
|
||||||
|
open "#LOCAL_CFLAGS += -DSAVE_AUDIO" in aimakefile download audio data
|
||||||
|
/userdata/1.pcm input data
|
||||||
|
/userdata/2.pcm output data
|
||||||
Binary file not shown.
BIN
rk3308/aispeech-4mic-32bit/dds_client/res/UDA_asr_chan2-2-mic2_30mm_20180504.bin
Executable file
BIN
rk3308/aispeech-4mic-32bit/dds_client/res/UDA_asr_chan2-2-mic2_30mm_20180504.bin
Executable file
Binary file not shown.
Reference in New Issue
Block a user