├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── drawable │ │ │ │ ├── firebase.png │ │ │ │ ├── ic_record.xml │ │ │ │ ├── ic_camera_on.xml │ │ │ │ ├── ic_video_call.xml │ │ │ │ ├── ic_camera_off.xml │ │ │ │ ├── ic_mic_on.xml │ │ │ │ ├── ic_speaker.xml │ │ │ │ ├── ic_screen_share.xml │ │ │ │ ├── ic_switch_camera.xml │ │ │ │ ├── ic_mic_off.xml │ │ │ │ ├── ic_stop_screen_share.xml │ │ │ │ ├── ic_call.xml │ │ │ │ ├── ic_end_call.xml │ │ │ │ ├── ic_ear.xml │ │ │ │ ├── ic_launcher_foreground.xml │ │ │ │ └── ic_launcher_background.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 │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-anydpi-v33 │ │ │ │ └── ic_launcher.xml │ │ │ ├── xml │ │ │ │ ├── backup_rules.xml │ │ │ │ └── data_extraction_rules.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── layout │ │ │ │ ├── activity_login.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── item_main_recycler_view.xml │ │ │ │ └── activity_call.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── codewithkael │ │ │ │ └── firebasevideocall │ │ │ │ ├── utils │ │ │ │ ├── UserStatus.kt │ │ │ │ ├── MyApplication.kt │ │ │ │ ├── FirebaseFieldNames.kt │ │ │ │ ├── MyEventListener.kt │ │ │ │ ├── DataModel.kt │ │ │ │ ├── AppModule.kt │ │ │ │ └── Extensions.kt │ │ │ │ ├── service │ │ │ │ ├── MainServiceActions.kt │ │ │ │ ├── MainServiceReceiver.kt │ │ │ │ ├── MainServiceRepository.kt │ │ │ │ └── MainService.kt │ │ │ │ ├── ui │ │ │ │ ├── CloseActivity.kt │ │ │ │ ├── LoginActivity.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ └── CallActivity.kt │ │ │ │ ├── webrtc │ │ │ │ ├── MySdpObserver.kt │ │ │ │ ├── MyPeerObserver.kt │ │ │ │ ├── ProximitySensor.java │ │ │ │ ├── WebRTCClient.kt │ │ │ │ ├── BluetoothManager.java │ │ │ │ └── RTCAudioManager.java │ │ │ │ ├── adapters │ │ │ │ └── MainRecyclerViewAdapter.kt │ │ │ │ ├── firebaseClient │ │ │ │ └── FirebaseClient.kt │ │ │ │ └── repository │ │ │ │ └── MainRepository.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── codewithkael │ │ │ └── firebasevideocall │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── codewithkael │ │ └── firebasevideocall │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro ├── google-services.json └── build.gradle ├── .idea ├── .gitignore ├── compiler.xml ├── vcs.xml ├── misc.xml ├── gradle.xml └── deploymentTargetDropDown.xml ├── .gitattributes ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .gitignore ├── settings.gradle ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | FirebaseVideoCall 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/firebase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/drawable/firebase.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codewithkael/FirebaseWebRTCVideoCall/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/UserStatus.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | enum class UserStatus { 4 | ONLINE,OFFLINE,IN_CALL 5 | } -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FirebaseWebRTCVideoCall 2 | An Implementation of webrtc video call with firebase Signaling server follow my Youtube Channel to see the full course about this source. 3 | 4 | my channel name is CodeWithKael 5 | www.youtube.com/@CodeWithKael 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/MyApplication.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class MyApplication : Application() -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/FirebaseFieldNames.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | object FirebaseFieldNames { 4 | const val STATUS = "status" 5 | const val PASSWORD = "password" 6 | const val LATEST_EVENT = "latest_event" 7 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 02 12:10:21 IRDT 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/service/MainServiceActions.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.service 2 | 3 | enum class MainServiceActions { 4 | START_SERVICE,SETUP_VIEWS,END_CALL,SWITCH_CAMERA,TOGGLE_AUDIO,TOGGLE_VIDEO,TOGGLE_AUDIO_DEVICE, 5 | TOGGLE_SCREEN_SHARE,STOP_SERVICE 6 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_record.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/ui/CloseActivity.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.ui 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | class CloseActivity : AppCompatActivity() { 7 | override fun onCreate(savedInstanceState: Bundle?) { 8 | super.onCreate(savedInstanceState) 9 | finishAffinity() 10 | } 11 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "FirebaseVideoCall" 16 | include ':app' 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_camera_on.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_video_call.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/test/java/com/codewithkael/firebasevideocall/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/MyEventListener.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | import com.google.firebase.database.DataSnapshot 4 | import com.google.firebase.database.DatabaseError 5 | import com.google.firebase.database.ValueEventListener 6 | 7 | open class MyEventListener : ValueEventListener { 8 | override fun onDataChange(snapshot: DataSnapshot) { 9 | 10 | } 11 | 12 | override fun onCancelled(error: DatabaseError) { 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_camera_off.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/webrtc/MySdpObserver.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.webrtc 2 | 3 | import org.webrtc.SdpObserver 4 | import org.webrtc.SessionDescription 5 | 6 | open class MySdpObserver : SdpObserver { 7 | override fun onCreateSuccess(desc: SessionDescription?) { 8 | 9 | } 10 | 11 | override fun onSetSuccess() { 12 | } 13 | 14 | override fun onCreateFailure(p0: String?) { 15 | } 16 | 17 | override fun onSetFailure(p0: String?) { 18 | } 19 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mic_on.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_speaker.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_screen_share.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/DataModel.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | enum class DataModelType { 4 | StartAudioCall,StartVideoCall,Offer,Answer,IceCandidates,EndCall 5 | } 6 | data class DataModel( 7 | val sender:String?=null, 8 | val target:String, 9 | val type:DataModelType, 10 | val data:String?=null, 11 | val timeStamp:Long = System.currentTimeMillis() 12 | ) 13 | 14 | 15 | fun DataModel.isValid(): Boolean { 16 | return System.currentTimeMillis() - this.timeStamp < 60000 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_switch_camera.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #57FFFFFF 11 | #57000000 12 | #3AAE09 13 | #EAE78F 14 | #E82039 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_mic_off.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_stop_screen_share.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_call.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_end_call.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/codewithkael/firebasevideocall/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.codewithkael.firebasevideocall", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/service/MainServiceReceiver.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.service 2 | 3 | import android.content.BroadcastReceiver 4 | import android.content.Context 5 | import android.content.Intent 6 | import com.codewithkael.firebasevideocall.ui.CloseActivity 7 | import dagger.hilt.android.AndroidEntryPoint 8 | import javax.inject.Inject 9 | 10 | @AndroidEntryPoint 11 | class MainServiceReceiver : BroadcastReceiver() { 12 | 13 | @Inject lateinit var serviceRepository: MainServiceRepository 14 | override fun onReceive(context: Context?, intent: Intent?) { 15 | if (intent?.action == "ACTION_EXIT"){ 16 | //we want to exit the whole application 17 | serviceRepository.stopService() 18 | context?.startActivity(Intent(context,CloseActivity::class.java)) 19 | 20 | } 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_ear.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | import android.content.Context 4 | import com.google.firebase.database.DatabaseReference 5 | import com.google.firebase.database.FirebaseDatabase 6 | import com.google.gson.Gson 7 | import dagger.Module 8 | import dagger.Provides 9 | import dagger.hilt.InstallIn 10 | import dagger.hilt.android.qualifiers.ApplicationContext 11 | import dagger.hilt.components.SingletonComponent 12 | 13 | @Module 14 | @InstallIn(SingletonComponent::class) 15 | class AppModule { 16 | 17 | @Provides 18 | fun provideContext(@ApplicationContext context:Context) : Context = context.applicationContext 19 | 20 | @Provides 21 | fun provideGson():Gson = Gson() 22 | 23 | @Provides 24 | fun provideDataBaseInstance():FirebaseDatabase = FirebaseDatabase.getInstance() 25 | 26 | @Provides 27 | fun provideDatabaseReference(db:FirebaseDatabase): DatabaseReference = db.reference 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/utils/Extensions.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.utils 2 | 3 | import android.widget.Toast 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.permissionx.guolindev.PermissionX 6 | 7 | fun AppCompatActivity.getCameraAndMicPermission(success:()->Unit){ 8 | PermissionX.init(this) 9 | .permissions(android.Manifest.permission.CAMERA,android.Manifest.permission.RECORD_AUDIO) 10 | .request{allGranted,_,_ -> 11 | 12 | if (allGranted){ 13 | success() 14 | } else{ 15 | Toast.makeText(this, "camera and mic permission is required", Toast.LENGTH_SHORT) 16 | .show() 17 | } 18 | } 19 | } 20 | 21 | fun Int.convertToHumanTime() : String{ 22 | val seconds = this%60 23 | val minutes = this/60 24 | val secondsString = if (seconds<10) "0$seconds" else "$seconds" 25 | val minutesString = if (minutes < 10) "0$minutes" else "$minutes" 26 | return "$minutesString:$secondsString" 27 | } -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/webrtc/MyPeerObserver.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.webrtc 2 | 3 | import org.webrtc.* 4 | 5 | open class MyPeerObserver : PeerConnection.Observer { 6 | override fun onSignalingChange(p0: PeerConnection.SignalingState?) { 7 | 8 | } 9 | 10 | override fun onIceConnectionChange(p0: PeerConnection.IceConnectionState?) { 11 | } 12 | 13 | override fun onIceConnectionReceivingChange(p0: Boolean) { 14 | } 15 | 16 | override fun onIceGatheringChange(p0: PeerConnection.IceGatheringState?) { 17 | } 18 | 19 | override fun onIceCandidate(p0: IceCandidate?) { 20 | } 21 | 22 | override fun onIceCandidatesRemoved(p0: Array?) { 23 | } 24 | 25 | override fun onAddStream(p0: MediaStream?) { 26 | } 27 | 28 | override fun onRemoveStream(p0: MediaStream?) { 29 | } 30 | 31 | override fun onDataChannel(p0: DataChannel?) { 32 | } 33 | 34 | override fun onRenegotiationNeeded() { 35 | } 36 | 37 | override fun onAddTrack(p0: RtpReceiver?, p1: Array?) { 38 | } 39 | } -------------------------------------------------------------------------------- /app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "12957448847", 4 | "firebase_url": "https://fir-videocall-d1cf8-default-rtdb.europe-west1.firebasedatabase.app", 5 | "project_id": "fir-videocall-d1cf8", 6 | "storage_bucket": "fir-videocall-d1cf8.appspot.com" 7 | }, 8 | "client": [ 9 | { 10 | "client_info": { 11 | "mobilesdk_app_id": "1:12957448847:android:abea1125f53b8d133b0efa", 12 | "android_client_info": { 13 | "package_name": "com.codewithkael.firebasevideocall" 14 | } 15 | }, 16 | "oauth_client": [ 17 | { 18 | "client_id": "12957448847-ao0slpr11b5pcbb589q9jsujt13otk2r.apps.googleusercontent.com", 19 | "client_type": 3 20 | } 21 | ], 22 | "api_key": [ 23 | { 24 | "current_key": "AIzaSyCcxKqsrfEZfUJuPu6yMpLiHgYmpm68xHE" 25 | } 26 | ], 27 | "services": { 28 | "appinvite_service": { 29 | "other_platform_oauth_client": [ 30 | { 31 | "client_id": "12957448847-ao0slpr11b5pcbb589q9jsujt13otk2r.apps.googleusercontent.com", 32 | "client_type": 3 33 | } 34 | ] 35 | } 36 | } 37 | } 38 | ], 39 | "configuration_version": "1" 40 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/main/java/com/codewithkael/firebasevideocall/ui/LoginActivity.kt: -------------------------------------------------------------------------------- 1 | package com.codewithkael.firebasevideocall.ui 2 | 3 | import android.content.Intent 4 | import androidx.appcompat.app.AppCompatActivity 5 | import android.os.Bundle 6 | import android.widget.Toast 7 | import com.codewithkael.firebasevideocall.databinding.ActivityLoginBinding 8 | import com.codewithkael.firebasevideocall.repository.MainRepository 9 | import dagger.hilt.android.AndroidEntryPoint 10 | import javax.inject.Inject 11 | 12 | 13 | @AndroidEntryPoint 14 | class LoginActivity : AppCompatActivity() { 15 | 16 | private lateinit var views:ActivityLoginBinding 17 | @Inject lateinit var mainRepository: MainRepository 18 | 19 | override fun onCreate(savedInstanceState: Bundle?) { 20 | super.onCreate(savedInstanceState) 21 | views = ActivityLoginBinding.inflate(layoutInflater) 22 | setContentView(views.root) 23 | init() 24 | } 25 | 26 | 27 | private fun init(){ 28 | views.apply { 29 | btn.setOnClickListener { 30 | mainRepository.login( 31 | usernameEt.text.toString(),passwordEt.text.toString() 32 | ){ isDone, reason -> 33 | if (!isDone){ 34 | Toast.makeText(this@LoginActivity, reason, Toast.LENGTH_SHORT).show() 35 | }else{ 36 | //start moving to our main activity 37 | startActivity(Intent(this@LoginActivity, MainActivity::class.java).apply { 38 | putExtra("username",usernameEt.text.toString()) 39 | }) 40 | } 41 | } 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 34 | 36 | 37 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'com.google.gms.google-services' 5 | id 'kotlin-kapt' 6 | id 'com.google.dagger.hilt.android' 7 | } 8 | 9 | android { 10 | namespace 'com.codewithkael.firebasevideocall' 11 | compileSdk 33 12 | 13 | defaultConfig { 14 | applicationId "com.codewithkael.firebasevideocall" 15 | minSdk 24 16 | targetSdk 33 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | compileOptions { 30 | sourceCompatibility JavaVersion.VERSION_1_8 31 | targetCompatibility JavaVersion.VERSION_1_8 32 | } 33 | kotlinOptions { 34 | jvmTarget = '1.8' 35 | } 36 | viewBinding{ 37 | enabled=true 38 | } 39 | } 40 | 41 | dependencies { 42 | 43 | implementation 'androidx.core:core-ktx:1.7.0' 44 | implementation 'androidx.appcompat:appcompat:1.6.1' 45 | implementation 'com.google.android.material:material:1.9.0' 46 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 47 | implementation platform('com.google.firebase:firebase-bom:32.2.0') 48 | implementation 'com.google.firebase:firebase-database-ktx:20.2.2' 49 | implementation 'com.google.code.gson:gson:2.10.1' 50 | implementation 'com.mesibo.api:webrtc:1.0.5' 51 | implementation "com.google.dagger:hilt-android:2.44" 52 | kapt "com.google.dagger:hilt-compiler:2.44" 53 | implementation 'com.guolindev.permissionx:permissionx:1.6.1' 54 | 55 | testImplementation 'junit:junit:4.13.2' 56 | androidTestImplementation 'androidx.test.ext:junit:1.1.5' 57 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 58 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 25 | 34 | 42 | 43 |