Skip to content

Commit

Permalink
Merge pull request #299 from york1996/master
Browse files Browse the repository at this point in the history
release_v2.4.0
  • Loading branch information
geeklok authored Nov 16, 2018
2 parents bf932a6 + 4b2b648 commit b2f2869
Show file tree
Hide file tree
Showing 29 changed files with 179 additions and 8 deletions.
8 changes: 4 additions & 4 deletions PLDroidMediaStreamingDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion '27.0.3'

defaultConfig {
applicationId "com.qiniu.pili.droid.streaming.demo"
minSdkVersion 15
targetSdkVersion 23
versionCode 67
versionName "2.3.0"
versionCode 68
versionName "2.4.0"
}
buildTypes {
release {
Expand All @@ -25,5 +25,5 @@ dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
compile 'com.google.zxing:core:3.2.0'
compile 'com.android.support:appcompat-v7:23.0.0'
compile files('libs/pldroid-media-streaming-2.3.0.jar')
compile files('libs/pldroid-media-streaming-2.4.0.jar')
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.hardware.Camera;
import android.media.AudioFormat;
import android.os.Build;
Expand All @@ -11,18 +10,22 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.Toast;

import com.github.angads25.filepicker.controller.DialogSelectionListener;
import com.github.angads25.filepicker.model.DialogConfigs;
import com.github.angads25.filepicker.model.DialogProperties;
import com.github.angads25.filepicker.view.FilePickerDialog;
import com.qiniu.pili.droid.streaming.AVCodecType;
import com.qiniu.pili.droid.streaming.CameraStreamingSetting;
import com.qiniu.pili.droid.streaming.FrameCapturedCallback;
import com.qiniu.pili.droid.streaming.MediaStreamingManager;
Expand Down Expand Up @@ -154,6 +157,7 @@ protected void initStreamingManager() {
microphoneStreamingSetting.setChannelConfig(AudioFormat.CHANNEL_IN_STEREO);
}
mMediaStreamingManager.prepare(mCameraStreamingSetting, microphoneStreamingSetting, buildWatermarkSetting(), mProfile);
mMediaStreamingManager.setAutoRefreshOverlay(true);
if (mCameraConfig.mIsCustomFaceBeauty) {
mMediaStreamingManager.setSurfaceTextureCallback(this);
}
Expand Down Expand Up @@ -234,6 +238,9 @@ public void run() {
}
Log.i(TAG, "switchCamera:" + facingId);
mMediaStreamingManager.switchCamera(facingId);

mIsEncodingMirror = mCameraConfig.mEncodingMirror;
mIsPreviewMirror = facingId == CameraStreamingSetting.CAMERA_FACING_ID.CAMERA_FACING_FRONT ? mCameraConfig.mPreviewMirror : false;
}
}

Expand Down Expand Up @@ -364,6 +371,9 @@ private WatermarkSetting buildWatermarkSetting() {
watermarkSetting.setResourceId(R.drawable.qiniu_logo);
watermarkSetting.setAlpha(mEncodingConfig.mWatermarkAlpha);
watermarkSetting.setSize(mEncodingConfig.mWatermarkSize);
if (mEncodingConfig.mWatermarkCustomWidth != 0 || mEncodingConfig.mWatermarkCustomHeight != 0) {
watermarkSetting.setCustomSize(mEncodingConfig.mWatermarkCustomWidth, mEncodingConfig.mWatermarkCustomHeight);
}
if (mEncodingConfig.mIsWatermarkLocationPreset) {
watermarkSetting.setLocation(mEncodingConfig.mWatermarkLocationPreset);
} else {
Expand Down Expand Up @@ -448,6 +458,7 @@ public void initView() {
Button previewMirrorBtn = (Button) findViewById(R.id.preview_mirror_btn);
Button encodingMirrorBtn = (Button) findViewById(R.id.encoding_mirror_btn);
Button picStreamingBtn = (Button) findViewById(R.id.pic_streaming_btn);
Button addOverlayBtn = (Button) findViewById(R.id.add_overlay_btn);

mFaceBeautyBtn.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -503,6 +514,25 @@ public void onClick(View v) {
}
});

if (mEncodingConfig.mCodecType == AVCodecType.HW_VIDEO_SURFACE_AS_INPUT_WITH_HW_AUDIO_CODEC ||
mEncodingConfig.mCodecType == AVCodecType.HW_VIDEO_SURFACE_AS_INPUT_WITH_SW_AUDIO_CODEC ||
mEncodingConfig.mCodecType == AVCodecType.HW_VIDEO_WITH_HW_AUDIO_CODEC ||
mEncodingConfig.mCodecType == AVCodecType.HW_VIDEO_CODEC) {
addOverlayBtn.setVisibility(View.VISIBLE);
addOverlayBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ImageView imageOverlay = new ImageView(AVStreamingActivity.this);
imageOverlay.setImageResource(R.drawable.qiniu_logo);
imageOverlay.setOnTouchListener(new ViewTouchListener(imageOverlay));
((FrameLayout) findViewById(R.id.content)).addView(imageOverlay, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));

mMediaStreamingManager.addOverlay(imageOverlay);
Toast.makeText(AVStreamingActivity.this, "双击删除贴图!", Toast.LENGTH_LONG).show();
}
});
}

mTorchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -587,6 +617,85 @@ public void onStopTrackingTouch(SeekBar seekBar) {
initAudioMixerPanel();
}

private class ViewTouchListener implements View.OnTouchListener {
private float lastTouchRawX;
private float lastTouchRawY;
private boolean scale;
private View mView;

public ViewTouchListener(View view) {
mView = view;
}

GestureDetector.SimpleOnGestureListener simpleOnGestureListener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
((FrameLayout) findViewById(R.id.content)).removeView(mView);
mMediaStreamingManager.removeOverlay(mView);
return true;
}

@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
return true;
}
};

final GestureDetector gestureDetector = new GestureDetector(AVStreamingActivity.this, simpleOnGestureListener);

@Override
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}

int action = event.getAction();
float touchRawX = event.getRawX();
float touchRawY = event.getRawY();
float touchX = event.getX();
float touchY = event.getY();

if (action == MotionEvent.ACTION_DOWN) {
boolean xOK = touchX >= v.getWidth() * 3 / 4 && touchX <= v.getWidth();
boolean yOK = touchY >= v.getHeight() * 2 / 4 && touchY <= v.getHeight();
scale = xOK && yOK;
}

if (action == MotionEvent.ACTION_MOVE) {
float deltaRawX = touchRawX - lastTouchRawX;
float deltaRawY = touchRawY - lastTouchRawY;

if (scale) {
// rotate
float centerX = v.getX() + (float) v.getWidth() / 2;
float centerY = v.getY() + (float) v.getHeight() / 2;
double angle = Math.atan2(touchRawY - centerY, touchRawX - centerX) * 180 / Math.PI;
v.setRotation((float) angle - 45);

// scale
float xx = (touchRawX >= centerX ? deltaRawX : -deltaRawX);
float yy = (touchRawY >= centerY ? deltaRawY : -deltaRawY);
float sf = (v.getScaleX() + xx / v.getWidth() + v.getScaleY() + yy / v.getHeight()) / 2;
v.setScaleX(sf);
v.setScaleY(sf);
} else {
// translate
v.setTranslationX(v.getTranslationX() + deltaRawX);
v.setTranslationY(v.getTranslationY() + deltaRawY);
}
}

if (action == MotionEvent.ACTION_UP) {
// 当 mMediaStreamingManager.setAutoRefreshOverlay(false) 时自动刷新关闭,建议在 UP 事件里进行手动刷新。
// mMediaStreamingManager.refreshOverlay(v, false);
}

lastTouchRawX = touchRawX;
lastTouchRawY = touchRawY;
return true;
}
}

private void initButtonText() {
updateFBButtonText();
updateCameraSwitcherButtonText(mCameraStreamingSetting.getReqCameraId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ private EncodingConfig buildEncodingConfig() {
encodingConfig.mWatermarkAlpha = Integer.parseInt(((EditText) root.findViewById(R.id.watermark_alpha)).getText().toString());
Spinner sizeSpinner = (Spinner) root.findViewById(R.id.watermark_size_presets);
encodingConfig.mWatermarkSize = WATERMARK_SIZE_PRESETS_MAPPING[sizeSpinner.getSelectedItemPosition()];
encodingConfig.mWatermarkCustomWidth = Integer.parseInt(((EditText)root.findViewById(R.id.watermark_custom_width)).getText().toString().trim());
encodingConfig.mWatermarkCustomHeight = Integer.parseInt(((EditText)root.findViewById(R.id.watermark_custom_height)).getText().toString().trim());
encodingConfig.mIsWatermarkLocationPreset = ((RadioButton) root.findViewById(R.id.watermark_location_preset)).isChecked();
if (encodingConfig.mIsWatermarkLocationPreset) {
Spinner presetSpinner = (Spinner) root.findViewById(R.id.watermark_location_presets);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class EncodingConfig implements Serializable {
public boolean mIsWatermarkEnabled;
public int mWatermarkAlpha;
public WatermarkSetting.WATERMARK_SIZE mWatermarkSize;
public int mWatermarkCustomWidth;
public int mWatermarkCustomHeight;
public boolean mIsWatermarkLocationPreset;
public WatermarkSetting.WATERMARK_LOCATION mWatermarkLocationPreset;
public float mWatermarkLocationCustomX;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
android:text="Picture\nStreaming"
android:textColor="@color/pldroid_streaming_white" />

<Button
android:id="@+id/add_overlay_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add\nOverlay"
android:textColor="@color/pldroid_streaming_white"
android:visibility="gone" />

</LinearLayout>

<LinearLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,35 @@
android:layout_height="wrap_content" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Watermark custom width:" />

<EditText
android:id="@+id/watermark_custom_width"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="0"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="height:" />

<EditText
android:id="@+id/watermark_custom_height"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:text="0"/>
</LinearLayout>

<RadioGroup
android:id="@+id/watermark_location_radio_group"
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion PLDroidMediaStreamingDemo/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.2.3'
classpath 'com.android.tools.build:gradle:3.1.4'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Dec 23 17:00:24 CST 2016
#Wed Oct 17 17:34:59 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
20 changes: 20 additions & 0 deletions ReleaseNotes/release-notes-2.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# PLDroidMediaStreaming Release Notes for 2.4.0

本次更新:

## 版本

- 发布 pldroid-media-streaming-2.4.0.jar

## 功能

- 新增以下两个方法用于 Surface 硬编下,推流前的纹理回调
* `MediaStreamingManager.setSurfaceTextureCallback2(SurfaceTextureCallback2)`
* `StreamingManager.setSurfaceTextureCallback2(SurfaceTextureCallback2)`
- 新增以下方法用于设置水印自定义像素大小,不仅限于固定枚举值
* `WatermarkSetting.setCustomSize(int width, int height)`

## 注意事项

- 从 v2.3.0 版本开始,增加 libpldroid_streaming_puic.so 库
- libpldroid_streaming_core.so 依赖于 libpldroid_streaming_puic.so,无论是否启用 QUIC 推流,都需要包含 libpldroid_streaming_puic.so 库
Binary file modified releases/arm64-v8a/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified releases/arm64-v8a/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified releases/armeabi-v7a/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified releases/armeabi-v7a/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified releases/armeabi/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified releases/armeabi/libpldroid_streaming_core.so
Binary file not shown.
Binary file removed releases/pldroid-media-streaming-2.3.0.jar
Binary file not shown.
Binary file added releases/pldroid-media-streaming-2.4.0.jar
Binary file not shown.
Binary file modified releases/x86/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified releases/x86/libpldroid_streaming_core.so
Binary file not shown.

0 comments on commit b2f2869

Please sign in to comment.