|
| 1 | +package me.kevingleason.androidrtc; |
| 2 | + |
| 3 | +import android.app.Activity; |
| 4 | +import android.opengl.GLSurfaceView; |
| 5 | + |
| 6 | +import org.webrtc.AudioSource; |
| 7 | +import org.webrtc.AudioTrack; |
| 8 | +import org.webrtc.MediaConstraints; |
| 9 | +import org.webrtc.MediaStream; |
| 10 | +import org.webrtc.PeerConnection; |
| 11 | +import org.webrtc.PeerConnectionFactory; |
| 12 | +import org.webrtc.VideoCapturer; |
| 13 | +import org.webrtc.VideoCapturerAndroid; |
| 14 | +import org.webrtc.VideoRenderer; |
| 15 | +import org.webrtc.VideoRendererGui; |
| 16 | +import org.webrtc.VideoSource; |
| 17 | +import org.webrtc.VideoTrack; |
| 18 | + |
| 19 | +/** |
| 20 | + * Created by GleasonK on 7/17/15. |
| 21 | + */ |
| 22 | +public class DemoRTC extends Activity { |
| 23 | +/* |
| 24 | + public static final String VIDEO_TRACK_ID = "MyVideo"; |
| 25 | + public static final String AUDIO_TRACK_ID = "MyAudio"; |
| 26 | + public static final String LOCAL_MEDIA_STREAM_ID = "MyStream"; |
| 27 | + public static int x, y, width, height; |
| 28 | +
|
| 29 | +
|
| 30 | + @Override |
| 31 | + public void onCreate(){ |
| 32 | + PeerConnectionFactory.initializeAndroidGlobals( |
| 33 | + this, // Context |
| 34 | + true, // Audio Enabled |
| 35 | + true, // Video Enabled |
| 36 | + true, // Hardware Acceleration Enabled |
| 37 | + null); // Render EGL Context |
| 38 | +
|
| 39 | + PeerConnectionFactory peerConnectionFactory = new PeerConnectionFactory(); |
| 40 | +
|
| 41 | + // Setup Video Stream Locally |
| 42 | + VideoCapturerAndroid.getDeviceCount(); |
| 43 | + VideoCapturerAndroid.getNameOfFrontFacingDevice(); |
| 44 | + VideoCapturerAndroid.getNameOfBackFacingDevice(); |
| 45 | + VideoCapturer capturer = VideoCapturerAndroid.create("KevinsDroid"); |
| 46 | + MediaConstraints videoConstraints = new MediaConstraints(); |
| 47 | + // TODO: Setup Video Constraints |
| 48 | + VideoSource videoSource = peerConnectionFactory.createVideoSource(capturer, videoConstraints); |
| 49 | + VideoTrack localVideoTrack = peerConnectionFactory.createVideoTrack(VIDEO_TRACK_ID, videoSource); |
| 50 | +
|
| 51 | + // Setup Audio Stream |
| 52 | + MediaConstraints audioConstraints = new MediaConstraints(); |
| 53 | + // TODO Setup Audio Constraints |
| 54 | + AudioSource audioSource = peerConnectionFactory.createAudioSource(audioConstraints); |
| 55 | + AudioTrack localAudioTrack = peerConnectionFactory.createAudioTrack(AUDIO_TRACK_ID, audioSource); |
| 56 | +
|
| 57 | + GLSurfaceView videoView = (GLSurfaceView) findViewById(R.id.glview_call); |
| 58 | + VideoRendererGui.setView(videoView, runnable); |
| 59 | + VideoRenderer renderer = VideoRendererGui.createGui(x, y, width, height, scaleType, false); |
| 60 | + localVideoTrack.addRenderer(renderer); |
| 61 | +
|
| 62 | + // Our Local MediaStream object |
| 63 | + MediaStream mediaStream = peerConnectionFactory.createLocalMediaStream(LOCAL_MEDIA_STREAM_ID); |
| 64 | + mediaStream.addTrack(localVideoTrack); |
| 65 | + mediaStream.addTrack(localAudioTrack); |
| 66 | +
|
| 67 | + // TODO PUBNUB TO SET UP PEER CONNECTION |
| 68 | + PeerConnection peerConnection = peerConnectionFactory.createPeerConnection( |
| 69 | + iceServers, |
| 70 | + constraints, |
| 71 | + observer); |
| 72 | + peerConnection.addStream(mediaStream); |
| 73 | + peerConnection.createOffer(); |
| 74 | + peerConnection.createAnswer(); |
| 75 | + } |
| 76 | +
|
| 77 | +*/ |
| 78 | +} |
0 commit comments