[m1] 添加M1拼接视频数据订阅接口、清扫车摄像头View和M1摄像头View共用

This commit is contained in:
xinfengkun
2023-05-09 15:33:08 +08:00
parent 9f47d1ed6b
commit bb22ec10d5
9 changed files with 102 additions and 15 deletions

View File

@@ -15,31 +15,34 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.mogo.eagle.core.function.api.autopilot.IMoGoRoboBusJinlvM1StitchedVideoListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoSweeperFutianBackCameraVideoListener;
import com.mogo.eagle.core.function.call.autopilot.CallerRoboBusJinlvM1StitchedVideoListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerSweeperFutianBackCameraVideoListenerManager;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
/**
* 清扫车摄像头展示View
* 清扫车摄像头展示View 10Hz
* M1拼接视频展示View 10Hz 需要订阅此数据CallerAutoPilotControlManager.setIsSubscribeM1StitchedVideo(isSubscribe)
*/
public class SweeperVideoView extends AppCompatImageView implements IMoGoSweeperFutianBackCameraVideoListener {
private static final String TAG = SweeperVideoView.class.getSimpleName();
public class MogoVideoView extends AppCompatImageView implements IMoGoSweeperFutianBackCameraVideoListener, IMoGoRoboBusJinlvM1StitchedVideoListener {
private static final String TAG = MogoVideoView.class.getSimpleName();
private final RequestOptions requestOptions = new RequestOptions()
.priority(Priority.HIGH)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.dontAnimate();
public SweeperVideoView(@NonNull Context context) {
public MogoVideoView(@NonNull Context context) {
super(context);
}
public SweeperVideoView(@NonNull Context context, @Nullable AttributeSet attrs) {
public MogoVideoView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public SweeperVideoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
public MogoVideoView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@@ -47,12 +50,14 @@ public class SweeperVideoView extends AppCompatImageView implements IMoGoSweeper
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerSweeperFutianBackCameraVideoListenerManager.INSTANCE.addListener(TAG, this);
CallerRoboBusJinlvM1StitchedVideoListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerSweeperFutianBackCameraVideoListenerManager.INSTANCE.removeListener(this);
CallerRoboBusJinlvM1StitchedVideoListenerManager.INSTANCE.removeListener(this);
}
private final CustomTarget<Bitmap> target = new CustomTarget<Bitmap>() {
@@ -60,7 +65,7 @@ public class SweeperVideoView extends AppCompatImageView implements IMoGoSweeper
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
//回调内容
if (!resource.isRecycled()) {
SweeperVideoView.this.setImageBitmap(resource);
MogoVideoView.this.setImageBitmap(resource);
}
}
@@ -70,18 +75,28 @@ public class SweeperVideoView extends AppCompatImageView implements IMoGoSweeper
}
};
@Override
public void onSweeperFutianBackCameraVideo(@NonNull byte[] data) {
private void draw(@NonNull byte[] data) {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
GlideApp.with(SweeperVideoView.this)
GlideApp.with(MogoVideoView.this)
.asBitmap()
.load(data)
.placeholder(SweeperVideoView.this.getDrawable())
.placeholder(MogoVideoView.this.getDrawable())
.apply(requestOptions)
.into(target);
}
});
}
@Override
public void onSweeperFutianBackCameraVideo(@NonNull byte[] data) {
draw(data);
}
@Override
public void onRoboBusJinlvM1StitchedVideo(@NonNull byte[] data) {
draw(data);
}
}