Skip to content

Commit

Permalink
Merge pull request #91 from ksvc/updateVer_2.2.0
Browse files Browse the repository at this point in the history
update ver to 2.2.0
  • Loading branch information
chriszeng87 authored Jan 26, 2018
2 parents 9e87d2b + 8a9667c commit 76a9dc8
Show file tree
Hide file tree
Showing 215 changed files with 18,729 additions and 1,337 deletions.
14 changes: 7 additions & 7 deletions demo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.ksyun.media.shortvideo.demo"
minSdkVersion 19
targetSdkVersion 27
versionCode 210
versionName "2.1.0.2"
versionCode 220
versionName "2.2.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
Expand All @@ -34,15 +34,15 @@ dependencies {
implementation 'com.tencent.bugly:crashreport:latest.release'
implementation 'com.tencent.bugly:nativecrashreport:latest.release'
//录制魔方动态贴纸依赖库,若不使用,可以不依赖
implementation 'com.ksyun.mc:libkmcfilter_sensetime:1.0.5'
implementation 'com.ksyun.mc:libkmcfilter_sensetime:1.0.7'
implementation 'com.ksyun.mc:SenseTimeAR:1.0.4'
//动态贴纸依赖库,若不使用,使用provided
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.lht:paintview:1.17'
compile 'com.ksyun.media:libksysv-java:2.1.0'
compile 'com.ksyun.media:libksysv-arm64:2.1.0'
compile 'com.ksyun.media:libksysv-armv7a:2.1.0'
compile 'com.ksyun.media:libksysv-x86:2.1.0'
compile 'com.ksyun.media:libksysv-java:2.2.0'
compile 'com.ksyun.media:libksysv-arm64:2.2.0'
compile 'com.ksyun.media:libksysv-armv7a:2.2.0'
compile 'com.ksyun.media:libksysv-x86:2.2.0'
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added demo/app/src/main/assets/KSYResource/17_ktv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.ksyun.media.shortvideo.kit.KSYRemuxKit;
import com.ksyun.media.streamer.encoder.VideoEncodeFormat;
import com.ksyun.media.streamer.framework.AVConst;
import com.ksyun.media.streamer.framework.VideoCodecFormat;
import com.ksyun.media.streamer.kit.StreamerConstants;

import java.util.ArrayList;
Expand Down Expand Up @@ -63,8 +64,8 @@ public class ConfigActivity extends Activity {

private static final int[] RECORD_PROFILE_ID = {R.id.record_config_low_power,
R.id.record_config_balance, R.id.record_config_high_performance};
private static final int[] ENCODE_PROFILE_TYPE = {VideoEncodeFormat.ENCODE_PROFILE_LOW_POWER,
VideoEncodeFormat.ENCODE_PROFILE_BALANCE, VideoEncodeFormat.ENCODE_PROFILE_HIGH_PERFORMANCE};
private static final int[] ENCODE_PROFILE_TYPE = {VideoCodecFormat.ENCODE_PROFILE_LOW_POWER,
VideoCodecFormat.ENCODE_PROFILE_BALANCE, VideoCodecFormat.ENCODE_PROFILE_HIGH_PERFORMANCE};

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
375 changes: 297 additions & 78 deletions demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import com.ksyun.media.shortvideo.demo.adapter.TransitionTypeAdapter;
import com.ksyun.media.shortvideo.kit.KSYMultiEditKit;
import com.ksyun.media.shortvideo.utils.ShortVideoConstants;
import com.ksyun.media.streamer.encoder.VideoEncodeFormat;
import com.ksyun.media.streamer.filter.imgtex.ImgTexScaleFilter;
import com.ksyun.media.streamer.framework.AVConst;
import com.ksyun.media.streamer.framework.VideoCodecFormat;
import com.ksyun.media.streamer.kit.StreamerConstants;

import java.io.File;
Expand All @@ -45,8 +45,8 @@ public class MultiImportActivity extends Activity {

private static final int[] OUTPUT_PROFILE_ID = {R.id.trans_output_config_low_power,
R.id.trans_output_config_balance, R.id.trans_output_config_high_performance};
private static final int[] ENCODE_PROFILE_TYPE = {VideoEncodeFormat.ENCODE_PROFILE_LOW_POWER,
VideoEncodeFormat.ENCODE_PROFILE_BALANCE, VideoEncodeFormat.ENCODE_PROFILE_HIGH_PERFORMANCE};
private static final int[] ENCODE_PROFILE_TYPE = {VideoCodecFormat.ENCODE_PROFILE_LOW_POWER,
VideoCodecFormat.ENCODE_PROFILE_BALANCE, VideoCodecFormat.ENCODE_PROFILE_HIGH_PERFORMANCE};

private RelativeLayout mPreviewLayout;
private GLSurfaceView mTransPreviewView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import com.ksyun.media.streamer.filter.imgtex.ImgBeautySpecialEffectsFilter;
import com.ksyun.media.streamer.filter.imgtex.ImgBeautyStylizeFilter;
import com.ksyun.media.streamer.filter.imgtex.ImgFilterBase;
import com.ksyun.media.streamer.filter.imgtex.ImgTexFilter;
import com.ksyun.media.streamer.filter.imgtex.ImgTexFilterBase;
import com.ksyun.media.streamer.kit.KSYStreamer;
import com.ksyun.media.streamer.kit.StreamerConstants;
import com.ksyun.media.streamer.logstats.StatsLogReport;
Expand Down Expand Up @@ -464,6 +462,9 @@ protected void onCreate(Bundle savedInstanceState) {
mKSYRecordKit.setOnInfoListener(mOnInfoListener);
mKSYRecordKit.setOnErrorListener(mOnErrorListener);
mKSYRecordKit.setOnLogEventListener(mOnLogEventListener);
//设置是否混音,即如果添加了背景音乐,将背景音乐的声音mix到音频文件中
mKSYRecordKit.setEnableAudioMix(true);

initBeautyUI(); //初始化美颜界面
initStickerUI(); //初始化动态贴纸界面
initFilterUI(); //初始化滤镜界面
Expand Down Expand Up @@ -1169,7 +1170,7 @@ private void addBeautyFiler() {
ImgFilterBase lastFilter = mBeautyFilters.get
(mLastImgBeautyTypeIndex);
if (mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(lastFilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, null);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, null, false);
}
}
mLastImgBeautyTypeIndex = mImgBeautyTypeIndex;
Expand All @@ -1182,7 +1183,7 @@ private void addBeautyFiler() {
if (mBeautyFilters.containsKey(mLastImgBeautyTypeIndex)) {
ImgFilterBase lastFilter = mBeautyFilters.get(mLastImgBeautyTypeIndex);
if (mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(lastFilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filterBase);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filterBase, false);
}
} else {
if (!mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(filterBase)) {
Expand Down Expand Up @@ -1239,7 +1240,7 @@ private void addBeautyFiler() {
mBeautyFilters.put(mImgBeautyTypeIndex, filterBase);
if (lastFilter != null && mKSYRecordKit.getImgTexFilterMgt().getFilter().contains
(lastFilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filterBase);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filterBase, false);
} else {
mKSYRecordKit.getImgTexFilterMgt().addFilter(filterBase);
}
Expand All @@ -1260,7 +1261,7 @@ private void addEffectFilter() {
if (mEffectFilters.containsKey(mLastEffectFilterIndex)) {
ImgFilterBase lastFilter = mEffectFilters.get(mLastEffectFilterIndex);
if (mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(lastFilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, null);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, null, false);
}
}
mLastEffectFilterIndex = mEffectFilterIndex;
Expand All @@ -1271,7 +1272,7 @@ private void addEffectFilter() {
if (mEffectFilters.containsKey(mLastEffectFilterIndex)) {
ImgFilterBase lastfilter = mEffectFilters.get(mLastEffectFilterIndex);
if (mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(lastfilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastfilter, filter);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastfilter, filter, false);
}
} else {
if (!mKSYRecordKit.getImgTexFilterMgt().getFilter().contains(filter)) {
Expand All @@ -1295,7 +1296,7 @@ private void addEffectFilter() {
}
if (lastFilter != null && mKSYRecordKit.getImgTexFilterMgt().getFilter().contains
(lastFilter)) {
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filter);
mKSYRecordKit.getImgTexFilterMgt().replaceFilter(lastFilter, filter, false);
} else {
mKSYRecordKit.getImgTexFilterMgt().addFilter(filter);
}
Expand Down Expand Up @@ -2503,7 +2504,7 @@ private void onRecyclerViewItemClick(int position) {
if (mKMCFilter == null) {
mKMCFilter = new KMCFilter(getApplicationContext(),
mKSYRecordKit.getGLRender());
mKSYRecordKit.getImgTexFilterMgt().setExtraFilter(mKMCFilter);
mKSYRecordKit.getImgTexFilterMgt().addFilter(mKMCFilter);
}

mKMCFilter.startShowingMaterial(mMaterial);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ksyun.media.shortvideo.demo;

import com.ksyun.media.streamer.encoder.VideoEncodeFormat;
import com.ksyun.media.streamer.framework.AVConst;
import com.ksyun.media.streamer.framework.VideoCodecFormat;
import com.ksyun.media.streamer.kit.StreamerConstants;

/**
Expand All @@ -16,7 +16,7 @@ public class ShortVideoConfig {
public int audioBitrate = StreamerConstants.DEFAULT_AUDIO_BITRATE;
public int encodeType = AVConst.CODEC_ID_AVC;
public int encodeMethod = StreamerConstants.ENCODE_METHOD_SOFTWARE;
public int encodeProfile = VideoEncodeFormat.ENCODE_PROFILE_LOW_POWER;
public int encodeProfile = VideoCodecFormat.ENCODE_PROFILE_LOW_POWER;
public int decodeMethod = StreamerConstants.DECODE_METHOD_HARDWARE;
public int audioEncodeProfile = AVConst.PROFILE_AAC_LOW;
public int videoCRF = 24;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand All @@ -18,21 +20,38 @@
*/

public class ImageTextAdapter extends RecyclerView.Adapter<ImageTextAdapter.FilterViewHolder> {
public static final int LONG_CLICK_STATE_START = 1;
public static final int LONG_CLICK_STATE_CLICKING = 2;
public static final int LONG_CLICK_STATE_END = 3;
public static final int LONG_CLICK_IDEL = 0;
private static final int UN_INIT = -1;
private Context mContext;
private List<Data> mData;
private OnImageItemClickListener mListener;
private FilterViewHolder mPreHolder;
private int mPreIndex = UN_INIT;
private OnImageLongItemClickListener mOnLongClick;
private Handler mHandler;
private boolean mIsLongClick;
private int mLongClickState = LONG_CLICK_IDEL;

public interface OnImageItemClickListener {
void onClick(int index);
}

public interface OnImageLongItemClickListener {
boolean onLongClick(View view, int index, int state);
}


public void setOnImageItemClick(OnImageItemClickListener listener) {
this.mListener = listener;
}

public void setOnImageLongItemClick(OnImageLongItemClickListener longItemClick) {
this.mOnLongClick = longItemClick;
}

public ImageTextAdapter(Context context, List<Data> data) {
this.mContext = context;
this.mData = data;
Expand All @@ -57,6 +76,7 @@ public void onBindViewHolder(final FilterViewHolder holder, final int position)
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mListener == null) return;
if (mPreHolder != null) {
mPreHolder.setActivated(false);
ImageTextAdapter.this.mData.get(mPreIndex).isSelected = false;
Expand All @@ -68,9 +88,50 @@ public void onClick(View v) {
mPreIndex = position;
}
});

holder.image.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (mOnLongClick == null) return false;

switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mHandler == null) mHandler = new Handler();
mHandler.postDelayed(new LongTimerRunnable(holder, view, position), 200);

break;
case MotionEvent.ACTION_MOVE:
if (mIsLongClick) {
holder.setActivated(true);
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
if (mIsLongClick) {
holder.setActivated(false);
mIsLongClick = false;
if (mLongClickState == LONG_CLICK_STATE_CLICKING) {
mLongClickState = LONG_CLICK_STATE_END;
if (mOnLongClick != null) {
mOnLongClick.onLongClick(view, position, mLongClickState);
}
mLongClickState = LONG_CLICK_IDEL;
}
return true;
}
break;

}
return mIsLongClick;
}
});
holder.title.setText(mData.get(position).text);
}


@Override
public int getItemCount() {
return mData.size();
Expand All @@ -82,6 +143,31 @@ public void clear() {
}
}

public void endLongClick() {
//正在长按
if (mLongClickState == LONG_CLICK_STATE_CLICKING) {
// 取消长按状态
cancelLongClick();
}
}

private void cancelLongClick() {
if (mHandler != null) {
mHandler.removeCallbacksAndMessages(null);
}
if (mIsLongClick) {
if (mPreHolder != null) {
mPreHolder.setActivated(false);
}
mIsLongClick = false;
mLongClickState = LONG_CLICK_STATE_END;
if (mOnLongClick != null) {
mOnLongClick.onLongClick(null, -1, mLongClickState);
}
mLongClickState = LONG_CLICK_IDEL;
}
}

public class FilterViewHolder extends RecyclerView.ViewHolder {
ImageView image;
ImageView border;
Expand Down Expand Up @@ -115,4 +201,41 @@ public Data(Drawable image, String type) {
this.text = type;
}
}

class LongTimerRunnable implements Runnable {
private View mView;
private int mIndex;
private FilterViewHolder mHolder;

LongTimerRunnable(FilterViewHolder holder, View view, int index) {
this.mView = view;
this.mIndex = index;
mHolder = holder;
}

@Override
public void run() {
if (mLongClickState == LONG_CLICK_IDEL) {
mLongClickState = LONG_CLICK_STATE_START;
} else if (mLongClickState == LONG_CLICK_STATE_START) {
mLongClickState = LONG_CLICK_STATE_CLICKING;
}
boolean result = true;
if (mOnLongClick != null) {
result = mOnLongClick.onLongClick(mView, mIndex, mLongClickState);
}
if(result) {
mIsLongClick = true;
if (mIsLongClick) {
mHolder.setActivated(true);
}

if (mHandler != null) {
mHandler.postDelayed(new LongTimerRunnable(mHolder, mView, mIndex), 100);
}
} else {
mLongClickState = LONG_CLICK_IDEL;
}
}
}
}
Loading

0 comments on commit 76a9dc8

Please sign in to comment.