Commit a9610aede28d388b9a69e692b387c85e7e4f39fa
1 parent
11b75d90
更新推流SDK
Showing
5 changed files
with
34 additions
and
55 deletions
.idea/misc.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <project version="4"> | 2 | <project version="4"> |
| 3 | - <component name="EntryPointsManager"> | ||
| 4 | - <entry_points version="2.0" /> | ||
| 5 | - </component> | ||
| 6 | <component name="NullableNotNullManager"> | 3 | <component name="NullableNotNullManager"> |
| 7 | <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | 4 | <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> |
| 8 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | 5 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> |
| @@ -27,17 +24,7 @@ | @@ -27,17 +24,7 @@ | ||
| 27 | </value> | 24 | </value> |
| 28 | </option> | 25 | </option> |
| 29 | </component> | 26 | </component> |
| 30 | - <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | ||
| 31 | - <OptionsSetting value="true" id="Add" /> | ||
| 32 | - <OptionsSetting value="true" id="Remove" /> | ||
| 33 | - <OptionsSetting value="true" id="Checkout" /> | ||
| 34 | - <OptionsSetting value="true" id="Update" /> | ||
| 35 | - <OptionsSetting value="true" id="Status" /> | ||
| 36 | - <OptionsSetting value="true" id="Edit" /> | ||
| 37 | - <ConfirmationsSetting value="0" id="Add" /> | ||
| 38 | - <ConfirmationsSetting value="0" id="Remove" /> | ||
| 39 | - </component> | ||
| 40 | - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | 27 | + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
| 41 | <output url="file://$PROJECT_DIR$/build/classes" /> | 28 | <output url="file://$PROJECT_DIR$/build/classes" /> |
| 42 | </component> | 29 | </component> |
| 43 | <component name="ProjectType"> | 30 | <component name="ProjectType"> |
app/build.gradle
| @@ -43,7 +43,8 @@ repositories { | @@ -43,7 +43,8 @@ repositories { | ||
| 43 | 43 | ||
| 44 | dependencies { | 44 | dependencies { |
| 45 | compile fileTree(include: ['*.jar'], dir: 'libs') | 45 | compile fileTree(include: ['*.jar'], dir: 'libs') |
| 46 | - compile 'com.cnlive:lib_cnlive:2.1.0' | 46 | + compile 'com.cnlive:lib_cnlive:3.0' |
| 47 | + compile 'com.cnlive:lib_cnutil:3.0.3' | ||
| 47 | compile 'com.android.support:appcompat-v7:25.2.0' | 48 | compile 'com.android.support:appcompat-v7:25.2.0' |
| 48 | compile 'com.android.support.constraint:constraint-layout:1.0.1' | 49 | compile 'com.android.support.constraint:constraint-layout:1.0.1' |
| 49 | 50 |
app/src/main/java/com/cnlive/demo/stream/CNStreamApplication.java
| @@ -14,7 +14,7 @@ public class CNStreamApplication extends Application { | @@ -14,7 +14,7 @@ public class CNStreamApplication extends Application { | ||
| 14 | public void onCreate() { | 14 | public void onCreate() { |
| 15 | super.onCreate(); | 15 | super.onCreate(); |
| 16 | 16 | ||
| 17 | - Config.init(this, "60_irn9gh9d49", "f7b6db55616d207fd5c07e2b580b5650c690aff58fb36d",true); | 17 | + Config.init(this, "60_irn9gh9d49", "f7b6db55616d207fd5c07e2b580b5650c690aff58fb36d"); |
| 18 | 18 | ||
| 19 | // 初始化fresco库,用来支持动态水印功能 | 19 | // 初始化fresco库,用来支持动态水印功能 |
| 20 | Fresco.initialize(this); | 20 | Fresco.initialize(this); |
app/src/main/java/com/cnlive/demo/stream/StreamActivity.java
| @@ -38,11 +38,12 @@ import android.widget.Toast; | @@ -38,11 +38,12 @@ import android.widget.Toast; | ||
| 38 | import com.cnlive.libs.stream.Streamer; | 38 | import com.cnlive.libs.stream.Streamer; |
| 39 | import com.cnlive.libs.stream.base.ICNAudioEffectFilter; | 39 | import com.cnlive.libs.stream.base.ICNAudioEffectFilter; |
| 40 | import com.cnlive.libs.stream.base.IStreamer; | 40 | import com.cnlive.libs.stream.base.IStreamer; |
| 41 | -import com.cnlive.libs.stream.base.ImgBeautyProFilter; | ||
| 42 | -import com.cnlive.libs.stream.base.ImgFilterBase; | 41 | +import com.cnlive.libs.stream.base.img.ICNImgFilterBase; |
| 43 | import com.cnlive.libs.stream.filter.CNAudioEffectFilter; | 42 | import com.cnlive.libs.stream.filter.CNAudioEffectFilter; |
| 44 | import com.cnlive.libs.stream.filter.CNAudioFilterBase; | 43 | import com.cnlive.libs.stream.filter.CNAudioFilterBase; |
| 45 | import com.cnlive.libs.stream.filter.CNAudioReverbFilter; | 44 | import com.cnlive.libs.stream.filter.CNAudioReverbFilter; |
| 45 | +import com.cnlive.libs.stream.filter.img.CNImgBeautyProFilter; | ||
| 46 | +import com.cnlive.libs.stream.filter.img.CNNewImgFilterBase; | ||
| 46 | import com.cnlive.libs.stream.model.ActivityConfig; | 47 | import com.cnlive.libs.stream.model.ActivityConfig; |
| 47 | 48 | ||
| 48 | import java.io.BufferedOutputStream; | 49 | import java.io.BufferedOutputStream; |
| @@ -55,10 +56,6 @@ import java.util.LinkedList; | @@ -55,10 +56,6 @@ import java.util.LinkedList; | ||
| 55 | import java.util.List; | 56 | import java.util.List; |
| 56 | 57 | ||
| 57 | import static com.cnlive.libs.stream.base.IStreamer.ENCODE_METHOD_HARDWARE; | 58 | import static com.cnlive.libs.stream.base.IStreamer.ENCODE_METHOD_HARDWARE; |
| 58 | -import static com.cnlive.libs.stream.base.IStreamer.ENCODE_METHOD_SOFTWARE_COMPAT; | ||
| 59 | -import static com.cnlive.libs.stream.base.IStreamer.ENCODE_PROFILE_BALANCE; | ||
| 60 | -import static com.cnlive.libs.stream.base.IStreamer.ENCODE_PROFILE_HIGH_PERFORMANCE; | ||
| 61 | -import static com.cnlive.libs.stream.base.IStreamer.ENCODE_PROFILE_LOW_POWER; | ||
| 62 | import static com.cnlive.libs.stream.base.IStreamer.VIDEO_RESOLUTION_360P; | 59 | import static com.cnlive.libs.stream.base.IStreamer.VIDEO_RESOLUTION_360P; |
| 63 | import static com.cnlive.libs.stream.model.Filters.*; | 60 | import static com.cnlive.libs.stream.model.Filters.*; |
| 64 | 61 | ||
| @@ -76,7 +73,6 @@ public class StreamActivity extends Activity { | @@ -76,7 +73,6 @@ public class StreamActivity extends Activity { | ||
| 76 | private View mSwitchCameraView; | 73 | private View mSwitchCameraView; |
| 77 | private View mFlashView; | 74 | private View mFlashView; |
| 78 | private ImageView mExposureView; | 75 | private ImageView mExposureView; |
| 79 | - private ImageView mAddView; | ||
| 80 | private TextView mShootingText; | 76 | private TextView mShootingText; |
| 81 | private CheckBox mWaterMarkCheckBox; | 77 | private CheckBox mWaterMarkCheckBox; |
| 82 | private CheckBox mBeautyCheckBox; | 78 | private CheckBox mBeautyCheckBox; |
| @@ -190,9 +186,6 @@ public class StreamActivity extends Activity { | @@ -190,9 +186,6 @@ public class StreamActivity extends Activity { | ||
| 190 | //亮度 | 186 | //亮度 |
| 191 | mExposureView = (ImageView) findViewById(R.id.exposure); | 187 | mExposureView = (ImageView) findViewById(R.id.exposure); |
| 192 | mExposureView.setOnClickListener(mObserverButton); | 188 | mExposureView.setOnClickListener(mObserverButton); |
| 193 | - //悬浮窗 | ||
| 194 | - mAddView = (ImageView) findViewById(R.id.add); | ||
| 195 | - mAddView.setOnClickListener(mObserverButton); | ||
| 196 | 189 | ||
| 197 | mCheckBoxObserver = new CheckBoxObserver(); | 190 | mCheckBoxObserver = new CheckBoxObserver(); |
| 198 | //美颜 | 191 | //美颜 |
| @@ -320,7 +313,7 @@ public class StreamActivity extends Activity { | @@ -320,7 +313,7 @@ public class StreamActivity extends Activity { | ||
| 320 | 313 | ||
| 321 | initBeautyUI(); | 314 | initBeautyUI(); |
| 322 | 315 | ||
| 323 | - mStreamer.setFilterOnErrorListener(new ImgFilterBase.OnErrorListener() { | 316 | + mStreamer.setFilterOnErrorListener(new ICNImgFilterBase.OnErrorListener() { |
| 324 | @Override | 317 | @Override |
| 325 | public void onError(int i) { | 318 | public void onError(int i) { |
| 326 | Toast.makeText(StreamActivity.this, "当前机型不支持该滤镜", Toast.LENGTH_SHORT).show(); | 319 | Toast.makeText(StreamActivity.this, "当前机型不支持该滤镜", Toast.LENGTH_SHORT).show(); |
| @@ -385,9 +378,9 @@ public class StreamActivity extends Activity { | @@ -385,9 +378,9 @@ public class StreamActivity extends Activity { | ||
| 385 | int diff = position - 16; | 378 | int diff = position - 16; |
| 386 | mStreamer.setFilter(CN_FILTER_BEAUTY_1977.getFilter() + diff); | 379 | mStreamer.setFilter(CN_FILTER_BEAUTY_1977.getFilter() + diff); |
| 387 | } | 380 | } |
| 388 | - List<ImgFilterBase> filters = mStreamer.getFilter(); | 381 | + List<CNNewImgFilterBase> filters = mStreamer.getFilter(); |
| 389 | if (filters != null && !filters.isEmpty()) { | 382 | if (filters != null && !filters.isEmpty()) { |
| 390 | - final ImgFilterBase filter = filters.get(0); | 383 | + final CNNewImgFilterBase filter = filters.get(0); |
| 391 | mBeautyGrindLayout.setVisibility(filter.isGrindRatioSupported() ? | 384 | mBeautyGrindLayout.setVisibility(filter.isGrindRatioSupported() ? |
| 392 | View.VISIBLE : View.GONE); | 385 | View.VISIBLE : View.GONE); |
| 393 | mBeautyWhitenLayout.setVisibility(filter.isWhitenRatioSupported() ? | 386 | mBeautyWhitenLayout.setVisibility(filter.isWhitenRatioSupported() ? |
| @@ -408,7 +401,7 @@ public class StreamActivity extends Activity { | @@ -408,7 +401,7 @@ public class StreamActivity extends Activity { | ||
| 408 | } else if (seekBar == mWhitenSeekBar) { | 401 | } else if (seekBar == mWhitenSeekBar) { |
| 409 | filter.setWhitenRatio(val); | 402 | filter.setWhitenRatio(val); |
| 410 | } else if (seekBar == mRuddySeekBar) { | 403 | } else if (seekBar == mRuddySeekBar) { |
| 411 | - if (filter instanceof ImgBeautyProFilter) { | 404 | + if (filter instanceof CNImgBeautyProFilter) { |
| 412 | val = progress / 50.f - 1.0f; | 405 | val = progress / 50.f - 1.0f; |
| 413 | } | 406 | } |
| 414 | filter.setRuddyRatio(val); | 407 | filter.setRuddyRatio(val); |
| @@ -429,7 +422,7 @@ public class StreamActivity extends Activity { | @@ -429,7 +422,7 @@ public class StreamActivity extends Activity { | ||
| 429 | mGrindSeekBar.setProgress((int) (filter.getGrindRatio() * 100)); | 422 | mGrindSeekBar.setProgress((int) (filter.getGrindRatio() * 100)); |
| 430 | mWhitenSeekBar.setProgress((int) (filter.getWhitenRatio() * 100)); | 423 | mWhitenSeekBar.setProgress((int) (filter.getWhitenRatio() * 100)); |
| 431 | int ruddyVal = (int) (filter.getRuddyRatio() * 100); | 424 | int ruddyVal = (int) (filter.getRuddyRatio() * 100); |
| 432 | - if (filter instanceof ImgBeautyProFilter) { | 425 | + if (filter instanceof CNImgBeautyProFilter) { |
| 433 | ruddyVal = (int) (filter.getRuddyRatio() * 50 + 50); | 426 | ruddyVal = (int) (filter.getRuddyRatio() * 50 + 50); |
| 434 | } | 427 | } |
| 435 | mRuddySeekBar.setProgress(ruddyVal); | 428 | mRuddySeekBar.setProgress(ruddyVal); |
| @@ -523,6 +516,7 @@ public class StreamActivity extends Activity { | @@ -523,6 +516,7 @@ public class StreamActivity extends Activity { | ||
| 523 | @Override | 516 | @Override |
| 524 | public void onResume() { | 517 | public void onResume() { |
| 525 | super.onResume(); | 518 | super.onResume(); |
| 519 | + | ||
| 526 | mStreamer.setDisplayPreview(mCameraPreviewView); | 520 | mStreamer.setDisplayPreview(mCameraPreviewView); |
| 527 | mStreamer.resume(); | 521 | mStreamer.resume(); |
| 528 | if (mStreamer.isRecording() && !mAudioOnlyCheckBox.isChecked()) { | 522 | if (mStreamer.isRecording() && !mAudioOnlyCheckBox.isChecked()) { |
| @@ -532,10 +526,13 @@ public class StreamActivity extends Activity { | @@ -532,10 +526,13 @@ public class StreamActivity extends Activity { | ||
| 532 | if (mWaterMarkCheckBox.isChecked()) { | 526 | if (mWaterMarkCheckBox.isChecked()) { |
| 533 | showWaterMark(); | 527 | showWaterMark(); |
| 534 | } | 528 | } |
| 529 | + | ||
| 535 | } | 530 | } |
| 536 | 531 | ||
| 532 | + @Override | ||
| 537 | public void onPause() { | 533 | public void onPause() { |
| 538 | super.onPause(); | 534 | super.onPause(); |
| 535 | + | ||
| 539 | mStreamer.pause(); | 536 | mStreamer.pause(); |
| 540 | // mStreamer.stopCameraPreview(); | 537 | // mStreamer.stopCameraPreview(); |
| 541 | // if (mStreamer.isRecording() && !mAudioOnlyCheckBox.isChecked()) { | 538 | // if (mStreamer.isRecording() && !mAudioOnlyCheckBox.isChecked()) { |
| @@ -641,12 +638,13 @@ public class StreamActivity extends Activity { | @@ -641,12 +638,13 @@ public class StreamActivity extends Activity { | ||
| 641 | } catch (FileNotFoundException e) { | 638 | } catch (FileNotFoundException e) { |
| 642 | e.printStackTrace(); | 639 | e.printStackTrace(); |
| 643 | } finally { | 640 | } finally { |
| 644 | - if (bos != null) | 641 | + if (bos != null) { |
| 645 | try { | 642 | try { |
| 646 | bos.close(); | 643 | bos.close(); |
| 647 | } catch (IOException e) { | 644 | } catch (IOException e) { |
| 648 | e.printStackTrace(); | 645 | e.printStackTrace(); |
| 649 | } | 646 | } |
| 647 | + } | ||
| 650 | } | 648 | } |
| 651 | } | 649 | } |
| 652 | }); | 650 | }); |
| @@ -661,13 +659,6 @@ public class StreamActivity extends Activity { | @@ -661,13 +659,6 @@ public class StreamActivity extends Activity { | ||
| 661 | } | 659 | } |
| 662 | } | 660 | } |
| 663 | 661 | ||
| 664 | - private void onAddClick() { | ||
| 665 | - Intent intent = new Intent(getApplicationContext(), FloatActivity.class); | ||
| 666 | - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
| 667 | - CNGlobalStreamer.setInstance(mStreamer); | ||
| 668 | - startActivity(intent); | ||
| 669 | - } | ||
| 670 | - | ||
| 671 | private class ButtonObserver implements View.OnClickListener { | 662 | private class ButtonObserver implements View.OnClickListener { |
| 672 | @Override | 663 | @Override |
| 673 | public void onClick(View view) { | 664 | public void onClick(View view) { |
| @@ -696,9 +687,6 @@ public class StreamActivity extends Activity { | @@ -696,9 +687,6 @@ public class StreamActivity extends Activity { | ||
| 696 | case R.id.exposure: | 687 | case R.id.exposure: |
| 697 | onExposureClick(); | 688 | onExposureClick(); |
| 698 | break; | 689 | break; |
| 699 | - case R.id.add: | ||
| 700 | - onAddClick(); | ||
| 701 | - break; | ||
| 702 | default: | 690 | default: |
| 703 | break; | 691 | break; |
| 704 | } | 692 | } |
| @@ -833,16 +821,19 @@ public class StreamActivity extends Activity { | @@ -833,16 +821,19 @@ public class StreamActivity extends Activity { | ||
| 833 | //如果需要静音所有音频,调用下面方法 | 821 | //如果需要静音所有音频,调用下面方法 |
| 834 | // mStreamer.setMuteAudio(isChecked); | 822 | // mStreamer.setMuteAudio(isChecked); |
| 835 | //如果只想要静音麦克风,则需要调用下面方法 | 823 | //如果只想要静音麦克风,则需要调用下面方法 |
| 836 | - if (isChecked) | 824 | + if (isChecked) { |
| 837 | mStreamer.setVoiceVolume(0.0f); | 825 | mStreamer.setVoiceVolume(0.0f); |
| 838 | - else mStreamer.setVoiceVolume(0.4f); | 826 | + } else { |
| 827 | + mStreamer.setVoiceVolume(0.4f); | ||
| 828 | + } | ||
| 839 | } | 829 | } |
| 840 | 830 | ||
| 841 | private void onWaterMarkChecked(boolean isChecked) { | 831 | private void onWaterMarkChecked(boolean isChecked) { |
| 842 | - if (isChecked) | 832 | + if (isChecked) { |
| 843 | showWaterMark(); | 833 | showWaterMark(); |
| 844 | - else | 834 | + } else { |
| 845 | hideWaterMark(); | 835 | hideWaterMark(); |
| 836 | + } | ||
| 846 | } | 837 | } |
| 847 | 838 | ||
| 848 | private void onFrontMirrorChecked(boolean isChecked) { | 839 | private void onFrontMirrorChecked(boolean isChecked) { |
app/src/main/res/layout/titlebar.xml
| @@ -16,15 +16,15 @@ | @@ -16,15 +16,15 @@ | ||
| 16 | android:textColor="#FFFFFF" | 16 | android:textColor="#FFFFFF" |
| 17 | android:textSize="19sp" /> | 17 | android:textSize="19sp" /> |
| 18 | 18 | ||
| 19 | - <ImageView | ||
| 20 | - android:id="@+id/add" | ||
| 21 | - android:layout_width="22dp" | ||
| 22 | - android:layout_height="22dp" | ||
| 23 | - android:layout_gravity="center_vertical" | ||
| 24 | - android:layout_marginRight="10dp" | ||
| 25 | - android:layout_marginTop="8dp" | ||
| 26 | - android:layout_toLeftOf="@+id/exposure" | ||
| 27 | - android:background="@drawable/float_view" /> | 19 | + <!--<ImageView--> |
| 20 | + <!--android:id="@+id/add"--> | ||
| 21 | + <!--android:layout_width="22dp"--> | ||
| 22 | + <!--android:layout_height="22dp"--> | ||
| 23 | + <!--android:layout_gravity="center_vertical"--> | ||
| 24 | + <!--android:layout_marginRight="10dp"--> | ||
| 25 | + <!--android:layout_marginTop="8dp"--> | ||
| 26 | + <!--android:layout_toLeftOf="@+id/exposure"--> | ||
| 27 | + <!--android:background="@drawable/float_view" />--> | ||
| 28 | 28 | ||
| 29 | <ImageView | 29 | <ImageView |
| 30 | android:id="@+id/exposure" | 30 | android:id="@+id/exposure" |