diff --git a/demo/app/build.gradle b/demo/app/build.gradle index e2d93e1..ed3b89f 100644 --- a/demo/app/build.gradle +++ b/demo/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.ksyun.media.shortvideo.demo" minSdkVersion 19 targetSdkVersion 24 - versionCode 142 - versionName "1.4.2" + versionCode 146 + versionName "1.4.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } sourceSets { @@ -40,8 +40,8 @@ dependencies { 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.ksyun.media:libksysv-java:1.4.2' - compile 'com.ksyun.media:libksysv-arm64:1.4.2' - compile 'com.ksyun.media:libksysv-armv7a:1.4.2' - compile 'com.ksyun.media:libksysv-x86:1.4.2' + compile 'com.ksyun.media:libksysv-java:1.4.6' + compile 'com.ksyun.media:libksysv-arm64:1.4.6' + compile 'com.ksyun.media:libksysv-armv7a:1.4.6' + compile 'com.ksyun.media:libksysv-x86:1.4.6' } diff --git a/demo/app/src/main/assets/AuthForTest.pkg b/demo/app/src/main/assets/AuthForTest.pkg new file mode 100644 index 0000000..c7aca78 --- /dev/null +++ b/demo/app/src/main/assets/AuthForTest.pkg @@ -0,0 +1 @@ +h1iuRSzMW60Iwm2XzBzu40UnPMP4Td2X2Ab5JAKtfDD3kzmND4Hc6McUvbtvI+TVSRmMsXYCynqIqMnlzLtS+srE1B4bkh4ZQ5GxVttDe2ldWspDUxwBdEk+8fI3l11UhZXZZh2XEoJ2reqytoneKQbVIqt7UrZFd4Wx9a6Tpp4=SZs8qatUU89FFTWMLWeM6KFxtsJOI2dS6COArBPYvrzJEVfVRk/2u80JsfX+JrvuGY6yTs/SMw6lTqZF0zcB67na0znaGd0ahfeRKm0dihOMjk9BtTmeWk4HH5i64rM8/7r/bh2NIRZGICsgpJzKW5w7wBLH3GHo7vmaiDblj60= \ No newline at end of file diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java index 760473f..268348b 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java @@ -1543,6 +1543,8 @@ public void onClick(View view) { mOutForGIF.setActivated(false); mOutEncodeWithH264.setEnabled(true); mOutEncodeWithH265.setEnabled(true); + mOutEncodeWithH264.setActivated(true); + mOutEncodeWithH265.setActivated(false); mOutEncodeByHW.setEnabled(true); break; case R.id.output_config_gif: diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java index 553d43e..a444e53 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java @@ -12,6 +12,7 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; +import android.widget.Toast; import com.ksyun.media.shortvideo.demo.adapter.MediaGalleryAdapter; import com.ksyun.media.shortvideo.demo.adapter.MediaSelectedAdapter; @@ -114,10 +115,14 @@ private void onSelectedDataConfirmed() { for (int i = 0; i < list.size(); i++) { path.add(list.get(i).filePath); } - Intent intent = new Intent(); - intent.putStringArrayListExtra("filePath", path); - setResult(RESULT_CODE, intent); - finish(); + if (path.size() == 0) { + Toast.makeText(this, "请至少选择一个文件", Toast.LENGTH_SHORT).show(); + } else { + Intent intent = new Intent(); + intent.putStringArrayListExtra("filePath", path); + setResult(RESULT_CODE, intent); + finish(); + } } private class ButtonObserver implements View.OnClickListener { diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java index 7b9507f..9ca0107 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java @@ -4,6 +4,7 @@ import com.ksyun.media.shortvideo.kit.KSYEditKit; import com.ksyun.media.shortvideo.utils.AuthInfoManager; +import org.apache.http.util.EncodingUtils; import org.json.JSONException; import org.json.JSONObject; @@ -12,6 +13,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.View; @@ -22,6 +24,8 @@ import android.widget.TextView; import android.widget.Toast; +import java.io.InputStream; + /** * 引导窗口页 */ @@ -79,7 +83,7 @@ private void showWebView() { mDefaultView.setVisibility(View.GONE); mWebView.setVisibility(View.VISIBLE); mWebView.loadUrl(COLOPHON_URL); - mWebView.setWebViewClient(new WebViewClient(){ + mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); @@ -102,7 +106,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { default: break; } - return super.onKeyDown(keyCode,event); + return super.onKeyDown(keyCode, event); } @Override @@ -122,73 +126,117 @@ public void onDestroy() { AuthInfoManager.getInstance().removeAuthResultListener(mCheckAuthResultListener); } - /** * SDK鉴权 */ private void checkAuth() { + String token = null; + try { + InputStream in = getResources().getAssets().open("AuthForTest.pkg"); - if (mAuthResponse == null) { - mAuthResponse = new HttpRequestTask.HttpResponseListener() { - @Override - public void onHttpResponse(int responseCode, String response) { - //params response - boolean authResult = false; - if (responseCode == 200) { - try { - JSONObject temp = new JSONObject(response); - JSONObject data = temp.getJSONObject("Data"); - int result = data.getInt("RetCode"); - if (result == 0) { - String authInfo = data.getString("Authorization"); - String date = data.getString("x-amz-date"); - //初始化鉴权信息 - AuthInfoManager.getInstance().setAuthInfo(authInfo, date); - //添加鉴权结果回调接口(不是必须) - AuthInfoManager.getInstance().addAuthResultListener(mCheckAuthResultListener); - //开始向KSServer申请鉴权 - AuthInfoManager.getInstance().checkAuth(); - authResult = true; - } else { - Log.e(TAG, "get auth failed from app server RetCode:" + result); - } - } catch (JSONException e) { - e.printStackTrace(); - Log.e(TAG, "get auth failed from app server json parse failed"); - } - } else { - Log.e(TAG, "get auth failed from app server responseCode:" + responseCode); - } + int length = in.available(); - final boolean finalAuthResult = authResult; - runOnUiThread(new Runnable() { + byte[] buffer = new byte[length]; + + in.read(buffer); + + token = EncodingUtils.getString(buffer, "UTF-8"); + + } catch (Exception e) { + e.printStackTrace(); + } + + if (!TextUtils.isEmpty(token)) { + AuthInfoManager.getInstance().setAuthInfo(token); + AuthInfoManager.getInstance().checkAuth(); + if (AuthInfoManager.getInstance().getAuthState()) { + Toast.makeText(ShortVideoActivity.this, "Auth Success", Toast.LENGTH_SHORT) + .show(); + } else { + Toast.makeText(ShortVideoActivity.this, "Auth Failed", Toast.LENGTH_SHORT) + .show(); + } + } else { + AuthInfoManager.getInstance().addAuthResultListener(new AuthInfoManager.CheckAuthResultListener() { + @Override + public void onAuthResult(int i) { + mMainHandler.post(new Runnable() { @Override public void run() { - if (!finalAuthResult) { - Toast.makeText(ShortVideoActivity.this, "get auth failed from app " + - "server", Toast.LENGTH_SHORT) + AuthInfoManager.getInstance().removeAuthResultListener(mCheckAuthResultListener); + if (AuthInfoManager.getInstance().getAuthState()) { + Toast.makeText(ShortVideoActivity.this, "Auth Success", Toast.LENGTH_SHORT) + .show(); + } else { + Toast.makeText(ShortVideoActivity.this, "Auth Failed", Toast.LENGTH_SHORT) .show(); - //鉴权失败,尝试3次 - if (mRetryCount < MAX_RETRY_COUNT) { - mRetryCount++; - checkAuth(); - } } } }); } - }; - } + }); + if (mAuthResponse == null) { + mAuthResponse = new HttpRequestTask.HttpResponseListener() { + @Override + public void onHttpResponse(int responseCode, String response) { + //params response + boolean authResult = false; + if (responseCode == 200) { + try { + JSONObject temp = new JSONObject(response); + JSONObject data = temp.getJSONObject("Data"); + int result = data.getInt("RetCode"); + if (result == 0) { + String authInfo = data.getString("Authorization"); + String date = data.getString("x-amz-date"); + //初始化鉴权信息 + AuthInfoManager.getInstance().setAuthInfo(authInfo, date); + //添加鉴权结果回调接口(不是必须) + AuthInfoManager.getInstance().addAuthResultListener(mCheckAuthResultListener); + //开始向KSServer申请鉴权 + AuthInfoManager.getInstance().checkAuth(); + authResult = true; + } else { + Log.e(TAG, "get auth failed from app server RetCode:" + result); + } + } catch (JSONException e) { + e.printStackTrace(); + Log.e(TAG, "get auth failed from app server json parse failed"); + } + } else { + Log.e(TAG, "get auth failed from app server responseCode:" + responseCode); + } - if (mAuthTask != null && mAuthTask.getStatus() != AsyncTask.Status.FINISHED) { - mAuthTask.cancel(true); - mAuthTask = null; + final boolean finalAuthResult = authResult; + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!finalAuthResult) { + Toast.makeText(ShortVideoActivity.this, "get auth failed from app " + + "server", Toast.LENGTH_SHORT) + .show(); + //鉴权失败,尝试3次 + if (mRetryCount < MAX_RETRY_COUNT) { + mRetryCount++; + checkAuth(); + } + } + } + }); + } + }; + } + + if (mAuthTask != null && mAuthTask.getStatus() != AsyncTask.Status.FINISHED) { + mAuthTask.cancel(true); + mAuthTask = null; + } + //开启异步任务,向AppServer请求鉴权信息 + mAuthTask = new HttpRequestTask(mAuthResponse); + String url = AUTH_SERVER_URI + "?Pkg=" + getApplicationContext().getPackageName(); + Log.d(TAG, "request auth:" + url); + mAuthTask.execute(url); } - //开启异步任务,向AppServer请求鉴权信息 - mAuthTask = new HttpRequestTask(mAuthResponse); - String url = AUTH_SERVER_URI + "?Pkg=" + getApplicationContext().getPackageName(); - Log.d(TAG, "request auth:" + url); - mAuthTask.execute(url); } private AuthInfoManager.CheckAuthResultListener mCheckAuthResultListener = new AuthInfoManager diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java index 1106bf8..40f77d9 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java @@ -54,7 +54,7 @@ public RecordProgressController(RecordProgressView view, Chronometer cmt) { private class ChangeProgressRunnable implements Runnable { @Override public void run() { - if (getChronometerTime() >= RecordActivity.MAX_DURATION) { + if (getTotalRecordTime() >= RecordActivity.MAX_DURATION) { mProgressView.invalidate(); if (mIsRecording && mRecordingLengthChangedListener != null) { mRecordingLengthChangedListener.passMaxPoint(); @@ -83,6 +83,14 @@ public int getChronometerTime() { return curTime * 1000; } + private long getTotalRecordTime() { + long time = 0; + for (RecordClipModel clip : mProgressClipList) { + time += clip.timeInterval; + } + return time; + } + /** * 是否到达了最小录制时长 * diff --git a/demo/gradle/wrapper/gradle-wrapper.properties b/demo/gradle/wrapper/gradle-wrapper.properties index 75536f6..596049c 100644 --- a/demo/gradle/wrapper/gradle-wrapper.properties +++ b/demo/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,5 @@ -#Fri May 19 20:52:25 CST 2017 +#Thu May 18 16:03:35 CST 2017 + distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html b/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html index 712c235..6822000 100644 --- a/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html +++ b/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html @@ -592,7 +592,7 @@

Summary

void - setOnErrorListener(KSYMergeKit.OnErrorListener onErrorListener) + setIFrameInterval(float interval) @@ -608,7 +608,7 @@

Summary

void - setOnInfoListener(KSYMergeKit.OnInfoListener onInfoListener) + setOnErrorListener(KSYMergeKit.OnErrorListener onErrorListener) @@ -624,7 +624,7 @@

Summary

void - setTargetSize(int width, int height) + setOnInfoListener(KSYMergeKit.OnInfoListener onInfoListener) @@ -640,7 +640,7 @@

Summary

void - setToTranscodeFiles(Map<Uri, Boolean> toTranscodeFiles) + setTargetSize(int width, int height) @@ -656,7 +656,7 @@

Summary

void - setVideoBitrate(int bitrate) + setToTranscodeFiles(Map<Uri, Boolean> toTranscodeFiles) @@ -669,6 +669,22 @@

Summary

+ void + + + setVideoBitrate(int bitrate) + + + + + + + + + + + + void @@ -678,6 +694,24 @@

Summary

+ + + + + + + + void + + + setVideoCrf(int crf) + +
set Constant Rate Factor
+ + + + + @@ -701,6 +735,22 @@

Summary

+ void + + + setVideoProfile(int videoProfile) + + + + + + + + + + + + void @@ -712,7 +762,7 @@

Summary

- + @@ -1532,6 +1582,47 @@

+ + +
+

+ + public + + + + + void + + setIFrameInterval + (float interval) +

+
+
+ +
+ + + +
+
+ +

+
+
Parameters
+ + + + + +
intervalI frame interval +
+
+ +
+
+ +
@@ -1727,6 +1818,37 @@
Throws
+ + +
+

+ + public + + + + + void + + setVideoCrf + (int crf) +

+
+
+ +
+ + + +
+
+ +

set Constant Rate Factor

+ +
+
+ +
@@ -1758,6 +1880,37 @@

+ + +
+

+ + public + + + + + void + + setVideoProfile + (int videoProfile) +

+
+
+ +
+ + + +
+
+ +

+ +
+
+ +
diff --git a/docs/reference/com/ksyun/media/shortvideo/kit/KSYTranscodeKit.html b/docs/reference/com/ksyun/media/shortvideo/kit/KSYTranscodeKit.html index 884db8f..b004614 100644 --- a/docs/reference/com/ksyun/media/shortvideo/kit/KSYTranscodeKit.html +++ b/docs/reference/com/ksyun/media/shortvideo/kit/KSYTranscodeKit.html @@ -754,6 +754,22 @@

Summary

+ void + + + setIFrameInterval(float interval) + + + + + + + + + + + + void @@ -765,7 +781,7 @@

Summary

- + @@ -783,7 +799,7 @@

Summary

- + @@ -801,7 +817,7 @@

Summary

- + @@ -819,7 +835,7 @@

Summary

- + @@ -837,6 +853,24 @@

Summary

+ + + + + + + + void + + + setVideoCrf(int crf) + +
set Constant Rate Factor
+ + + + + @@ -2284,6 +2318,47 @@
See Also
+ + +
+

+ + public + + + + + void + + setIFrameInterval + (float interval) +

+
+
+ +
+ + + +
+
+ +

+
+
Parameters
+ + + + + +
intervalI frame interval +
+
+ +
+
+ +
@@ -2528,6 +2603,37 @@
See Also
+ + +
+

+ + public + + + + + void + + setVideoCrf + (int crf) +

+
+
+ +
+ + + +
+
+ +

set Constant Rate Factor

+ +
+
+ +
diff --git a/docs/reference/com/ksyun/media/shortvideo/utils/ShortVideoConstants.html b/docs/reference/com/ksyun/media/shortvideo/utils/ShortVideoConstants.html index f5b1277..6153132 100644 --- a/docs/reference/com/ksyun/media/shortvideo/utils/ShortVideoConstants.html +++ b/docs/reference/com/ksyun/media/shortvideo/utils/ShortVideoConstants.html @@ -1631,7 +1631,7 @@

Constant Value: - "1.4.2" + "1.4.6"

diff --git a/libs/libsv/arm64-v8a/libksyapm.so b/libs/libsv/arm64-v8a/libksyapm.so index 2ddef8f..0870441 100755 Binary files a/libs/libsv/arm64-v8a/libksyapm.so and b/libs/libsv/arm64-v8a/libksyapm.so differ diff --git a/libs/libsv/arm64-v8a/libksylive.so b/libs/libsv/arm64-v8a/libksylive.so index 3b85348..9c8306b 100755 Binary files a/libs/libsv/arm64-v8a/libksylive.so and b/libs/libsv/arm64-v8a/libksylive.so differ diff --git a/libs/libsv/armeabi-v7a/libksyapm.so b/libs/libsv/armeabi-v7a/libksyapm.so index 352b865..e7d5b10 100755 Binary files a/libs/libsv/armeabi-v7a/libksyapm.so and b/libs/libsv/armeabi-v7a/libksyapm.so differ diff --git a/libs/libsv/armeabi-v7a/libksylive.so b/libs/libsv/armeabi-v7a/libksylive.so index bd54e98..a54c8a6 100755 Binary files a/libs/libsv/armeabi-v7a/libksylive.so and b/libs/libsv/armeabi-v7a/libksylive.so differ diff --git a/libs/libsv/armeabi/libksyapm.so b/libs/libsv/armeabi/libksyapm.so index 5fd7115..0229a0b 100755 Binary files a/libs/libsv/armeabi/libksyapm.so and b/libs/libsv/armeabi/libksyapm.so differ diff --git a/libs/libsv/armeabi/libksylive.so b/libs/libsv/armeabi/libksylive.so index b4b3c90..36a5084 100755 Binary files a/libs/libsv/armeabi/libksylive.so and b/libs/libsv/armeabi/libksylive.so differ diff --git a/libs/libsv/ksylive.jar b/libs/libsv/ksylive.jar index 5b856b5..4d55cf5 100644 Binary files a/libs/libsv/ksylive.jar and b/libs/libsv/ksylive.jar differ diff --git a/libs/libsv/libksyplayer.jar b/libs/libsv/libksyplayer.jar index e87750e..9101d69 100644 Binary files a/libs/libsv/libksyplayer.jar and b/libs/libsv/libksyplayer.jar differ diff --git a/libs/libsv/libksysv.jar b/libs/libsv/libksysv.jar index 92a3f4b..13c42a3 100644 Binary files a/libs/libsv/libksysv.jar and b/libs/libsv/libksysv.jar differ diff --git a/libs/libsv/x86/libksyapm.so b/libs/libsv/x86/libksyapm.so index 34478b8..c91995a 100755 Binary files a/libs/libsv/x86/libksyapm.so and b/libs/libsv/x86/libksyapm.so differ diff --git a/libs/libsv/x86/libksylive.so b/libs/libsv/x86/libksylive.so index a0917d3..b85332f 100755 Binary files a/libs/libsv/x86/libksylive.so and b/libs/libsv/x86/libksylive.so differ