正在显示
1 个修改的文件
包含
30 行增加
和
10 行删除
| @@ -4,12 +4,12 @@ import android.content.Context | @@ -4,12 +4,12 @@ import android.content.Context | ||
| 4 | import com.github.ajalt.timberkt.Timber | 4 | import com.github.ajalt.timberkt.Timber |
| 5 | import dagger.Module | 5 | import dagger.Module |
| 6 | import dagger.Provides | 6 | import dagger.Provides |
| 7 | -import org.webrtc.EglBase | ||
| 8 | -import org.webrtc.PeerConnectionFactory | 7 | +import org.webrtc.* |
| 9 | import org.webrtc.audio.AudioDeviceModule | 8 | import org.webrtc.audio.AudioDeviceModule |
| 10 | import org.webrtc.audio.JavaAudioDeviceModule | 9 | import org.webrtc.audio.JavaAudioDeviceModule |
| 11 | import javax.inject.Singleton | 10 | import javax.inject.Singleton |
| 12 | 11 | ||
| 12 | + | ||
| 13 | @Module | 13 | @Module |
| 14 | class RTCModule { | 14 | class RTCModule { |
| 15 | companion object { | 15 | companion object { |
| @@ -87,25 +87,45 @@ class RTCModule { | @@ -87,25 +87,45 @@ class RTCModule { | ||
| 87 | 87 | ||
| 88 | @Provides | 88 | @Provides |
| 89 | @Singleton | 89 | @Singleton |
| 90 | + fun eglBase(): EglBase { | ||
| 91 | + return EglBase.create() | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @Provides | ||
| 95 | + fun eglContext(eglBase: EglBase): EglBase.Context = eglBase.eglBaseContext | ||
| 96 | + | ||
| 97 | + @Provides | ||
| 98 | + fun videoEncoderFactory(eglContext: EglBase.Context): VideoEncoderFactory = | ||
| 99 | + DefaultVideoEncoderFactory( | ||
| 100 | + eglContext, | ||
| 101 | + true, | ||
| 102 | + true | ||
| 103 | + ) | ||
| 104 | + | ||
| 105 | + @Provides | ||
| 106 | + fun videoDecoderFactory(eglContext: EglBase.Context): VideoDecoderFactory = | ||
| 107 | + DefaultVideoDecoderFactory(eglContext) | ||
| 108 | + | ||
| 109 | + @Provides | ||
| 110 | + @Singleton | ||
| 90 | fun peerConnectionFactory( | 111 | fun peerConnectionFactory( |
| 91 | appContext: Context, | 112 | appContext: Context, |
| 92 | - audioDeviceModule: AudioDeviceModule | 113 | + audioDeviceModule: AudioDeviceModule, |
| 114 | + videoEncoderFactory: VideoEncoderFactory, | ||
| 115 | + videoDecoderFactory: VideoDecoderFactory, | ||
| 93 | ): PeerConnectionFactory { | 116 | ): PeerConnectionFactory { |
| 94 | PeerConnectionFactory.initialize( | 117 | PeerConnectionFactory.initialize( |
| 95 | - PeerConnectionFactory.InitializationOptions.builder(appContext) | 118 | + PeerConnectionFactory.InitializationOptions |
| 119 | + .builder(appContext) | ||
| 96 | .createInitializationOptions() | 120 | .createInitializationOptions() |
| 97 | ) | 121 | ) |
| 98 | 122 | ||
| 99 | return PeerConnectionFactory.builder() | 123 | return PeerConnectionFactory.builder() |
| 100 | .setAudioDeviceModule(audioDeviceModule) | 124 | .setAudioDeviceModule(audioDeviceModule) |
| 125 | + .setVideoEncoderFactory(videoEncoderFactory) | ||
| 126 | + .setVideoDecoderFactory(videoDecoderFactory) | ||
| 101 | .createPeerConnectionFactory() | 127 | .createPeerConnectionFactory() |
| 102 | } | 128 | } |
| 103 | 129 | ||
| 104 | - | ||
| 105 | - @Provides | ||
| 106 | - @Singleton | ||
| 107 | - fun eglBase(): EglBase { | ||
| 108 | - return EglBase.create() | ||
| 109 | - } | ||
| 110 | } | 130 | } |
| 111 | } | 131 | } |
-
请 注册 或 登录 后发表评论