|
40 | 40 | *
|
41 | 41 | * 本文件展示了如何使用TRTC SDK实现视频文件直播分享功能,主要流程如下:
|
42 | 42 | * - 读取视频文件、对视频文件进行解封装 --> 解码;
|
43 |
| - * - 将解码后的音视频帧通过TRTC的自定义采集接口{@link TRTCCloud#sendCustomAudioData(TRTCCloudDef.TRTCAudioFrame)} 和{@link TRTCCloud#sendCustomVideoData(TRTCCloudDef.TRTCVideoFrame)}发送给TRTC SDK; |
44 |
| - * - 通过{@link TRTCCloud#setLocalVideoRenderListener(int, int, TRTCCloudListener.TRTCVideoRenderListener)}获取处理后的本地视频帧并渲染到屏幕上; |
45 |
| - * - 通过{@link TRTCCloud#setAudioFrameListener(TRTCCloudListener.TRTCAudioFrameListener)} )}获取处理后的音频帧并进行播放; |
46 |
| - * - 如果有远端主播,可以通过{@link TRTCCloud#setRemoteVideoRenderListener(String, int, int, TRTCCloudListener.TRTCVideoRenderListener)} 获取远端主播的视频帧并渲染到屏幕上,远端主播的音频会在上一步自动混音后播放; |
| 43 | + * - 将解码后的音视频帧通过TRTC的自定义采集接口{@link com.tencent.trtc.TRTCCloud#sendCustomAudioData(com.tencent.trtc.TRTCCloudDef.TRTCAudioFrame)} 和{@link com.tencent.trtc.TRTCCloud#sendCustomVideoData(int, com.tencent.trtc.TRTCCloudDef.TRTCVideoFrame)}发送给TRTC SDK; |
| 44 | + * - 通过{@link com.tencent.trtc.TRTCCloud#setLocalVideoRenderListener(int, int, com.tencent.trtc.TRTCCloudListener.TRTCVideoRenderListener)}获取处理后的本地视频帧并渲染到屏幕上; |
| 45 | + * - 通过{@link com.tencent.trtc.TRTCCloud#setAudioFrameListener(com.tencent.trtc.TRTCCloudListener.TRTCAudioFrameListener)} )}获取处理后的音频帧并进行播放; |
| 46 | + * - 如果有远端主播,可以通过{@link com.tencent.trtc.TRTCCloud#setRemoteVideoRenderListener(String, int, int, com.tencent.trtc.TRTCCloudListener.TRTCVideoRenderListener)} 获取远端主播的视频帧并渲染到屏幕上,远端主播的音频会在上一步自动混音后播放; |
47 | 47 | *
|
48 | 48 | * - 更多细节,详见API说明文档{https://liteav.sdk.qcloud.com/doc/api/zh-cn/group__TRTCCloud__android.html}
|
49 | 49 | */
|
|
53 | 53 | *
|
54 | 54 | * This document shows how to share a video file during live streaming. The steps are detailed below:
|
55 | 55 | * - Read and de-encapsulate the video file --> decode
|
56 |
| - * - Call the SDK’s custom audio and video capturing APIs {@link TRTCCloud#sendCustomAudioData(TRTCCloudDef.TRTCAudioFrame)} and {@link TRTCCloud#sendCustomVideoData(TRTCCloudDef.TRTCVideoFrame)} to send the decoded audio and video frames to the SDK. |
57 |
| - * - Call {@link TRTCCloud#setLocalVideoRenderListener(int, int, TRTCCloudListener.TRTCVideoRenderListener)} to get the processed local video frames and render them to the screen. |
58 |
| - * - Call {@link TRTCCloud#setAudioFrameListener(TRTCCloudListener.TRTCAudioFrameListener)} )} to get and play the processed audio frames. |
59 |
| - * - If there is a remote anchor, call {@link TRTCCloud#setRemoteVideoRenderListener(String, int, int, TRTCCloudListener.TRTCVideoRenderListener)} to get the anchor’s video frames and render them to the screen. The audio of the anchor is automatically mixed and played in the previous step. |
| 56 | + * - Call the SDK’s custom audio and video capturing APIs {@link com.tencent.trtc.TRTCCloud#sendCustomAudioData(com.tencent.trtc.TRTCCloudDef.TRTCAudioFrame)} and {@link com.tencent.trtc.TRTCCloud#sendCustomVideoData(int, com.tencent.trtc.TRTCCloudDef.TRTCVideoFrame)} to send the decoded audio and video frames to the SDK. |
| 57 | + * - Call {@link com.tencent.trtc.TRTCCloud#setLocalVideoRenderListener(int, int, com.tencent.trtc.TRTCCloudListener.TRTCVideoRenderListener)} to get the processed local video frames and render them to the screen. |
| 58 | + * - Call {@link com.tencent.trtc.TRTCCloud#setAudioFrameListener(com.tencent.trtc.TRTCCloudListener.TRTCAudioFrameListener)} )} to get and play the processed audio frames. |
| 59 | + * - If there is a remote anchor, call {@link com.tencent.trtc.TRTCCloud#setRemoteVideoRenderListener(String, int, int, com.tencent.trtc.TRTCCloudListener.TRTCVideoRenderListener)} to get the anchor’s video frames and render them to the screen. The audio of the anchor is automatically mixed and played in the previous step. |
60 | 60 | *
|
61 | 61 | * - For more information, please see the API document {https://liteav.sdk.qcloud.com/doc/api/zh-cn/group__TRTCCloud__android.html}.
|
62 | 62 | */
|
@@ -111,7 +111,7 @@ public void onFrameAvailable(EGLContext eglContext, int textureId, int width, in
|
111 | 111 | videoFrame.pixelFormat = TRTCCloudDef.TRTC_VIDEO_PIXEL_FORMAT_Texture_2D;
|
112 | 112 | videoFrame.bufferType = TRTCCloudDef.TRTC_VIDEO_BUFFER_TYPE_TEXTURE;
|
113 | 113 |
|
114 |
| - mTRTCCloud.sendCustomVideoData(videoFrame); |
| 114 | + mTRTCCloud.sendCustomVideoData(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, videoFrame); |
115 | 115 | }
|
116 | 116 | };
|
117 | 117 |
|
@@ -171,7 +171,7 @@ private void enterRoom(String roomId, String userId) {
|
171 | 171 | mTRTCParams.role = TRTCCloudDef.TRTCRoleAnchor;
|
172 | 172 | mTRTCCloud.enterRoom(mTRTCParams, TRTCCloudDef.TRTC_APP_SCENE_LIVE);
|
173 | 173 |
|
174 |
| - mTRTCCloud.enableCustomVideoCapture(true); |
| 174 | + mTRTCCloud.enableCustomVideoCapture(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG, true); |
175 | 175 | mTRTCCloud.enableCustomAudioCapture(true);
|
176 | 176 | mMediaFileSyncReader.start(mAudioFrameReadListener, mVideoFrameReadListener);
|
177 | 177 |
|
|
0 commit comments