This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.webrtccodelab; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.util.Log; | |
import org.webrtc.AudioSource; | |
import org.webrtc.AudioTrack; | |
import org.webrtc.Camera1Enumerator; | |
import org.webrtc.Camera2Enumerator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void start() { | |
//Initialize PeerConnectionFactory globals. | |
//Params are context, initAudio,initVideo and videoCodecHwAcceleration | |
PeerConnectionFactory.initializeAndroidGlobals(this, true, true, true); | |
//Create a new PeerConnectionFactory instance. | |
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); | |
peerConnectionFactory = new PeerConnectionFactory(options); | |
//Now create a VideoCapturer instance. Callback methods are there if you want to do something! Duh! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private VideoCapturer createVideoCapturer() { | |
VideoCapturer videoCapturer; | |
videoCapturer = createCameraCapturer(new Camera1Enumerator(false)); | |
return videoCapturer; | |
} | |
private VideoCapturer createCameraCapturer(CameraEnumerator enumerator) { | |
final String[] deviceNames = enumerator.getDeviceNames(); | |
// Trying to find a front facing camera! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var os = require('os'); | |
var nodeStatic = require('node-static'); | |
var https = require('https'); | |
var socketIO = require('socket.io'); | |
var fs = require("fs"); | |
var options = { | |
key: fs.readFileSync('key.pem'), | |
cert: fs.readFileSync('cert.pem') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity implements View.OnClickListener, SignallingClient.SignalingInterface { | |
PeerConnectionFactory peerConnectionFactory; | |
MediaConstraints audioConstraints; | |
MediaConstraints videoConstraints; | |
MediaConstraints sdpConstraints; | |
VideoSource videoSource; | |
VideoTrack localVideoTrack; | |
AudioSource audioSource; | |
AudioTrack localAudioTrack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SignallingClient { | |
private static SignallingClient instance; | |
private String roomName = null; | |
private Socket socket; | |
boolean isChannelReady = false; | |
boolean isInitiator = false; | |
boolean isStarted = false; | |
private SignalingInterface callback; | |
//This piece of code should not go into production!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivityKotlin : AppCompatActivity(), View.OnClickListener, SignallingClientKotlin.SignalingInterface { | |
private val rootEglBase by lazy { EglBase.create() } | |
private val peerConnectionFactory: PeerConnectionFactory by lazy { | |
//Initialize PeerConnectionFactory globals. | |
val initializationOptions = PeerConnectionFactory.InitializationOptions.builder(this) | |
.setEnableVideoHwAcceleration(true) | |
.createInitializationOptions() | |
PeerConnectionFactory.initialize(initializationOptions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class SignallingClientKotlin { | |
internal interface SignalingInterface { | |
fun onRemoteHangUp(msg: String) | |
fun onOfferReceived(data: JSONObject) | |
fun onAnswerReceived(data: JSONObject) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package xyz.vivekc.shared | |
//Mark the function dependent on platform implementation to be `expect` | |
expect fun getCurrentDate(): String | |
//This is the function which would be called by the Android or iOS app | |
fun getDate(): String { | |
return "Today's Date is ${getCurrentDate()}" | |
} |
OlderNewer