Commit 1b7145b9 by guoxuejian

Add LiveStartPushResponse class and update liveStartPush method to use it

parent 186c6ad5
package com.dji.sdk.cloudapi.livestream;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
/**
* Response output for live_start_push services_reply.
* Newer DJI firmware returns {"origin_video_id": []} in the output field.
*/
public class LiveStartPushResponse {
@JsonProperty("origin_video_id")
private List<String> originVideoId;
public LiveStartPushResponse() {
}
public List<String> getOriginVideoId() {
return originVideoId;
}
public LiveStartPushResponse setOriginVideoId(List<String> originVideoId) {
this.originVideoId = originVideoId;
return this;
}
}
......@@ -52,9 +52,9 @@ public abstract class AbstractLivestreamService {
* @param request data
* @return services_reply
*/
public TopicServicesResponse<ServicesReplyData<String>> liveStartPush(GatewayManager gateway, LiveStartPushRequest request) {
public TopicServicesResponse<ServicesReplyData<LiveStartPushResponse>> liveStartPush(GatewayManager gateway, LiveStartPushRequest request) {
return servicesPublish.publish(
new TypeReference<String>() {},
new TypeReference<LiveStartPushResponse>() {},
gateway.getGatewaySn(),
LiveStreamMethodEnum.LIVE_START_PUSH.getMethod(),
request,
......
......@@ -153,7 +153,6 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
Set<String> existingSessions = findSessionKeys(liveParam.getVideoId());
boolean streamAlreadyRunning = !forceMqttPush
&& existingSessions != null && !existingSessions.isEmpty();
String rtspOutputUrl = null; // RTSP 特殊:播放地址来自设备响应
if (streamAlreadyRunning) {
log.info("Stream already running with {} viewer(s), skip MQTT push and reuse. videoId={}",
......@@ -166,7 +165,7 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
// videoQuality 为空时默认 AUTO(refresh 场景前端可能不传)
VideoQualityEnum quality = liveParam.getVideoQuality() != null
? liveParam.getVideoQuality() : VideoQualityEnum.AUTO;
TopicServicesResponse<ServicesReplyData<String>> response = abstractLivestreamService.liveStartPush(
TopicServicesResponse<ServicesReplyData<LiveStartPushResponse>> response = abstractLivestreamService.liveStartPush(
SDKManager.getDeviceSDK(responseResult.getData().getDeviceSn()),
new LiveStartPushRequest()
.setUrl(url)
......@@ -184,11 +183,6 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
return HttpResultResponse.error(response.getData().getResult());
}
}
// 保存 RTSP 设备返回的 output(仅首次推流时设备会返回)
if (StringUtils.hasText(response.getData().getOutput())) {
rtspOutputUrl = response.getData().getOutput();
}
}
// ========== 构造播放地址(无论首个还是复用,URL 构造逻辑一致) ==========
......@@ -212,12 +206,7 @@ public class LiveStreamServiceImpl implements ILiveStreamService {
.toString());
break;
case RTSP:
// RTSP 优先用设备返回的 output 地址,复用时回退到配置 URL
if (StringUtils.hasText(rtspOutputUrl)) {
live.setUrl(rtspOutputUrl);
} else {
live.setUrl(url.toString());
}
break;
case WHIP:
live.setUrl(url.toString().replace("whip", "whep"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment