通过断点,查看发送数据流程如下
image.png
进一步的入口是
MyRecorder.java
public void startSwapData() {
mEncoderHandler.post(swapDataRunnable);
}
由RenderSrfTex来调用,这个类是什么??
这个类由MyRenderer来调用
public void setRecorder(MyRecorder recorder) {
synchronized(this) {
if (recorder != null) {
mRenderSrfTex = new RenderSrfTex(mEffectTextureId, recorder);
mRenderSrfTex.setVideoSize(mVideoWidth, mVideoHeight);
if(mWatermark != null) {
mRenderSrfTex.setWatermark(mWatermark);
}
} else {
mRenderSrfTex = null;
}
}
}
这个又由 CameraVideoController来调用,这个start方法应该就是直播开始的方法了。
public void start() {
if(mListener == null) {
return;
}
SopCastLog.d(SopCastConstant.TAG, "Start video recording");
mRecorder = new MyRecorder(mVideoConfiguration);
mRecorder.setVideoEncodeListener(mListener);
mRecorder.prepareEncoder();
mRenderer.setRecorder(mRecorder);
}
这个Controller是在CameraLivingView中初始化的。
private void initView() {
CameraVideoController videoController = new CameraVideoController(mRenderer);
NormalAudioController audioController = new NormalAudioController();
mStreamController = new StreamController(videoController, audioController);
mRenderer.setCameraOpenListener(mCameraOpenListener);
}
这个View直接放在布局里面的
<com.laifeng.sopcastsdk.ui.CameraLivingView
android:id="@+id/liveView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
总的Activity的入口是LandscapeActivity
点击开始后的动作是
mRtmpSender.setAddress(uploadUrl);
mProgressConnecting.setVisibility(View.VISIBLE);
Toast.makeText(LandscapeActivity.this, "start connecting", Toast.LENGTH_SHORT).show();
mRecordBtn.setBackgroundResource(R.mipmap.ic_record_stop);
mRtmpSender.connect();
isRecording = true;
网友评论