[*] android项目结构调整
This commit is contained in:
@@ -1,14 +1,10 @@
|
|||||||
package com.acgist.taoyao.client;
|
package com.acgist.taoyao.client;
|
||||||
|
|
||||||
import android.app.KeyguardManager;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.PowerManager;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开机启动
|
* 开机启动
|
||||||
@@ -21,7 +17,7 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
Log.i(BootReceiver.class.getSimpleName(), "onReceive");
|
Log.i(BootReceiver.class.getSimpleName(), "onReceive");
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
|
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||||
if(resources.getBoolean(R.bool.preview)) {
|
if(resources.getBoolean(R.bool.preview)) {
|
||||||
this.launchPreview(context);
|
this.launchPreview(context);
|
||||||
}
|
}
|
||||||
@@ -34,9 +30,9 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
* @param context 上下文
|
* @param context 上下文
|
||||||
*/
|
*/
|
||||||
private void launchPreview(Context context) {
|
private void launchPreview(Context context) {
|
||||||
final Intent mainActivity = new Intent(context, MainActivity.class);
|
final Intent intent = new Intent(context, MainActivity.class);
|
||||||
mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startForegroundService(mainActivity);
|
context.startForegroundService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
if(this.mainHandler == null) {
|
if(this.mainHandler == null) {
|
||||||
this.mainHandler = new MainHandler();
|
this.mainHandler = new MainHandler();
|
||||||
}
|
}
|
||||||
|
intent.setAction(MediaService.Action.CONNECT.name());
|
||||||
intent.putExtra("mainHandler", this.mainHandler);
|
intent.putExtra("mainHandler", this.mainHandler);
|
||||||
intent.setAction("connect");
|
intent.setAction("connect");
|
||||||
this.startService(intent);
|
this.startService(intent);
|
||||||
|
|||||||
@@ -27,6 +27,20 @@ public class MediaService extends Service {
|
|||||||
System.loadLibrary("taoyao");
|
System.loadLibrary("taoyao");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动作类型
|
||||||
|
*
|
||||||
|
* @author acgist
|
||||||
|
*/
|
||||||
|
public enum Action {
|
||||||
|
|
||||||
|
// 连接
|
||||||
|
CONNECT,
|
||||||
|
// 重连
|
||||||
|
RECONNECT;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Taoyao taoyao;
|
private Taoyao taoyao;
|
||||||
private Handler mainHandler;
|
private Handler mainHandler;
|
||||||
|
|
||||||
@@ -45,7 +59,7 @@ public class MediaService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.i(MediaService.class.getSimpleName(), "onStartCommand");
|
Log.i(MediaService.class.getSimpleName(), "onStartCommand");
|
||||||
if("connect".equals(intent.getAction())) {
|
if(Action.CONNECT.name().equals(intent.getAction())) {
|
||||||
if(this.taoyao == null) {
|
if(this.taoyao == null) {
|
||||||
Log.d(MediaService.class.getSimpleName(), "打开信令连接");
|
Log.d(MediaService.class.getSimpleName(), "打开信令连接");
|
||||||
this.mainHandler = (Handler) intent.getSerializableExtra("mainHandler");
|
this.mainHandler = (Handler) intent.getSerializableExtra("mainHandler");
|
||||||
@@ -53,7 +67,7 @@ public class MediaService extends Service {
|
|||||||
} else {
|
} else {
|
||||||
Log.d(MediaService.class.getSimpleName(), "信令已经连接");
|
Log.d(MediaService.class.getSimpleName(), "信令已经连接");
|
||||||
}
|
}
|
||||||
} else if("reconnect".equals(intent.getAction())) {
|
} else if(Action.RECONNECT.name().equals(intent.getAction())) {
|
||||||
Log.d(MediaService.class.getSimpleName(), "重新连接信令");
|
Log.d(MediaService.class.getSimpleName(), "重新连接信令");
|
||||||
this.connect();
|
this.connect();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
editor.commit();
|
editor.commit();
|
||||||
// 重连
|
// 重连
|
||||||
final Intent intent = new Intent(this, MediaService.class);
|
final Intent intent = new Intent(this, MediaService.class);
|
||||||
intent.setAction("reconnect");
|
intent.setAction(MediaService.Action.RECONNECT.name());
|
||||||
this.startService(intent);
|
this.startService(intent);
|
||||||
// 返回预览页面
|
// 返回预览页面
|
||||||
this.startActivity(new Intent(this, MainActivity.class));
|
this.startActivity(new Intent(this, MainActivity.class));
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.acgist.taoyao.client.config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置
|
|
||||||
*
|
|
||||||
* @author acgist
|
|
||||||
*/
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.acgist.taoyao.client.media;
|
package com.acgist.taoyao.client.media;
|
||||||
|
|
||||||
public class ClientManager {
|
public class RoomClientManager {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.acgist.taoyao.client.p2p;
|
||||||
|
|
||||||
|
public class P2PClientManager {
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ import com.acgist.taoyao.boot.model.MessageCode;
|
|||||||
import com.acgist.taoyao.boot.model.MessageCodeException;
|
import com.acgist.taoyao.boot.model.MessageCodeException;
|
||||||
import com.acgist.taoyao.boot.utils.CloseableUtils;
|
import com.acgist.taoyao.boot.utils.CloseableUtils;
|
||||||
import com.acgist.taoyao.boot.utils.JSONUtils;
|
import com.acgist.taoyao.boot.utils.JSONUtils;
|
||||||
import com.acgist.media.ClientRecorder;
|
import com.acgist.taoyao.media.ClientRecorder;
|
||||||
import com.acgist.taoyao.client.utils.IdUtils;
|
import com.acgist.taoyao.client.utils.IdUtils;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
@@ -314,12 +314,10 @@ public final class Taoyao {
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(Taoyao.class.getSimpleName(), "接收信令异常", e);
|
Log.e(Taoyao.class.getSimpleName(), "接收信令异常", e);
|
||||||
if(this.socket.isClosed()) {
|
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param message 原始消息
|
* @param message 原始消息
|
||||||
@@ -416,8 +414,8 @@ public final class Taoyao {
|
|||||||
Log.d(Taoyao.class.getSimpleName(), "关闭信令:" + this.host + ":" + this.port);
|
Log.d(Taoyao.class.getSimpleName(), "关闭信令:" + this.host + ":" + this.port);
|
||||||
this.close = true;
|
this.close = true;
|
||||||
this.disconnect();
|
this.disconnect();
|
||||||
this.executor.shutdownNow();
|
this.executor.shutdown();
|
||||||
this.scheduled.shutdownNow();
|
this.scheduled.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.acgist.media;
|
package com.acgist.taoyao.media;
|
||||||
|
|
||||||
public class AudioPublisher {
|
public class AudioPublisher {
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.acgist.media;
|
package com.acgist.taoyao.media;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 录像机
|
* 录像机
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
package com.acgist.media;
|
package com.acgist.taoyao.media;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 房间终端
|
* 房间终端
|
||||||
|
* 使用NDK + Mediasoup实现多人会话
|
||||||
*
|
*
|
||||||
* @author acgist
|
* @author acgist
|
||||||
*/
|
*/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.acgist.media;
|
package com.acgist.taoyao.media;
|
||||||
|
|
||||||
public class VideoPublisher {
|
public class VideoPublisher {
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.acgist.taoyao.p2p;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* P2P终端
|
||||||
|
* 使用安卓SDK + WebRTC实现P2P会话
|
||||||
|
*
|
||||||
|
* @author acgist
|
||||||
|
*/
|
||||||
|
public class P2PClient {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user