thunder
2021-05-10 16:48:12 3 举报
thunder + yyvideolib
作者其他创作
大纲/内容
VideoEncoderGroupFilter
AudioEngine
LiveEngineEventCallBacker->onTransEvent
openCamera之后notifyCameraPreviewParameter
ThunderEngine加载了4个sothunderyydec265ffmpeg-neonc++_shared
4、打开本地视频推送stopLocalVideoStream(false)
VideoLiveFilterContext
+ VideoEncoderConfig+ GlManager+ WaterMark 不放在滤镜,是说因为YYMediSample可能会被存储成中间数据,体现不了实时性质。+ Surface的管理+ 弱网/低码流策略管理
ThunderNative.getAbroadNetWorkStrategy()转ArgoConfig
startEncodeVideo
LiveEngineEventCallBacker.onTransServiceStreamsNotify
2、YMFLiveAPI的startPreview// 设定view之后意味着模式全部选定了setPreviewRenderMode(renderMode); 注意这个设置是对整个YMFLivemCameraSurfaceView = view; 缓存预览viewmVideoLiveSessionYCloud.setPreviewSurfaceView(view); 设置holder callback之后,三大回调统一由onSurfaceInfoEvent处理。
notifyCameraPreviewParameter触发startPreview
更新全局变量m_videoPublishCfg
2、YYLiveNative::instance().init
TransEngine
updatePublisherConfig 更新YMFLive的VideoPublisheParam
是否启动海外弱网逻辑YMFLiveAPI.setAbroadNetWorkStrategy 开启采集YMFLiveAPI.startEncodeVideo
2、addBroadcastRoomId
1、YMFLiveAPI的startVideoCapture1、默认CaptureType.CAMERA,初始化 initVideoLiveSession,有很多下层回调 和 上层接口,详情查看VideoLiveSessionYCloud。2、YYCamera.getInstance().startPreview(但此时没有预览view)只是初始化打开YYCamera。然后通过setCameraListener注入VideoLiveSessionYCloud进行通信。3、LiveSessionYCloud.配置预览参数
RtcEngineManager可理解为ThunderEngine的wrapper+FaceDemoManager美颜贴图相关
3、startLocalVideoPreview转 startPreview
updateVideoRtcEncoderInfo(LIVE_VIDEO_STREAM_TYPE_HIGH)
4、LiveEngine::instance()->initSDK3、LiveEngine::createLiveEngine();
1、CameraPreviewCallbackHost.setPreviewCallbackWithBuffer触发YYCamera.setPreviewCallbackWithBuffer(this)实现android.camera.onPreviewFrame,所以CameraPreviewCallbackHost接受android摄像头第一手的预览数据2、CameraCaptureFilter mCaptureFilter.init();3、span style=\"font-size: inherit;\
2、enableLocalVideoCapture转startVideoCapture
1、joinRoom
sendUserJoinRoom / sendQueryRoomUser进房间成功后才发送上线通知和查询在线用户
YMFLiveAPI.startVideoCapture通过LiveEngineEventCallBacker回调
LiveEngine
startVideoCapture(deviceId)
如果当是编码格式是h265,而且YMFLiveAPI.getSupportH265EncodeProperty()不支持,则需要显式改为H264
1、ThunderNative.init
startVideoEncode
YYVideoEngine
(这里我关心VideoEncoderGroupFilter优先分析)
3、YMFLiveAPI的startEncodeVideo基本都是在操作mVideoLiveSessionYCloud,YMFLiveAPI实现IEncoderListener,接受VideoLiveSessionYCloud的回调。mVideoLiveSessionYCloud.startEncoder 启动编码注意setResolutionModifyConfigs和setAbroadNetWorkStrategy两个策略配置
LiveEngineEventCallBacker
+ XThread :: onThreadRun+ ITransEngineCallBack+ ILiveEngineAudioEngineCallBack+ ILiveEngineVideoEngineCallBack
setLocalVideoCanvas
updateVideoPublisherConfig
先判断pView的类型checkViewType,因为拉取配置的原因,可能导致初始化view类型不对。YMFLiveAPI.startPreview
sendLiveEngineEvent
CameraInterface
+ 内置Handler+Thread。
VideoLiveSessionYCloud视频SDK总入口,初始化摄像头采集、预处理、本地预览、编码和裁剪模块
+ VideoLiveFilterContext+ 各种功能filter组成的调用链,会通过VideoLiveFilterContext添加到GLManager+ CameraSurfaceView & HolderCallback+ CameraPreviewCallbackHost+
checkPublishVideoConfigAvailable
VideoLiveSessionYCloud构造函数,构造出Filter调用链,关键功能的那几个加粗了
4、checkAllSubscribe
setVideoPreviewStartStatus
YYLiveNative
可理解为ThunderNative在Jni层的对象封装,YLEProcess的执行实体ThunderNative的各种方法实现
经过createEngine / joinRoom后 updatePublisherConfig / startVideoCapture / startPreview / startEncodeVideo都是直接操作yyvideolib开播库
YYCamera.getInstance()
开启SDK的摄像头操作封装在此类中,实现了预览采集等功能.。此类没有做到线程安全,需要在CameraInterface线程中操作。+CameraInterface (Runnable)所有功能函数全都在这里实现。
MediaManager = RtcEngineManager + YMFLiveAPI
ThunderNative
根据用户的选择选出对应的视频流进行订阅selectSubscribeNotifyStreams
+ ThunderNative.NotificationDispatcher 通过handler把信令消息和一些指令类消息回传给上层+ YLEBase 通过ByteBuffer,封装 即将传入到Native层的 各种功能协议。由YLEProcess执行功能+ YLEProcess(YYLiveSdkProcess)YLEBase的功能执行实体,即YYLiveSdkProcess.jni传入native层
ArgoServiceManager
1.1 sendToken
onRoomStreamsNotifyonTrandingStreamsNotifyonSubscribeStreamsNotify
6、sendSubscribeStream
1、setLocalVideoCanvasThunderVideoCanvas包装一个ThunderPreviewView
0、YMFLiveAPI的updatePublisherConfigthunder层的enableLocalVideoCapture触发YMFLiveAPI的updatePublisherConfig,函数内主要处理mUploadParams (VideoPublisheParam) 订阅上传的视频配置参数:1、通过YMFCustomVideoUtil.getEncodedVideoConfig 限制 档位比小流的档位还低,不需要配置小流和弱网;1.1、弱网和低码流的那堆相关配置都是通过调用setCustomVideoConfig设置的,对应thunder层的 YYVideoEngine::updateVideoEncoderConfig<- LiveEngine::updateCustomVideoEncoderConfig<-ArgoConfigHandler::onCustomVideoConfig 也就是ThunderEngine.Init的时候访问Argo获取的配置回调下发过来的。1.2、弱网监控的触发流程是LiveEngineEventCallBacker::onTransVideoDynamicBitrate -> LiveEngine::onTransVideoDynamicBitrate -> YYVideoEngine::onDynamicBitrate -> YYLiveAPI.setNetworkBitrateSuggest2、disassembleUploadParams:拆分所有的开播参数,判断是否要更新采集/编码参数。把mUploadParams (VideoPublisheParam) 拆分成 CameraPreviewConfig + VideoEncoderConfig3、mNeedRestartEncoderFlag {对应操作三大Session主要还是关闭编码器,重设编码参数,还有弱网配置,低码流配置等,重新打开编码流程;修改统一回调YMFStreamSyncSourceManager.getInstance().changeVideoConfig();}mNeedRestartCaptureFlag {YYCamera.getInstance().changePreviewParameter()YMFStreamSyncSourceManager.getInstance().changeVideoConfig();}mNeedLowDelayChangeFlag {// 切换低延时不需要停播再开播设置三大Session的setLowStreamEncoderConfigs / setLowDelayMode}
onSubscribeStreamsNotify
updateAppCfgByVideoPublish
YMFLiveAPI 类接口组成部分
VideoPublisheParam:mUploadParamsCameraPreviewConfig:mCameraPreviewConfigVideoEncoderConfig:mVideoEncoderConfigYMFCustomVideoUtil {int mLowStreamInitWidthint mLowStreamInitHeightint mLowStreamInitFpsint mLowStreamInitBitrateString mSoftEncodeParamsString mHardEncodeParamsString mWeakNetSoftEncodeParamsString mWeakNetHardEncodeParamsList<NetWorkCfg> mInitQualityConfigs List<NetWorkCfg> mInitSmoothlyConfigs}编码源是CameraStream用VideoLiveSessionYCloud 编码源是ScreenStream用ScreenLiveSessionYCloud编码源是OriginStream用YMFExternalTextureSessionYCloud
LiveServiceChannel
Thunder.java
LivePublisher
setVideoCaptureStartStatus
5、resetAudioEngine
m_javaPlayObject关联com/thunder/livesdk/video/ThunderVideoPlayEngineImp.java,交叉调用java的方法m_javaPubObject关联com/thunder/livesdk/video/ThunderVideoPublishEngineImp.java,交叉调用java的方法
ThunderBlot.Demo
3、queryRoomStreams
LiveEngine是个各功能汇聚综合体,主要包含以下核心功能类
+ VideoEngine -> YYVideoEngine+ AudioEngine+ TransEngine+ ArgoServiceManager+ LiveServiceChannel+ pCallBacker = new LiveEngineEventCallBacker(this);+ pPublisher = new LivePublisher(this);+ pSubscriber = new LiveSubscriber(this);+ pTranscodingCfg = new LiveTranscodingCfg(this);+ pSmartDnsProxy = new LiveEngineSmartDns;+ pBehavior = new LiveEngineBehavior;+ pOnlineUser = new LiveOnlineUser(this);在LiveEngine::initSDK,ArgoService会根据appid,uid,系统型号等信息,到后台拉取配置,主要是视频编码、弱网配置、传输等配置信息。然后LiveEngineEventCallBacker是一个XThread,监控着其中几个关键部分的回调和消息发送( onTransEvent / sendLiveEngineEvent / )
LiveSubscriber
0 条评论
下一页