Skip to content

Commit

Permalink
Merge pull request #1 from ksvc/update-v1.0.1
Browse files Browse the repository at this point in the history
update to v1.0.1
  • Loading branch information
buliaoyin authored Dec 14, 2017
2 parents dce4372 + 65f607a commit 4386569
Show file tree
Hide file tree
Showing 130 changed files with 5,408 additions and 953 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.1'
}

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -15,6 +16,7 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

Expand Down
10 changes: 0 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,3 @@
echo "====================== copy libs ========"
rm -rf libunionstreamer/libs
cp -p -r prebuilt/libs libunionstreamer/

echo "====================== build ndk ========"
MODULES="fdkaacencoder x264encoder librtmppub"
for MODULE in $MODULES
do
cd $MODULE
ndk-build clean
ndk-build -j4
cd ..
done
36 changes: 18 additions & 18 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
compileSdkVersion 27
buildToolsVersion '27.0.1'

defaultConfig {
applicationId "org.opencdnunion.media.streamer.demo"
minSdkVersion 15
targetSdkVersion 25
minSdkVersion 19
targetSdkVersion 27
versionCode 100
versionName "1.0.0"

Expand All @@ -27,19 +27,19 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.lht:paintview:1.16'
compile 'com.facebook.fresco:fresco:1.4.0'
compile 'com.facebook.fresco:animated-gif:1.4.0'
compile 'com.facebook.fresco:animated-webp:1.4.0'
//compile 'com.facebook.fresco:webpsupport:1.4.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.jakewharton:butterknife:8.8.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.lht:paintview:1.17'
implementation 'com.facebook.fresco:fresco:1.4.0'
implementation 'com.facebook.fresco:animated-gif:1.4.0'
implementation 'com.facebook.fresco:animated-webp:1.4.0'
//implementation 'com.facebook.fresco:webpsupport:1.4.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
compile project(':libunionstreamer')
compile project(':x264encoder')
compile project(':fdkaacencoder')
compile project(':librtmppub')
implementation 'com.h6ah4i.android.widget.verticalseekbar:verticalseekbar:0.7.2'
implementation project(':libunionstreamer')
implementation project(':x264encoder')
implementation project(':fdkaacencoder')
implementation project(':librtmppub')
}
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import android.view.ViewGroup;
import android.widget.CheckBox;

import org.opencdnunion.media.streamer.capture.AudioPlayerCapture;
import org.opencdnunion.media.streamer.filter.audio.AudioFilterBase;
import org.opencdnunion.media.streamer.filter.audio.AudioReverbFilter;
import org.opencdnunion.media.streamer.filter.audio.KSYAudioEffectFilter;
import org.opencdnunion.media.streamer.filter.audio.AudioEffectFilter;
import org.opencdnunion.media.streamer.kit.UnionStreamer;

import java.util.LinkedList;
Expand All @@ -36,7 +37,10 @@ public class AudioFuncFragment extends Fragment {

protected StdCameraActivity mActivity;
protected UnionStreamer mStreamer;
protected String mBgmPath;

private int mChooseBGMFilter = 3;
private String[] mBGMFilterName = {"-3", "-2", "-1", "0", "1", "2", "3"};
private boolean[] mChooseFilter = {false, false, false, false, false, false,
false, false, false, false};

Expand All @@ -48,6 +52,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
ButterKnife.bind(this, view);
mActivity = (StdCameraActivity) getActivity();
mStreamer = mActivity.mStreamer;
mBgmPath = "file://" + mActivity.mSdcardPath + "/test.mp3";
return view;
}

Expand All @@ -73,6 +78,46 @@ public void onResume() {
}
}

@OnCheckedChanged(R.id.bgm)
protected void onBgmChecked(boolean isChecked) {
if (isChecked) {
mStreamer.getAudioPlayerCapture().setOnCompletionListener(mOnCompletionListener);
mStreamer.getAudioPlayerCapture().setOnErrorListener(mOnErrorListener);
mStreamer.getAudioPlayerCapture().setVolume(0.4f);
mStreamer.setEnableAudioMix(true);
mStreamer.startBgm(mBgmPath, true);
} else {
mStreamer.stopBgm();
}
}

@OnClick(R.id.bgm_filter)
protected void onChooseBGMFilter() {
AlertDialog alertDialog;
alertDialog = new AlertDialog.Builder(mActivity)
.setTitle("请选择背景音乐变调等级")
.setSingleChoiceItems(mBGMFilterName, mChooseBGMFilter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mChooseBGMFilter = which;
}
})
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int level = Integer.parseInt(mBGMFilterName[mChooseBGMFilter]);
AudioEffectFilter audioEffect = new AudioEffectFilter(
AudioEffectFilter.AUDIO_EFFECT_TYPE_PITCH);
audioEffect.setPitchLevel(level);
mStreamer.getAudioPlayerCapture().getAudioFilterMgt().setFilter(audioEffect);
dialog.dismiss();
}
})
.create();
alertDialog.setCancelable(false);
alertDialog.show();
}

@OnClick(R.id.audio_filter)
protected void showChooseAudioFilter() {
AlertDialog alertDialog;
Expand Down Expand Up @@ -102,23 +147,23 @@ public void onClick(DialogInterface dialog, int which) {
filters.add(demofilter);
}
if (mChooseFilter[2]) {
KSYAudioEffectFilter audioEffect = new KSYAudioEffectFilter(
KSYAudioEffectFilter.AUDIO_EFFECT_TYPE_FEMALE);
AudioEffectFilter audioEffect = new AudioEffectFilter(
AudioEffectFilter.AUDIO_EFFECT_TYPE_FEMALE);
filters.add(audioEffect);
}
if (mChooseFilter[3]) {
KSYAudioEffectFilter audioEffect = new KSYAudioEffectFilter(
KSYAudioEffectFilter.AUDIO_EFFECT_TYPE_MALE);
AudioEffectFilter audioEffect = new AudioEffectFilter(
AudioEffectFilter.AUDIO_EFFECT_TYPE_MALE);
filters.add(audioEffect);
}
if (mChooseFilter[4]) {
KSYAudioEffectFilter audioEffect = new KSYAudioEffectFilter(
KSYAudioEffectFilter.AUDIO_EFFECT_TYPE_HEROIC);
AudioEffectFilter audioEffect = new AudioEffectFilter(
AudioEffectFilter.AUDIO_EFFECT_TYPE_HEROIC);
filters.add(audioEffect);
}
if (mChooseFilter[5]) {
KSYAudioEffectFilter audioEffect = new KSYAudioEffectFilter(
KSYAudioEffectFilter.AUDIO_EFFECT_TYPE_ROBOT);
AudioEffectFilter audioEffect = new AudioEffectFilter(
AudioEffectFilter.AUDIO_EFFECT_TYPE_ROBOT);
filters.add(audioEffect);
}

Expand Down Expand Up @@ -155,4 +200,20 @@ protected void OnNSChecked(boolean isChecked){
protected void onAudioLDChecked(boolean isChecked) {
mStreamer.setEnableAudioLowDelay(isChecked);
}

AudioPlayerCapture.OnCompletionListener mOnCompletionListener =
new AudioPlayerCapture.OnCompletionListener() {
@Override
public void onCompletion(AudioPlayerCapture audioPlayerCapture) {
Log.d(TAG, "End of the currently playing music");
}
};

AudioPlayerCapture.OnErrorListener mOnErrorListener = new AudioPlayerCapture.OnErrorListener() {
@Override
public void onError(AudioPlayerCapture audioPlayerCapture, int what, long extra) {
Log.e(TAG, "OnErrorListener, Error:" + what + ", extra:" + extra);
mStreamer.stopBgm();
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected void config() {
}

protected void handleOnResume() {
// 调用KSYStreamer的onResume接口
// 调用UnionStreamer的onResume接口
mStreamer.onResume();
// 停止背景图采集
mStreamer.stopImageCapture();
Expand All @@ -225,7 +225,7 @@ protected void handleOnResume() {
}

protected void handleOnPause() {
// 调用KSYStreamer的onPause接口
// 调用UnionStreamer的onPause接口
mStreamer.onPause();
// 停止摄像头采集,然后开启背景图采集,以实现后台背景图推流功能
mStreamer.stopCameraPreview();
Expand Down Expand Up @@ -301,12 +301,12 @@ public void onError(ImgTexFilterBase filter, int errno) {
Toast.makeText(BaseCameraActivity.this, "当前机型不支持该滤镜",
Toast.LENGTH_SHORT).show();
mStreamer.getImgTexFilterMgt().setFilter(mStreamer.getGLRender(),
ImgTexFilterMgt.KSY_FILTER_BEAUTY_DISABLE);
ImgTexFilterMgt.IMG_FILTER_BEAUTY_DISABLE);
}
});
// 设置美颜滤镜,关于美颜滤镜的具体说明请参见专题说明以及完整版demo
mStreamer.getImgTexFilterMgt().setFilter(mStreamer.getGLRender(),
ImgTexFilterMgt.KSY_FILTER_BEAUTY_PRO3);
ImgTexFilterMgt.IMG_FILTER_BEAUTY_PRO3);
}

private void startDebugInfoTimer() {
Expand Down Expand Up @@ -390,28 +390,28 @@ protected void stopChronometer() {
protected void onStreamerInfo(int what, int msg1, int msg2) {
Log.d(TAG, "OnInfo: " + what + " msg1: " + msg1 + " msg2: " + msg2);
switch (what) {
case StreamerConstants.KSY_STREAMER_CAMERA_INIT_DONE:
Log.d(TAG, "KSY_STREAMER_CAMERA_INIT_DONE");
case StreamerConstants.UNION_STREAMER_CAMERA_INIT_DONE:
Log.d(TAG, "UNION_STREAMER_CAMERA_INIT_DONE");
break;
case StreamerConstants.KSY_STREAMER_CAMERA_FACING_CHANGED:
Log.d(TAG, "KSY_STREAMER_CAMERA_FACING_CHANGED");
case StreamerConstants.UNION_STREAMER_CAMERA_FACING_CHANGED:
Log.d(TAG, "UNION_STREAMER_CAMERA_FACING_CHANGED");
// check is flash torch mode supported
mFlashView.setEnabled(mStreamer.getCameraCapture().isTorchSupported());
break;
case StreamerConstants.KSY_STREAMER_OPEN_STREAM_SUCCESS:
Log.d(TAG, "KSY_STREAMER_OPEN_STREAM_SUCCESS");
case StreamerConstants.UNION_STREAMER_OPEN_STREAM_SUCCESS:
Log.d(TAG, "UNION_STREAMER_OPEN_STREAM_SUCCESS");
mStreamingText.setText(STOP_STREAM);
startChronometer();
break;
case StreamerConstants.KSY_STREAMER_FRAME_SEND_SLOW:
Log.d(TAG, "KSY_STREAMER_FRAME_SEND_SLOW " + msg1 + "ms");
case StreamerConstants.UNION_STREAMER_FRAME_SEND_SLOW:
Log.d(TAG, "UNION_STREAMER_FRAME_SEND_SLOW " + msg1 + "ms");
Toast.makeText(BaseCameraActivity.this, "Network not good!",
Toast.LENGTH_SHORT).show();
break;
case StreamerConstants.KSY_STREAMER_EST_BW_RAISE:
case StreamerConstants.UNION_STREAMER_EST_BW_RAISE:
Log.d(TAG, "BW raise to " + msg1 / 1000 + "kbps");
break;
case StreamerConstants.KSY_STREAMER_EST_BW_DROP:
case StreamerConstants.UNION_STREAMER_EST_BW_DROP:
Log.d(TAG, "BW drop to " + msg1 / 1000 + "kpbs");
break;
default:
Expand All @@ -422,17 +422,17 @@ protected void onStreamerInfo(int what, int msg1, int msg2) {
protected void onStreamerError(int what, int msg1, int msg2) {
Log.e(TAG, "streaming error: what=" + what + " msg1=" + msg1 + " msg2=" + msg2);
switch (what) {
case StreamerConstants.KSY_STREAMER_AUDIO_RECORDER_ERROR_START_FAILED:
case StreamerConstants.KSY_STREAMER_AUDIO_RECORDER_ERROR_UNKNOWN:
case StreamerConstants.UNION_STREAMER_AUDIO_RECORDER_ERROR_START_FAILED:
case StreamerConstants.UNION_STREAMER_AUDIO_RECORDER_ERROR_UNKNOWN:
break;
case StreamerConstants.KSY_STREAMER_CAMERA_ERROR_UNKNOWN:
case StreamerConstants.KSY_STREAMER_CAMERA_ERROR_START_FAILED:
case StreamerConstants.KSY_STREAMER_CAMERA_ERROR_EVICTED:
case StreamerConstants.KSY_STREAMER_CAMERA_ERROR_SERVER_DIED:
case StreamerConstants.UNION_STREAMER_CAMERA_ERROR_UNKNOWN:
case StreamerConstants.UNION_STREAMER_CAMERA_ERROR_START_FAILED:
case StreamerConstants.UNION_STREAMER_CAMERA_ERROR_EVICTED:
case StreamerConstants.UNION_STREAMER_CAMERA_ERROR_SERVER_DIED:
mStreamer.stopCameraPreview();
break;
case StreamerConstants.KSY_STREAMER_VIDEO_ENCODER_ERROR_UNSUPPORTED:
case StreamerConstants.KSY_STREAMER_VIDEO_ENCODER_ERROR_UNKNOWN:
case StreamerConstants.UNION_STREAMER_VIDEO_ENCODER_ERROR_UNSUPPORTED:
case StreamerConstants.UNION_STREAMER_VIDEO_ENCODER_ERROR_UNKNOWN:
handleEncodeError();
default:
reStreaming(what);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ protected void onViewAddClick() {
mSwitchToFloatView = true;
Intent intent = new Intent(getApplicationContext(), FloatViewActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
KSYGlobalStreamer.setInstance(mStreamer);
UnionGlobalStreamer.setInstance(mStreamer);
startActivity(intent);
}

@Override
protected void handleOnResume() {
// 重新设置预览View,防止从悬浮窗回来后黑屏
mStreamer.setDisplayPreview(mGLSurfaceView);
// 调用KSYStreamer的onResume接口
// 调用UnionStreamer的onResume接口
mStreamer.onResume();
// 停止背景图采集
mStreamer.stopImageCapture();
Expand All @@ -43,7 +43,7 @@ protected void handleOnResume() {

@Override
protected void handleOnPause() {
// 调用KSYStreamer的onPause接口
// 调用UnionStreamer的onPause接口
mStreamer.onPause();
if (!mSwitchToFloatView) {
// 停止摄像头采集,然后开启背景图采集,以实现后台背景图推流功能
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void onDestroy() {
mOrientationEventListener.disable();
}
removeSurfaceWindow();
KSYGlobalStreamer.setInstance(null);
UnionGlobalStreamer.setInstance(null);
}

@Override
Expand All @@ -120,8 +120,8 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
}

private void onBackoffClick() {
KSYGlobalStreamer.getInstance().onPause();
KSYGlobalStreamer.getInstance().setDisplayPreview((GLSurfaceView) null);
UnionGlobalStreamer.getInstance().onPause();
UnionGlobalStreamer.getInstance().setDisplayPreview((GLSurfaceView) null);
FloatViewActivity.this.finish();
}

Expand Down Expand Up @@ -193,7 +193,7 @@ public void onClick(View v) {
});

mCameraView = new GLSurfaceView(this);
KSYGlobalStreamer.getInstance().setDisplayPreview(mCameraView);
UnionGlobalStreamer.getInstance().setDisplayPreview(mCameraView);
RelativeLayout.LayoutParams previewLayoutParams =
new RelativeLayout.LayoutParams(width, height);
mFloatLayout.addView(mCameraView, previewLayoutParams);
Expand Down Expand Up @@ -270,7 +270,7 @@ private void addFloatView() {

int rotation = getDisplayRotation();
Log.d(TAG, "InitialRotate: " + rotation);
KSYGlobalStreamer.getInstance().setRotateDegrees(rotation);
UnionGlobalStreamer.getInstance().setRotateDegrees(rotation);
}

private void addFloatViewWithPermCheck() {
Expand Down Expand Up @@ -313,7 +313,7 @@ private void onSwitchRotate() {
if (mPreviewWindowShow) {
int rotation = getDisplayRotation();
Log.i(TAG, "onSwitchRotate: " + mLastRotation + "->" + rotation);
KSYGlobalStreamer.getInstance().setRotateDegrees(rotation);
UnionGlobalStreamer.getInstance().setRotateDegrees(rotation);

boolean isLastLandscape = (mLastRotation % 180) != 0;
boolean isLandscape = (rotation % 180) != 0;
Expand All @@ -335,7 +335,7 @@ private void onSwitchRotate() {

// update water mark position while screen orientation changed
private void updateWaterMark(boolean isLandscape) {
UnionStreamer streamer = KSYGlobalStreamer.getInstance();
UnionStreamer streamer = UnionGlobalStreamer.getInstance();
streamer.hideWaterMarkLogo();
streamer.hideWaterMarkTime();
if (!isLandscape) {
Expand Down
Loading

0 comments on commit 4386569

Please sign in to comment.