Committed by
GitHub
Add ability to attach VideoProcessor to capturers (#192)
正在显示
2 个修改的文件
包含
11 行增加
和
3 行删除
| @@ -71,6 +71,7 @@ internal constructor( | @@ -71,6 +71,7 @@ internal constructor( | ||
| 71 | name: String = "", | 71 | name: String = "", |
| 72 | capturer: VideoCapturer, | 72 | capturer: VideoCapturer, |
| 73 | options: LocalVideoTrackOptions = videoTrackCaptureDefaults.copy(), | 73 | options: LocalVideoTrackOptions = videoTrackCaptureDefaults.copy(), |
| 74 | + videoProcessor: VideoProcessor? = null, | ||
| 74 | ): LocalVideoTrack { | 75 | ): LocalVideoTrack { |
| 75 | return LocalVideoTrack.createTrack( | 76 | return LocalVideoTrack.createTrack( |
| 76 | peerConnectionFactory = peerConnectionFactory, | 77 | peerConnectionFactory = peerConnectionFactory, |
| @@ -80,6 +81,7 @@ internal constructor( | @@ -80,6 +81,7 @@ internal constructor( | ||
| 80 | options = options, | 81 | options = options, |
| 81 | rootEglBase = eglBase, | 82 | rootEglBase = eglBase, |
| 82 | trackFactory = videoTrackFactory, | 83 | trackFactory = videoTrackFactory, |
| 84 | + videoProcessor = videoProcessor, | ||
| 83 | ) | 85 | ) |
| 84 | } | 86 | } |
| 85 | 87 | ||
| @@ -91,6 +93,7 @@ internal constructor( | @@ -91,6 +93,7 @@ internal constructor( | ||
| 91 | fun createVideoTrack( | 93 | fun createVideoTrack( |
| 92 | name: String = "", | 94 | name: String = "", |
| 93 | options: LocalVideoTrackOptions = videoTrackCaptureDefaults.copy(), | 95 | options: LocalVideoTrackOptions = videoTrackCaptureDefaults.copy(), |
| 96 | + videoProcessor: VideoProcessor? = null, | ||
| 94 | ): LocalVideoTrack { | 97 | ): LocalVideoTrack { |
| 95 | return LocalVideoTrack.createTrack( | 98 | return LocalVideoTrack.createTrack( |
| 96 | peerConnectionFactory, | 99 | peerConnectionFactory, |
| @@ -99,6 +102,7 @@ internal constructor( | @@ -99,6 +102,7 @@ internal constructor( | ||
| 99 | options, | 102 | options, |
| 100 | eglBase, | 103 | eglBase, |
| 101 | videoTrackFactory, | 104 | videoTrackFactory, |
| 105 | + videoProcessor = videoProcessor, | ||
| 102 | ) | 106 | ) |
| 103 | } | 107 | } |
| 104 | 108 |
| @@ -199,11 +199,12 @@ constructor( | @@ -199,11 +199,12 @@ constructor( | ||
| 199 | name: String, | 199 | name: String, |
| 200 | capturer: VideoCapturer, | 200 | capturer: VideoCapturer, |
| 201 | options: LocalVideoTrackOptions = LocalVideoTrackOptions(), | 201 | options: LocalVideoTrackOptions = LocalVideoTrackOptions(), |
| 202 | - | ||
| 203 | rootEglBase: EglBase, | 202 | rootEglBase: EglBase, |
| 204 | - trackFactory: Factory | 203 | + trackFactory: Factory, |
| 204 | + videoProcessor: VideoProcessor? = null, | ||
| 205 | ): LocalVideoTrack { | 205 | ): LocalVideoTrack { |
| 206 | val source = peerConnectionFactory.createVideoSource(false) | 206 | val source = peerConnectionFactory.createVideoSource(false) |
| 207 | + source.setVideoProcessor(videoProcessor) | ||
| 207 | val surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureThread", rootEglBase.eglBaseContext) | 208 | val surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureThread", rootEglBase.eglBaseContext) |
| 208 | capturer.initialize( | 209 | capturer.initialize( |
| 209 | surfaceTextureHelper, | 210 | surfaceTextureHelper, |
| @@ -226,13 +227,15 @@ constructor( | @@ -226,13 +227,15 @@ constructor( | ||
| 226 | ) | 227 | ) |
| 227 | return track | 228 | return track |
| 228 | } | 229 | } |
| 230 | + | ||
| 229 | internal fun createTrack( | 231 | internal fun createTrack( |
| 230 | peerConnectionFactory: PeerConnectionFactory, | 232 | peerConnectionFactory: PeerConnectionFactory, |
| 231 | context: Context, | 233 | context: Context, |
| 232 | name: String, | 234 | name: String, |
| 233 | options: LocalVideoTrackOptions, | 235 | options: LocalVideoTrackOptions, |
| 234 | rootEglBase: EglBase, | 236 | rootEglBase: EglBase, |
| 235 | - trackFactory: Factory | 237 | + trackFactory: Factory, |
| 238 | + videoProcessor: VideoProcessor? = null, | ||
| 236 | ): LocalVideoTrack { | 239 | ): LocalVideoTrack { |
| 237 | 240 | ||
| 238 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != | 241 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != |
| @@ -242,6 +245,7 @@ constructor( | @@ -242,6 +245,7 @@ constructor( | ||
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | val source = peerConnectionFactory.createVideoSource(options.isScreencast) | 247 | val source = peerConnectionFactory.createVideoSource(options.isScreencast) |
| 248 | + source.setVideoProcessor(videoProcessor) | ||
| 245 | val (capturer, newOptions) = createVideoCapturer(context, options) ?: TODO() | 249 | val (capturer, newOptions) = createVideoCapturer(context, options) ?: TODO() |
| 246 | val surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureThread", rootEglBase.eglBaseContext) | 250 | val surfaceTextureHelper = SurfaceTextureHelper.create("VideoCaptureThread", rootEglBase.eglBaseContext) |
| 247 | capturer.initialize( | 251 | capturer.initialize( |
-
请 注册 或 登录 后发表评论