Skip to content

Commit a253879

Browse files
committed
First Commit
1 parent cf93323 commit a253879

36 files changed

+1575
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.gradle
2+
/local.properties
3+
/.idea/workspace.xml
4+
/.idea/libraries
5+
.DS_Store
6+
/build

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 21
5+
buildToolsVersion "20.0.0"
6+
7+
defaultConfig {
8+
applicationId "me.kevingleason.androidrtc"
9+
minSdkVersion 15
10+
targetSdkVersion 21
11+
versionCode 1
12+
versionName "1.0"
13+
}
14+
buildTypes {
15+
release {
16+
runProguard false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
compile 'io.pristine:libjingle:9127@aar'
25+
compile 'com.pubnub:pubnub-android:3.7.4'
26+
}

app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/GleasonK/algs4/AndroidSDK/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package me.kevingleason.androidrtc;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}

app/src/main/AndroidManifest.xml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="me.kevingleason.androidrtc" >
4+
5+
<!-- WebRTC Dependencies -->
6+
<uses-feature android:name="android.hardware.camera" />
7+
<uses-feature android:name="android.hardware.camera.autofocus" />
8+
<uses-feature
9+
android:glEsVersion="0x00020000"
10+
android:required="true" />
11+
12+
<uses-permission android:name="android.permission.CAMERA" />
13+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
14+
<uses-permission android:name="android.permission.INTERNET" />
15+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
16+
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
17+
18+
<!-- PubNub Dependencies -->
19+
<!--<uses-permission android:name="android.permission.INTERNET" />-->
20+
<uses-permission android:name="android.permission.WAKE_LOCK" />
21+
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
22+
<permission android:name="your.package.name.permission.C2D_MESSAGE" android:protectionLevel="signature" />
23+
<uses-permission android:name="your.package.name.permission.C2D_MESSAGE" />
24+
25+
<application
26+
android:allowBackup="true"
27+
android:icon="@drawable/ic_launcher"
28+
android:label="@string/app_name"
29+
android:theme="@style/AppTheme" >
30+
<activity
31+
android:name="me.kevingleason.androidrtc.MainActivity"
32+
android:label="@string/app_name" >
33+
<intent-filter>
34+
<action android:name="android.intent.action.MAIN" />
35+
36+
<category android:name="android.intent.category.LAUNCHER" />
37+
</intent-filter>
38+
</activity>
39+
<activity
40+
android:name="me.kevingleason.androidrtc.VideoChatActivity"
41+
android:label="@string/title_activity_video_chat"
42+
android:parentActivityName="me.kevingleason.androidrtc.MainActivity" >
43+
<meta-data
44+
android:name="android.support.PARENT_ACTIVITY"
45+
android:value="me.kevingleason.androidrtc.MainActivity" />
46+
</activity>
47+
</application>
48+
49+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package me.kevingleason.androidrtc;
2+
3+
import android.util.Log;
4+
5+
import org.json.JSONObject;
6+
import org.webrtc.MediaStream;
7+
8+
import me.kevingleason.androidrtc.api.PnPeer;
9+
import me.kevingleason.androidrtc.api.PnRTCListener;
10+
import me.kevingleason.androidrtc.api.PnRTCMessage;
11+
12+
/**
13+
* Created by GleasonK on 7/23/15.
14+
*/
15+
public class LogRTCListener extends PnRTCListener {
16+
@Override
17+
public void onCallReady(String callId) {
18+
Log.i("RTCListener", "OnCallReady - " + callId);
19+
}
20+
21+
@Override
22+
public void onConnected(String userId) {
23+
Log.i("RTCListener", "OnConnected - " + userId);
24+
}
25+
26+
@Override
27+
public void onStatusChanged(PnPeer peer) {
28+
Log.i("RTCListener", "OnStatusChanged - " + peer.toString());
29+
}
30+
31+
@Override
32+
public void onLocalStream(MediaStream localStream) {
33+
Log.i("RTCListener", "OnLocalStream - " + localStream.toString());
34+
}
35+
36+
@Override
37+
public void onAddRemoteStream(MediaStream remoteStream, PnPeer peer) {
38+
Log.i("RTCListener", "OnAddRemoteStream - " + peer.toString());
39+
}
40+
41+
@Override
42+
public void onRemoveRemoteStream(MediaStream remoteStream, PnPeer peer) {
43+
Log.i("RTCListener", "OnRemoveRemoteStream - " + peer.toString());
44+
}
45+
46+
@Override
47+
public void onMessage(PnPeer peer, Object message) {
48+
Log.i("RTCListener", "OnMessage - " + ((JSONObject)message).toString());
49+
}
50+
51+
@Override
52+
public void onDebug(PnRTCMessage message) {
53+
Log.i("RTCListener", "OnDebug - " + message.getMessage());
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package me.kevingleason.androidrtc;
2+
3+
import android.app.Activity;
4+
import android.content.Intent;
5+
import android.os.Bundle;
6+
import android.view.Menu;
7+
import android.view.MenuItem;
8+
import android.view.View;
9+
10+
11+
public class MainActivity extends Activity {
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_main);
17+
}
18+
19+
20+
@Override
21+
public boolean onCreateOptionsMenu(Menu menu) {
22+
// Inflate the menu; this adds items to the action bar if it is present.
23+
getMenuInflater().inflate(R.menu.menu_main, menu);
24+
return true;
25+
}
26+
27+
@Override
28+
public boolean onOptionsItemSelected(MenuItem item) {
29+
// Handle action bar item clicks here. The action bar will
30+
// automatically handle clicks on the Home/Up button, so long
31+
// as you specify a parent activity in AndroidManifest.xml.
32+
int id = item.getItemId();
33+
34+
//noinspection SimplifiableIfStatement
35+
if (id == R.id.action_settings) {
36+
return true;
37+
}
38+
39+
return super.onOptionsItemSelected(item);
40+
}
41+
42+
public void toVideo(View view){
43+
Intent intent = new Intent(this, VideoChatActivity.class);
44+
startActivity(intent);
45+
}
46+
}

0 commit comments

Comments
 (0)