Skip to content

Commit 007c4a4

Browse files
author
KingYin
committed
Initial commit
0 parents  commit 007c4a4

File tree

136 files changed

+22388
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+22388
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/.gitignore

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

app/build.gradle

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion rootProject.ext.compileSdkVersion
5+
buildToolsVersion rootProject.ext.buildToolsVersion
6+
defaultConfig {
7+
applicationId "com.wangshuo.wslive.wslivedemo"
8+
minSdkVersion 18
9+
targetSdkVersion 22
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
ndk {
14+
abiFilters "armeabi-v7a"
15+
}
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
}
24+
25+
dependencies {
26+
compile fileTree(dir: 'libs', include: ['*.jar'])
27+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28+
exclude group: 'com.android.support', module: 'support-annotations'
29+
})
30+
compile 'com.android.support:appcompat-v7:26.+'
31+
testCompile 'junit:junit:4.12'
32+
33+
compile project(':libWSLive')
34+
}

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 C:\Users\mayn\AppData\Local\Android\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,26 @@
1+
package com.wangshuo.wslive.wslivedemo;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.wangshuo.wslive.wslivedemo", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.wangshuo.wslive.wslivedemo">
4+
5+
<uses-feature android:name="android.hardware.camera"/>
6+
<uses-feature android:name="android.hardware.camera.autofocus"/>
7+
<uses-feature android:name="android.hardware.camera.flash"/>
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.WRITE_EXTERNAL_STORAGE"/>
16+
17+
<application
18+
android:allowBackup="true"
19+
android:icon="@mipmap/ic_launcher"
20+
android:label="@string/app_name"
21+
android:supportsRtl="true"
22+
android:theme="@style/AppTheme">
23+
<activity android:name=".LiveActivity"
24+
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
25+
android:screenOrientation="portrait">
26+
<intent-filter>
27+
<action android:name="android.intent.action.MAIN"/>
28+
29+
<category android:name="android.intent.category.LAUNCHER"/>
30+
</intent-filter>
31+
</activity>
32+
</application>
33+
34+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.wangshuo.wslive.wslivedemo;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.widget.Toast;
6+
7+
import java.util.LinkedList;
8+
import java.util.Random;
9+
10+
import me.lake.librestreaming.core.listener.RESConnectionListener;
11+
import me.lake.librestreaming.filter.hardvideofilter.BaseHardVideoFilter;
12+
import me.lake.librestreaming.filter.hardvideofilter.HardVideoGroupFilter;
13+
import me.lake.librestreaming.ws.StreamAVOption;
14+
import me.lake.librestreaming.ws.StreamLiveCameraView;
15+
import me.lake.librestreaming.ws.filter.hardfilter.GPUImageBeautyFilter;
16+
import me.lake.librestreaming.ws.filter.hardfilter.extra.GPUImageCompatibleFilter;
17+
18+
public class LiveActivity extends AppCompatActivity {
19+
private static final String TAG = LiveActivity.class.getSimpleName();
20+
private StreamLiveCameraView mLiveCameraView;
21+
private StreamAVOption streamAVOption;
22+
private String rtmpUrl = "rtmp://ossrs.net/" + getRandomAlphaString(3) + '/' + getRandomAlphaDigitString(5);
23+
24+
private LiveUI mLiveUI;
25+
26+
@Override
27+
protected void onCreate(Bundle savedInstanceState) {
28+
super.onCreate(savedInstanceState);
29+
setContentView(R.layout.activity_live);
30+
StatusBarUtils.setTranslucentStatus(this);
31+
32+
initLiveConfig();
33+
mLiveUI = new LiveUI(this,mLiveCameraView,rtmpUrl);
34+
}
35+
36+
/**
37+
* 设置推流参数
38+
*/
39+
public void initLiveConfig() {
40+
mLiveCameraView = (StreamLiveCameraView) findViewById(R.id.stream_previewView);
41+
42+
//参数配置 start
43+
streamAVOption = new StreamAVOption();
44+
streamAVOption.streamUrl = rtmpUrl;
45+
//参数配置 end
46+
47+
mLiveCameraView.init(this, streamAVOption);
48+
mLiveCameraView.addStreamStateListener(resConnectionListener);
49+
LinkedList<BaseHardVideoFilter> files = new LinkedList<>();
50+
files.add(new GPUImageCompatibleFilter(new GPUImageBeautyFilter()));
51+
//files.add(new GPUImageCompatibleFilter(new GPUImageAddBlendFilter()));
52+
mLiveCameraView.setHardVideoFilter(new HardVideoGroupFilter(files));
53+
}
54+
55+
RESConnectionListener resConnectionListener = new RESConnectionListener() {
56+
@Override
57+
public void onOpenConnectionResult(int result) {
58+
//result 0成功 1 失败
59+
Toast.makeText(LiveActivity.this,"打开推流连接 状态:"+result+ " 推流地址:"+rtmpUrl,Toast.LENGTH_LONG).show();
60+
}
61+
62+
@Override
63+
public void onWriteError(int errno) {
64+
Toast.makeText(LiveActivity.this,"推流出错",Toast.LENGTH_LONG).show();
65+
}
66+
67+
@Override
68+
public void onCloseConnectionResult(int result) {
69+
//result 0成功 1 失败
70+
Toast.makeText(LiveActivity.this,"关闭推流连接 状态:"+result,Toast.LENGTH_LONG).show();
71+
}
72+
};
73+
74+
@Override
75+
protected void onDestroy() {
76+
super.onDestroy();
77+
mLiveCameraView.destroy();
78+
}
79+
80+
81+
private static String getRandomAlphaString(int length) {
82+
String base = "abcdefghijklmnopqrstuvwxyz";
83+
Random random = new Random();
84+
StringBuilder sb = new StringBuilder();
85+
for (int i = 0; i < length; i++) {
86+
int number = random.nextInt(base.length());
87+
sb.append(base.charAt(number));
88+
}
89+
return sb.toString();
90+
}
91+
92+
private static String getRandomAlphaDigitString(int length) {
93+
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
94+
Random random = new Random();
95+
StringBuilder sb = new StringBuilder();
96+
for (int i = 0; i < length; i++) {
97+
int number = random.nextInt(base.length());
98+
sb.append(base.charAt(number));
99+
}
100+
return sb.toString();
101+
}
102+
}

0 commit comments

Comments
 (0)