niagara中camera driver的工作原理

首先从类BVideoStreamBinding看起,help文档里描述“Instances of this class serve as the glue between a BVideoPlayer widget and a driver's BIVideoCamera component.”

从started一路往下看到initiateStream,里面有两处注意:1,resolveFresh;2, this.videoStream = this.videoPlaybackSession.establishVideoStream(this.videoSource, this.playbackParams, this.videoDecoder, this)。

resolveFresh里解析各种相关资源,包括videoPlayer, videoSource, videoPlaybackSession和videoDecoder等。

VideoPlaybackSession:

establishVideoStream里赋值IVideoDecoder,最重要的是Thread.start(),用jadx反编译看到的是一个匿名内部类,run方法反编译错误,但是可以看到这一句BIVideoSource.streamToDestination(...),BDdfVideoCamera实现了该接口。 streamToDestination ( BPlaybackParams , IVideoDestination ) 这里的IVideoDestination实际传入的就是this(VideoPlaybackSession)。

DdfVideoStreamUtil:

BIVideoSource.streamToDestination(...)里调用了DdfVideoStreamUtil的streamToDestinatio(...):获得BIDdfVideoStreamRequest(就是你在getVideoStreamRequestType里指定的类型,一般是BDdfRtspStreamRequest的子类),在新线程中调用BIDdfVideoStreamRequest.makeVideoStream(),将返回的IVideoStream传入IVideoDestination.receiveVideoStream(IVideoStream)。

VideoPlaybackSession->IVideoDecoder(继承IVideoDestination):

VideoPlaybackSession的receiveVideoStream(IVideoStream)里调用了IVideoDecoder.receiveVideoStream(IVideoStream),IVideoDecoder就是你在makeVideoDecoder里指定的类型。抽象类VideoDecoder实现了receiveVideoStream。

VideoDecoder:

这里只简单的贴出代码,都很好理解了。


后记:我是在niagara3.7下开发,在3.8上运行,结果出现“java.lang.NoSuchFieldError”。原因是类VidFrame的成员变量rawData的类型在3.7里是javax.baja.io.ByteBuffer,但在3.8里变成了javax.baja.nre.util.ByteBuffer。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值