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