Quellcode durchsuchen

工作空间 rtmp测试

S0025136190 vor 1 Jahr
Ursprung
Commit
dd6df3314d

+ 1 - 1
Backend/cloud-sdk/src/main/java/com/dji/sdk/cloudapi/device/api/AbstractDeviceService.java

@@ -148,7 +148,7 @@ public class AbstractDeviceService {
      */
     @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_RC_LIVE_STATUS)
     public void rcLiveStatusUpdate(TopicStateRequest<RcLiveStatus> request, MessageHeaders headers) {
-        throw new UnsupportedOperationException("rcLiveStatusUpdate not implemented");
+        //throw new UnsupportedOperationException("rcLiveStatusUpdate not implemented");
     }
 
     /**

+ 1 - 1
Backend/sample/pom.xml

@@ -164,7 +164,7 @@
         <!--视频截取依赖-->
         <dependency>
             <groupId>org.bytedeco</groupId>
-            <artifactId>javacv-platform</artifactId>
+            <artifactId>javacv</artifactId>
             <version>1.5.9</version>
         </dependency>
 

+ 0 - 15
Backend/sample/src/main/java/com/dji/sample/common/util/ThumbnailatorUtil.java

@@ -3,32 +3,17 @@ package com.dji.sample.common.util;
 
 import com.dji.sample.component.oss.model.OssConfiguration;
 import com.dji.sample.component.oss.service.impl.OssServiceContext;
-import com.dji.sample.media.model.MediaExifDTO;
-import com.drew.imaging.ImageMetadataReader;
-import com.drew.metadata.Metadata;
-import com.drew.metadata.exif.ExifIFD0Directory;
-import com.drew.metadata.exif.ExifSubIFDDirectory;
-import com.drew.metadata.exif.GpsDirectory;
-import com.drew.metadata.file.FileTypeDirectory;
-import com.drew.metadata.mp4.Mp4Directory;
-import com.drew.metadata.mp4.media.Mp4VideoDirectory;
 import lombok.extern.slf4j.Slf4j;
 import net.coobird.thumbnailator.Thumbnails;
 import org.bytedeco.javacv.FFmpegFrameGrabber;
 import org.bytedeco.javacv.Frame;
 import org.bytedeco.javacv.Java2DFrameConverter;
 import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
 
-import javax.imageio.ImageIO;
 import java.awt.*;
 import java.awt.image.BufferedImage;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * @author hqjiang

+ 6 - 6
Backend/sample/src/main/java/com/dji/sample/map/service/impl/GroupElementServiceImpl.java

@@ -50,16 +50,16 @@ public class GroupElementServiceImpl implements IGroupElementService {
     @Override
     public Boolean saveElement(String groupId, Integer elementFrom, CreateMapElementRequest elementCreate) {
         //获取序号
-        Integer elementCount = mapper.selectCount(new LambdaQueryWrapper<GroupElementEntity>()
-                .eq(GroupElementEntity::getGroupId, groupId)
-                .eq(GroupElementEntity::getElementType,ElementTypeEnum.findVal(elementCreate.getResource().getContent().getGeometry().getType())));
+//        Integer elementCount = mapper.selectCount(new LambdaQueryWrapper<GroupElementEntity>()
+//                .eq(GroupElementEntity::getGroupId, groupId)
+//                .eq(GroupElementEntity::getElementType,ElementTypeEnum.findVal(elementCreate.getResource().getContent().getGeometry().getType())));
 
         Optional<GroupElementEntity> groupElementOpt = this.getEntityByElementId(elementCreate.getId());
 
         if (groupElementOpt.isPresent()) {
             return false;
         }
-        GroupElementEntity groupElement = this.createDtoConvertToEntity(elementFrom, elementCount, elementCreate);
+        GroupElementEntity groupElement = this.createDtoConvertToEntity(elementFrom, null, elementCreate);
         groupElement.setGroupId(groupId);
 
         boolean saveElement = mapper.insert(groupElement) > 0;
@@ -195,8 +195,8 @@ public class GroupElementServiceImpl implements IGroupElementService {
         ElementProperty properties = elementCreate.getResource().getContent().getProperties();
         return GroupElementEntity.builder()
                 .elementId(elementCreate.getId())
-                //.elementName(elementCreate.getName())
-                .elementName(elementCreate.getResource().getUsername() + ++elementCnt)
+                .elementName(elementCreate.getName())
+//                .elementName(elementCreate.getResource().getUsername() + ++elementCnt)
                 .username(elementCreate.getResource().getUsername())
                 .elementType(ElementTypeEnum.findVal(elementCreate.getResource().getContent().getGeometry().getType()))
                 .clampToGround(properties.getClampToGround() != null && properties.getClampToGround())

+ 3 - 1
Backend/sample/src/main/java/com/dji/sample/map/service/impl/GroupServiceImpl.java

@@ -40,7 +40,9 @@ public class GroupServiceImpl implements IGroupService {
 
     @Override
     public List<GetMapElementsResponse> getAllGroupsByWorkspaceId(String workspaceId, String groupId, Boolean isDistributed) {
-        createDefaultGroups(workspaceId);
+        if(StringUtils.hasText(workspaceId)) {
+            createDefaultGroups(workspaceId);
+        }
         return mapper.selectList(
                 new LambdaQueryWrapper<GroupEntity>()
                         .eq(GroupEntity::getWorkspaceId, workspaceId)

+ 1 - 1
Backend/sample/src/main/java/com/dji/sample/media/controller/FileController.java

@@ -173,7 +173,7 @@ public class FileController {
      * @return
      */
     @PutMapping("/{workspace_id}/updateFile/{file_id}")
-    public HttpResultResponse updateDevice(@RequestBody MediaFileDTO mediaFile,
+    public HttpResultResponse updateFile(@RequestBody MediaFileDTO mediaFile,
                                            @PathVariable("workspace_id") String workspaceId,
                                            @PathVariable("file_id") String fileId) {
         mediaFile.setFileId(fileId);

+ 19 - 13
Backend/sample/src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java

@@ -273,7 +273,7 @@ public class FileServiceImpl implements IFileService {
         }
         //生成缩略图
         String tObjectKey = getThumbnailObjectKey(file.getName());
-        putThumbnailImage(tObjectKey,file.getObjectKey());
+        putThumbnailImage(tObjectKey,file.getObjectKey(),true);
 
         MediaFileEntity.MediaFileEntityBuilder builder = MediaFileEntity.builder();
 
@@ -368,8 +368,7 @@ public class FileServiceImpl implements IFileService {
             }
             MediaTypeEnum mediaTypeEnum = convertMediaType(entity);
             String url = ossService.getObjectUrl(OssConfiguration.bucket, entity.getObjectKey()).toString();
-//            String thumbnailURL = getThumbnailURL(entity);
-            String thumbnailURL = null;
+            String thumbnailURL = getThumbnailURL(entity);
             builder.fileName(entity.getFileName())
                     .fileId(entity.getFileId())
                     .filePath(entity.getFilePath())
@@ -416,28 +415,35 @@ public class FileServiceImpl implements IFileService {
         String originFileName = entity.getFileName();
         //缩略图路径
         String tObjectKey = getThumbnailObjectKey(originFileName);
-        putThumbnailImage(tObjectKey,entity.getObjectKey());
+        if(!putThumbnailImage(tObjectKey,entity.getObjectKey(),false)) {
+            return null;
+        }
         return ossService.getObjectUrl(OssConfiguration.bucket, tObjectKey).toString();
 
     }
 
-    private void putThumbnailImage(String tObjectKey, String originObjectKey) {
+    private boolean putThumbnailImage(String tObjectKey, String originObjectKey,boolean toCreate) {
         if(originObjectKey.endsWith(PicExifUtil.MP4)) {
             System.out.println(originObjectKey);
         }
         //生成缩略图
         if(!ossService.objectExists(OssConfiguration.bucket,tObjectKey)) {
-            BufferedImage bufferedImage = ThumbnailatorUtil.getThumbnail(originObjectKey,100,100);
-            if(bufferedImage != null) {
-                ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-                try {
-                    ImageIO.write(bufferedImage, JPEG, outputStream);
-                } catch (IOException e) {
-                    e.printStackTrace();
+            if(toCreate) {
+                BufferedImage bufferedImage = ThumbnailatorUtil.getThumbnail(originObjectKey, 100, 100);
+                if (bufferedImage != null) {
+                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+                    try {
+                        ImageIO.write(bufferedImage, JPEG, outputStream);
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                    ossService.putObject(OssConfiguration.bucket, tObjectKey, new ByteArrayInputStream(outputStream.toByteArray()));
                 }
-                ossService.putObject(OssConfiguration.bucket,tObjectKey,new ByteArrayInputStream(outputStream.toByteArray()));
+            } else {
+                return false;
             }
         }
+        return true;
     }
 
     private String getThumbnailObjectKey(String originFileName) {

+ 14 - 14
Backend/sample/src/main/resources/application-test.yml

@@ -115,9 +115,9 @@ url:
 oss:
   enable: true
   provider: minio
-  endpoint: http://60.204.184.98:39000
-  access-key: dji_minio2
-  secret-key: 12345678
+  endpoint: http://49.234.30.234:9002
+  access-key: admin
+  secret-key: Qwer~123.
   bucket: dji-cloudapi
   expire: 3600
   region: us-east-1
@@ -143,18 +143,18 @@ cloud-api:
 livestream:
   url:
     # It is recommended to use a program to create Token. https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/media/RtcTokenBuilder2.java
-    agora:
-      channel: Please enter the agora channel.
-      token: Please enter the agora temporary token.
-      uid:  654321
+#    agora:
+#      channel: Please enter the agora channel.
+#      token: Please enter the agora temporary token.
+#      uid:  654321
 
     # RTMP  Note: This IP is the address of the streaming server. If you want to see livestream on web page, you need to convert the RTMP stream to WebRTC stream.
     rtmp:
-      url: Please enter the rtmp access address.  # Example: 'rtmp://192.168.1.1/live/'
-    rtsp:
-      username: Please enter the username.
-      password: Please enter the password.
-      port: 8554
+      url: rtmp://203.156.230.22:19350/rlive/stream_27?sign=nwo03DJb&  # Example: 'rtmp://192.168.1.1/live/'
+#    rtsp:
+#      username: Please enter the username.
+#      password: Please enter the password.
+#      port: 8554
 
     # GB28181 Note:If you don't know what these parameters mean, you can go to Pilot2 and select the GB28181 page in the cloud platform. Where the parameters same as these parameters.
 #    gb28181:
@@ -167,5 +167,5 @@ livestream:
 #      channel: Please enter the channel.
 
     # Webrtc: Only supports using whip standard
-    whip:
-      url: Please enter the rtmp access address. #  Example:http://192.168.1.1:1985/rtc/v1/whip/?app=live&stream=
+#    whip:
+#      url: Please enter the rtmp access address. #  Example:http://192.168.1.1:1985/rtc/v1/whip/?app=live&stream=