Skip to content

Commit

Permalink
Release for v3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
BoleLiu committed Aug 31, 2023
1 parent f8cb288 commit 7c808d6
Show file tree
Hide file tree
Showing 77 changed files with 168 additions and 19 deletions.
4 changes: 2 additions & 2 deletions PLDroidMediaStreamingDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.qiniu.pili.droid.streaming.demo"
minSdkVersion 18
targetSdkVersion 29
versionCode 77
versionName "3.1.4"
versionCode 78
versionName "3.1.5"
}
buildTypes {
release {
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class MainActivity extends FragmentActivity {
private static final String TAG = "MainActivity";

private static final String GENERATE_STREAM_TEXT = "https://api-demo.qnsdk.com/v1/live/stream/";
private static final String QN_PUBLISH_URL_PREFIX = "rtmp://pili-publish.qnsdk.com/sdk-live/";
private static final String QN_RTMP_PUBLISH_URL_PREFIX = "rtmp://pili-publish.qnsdk.com/sdk-live/";
private static final String QN_SRT_PUBLISH_URL_PREFIX = "srt://pili-publish.qnsdk.com";
private static final String QN_PLAY_URL_PREFIX = "rtmp://pili-rtmp.qnsdk.com/sdk-live/";

private static final String[] STREAM_TYPES = { "Video-Audio", "Audio", "Import", "Screen" };
Expand Down Expand Up @@ -367,7 +368,8 @@ private boolean isQNPublishUrl(String url) {
Log.i(TAG, "Url can not be null !");
return false;
}
return url.startsWith(QN_PUBLISH_URL_PREFIX);
return url.startsWith(QN_RTMP_PUBLISH_URL_PREFIX)
|| url.startsWith(QN_SRT_PUBLISH_URL_PREFIX);
}

private String getStreamName(String publishUrl) {
Expand All @@ -376,8 +378,17 @@ private String getStreamName(String publishUrl) {
return null;
}
int startIndex = publishUrl.lastIndexOf("/");
int endIndex = publishUrl.indexOf("?");
return publishUrl.substring(startIndex + 1, endIndex);
int endIndex = -1;
if (publishUrl.startsWith(QN_RTMP_PUBLISH_URL_PREFIX)) {
endIndex = publishUrl.indexOf("?");
} else if (publishUrl.startsWith(QN_SRT_PUBLISH_URL_PREFIX)) {
endIndex = publishUrl.indexOf(',');
}
if (endIndex == -1) {
return publishUrl.substring(startIndex + 1);
} else {
return publishUrl.substring(startIndex + 1, endIndex);
}
}

private void copyToClipboard(String content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.qiniu.pili.droid.streaming.FrameCapturedCallback;
import com.qiniu.pili.droid.streaming.MediaStreamingManager;
import com.qiniu.pili.droid.streaming.MicrophoneStreamingSetting;
import com.qiniu.pili.droid.streaming.PLVideoEncodeType;
import com.qiniu.pili.droid.streaming.StreamStatusCallback;
import com.qiniu.pili.droid.streaming.StreamingPreviewCallback;
import com.qiniu.pili.droid.streaming.StreamingProfile;
Expand Down Expand Up @@ -82,6 +83,7 @@ public class AVStreamingActivity extends Activity implements
private boolean mIsPreviewMirror = false;
private boolean mIsEncodingMirror = false;
private boolean mIsPlayingback = false;
private boolean mIsAudioMixLoop = true;
private boolean mIsStreaming = false;

private volatile boolean mIsSupportTorch = false;
Expand Down Expand Up @@ -163,7 +165,7 @@ protected void onStart() {
// 打开摄像头
mMediaStreamingManager.resume();
} else {
ToastUtils.s(this, "当前正在图片推流!!!");
ToastUtils.s(getApplicationContext(), "当前正在图片推流!!!");
}
}

Expand Down Expand Up @@ -298,6 +300,8 @@ private void initEncodingProfile() {
mProfile.setVideoAdaptiveBitrateRange(mEncodingConfig.mAdaptiveBitrateMin * 1024, mEncodingConfig.mAdaptiveBitrateMax * 1024);
}
}
// 设置视频编码格式(H.264/H.265)
mProfile.setVideoEncodeType(mEncodingConfig.mVideoEncodeType);

// 设置音频质量参数
if (mEncodingConfig.mIsAudioQualityPreset) {
Expand Down Expand Up @@ -404,6 +408,7 @@ private void initStreamingManager() {
microphoneStreamingSetting.setBluetoothSCOEnabled(isBluetoothScoEnabled);
mMediaStreamingManager.prepare(mCameraStreamingSetting, microphoneStreamingSetting, mWatermarkSetting, mProfile);
mMediaStreamingManager.setAutoRefreshOverlay(true);
mMediaStreamingManager.setNativeLoggingEnabled(true);
cameraPreviewFrameView.setListener(this);

// 设置推流所需监听器
Expand Down Expand Up @@ -448,7 +453,7 @@ public void onProgress(long progress, long duration) {
mAudioFile = Cache.getAudioFile(this);
if (mAudioFile != null) {
try {
mAudioMixer.setFile(mAudioFile, true);
mAudioMixer.setFile(mAudioFile, mIsAudioMixLoop);
} catch (IOException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -499,7 +504,7 @@ public void onPreviewMirrorClicked() {
mIsPreviewMirror = !mIsPreviewMirror;
boolean res = mMediaStreamingManager.setPreviewMirror(mIsPreviewMirror);
if (res) {
ToastUtils.s(AVStreamingActivity.this, "镜像成功");
ToastUtils.s(getApplicationContext(), "镜像成功");
} else {
mIsPreviewMirror = !mIsPreviewMirror;
}
Expand Down Expand Up @@ -618,7 +623,7 @@ public void onSelectedFilePaths(String[] files) {
}
String filePath = files[0];
try {
mAudioMixer.setFile(filePath, true);
mAudioMixer.setFile(filePath, mIsAudioMixLoop);
Cache.setAudioFile(AVStreamingActivity.this, filePath);
ToastUtils.s(getApplicationContext(), "setup mix file " + filePath + " success. duration:" + mAudioMixer.getDuration());
} catch (IOException e) {
Expand Down Expand Up @@ -660,7 +665,7 @@ public void onAudioMixStopClicked() {
String text = stopSuccess ? "mixing stop success" : "mixing stop failed !!!";
ToastUtils.s(getApplicationContext(), text);
if (stopSuccess) {
updateMixBtnText();
mControlFragment.setAudioMixControllerText("Play");
}
}
}
Expand All @@ -678,6 +683,11 @@ public void onAudioMixPlaybackClicked() {
mIsPlayingback = !mIsPlayingback;
}

@Override
public void onAudioMixLoopEnabled(boolean enabled) {
mIsAudioMixLoop = enabled;
}

/**
* 点击图片推流按钮时触发,用于控制图片推流
*/
Expand Down Expand Up @@ -880,7 +890,7 @@ public boolean onZoomValueChanged(float factor) {
*/
private StreamingStateChangedListener mStreamingStateChangedListener = new StreamingStateChangedListener() {
@Override
public void onStateChanged(StreamingState streamingState, Object extra) {
public void onStateChanged(StreamingState streamingState, final Object extra) {
Log.i(TAG, "onStateChanged : " + streamingState.name());
switch (streamingState) {
case PREPARING:
Expand Down Expand Up @@ -921,6 +931,15 @@ public void run() {
}
});
break;
case VIDEO_ENCODER_READY:
runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.s(getApplicationContext(),
"编码器初始化完成:" + ((PLVideoEncodeType) extra).name());
}
});
break;
case START_VIDEO_ENCODER_FAIL:
case VIDEO_ENCODER_ERROR:
case START_AUDIO_ENCODER_FAIL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.widget.Toast;

import com.qiniu.pili.droid.streaming.AVCodecType;
import com.qiniu.pili.droid.streaming.PLVideoEncodeType;
import com.qiniu.pili.droid.streaming.StreamStatusCallback;
import com.qiniu.pili.droid.streaming.StreamingManager;
import com.qiniu.pili.droid.streaming.StreamingProfile;
Expand All @@ -27,6 +28,7 @@
import com.qiniu.pili.droid.streaming.demo.R;
import com.qiniu.pili.droid.streaming.demo.core.ExtAudioCapture;
import com.qiniu.pili.droid.streaming.demo.core.ExtVideoCapture;
import com.qiniu.pili.droid.streaming.demo.utils.ToastUtils;
import com.qiniu.pili.droid.streaming.demo.utils.Util;

import java.net.URISyntaxException;
Expand Down Expand Up @@ -214,6 +216,8 @@ private void initEncodingProfile() {
mProfile.setVideoAdaptiveBitrateRange(mEncodingConfig.mAdaptiveBitrateMin * 1024, mEncodingConfig.mAdaptiveBitrateMax * 1024);
}
}
// 设置视频编码格式(H.264/H.265)
mProfile.setVideoEncodeType(mEncodingConfig.mVideoEncodeType);

// 设置音频质量参数
if (mEncodingConfig.mIsAudioQualityPreset) {
Expand Down Expand Up @@ -337,7 +341,7 @@ public void run() {
*/
private StreamingStateChangedListener mStreamingStateChangedListener = new StreamingStateChangedListener() {
@Override
public void onStateChanged(StreamingState streamingState, Object extra) {
public void onStateChanged(StreamingState streamingState, final Object extra) {
Log.i(TAG, "StreamingState streamingState:" + streamingState + ",extra:" + extra);
switch (streamingState) {
case PREPARING:
Expand Down Expand Up @@ -396,6 +400,15 @@ public void onStateChanged(StreamingState streamingState, Object extra) {
case UNAUTHORIZED_PACKAGE:
mLogContent += "Unauthorized package\n";
break;
case VIDEO_ENCODER_READY:
runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.s(getApplicationContext(),
"编码器初始化完成:" + ((PLVideoEncodeType) extra).name());
}
});
break;
case START_VIDEO_ENCODER_FAIL:
case VIDEO_ENCODER_ERROR:
case START_AUDIO_ENCODER_FAIL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.qiniu.pili.droid.streaming.PLVideoEncodeType;
import com.qiniu.pili.droid.streaming.ScreenSetting;
import com.qiniu.pili.droid.streaming.ScreenStreamingManager;
import com.qiniu.pili.droid.streaming.StreamStatusCallback;
Expand All @@ -29,6 +30,7 @@
import com.qiniu.pili.droid.streaming.demo.plain.EncodingConfig;
import com.qiniu.pili.droid.streaming.demo.utils.Config;
import com.qiniu.pili.droid.streaming.demo.R;
import com.qiniu.pili.droid.streaming.demo.utils.ToastUtils;
import com.qiniu.pili.droid.streaming.demo.utils.Util;

import java.net.URISyntaxException;
Expand Down Expand Up @@ -217,6 +219,8 @@ private void initEncodingProfile() {
mProfile.setVideoAdaptiveBitrateRange(mEncodingConfig.mAdaptiveBitrateMin * 1024, mEncodingConfig.mAdaptiveBitrateMax * 1024);
}
}
// 设置视频编码格式(H.264/H.265)
mProfile.setVideoEncodeType(mEncodingConfig.mVideoEncodeType);

// 设置音频质量参数
if (mEncodingConfig.mIsAudioQualityPreset) {
Expand Down Expand Up @@ -340,7 +344,7 @@ public void run() {
*/
private StreamingStateChangedListener mStreamingStateChangedListener = new StreamingStateChangedListener() {
@Override
public void onStateChanged(StreamingState streamingState, Object extra) {
public void onStateChanged(StreamingState streamingState, final Object extra) {
Log.i(TAG, "StreamingState streamingState:" + streamingState + ",extra:" + extra);
switch (streamingState) {
case PREPARING:
Expand Down Expand Up @@ -385,6 +389,15 @@ public void onStateChanged(StreamingState streamingState, Object extra) {
case UNKNOWN:
mStatusMsgContent = getString(R.string.string_state_ready);
break;
case VIDEO_ENCODER_READY:
runOnUiThread(new Runnable() {
@Override
public void run() {
ToastUtils.s(getApplicationContext(),
"编码器初始化完成:" + ((PLVideoEncodeType) extra).name());
}
});
break;
case SENDING_BUFFER_EMPTY:
case SENDING_BUFFER_FULL:
case AUDIO_RECORDING_FAIL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ScrollView;
Expand Down Expand Up @@ -74,6 +76,7 @@ public interface OnEventClickedListener {
void onAudioMixControllerClicked();
void onAudioMixStopClicked();
void onAudioMixPlaybackClicked();
void onAudioMixLoopEnabled(boolean enabled);
void onSendSEIClicked();
}

Expand Down Expand Up @@ -413,6 +416,16 @@ public void onClick(View v) {
}
});

CheckBox loopCheckBox = mFragmentView.findViewById(R.id.loop_btn);
loopCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (mOnEventClickedListener != null) {
mOnEventClickedListener.onAudioMixLoopEnabled(isChecked);
}
}
});

return mFragmentView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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.PLVideoEncodeType;
import com.qiniu.pili.droid.streaming.StreamingProfile;
import com.qiniu.pili.droid.streaming.WatermarkSetting;
import com.qiniu.pili.droid.streaming.demo.R;
Expand Down Expand Up @@ -224,6 +225,8 @@ private EncodingConfig buildEncodingConfig() {
codecHW? AVCodecType.HW_VIDEO_SURFACE_AS_INPUT_WITH_HW_AUDIO_CODEC :
AVCodecType.HW_VIDEO_YUV_AS_INPUT_WITH_HW_AUDIO_CODEC;
}
boolean encodeH264 = ((RadioButton) root.findViewById(R.id.video_avc)).isChecked();
encodingConfig.mVideoEncodeType = encodeH264 ? PLVideoEncodeType.H264 : PLVideoEncodeType.HEVC;
// set video if not audio only
if (!encodingConfig.mIsAudioOnly) {
// quality
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.qiniu.pili.droid.streaming.demo.plain;

import com.qiniu.pili.droid.streaming.AVCodecType;
import com.qiniu.pili.droid.streaming.PLVideoEncodeType;
import com.qiniu.pili.droid.streaming.StreamingProfile;
import com.qiniu.pili.droid.streaming.WatermarkSetting;

Expand All @@ -12,6 +13,7 @@
*/
public class EncodingConfig implements Serializable {
public AVCodecType mCodecType;
public PLVideoEncodeType mVideoEncodeType;
public boolean mIsAudioOnly;

public boolean mIsVideoQualityPreset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onCreate() {

private Notification getNotification() {
Notification.Builder builder = new Notification.Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setSmallIcon(R.drawable.qiniu_logo)
.setContentTitle("七牛推流")
.setContentText("后台运行中");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 18 additions & 3 deletions PLDroidMediaStreamingDemo/app/src/main/res/layout/audio_mixer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,46 @@

<Button
android:id="@+id/mix_file_btn"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="File"
android:textColor="@color/pldroid_streaming_white" />

<Button
android:id="@+id/mix_btn"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Play"
android:textColor="@color/pldroid_streaming_white" />

<Button
android:id="@+id/mix_stop_btn"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Stop"
android:textColor="@color/pldroid_streaming_white" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/playback_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TogglePlayback"
android:textColor="@color/pldroid_streaming_white" />

<CheckBox
android:id="@+id/loop_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Loop"
android:textColor="@color/pldroid_streaming_white"
android:checked="true" />
</LinearLayout>

<LinearLayout
Expand Down
Loading

0 comments on commit 7c808d6

Please sign in to comment.