Skip to content

Commit f757f5a

Browse files
committed
Lua Acr插件配置信息传递
1 parent 448cb87 commit f757f5a

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

VideoOS/LuaViewSDK/src/cn/com/venvy/lua/maper/VenvyAcrCloudMapper.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.io.File;
1414
import java.util.List;
1515

16+
import cn.com.venvy.common.bean.AcrConfigInfo;
1617
import cn.com.venvy.common.utils.VenvyFileUtil;
1718
import cn.com.venvy.common.utils.VenvyLog;
1819
import cn.com.venvy.lua.ud.VenvyUDAcrClouldCallback;
@@ -64,12 +65,18 @@ public LuaValue startAcrRecognize(U target, Varargs args) {
6465
VenvyLog.e(VenvyAcrCloudMapper.class.getName(), new NullPointerException("startAcrRecognize is error,because recognize url is null"));
6566
return LuaValue.NIL;
6667
}
67-
File file=new File(filePath);
68-
if(!file.exists()||!file.isFile()){
68+
String key = LuaUtil.getString(args, 3);
69+
String secret = LuaUtil.getString(args, 4);
70+
if (TextUtils.isEmpty(key) || TextUtils.isEmpty(secret)) {
71+
VenvyLog.e(VenvyAcrCloudMapper.class.getName(), new NullPointerException("startAcrRecognize is error,because key or secret is null"));
72+
return LuaValue.NIL;
73+
}
74+
File file = new File(filePath);
75+
if (!file.exists() || !file.isFile()) {
6976
VenvyLog.e(VenvyAcrCloudMapper.class.getName(), new NullPointerException("startAcrRecognize is error,because recognize url is null"));
7077
return LuaValue.NIL;
7178
}
72-
target.startRecognize(VenvyFileUtil.readBytes(file));
79+
target.startRecognize(new AcrConfigInfo(key, secret, null), VenvyFileUtil.readBytes(file));
7380
}
7481
} catch (Exception e) {
7582
VenvyLog.e(VenvyAcrCloudMapper.class.getName(), e);

VideoOS/LuaViewSDK/src/cn/com/venvy/lua/ud/VenvyUDAcrClouldCallback.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.luaj.vm2.Varargs;
1313

1414
import cn.com.venvy.common.acr.VenvyACRCloudFactory;
15+
import cn.com.venvy.common.bean.AcrConfigInfo;
1516
import cn.com.venvy.common.interf.IACRCloud;
1617
import cn.com.venvy.lua.view.VenvyLVAcrClouldCallback;
1718

@@ -46,9 +47,9 @@ public void handleAcrMessageBundle(Bundle bundle) {
4647
LuaUtil.callFunction(mMqttCallback, JsonUtil.toLuaTable(message));
4748
}
4849

49-
public void startRecognize(byte[] buffer) {
50+
public void startRecognize(AcrConfigInfo info,byte[] buffer) {
5051
if (mAcrCloud != null) {
51-
mAcrCloud.startRecognize(buffer);
52+
mAcrCloud.startRecognize(info,buffer);
5253
}
5354
}
5455

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cn.com.venvy.common.bean;
2+
3+
/**
4+
* Created by lgf on 2020/2/27.
5+
*/
6+
7+
public class AcrConfigInfo {
8+
public String host;
9+
public String key;
10+
public String secret;
11+
12+
public AcrConfigInfo(String key, String secret, String host) {
13+
this.host = host;
14+
this.key = key;
15+
this.secret = secret;
16+
}
17+
}

VideoOS/VenvyLibrary/src/main/java/cn/com/venvy/common/interf/IACRCloud.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package cn.com.venvy.common.interf;
22

3+
import cn.com.venvy.common.bean.AcrConfigInfo;
4+
35
/**
46
* Created by lgf on 2020/2/24.
57
*/
@@ -13,7 +15,7 @@ public interface IACRCloud {
1315
由于“ Android UI主线程”无法发送网络请求,因此必须在子线程中调用此函数。
1416
* @param buffer
1517
*/
16-
void startRecognize(byte[] buffer);
18+
void startRecognize(AcrConfigInfo info, byte[] buffer);
1719

1820
/***
1921
* 此功能将立即取消识别。

0 commit comments

Comments
 (0)