├── .editorconfig ├── .gitattributes ├── .github ├── CODEOWNERS ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── android.yml │ ├── publish-snapshot.yml │ ├── publish.yml │ └── release-docs.yaml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle.kts └── src │ ├── main │ ├── AndroidManifest.xml │ ├── baseline-prof.txt │ ├── kotlin │ │ └── io │ │ │ └── getstream │ │ │ └── webrtc │ │ │ └── sample │ │ │ └── compose │ │ │ ├── MainActivity.kt │ │ │ ├── WebRTCApp.kt │ │ │ ├── ui │ │ │ ├── components │ │ │ │ └── VideoRenderer.kt │ │ │ ├── screens │ │ │ │ ├── stage │ │ │ │ │ └── StageScreen.kt │ │ │ │ └── video │ │ │ │ │ ├── CallMediaState.kt │ │ │ │ │ ├── VideoCallControlAction.kt │ │ │ │ │ ├── VideoCallControls.kt │ │ │ │ │ └── VideoCallScreen.kt │ │ │ └── theme │ │ │ │ ├── Color.kt │ │ │ │ ├── Shape.kt │ │ │ │ ├── Theme.kt │ │ │ │ └── Type.kt │ │ │ └── webrtc │ │ │ ├── SignalingClient.kt │ │ │ ├── audio │ │ │ ├── AudioDevice.kt │ │ │ ├── AudioDeviceChangeListener.kt │ │ │ ├── AudioFocusRequestWrapper.kt │ │ │ ├── AudioHandler.kt │ │ │ ├── AudioManagerAdapter.kt │ │ │ ├── AudioManagerAdapterImpl.kt │ │ │ └── AudioSwitch.kt │ │ │ ├── peer │ │ │ ├── StreamPeerConnection.kt │ │ │ ├── StreamPeerConnectionFactory.kt │ │ │ └── StreamPeerType.kt │ │ │ ├── sessions │ │ │ ├── WebRtcSessionManager.kt │ │ │ └── WebRtcSessionManagerImpl.kt │ │ │ └── utils │ │ │ └── Stringify.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_call_end.xml │ │ ├── ic_camera_flip.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_launcher_foreground.xml │ │ ├── ic_mic_off.xml │ │ ├── ic_mic_on.xml │ │ ├── ic_videocam_off.xml │ │ └── ic_videocam_on.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-anydpi-v33 │ │ └── ic_launcher.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── release │ └── generated │ └── baselineProfiles │ ├── baseline-prof.txt │ └── startup-prof.txt ├── bash └── baseline-profile-amender.sh ├── benchmark ├── .gitignore ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── io │ └── getstream │ └── webrtc │ └── android │ └── benchmark │ ├── BaselineProfileGenerator.kt │ └── Utils.kt ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ └── io │ └── getstream │ └── Configurations.kt ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── scripts ├── publish-module.gradle └── publish-root.gradle ├── settings.gradle.kts ├── spotless ├── copyright.kt ├── copyright.kts └── copyright.xml ├── stream-webrtc-android-bom ├── api │ └── stream-webrtc-android-bom.api └── build.gradle.kts ├── stream-webrtc-android-compose ├── .gitignore ├── api │ └── stream-webrtc-android-compose.api ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ ├── baseline-prof.txt │ └── kotlin │ └── io │ └── getstream │ └── webrtc │ └── android │ └── compose │ ├── FloatingVideoRenderer.kt │ ├── VideoRenderer.kt │ └── VideoScalingType.kt ├── stream-webrtc-android-ktx ├── .gitignore ├── api │ └── stream-webrtc-android-ktx.api ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ ├── baseline-prof.txt │ └── kotlin │ └── io │ └── getstream │ └── webrtc │ └── android │ └── ktx │ ├── PeerConnectionExtensions.kt │ ├── SDPExtensions.kt │ └── Stringify.kt ├── stream-webrtc-android-ui ├── .gitignore ├── api │ └── stream-webrtc-android-ui.api ├── build.gradle.kts └── src │ └── main │ ├── AndroidManifest.xml │ ├── baseline-prof.txt │ └── kotlin │ └── io │ └── getstream │ └── webrtc │ └── android │ └── ui │ └── VideoTextureViewRenderer.kt ├── stream-webrtc-android-utils ├── ContextUtils.java ├── LibaomAv1Decoder.java ├── Loggable.java ├── Logging.java ├── NetworkPreference.java ├── Priority.java ├── Size.java ├── ThreadUtils.java ├── VideoFrameBufferType.java └── WebRTCException.kt ├── stream-webrtc-android ├── .gitignore ├── api │ └── stream-webrtc-android.api ├── build.gradle.kts ├── consumer-rules.pro ├── libs │ ├── arm64-v8a │ │ └── libjingle_peerconnection_so.so │ ├── armeabi-v7a │ │ └── libjingle_peerconnection_so.so │ ├── x86 │ │ └── libjingle_peerconnection_so.so │ └── x86_64 │ │ └── libjingle_peerconnection_so.so └── src │ └── main │ ├── AndroidManifest.xml │ ├── baseline-prof.txt │ ├── java │ └── org │ │ └── webrtc │ │ ├── AddIceObserver.java │ │ ├── AndroidVideoDecoder.java │ │ ├── AudioDecoderFactoryFactory.java │ │ ├── AudioEncoderFactoryFactory.java │ │ ├── AudioProcessingFactory.java │ │ ├── AudioSource.java │ │ ├── AudioTrack.java │ │ ├── AudioTrackSink.java │ │ ├── BaseBitrateAdjuster.java │ │ ├── BitrateAdjuster.java │ │ ├── BuiltinAudioDecoderFactoryFactory.java │ │ ├── BuiltinAudioEncoderFactoryFactory.java │ │ ├── CallSessionFileRotatingLogSink.java │ │ ├── CalledByNative.java │ │ ├── CalledByNativeUnchecked.java │ │ ├── Camera1Capturer.java │ │ ├── Camera1Enumerator.java │ │ ├── Camera1Session.java │ │ ├── Camera2Capturer.java │ │ ├── Camera2Enumerator.java │ │ ├── Camera2Session.java │ │ ├── CameraCapturer.java │ │ ├── CameraEnumerationAndroid.java │ │ ├── CameraEnumerator.java │ │ ├── CameraSession.java │ │ ├── CameraVideoCapturer.java │ │ ├── CandidatePairChangeEvent.java │ │ ├── CapturerObserver.java │ │ ├── ContextUtils.java │ │ ├── CryptoOptions.java │ │ ├── DataChannel.java │ │ ├── Dav1dDecoder.java │ │ ├── DefaultAlignedVideoEncoderFactory.kt │ │ ├── DefaultBlacklistedVideoDecoderFactory.java │ │ ├── DefaultVideoDecoderFactory.java │ │ ├── DefaultVideoEncoderFactory.java │ │ ├── DtmfSender.java │ │ ├── DynamicBitrateAdjuster.java │ │ ├── EglBase.java │ │ ├── EglBase10.java │ │ ├── EglBase10Impl.java │ │ ├── EglBase14.java │ │ ├── EglBase14Impl.java │ │ ├── EglRenderer.java │ │ ├── EglThread.java │ │ ├── Empty.java │ │ ├── EncodedImage.java │ │ ├── ExternalAudioProcessingFactory.java │ │ ├── FecControllerFactoryFactoryInterface.java │ │ ├── FileVideoCapturer.java │ │ ├── FrameCryptor.java │ │ ├── FrameCryptorAlgorithm.java │ │ ├── FrameCryptorFactory.java │ │ ├── FrameCryptorKeyProvider.java │ │ ├── FrameDecryptor.java │ │ ├── FrameEncryptor.java │ │ ├── FramerateBitrateAdjuster.java │ │ ├── GlGenericDrawer.java │ │ ├── GlRectDrawer.java │ │ ├── GlShader.java │ │ ├── GlTextureFrameBuffer.java │ │ ├── GlUtil.java │ │ ├── H264Utils.java │ │ ├── HardwareVideoDecoderFactory.java │ │ ├── HardwareVideoEncoder.java │ │ ├── HardwareVideoEncoderFactory.java │ │ ├── HardwareVideoEncoderWrapper.java │ │ ├── HardwareVideoEncoderWrapperFactory.java │ │ ├── Histogram.java │ │ ├── IceCandidate.java │ │ ├── IceCandidateErrorEvent.java │ │ ├── JNILogging.java │ │ ├── JavaI420Buffer.java │ │ ├── JniCommon.java │ │ ├── JniHelper.java │ │ ├── LibaomAv1Encoder.java │ │ ├── LibvpxVp8Decoder.java │ │ ├── LibvpxVp8Encoder.java │ │ ├── LibvpxVp9Decoder.java │ │ ├── LibvpxVp9Encoder.java │ │ ├── Loggable.java │ │ ├── Logging.java │ │ ├── ManagedAudioProcessingFactory.java │ │ ├── MediaCodecUtils.java │ │ ├── MediaCodecVideoDecoderFactory.java │ │ ├── MediaCodecWrapper.java │ │ ├── MediaCodecWrapperFactory.java │ │ ├── MediaCodecWrapperFactoryImpl.java │ │ ├── MediaConstraints.java │ │ ├── MediaSource.java │ │ ├── MediaStream.java │ │ ├── MediaStreamTrack.java │ │ ├── Metrics.java │ │ ├── NV12Buffer.java │ │ ├── NV21Buffer.java │ │ ├── NativeAndroidVideoTrackSource.java │ │ ├── NativeCapturerObserver.java │ │ ├── NativeExternalAudioProcessingFactory.java │ │ ├── NativeLibrary.java │ │ ├── NativeLibraryLoader.java │ │ ├── NativePeerConnectionFactory.java │ │ ├── NetEqFactoryFactory.java │ │ ├── NetworkChangeDetector.java │ │ ├── NetworkChangeDetectorFactory.java │ │ ├── NetworkControllerFactoryFactory.java │ │ ├── NetworkMonitor.java │ │ ├── NetworkMonitorAutoDetect.java │ │ ├── NetworkPreference.java │ │ ├── NetworkStatePredictorFactoryFactory.java │ │ ├── OWNERS │ │ ├── PeerConnection.java │ │ ├── PeerConnectionDependencies.java │ │ ├── PeerConnectionFactory.java │ │ ├── PlatformSoftwareVideoDecoderFactory.java │ │ ├── Predicate.java │ │ ├── Priority.java │ │ ├── RTCStats.java │ │ ├── RTCStatsCollectorCallback.java │ │ ├── RTCStatsReport.java │ │ ├── RefCountDelegate.java │ │ ├── RefCounted.java │ │ ├── RenderSynchronizer.java │ │ ├── RendererCommon.java │ │ ├── ResolutionAdjustment.kt │ │ ├── RtcCertificatePem.java │ │ ├── RtpCapabilities.java │ │ ├── RtpParameters.java │ │ ├── RtpReceiver.java │ │ ├── RtpSender.java │ │ ├── RtpTransceiver.java │ │ ├── SSLCertificateVerifier.java │ │ ├── ScreenCapturerAndroid.java │ │ ├── SdpObserver.java │ │ ├── SessionDescription.java │ │ ├── SimulcastAlignedVideoEncoderFactory.kt │ │ ├── SimulcastVideoEncoder.java │ │ ├── SimulcastVideoEncoderFactory.java │ │ ├── Size.java │ │ ├── SoftwareVideoDecoderFactory.java │ │ ├── SoftwareVideoEncoderFactory.java │ │ ├── StatsObserver.java │ │ ├── StatsReport.java │ │ ├── SurfaceEglRenderer.java │ │ ├── SurfaceTextureHelper.java │ │ ├── SurfaceViewRenderer.java │ │ ├── TextureBufferImpl.java │ │ ├── ThreadUtils.java │ │ ├── TimestampAligner.java │ │ ├── TurnCustomizer.java │ │ ├── VideoCapturer.java │ │ ├── VideoCodecInfo.java │ │ ├── VideoCodecMimeType.java │ │ ├── VideoCodecStatus.java │ │ ├── VideoDecoder.java │ │ ├── VideoDecoderFactory.java │ │ ├── VideoDecoderFallback.java │ │ ├── VideoDecoderWrapper.java │ │ ├── VideoEncoder.java │ │ ├── VideoEncoderFactory.java │ │ ├── VideoEncoderFallback.java │ │ ├── VideoEncoderWrapper.java │ │ ├── VideoFileRenderer.java │ │ ├── VideoFrame.java │ │ ├── VideoFrameBufferType.java │ │ ├── VideoFrameDrawer.java │ │ ├── VideoProcessor.java │ │ ├── VideoSink.java │ │ ├── VideoSource.java │ │ ├── VideoTrack.java │ │ ├── WebRTCException.kt │ │ ├── WebRtcClassLoader.java │ │ ├── WrappedNativeI420Buffer.java │ │ ├── WrappedNativeVideoDecoder.java │ │ ├── WrappedNativeVideoEncoder.java │ │ ├── WrappedVideoDecoderFactory.java │ │ ├── YuvConverter.java │ │ ├── YuvHelper.java │ │ ├── audio │ │ ├── AudioDeviceModule.java │ │ ├── AudioRecordDataCallback.java │ │ ├── JavaAudioDeviceModule.java │ │ ├── LegacyAudioDeviceModule.java │ │ ├── LowLatencyAudioBufferManager.java │ │ ├── VolumeLogger.java │ │ ├── WebRtcAudioEffects.java │ │ ├── WebRtcAudioManager.java │ │ ├── WebRtcAudioRecord.java │ │ ├── WebRtcAudioTrack.java │ │ └── WebRtcAudioUtils.java │ │ └── voiceengine │ │ ├── BuildInfo.java │ │ ├── WebRtcAudioEffects.java │ │ ├── WebRtcAudioManager.java │ │ ├── WebRtcAudioRecord.java │ │ ├── WebRtcAudioTrack.java │ │ └── WebRtcAudioUtils.java │ └── resources │ └── META-INF │ └── io │ └── getstream │ └── stream-webrtc-android │ └── verification.properties └── usecases.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | [*] 3 | # Most of the standard properties are supported 4 | indent_size=2 5 | max_line_length=100 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.txt linguist-language=Kotlin 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # More details are here: https://help.github.com/articles/about-codeowners/ 5 | 6 | # The '*' pattern is global owners. 7 | # Not adding in this PR, but I'd like to try adding a global owner set with the entire team. 8 | # One interpretation of their docs is that global owners are added only if not removed 9 | # by a more local rule. 10 | 11 | # Order is important. The last matching pattern has the most precedence. 12 | # The folders are ordered as follows: 13 | 14 | # In each subsection folders are ordered first by depth, then alphabetically. 15 | # This should make it easy to add new rules without breaking existing ones. 16 | * @skydoves -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gradle" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | # Allow up to 10 open pull requests for pip dependencies 13 | open-pull-requests-limit: 10 14 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ### 🎯 Goal 2 | Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. 3 | 4 | ### 🛠 Implementation details 5 | Describe the implementation details for this Pull Request. 6 | 7 | ### ✍️ Explain examples 8 | Explain examples with code for this updates. 9 | 10 | ### Preparing a pull request for review 11 | Ensure your change is properly formatted by running: 12 | 13 | ```gradle 14 | $ ./gradlew spotlessApply 15 | ``` 16 | 17 | Please correct any failures before requesting a review. -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: set up JDK 16 | uses: actions/setup-java@v1 17 | with: 18 | java-version: 17 19 | 20 | - name: Cache Gradle and wrapper 21 | uses: actions/cache@v2 22 | with: 23 | path: | 24 | ~/.gradle/caches 25 | ~/.gradle/wrapper 26 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} 27 | restore-keys: | 28 | ${{ runner.os }}-gradle- 29 | - name: Make Gradle executable 30 | run: chmod +x ./gradlew 31 | 32 | - name: Build with Gradle 33 | run: | 34 | ./gradlew --scan --stacktrace \ 35 | assemble -x :benchmark:pixel6api33Setup -x :benchmark:pixel6api33NonMinifiedReleaseAndroidTest -x :benchmark:collectNonMinifiedReleaseBaselineProfile -------------------------------------------------------------------------------- /.github/workflows/publish-snapshot.yml: -------------------------------------------------------------------------------- 1 | name: Publish Snapshot builds 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | publish: 11 | name: Snapshot build and publish 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Check out code 15 | uses: actions/checkout@v2 16 | - name: Set up JDK 17 17 | uses: actions/setup-java@v2 18 | with: 19 | distribution: adopt 20 | java-version: 17 21 | - name: Release build 22 | run: ./gradlew assemble --scan -x :benchmark:pixel6api33Setup -x :benchmark:pixel6api33NonMinifiedReleaseAndroidTest -x :benchmark:collectNonMinifiedReleaseBaselineProfile 23 | - name: Source jar and dokka 24 | run: ./gradlew androidSourcesJar javadocJar --scan 25 | - name: Publish to MavenCentral 26 | run: ./gradlew publishReleasePublicationToSonatypeRepository --scan 27 | env: 28 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 29 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 30 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} 31 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 32 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }} 33 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} 34 | SNAPSHOT: true 35 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | release: 5 | types: [released] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | publish: 10 | name: Release build and publish 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Check out code 14 | uses: actions/checkout@v2 15 | - name: Set up JDK 17 16 | uses: actions/setup-java@v2 17 | with: 18 | distribution: adopt 19 | java-version: 17 20 | - name: Release build 21 | run: ./gradlew assemble --scan -x :benchmark:pixel6api33Setup -x :benchmark:pixel6api33NonMinifiedReleaseAndroidTest -x :benchmark:collectNonMinifiedReleaseBaselineProfile 22 | - name: Source jar and dokka 23 | run: ./gradlew androidSourcesJar javadocJar --scan 24 | - name: Publish to MavenCentral 25 | run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository --scan 26 | env: 27 | OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} 28 | OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} 29 | SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} 30 | SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} 31 | SIGNING_KEY: ${{ secrets.SIGNING_KEY }} 32 | SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} 33 | -------------------------------------------------------------------------------- /.github/workflows/release-docs.yaml: -------------------------------------------------------------------------------- 1 | name: ReleaseDocs 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | workflow_dispatch: 8 | 9 | jobs: 10 | publish_dokka: 11 | name: Dokka docs 12 | runs-on: ubuntu-22.04 13 | steps: 14 | - name: Check out code 15 | uses: actions/checkout@v3.1.0 16 | with: 17 | ref: main 18 | - name: Set up JDK 17 19 | uses: actions/setup-java@v3.6.0 20 | with: 21 | distribution: adopt 22 | java-version: 17 23 | - name: Generate Dokka HTML docs 24 | run: ./gradlew dokkaHtmlMultimodule 25 | - name: Deploy to GitHub pages 26 | uses: peaceiris/actions-gh-pages@v3 27 | with: 28 | github_token: ${{ secrets.DOCUSAURUS_GH_TOKEN }} 29 | publish_dir: ./build/dokka/htmlMultiModule 30 | publish_branch: gh-pages -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Kotlin class files 12 | .kotlin 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | /.idea 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # Intellij 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/dictionaries 45 | .idea/libraries 46 | app/.idea/ 47 | 48 | # Mac 49 | *.DS_Store 50 | 51 | # Keystore files 52 | *.jks 53 | 54 | # External native build folder generated in Android Studio 2.2 and later 55 | .externalNativeBuild 56 | 57 | # Google Services (e.g. APIs or Firebase) 58 | google-services.json 59 | 60 | # Freeline 61 | freeline.py 62 | freeline/ 63 | freeline_project_description.json 64 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 37 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/WebRTCApp.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose 18 | 19 | import android.app.Application 20 | import io.getstream.log.android.AndroidStreamLogger 21 | 22 | class WebRTCApp : Application() { 23 | 24 | override fun onCreate() { 25 | super.onCreate() 26 | 27 | AndroidStreamLogger.installOnDebuggableApp(this) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/ui/screens/video/CallMediaState.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.ui.screens.video 18 | 19 | data class CallMediaState( 20 | val isMicrophoneEnabled: Boolean = true, 21 | val isCameraEnabled: Boolean = true, 22 | ) 23 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.ui.theme 18 | 19 | import androidx.compose.ui.graphics.Color 20 | 21 | val Purple200 = Color(0xFFBB86FC) 22 | val Purple500 = Color(0xFF6200EE) 23 | val Purple700 = Color(0xFF3700B3) 24 | val Teal200 = Color(0xFF03DAC5) 25 | val Primary = Color(0xFF337EFF) 26 | val Disabled = Color(0xFFFF1A24) 27 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/ui/theme/Shape.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.ui.theme 18 | 19 | import androidx.compose.foundation.shape.RoundedCornerShape 20 | import androidx.compose.material.Shapes 21 | import androidx.compose.ui.unit.dp 22 | 23 | val Shapes = Shapes( 24 | small = RoundedCornerShape(4.dp), 25 | medium = RoundedCornerShape(4.dp), 26 | large = RoundedCornerShape(0.dp), 27 | ) 28 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.ui.theme 18 | 19 | import androidx.compose.foundation.isSystemInDarkTheme 20 | import androidx.compose.material.MaterialTheme 21 | import androidx.compose.material.darkColors 22 | import androidx.compose.material.lightColors 23 | import androidx.compose.runtime.Composable 24 | 25 | private val DarkColorPalette = darkColors( 26 | primary = Purple200, 27 | primaryVariant = Purple700, 28 | secondary = Teal200, 29 | ) 30 | 31 | private val LightColorPalette = lightColors( 32 | primary = Purple500, 33 | primaryVariant = Purple700, 34 | secondary = Teal200, 35 | 36 | /* Other default colors to override 37 | background = Color.White, 38 | surface = Color.White, 39 | onPrimary = Color.White, 40 | onSecondary = Color.Black, 41 | onBackground = Color.Black, 42 | onSurface = Color.Black, 43 | */ 44 | ) 45 | 46 | @Composable 47 | fun WebrtcSampleComposeTheme( 48 | darkTheme: Boolean = isSystemInDarkTheme(), 49 | content: @Composable () -> Unit, 50 | ) { 51 | val colors = if (darkTheme) { 52 | DarkColorPalette 53 | } else { 54 | LightColorPalette 55 | } 56 | 57 | MaterialTheme( 58 | colors = colors, 59 | typography = Typography, 60 | shapes = Shapes, 61 | content = content, 62 | ) 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.ui.theme 18 | 19 | import androidx.compose.material.Typography 20 | import androidx.compose.ui.text.TextStyle 21 | import androidx.compose.ui.text.font.FontFamily 22 | import androidx.compose.ui.text.font.FontWeight 23 | import androidx.compose.ui.unit.sp 24 | 25 | // Set of Material typography styles to start with 26 | val Typography = Typography( 27 | body1 = TextStyle( 28 | fontFamily = FontFamily.Default, 29 | fontWeight = FontWeight.Normal, 30 | fontSize = 16.sp, 31 | ), 32 | /* Other default text styles to override 33 | button = TextStyle( 34 | fontFamily = FontFamily.Default, 35 | fontWeight = FontWeight.W500, 36 | fontSize = 14.sp 37 | ), 38 | caption = TextStyle( 39 | fontFamily = FontFamily.Default, 40 | fontWeight = FontWeight.Normal, 41 | fontSize = 12.sp 42 | ) 43 | */ 44 | ) 45 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/audio/AudioDevice.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.audio 18 | 19 | sealed class AudioDevice { 20 | 21 | /** The friendly name of the device.*/ 22 | abstract val name: String 23 | 24 | /** An [AudioDevice] representing a Bluetooth Headset.*/ 25 | data class BluetoothHeadset internal constructor(override val name: String = "Bluetooth") : 26 | AudioDevice() 27 | 28 | /** An [AudioDevice] representing a Wired Headset.*/ 29 | data class WiredHeadset internal constructor(override val name: String = "Wired Headset") : 30 | AudioDevice() 31 | 32 | /** An [AudioDevice] representing the Earpiece.*/ 33 | data class Earpiece internal constructor(override val name: String = "Earpiece") : AudioDevice() 34 | 35 | /** An [AudioDevice] representing the Speakerphone.*/ 36 | data class Speakerphone internal constructor(override val name: String = "Speakerphone") : 37 | AudioDevice() 38 | } 39 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/audio/AudioDeviceChangeListener.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.audio 18 | 19 | typealias AudioDeviceChangeListener = ( 20 | audioDevices: List, 21 | selectedAudioDevice: AudioDevice?, 22 | ) -> Unit 23 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/audio/AudioFocusRequestWrapper.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.audio 18 | 19 | import android.annotation.SuppressLint 20 | import android.media.AudioAttributes 21 | import android.media.AudioFocusRequest 22 | import android.media.AudioManager 23 | 24 | internal class AudioFocusRequestWrapper { 25 | 26 | @SuppressLint("NewApi") 27 | fun buildRequest( 28 | audioFocusChangeListener: AudioManager.OnAudioFocusChangeListener, 29 | ): AudioFocusRequest { 30 | val playbackAttributes = AudioAttributes.Builder() 31 | .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) 32 | .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) 33 | .build() 34 | return AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN_TRANSIENT) 35 | .setAudioAttributes(playbackAttributes) 36 | .setAcceptsDelayedFocusGain(true) 37 | .setOnAudioFocusChangeListener(audioFocusChangeListener) 38 | .build() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/audio/AudioManagerAdapter.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.audio 18 | 19 | internal interface AudioManagerAdapter { 20 | 21 | fun hasEarpiece(): Boolean 22 | 23 | fun hasSpeakerphone(): Boolean 24 | 25 | fun setAudioFocus() 26 | 27 | fun enableBluetoothSco(enable: Boolean) 28 | 29 | fun enableSpeakerphone(enable: Boolean) 30 | 31 | fun mute(mute: Boolean) 32 | 33 | fun cacheAudioState() 34 | 35 | fun restoreAudioState() 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/peer/StreamPeerType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.peer 18 | 19 | /** 20 | * The type of peer connections, either a [PUBLISHER] that sends data to the call or a [SUBSCRIBER] 21 | * that receives and decodes the data from the server. 22 | */ 23 | enum class StreamPeerType { 24 | PUBLISHER, 25 | SUBSCRIBER, 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/sessions/WebRtcSessionManager.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.sessions 18 | 19 | import io.getstream.webrtc.sample.compose.webrtc.SignalingClient 20 | import io.getstream.webrtc.sample.compose.webrtc.peer.StreamPeerConnectionFactory 21 | import kotlinx.coroutines.flow.SharedFlow 22 | import org.webrtc.VideoTrack 23 | 24 | interface WebRtcSessionManager { 25 | 26 | val signalingClient: SignalingClient 27 | 28 | val peerConnectionFactory: StreamPeerConnectionFactory 29 | 30 | val localVideoSinkFlow: SharedFlow 31 | 32 | val remoteVideoSinkFlow: SharedFlow 33 | 34 | fun onSessionScreenReady() 35 | 36 | fun flipCamera() 37 | 38 | fun enableMicrophone(enabled: Boolean) 39 | 40 | fun disconnect() 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/kotlin/io/getstream/webrtc/sample/compose/webrtc/utils/Stringify.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.sample.compose.webrtc.utils 18 | 19 | import io.getstream.webrtc.sample.compose.webrtc.peer.StreamPeerType 20 | 21 | fun StreamPeerType.stringify() = when (this) { 22 | StreamPeerType.PUBLISHER -> "publisher" 23 | StreamPeerType.SUBSCRIBER -> "subscriber" 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_call_end.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_camera_flip.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mic_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mic_on.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_videocam_off.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 23 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_videocam_on.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 22 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | #FFBB86FC 19 | #FF6200EE 20 | #FF3700B3 21 | #FF03DAC5 22 | #FF018786 23 | #FF000000 24 | #FFFFFFFF 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | webrtc-sample-compose 19 | 20 | Offline 21 | Second peer is missing 22 | Ready to start session 23 | Creating session 24 | Session Active 25 | 26 | Start session 27 | Join session 28 | 29 | End Session 30 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /bash/baseline-profile-amender.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | awk '/org/ && /webrtc/ && !/getstream/' app/src/main/baseline-prof.txt > stream-webrtc-android/src/main/baseline-prof.txt 16 | awk '/getstream/ && /compose/ && !/ui/ && !/ktx/ && !/sample/' app/src/main/baseline-prof.txt > stream-webrtc-android-compose/src/main/baseline-prof.txt 17 | awk '/getstream/ && !/compose/ && /ui/ && !/ktx/ && !/sample/' app/src/main/baseline-prof.txt > stream-webrtc-android-ui/src/main/baseline-prof.txt 18 | awk '/getstream/ && !/compose/ && !/ui/ && /ktx/ && !/sample/' app/src/main/baseline-prof.txt > stream-webrtc-android-ktx/src/main/baseline-prof.txt -------------------------------------------------------------------------------- /benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /benchmark/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /benchmark/src/main/java/io/getstream/webrtc/android/benchmark/BaselineProfileGenerator.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.android.benchmark 18 | 19 | import android.os.Build 20 | import androidx.annotation.RequiresApi 21 | import androidx.benchmark.macro.junit4.BaselineProfileRule 22 | import androidx.test.uiautomator.By 23 | import org.junit.Rule 24 | import org.junit.Test 25 | 26 | /** 27 | * Generates a baseline profile which can be copied to `app/src/main/baseline-prof.txt`. 28 | */ 29 | @RequiresApi(Build.VERSION_CODES.P) 30 | class BaselineProfileGenerator { 31 | @get:Rule 32 | val baselineProfileRule = BaselineProfileRule() 33 | 34 | @Test 35 | fun startup() = 36 | baselineProfileRule.collect( 37 | packageName = "io.getstream.webrtc.sample.compose", 38 | stableIterations = 2, 39 | maxIterations = 8, 40 | includeInStartupProfile = true, 41 | ) { 42 | startActivityAndWait() 43 | 44 | device.waitForIdle() 45 | 46 | device.waitForObject(By.text(getPermissionText()), 5_000)?.click() 47 | device.waitForObject(By.text(getPermissionText()), 5_000)?.click() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /benchmark/src/main/java/io/getstream/webrtc/android/benchmark/Utils.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.android.benchmark 18 | 19 | import android.os.Build 20 | import androidx.test.uiautomator.BySelector 21 | import androidx.test.uiautomator.UiDevice 22 | import androidx.test.uiautomator.UiObject2 23 | import androidx.test.uiautomator.Until 24 | 25 | internal fun getPermissionText(): String { 26 | return when { 27 | Build.VERSION.SDK_INT <= 28 -> "ALLOW" 28 | Build.VERSION.SDK_INT == 29 -> "Allow only while using the app" 29 | else -> "While using the app" 30 | } 31 | } 32 | 33 | internal fun UiDevice.waitForObject(selector: BySelector, timeout: Long = 5_000): UiObject2? { 34 | if (wait(Until.hasObject(selector), timeout)) { 35 | return findObject(selector) 36 | } 37 | return null 38 | } 39 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | @Suppress("DSL_SCOPE_VIOLATION") 2 | plugins { 3 | alias(libs.plugins.android.application) apply false 4 | alias(libs.plugins.android.library) apply false 5 | alias(libs.plugins.kotlin.android) apply false 6 | // alias(libs.plugins.compose.compiler) apply false 7 | alias(libs.plugins.baseline.profile) apply false 8 | alias(libs.plugins.nexusPlugin) 9 | alias(libs.plugins.spotless) 10 | alias(libs.plugins.dokka) 11 | alias(libs.plugins.kotlinBinaryCompatibilityValidator) 12 | } 13 | 14 | apply(from ="${rootDir}/scripts/publish-root.gradle") 15 | 16 | apiValidation { 17 | ignoredProjects.addAll(listOf("app")) 18 | nonPublicMarkers.add("kotlin.PublishedApi") 19 | } 20 | 21 | subprojects { 22 | tasks.withType().all { 23 | kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString() 24 | } 25 | 26 | apply(plugin = rootProject.libs.plugins.spotless.get().pluginId) 27 | extensions.configure { 28 | kotlin { 29 | target("**/*.kt") 30 | targetExclude("$buildDir/**/*.kt") 31 | ktlint().editorConfigOverride( 32 | mapOf( 33 | "indent_size" to "2", 34 | "continuation_indent_size" to "2" 35 | ) 36 | ) 37 | licenseHeaderFile(rootProject.file("spotless/copyright.kt")) 38 | trimTrailingWhitespace() 39 | endWithNewline() 40 | } 41 | format("kts") { 42 | target("**/*.kts") 43 | targetExclude("$buildDir/**/*.kts") 44 | licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)") 45 | } 46 | format("xml") { 47 | target("**/*.xml") 48 | targetExclude("**/build/**/*.xml") 49 | licenseHeaderFile(rootProject.file("spotless/copyright.xml"), "(<[^!?])") 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | } 8 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/io/getstream/Configurations.kt: -------------------------------------------------------------------------------- 1 | package io.getstream 2 | 3 | object Configurations { 4 | const val compileSdk = 35 5 | const val targetSdk = 35 6 | const val minSdk = 21 7 | const val appMinSdk = 24 8 | const val majorVersion = 1 9 | const val minorVersion = 3 10 | const val patchVersion = 8 11 | const val versionName = "$majorVersion.$minorVersion.$patchVersion" 12 | const val snapshotVersionName = "$majorVersion.$minorVersion.${patchVersion + 1}-SNAPSHOT" 13 | const val artifactGroup = "io.getstream" 14 | } 15 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official 20 | # Enables namespacing of each library's R class so that its R class includes only the 21 | # resources declared in the library itself and none from the library's dependencies, 22 | # thereby reducing the size of the R class for that library 23 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /scripts/publish-root.gradle: -------------------------------------------------------------------------------- 1 | import io.getstream.Configurations 2 | 3 | // Create variables with empty default values 4 | ext["ossrhUsername"] = '' 5 | ext["ossrhPassword"] = '' 6 | ext["sonatypeStagingProfileId"] = '' 7 | ext["signing.keyId"] = '' 8 | ext["signing.password"] = '' 9 | ext["signing.key"] = '' 10 | ext["snapshot"] = '' 11 | 12 | File secretPropsFile = project.rootProject.file('local.properties') 13 | if (secretPropsFile.exists()) { 14 | // Read local.properties file first if it exists 15 | Properties p = new Properties() 16 | new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } 17 | p.each { name, value -> ext[name] = value } 18 | } else { 19 | // Use system environment variables 20 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') 21 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') 22 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') 23 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') 24 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD') 25 | ext["signing.key"] = System.getenv('SIGNING_KEY') 26 | ext["snapshot"] = System.getenv('SNAPSHOT') 27 | } 28 | 29 | if (snapshot) { 30 | ext["rootVersionName"] = Configurations.snapshotVersionName 31 | } else { 32 | ext["rootVersionName"] = Configurations.versionName 33 | } 34 | 35 | // Set up Sonatype repository 36 | nexusPublishing { 37 | repositories { 38 | sonatype { 39 | stagingProfileId = sonatypeStagingProfileId 40 | username = ossrhUsername 41 | password = ossrhPassword 42 | version = rootVersionName 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | pluginManagement { 3 | repositories { 4 | google() 5 | mavenCentral() 6 | gradlePluginPortal() 7 | maven(url = "https://plugins.gradle.org/m2/") 8 | } 9 | } 10 | dependencyResolutionManagement { 11 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 12 | repositories { 13 | google() 14 | mavenCentral() 15 | maven(url = "https://plugins.gradle.org/m2/") 16 | } 17 | } 18 | rootProject.name = "stream-webrtc-android" 19 | include(":app") 20 | include(":stream-webrtc-android") 21 | include(":stream-webrtc-android-ui") 22 | include(":stream-webrtc-android-compose") 23 | include(":stream-webrtc-android-ktx") 24 | include(":stream-webrtc-android-bom") 25 | include(":benchmark") -------------------------------------------------------------------------------- /spotless/copyright.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-$YEAR Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /spotless/copyright.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-$YEAR Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2. 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /spotless/copyright.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /stream-webrtc-android-bom/api/stream-webrtc-android-bom.api: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android-bom/api/stream-webrtc-android-bom.api -------------------------------------------------------------------------------- /stream-webrtc-android-bom/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import io.getstream.Configurations 2 | 3 | plugins { 4 | kotlin("jvm") 5 | } 6 | 7 | rootProject.extra.apply { 8 | set("PUBLISH_GROUP_ID", Configurations.artifactGroup) 9 | set("PUBLISH_ARTIFACT_ID", "stream-webrtc-android-bom") 10 | set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) 11 | } 12 | 13 | dependencies { 14 | constraints { 15 | api(project(":stream-webrtc-android")) 16 | api(project(":stream-webrtc-android-ui")) 17 | api(project(":stream-webrtc-android-compose")) 18 | api(project(":stream-webrtc-android-ktx")) 19 | } 20 | } 21 | 22 | apply(from ="${rootDir}/scripts/publish-module.gradle") -------------------------------------------------------------------------------- /stream-webrtc-android-compose/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /stream-webrtc-android-compose/api/stream-webrtc-android-compose.api: -------------------------------------------------------------------------------- 1 | public final class io/getstream/webrtc/android/compose/FloatingVideoRendererKt { 2 | public static final fun FloatingVideoRenderer-_BRzflo (Landroidx/compose/ui/Modifier;Lorg/webrtc/VideoTrack;JLandroidx/compose/foundation/layout/PaddingValues;Lorg/webrtc/EglBase$Context;Lorg/webrtc/RendererCommon$RendererEvents;Landroidx/compose/runtime/Composer;II)V 3 | } 4 | 5 | public final class io/getstream/webrtc/android/compose/VideoRendererKt { 6 | public static final fun VideoRenderer (Landroidx/compose/ui/Modifier;Lorg/webrtc/VideoTrack;Lorg/webrtc/EglBase$Context;Lio/getstream/webrtc/android/compose/VideoScalingType;Lkotlin/jvm/functions/Function1;Lorg/webrtc/RendererCommon$RendererEvents;Landroidx/compose/runtime/Composer;II)V 7 | } 8 | 9 | public final class io/getstream/webrtc/android/compose/VideoScalingType : java/lang/Enum { 10 | public static final field Companion Lio/getstream/webrtc/android/compose/VideoScalingType$Companion; 11 | public static final field SCALE_ASPECT_BALANCED Lio/getstream/webrtc/android/compose/VideoScalingType; 12 | public static final field SCALE_ASPECT_FILL Lio/getstream/webrtc/android/compose/VideoScalingType; 13 | public static final field SCALE_ASPECT_FIT Lio/getstream/webrtc/android/compose/VideoScalingType; 14 | public static final field SCAPE_ASPECT_FILL Lio/getstream/webrtc/android/compose/VideoScalingType; 15 | public static fun getEntries ()Lkotlin/enums/EnumEntries; 16 | public static fun valueOf (Ljava/lang/String;)Lio/getstream/webrtc/android/compose/VideoScalingType; 17 | public static fun values ()[Lio/getstream/webrtc/android/compose/VideoScalingType; 18 | } 19 | 20 | public final class io/getstream/webrtc/android/compose/VideoScalingType$Companion { 21 | } 22 | 23 | -------------------------------------------------------------------------------- /stream-webrtc-android-compose/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /stream-webrtc-android-compose/src/main/kotlin/io/getstream/webrtc/android/compose/VideoScalingType.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.android.compose 18 | 19 | import org.webrtc.RendererCommon 20 | 21 | /** 22 | * Types of video scaling: 23 | * SCALE_ASPECT_FIT - video frame is scaled to fit the size of the view by 24 | * maintaining the aspect ratio (black borders may be displayed). 25 | * 26 | * SCALE_ASPECT_FILL - video frame is scaled to fill the size of the view by 27 | * maintaining the aspect ratio. Some portion of the video frame may be clipped. 28 | * 29 | * SCALE_ASPECT_BALANCED - Compromise between FIT and FILL. Video frame will fill as much as 30 | * possible of the view while maintaining aspect ratio, under the constraint that at least 31 | * `BALANCED_VISIBLE_FRACTION` of the frame content will be shown. 32 | */ 33 | public enum class VideoScalingType { 34 | SCALE_ASPECT_FIT, 35 | SCALE_ASPECT_FILL, 36 | SCALE_ASPECT_BALANCED, 37 | ; 38 | 39 | public companion object { 40 | 41 | @Deprecated( 42 | message = "Use SCALE_ASPECT_FILL instead", 43 | replaceWith = ReplaceWith("VideoScalingType.SCALE_ASPECT_FILL"), 44 | ) 45 | @JvmField 46 | public val SCAPE_ASPECT_FILL: VideoScalingType = SCALE_ASPECT_FILL 47 | 48 | internal fun VideoScalingType.toCommonScalingType(): RendererCommon.ScalingType { 49 | return when (this) { 50 | SCALE_ASPECT_FIT -> RendererCommon.ScalingType.SCALE_ASPECT_FIT 51 | SCALE_ASPECT_FILL -> RendererCommon.ScalingType.SCALE_ASPECT_FILL 52 | SCALE_ASPECT_BALANCED -> RendererCommon.ScalingType.SCALE_ASPECT_BALANCED 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/api/stream-webrtc-android-ktx.api: -------------------------------------------------------------------------------- 1 | public final class io/getstream/webrtc/android/ktx/PeerConnectionExtensionsKt { 2 | public static final fun addRtcIceCandidate (Lorg/webrtc/PeerConnection;Lorg/webrtc/IceCandidate;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 3 | } 4 | 5 | public final class io/getstream/webrtc/android/ktx/SDPExtensionsKt { 6 | public static final fun createSessionDescription (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 7 | public static final fun suspendSdpObserver (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; 8 | } 9 | 10 | public final class io/getstream/webrtc/android/ktx/StringifyKt { 11 | public static final fun stringify (Lorg/webrtc/IceCandidateErrorEvent;)Ljava/lang/String; 12 | public static final fun stringify (Lorg/webrtc/MediaStreamTrack;)Ljava/lang/String; 13 | public static final fun stringify (Lorg/webrtc/SessionDescription;)Ljava/lang/String; 14 | public static final fun stringify (Lorg/webrtc/audio/JavaAudioDeviceModule$AudioSamples;)Ljava/lang/String; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | import io.getstream.Configurations 4 | 5 | @Suppress("DSL_SCOPE_VIOLATION") 6 | plugins { 7 | id(libs.plugins.android.library.get().pluginId) 8 | id(libs.plugins.kotlin.android.get().pluginId) 9 | id(libs.plugins.baseline.profile.get().pluginId) 10 | } 11 | 12 | rootProject.extra.apply { 13 | set("PUBLISH_GROUP_ID", Configurations.artifactGroup) 14 | set("PUBLISH_ARTIFACT_ID", "stream-webrtc-android-ktx") 15 | set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) 16 | } 17 | 18 | apply(from = "${rootDir}/scripts/publish-module.gradle") 19 | 20 | android { 21 | namespace = "io.getstream.webrtc.android.ktx" 22 | compileSdk = Configurations.compileSdk 23 | 24 | defaultConfig { 25 | minSdk = Configurations.minSdk 26 | } 27 | 28 | compileOptions { 29 | sourceCompatibility = JavaVersion.VERSION_11 30 | targetCompatibility = JavaVersion.VERSION_11 31 | } 32 | 33 | lint { 34 | abortOnError = false 35 | } 36 | 37 | baselineProfile { 38 | baselineProfileOutputDir = "." 39 | filter { 40 | include("io.getstream.webrtc.android.ktx.**") 41 | } 42 | } 43 | } 44 | 45 | tasks.withType { 46 | kotlinOptions.freeCompilerArgs += listOf( 47 | "-Xexplicit-api=strict" 48 | ) 49 | } 50 | 51 | tasks.withType(JavaCompile::class.java).configureEach { 52 | this.targetCompatibility = libs.versions.jvmTarget.get() 53 | this.sourceCompatibility = libs.versions.jvmTarget.get() 54 | } 55 | 56 | dependencies { 57 | api(project(":stream-webrtc-android")) 58 | 59 | baselineProfile(project(":benchmark")) 60 | } -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/src/main/baseline-prof.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android-ktx/src/main/baseline-prof.txt -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/src/main/kotlin/io/getstream/webrtc/android/ktx/PeerConnectionExtensions.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.android.ktx 18 | 19 | import org.webrtc.AddIceObserver 20 | import org.webrtc.IceCandidate 21 | import org.webrtc.PeerConnection 22 | import org.webrtc.WebRTCException 23 | import kotlin.coroutines.resume 24 | import kotlin.coroutines.suspendCoroutine 25 | 26 | /** 27 | * Add a given [IceCandidate] to a [PeerConnection]. 28 | * 29 | * @param iceCandidate A given [IceCandidate]. 30 | */ 31 | public suspend fun PeerConnection.addRtcIceCandidate(iceCandidate: IceCandidate): Result { 32 | return suspendCoroutine { cont -> 33 | addIceCandidate( 34 | iceCandidate, 35 | object : AddIceObserver { 36 | override fun onAddSuccess() { 37 | cont.resume(Result.success(Unit)) 38 | } 39 | 40 | override fun onAddFailure(error: String?) { 41 | cont.resume(Result.failure(WebRTCException(message = error))) 42 | } 43 | }, 44 | ) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /stream-webrtc-android-ktx/src/main/kotlin/io/getstream/webrtc/android/ktx/Stringify.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package io.getstream.webrtc.android.ktx 18 | 19 | import org.webrtc.IceCandidateErrorEvent 20 | import org.webrtc.MediaStreamTrack 21 | import org.webrtc.SessionDescription 22 | import org.webrtc.audio.JavaAudioDeviceModule 23 | 24 | public fun SessionDescription.stringify(): String = 25 | "SessionDescription(type=$type, description=$description)" 26 | 27 | public fun MediaStreamTrack.stringify(): String { 28 | return "MediaStreamTrack(id=${id()}, kind=${kind()}, enabled: ${enabled()}, state=${state()})" 29 | } 30 | 31 | public fun IceCandidateErrorEvent.stringify(): String { 32 | return "IceCandidateErrorEvent(errorCode=$errorCode, $errorText, " + 33 | "address=$address, port=$port, url=$url)" 34 | } 35 | 36 | public fun JavaAudioDeviceModule.AudioSamples.stringify(): String { 37 | return "AudioSamples(audioFormat=$audioFormat, channelCount=$channelCount" + 38 | ", sampleRate=$sampleRate, data.size=${data.size})" 39 | } 40 | -------------------------------------------------------------------------------- /stream-webrtc-android-ui/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /stream-webrtc-android-ui/api/stream-webrtc-android-ui.api: -------------------------------------------------------------------------------- 1 | public class io/getstream/webrtc/android/ui/VideoTextureViewRenderer : android/view/TextureView, android/view/TextureView$SurfaceTextureListener, org/webrtc/VideoSink { 2 | public fun (Landroid/content/Context;)V 3 | public fun (Landroid/content/Context;Landroid/util/AttributeSet;)V 4 | public synthetic fun (Landroid/content/Context;Landroid/util/AttributeSet;ILkotlin/jvm/internal/DefaultConstructorMarker;)V 5 | public final fun init (Lorg/webrtc/EglBase$Context;Lorg/webrtc/RendererCommon$RendererEvents;)V 6 | protected fun onDetachedFromWindow ()V 7 | public fun onFrame (Lorg/webrtc/VideoFrame;)V 8 | protected fun onLayout (ZIIII)V 9 | protected fun onMeasure (II)V 10 | public fun onSurfaceTextureAvailable (Landroid/graphics/SurfaceTexture;II)V 11 | public fun onSurfaceTextureDestroyed (Landroid/graphics/SurfaceTexture;)Z 12 | public fun onSurfaceTextureSizeChanged (Landroid/graphics/SurfaceTexture;II)V 13 | public fun onSurfaceTextureUpdated (Landroid/graphics/SurfaceTexture;)V 14 | public final fun pauseVideo ()V 15 | public final fun resumeVideo ()V 16 | public final fun setMirror (Z)V 17 | public final fun setScalingType (Lorg/webrtc/RendererCommon$ScalingType;)V 18 | public final fun setScalingType (Lorg/webrtc/RendererCommon$ScalingType;Lorg/webrtc/RendererCommon$ScalingType;)V 19 | } 20 | 21 | -------------------------------------------------------------------------------- /stream-webrtc-android-ui/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | import io.getstream.Configurations 4 | 5 | @Suppress("DSL_SCOPE_VIOLATION") plugins { 6 | id(libs.plugins.android.library.get().pluginId) 7 | id(libs.plugins.kotlin.android.get().pluginId) 8 | id(libs.plugins.baseline.profile.get().pluginId) 9 | } 10 | 11 | rootProject.extra.apply { 12 | set("PUBLISH_GROUP_ID", Configurations.artifactGroup) 13 | set("PUBLISH_ARTIFACT_ID", "stream-webrtc-android-ui") 14 | set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) 15 | } 16 | 17 | apply(from = "${rootDir}/scripts/publish-module.gradle") 18 | 19 | android { 20 | namespace = "io.getstream.webrtc.android.ui" 21 | compileSdk = Configurations.compileSdk 22 | 23 | defaultConfig { 24 | minSdk = Configurations.minSdk 25 | } 26 | 27 | compileOptions { 28 | sourceCompatibility = JavaVersion.VERSION_11 29 | targetCompatibility = JavaVersion.VERSION_11 30 | } 31 | 32 | lint { 33 | abortOnError = false 34 | } 35 | 36 | baselineProfile { 37 | baselineProfileOutputDir = "." 38 | filter { 39 | include("io.getstream.webrtc.android.ui.**") 40 | } 41 | } 42 | } 43 | 44 | tasks.withType { 45 | kotlinOptions.freeCompilerArgs += listOf( 46 | "-Xexplicit-api=strict" 47 | ) 48 | } 49 | 50 | tasks.withType(JavaCompile::class.java).configureEach { 51 | this.targetCompatibility = libs.versions.jvmTarget.get() 52 | this.sourceCompatibility = libs.versions.jvmTarget.get() 53 | } 54 | 55 | dependencies { 56 | api(project(":stream-webrtc-android")) 57 | 58 | baselineProfile(project(":benchmark")) 59 | } -------------------------------------------------------------------------------- /stream-webrtc-android-ui/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/ContextUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | /** 16 | * Class for storing the application context and retrieving it in a static context. Similar to 17 | * org.chromium.base.ContextUtils. 18 | */ 19 | public class ContextUtils { 20 | private static final String TAG = "ContextUtils"; 21 | private static Context applicationContext; 22 | 23 | /** 24 | * Stores the application context that will be returned by getApplicationContext. This is called 25 | * by PeerConnectionFactory.initialize. The application context must be set before creating 26 | * a PeerConnectionFactory and must not be modified while it is alive. 27 | */ 28 | public static void initialize(Context applicationContext) { 29 | if (applicationContext == null) { 30 | throw new IllegalArgumentException( 31 | "Application context cannot be null for ContextUtils.initialize."); 32 | } 33 | ContextUtils.applicationContext = applicationContext; 34 | } 35 | 36 | /** 37 | * Returns the stored application context. 38 | * 39 | * @deprecated crbug.com/webrtc/8937 40 | */ 41 | @Deprecated 42 | public static Context getApplicationContext() { 43 | return applicationContext; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/LibaomAv1Decoder.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | public class LibaomAv1Decoder extends WrappedNativeVideoDecoder { 4 | public LibaomAv1Decoder() { 5 | } 6 | 7 | public long createNativeVideoDecoder() { 8 | return nativeCreateDecoder(); 9 | } 10 | 11 | static native long nativeCreateDecoder(); 12 | 13 | static native boolean nativeIsSupported(); 14 | } 15 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/Loggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.Logging.Severity; 14 | 15 | /** 16 | * Java interface for WebRTC logging. The default implementation uses webrtc.Logging. 17 | * 18 | * When injected, the Loggable will receive logging from both Java and native. 19 | */ 20 | public interface Loggable { 21 | public void onLogMessage(String message, Severity severity, String tag); 22 | } 23 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/NetworkPreference.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface NetworkPreference { 8 | int NEUTRAL = 0; 9 | int NOT_PREFERRED = -1; 10 | } 11 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/Priority.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface Priority { 8 | int VERY_LOW = 0; 9 | int LOW = 1; 10 | int MEDIUM = 2; 11 | int HIGH = 3; 12 | } 13 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/Size.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Class for representing size of an object. Very similar to android.util.Size but available on all 15 | * devices. 16 | */ 17 | public class Size { 18 | public int width; 19 | public int height; 20 | 21 | public Size(int width, int height) { 22 | this.width = width; 23 | this.height = height; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return width + "x" + height; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object other) { 33 | if (!(other instanceof Size)) { 34 | return false; 35 | } 36 | final Size otherSize = (Size) other; 37 | return width == otherSize.width && height == otherSize.height; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | // Use prime close to 2^16 to avoid collisions for normal values less than 2^16. 43 | return 1 + 65537 * width + height; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /stream-webrtc-android-utils/VideoFrameBufferType.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface VideoFrameBufferType { 8 | int NATIVE = 0; 9 | int I420 = 1; 10 | int I420A = 2; 11 | int I422 = 3; 12 | int I444 = 4; 13 | int I010 = 5; 14 | int I210 = 6; 15 | int NV12 = 7; 16 | } -------------------------------------------------------------------------------- /stream-webrtc-android-utils/WebRTCException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.webrtc 18 | 19 | /** 20 | * Represent an exception for the RTC. 21 | */ 22 | class WebRTCException(override val message: String?) : RuntimeException() 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /stream-webrtc-android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | import io.getstream.Configurations 4 | 5 | @Suppress("DSL_SCOPE_VIOLATION") 6 | plugins { 7 | id(libs.plugins.android.library.get().pluginId) 8 | id(libs.plugins.kotlin.android.get().pluginId) 9 | id(libs.plugins.baseline.profile.get().pluginId) 10 | } 11 | 12 | rootProject.extra.apply { 13 | set("PUBLISH_GROUP_ID", Configurations.artifactGroup) 14 | set("PUBLISH_ARTIFACT_ID", "stream-webrtc-android") 15 | set("PUBLISH_VERSION", rootProject.extra.get("rootVersionName")) 16 | } 17 | 18 | apply(from ="${rootDir}/scripts/publish-module.gradle") 19 | 20 | android { 21 | namespace = "org.webrtc" 22 | compileSdk = Configurations.compileSdk 23 | 24 | defaultConfig { 25 | minSdk = Configurations.minSdk 26 | consumerProguardFiles("consumer-rules.pro") 27 | } 28 | 29 | sourceSets { 30 | getByName("main") { 31 | jniLibs.srcDir("libs") 32 | } 33 | } 34 | 35 | lint { 36 | abortOnError = false 37 | } 38 | 39 | compileOptions { 40 | sourceCompatibility = JavaVersion.VERSION_11 41 | targetCompatibility = JavaVersion.VERSION_11 42 | } 43 | 44 | baselineProfile { 45 | baselineProfileOutputDir = "." 46 | filter { 47 | include("org.webrtc.**") 48 | } 49 | } 50 | } 51 | 52 | tasks.withType(JavaCompile::class.java).configureEach { 53 | this.targetCompatibility = libs.versions.jvmTarget.get() 54 | this.sourceCompatibility = libs.versions.jvmTarget.get() 55 | } 56 | 57 | dependencies { 58 | implementation(libs.androidx.annotation) 59 | 60 | baselineProfile(project(":benchmark")) 61 | } -------------------------------------------------------------------------------- /stream-webrtc-android/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | # defines consumer proguard rules for org.webrt 2 | -keep class org.webrtc.** { *; } -------------------------------------------------------------------------------- /stream-webrtc-android/libs/arm64-v8a/libjingle_peerconnection_so.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android/libs/arm64-v8a/libjingle_peerconnection_so.so -------------------------------------------------------------------------------- /stream-webrtc-android/libs/armeabi-v7a/libjingle_peerconnection_so.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android/libs/armeabi-v7a/libjingle_peerconnection_so.so -------------------------------------------------------------------------------- /stream-webrtc-android/libs/x86/libjingle_peerconnection_so.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android/libs/x86/libjingle_peerconnection_so.so -------------------------------------------------------------------------------- /stream-webrtc-android/libs/x86_64/libjingle_peerconnection_so.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GetStream/webrtc-android/7969934920f9f6f6d662a56cf655d1e80ecb1915/stream-webrtc-android/libs/x86_64/libjingle_peerconnection_so.so -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AddIceObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface to handle completion of addIceCandidate */ 14 | public interface AddIceObserver { 15 | /** Called when ICE candidate added successfully.*/ 16 | @CalledByNative public void onAddSuccess(); 17 | 18 | /** Called when ICE candidate addition failed.*/ 19 | @CalledByNative public void onAddFailure(String error); 20 | } 21 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AudioDecoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::AudioDecoderFactory}. 15 | */ 16 | public interface AudioDecoderFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::AudioDecoderFactory}. The caller takes ownership. 19 | */ 20 | long createNativeAudioDecoderFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AudioEncoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::AudioEncoderFactory}. 15 | */ 16 | public interface AudioEncoderFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::AudioEncoderFactory}. The caller takes ownership. 19 | */ 20 | long createNativeAudioEncoderFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AudioProcessingFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::AudioProcessing instances. */ 14 | public interface AudioProcessingFactory { 15 | /** 16 | * Dynamically allocates a webrtc::AudioProcessing instance and returns a pointer to it. 17 | * The caller takes ownership of the object. 18 | */ 19 | public long createNative(); 20 | } 21 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AudioSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Java wrapper for a C++ AudioSourceInterface. Used as the source for one or 15 | * more {@code AudioTrack} objects. 16 | */ 17 | public class AudioSource extends MediaSource { 18 | public AudioSource(long nativeSource) { 19 | super(nativeSource); 20 | } 21 | 22 | /** Returns a pointer to webrtc::AudioSourceInterface. */ 23 | long getNativeAudioSource() { 24 | return getNativeMediaSource(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/AudioTrackSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | /** 16 | * Java version of rtc::AudioTrackSinkInterface. 17 | */ 18 | public interface AudioTrackSink { 19 | /** 20 | * Implementations should copy the audio data into a local copy if they wish 21 | * to use the data after this function returns. 22 | */ 23 | @CalledByNative 24 | void onData(ByteBuffer audioData, int bitsPerSample, int sampleRate, 25 | int numberOfChannels, int numberOfFrames, 26 | long absoluteCaptureTimestampMs); 27 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/BaseBitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** BitrateAdjuster that tracks bitrate and framerate but does not adjust them. */ 14 | class BaseBitrateAdjuster implements BitrateAdjuster { 15 | protected int targetBitrateBps; 16 | protected double targetFramerateFps; 17 | 18 | @Override 19 | public void setTargets(int targetBitrateBps, double targetFramerateFps) { 20 | this.targetBitrateBps = targetBitrateBps; 21 | this.targetFramerateFps = targetFramerateFps; 22 | } 23 | 24 | @Override 25 | public void reportEncodedFrame(int size) { 26 | // No op. 27 | } 28 | 29 | @Override 30 | public int getAdjustedBitrateBps() { 31 | return targetBitrateBps; 32 | } 33 | 34 | @Override 35 | public double getAdjustedFramerateFps() { 36 | return targetFramerateFps; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/BitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Object that adjusts the bitrate of a hardware codec. */ 14 | interface BitrateAdjuster { 15 | /** 16 | * Sets the target bitrate in bits per second and framerate in frames per second. 17 | */ 18 | void setTargets(int targetBitrateBps, double targetFramerateFps); 19 | 20 | /** 21 | * Should be used to report the size of an encoded frame to the bitrate adjuster. Use 22 | * getAdjustedBitrateBps to get the updated bitrate after calling this method. 23 | */ 24 | void reportEncodedFrame(int size); 25 | 26 | /** Gets the current bitrate. */ 27 | int getAdjustedBitrateBps(); 28 | 29 | /** Gets the current framerate. */ 30 | double getAdjustedFramerateFps(); 31 | } 32 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/BuiltinAudioDecoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Creates a native {@code webrtc::AudioDecoderFactory} with the builtin audio decoders. 15 | */ 16 | public class BuiltinAudioDecoderFactoryFactory implements AudioDecoderFactoryFactory { 17 | @Override 18 | public long createNativeAudioDecoderFactory() { 19 | return nativeCreateBuiltinAudioDecoderFactory(); 20 | } 21 | 22 | private static native long nativeCreateBuiltinAudioDecoderFactory(); 23 | } 24 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/BuiltinAudioEncoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * This class creates a native {@code webrtc::AudioEncoderFactory} with the builtin audio encoders. 15 | */ 16 | public class BuiltinAudioEncoderFactoryFactory implements AudioEncoderFactoryFactory { 17 | @Override 18 | public long createNativeAudioEncoderFactory() { 19 | return nativeCreateBuiltinAudioEncoderFactory(); 20 | } 21 | 22 | private static native long nativeCreateBuiltinAudioEncoderFactory(); 23 | } 24 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CallSessionFileRotatingLogSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class CallSessionFileRotatingLogSink { 14 | private long nativeSink; 15 | 16 | public static byte[] getLogData(String dirPath) { 17 | if (dirPath == null) { 18 | throw new IllegalArgumentException("dirPath may not be null."); 19 | } 20 | return nativeGetLogData(dirPath); 21 | } 22 | 23 | public CallSessionFileRotatingLogSink( 24 | String dirPath, int maxFileSize, Logging.Severity severity) { 25 | if (dirPath == null) { 26 | throw new IllegalArgumentException("dirPath may not be null."); 27 | } 28 | nativeSink = nativeAddSink(dirPath, maxFileSize, severity.ordinal()); 29 | } 30 | 31 | public void dispose() { 32 | if (nativeSink != 0) { 33 | nativeDeleteSink(nativeSink); 34 | nativeSink = 0; 35 | } 36 | } 37 | 38 | private static native long nativeAddSink(String dirPath, int maxFileSize, int severity); 39 | private static native void nativeDeleteSink(long sink); 40 | private static native byte[] nativeGetLogData(String dirPath); 41 | } 42 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CalledByNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.lang.annotation.ElementType; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | * @CalledByNative is used by the JNI generator to create the necessary JNI 20 | * bindings and expose this method to native code. 21 | */ 22 | @Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) 23 | @Retention(RetentionPolicy.CLASS) 24 | public @interface CalledByNative { 25 | /* 26 | * If present, tells which inner class the method belongs to. 27 | */ 28 | public String value() default ""; 29 | } 30 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CalledByNativeUnchecked.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.lang.annotation.ElementType; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | * @CalledByNativeUnchecked is used to generate JNI bindings that do not check for exceptions. 20 | * It only makes sense to use this annotation on methods that declare a throws... spec. 21 | * However, note that the exception received native side maybe an 'unchecked' (RuntimeExpception) 22 | * such as NullPointerException, so the native code should differentiate these cases. 23 | * Usage of this should be very rare; where possible handle exceptions in the Java side and use a 24 | * return value to indicate success / failure. 25 | */ 26 | @Target(ElementType.METHOD) 27 | @Retention(RetentionPolicy.CLASS) 28 | public @interface CalledByNativeUnchecked { 29 | /* 30 | * If present, tells which inner class the method belongs to. 31 | */ 32 | public String value() default ""; 33 | } 34 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Camera1Capturer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | public class Camera1Capturer extends CameraCapturer { 16 | private final boolean captureToTexture; 17 | 18 | public Camera1Capturer( 19 | String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) { 20 | super(cameraName, eventsHandler, new Camera1Enumerator(captureToTexture)); 21 | 22 | this.captureToTexture = captureToTexture; 23 | } 24 | 25 | @Override 26 | protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, 27 | CameraSession.Events events, Context applicationContext, 28 | SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, 29 | int framerate) { 30 | Camera1Session.create(createSessionCallback, events, captureToTexture, applicationContext, 31 | surfaceTextureHelper, cameraName, width, height, framerate); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Camera2Capturer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | import android.hardware.camera2.CameraManager; 15 | import androidx.annotation.Nullable; 16 | 17 | public class Camera2Capturer extends CameraCapturer { 18 | private final Context context; 19 | @Nullable private final CameraManager cameraManager; 20 | 21 | public Camera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler) { 22 | super(cameraName, eventsHandler, new Camera2Enumerator(context)); 23 | 24 | this.context = context; 25 | cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); 26 | } 27 | 28 | @Override 29 | protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, 30 | CameraSession.Events events, Context applicationContext, 31 | SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, 32 | int framerate) { 33 | Camera2Session.create(createSessionCallback, events, applicationContext, cameraManager, 34 | surfaceTextureHelper, cameraName, width, height, framerate); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CameraEnumerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.CameraEnumerationAndroid.CaptureFormat; 14 | 15 | import java.util.List; 16 | 17 | public interface CameraEnumerator { 18 | public String[] getDeviceNames(); 19 | public boolean isFrontFacing(String deviceName); 20 | public boolean isBackFacing(String deviceName); 21 | public List getSupportedFormats(String deviceName); 22 | 23 | public CameraVideoCapturer createCapturer( 24 | String deviceName, CameraVideoCapturer.CameraEventsHandler eventsHandler); 25 | } 26 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CandidatePairChangeEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Representation of a change in selected ICE candidate pair. 15 | * {@code CandidatePairChangeEvent} in the C++ API. 16 | */ 17 | public final class CandidatePairChangeEvent { 18 | public final IceCandidate local; 19 | public final IceCandidate remote; 20 | public final int lastDataReceivedMs; 21 | public final String reason; 22 | 23 | /** 24 | * An estimate from the ICE stack on how long it was disconnected before 25 | * changing to the new candidate pair in this event. 26 | * The first time an candidate pair is signaled the value will be 0. 27 | */ 28 | public final int estimatedDisconnectedTimeMs; 29 | 30 | @CalledByNative 31 | CandidatePairChangeEvent(IceCandidate local, IceCandidate remote, int lastDataReceivedMs, 32 | String reason, int estimatedDisconnectedTimeMs) { 33 | this.local = local; 34 | this.remote = remote; 35 | this.lastDataReceivedMs = lastDataReceivedMs; 36 | this.reason = reason; 37 | this.estimatedDisconnectedTimeMs = estimatedDisconnectedTimeMs; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/CapturerObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for observering a capturer. Passed to {@link VideoCapturer#initialize}. Provided by 15 | * {@link VideoSource#getCapturerObserver}. 16 | * 17 | * All callbacks must be executed on a single thread. 18 | */ 19 | public interface CapturerObserver { 20 | /** Notify if the capturer have been started successfully or not. */ 21 | void onCapturerStarted(boolean success); 22 | /** Notify that the capturer has been stopped. */ 23 | void onCapturerStopped(); 24 | 25 | /** Delivers a captured frame. */ 26 | void onFrameCaptured(VideoFrame frame); 27 | } 28 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/ContextUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | /** 16 | * Class for storing the application context and retrieving it in a static context. Similar to 17 | * org.chromium.base.ContextUtils. 18 | */ 19 | public class ContextUtils { 20 | private static final String TAG = "ContextUtils"; 21 | private static Context applicationContext; 22 | 23 | /** 24 | * Stores the application context that will be returned by getApplicationContext. This is called 25 | * by PeerConnectionFactory.initialize. The application context must be set before creating 26 | * a PeerConnectionFactory and must not be modified while it is alive. 27 | */ 28 | public static void initialize(Context applicationContext) { 29 | if (applicationContext == null) { 30 | throw new IllegalArgumentException( 31 | "Application context cannot be null for ContextUtils.initialize."); 32 | } 33 | ContextUtils.applicationContext = applicationContext; 34 | } 35 | 36 | /** 37 | * Returns the stored application context. 38 | * 39 | * @deprecated crbug.com/webrtc/8937 40 | */ 41 | @Deprecated 42 | public static Context getApplicationContext() { 43 | return applicationContext; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Dav1dDecoder.java: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 4 | * 5 | * Use of this source code is governed by a BSD-style license 6 | * that can be found in the LICENSE file in the root of the source 7 | * tree. An additional intellectual property rights grant can be found 8 | * in the file PATENTS. All contributing project authors may 9 | * be found in the AUTHORS file in the root of the source tree. 10 | */ 11 | 12 | package org.webrtc; 13 | 14 | public class Dav1dDecoder extends WrappedNativeVideoDecoder { 15 | @Override 16 | public long createNative(long webrtcEnvRef) { 17 | return nativeCreateDecoder(); 18 | } 19 | 20 | static native long nativeCreateDecoder(); 21 | } 22 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/EglBase10.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import javax.microedition.khronos.egl.EGL10; 14 | import javax.microedition.khronos.egl.EGLConfig; 15 | import javax.microedition.khronos.egl.EGLContext; 16 | import javax.microedition.khronos.egl.EGLDisplay; 17 | 18 | /** EGL 1.0 implementation of EglBase. */ 19 | public interface EglBase10 extends EglBase { 20 | interface Context extends EglBase.Context { 21 | EGLContext getRawContext(); 22 | } 23 | 24 | interface EglConnection extends EglBase.EglConnection { 25 | EGL10 getEgl(); 26 | 27 | EGLContext getContext(); 28 | 29 | EGLDisplay getDisplay(); 30 | 31 | EGLConfig getConfig(); 32 | } 33 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/EglBase14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.opengl.EGLConfig; 14 | import android.opengl.EGLContext; 15 | import android.opengl.EGLDisplay; 16 | 17 | /** EGL 1.4 implementation of EglBase. */ 18 | public interface EglBase14 extends EglBase { 19 | interface Context extends EglBase.Context { 20 | EGLContext getRawContext(); 21 | } 22 | 23 | interface EglConnection extends EglBase.EglConnection { 24 | EGLContext getContext(); 25 | 26 | EGLDisplay getDisplay(); 27 | 28 | EGLConfig getConfig(); 29 | } 30 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Empty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Empty class for use in libjingle_peerconnection_java because all targets require at least one 15 | * Java file. 16 | */ 17 | class Empty {} 18 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/FecControllerFactoryFactoryInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Factory for creating webrtc::FecControllerFactory instances. 15 | */ 16 | public interface FecControllerFactoryFactoryInterface { 17 | /** 18 | * Dynamically allocates a webrtc::FecControllerFactory instance and returns a pointer to it. 19 | * The caller takes ownership of the object. 20 | */ 21 | public long createNative(); 22 | } 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/FrameCryptorAlgorithm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 LiveKit 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.webrtc; 18 | 19 | public enum FrameCryptorAlgorithm { 20 | AES_GCM, 21 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/FrameDecryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The FrameDecryptor interface allows Java API users to provide a 15 | * pointer to their native implementation of the FrameDecryptorInterface. 16 | * FrameDecryptors are extremely performance sensitive as they must process all 17 | * incoming video and audio frames. Due to this reason they should always be 18 | * backed by a native implementation 19 | * @note Not ready for production use. 20 | */ 21 | public interface FrameDecryptor { 22 | /** 23 | * @return A FrameDecryptorInterface pointer. 24 | */ 25 | long getNativeFrameDecryptor(); 26 | } 27 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/FrameEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The FrameEncryptor interface allows Java API users to provide a pointer to 15 | * their native implementation of the FrameEncryptorInterface. 16 | * FrameEncyptors are extremely performance sensitive as they must process all 17 | * outgoing video and audio frames. Due to this reason they should always be 18 | * backed by a native implementation. 19 | * @note Not ready for production use. 20 | */ 21 | public interface FrameEncryptor { 22 | /** 23 | * @return A FrameEncryptorInterface pointer. 24 | */ 25 | long getNativeFrameEncryptor(); 26 | } 27 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/FramerateBitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * BitrateAdjuster that adjusts the bitrate to compensate for changes in the framerate. Used with 15 | * hardware codecs that assume the framerate never changes. 16 | */ 17 | class FramerateBitrateAdjuster extends BaseBitrateAdjuster { 18 | private static final int DEFAULT_FRAMERATE_FPS = 30; 19 | 20 | @Override 21 | public void setTargets(int targetBitrateBps, double targetFramerateFps) { 22 | // Keep frame rate unchanged and adjust bit rate. 23 | this.targetFramerateFps = DEFAULT_FRAMERATE_FPS; 24 | this.targetBitrateBps = (int) (targetBitrateBps * DEFAULT_FRAMERATE_FPS / targetFramerateFps); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/GlRectDrawer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Simplest possible GL shader that just draws frames as opaque quads. */ 14 | public class GlRectDrawer extends GlGenericDrawer { 15 | private static final String FRAGMENT_SHADER = "void main() {\n" 16 | + " gl_FragColor = sample(tc);\n" 17 | + "}\n"; 18 | 19 | private static class ShaderCallbacks implements GlGenericDrawer.ShaderCallbacks { 20 | @Override 21 | public void onNewShader(GlShader shader) {} 22 | 23 | @Override 24 | public void onPrepareShader(GlShader shader, float[] texMatrix, int frameWidth, int frameHeight, 25 | int viewportWidth, int viewportHeight) {} 26 | } 27 | 28 | public GlRectDrawer() { 29 | super(FRAGMENT_SHADER, new ShaderCallbacks()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/HardwareVideoEncoderWrapperFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2024 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.webrtc; 17 | 18 | /** 19 | * Original source: https://github.com/shiguredo/sora-android-sdk/blob/3cc88e806ab2f2327bf304207 20 | * 2e98d6da9df4408/sora-android-sdk/src/main/kotlin/jp/shiguredo/sora/sdk/codec/HardwareVideoEnco 21 | * derWrapperFactory.kt 22 | */ 23 | class HardwareVideoEncoderWrapperFactory implements VideoEncoderFactory { 24 | 25 | private static final String TAG = "HardwareVideoEncoderWrapperFactory"; 26 | 27 | private final HardwareVideoEncoderFactory factory; 28 | private final int resolutionPixelAlignment; 29 | 30 | public HardwareVideoEncoderWrapperFactory(HardwareVideoEncoderFactory factory, int resolutionPixelAlignment) { 31 | this.factory = factory; 32 | this.resolutionPixelAlignment = resolutionPixelAlignment; 33 | if (resolutionPixelAlignment == 0) { 34 | throw new IllegalArgumentException("resolutionPixelAlignment should not be 0"); 35 | } 36 | } 37 | 38 | @Override 39 | public VideoEncoder createEncoder(VideoCodecInfo videoCodecInfo) { 40 | try { 41 | VideoEncoder encoder = factory.createEncoder(videoCodecInfo); 42 | if (encoder == null) { 43 | return null; 44 | } 45 | return new HardwareVideoEncoderWrapper(encoder, resolutionPixelAlignment); 46 | } catch (Exception e) { 47 | Logging.e(TAG, "createEncoder failed", e); 48 | return null; 49 | } 50 | } 51 | 52 | @Override 53 | public VideoCodecInfo[] getSupportedCodecs() { 54 | return factory.getSupportedCodecs(); 55 | } 56 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Histogram.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Class for holding the native pointer of a histogram. Since there is no way to destroy a 15 | * histogram, please don't create unnecessary instances of this object. This class is thread safe. 16 | * 17 | * Usage example: 18 | * private static final Histogram someMetricHistogram = 19 | * Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50); 20 | * someMetricHistogram.addSample(someVariable); 21 | */ 22 | class Histogram { 23 | private final long handle; 24 | 25 | private Histogram(long handle) { 26 | this.handle = handle; 27 | } 28 | 29 | static public Histogram createCounts(String name, int min, int max, int bucketCount) { 30 | return new Histogram(nativeCreateCounts(name, min, max, bucketCount)); 31 | } 32 | 33 | static public Histogram createEnumeration(String name, int max) { 34 | return new Histogram(nativeCreateEnumeration(name, max)); 35 | } 36 | 37 | public void addSample(int sample) { 38 | nativeAddSample(handle, sample); 39 | } 40 | 41 | private static native long nativeCreateCounts(String name, int min, int max, int bucketCount); 42 | private static native long nativeCreateEnumeration(String name, int max); 43 | private static native void nativeAddSample(long handle, int sample); 44 | } 45 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/IceCandidateErrorEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public final class IceCandidateErrorEvent { 14 | /** The local IP address used to communicate with the STUN or TURN server. */ 15 | public final String address; 16 | /** The port used to communicate with the STUN or TURN server. */ 17 | public final int port; 18 | /** 19 | * The STUN or TURN URL that identifies the STUN or TURN server for which the failure occurred. 20 | */ 21 | public final String url; 22 | /** 23 | * The numeric STUN error code returned by the STUN or TURN server. If no host candidate can reach 24 | * the server, errorCode will be set to the value 701 which is outside the STUN error code range. 25 | * This error is only fired once per server URL while in the RTCIceGatheringState of "gathering". 26 | */ 27 | public final int errorCode; 28 | /** 29 | * The STUN reason text returned by the STUN or TURN server. If the server could not be reached, 30 | * errorText will be set to an implementation-specific value providing details about the error. 31 | */ 32 | public final String errorText; 33 | 34 | @CalledByNative 35 | public IceCandidateErrorEvent( 36 | String address, int port, String url, int errorCode, String errorText) { 37 | this.address = address; 38 | this.port = port; 39 | this.url = url; 40 | this.errorCode = errorCode; 41 | this.errorText = errorText; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/JNILogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.CalledByNative; 14 | import org.webrtc.Loggable; 15 | import org.webrtc.Logging.Severity; 16 | 17 | class JNILogging { 18 | private final Loggable loggable; 19 | 20 | public JNILogging(Loggable loggable) { 21 | this.loggable = loggable; 22 | } 23 | 24 | @CalledByNative 25 | public void logToInjectable(String message, Integer severity, String tag) { 26 | loggable.onLogMessage(message, Severity.values()[severity], tag); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/JniCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | /** Class with static JNI helper functions that are used in many places. */ 16 | public class JniCommon { 17 | /** Functions to increment/decrement an rtc::RefCountInterface pointer. */ 18 | public static native void nativeAddRef(long refCountedPointer); 19 | public static native void nativeReleaseRef(long refCountedPointer); 20 | 21 | public static native ByteBuffer nativeAllocateByteBuffer(int size); 22 | public static native void nativeFreeByteBuffer(ByteBuffer buffer); 23 | } 24 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/JniHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.io.UnsupportedEncodingException; 14 | import java.util.Map; 15 | 16 | /** 17 | * This class is only used from jni_helper.cc to give some Java functionality that were not possible 18 | * to generate in other ways due to bugs.webrtc.org/8606 and bugs.webrtc.org/8632. 19 | */ 20 | class JniHelper { 21 | // TODO(bugs.webrtc.org/8632): Remove. 22 | @CalledByNative 23 | static byte[] getStringBytes(String s) { 24 | try { 25 | return s.getBytes("ISO-8859-1"); 26 | } catch (UnsupportedEncodingException e) { 27 | throw new RuntimeException("ISO-8859-1 is unsupported"); 28 | } 29 | } 30 | 31 | // TODO(bugs.webrtc.org/8632): Remove. 32 | @CalledByNative 33 | static Object getStringClass() { 34 | return String.class; 35 | } 36 | 37 | // TODO(bugs.webrtc.org/8606): Remove. 38 | @CalledByNative 39 | static Object getKey(Map.Entry entry) { 40 | return entry.getKey(); 41 | } 42 | 43 | // TODO(bugs.webrtc.org/8606): Remove. 44 | @CalledByNative 45 | static Object getValue(Map.Entry entry) { 46 | return entry.getValue(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/LibaomAv1Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | import java.util.List; 13 | 14 | public class LibaomAv1Encoder extends WrappedNativeVideoEncoder { 15 | @Override 16 | public long createNative(long webrtcEnvRef) { 17 | return nativeCreate(webrtcEnvRef); 18 | } 19 | 20 | static native long nativeCreate(long webrtcEnvRef); 21 | 22 | @Override 23 | public boolean isHardwareEncoder() { 24 | return false; 25 | } 26 | 27 | static List scalabilityModes() { 28 | return nativeGetSupportedScalabilityModes(); 29 | } 30 | 31 | static native List nativeGetSupportedScalabilityModes(); 32 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/LibvpxVp8Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp8Decoder extends WrappedNativeVideoDecoder { 14 | @Override 15 | public long createNative(long webrtcEnvRef) { 16 | return nativeCreateDecoder(webrtcEnvRef); 17 | } 18 | 19 | static native long nativeCreateDecoder(long webrtcEnvRef); 20 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/LibvpxVp8Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp8Encoder extends WrappedNativeVideoEncoder { 14 | @Override 15 | public long createNative(long webrtcEnvRef) { 16 | return nativeCreate(webrtcEnvRef); 17 | } 18 | 19 | static native long nativeCreate(long webrtcEnvRef); 20 | 21 | @Override 22 | public boolean isHardwareEncoder() { 23 | return false; 24 | } 25 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/LibvpxVp9Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp9Decoder extends WrappedNativeVideoDecoder { 14 | @Override 15 | public long createNative(long webrtcEnvRef) { 16 | return nativeCreateDecoder(); 17 | } 18 | 19 | static native long nativeCreateDecoder(); 20 | 21 | static native boolean nativeIsSupported(); 22 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/LibvpxVp9Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | import java.util.List; 13 | 14 | public class LibvpxVp9Encoder extends WrappedNativeVideoEncoder { 15 | @Override 16 | public long createNative(long webrtcEnvRef) { 17 | return nativeCreate(webrtcEnvRef); 18 | } 19 | 20 | static native long nativeCreate(long webrtcEnvRef); 21 | 22 | @Override 23 | public boolean isHardwareEncoder() { 24 | return false; 25 | } 26 | 27 | static native boolean nativeIsSupported(); 28 | 29 | static List scalabilityModes() { 30 | return nativeGetSupportedScalabilityModes(); 31 | } 32 | 33 | static native List nativeGetSupportedScalabilityModes(); 34 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Loggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.Logging.Severity; 14 | 15 | /** 16 | * Java interface for WebRTC logging. The default implementation uses webrtc.Logging. 17 | * 18 | * When injected, the Loggable will receive logging from both Java and native. 19 | */ 20 | public interface Loggable { 21 | public void onLogMessage(String message, Severity severity, String tag); 22 | } 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/ManagedAudioProcessingFactory.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | /* 4 | * Copyright 2024 The WebRTC project authors. All Rights Reserved. 5 | * 6 | * Use of this source code is governed by a BSD-style license 7 | * that can be found in the LICENSE file in the root of the source 8 | * tree. An additional intellectual property rights grant can be found 9 | * in the file PATENTS. All contributing project authors may 10 | * be found in the AUTHORS file in the root of the source tree. 11 | */ 12 | 13 | /** AudioProcessing factory with lifecycle management and runtime control capabilities. */ 14 | public interface ManagedAudioProcessingFactory extends AudioProcessingFactory { 15 | /** 16 | * Destroys the native AudioProcessing instance. 17 | */ 18 | public void destroyNative(); 19 | 20 | /** 21 | * Checks if the AudioProcessing is enabled. 22 | * @return true if enabled, false otherwise. 23 | */ 24 | public boolean isEnabled(); 25 | 26 | /** 27 | * Sets the enabled state of the AudioProcessing. 28 | * @param enabled The desired enabled state. 29 | */ 30 | public void setEnabled(boolean enabled); 31 | } 32 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/MediaCodecWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.media.MediaCodec; 14 | import android.media.MediaCodecInfo; 15 | import android.media.MediaCrypto; 16 | import android.media.MediaFormat; 17 | import android.os.Bundle; 18 | import android.view.Surface; 19 | import java.nio.ByteBuffer; 20 | 21 | /** 22 | * Subset of methods defined in {@link android.media.MediaCodec} needed by 23 | * {@link HardwareVideoEncoder} and {@link AndroidVideoDecoder}. This interface 24 | * exists to allow mocking and using a fake implementation in tests. 25 | */ 26 | interface MediaCodecWrapper { 27 | void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags); 28 | 29 | void start(); 30 | 31 | void flush(); 32 | 33 | void stop(); 34 | 35 | void release(); 36 | 37 | int dequeueInputBuffer(long timeoutUs); 38 | 39 | void queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags); 40 | 41 | int dequeueOutputBuffer(MediaCodec.BufferInfo info, long timeoutUs); 42 | 43 | void releaseOutputBuffer(int index, boolean render); 44 | 45 | MediaFormat getInputFormat(); 46 | 47 | MediaFormat getOutputFormat(); 48 | 49 | MediaFormat getOutputFormat(int index); 50 | 51 | ByteBuffer getInputBuffer(int index); 52 | 53 | ByteBuffer getOutputBuffer(int index); 54 | 55 | Surface createInputSurface(); 56 | 57 | void setParameters(Bundle params); 58 | 59 | MediaCodecInfo getCodecInfo(); 60 | } 61 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/MediaCodecWrapperFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.io.IOException; 14 | 15 | interface MediaCodecWrapperFactory { 16 | /** 17 | * Creates a new {@link MediaCodecWrapper} by codec name. 18 | * 19 | *

For additional information see {@link android.media.MediaCodec#createByCodecName}. 20 | */ 21 | MediaCodecWrapper createByCodecName(String name) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/MediaSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Java wrapper for a C++ MediaSourceInterface. */ 14 | public class MediaSource { 15 | /** Tracks MediaSourceInterface.SourceState */ 16 | public enum State { 17 | INITIALIZING, 18 | LIVE, 19 | ENDED, 20 | MUTED; 21 | 22 | @CalledByNative("State") 23 | static State fromNativeIndex(int nativeIndex) { 24 | return values()[nativeIndex]; 25 | } 26 | } 27 | 28 | private final RefCountDelegate refCountDelegate; 29 | private long nativeSource; 30 | 31 | public MediaSource(long nativeSource) { 32 | refCountDelegate = new RefCountDelegate(() -> JniCommon.nativeReleaseRef(nativeSource)); 33 | this.nativeSource = nativeSource; 34 | } 35 | 36 | public State state() { 37 | checkMediaSourceExists(); 38 | return nativeGetState(nativeSource); 39 | } 40 | 41 | public void dispose() { 42 | checkMediaSourceExists(); 43 | refCountDelegate.release(); 44 | nativeSource = 0; 45 | } 46 | 47 | /** Returns a pointer to webrtc::MediaSourceInterface. */ 48 | protected long getNativeMediaSource() { 49 | checkMediaSourceExists(); 50 | return nativeSource; 51 | } 52 | 53 | /** 54 | * Runs code in {@code runnable} holding a reference to the media source. If the object has 55 | * already been released, does nothing. 56 | */ 57 | void runWithReference(Runnable runnable) { 58 | if (refCountDelegate.safeRetain()) { 59 | try { 60 | runnable.run(); 61 | } finally { 62 | refCountDelegate.release(); 63 | } 64 | } 65 | } 66 | 67 | private void checkMediaSourceExists() { 68 | if (nativeSource == 0) { 69 | throw new IllegalStateException("MediaSource has been disposed."); 70 | } 71 | } 72 | 73 | private static native State nativeGetState(long pointer); 74 | } 75 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NativeCapturerObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.VideoFrame; 14 | 15 | /** 16 | * Used from native api and implements a simple VideoCapturer.CapturerObserver that feeds frames to 17 | * a webrtc::jni::AndroidVideoTrackSource. 18 | */ 19 | class NativeCapturerObserver implements CapturerObserver { 20 | private final NativeAndroidVideoTrackSource nativeAndroidVideoTrackSource; 21 | 22 | @CalledByNative 23 | public NativeCapturerObserver(long nativeSource) { 24 | this.nativeAndroidVideoTrackSource = new NativeAndroidVideoTrackSource(nativeSource); 25 | } 26 | 27 | @Override 28 | public void onCapturerStarted(boolean success) { 29 | nativeAndroidVideoTrackSource.setState(success); 30 | } 31 | 32 | @Override 33 | public void onCapturerStopped() { 34 | nativeAndroidVideoTrackSource.setState(/* isLive= */ false); 35 | } 36 | 37 | @Override 38 | public void onFrameCaptured(VideoFrame frame) { 39 | final VideoProcessor.FrameAdaptationParameters parameters = 40 | nativeAndroidVideoTrackSource.adaptFrame(frame); 41 | if (parameters == null) { 42 | // Drop frame. 43 | return; 44 | } 45 | 46 | final VideoFrame.Buffer adaptedBuffer = 47 | frame.getBuffer().cropAndScale(parameters.cropX, parameters.cropY, parameters.cropWidth, 48 | parameters.cropHeight, parameters.scaleWidth, parameters.scaleHeight); 49 | nativeAndroidVideoTrackSource.onFrameCaptured( 50 | new VideoFrame(adaptedBuffer, frame.getRotation(), parameters.timestampNs)); 51 | adaptedBuffer.release(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NativeExternalAudioProcessingFactory.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | public class NativeExternalAudioProcessingFactory implements AudioProcessingFactory { 4 | 5 | private final String libname; 6 | 7 | public NativeExternalAudioProcessingFactory(String libname) { 8 | if (libname == null) { 9 | throw new NullPointerException("libname must not be null."); 10 | } 11 | if (libname.isEmpty()) { 12 | throw new IllegalArgumentException("libname must not be empty."); 13 | } 14 | this.libname = libname; 15 | } 16 | 17 | @Override 18 | public long createNative() { 19 | return nativeCreateAudioProcessingModule(libname); 20 | } 21 | 22 | public void destroyNative() { 23 | nativeDestroyAudioProcessingModule(); 24 | } 25 | 26 | private static native long nativeCreateAudioProcessingModule(String libname); 27 | 28 | 29 | private static native void nativeDestroyAudioProcessingModule(); 30 | 31 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NativeLibrary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | class NativeLibrary { 14 | private static String TAG = "NativeLibrary"; 15 | 16 | static class DefaultLoader implements NativeLibraryLoader { 17 | @Override 18 | public boolean load(String name) { 19 | Logging.d(TAG, "Loading library: " + name); 20 | System.loadLibrary(name); 21 | 22 | // Not relevant, but kept for API compatibility. 23 | return true; 24 | } 25 | } 26 | 27 | private static Object lock = new Object(); 28 | private static boolean libraryLoaded; 29 | 30 | /** 31 | * Loads the native library. Clients should call PeerConnectionFactory.initialize. It will call 32 | * this method for them. 33 | */ 34 | static void initialize(NativeLibraryLoader loader, String libraryName) { 35 | synchronized (lock) { 36 | if (libraryLoaded) { 37 | Logging.d(TAG, "Native library has already been loaded."); 38 | return; 39 | } 40 | Logging.d(TAG, "Loading native library: " + libraryName); 41 | libraryLoaded = loader.load(libraryName); 42 | } 43 | } 44 | 45 | /** Returns true if the library has been loaded successfully. */ 46 | static boolean isLoaded() { 47 | synchronized (lock) { 48 | return libraryLoaded; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NativeLibraryLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for loading native libraries. A custom loader can be passed to 15 | * PeerConnectionFactory.initialize. 16 | */ 17 | public interface NativeLibraryLoader { 18 | /** 19 | * Loads a native library with the given name. 20 | * 21 | * @return True on success 22 | */ 23 | boolean load(String name); 24 | } 25 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NativePeerConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::jni::OwnedPeerConnection instances. */ 14 | public interface NativePeerConnectionFactory { 15 | /** 16 | * Create a new webrtc::jni::OwnedPeerConnection instance and returns a pointer to it. 17 | * The caller takes ownership of the object. 18 | */ 19 | long createNativePeerConnection(); 20 | } 21 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NetEqFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::NetEqFactory}. 15 | */ 16 | public interface NetEqFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::NetEqFactory}. The caller takes ownership. 19 | */ 20 | long createNativeNetEqFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NetworkChangeDetectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | public interface NetworkChangeDetectorFactory { 16 | public NetworkChangeDetector create(NetworkChangeDetector.Observer observer, Context context); 17 | } 18 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NetworkControllerFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::NetworkControllerFactory instances. */ 14 | public interface NetworkControllerFactoryFactory { 15 | /** 16 | * Dynamically allocates a webrtc::NetworkControllerFactory instance and returns a pointer to 17 | * it. The caller takes ownership of the object. 18 | */ 19 | public long createNativeNetworkControllerFactory(); 20 | } 21 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NetworkPreference.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface NetworkPreference { 8 | int NEUTRAL = 0; 9 | int NOT_PREFERRED = -1; 10 | } 11 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/NetworkStatePredictorFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::NetworkStatePredictorFactory instances. */ 14 | public interface NetworkStatePredictorFactoryFactory { 15 | /** 16 | * Dynamically allocates a webrtc::NetworkStatePredictorFactory instance and returns a pointer to 17 | * it. The caller takes ownership of the object. 18 | */ 19 | public long createNativeNetworkStatePredictorFactory(); 20 | } 21 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/OWNERS: -------------------------------------------------------------------------------- 1 | per-file Camera*=xalep@webrtc.org 2 | per-file Histogram.java=xalep@webrtc.org 3 | per-file Metrics.java=xalep@webrtc.org 4 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/PeerConnectionDependencies.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | 15 | /** 16 | * PeerConnectionDependencies holds all PeerConnection dependencies that are 17 | * applied per PeerConnection. A dependency is distinct from a configuration 18 | * as it defines significant executable code that can be provided by a user of 19 | * the API. 20 | */ 21 | public final class PeerConnectionDependencies { 22 | // Mandatory dependencies. 23 | private final PeerConnection.Observer observer; 24 | 25 | // Optional fields. 26 | private final SSLCertificateVerifier sslCertificateVerifier; 27 | 28 | public static class Builder { 29 | private PeerConnection.Observer observer; 30 | private SSLCertificateVerifier sslCertificateVerifier; 31 | 32 | private Builder(PeerConnection.Observer observer) { 33 | this.observer = observer; 34 | } 35 | 36 | public Builder setSSLCertificateVerifier(SSLCertificateVerifier sslCertificateVerifier) { 37 | this.sslCertificateVerifier = sslCertificateVerifier; 38 | return this; 39 | } 40 | 41 | // Observer is a required dependency and so is forced in the construction of the object. 42 | public PeerConnectionDependencies createPeerConnectionDependencies() { 43 | return new PeerConnectionDependencies(observer, sslCertificateVerifier); 44 | } 45 | } 46 | 47 | public static Builder builder(PeerConnection.Observer observer) { 48 | return new Builder(observer); 49 | } 50 | 51 | PeerConnection.Observer getObserver() { 52 | return observer; 53 | } 54 | 55 | @Nullable 56 | SSLCertificateVerifier getSSLCertificateVerifier() { 57 | return sslCertificateVerifier; 58 | } 59 | 60 | private PeerConnectionDependencies( 61 | PeerConnection.Observer observer, SSLCertificateVerifier sslCertificateVerifier) { 62 | this.observer = observer; 63 | this.sslCertificateVerifier = sslCertificateVerifier; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/PlatformSoftwareVideoDecoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.media.MediaCodecInfo; 14 | import androidx.annotation.Nullable; 15 | import java.util.Arrays; 16 | 17 | /** Factory for Android platform software VideoDecoders. */ 18 | public class PlatformSoftwareVideoDecoderFactory extends MediaCodecVideoDecoderFactory { 19 | /** 20 | * Default allowed predicate. 21 | */ 22 | private static final Predicate defaultAllowedPredicate = 23 | new Predicate() { 24 | @Override 25 | public boolean test(MediaCodecInfo arg) { 26 | return MediaCodecUtils.isSoftwareOnly(arg); 27 | } 28 | }; 29 | 30 | /** 31 | * Creates a PlatformSoftwareVideoDecoderFactory that supports surface texture rendering. 32 | * 33 | * @param sharedContext The textures generated will be accessible from this context. May be null, 34 | * this disables texture support. 35 | */ 36 | public PlatformSoftwareVideoDecoderFactory(@Nullable EglBase.Context sharedContext) { 37 | super(sharedContext, defaultAllowedPredicate); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Priority.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface Priority { 8 | int VERY_LOW = 0; 9 | int LOW = 1; 10 | int MEDIUM = 2; 11 | int HIGH = 3; 12 | } 13 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/RTCStatsCollectorCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for receiving stats reports (see webrtc::RTCStatsCollectorCallback). */ 14 | public interface RTCStatsCollectorCallback { 15 | /** Called when the stats report is ready. */ 16 | @CalledByNative public void onStatsDelivered(RTCStatsReport report); 17 | } 18 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/RTCStatsReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.util.Map; 14 | 15 | /** 16 | * Java version of webrtc::RTCStatsReport. Each RTCStatsReport produced by 17 | * getStats contains multiple RTCStats objects; one for each underlying object 18 | * (codec, stream, transport, etc.) that was inspected to produce the stats. 19 | */ 20 | public class RTCStatsReport { 21 | private final long timestampUs; 22 | private final Map stats; 23 | 24 | public RTCStatsReport(long timestampUs, Map stats) { 25 | this.timestampUs = timestampUs; 26 | this.stats = stats; 27 | } 28 | 29 | // Timestamp in microseconds. 30 | public double getTimestampUs() { 31 | return timestampUs; 32 | } 33 | 34 | // Map of stats object IDs to stats objects. Can be used to easily look up 35 | // other stats objects, when they refer to each other by ID. 36 | public Map getStatsMap() { 37 | return stats; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | StringBuilder builder = new StringBuilder(); 43 | builder.append("{ timestampUs: ").append(timestampUs).append(", stats: [\n"); 44 | boolean first = true; 45 | for (RTCStats stat : stats.values()) { 46 | if (!first) { 47 | builder.append(",\n"); 48 | } 49 | builder.append(stat); 50 | first = false; 51 | } 52 | builder.append(" ] }"); 53 | return builder.toString(); 54 | } 55 | 56 | // TODO(bugs.webrtc.org/8557) Use ctor directly with full Map type. 57 | @SuppressWarnings("unchecked") 58 | @CalledByNative 59 | private static RTCStatsReport create(long timestampUs, Map stats) { 60 | return new RTCStatsReport(timestampUs, stats); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/RefCountDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | import java.util.concurrent.atomic.AtomicInteger; 15 | 16 | /** 17 | * Implementation of RefCounted that executes a Runnable once the ref count reaches zero. 18 | */ 19 | class RefCountDelegate implements RefCounted { 20 | private final AtomicInteger refCount = new AtomicInteger(1); 21 | private final @Nullable Runnable releaseCallback; 22 | 23 | /** 24 | * @param releaseCallback Callback that will be executed once the ref count reaches zero. 25 | */ 26 | public RefCountDelegate(@Nullable Runnable releaseCallback) { 27 | this.releaseCallback = releaseCallback; 28 | } 29 | 30 | @Override 31 | public void retain() { 32 | int updated_count = refCount.incrementAndGet(); 33 | if (updated_count < 2) { 34 | throw new IllegalStateException("retain() called on an object with refcount < 1"); 35 | } 36 | } 37 | 38 | @Override 39 | public void release() { 40 | int updated_count = refCount.decrementAndGet(); 41 | if (updated_count < 0) { 42 | throw new IllegalStateException("release() called on an object with refcount < 1"); 43 | } 44 | if (updated_count == 0 && releaseCallback != null) { 45 | releaseCallback.run(); 46 | } 47 | } 48 | 49 | /** 50 | * Tries to retain the object. Can be used in scenarios where it is unknown if the object has 51 | * already been released. Returns true if successful or false if the object was already released. 52 | */ 53 | boolean safeRetain() { 54 | int currentRefCount = refCount.get(); 55 | while (currentRefCount != 0) { 56 | if (refCount.weakCompareAndSet(currentRefCount, currentRefCount + 1)) { 57 | return true; 58 | } 59 | currentRefCount = refCount.get(); 60 | } 61 | return false; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/RefCounted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for ref counted objects in WebRTC. These objects have significant resources that need 15 | * to be freed when they are no longer in use. Each objects starts with ref count of one when 16 | * created. If a reference is passed as a parameter to a method, the caller has ownesrship of the 17 | * object by default - calling release is not necessary unless retain is called. 18 | */ 19 | public interface RefCounted { 20 | /** Increases ref count by one. */ 21 | @CalledByNative void retain(); 22 | 23 | /** 24 | * Decreases ref count by one. When the ref count reaches zero, resources related to the object 25 | * will be freed. 26 | */ 27 | @CalledByNative void release(); 28 | } 29 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/ResolutionAdjustment.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.webrtc 18 | 19 | /** 20 | * Resolution alignment values. Generally the [MULTIPLE_OF_16] is recommended 21 | * for both VP8 and H264 22 | */ 23 | enum class ResolutionAdjustment(val value: Int) { 24 | NONE(1), 25 | MULTIPLE_OF_2(2), 26 | MULTIPLE_OF_4(4), 27 | MULTIPLE_OF_8(8), 28 | MULTIPLE_OF_16(16), 29 | } 30 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SSLCertificateVerifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The SSLCertificateVerifier interface allows API users to provide custom 15 | * logic to verify certificates. 16 | */ 17 | public interface SSLCertificateVerifier { 18 | /** 19 | * Implementations of verify allow applications to provide custom logic for 20 | * verifying certificates. This is not required by default and should be used 21 | * with care. 22 | * 23 | * @param certificate A byte array containing a DER encoded X509 certificate. 24 | * @return True if the certificate is verified and trusted else false. 25 | */ 26 | @CalledByNative boolean verify(byte[] certificate); 27 | } 28 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SdpObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for observing SDP-related events. */ 14 | public interface SdpObserver { 15 | /** Called on success of Create{Offer,Answer}(). */ 16 | @CalledByNative void onCreateSuccess(SessionDescription sdp); 17 | 18 | /** Called on success of Set{Local,Remote}Description(). */ 19 | @CalledByNative void onSetSuccess(); 20 | 21 | /** Called on error of Create{Offer,Answer}(). */ 22 | @CalledByNative void onCreateFailure(String error); 23 | 24 | /** Called on error of Set{Local,Remote}Description(). */ 25 | @CalledByNative void onSetFailure(String error); 26 | } 27 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SessionDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.util.Locale; 14 | 15 | /** 16 | * Description of an RFC 4566 Session. 17 | * SDPs are passed as serialized Strings in Java-land and are materialized 18 | * to SessionDescriptionInterface as appropriate in the JNI layer. 19 | */ 20 | public class SessionDescription { 21 | /** Java-land enum version of SessionDescriptionInterface's type() string. */ 22 | public static enum Type { 23 | OFFER, 24 | PRANSWER, 25 | ANSWER, 26 | ROLLBACK; 27 | 28 | public String canonicalForm() { 29 | return name().toLowerCase(Locale.US); 30 | } 31 | 32 | @CalledByNative("Type") 33 | public static Type fromCanonicalForm(String canonical) { 34 | return Type.valueOf(Type.class, canonical.toUpperCase(Locale.US)); 35 | } 36 | } 37 | 38 | public final Type type; 39 | public final String description; 40 | 41 | @CalledByNative 42 | public SessionDescription(Type type, String description) { 43 | this.type = type; 44 | this.description = description; 45 | } 46 | 47 | @CalledByNative 48 | String getDescription() { 49 | return description; 50 | } 51 | 52 | @CalledByNative 53 | String getTypeInCanonicalForm() { 54 | return type.canonicalForm(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SimulcastVideoEncoder.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | public class SimulcastVideoEncoder extends WrappedNativeVideoEncoder { 4 | 5 | static native long nativeCreateEncoder(long webrtcEnvRef, VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info); 6 | 7 | VideoEncoderFactory primary; 8 | VideoEncoderFactory fallback; 9 | VideoCodecInfo info; 10 | 11 | public SimulcastVideoEncoder(VideoEncoderFactory primary, VideoEncoderFactory fallback, VideoCodecInfo info) { 12 | this.primary = primary; 13 | this.fallback = fallback; 14 | this.info = info; 15 | } 16 | 17 | @Override 18 | public long createNative(long webrtcEnvRef) { 19 | return nativeCreateEncoder(webrtcEnvRef, primary, fallback, info); 20 | } 21 | 22 | @Override 23 | public boolean isHardwareEncoder() { 24 | return false; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SimulcastVideoEncoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Arrays; 18 | 19 | public class SimulcastVideoEncoderFactory implements VideoEncoderFactory { 20 | 21 | static native List nativeVP9Codecs(); 22 | static native VideoCodecInfo nativeAV1Codec(); 23 | 24 | VideoEncoderFactory primary; 25 | VideoEncoderFactory fallback; 26 | 27 | public SimulcastVideoEncoderFactory(VideoEncoderFactory primary, VideoEncoderFactory fallback) { 28 | this.primary = primary; 29 | this.fallback = fallback; 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public VideoEncoder createEncoder(VideoCodecInfo info) { 35 | return new SimulcastVideoEncoder(primary, fallback, info); 36 | } 37 | 38 | @Override 39 | public VideoCodecInfo[] getSupportedCodecs() { 40 | List codecs = new ArrayList(); 41 | codecs.addAll(Arrays.asList(primary.getSupportedCodecs())); 42 | if (fallback != null) { 43 | codecs.addAll(Arrays.asList(fallback.getSupportedCodecs())); 44 | } 45 | codecs.addAll(nativeVP9Codecs()); 46 | codecs.add(nativeAV1Codec()); 47 | return codecs.toArray(new VideoCodecInfo[codecs.size()]); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/Size.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Class for representing size of an object. Very similar to android.util.Size but available on all 15 | * devices. 16 | */ 17 | public class Size { 18 | public int width; 19 | public int height; 20 | 21 | public Size(int width, int height) { 22 | this.width = width; 23 | this.height = height; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return width + "x" + height; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object other) { 33 | if (!(other instanceof Size)) { 34 | return false; 35 | } 36 | final Size otherSize = (Size) other; 37 | return width == otherSize.width && height == otherSize.height; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | // Use prime close to 2^16 to avoid collisions for normal values less than 2^16. 43 | return 1 + 65537 * width + height; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SoftwareVideoDecoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | import java.util.List; 15 | 16 | public class SoftwareVideoDecoderFactory implements VideoDecoderFactory { 17 | private static final String TAG = "SoftwareVideoDecoderFactory"; 18 | 19 | private final long nativeFactory; 20 | 21 | public SoftwareVideoDecoderFactory() { 22 | this.nativeFactory = nativeCreateFactory(); 23 | } 24 | 25 | @Nullable 26 | @Override 27 | public VideoDecoder createDecoder(VideoCodecInfo info) { 28 | if (!nativeIsSupported(nativeFactory, info)) { 29 | Logging.w(TAG, "Trying to create decoder for unsupported format. " + info); 30 | return null; 31 | } 32 | return new WrappedNativeVideoDecoder() { 33 | @Override 34 | public long createNative(long webrtcEnvRef) { 35 | return nativeCreate(nativeFactory, webrtcEnvRef, info); 36 | } 37 | }; 38 | } 39 | 40 | @Override 41 | public VideoCodecInfo[] getSupportedCodecs() { 42 | return nativeGetSupportedCodecs(nativeFactory).toArray(new VideoCodecInfo[0]); 43 | } 44 | 45 | private static native long nativeCreateFactory(); 46 | 47 | private static native boolean nativeIsSupported(long factory, VideoCodecInfo info); 48 | 49 | private static native long nativeCreate( 50 | long factory, long webrtcEnvRef, VideoCodecInfo info); 51 | 52 | private static native List nativeGetSupportedCodecs(long factory); 53 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/SoftwareVideoEncoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | public class SoftwareVideoEncoderFactory implements VideoEncoderFactory { 18 | private static final String TAG = "SoftwareVideoEncoderFactory"; 19 | 20 | private final long nativeFactory; 21 | 22 | public SoftwareVideoEncoderFactory() { 23 | this.nativeFactory = nativeCreateFactory(); 24 | } 25 | 26 | @Nullable 27 | @Override 28 | public VideoEncoder createEncoder(VideoCodecInfo info) { 29 | if (!nativeIsSupported(nativeFactory, info)) { 30 | Logging.w(TAG, "Trying to create encoder for unsupported format. " + info); 31 | return null; 32 | } 33 | 34 | return new WrappedNativeVideoEncoder() { 35 | @Override 36 | public long createNative(long webrtcEnvRef) { 37 | return nativeCreate(nativeFactory, webrtcEnvRef, info); 38 | } 39 | 40 | @Override 41 | public boolean isHardwareEncoder() { 42 | return false; 43 | } 44 | }; 45 | } 46 | 47 | @Override 48 | public VideoCodecInfo[] getSupportedCodecs() { 49 | return nativeGetSupportedCodecs(nativeFactory).toArray(new VideoCodecInfo[0]); 50 | } 51 | 52 | private static native long nativeCreateFactory(); 53 | 54 | private static native boolean nativeIsSupported(long factory, VideoCodecInfo info); 55 | 56 | private static native long nativeCreate(long factory, long webrtcEnvRef, VideoCodecInfo info); 57 | 58 | private static native List nativeGetSupportedCodecs(long factory); 59 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/StatsObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for observing Stats reports (see webrtc::StatsObservers). */ 14 | public interface StatsObserver { 15 | /** Called when the reports are ready.*/ 16 | @CalledByNative public void onComplete(StatsReport[] reports); 17 | } 18 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/StatsReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Java version of webrtc::StatsReport. */ 14 | public class StatsReport { 15 | /** Java version of webrtc::StatsReport::Value. */ 16 | public static class Value { 17 | public final String name; 18 | public final String value; 19 | 20 | @CalledByNative("Value") 21 | public Value(String name, String value) { 22 | this.name = name; 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | StringBuilder builder = new StringBuilder(); 29 | builder.append("[").append(name).append(": ").append(value).append("]"); 30 | return builder.toString(); 31 | } 32 | } 33 | 34 | public final String id; 35 | public final String type; 36 | // Time since 1970-01-01T00:00:00Z in milliseconds. 37 | public final double timestamp; 38 | public final Value[] values; 39 | 40 | @CalledByNative 41 | public StatsReport(String id, String type, double timestamp, Value[] values) { 42 | this.id = id; 43 | this.type = type; 44 | this.timestamp = timestamp; 45 | this.values = values; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | StringBuilder builder = new StringBuilder(); 51 | builder.append("id: ") 52 | .append(id) 53 | .append(", type: ") 54 | .append(type) 55 | .append(", timestamp: ") 56 | .append(timestamp) 57 | .append(", values: "); 58 | for (int i = 0; i < values.length; ++i) { 59 | builder.append(values[i].toString()).append(", "); 60 | } 61 | return builder.toString(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/TurnCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Java wrapper for a C++ TurnCustomizer. */ 14 | public class TurnCustomizer { 15 | private long nativeTurnCustomizer; 16 | 17 | public TurnCustomizer(long nativeTurnCustomizer) { 18 | this.nativeTurnCustomizer = nativeTurnCustomizer; 19 | } 20 | 21 | public void dispose() { 22 | checkTurnCustomizerExists(); 23 | nativeFreeTurnCustomizer(nativeTurnCustomizer); 24 | nativeTurnCustomizer = 0; 25 | } 26 | 27 | private static native void nativeFreeTurnCustomizer(long turnCustomizer); 28 | 29 | /** Return a pointer to webrtc::TurnCustomizer. */ 30 | @CalledByNative 31 | long getNativeTurnCustomizer() { 32 | checkTurnCustomizerExists(); 33 | return nativeTurnCustomizer; 34 | } 35 | 36 | private void checkTurnCustomizerExists() { 37 | if (nativeTurnCustomizer == 0) { 38 | throw new IllegalStateException("TurnCustomizer has been disposed."); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoCapturer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | // Base interface for all VideoCapturers to implement. 16 | public interface VideoCapturer { 17 | /** 18 | * This function is used to initialize the camera thread, the android application context, and the 19 | * capture observer. It will be called only once and before any startCapture() request. The 20 | * camera thread is guaranteed to be valid until dispose() is called. If the VideoCapturer wants 21 | * to deliver texture frames, it should do this by rendering on the SurfaceTexture in 22 | * {@code surfaceTextureHelper}, register itself as a listener, and forward the frames to 23 | * CapturerObserver.onFrameCaptured(). The caller still has ownership of {@code 24 | * surfaceTextureHelper} and is responsible for making sure surfaceTextureHelper.dispose() is 25 | * called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new 26 | * VideoCapturer once the previous VideoCapturer has been disposed. 27 | */ 28 | void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext, 29 | CapturerObserver capturerObserver); 30 | 31 | /** 32 | * Start capturing frames in a format that is as close as possible to {@code width x height} and 33 | * {@code framerate}. 34 | */ 35 | void startCapture(int width, int height, int framerate); 36 | 37 | /** 38 | * Stop capturing. This function should block until capture is actually stopped. 39 | */ 40 | void stopCapture() throws InterruptedException; 41 | 42 | void changeCaptureFormat(int width, int height, int framerate); 43 | 44 | /** 45 | * Perform any final cleanup here. No more capturing will be done after this call. 46 | */ 47 | void dispose(); 48 | 49 | /** 50 | * @return true if-and-only-if this is a screen capturer. 51 | */ 52 | boolean isScreencast(); 53 | } 54 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoCodecMimeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Enumeration of supported video codec types. */ 14 | enum VideoCodecMimeType { 15 | VP8("video/x-vnd.on2.vp8"), 16 | VP9("video/x-vnd.on2.vp9"), 17 | H264("video/avc"), 18 | AV1("video/av01"), 19 | H265("video/hevc"); 20 | 21 | private final String mimeType; 22 | 23 | private VideoCodecMimeType(String mimeType) { 24 | this.mimeType = mimeType; 25 | } 26 | 27 | String mimeType() { 28 | return mimeType; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoCodecStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Status codes reported by video encoding/decoding components. This should be kept in sync with 15 | * video_error_codes.h. 16 | */ 17 | public enum VideoCodecStatus { 18 | TARGET_BITRATE_OVERSHOOT(5), 19 | REQUEST_SLI(2), 20 | NO_OUTPUT(1), 21 | OK(0), 22 | ERROR(-1), 23 | LEVEL_EXCEEDED(-2), 24 | MEMORY(-3), 25 | ERR_PARAMETER(-4), 26 | ERR_SIZE(-5), 27 | TIMEOUT(-6), 28 | UNINITIALIZED(-7), 29 | ERR_REQUEST_SLI(-12), 30 | FALLBACK_SOFTWARE(-13); 31 | 32 | private final int number; 33 | 34 | private VideoCodecStatus(int number) { 35 | this.number = number; 36 | } 37 | 38 | @CalledByNative 39 | public int getNumber() { 40 | return number; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoDecoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | 15 | /** Factory for creating VideoDecoders. */ 16 | public interface VideoDecoderFactory { 17 | /** 18 | * Creates a VideoDecoder for the given codec. Supports the same codecs supported by 19 | * VideoEncoderFactory. 20 | */ 21 | @Nullable @CalledByNative VideoDecoder createDecoder(VideoCodecInfo info); 22 | 23 | /** 24 | * Enumerates the list of supported video codecs. 25 | */ 26 | @CalledByNative 27 | default VideoCodecInfo[] getSupportedCodecs() { 28 | return new VideoCodecInfo[0]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoDecoderFallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * A combined video decoder that falls back on a secondary decoder if the primary decoder fails. 15 | */ 16 | public class VideoDecoderFallback extends WrappedNativeVideoDecoder { 17 | private final VideoDecoder fallback; 18 | private final VideoDecoder primary; 19 | 20 | public VideoDecoderFallback(VideoDecoder fallback, VideoDecoder primary) { 21 | this.fallback = fallback; 22 | this.primary = primary; 23 | } 24 | 25 | @Override 26 | public long createNative(long webrtcEnvRef) { 27 | return nativeCreate(webrtcEnvRef, fallback, primary); 28 | } 29 | 30 | private static native long nativeCreate( 31 | long webrtcEnvRef, VideoDecoder fallback, VideoDecoder primary); 32 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoDecoderWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.VideoDecoder; 14 | 15 | /** 16 | * This class contains the Java glue code for JNI generation of VideoDecoder. 17 | */ 18 | class VideoDecoderWrapper { 19 | @CalledByNative 20 | static VideoDecoder.Callback createDecoderCallback(final long nativeDecoder) { 21 | return (VideoFrame frame, Integer decodeTimeMs, 22 | Integer qp) -> nativeOnDecodedFrame(nativeDecoder, frame, decodeTimeMs, qp); 23 | } 24 | 25 | private static native void nativeOnDecodedFrame( 26 | long nativeVideoDecoderWrapper, VideoFrame frame, Integer decodeTimeMs, Integer qp); 27 | } 28 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoEncoderFallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * A combined video encoder that falls back on a secondary encoder if the primary encoder fails. 15 | */ 16 | public class VideoEncoderFallback extends WrappedNativeVideoEncoder { 17 | private final VideoEncoder fallback; 18 | private final VideoEncoder primary; 19 | 20 | public VideoEncoderFallback(VideoEncoder fallback, VideoEncoder primary) { 21 | this.fallback = fallback; 22 | this.primary = primary; 23 | } 24 | 25 | @Override 26 | public long createNative(long webrtcEnvRef) { 27 | return nativeCreate(webrtcEnvRef, fallback, primary); 28 | } 29 | 30 | @Override 31 | public boolean isHardwareEncoder() { 32 | return primary.isHardwareEncoder(); 33 | } 34 | 35 | private static native long nativeCreate( 36 | long webrtcEnvRef, VideoEncoder fallback, VideoEncoder primary); 37 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoEncoderWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | // Explicit imports necessary for JNI generation. 14 | import androidx.annotation.Nullable; 15 | import org.webrtc.VideoEncoder; 16 | 17 | /** 18 | * This class contains the Java glue code for JNI generation of VideoEncoder. 19 | */ 20 | class VideoEncoderWrapper { 21 | @CalledByNative 22 | static boolean getScalingSettingsOn(VideoEncoder.ScalingSettings scalingSettings) { 23 | return scalingSettings.on; 24 | } 25 | 26 | @Nullable 27 | @CalledByNative 28 | static Integer getScalingSettingsLow(VideoEncoder.ScalingSettings scalingSettings) { 29 | return scalingSettings.low; 30 | } 31 | 32 | @Nullable 33 | @CalledByNative 34 | static Integer getScalingSettingsHigh(VideoEncoder.ScalingSettings scalingSettings) { 35 | return scalingSettings.high; 36 | } 37 | 38 | @CalledByNative 39 | static VideoEncoder.Callback createEncoderCallback(final long nativeEncoder) { 40 | return (EncodedImage frame, 41 | VideoEncoder.CodecSpecificInfo info) -> nativeOnEncodedFrame(nativeEncoder, frame); 42 | } 43 | 44 | private static native void nativeOnEncodedFrame( 45 | long nativeVideoEncoderWrapper, EncodedImage frame); 46 | } 47 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoFrameBufferType.java: -------------------------------------------------------------------------------- 1 | package org.webrtc; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | public @interface VideoFrameBufferType { 8 | int NATIVE = 0; 9 | int I420 = 1; 10 | int I420A = 2; 11 | int I422 = 3; 12 | int I444 = 4; 13 | int I010 = 5; 14 | int I210 = 6; 15 | int NV12 = 7; 16 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/VideoSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Java version of rtc::VideoSinkInterface. 15 | */ 16 | public interface VideoSink { 17 | /** 18 | * Implementations should call frame.retain() if they need to hold a reference to the frame after 19 | * this function returns. Each call to retain() should be followed by a call to frame.release() 20 | * when the reference is no longer needed. 21 | */ 22 | @CalledByNative void onFrame(VideoFrame frame); 23 | } 24 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/WebRTCException.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2023 Stream.io Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.webrtc 18 | 19 | /** 20 | * Represent an exception for the RTC. 21 | */ 22 | class WebRTCException(override val message: String?) : RuntimeException() 23 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/WebRtcClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * This class provides a ClassLoader that is capable of loading WebRTC Java classes regardless of 15 | * what thread it's called from. Such a ClassLoader is needed for the few cases where the JNI 16 | * mechanism is unable to automatically determine the appropriate ClassLoader instance. 17 | */ 18 | class WebRtcClassLoader { 19 | @CalledByNative 20 | static Object getClassLoader() { 21 | Object loader = WebRtcClassLoader.class.getClassLoader(); 22 | if (loader == null) { 23 | throw new RuntimeException("Failed to get WebRTC class loader."); 24 | } 25 | return loader; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/WrappedNativeVideoDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Wraps a native webrtc::VideoDecoder. 15 | */ 16 | public abstract class WrappedNativeVideoDecoder implements VideoDecoder { 17 | @Override public abstract long createNative(long webrtcEnvRef); 18 | 19 | @Override 20 | public final VideoCodecStatus initDecode(Settings settings, Callback decodeCallback) { 21 | throw new UnsupportedOperationException("Not implemented."); 22 | } 23 | 24 | @Override 25 | public final VideoCodecStatus release() { 26 | throw new UnsupportedOperationException("Not implemented."); 27 | } 28 | 29 | @Override 30 | public final VideoCodecStatus decode(EncodedImage frame, DecodeInfo info) { 31 | throw new UnsupportedOperationException("Not implemented."); 32 | } 33 | 34 | @Override 35 | public final String getImplementationName() { 36 | throw new UnsupportedOperationException("Not implemented."); 37 | } 38 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/WrappedNativeVideoEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Wraps a native webrtc::VideoEncoder. 15 | */ 16 | public abstract class WrappedNativeVideoEncoder implements VideoEncoder { 17 | @Override public abstract long createNative(long webrtcEnvRef); 18 | @Override public abstract boolean isHardwareEncoder(); 19 | 20 | @Override 21 | public final VideoCodecStatus initEncode(Settings settings, Callback encodeCallback) { 22 | throw new UnsupportedOperationException("Not implemented."); 23 | } 24 | 25 | @Override 26 | public final VideoCodecStatus release() { 27 | throw new UnsupportedOperationException("Not implemented."); 28 | } 29 | 30 | @Override 31 | public final VideoCodecStatus encode(VideoFrame frame, EncodeInfo info) { 32 | throw new UnsupportedOperationException("Not implemented."); 33 | } 34 | 35 | @Override 36 | public final VideoCodecStatus setRateAllocation(BitrateAllocation allocation, int framerate) { 37 | throw new UnsupportedOperationException("Not implemented."); 38 | } 39 | 40 | @Override 41 | public final ScalingSettings getScalingSettings() { 42 | throw new UnsupportedOperationException("Not implemented."); 43 | } 44 | 45 | @Override 46 | public final String getImplementationName() { 47 | throw new UnsupportedOperationException("Not implemented."); 48 | } 49 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/audio/AudioDeviceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc.audio; 12 | 13 | /** 14 | * This interface is a thin wrapper on top of a native C++ webrtc::AudioDeviceModule (ADM). The 15 | * reason for basing it on a native ADM instead of a pure Java interface is that we have two native 16 | * Android implementations (OpenSLES and AAudio) that does not make sense to wrap through JNI. 17 | * 18 | *

Note: This class is still under development and may change without notice. 19 | */ 20 | public interface AudioDeviceModule { 21 | /** 22 | * Returns a C++ pointer to a webrtc::AudioDeviceModule. Caller does _not_ take ownership and 23 | * lifetime is handled through the release() call. 24 | */ 25 | long getNativeAudioDeviceModulePointer(); 26 | 27 | /** 28 | * Release resources for this AudioDeviceModule, including native resources. The object should not 29 | * be used after this call. 30 | */ 31 | void release(); 32 | 33 | /** Control muting/unmuting the speaker. */ 34 | void setSpeakerMute(boolean mute); 35 | 36 | /** Control muting/unmuting the microphone. */ 37 | void setMicrophoneMute(boolean mute); 38 | 39 | /** 40 | * Enable or disable built in noise suppressor. Returns true if the enabling was successful, 41 | * otherwise false is returned. 42 | */ 43 | default boolean setNoiseSuppressorEnabled(boolean enabled) { 44 | return false; 45 | } 46 | 47 | /** 48 | * Sets the preferred field dimension for the built-in microphone. Returns 49 | * true if setting was successful, otherwise false is returned. 50 | * This functionality can be implemented with 51 | * {@code android.media.MicrophoneDirection.setPreferredMicrophoneFieldDimension}. 52 | */ 53 | default boolean setPreferredMicrophoneFieldDimension(float dimension) { 54 | return false; 55 | } 56 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/audio/AudioRecordDataCallback.java: -------------------------------------------------------------------------------- 1 | package org.webrtc.audio; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public interface AudioRecordDataCallback { 8 | /** 9 | * Invoked after an audio sample is recorded. Can be used to manipulate 10 | * the ByteBuffer before it's fed into WebRTC. Currently the audio in the 11 | * ByteBuffer is always PCM 16bit and the buffer sample size is ~10ms. 12 | * 13 | * @param audioFormat format in android.media.AudioFormat 14 | */ 15 | void onAudioDataRecorded(int audioFormat, int channelCount, int sampleRate, @NonNull ByteBuffer audioBuffer); 16 | } -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/audio/LegacyAudioDeviceModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc.audio; 12 | 13 | import org.webrtc.voiceengine.WebRtcAudioRecord; 14 | import org.webrtc.voiceengine.WebRtcAudioTrack; 15 | 16 | /** 17 | * This class represents the legacy AudioDeviceModule that is currently hardcoded into C++ WebRTC. 18 | * It will return a null native AudioDeviceModule pointer, leading to an internal object being 19 | * created inside WebRTC that is controlled by static calls to the classes under the voiceengine 20 | * package. Please use the new JavaAudioDeviceModule instead of this class. 21 | */ 22 | @Deprecated 23 | public class LegacyAudioDeviceModule implements AudioDeviceModule { 24 | @Override 25 | public long getNativeAudioDeviceModulePointer() { 26 | // Returning a null pointer will make WebRTC construct the built-in legacy AudioDeviceModule for 27 | // Android internally. 28 | return 0; 29 | } 30 | 31 | @Override 32 | public void release() { 33 | // All control for this ADM goes through static global methods and the C++ object is owned 34 | // internally by WebRTC. 35 | } 36 | 37 | @Override 38 | public void setSpeakerMute(boolean mute) { 39 | WebRtcAudioTrack.setSpeakerMute(mute); 40 | } 41 | 42 | @Override 43 | public void setMicrophoneMute(boolean mute) { 44 | WebRtcAudioRecord.setMicrophoneMute(mute); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/java/org/webrtc/voiceengine/BuildInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc.voiceengine; 12 | 13 | import android.os.Build; 14 | 15 | public final class BuildInfo { 16 | public static String getDevice() { 17 | return Build.DEVICE; 18 | } 19 | 20 | public static String getDeviceModel() { 21 | return Build.MODEL; 22 | } 23 | 24 | public static String getProduct() { 25 | return Build.PRODUCT; 26 | } 27 | 28 | public static String getBrand() { 29 | return Build.BRAND; 30 | } 31 | 32 | public static String getDeviceManufacturer() { 33 | return Build.MANUFACTURER; 34 | } 35 | 36 | public static String getAndroidBuildId() { 37 | return Build.ID; 38 | } 39 | 40 | public static String getBuildType() { 41 | return Build.TYPE; 42 | } 43 | 44 | public static String getBuildRelease() { 45 | return Build.VERSION.RELEASE; 46 | } 47 | 48 | public static int getSdkVersion() { 49 | return Build.VERSION.SDK_INT; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /stream-webrtc-android/src/main/resources/META-INF/io/getstream/stream-webrtc-android/verification.properties: -------------------------------------------------------------------------------- 1 | #This is the verification token for the io.getstream:stream-webrtc-android SDK. 2 | #Mon Jan 20 16:23:34 PST 2025 3 | token=JCIGEHGPBBA3XCTNIOMQHE7SLI 4 | -------------------------------------------------------------------------------- /usecases.md: -------------------------------------------------------------------------------- 1 | 2 | # Who's using WebRTC Android? 3 | If your product uses WebRTC Android, welcome to contribute by creating a pull request or let me know through other contacts! 🤗 4 | 5 | ## [Stream Video SDK](https://getstream.io/video?utm_source=Github&utm_medium=Jaewoong_OSS&utm_content=Developer&utm_campaign=Github_Feb2023_Jaewoong_StreamWebRTCAndroid&utm_term=DevRelOss) 6 | 7 | ![logo2](https://user-images.githubusercontent.com/24237865/225775639-c9fddf13-d9e4-48f9-89cb-2b8bf227d4db.png) 8 | 9 | # License 10 | ```xml 11 | Copyright 2023 Stream.IO, Inc. All Rights Reserved. 12 | 13 | Licensed under the Apache License, Version 2.0 (the "License"); 14 | you may not use this file except in compliance with the License. 15 | You may obtain a copy of the License at 16 | 17 | http://www.apache.org/licenses/LICENSE-2.0 18 | 19 | Unless required by applicable law or agreed to in writing, software 20 | distributed under the License is distributed on an "AS IS" BASIS, 21 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | See the License for the specific language governing permissions and 23 | limitations under the License. 24 | ``` 25 | --------------------------------------------------------------------------------