-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from Johnny1994/dev
release v2.4.1
- Loading branch information
Showing
62 changed files
with
593 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-412 KB
PLDroidMediaStreamingDemo/app/libs/pldroid-media-streaming-2.4.0.jar
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...amingDemo/app/src/main/java/com/qiniu/pili/droid/streaming/demo/StreamingApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,65 @@ | ||
package com.qiniu.pili.droid.streaming.demo; | ||
|
||
import android.app.Application; | ||
import android.content.Intent; | ||
|
||
import com.qiniu.pili.droid.streaming.StreamingEnv; | ||
import com.qiniu.pili.droid.streaming.demo.service.KeepAppAliveService; | ||
import com.qiniu.pili.droid.streaming.demo.utils.AppStateTracker; | ||
|
||
public class StreamingApplication extends Application { | ||
|
||
private boolean mIsServiceAlive; | ||
private Intent mServiceIntent; | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
/** | ||
* init must be called before any other func | ||
*/ | ||
StreamingEnv.init(getApplicationContext()); | ||
|
||
/** | ||
* track app background state to avoid possibly stopping microphone recording | ||
* in screen streaming mode on Android P+ | ||
*/ | ||
AppStateTracker.track(this, new AppStateTracker.AppStateChangeListener() { | ||
@Override | ||
public void appTurnIntoForeground() { | ||
stopService(); | ||
} | ||
|
||
@Override | ||
public void appTurnIntoBackGround() { | ||
startService(); | ||
} | ||
|
||
@Override | ||
public void appDestroyed() { | ||
stopService(); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* start foreground service to make process not turn to idle state | ||
* | ||
* on Android P+, it doesn't allow recording audio to protect user's privacy in idle state. | ||
*/ | ||
private void startService() { | ||
if (mServiceIntent == null) { | ||
mServiceIntent = new Intent(StreamingApplication.this, KeepAppAliveService.class); | ||
} | ||
startService(mServiceIntent); | ||
mIsServiceAlive = true; | ||
} | ||
|
||
private void stopService() { | ||
if (mIsServiceAlive) { | ||
stopService(mServiceIntent); | ||
mServiceIntent = null; | ||
mIsServiceAlive = false; | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...mo/app/src/main/java/com/qiniu/pili/droid/streaming/demo/service/KeepAppAliveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.qiniu.pili.droid.streaming.demo.service; | ||
|
||
import android.app.Notification; | ||
import android.app.NotificationChannel; | ||
import android.app.NotificationManager; | ||
import android.app.Service; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Build; | ||
import android.os.IBinder; | ||
import android.support.annotation.Nullable; | ||
|
||
import com.qiniu.pili.droid.streaming.demo.R; | ||
|
||
public class KeepAppAliveService extends Service { | ||
private NotificationManager mNotificationManager; | ||
private String mNotificationId = "keepAppAliveId"; | ||
private String mNotificationName = "Keep app alive"; | ||
|
||
@Nullable | ||
@Override | ||
public IBinder onBind(Intent intent) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
NotificationChannel channel = new NotificationChannel(mNotificationId, mNotificationName, NotificationManager.IMPORTANCE_HIGH); | ||
mNotificationManager.createNotificationChannel(channel); | ||
} | ||
startForeground(1, getNotification()); | ||
} | ||
|
||
private Notification getNotification() { | ||
Notification.Builder builder = new Notification.Builder(this) | ||
.setSmallIcon(R.mipmap.ic_launcher) | ||
.setContentTitle("七牛推流") | ||
.setContentText("后台运行中"); | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
builder.setChannelId(mNotificationId); | ||
} | ||
return builder.build(); | ||
} | ||
} |
105 changes: 105 additions & 0 deletions
105
...mingDemo/app/src/main/java/com/qiniu/pili/droid/streaming/demo/utils/AppStateTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package com.qiniu.pili.droid.streaming.demo.utils; | ||
|
||
import android.app.Activity; | ||
import android.app.Application; | ||
import android.os.Bundle; | ||
|
||
public class AppStateTracker { | ||
public static final int STATE_FOREGROUND = 0; | ||
|
||
public static final int STATE_BACKGROUND = 1; | ||
|
||
private static int currentState; | ||
|
||
public static int getCurrentState() { | ||
return currentState; | ||
} | ||
|
||
public interface AppStateChangeListener { | ||
void appTurnIntoForeground(); | ||
void appTurnIntoBackGround(); | ||
void appDestroyed(); | ||
} | ||
|
||
public static void track(Application application, final AppStateChangeListener appStateChangeListener){ | ||
|
||
application.registerActivityLifecycleCallbacks(new SimpleActivityLifecycleCallbacks(){ | ||
|
||
private int resumeActivityCount = 0; | ||
private int createActivityCount = 0; | ||
|
||
@Override | ||
public void onActivityCreated(Activity activity, Bundle bundle) { | ||
createActivityCount++; | ||
} | ||
|
||
@Override | ||
public void onActivityStarted(Activity activity) { | ||
if (resumeActivityCount==0){ | ||
currentState = STATE_FOREGROUND; | ||
appStateChangeListener.appTurnIntoForeground(); | ||
} | ||
|
||
resumeActivityCount++; | ||
} | ||
|
||
@Override | ||
public void onActivityStopped(Activity activity) { | ||
resumeActivityCount--; | ||
|
||
if (resumeActivityCount==0){ | ||
currentState = STATE_BACKGROUND; | ||
appStateChangeListener.appTurnIntoBackGround(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onActivityDestroyed(Activity activity) { | ||
createActivityCount--; | ||
|
||
if (createActivityCount == 0) { | ||
appStateChangeListener.appDestroyed(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
private static class SimpleActivityLifecycleCallbacks implements Application | ||
.ActivityLifecycleCallbacks{ | ||
|
||
@Override | ||
public void onActivityCreated(Activity activity, Bundle bundle) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityStarted(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityResumed(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityPaused(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityStopped(Activity activity) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { | ||
|
||
} | ||
|
||
@Override | ||
public void onActivityDestroyed(Activity activity) { | ||
|
||
} | ||
} | ||
} |
Binary file modified
BIN
+12 KB
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/arm64-v8a/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified
BIN
+27.9 KB
(120%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/arm64-v8a/libpldroid_streaming_aac_encoder.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/arm64-v8a/libpldroid_streaming_amix.so
Binary file not shown.
Binary file modified
BIN
-4.09 KB
(97%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/arm64-v8a/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...oidMediaStreamingDemo/app/src/main/jniLibs/arm64-v8a/libpldroid_streaming_h264_encoder.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi-v7a/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
...idMediaStreamingDemo/app/src/main/jniLibs/armeabi-v7a/libpldroid_streaming_aac_encoder.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi-v7a/libpldroid_streaming_amix.so
Binary file not shown.
Binary file modified
BIN
+3.94 KB
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi-v7a/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified
BIN
-4 KB
(100%)
...dMediaStreamingDemo/app/src/main/jniLibs/armeabi-v7a/libpldroid_streaming_h264_encoder.so
Binary file not shown.
Binary file modified
BIN
+4 KB
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified
BIN
-4 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi/libpldroid_streaming_aac_encoder.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi/libpldroid_streaming_amix.so
Binary file not shown.
Binary file modified
BIN
+3.94 KB
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified
BIN
-4 KB
(99%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/armeabi/libpldroid_streaming_h264_encoder.so
Binary file not shown.
Binary file modified
BIN
+4 KB
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/x86/libpldroid_mmprocessing.so
Binary file not shown.
Binary file modified
BIN
+43.9 KB
(140%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/x86/libpldroid_streaming_aac_encoder.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/x86/libpldroid_streaming_amix.so
Binary file not shown.
Binary file modified
BIN
-4.06 KB
(97%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/x86/libpldroid_streaming_core.so
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
PLDroidMediaStreamingDemo/app/src/main/jniLibs/x86/libpldroid_streaming_h264_encoder.so
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ buildscript { | |
allprojects { | ||
repositories { | ||
jcenter() | ||
google() | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.