Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PRWrl committed Sep 27, 2018
0 parents commit 87112d6
Show file tree
Hide file tree
Showing 353 changed files with 26,652 additions and 0 deletions.
48 changes: 48 additions & 0 deletions OpenLive-Android/.gitignore
@@ -0,0 +1,48 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
build/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

# Mac OS X
.DS_Store

# Android Studio
.gradle
/local.properties
/.idea/workspace.xml
obj/

.externalNativeBuild

# cscope or ctags files
cscope.in.out
cscope.out
cscope.po.out
tags

9 changes: 9 additions & 0 deletions OpenLive-Android/LICENSE
@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2016 Agora Lab, Inc (http://www.agora.io/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

64 changes: 64 additions & 0 deletions OpenLive-Android/README.md
@@ -0,0 +1,64 @@
# OpenLive for Android

*其他语言版本: [简体中文](README.zh.md)*

The OpenLive for Android Sample App is an open-source demo that will help you get live video broadcasting integrated directly into your Android applications using the Agora Video SDK.

With this sample app, you can:

- Join / leave channel
- Set role as broadcaster or audience
- Mute / unmute audio
- Switch camera
- Setup resolution, frame rate and bit rate

A tutorial demo can be found here: [Agora-Android-Tutorial-1to1](https://github.com/AgoraIO/Agora-Android-Tutorial-1to1)

Agora Video SDK supports iOS / Android / Windows / macOS etc. You can find demos of these platform here:

- [OpenLive-iOS](https://github.com/AgoraIO/OpenLive-iOS)
- [OpenLive-Windows](https://github.com/AgoraIO/OpenLive-Windows)
- [OpenLive-macOS](https://github.com/AgoraIO/OpenLive-macOS)

## Running the App
**First**, create a developer account at [Agora.io](https://dashboard.agora.io/signin/), and obtain an App ID. Update "app/src/main/res/values/strings_config.xml" with your App ID.

```
<string name="private_app_id"><#YOUR APP ID#></string>
```

**Next**, integrate the Agora Video SDK and there are two ways to integrate:

- The recommended way to integrate:

Add the address which can integrate the Agora Video SDK automatically through JCenter in the property of the dependence of the "app/build.gradle":
```
compile 'io.agora.rtc:full-sdk:2.2.0'
```
(Adding the link address is the most important step if you want to integrate the Agora Video SDK in your own application.)

- Alternative way to integrate:

First, download the **Agora Video SDK** from [Agora.io SDK](https://www.agora.io/en/download/). Unzip the downloaded SDK package and copy ***.jar** under **libs** to **app/libs**, **arm64-v8a**/**x86**/**armeabi-v7a** under **libs** to **app/src/main/jniLibs**.

Then, add the following code in the property of the dependence of the "app/build.gradle":

```
compile fileTree(dir: 'libs', include: ['*.jar'])
```

**Finally**, open project with Android Studio, connect your Android device, build and run.

Or use `Gradle` to build and run.

## Developer Environment Requirements
- Android Studio 2.0 or above
- Real devices (Nexus 5X or other devices)
- Some simulators are function missing or have performance issue, so real device is the best choice

## Connect Us
- You can find full API document at [Document Center](https://docs.agora.io/en/)
- You can file bugs about this demo at [issue](https://github.com/AgoraIO/OpenLive-Android/issues)

## License
The MIT License (MIT).
69 changes: 69 additions & 0 deletions OpenLive-Android/README.zh.md
@@ -0,0 +1,69 @@
# OpenLive for Android

*Read this in other languages: [English](README.md)*

这个开源示例项目演示了如何快速集成 Agora 视频 SDK,实现多人视频连麦直播。

在这个示例项目中包含了以下功能:

- 加入通话和离开通话;
- 主播和观众模式切换;
- 静音和解除静音;
- 切换前置摄像头和后置摄像头;
- 选择分辨率、码率和帧率;

你也可以在这里查看入门版的示例项目:[Agora-Android-Tutorial-1to1](https://github.com/AgoraIO/Agora-Android-Tutorial-1to1)

Agora 视频 SDK 支持 iOS / Android / Windows / macOS 等多个平台,你可以查看对应各平台的示例项目:

- [OpenLive-iOS](https://github.com/AgoraIO/OpenLive-iOS)
- [OpenLive-Windows](https://github.com/AgoraIO/OpenLive-Windows)
- [OpenLive-macOS](https://github.com/AgoraIO/OpenLive-macOS)

## 运行示例程序
**首先**[Agora.io 注册](https://dashboard.agora.io/cn/signup/) 注册账号,并创建自己的测试项目,获取到 AppID。将 AppID 填写进 "app/src/main/res/values/strings_config.xml"

```
<string name="private_app_id"><#YOUR APP ID#></string>
```

**然后**是集成 Agora 视频 SDK,集成方式有以下两种:

- 首选集成方式:

在项目对应的模块的 "app/build.gradle" 文件的依赖属性中加入通过 JCenter 自动集成 Agora 视频 SDK 的地址:

```
compile 'io.agora.rtc:full-sdk:2.2.0'
```

(如果要在自己的应用中集成 Agora 视频 SDK,添加链接地址是最重要的一步。)

- 次选集成方式:

第一步: 在 [Agora.io SDK](https://www.agora.io/cn/download/) 下载 **视频通话 + 直播 SDK**,解压后将其中的 **libs** 文件夹下的 ***.jar** 复制到本项目的 **app/libs** 下,其中的 **libs** 文件夹下的 **arm64-v8a**/**x86**/**armeabi-v7a** 复制到本项目的 **app/src/main/jniLibs** 下。

第二步: 在本项目的 "app/build.gradle" 文件依赖属性中添加如下依赖关系:

```
compile fileTree(dir: 'libs', include: ['*.jar'])
```

**最后**用 Android Studio 打开该项目,连上设备,编译并运行。

也可以使用 `Gradle` 直接编译运行。

## 运行环境
- Android Studio 2.0 +
- 真实 Android 设备 (Nexus 5X 或者其它设备)
- 部分模拟器会存在功能缺失或者性能问题,所以推荐使用真机

## 联系我们
- 完整的 API 文档见 [文档中心](https://docs.agora.io/cn/)
- 如果在集成中遇到问题, 你可以到 [开发者社区](https://dev.agora.io/cn/) 提问
- 如果有售前咨询问题, 可以拨打 400 632 6626,或加入官方Q群 12742516 提问
- 如果需要售后技术支持, 你可以在 [Agora Dashboard](https://dashboard.agora.io) 提交工单
- 如果发现了示例代码的 bug, 欢迎提交 [issue](https://github.com/AgoraIO/OpenLive-Android/issues)

## 代码许可
The MIT License (MIT).
1 change: 1 addition & 0 deletions OpenLive-Android/app/.gitignore
@@ -0,0 +1 @@
/build
49 changes: 49 additions & 0 deletions OpenLive-Android/app/build.gradle
@@ -0,0 +1,49 @@
apply plugin: 'com.android.application'

repositories {
jcenter()
}

android {
compileSdkVersion 26

defaultConfig {
applicationId "io.agora.openlive"
minSdkVersion 16 // JELLY_BEAN
targetSdkVersion 26
versionCode 8
versionName "x.y.z"

ndk {
abiFilters "armeabi-v7a", "x86" // DO NOT MODIFY THIS LINE, IT'S UPDATED BY BUILD MACHINE AUTOMATICALLY.
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) // DO NOT CHANGE, CI may needs it when packaging
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'org.slf4j:slf4j-api:1.7.21'
implementation 'com.github.tony19:logback-android-core:1.1.1-4'
implementation('com.github.tony19:logback-android-classic:1.1.1-4') {
// workaround issue #73
exclude group: 'com.google.android', module: 'android'
}

androidTestImplementation 'com.jayway.android.robotium:robotium-solo:5.6.3'
}
1 change: 1 addition & 0 deletions OpenLive-Android/app/libs/PLACEHOLDER
@@ -0,0 +1 @@
agora-rtc-sdk.jar
17 changes: 17 additions & 0 deletions OpenLive-Android/app/proguard-rules.pro
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/guohai/Dev/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -0,0 +1,87 @@
package io.agora.openlive.ui;

import android.test.ActivityInstrumentationTestCase2;

import com.robotium.solo.Solo;

import io.agora.openlive.R;

public class BasicTests extends ActivityInstrumentationTestCase2<MainActivity> {

private Solo solo;

public BasicTests() {
super(MainActivity.class);
}

@Override
public void setUp() throws Exception {
solo = new Solo(getInstrumentation(), getActivity());
}

@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
}

public String getString(int resId) {
return solo.getString(resId);
}

public void testJoinAsBroadcaster() throws Exception {
String AUTO_TEST_CHANNEL_NAME = "auto_test_" + System.currentTimeMillis();

solo.unlockScreen();

solo.assertCurrentActivity("Expected MainActivity activity", "MainActivity");
solo.clearEditText(0);
solo.enterText(0, AUTO_TEST_CHANNEL_NAME);
solo.waitForText(AUTO_TEST_CHANNEL_NAME, 1, 2000L);

solo.clickOnView(solo.getView(R.id.button_join));

solo.waitForDialogToOpen(1000);

solo.clickOnButton(getString(R.string.label_broadcaster));

String targetActivity = LiveRoomActivity.class.getSimpleName();

solo.waitForLogMessage("onJoinChannelSuccess " + AUTO_TEST_CHANNEL_NAME, JOIN_CHANNEL_SUCCESS_THRESHOLD + 1000);

solo.waitForLogMessage("onFirstLocalVideoFrame ", FIRST_LOCAL_VIDEO_SHOWN_THRESHOLD + 500);

solo.assertCurrentActivity("Expected " + targetActivity + " activity", targetActivity);
}

private static final int FIRST_REMOTE_VIDEO_RECEIVED_THRESHOLD = 5000;
private static final int FIRST_LOCAL_VIDEO_SHOWN_THRESHOLD = 1500;
private static final int JOIN_CHANNEL_SUCCESS_THRESHOLD = 5000;

public void testJoinAsAudience() throws Exception {
String AUTO_TEST_CHANNEL_NAME = "for_auto_test";

solo.unlockScreen();

solo.assertCurrentActivity("Expected MainActivity activity", "MainActivity");
solo.clearEditText(0);
solo.enterText(0, AUTO_TEST_CHANNEL_NAME);
solo.waitForText(AUTO_TEST_CHANNEL_NAME, 1, 2000L);

solo.clickOnView(solo.getView(R.id.button_join));

solo.waitForDialogToOpen(1000);

solo.clickOnButton(getString(R.string.label_audience));

String targetActivity = LiveRoomActivity.class.getSimpleName();

solo.waitForLogMessage("onJoinChannelSuccess " + AUTO_TEST_CHANNEL_NAME, JOIN_CHANNEL_SUCCESS_THRESHOLD);

long firstRemoteVideoTs = System.currentTimeMillis();
solo.waitForLogMessage("onFirstRemoteVideoDecoded ", FIRST_REMOTE_VIDEO_RECEIVED_THRESHOLD + 1000);

solo.assertCurrentActivity("Expected " + targetActivity + " activity", targetActivity);

assertTrue("first remote video frame not received", System.currentTimeMillis() - firstRemoteVideoTs <= FIRST_REMOTE_VIDEO_RECEIVED_THRESHOLD);
}
}
39 changes: 39 additions & 0 deletions OpenLive-Android/app/src/main/AndroidManifest.xml
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.agora.openlive">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />

<application
android:name=".AGApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".ui.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.LiveRoomActivity"
android:screenOrientation="portrait"
android:theme="@style/FullscreenTheme" />
<activity
android:name=".ui.SettingsActivity"
android:screenOrientation="portrait"
android:label="@string/label_settings" />
</application>

</manifest>

0 comments on commit 87112d6

Please sign in to comment.