Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
* OTS-283: docs refactor (#145)

* edited for clarity and professionalism

* OTS-283: 1-1 sample app reorg

* OTS-283: 1-1 sample app reorg

* OTS-283: 1-1 sample app reorg

* Bump npm version.

* Bug fix: unsubscribe streams from the session (#147)

* add reconnection logic

* Updating one-to-one in Android (#148)

* add permission for avoiding crash in iOS 10

* Fixing dirs (#152)

* update README.md
  • Loading branch information
marinaserranomontes authored Oct 9, 2016
1 parent 5a969d8 commit e231af4
Show file tree
Hide file tree
Showing 200 changed files with 574 additions and 965 deletions.
48 changes: 44 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
![logo](./tokbox-logo.png)

# OpenTok One-to-One Communication Sample Apps<br/>Version 1.1
# OpenTok One-to-One Communication Sample App<br/>Version 1.2

This is where you can explore the OpenTok sample apps! These samples include the use of accelerator packs, available from your TokBox representative, which you can use to quickly and easily develop powerful OpenTok applications.
The OpenTok One-to-One Communication Sample App is an open-source solution that enables you to quickly get started in your development efforts to set up interoperable, production-quality audio/video communication between users.

All of the sample apps are based on the the OpenTok One-to-One Communication Sample App, which is an open-source solution that enables you to quickly get started in your development efforts to set up interoperable, production-quality audio/video communication between users.
As you get started with this OpenTok sample, you will learn the best practices used to develop and manage the audio, video, and camera elements on mobile devices or in the browser. We recommend this is as your first step in delivering [Real Time Communications (WebRTC)](https://tokbox.com/about-webrtc) solutions on the OpenTok platform.

- **[One-to-One Communication Sample App](./one-to-one-sample-app)**: Begin by exploring this sample app, and learn the best practices used to develop and manage the audio, video, and camera elements on mobile devices or in the browser.
With this sample app, you can:

- Start and end audio/visual communication between two users.
- Achieve interoperability between web and mobile devices.
- Mute or unmute audio.
- Enable or disable video.
- Control the camera to point in the forward direction or in the reverse direction (selfie mode).
- Customize the UI features and layout.

You can create mobile apps for Android and iOS, or embed the interactive session between users into any website.

To get started with your development, visit the following sites:

- [OpenTok One-to-One Communication Sample App for Android](./android)
- [OpenTok One-to-One Communication Sample App for iOS](./iOS)
- [OpenTok One-to-One Communication Sample App for JavaScript](./js)

_**NOTE: The audio-video communication logic provided in all OpenTok One-to-One Communication Sample Apps is contained in the [OpenTok Common Accelerator Session Pack](https://github.com/opentok/acc-pack-common).**_



# Device interoperability with One-to-One communication

The OpenTok One-to-One Communication Sample App highlights the interoperability of web and mobile devices using the OpenTok platform. Regardless of the supported devices used, the OpenTok platform supports the ability of users to interact with each other and exchange audio and video. Even if the clients are on different platforms, they can both connect, publish, and subscribe to streams in the same session.

This sample app requires a **Session ID**, **Token**, and **API Key**. In the sample, you can get these values at the [OpenTok Developer Dashboard](https://dashboard.tokbox.com/). For production deployment, you must generate the **Session ID** and **Token** values using one of the [OpenTok Server SDKs](https://tokbox.com/developer/sdks/server/).

For example, suppose one user is using a web (JS) version of the One-to-One Communication Sample App and another user is using a mobile version (Android or iOS). If they are both using the same **Session ID** and **API Key**, they can subscribe to each other’s audio and video streams, and the user interface rendered on both devices will allow them to interact with each other and take advantage of all the features of the sample app.

Use the following approach to try this out:

1. Configure a web and mobile user with the required **Session ID**, **Token**, and **API Key** values, using the same **Session ID** and **API Key** for each.

2. For mobile users, ensure that `SUBSCRIBE_TO_SELF = false` (Android) and `subscribeToSelf = NO` (iOS) in the configuration.

3. Start the web and mobile apps. You will observe the following interactions:

- Both apps connect to the session.
- Both apps start publishing and subscribing to each other’s streams.

4. Observe what happens for each user when you:

- Enable or disable local audio/video on the mobile app.
- Enable or disable local audio/video on the web app.
- Enable or disable remote audio/video on the mobile app.
- Enable or disable remote audio/video on the web app.
13 changes: 13 additions & 0 deletions one-to-one-sample-app/RELEASE-NOTES.md → RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# RELEASE NOTES

## OpenTok One-to-One Communication Sample App Version 1.2

### New Features and Enhancements

- (Android and iOS only) The One-to-One Communication Sample App includes the session reconnections callbacks.
- (Android only) New camera callabcks.

### Resolved Issues

- (Android only) There was in issue with the audio and video permissions denied for Android version 6+. This issue has been resolved.
- (_iOS only) There was in issue with UIs didn't get reset after ending the call. This issue has been resolved.
- (_JS only) There was in issue trying to unsubscribe a stream from the session. This issue has been resolved.

## OpenTok One-to-One Communication Sample App Version 1.1

### New Features and Enhancements
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
versionName "1.2"
archivesBaseName = "OneToOneSample-$versionName"
}
buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
Expand All @@ -31,7 +34,7 @@


public class MainActivity extends AppCompatActivity implements OneToOneCommunication.Listener, PreviewControlFragment.PreviewControlCallbacks, RemoteControlFragment.RemoteControlCallbacks, PreviewCameraFragment.PreviewCameraCallbacks {
private final String LOGTAG = "opentok-main-activity";
private final String LOGTAG = MainActivity.class.getSimpleName();

private final String[] permissions = {Manifest.permission.RECORD_AUDIO, Manifest.permission.CAMERA};
private final int permsRequestCode = 200;
Expand All @@ -56,6 +59,8 @@ public class MainActivity extends AppCompatActivity implements OneToOneCommunica
private OTKAnalyticsData mAnalyticsData;
private OTKAnalytics mAnalytics;

private boolean mAudioPermission = false;
private boolean mVideoPermission = false;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -90,8 +95,15 @@ protected void onCreate(Bundle savedInstanceState) {
mLocalAudioOnlyView = (RelativeLayout) findViewById(R.id.localAudioOnlyView);

//request Marshmallow camera permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(permissions, permsRequestCode);
//request Marshmallow camera permission
if (ContextCompat.checkSelfPermission(this,permissions[1]) != PackageManager.PERMISSION_GRANTED || ContextCompat.checkSelfPermission(this,permissions[0]) != PackageManager.PERMISSION_GRANTED){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(permissions, permsRequestCode);
}
}
else {
mVideoPermission = true;
mAudioPermission = true;
}

//init 1to1 communication object
Expand Down Expand Up @@ -144,13 +156,37 @@ public void onConfigurationChanged(Configuration newConfig) {
}

@Override
public void onRequestPermissionsResult(int permsRequestCode, String[] permissions,
public void onRequestPermissionsResult(final int permsRequestCode, final String[] permissions,
int[] grantResults) {
switch (permsRequestCode) {

case 200:
boolean video = grantResults[0] == PackageManager.PERMISSION_GRANTED;
boolean audio = grantResults[1] == PackageManager.PERMISSION_GRANTED;
mVideoPermission = grantResults[0] == PackageManager.PERMISSION_GRANTED;
mAudioPermission = grantResults[1] == PackageManager.PERMISSION_GRANTED;


if ( !mVideoPermission || !mAudioPermission ){
final AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(getResources().getString(R.string.permissions_denied_title));
builder.setMessage(getResources().getString(R.string.alert_permissions_denied));
builder.setPositiveButton("I'M SURE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setNegativeButton("RE-TRY", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(permissions, permsRequestCode);
}
}
});
builder.show();
}

break;
}
}
Expand Down Expand Up @@ -263,19 +299,25 @@ private void cleanViewsAndControls() {

@Override
public void onInitialized() {
Log.i(LOGTAG, "OneToOne communication has been initialized.");

addLogEvent(OpenTokConfig.LOG_ACTION_START_COMM, OpenTokConfig.LOG_VARIATION_SUCCESS);
}

//OneToOneCommunication callbacks
@Override
public void onError(String error) {
Log.i(LOGTAG, "Error: "+error);

Toast.makeText(this, error, Toast.LENGTH_LONG).show();
mComm.end(); //end communication
cleanViewsAndControls(); //restart views
}

@Override
public void onQualityWarning(boolean warning) {
Log.i(LOGTAG, "The quality has degraded");

if (warning) { //quality warning
mAlert.setBackgroundResource(R.color.quality_warning);
mAlert.setTextColor(this.getResources().getColor(R.color.warning_text));
Expand All @@ -295,9 +337,11 @@ public void run() {
@Override
public void onAudioOnly(boolean enabled) {
if (enabled) {
Log.i(LOGTAG, "Audio only is enabled");
mAudioOnlyView.setVisibility(View.VISIBLE);
}
else {
Log.i(LOGTAG, "Audio only is disabled");
mAudioOnlyView.setVisibility(View.GONE);
}
}
Expand All @@ -306,6 +350,7 @@ public void onAudioOnly(boolean enabled) {
public void onPreviewReady(View preview) {
mPreviewViewContainer.removeAllViews();
if (preview != null) {
Log.i(LOGTAG, "The preview view is ready to be attached");
layoutParamsPreview = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

Expand Down Expand Up @@ -339,6 +384,7 @@ public void onRemoteViewReady(View remoteView) {
mRemoteViewContainer.setClickable(false);
}
else {
Log.i(LOGTAG, "The remote view is ready to be attached.");
//show remote view
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
this.getResources().getDisplayMetrics().widthPixels, this.getResources()
Expand All @@ -349,6 +395,23 @@ public void onRemoteViewReady(View remoteView) {
}
}

@Override
public void onReconnecting() {
Log.i(LOGTAG, "The session is reconnecting.");
Toast.makeText(this, R.string.reconnecting, Toast.LENGTH_LONG).show();
}

@Override
public void onReconnected() {
Log.i(LOGTAG, "The session reconnected.");
Toast.makeText(this, R.string.reconnected, Toast.LENGTH_LONG).show();
}

@Override
public void onCameraChanged(int newCameraId) {
Log.i(LOGTAG, "The camera changed. New camera id is: "+newCameraId);
}

private void addLogEvent(String action, String variation){
if ( mAnalytics!= null ) {
mAnalytics.logEvent(action, variation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class OpenTokConfig {
public static final boolean SUBSCRIBE_TO_SELF = false;

// For internal use only. Please do not modify or remove this code.
public static final String LOG_CLIENT_VERSION = "android-vsol-1.0.0";
public static final String LOG_CLIENT_VERSION = "android-vsol-1.1.0";
public static final String LOG_COMPONENTID = "oneToOneSample";
public static final String LOG_ACTION_INITIALIZE = "Init";
public static final String LOG_ACTION_START_COMM = "Start";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class PreviewCameraFragment extends Fragment {

private static final String LOGTAG = "opentok-previewcamera";
private static final String LOGTAG = PreviewCameraFragment.class.getSimpleName();
private MainActivity mActivity;

private RelativeLayout mContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class PreviewControlFragment extends Fragment {

private static final String LOGTAG = "opentok-previewcontrol";
private static final String LOGTAG = PreviewControlFragment.class.getSimpleName();

private MainActivity mActivity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class RemoteControlFragment extends Fragment {

private static final String LOGTAG = "opentok-remotecontrol";
private static final String LOGTAG = RemoteControlFragment.class.getSimpleName();
private static final int ANIMATION_DURATION = 7000;

private MainActivity mActivity;
Expand Down
9 changes: 9 additions & 0 deletions android/OneToOneSample/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<resources>
<string name="app_name">OneToOneSample</string>
<string name="network_quality">Network connection is unstable.</string>
<string name="reconnecting">The session is reconnecting</string>
<string name="reconnected">The session reconnected</string>
<string name="permissions_denied_title">Permissions Denied</string>
<string name="permissions_denied">Cannot use this app without requested permission. Please, grant audio and video permissions</string>
<string name="alert_permissions_denied">Without these permissions the app is unable to make call.Are you sure you want to deny these permissions?</string>
</resources>
Loading

0 comments on commit e231af4

Please sign in to comment.