Skip to content

Instantly share code, notes, and snippets.

View ShwetaChauhan18's full-sized avatar
🎯
Focusing

Shweta Chauhan ShwetaChauhan18

🎯
Focusing
View GitHub Profile
private fun startStreamingVideo() {
//creating local mediastream
val mediaStream = factory?.createLocalMediaStream("ARDAMS")
mediaStream?.apply {
addTrack(localAudioTrack)
addTrack(localVideoTrack)
localPeerConnection?.addStream(this)
}
val sdpMediaConstraints = MediaConstraints()
private fun initializePeerConnections() {
localPeerConnection = createPeerConnection(factory, true)
remotePeerConnection = createPeerConnection(factory, false);
}
private fun createPeerConnection(factory: PeerConnectionFactory?, isLocal: Boolean): PeerConnection? {
val iceServers = ArrayList<PeerConnection.IceServer>()
iceServers.add(PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer())
val rtcConfig = RTCConfiguration(iceServers) //new ArrayList<>()
val pcObserver: PeerConnection.Observer = object : PeerConnection.Observer {
private fun initializePeerConnections() {
localPeerConnection = createPeerConnection(factory, true)
remotePeerConnection = createPeerConnection(factory, false);
}
private fun createPeerConnection(factory: PeerConnectionFactory?, isLocal: Boolean): PeerConnection? {
val iceServers = ArrayList<PeerConnection.IceServer>()
iceServers.add(PeerConnection.IceServer.builder("stun:stun.l.google.com:19302").createIceServer())
val rtcConfig = RTCConfiguration(iceServers) //new ArrayList<>()
val pcObserver: PeerConnection.Observer = object : PeerConnection.Observer {
private fun initializeSurfaceViews() {
binding?.localGlSurfaceView?.init(rootEglBase?.eglBaseContext, null)
binding?.localGlSurfaceView?.setEnableHardwareScaler(true)
binding?.localGlSurfaceView?.setMirror(true)
binding.remoteGlSurfaceView.init(rootEglBase.getEglBaseContext(), null);
binding.remoteGlSurfaceView.setEnableHardwareScaler(true);
binding.remoteGlSurfaceView.setMirror(true);
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_gl_surface_view"
private fun createVideoTrackFromCameraAndShowIt() {
val videoCapturer: VideoCapturer? = createVideoCapturer()
//Create a VideoSource instance
videoCapturer?.let {
surfaceTextureHelper = SurfaceTextureHelper.create("CaptureThread", rootEglBase!!.eglBaseContext)
videoSource = factory?.createVideoSource(videoCapturer.isScreencast)
videoCapturer.initialize(surfaceTextureHelper, this, videoSource?.capturerObserver)
}
localVideoTrack = factory?.createVideoTrack("100", videoSource)
@ShwetaChauhan18
ShwetaChauhan18 / InitializePeerConnectionFactory.kt
Last active April 12, 2020 14:48
initializePeerConnectionFactory
private fun initializePeerConnectionFactory() {
val rootEglBase = EglBase.create();
//Initialize PeerConnectionFactory globals.
val initializationOptions = InitializationOptions.builder(this).createInitializationOptions()
PeerConnectionFactory.initialize(initializationOptions)
//Create a new PeerConnectionFactory instance - using Hardware encoder and decoder.
val options = PeerConnectionFactory.Options()
val defaultVideoEncoderFactory = DefaultVideoEncoderFactory(rootEglBase?.eglBaseContext, /* enableIntelVp8Encoder */true, /* enableH264HighProfile */true)
<com.simform.customcomponent.SSCustomEdittextOutlinedBorder
android:id="@+id/edtAbout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_10sdp"
android:inputType="textMultiLine|textCapSentences"
app:custom_component_editText_hint="@string/edt_hint_about"
app:custom_component_maxline="3"
app:custom_component_minline="3"
app:custom_component_maxLength="25"
+-----------------------------------------+--------------------------------------------+---------------------------------------+
| Attribute | Description | Default |
+-----------------------------------------+--------------------------------------------+---------------------------------------+
| app:isErrorEnable | Whether the EditText error is enabled | false |
| app:custom_component_title | Set Outlined border title text | R.string.app_name |
| app:custom_component_editText_hint | Set EditText hint | R.string.app_name |
| app:custom_component_maxline | Set maximum height of the EditText | 1 |
| app:custom_component_minline | Set minimum height of the EditText | 1
ViewCompat.setOnApplyWindowInsetsListener(nav_view) { v, insets ->
// We'll set the views bottom padding to be the same
// value as the system gesture insets bottom value
v.updatePadding(
bottom = insets.systemWindowInsetBottom
)
// return the insets
insets
}