DJI Mobile SDK Documentation
      包:dji.v5.manager.interfaces
      classSince MSDK 5.8.0

      ICameraStreamManager

      相机码流管理类。支持相机镜头的码流显示、获取码流数据和帧数据等功能。以下是接口使用流程:

      Package dji.v5.manager.interfacesAndroid · Java / Kotlin

      相机码流管理类。支持相机镜头的码流显示、获取码流数据和帧数据等功能。以下是接口使用流程:

    • 通过addAvailableCameraUpdatedListener添加监听器获取可用的相机索引。
    • 调用putCameraStreamSurface将相机码流的画面显示到特定的的surface中。
    • 添加码流数据监听器addReceiveStreamListener来接收码流数据,码流数据可用于自行解码显示和第三方直播等功能。
    • 添加帧数据监听器addFrameListener来接收帧数据。帧数据可以用于AI识别等功能的算法处理。


    • MSDK 5.8.0开始支持

      成员

      31 个成员

      监听

      8

      方法

      11

      枚举

      5

      Class

      7
      method

      addAvailableCameraUpdatedListener

      Since MSDK 5.8.0
      void addAvailableCameraUpdatedListener(@NonNull AvailableCameraUpdatedListener listener)

      设置可用相机监听器。通过此监听器可以监听可用的相机索引。获取到可用的相机索引以后可以调用putCameraStreamSurface显示特定相机的码流。

      参数

      名称类型说明
      listener@NonNull AvailableCameraUpdatedListener 可用相机监听器
      method

      removeAvailableCameraUpdatedListener

      Since MSDK 5.8.0
      void removeAvailableCameraUpdatedListener(@NonNull AvailableCameraUpdatedListener listener)

      移除可用相机监听器。

      参数

      名称类型说明
      listener@NonNull AvailableCameraUpdatedListener 可用相机监听器
      method

      putCameraStreamSurface

      Since MSDK 5.8.0
      void putCameraStreamSurface(@NonNull ComponentIndexType cameraIndex,
      @NonNull Surface surface,
      int surfaceWidth,
      int surfaceHeight,
      @NonNull ScaleType scaleType)

      将相机码流的画面显示到特定的的surface中,单个surface只能显示一个相机的码流画面。如果针对同一个surface多次调用此接口,将进行该surface的参数更新,比如更新相机索引,surface的宽高和缩放类型。

      注意

      如果你希望显示不同相机镜头的画面,你可以调用KeyCameraVideoStreamSource进行相机镜头切换。

      参数

      名称类型说明
      cameraIndex@NonNull ComponentIndexType 设置需要进行码流显示的相机索引。
      surface@NonNull Surface 设置需要进行码流显示的surface。支持SurfaceView、TextureView和MediaCodeC的surface,不支持GLSurfaceView的surface以及任何和OpenGL绑定的surface。
      surfaceWidthint 设置需要进行码流显示的surface宽度。
      surfaceHeightint 设置需要进行码流显示的surface高度。
      scaleType@NonNull ScaleType 设置需要进行码流显示的surface的缩放类型。
      method

      removeCameraStreamSurface

      Since MSDK 5.8.0
      void removeCameraStreamSurface(@NonNull Surface surface)

      移除已经添加的surface,当你不再需要使用该surface的时候,请调用此接口移除已经添加的surface,否则会导致内存泄漏。移除后该surface将不再显示相机画面。

      参数

      名称类型说明
      surface@NonNull Surface 设置需要移除的Surface。
      method

      addReceiveStreamListener

      Since MSDK 5.8.0
      void addReceiveStreamListener(@NonNull ComponentIndexType cameraIndex, @NonNull ReceiveStreamListener listener)

      添加码流数据监听器。通过此监听器可以接收指定相机的码流数据。你可以使用此码流数据自行解码显示或者实现第三方直播等功能。

      参数

      名称类型说明
      cameraIndex@NonNull ComponentIndexType 设置需要监听的相机索引。
      listener@NonNull ReceiveStreamListener 码流数据监听器
      method

      removeReceiveStreamListener

      Since MSDK 5.8.0
      void removeReceiveStreamListener(@NonNull ReceiveStreamListener listener)

      移除码流数据监听器。

      参数

      名称类型说明
      listener@NonNull ReceiveStreamListener 码流数据监听器
      method

      addFrameListener

      Since MSDK 5.8.0
      void addFrameListener(@NonNull ComponentIndexType cameraIndex,
      @NonNull FrameFormat format,
      @NonNull CameraFrameListener listener)

      添加帧数据监听器。通过此监听器可以监听指定相机解码后的帧数据,你可以使用帧数据实现AI识别等功能。

      参数

      名称类型说明
      cameraIndex@NonNull ComponentIndexType 设置需要监听的相机索引。
      format@NonNull FrameFormat 设置需要监听的帧格式。
      listener@NonNull CameraFrameListener 帧数据监听器
      method

      removeFrameListener

      Since MSDK 5.8.0
      void removeFrameListener(@NonNull CameraFrameListener listener)

      移除帧数据监听器。

      参数

      名称类型说明
      listener@NonNull CameraFrameListener 帧数据监听器
      method

      setKeepAliveDecoding

      Since MSDK 5.8.0
      void setKeepAliveDecoding(boolean isKeepALive)

      是否让解码器在后台持续解码,默认值为false。如果为false,当模块内部没有引用任何Surface、ReceiveStreamListener、CameraFrameListener的时候,解码器会暂停解码以降低后台性能/电量的消耗,但是这会增加首次推送相机码流数据的延迟。如果为true,那么解码器会持续在后台解码,这会增加性能/电量的消耗,但是可以降低首次推送相机码流数据的延迟。

      参数

      名称类型说明
      isKeepALiveboolean true表示解码器在后台持续解码。
      method

      getLiveViewLocationWithGPS

      Since MSDK 5.9.0
      @NonNull
      PinPointInfo getLiveViewLocationWithGPS(@NonNull LocationCoordinate3D pointPos, @NonNull ComponentIndexType type)

      获取GPS点的Pin点信息,用于在图传界面中显示GPS点的相对位置。

      参数

      名称类型说明
      pointPos@NonNull LocationCoordinate3D GPS位置,可以通过KeyLaserMeasureInformation的 getLocation3D接口获取位置,也可以通过地图获取位置。
      type@NonNull ComponentIndexType 设置当前码流显示的相机索引。

      返回值

      类型说明
      PinPointInfo返回Pin点信息。
      method

      enableVisionAssist

      Since MSDK 5.12.0
      void enableVisionAssist(boolean enabled, @Nullable CommonCallbacks.CompletionCallback callback)

      开启辅助影像功能。辅助影像功能开启后,飞行界面右下角会显示视觉传感器画面(Spotlight Pro、航线飞行、返航模式下不支持开启飞行辅助影像)。你可以调用setVisionAssistViewDirection切换辅助影像的方向。

      参数

      名称类型说明
      enabledboolean true表示开启辅助影像。
      callback@Nullable CommonCallbacks.CompletionCallback 返回执行结果的回调。
      method

      setVisionAssistViewDirection

      Since MSDK 5.12.0
      void setVisionAssistViewDirection(VisionAssistDirection direction, @Nullable CommonCallbacks.CompletionCallback callback)

      设置辅助影像方向。

      参数

      名称类型说明
      directionVisionAssistDirection 辅助影像方向。
      callback@Nullable CommonCallbacks.CompletionCallback 返回执行结果的回调。
      method

      addVisionAssistStatusListener

      Since MSDK 5.12.0
      void addVisionAssistStatusListener(@NonNull VisionAssistStatusListener listener)

      添加辅助影像状态监听器。通过此监听器可以获取辅助影像的开关状态,设置的辅助影像的方向以及支持的辅助影像方向范围等功能。

      参数

      名称类型说明
      listener@NonNull VisionAssistStatusListener 辅助影像状态监听器
      method

      removeVisionAssistStatusListener

      Since MSDK 5.12.0
      void removeVisionAssistStatusListener(@NonNull VisionAssistStatusListener listener)

      移除辅助影像状态监听器。

      参数

      名称类型说明
      listener@NonNull VisionAssistStatusListener 辅助影像状态监听器
      method

      setStreamEncoderBitrate

      Since MSDK 5.12.0
      void setStreamEncoderBitrate(ComponentIndexType cameraIndex, int bitrate)

      设置编码器的码率,单位:bit/s。

      参数

      名称类型说明
      cameraIndexComponentIndexType 相机索引。
      bitrateint 编码器的码率。
      method

      getStreamEncoderBitrate

      Since MSDK 5.12.0
      int getStreamEncoderBitrate(ComponentIndexType cameraIndex)

      获取编码器的码率。

      参数

      名称类型说明
      cameraIndexComponentIndexType 相机索引。

      返回值

      类型说明
      int返回对应相机索引的编码器码率。
      method

      setStreamPriority

      Since MSDK 5.15.0
      void setStreamPriority(ComponentIndexType cameraIndex, ChannelPriority priority)

      设置图传通道优先级。

      参数

      名称类型说明
      cameraIndexComponentIndexType 相机索引。
      priorityChannelPriority 图传通道优先级
      method

      getStreamPriority

      Since MSDK 5.15.0
      ChannelPriority getStreamPriority(ComponentIndexType cameraIndex)

      读取图传通道优先级。

      参数

      名称类型说明
      cameraIndexComponentIndexType 相机索引。

      返回值

      类型说明
      ChannelPriority返回图传通道优先级。
      method

      enableStream

      Since MSDK 5.15.0
      void enableStream(ComponentIndexType cameraIndex, boolean enable)

      开启/关闭图传。

      参数

      名称类型说明
      cameraIndexComponentIndexType 相机索引。
      enableboolean 开启/关闭图传。
      class

      AvailableCameraUpdatedListener

      Since MSDK 5.8.0
      interface AvailableCameraUpdatedListener

      可用相机监听器。

      class

      CameraFrameListener

      Since MSDK 5.8.0
      interface CameraFrameListener

      帧数据监听器。

      class

      ReceiveStreamListener

      Since MSDK 5.8.0
      interface ReceiveStreamListener

      码流数据监听器。

      class

      VisionAssistStatusListener

      Since MSDK 5.12.0
      interface VisionAssistStatusListener

      辅助影像监听器。

      enum

      VisionAssistDirection

      Since MSDK 5.12.0

      辅助影像模式。

      枚举成员

      名称说明
      OFF关闭。
      FRONT手动模式:前。
      LEFT手动模式:左。
      RIGHT手动模式:右。
      UP手动模式:上。
      DOWN手动模式:下。
      AUTO自动模式,相机将基于飞行方向自动切换视觉传感器画面。
      class

      StreamInfo

      Since MSDK 5.8.0
      class StreamInfo

      码流信息类,可获取码流的宽度,高度和帧率等信息。

      enum

      MimeType

      Since MSDK 5.8.0

      编解码的媒体类型,支持H264和H265。

      枚举成员

      名称说明
      H264H264
      H265H265
      enum

      ScaleType

      Since MSDK 5.8.0

      画面缩放类型。

      枚举成员

      名称说明
      FIX_XY拉伸铺满。
      CENTER_CROP裁剪适应铺满。
      CENTER_INSIDE缩放适应。
      enum

      FrameFormat

      Since MSDK 5.8.0

      帧数据格式。

      枚举成员

      名称说明
      YUV420_888YUV420_888
      YUV444_888YUV444_888
      YUY2YUV2
      NV21NV21
      RGBA_8888RGBA_8888
      class

      PinPointInfo

      Since MSDK 5.9.0
      class PinPointInfo

      Pin点信息类,可获取Pin点的位置和回调结果。

      class

      PinPoint

      Since MSDK 5.9.0
      class PinPoint

      Pin点在图传界面的位置,(0,0)是图传界面的左上角,(1,1)是图传界面的右下角。


      Members

      enum
      enum

      Result

      Pin点回调结果。

      枚举成员

      名称说明
      SUCCESS成功获取Pin点位置,Pin点在图传界面中。
      SUCCESS_BUT_OUT_OF_SCREEN成功获取Pin点位置,但该点不在图传界面中,应该显示在侧面,请参考DJI Pilot。
      FAILED获取Pin点位置失败。
      INVALID_DRONE_POSITION获取Pin点位置失败,因为无法获取飞行器位置。
      INVALID_POINT_POSITION获取Pin点位置失败,因为设置的GPS位置是无效的。
      GIMBAL_ATTI_ERROR获取Pin点位置失败,因为云台姿态是无效的。
      CAMEAR_ERROR获取Pin点位置失败,因为相机错误。