Skip to content

Commit d81fa09

Browse files
authored
Merge branch 'master' into resume-check-ctx-expire
2 parents 98bf6ea + 8b8c4b5 commit d81fa09

File tree

6 files changed

+124
-18
lines changed

6 files changed

+124
-18
lines changed

src/main/java/com/qiniu/qvs/DeviceManager.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.qiniu.qvs.model.PatchOperation;
66
import com.qiniu.http.Client;
77
import com.qiniu.http.Response;
8+
import com.qiniu.qvs.model.PlayContral;
89
import com.qiniu.qvs.model.VoiceChat;
910
import com.qiniu.util.Auth;
1011
import com.qiniu.util.StringMap;
@@ -138,22 +139,24 @@ public Response queryGBRecordHistories(String namespaceId, String gbId, String c
138139
return QvsResponse.get(url, client, auth);
139140
}
140141

141-
public Response getVoiceChatUrl(String namespaceId, String gbId, VoiceChat voiceChat) throws QiniuException {
142+
public Response getVoiceChatUrl(String namespaceId, String gbId, VoiceChat voiceChat) throws QiniuException {
142143
String url = String.format("%s/v1/namespaces/%s/devices/%s/talk", apiServer, namespaceId, gbId);
143-
StringMap params = getStringMap(voiceChat);
144+
StringMap params = QvsMap.getVoiceChatMap(voiceChat);
144145
return com.qiniu.qvs.QvsResponse.post(url, params, client, auth);
145146
}
146147

147-
private StringMap getStringMap(VoiceChat voiceChat) {
148-
StringMap params = new StringMap().putNotNull("isV2", voiceChat.getLatency());
149-
params.put("channels", voiceChat.getChannels());
150-
params.put("version", voiceChat.getVersion());
151-
params.put("transProtocol", voiceChat.getTransProtocol());
152-
return params;
148+
public Response sendVoiceChatData(String url, String base64_pcm) throws QiniuException {
149+
StringMap params = new StringMap().putNotNull("base64_pcm", base64_pcm);
150+
return QvsResponse.post(url, params, client, auth);
153151
}
154152

155-
public Response sendVoiceChatData(String url, String base64_pcm) throws QiniuException {
156-
StringMap params = new StringMap().putNotNull("base64_pcm", base64_pcm);
153+
/*
154+
* 本地录像回放控制
155+
* streamId 流ID可以从查询本地录像列表接口queryGBRecordHistories获取的streamId
156+
*/
157+
public Response controlGBRecord(String namespaceId, String streamId, PlayContral playContral) throws QiniuException {
158+
String url = String.format("%s/v1/namespaces/%s/streams/%s/playback/control", apiServer, namespaceId, streamId);
159+
StringMap params = QvsMap.getPlayContralMap(playContral);
157160
return QvsResponse.post(url, params, client, auth);
158161
}
159162
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.qiniu.qvs;
2+
3+
import com.qiniu.qvs.model.PlayContral;
4+
import com.qiniu.qvs.model.VoiceChat;
5+
import com.qiniu.util.StringMap;
6+
7+
public class QvsMap {
8+
private QvsMap() {
9+
}
10+
11+
public static StringMap getVoiceChatMap(VoiceChat voiceChat) {
12+
StringMap params = new StringMap().putNotNull("isV2", voiceChat.getLatency());
13+
params.put("channels", voiceChat.getChannels());
14+
params.put("version", voiceChat.getVersion());
15+
params.put("transProtocol", voiceChat.getTransProtocol());
16+
return params;
17+
}
18+
19+
public static StringMap getPlayContralMap(PlayContral playContral) {
20+
StringMap params = new StringMap().putNotNull("command", playContral.getCommand());
21+
params.put("range", playContral.getRange());
22+
params.put("scale", playContral.getScale());
23+
return params;
24+
}
25+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.qiniu.qvs.model;
2+
3+
public class PlayContral {
4+
private String command;
5+
private String range;
6+
private Float scale;
7+
8+
public PlayContral(String command, String range, Float scale) {
9+
this.command = command;
10+
this.range = range;
11+
this.scale = scale;
12+
}
13+
14+
public String getCommand() {
15+
return command;
16+
}
17+
18+
public void setCommand(String command) {
19+
this.command = command;
20+
}
21+
22+
public String getRange() {
23+
return range;
24+
}
25+
26+
public void setRange(String range) {
27+
this.range = range;
28+
}
29+
30+
public Float getScale() {
31+
return scale;
32+
}
33+
34+
public void setScale(Float scale) {
35+
this.scale = scale;
36+
}
37+
}

src/main/java/com/qiniu/qvs/model/VoiceChat.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ public class VoiceChat {
66
private String version; // 对讲国标协议版本,取值"2014"或"2016",默认为2014,例如大部分大华摄像头为GBT 28181-2014版本对讲模式
77
private String transProtocol; // 取值"tcp"或"udp",流传输模式,默认udp
88

9+
public VoiceChat(Boolean latency, String[] channels, String version, String transProtocol) {
10+
this.latency = latency;
11+
this.channels = channels;
12+
this.version = version;
13+
this.transProtocol = transProtocol;
14+
}
15+
916
public Boolean getLatency() {
1017
return latency;
1118
}

src/test/java/test/com/qiniu/qvs/DeviceManagerTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,39 @@ public void testQueryGBRecordHistories() {
201201
}
202202
}
203203
}
204+
205+
@Test
206+
@Tag("IntegrationTest")
207+
public void testQueryGBRecordHistories() {
208+
try {
209+
res = deviceManager.queryGBRecordHistories("qiniu", "31011500991180013385", "34020000001310000001",
210+
1665190800, 1665192093);
211+
assertNotNull(res);
212+
System.out.println(res.bodyString());
213+
} catch (QiniuException e) {
214+
e.printStackTrace();
215+
} finally {
216+
if (res != null) {
217+
res.close();
218+
}
219+
}
220+
}
221+
222+
@Test
223+
@Tag("IntegrationTest")
224+
public void controlGBRecord() {
225+
try {
226+
PlayContral playContral = new PlayContral("play","5",2.0F);
227+
res = deviceManager.controlGBRecord("qiniu", "31011500991180013385_34020000001310000001_history_1665190800_1665192092", playContral);
228+
assertNotNull(res);
229+
System.out.println(res.bodyString());
230+
} catch (QiniuException e) {
231+
e.printStackTrace();
232+
} finally {
233+
if (res != null) {
234+
res.close();
235+
}
236+
}
237+
}
204238
*/
205239
}

src/test/java/test/com/qiniu/streaming/StreamingTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55
import static org.junit.jupiter.api.Assertions.assertNotEquals;
66
import static org.junit.jupiter.api.Assertions.assertTrue;
77
import static org.junit.jupiter.api.Assertions.fail;
8+
9+
import org.junit.jupiter.api.Tag;
10+
import org.junit.jupiter.api.Test;
11+
812
import com.qiniu.common.QiniuException;
913
import com.qiniu.streaming.StreamingManager;
1014
import com.qiniu.streaming.model.ActivityRecords;
1115
import com.qiniu.streaming.model.StreamAttribute;
1216
import com.qiniu.streaming.model.StreamListing;
17+
import com.qiniu.streaming.model.StreamStatus;
1318
import com.qiniu.util.Auth;
19+
1420
import test.com.qiniu.TestConfig;
15-
import org.junit.jupiter.api.Tag;
16-
import org.junit.jupiter.api.Test;
1721

1822
/**
1923
* Created by bailong on 16/9/22 Updated by panyuan on 19/3/12
@@ -88,12 +92,8 @@ public void testStreamOperation() throws QiniuException {
8892
assertEquals(0, attr.disabledTill);
8993
assertNotEquals(0, attr.updatedAt);
9094

91-
try {
92-
manager.status(stream);
93-
fail();
94-
} catch (QiniuException e) {
95-
assertEquals(619, e.code());
96-
}
95+
StreamStatus status = manager.status(stream);
96+
assertEquals(0, status.startAt);
9797

9898
try {
9999
manager.saveAs(stream, null, 0, 0);

0 commit comments

Comments
 (0)