[*] 每日优化
配置没有改变不要重连信令 忽略房间重复邀请
This commit is contained in:
@@ -2,6 +2,7 @@ package com.acgist.taoyao.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.ColorStateList;
|
||||
@@ -18,6 +19,7 @@ import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
@@ -51,7 +53,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
Log.i(MainActivity.class.getSimpleName(), "onCreate");
|
||||
Log.d(MainActivity.class.getSimpleName(), "onCreate");
|
||||
super.onCreate(bundle);
|
||||
final Window window = this.getWindow();
|
||||
// 强制横屏
|
||||
@@ -76,19 +78,19 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Log.i(MainActivity.class.getSimpleName(), "onStart");
|
||||
Log.d(MainActivity.class.getSimpleName(), "onStart");
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Log.i(MainActivity.class.getSimpleName(), "onStop");
|
||||
Log.d(MainActivity.class.getSimpleName(), "onStop");
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Log.i(MainActivity.class.getSimpleName(), "onDestroy");
|
||||
Log.d(MainActivity.class.getSimpleName(), "onDestroy");
|
||||
super.onDestroy();
|
||||
// 资源释放
|
||||
}
|
||||
@@ -123,10 +125,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
Manifest.permission.RECEIVE_BOOT_COMPLETED,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
};
|
||||
if (Stream.of(permissions).map(this.getApplicationContext()::checkSelfPermission).allMatch(v -> v == PackageManager.PERMISSION_GRANTED)) {
|
||||
Log.i(MediaService.class.getSimpleName(), "授权成功");
|
||||
final Context context = this.getApplicationContext();
|
||||
if (Stream.of(permissions).map(context::checkSelfPermission).allMatch(v -> v == PackageManager.PERMISSION_GRANTED)) {
|
||||
Log.d(MediaService.class.getSimpleName(), "授权成功");
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(this, permissions, IdUtils.nextInt());
|
||||
Toast.makeText(context, "授权失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +162,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
Log.i(MediaManager.class.getSimpleName(), "屏幕捕获成功");
|
||||
Log.d(MediaManager.class.getSimpleName(), "屏幕捕获成功");
|
||||
final Intent intent = new Intent(this, MediaService.class);
|
||||
intent.setAction(MediaService.Action.SCREEN_CAPTURE.name());
|
||||
intent.putExtra("data", result.getData());
|
||||
@@ -290,6 +294,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
layoutParams.width = 0;
|
||||
layoutParams.height = 0;
|
||||
} else {
|
||||
// 复用布局
|
||||
layoutParams = this.removeLayoutParams.remove(0);
|
||||
}
|
||||
final SurfaceView surfaceView = (SurfaceView) message.obj;
|
||||
@@ -312,8 +317,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
return;
|
||||
}
|
||||
video.removeViewAt(index);
|
||||
// 缓存布局
|
||||
this.removeLayoutParams.add(surfaceView.getLayoutParams());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MediaService extends Service {
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.i(MediaService.class.getSimpleName(), "onCreate");
|
||||
Log.d(MediaService.class.getSimpleName(), "onCreate");
|
||||
Log.i(MediaService.class.getSimpleName(), """
|
||||
庭院深深深几许,杨柳堆烟,帘幕无重数。玉勒雕鞍游冶处,楼高不见章台路。
|
||||
雨横风狂三月暮,门掩黄昏,无计留春住。泪眼问花花不语,乱红飞过秋千去。
|
||||
@@ -97,13 +97,13 @@ public class MediaService extends Service {
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
Log.i(MediaService.class.getSimpleName(), "onBind");
|
||||
Log.d(MediaService.class.getSimpleName(), "onBind");
|
||||
return new Binder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.i(MediaService.class.getSimpleName(), "onStartCommand:" + intent.getAction());
|
||||
Log.d(MediaService.class.getSimpleName(), "onStartCommand:" + intent.getAction());
|
||||
if (Action.BOOT.name().equals(intent.getAction())) {
|
||||
this.boot();
|
||||
this.openConnect();
|
||||
@@ -122,7 +122,7 @@ public class MediaService extends Service {
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.i(MediaService.class.getSimpleName(), "onDestroy");
|
||||
Log.d(MediaService.class.getSimpleName(), "onDestroy");
|
||||
super.onDestroy();
|
||||
this.close();
|
||||
}
|
||||
@@ -155,11 +155,11 @@ public class MediaService extends Service {
|
||||
resources.getInteger(R.integer.imageQuantity),
|
||||
resources.getString(R.string.audioQuantity),
|
||||
resources.getString(R.string.videoQuantity),
|
||||
resources.getBoolean(R.bool.broadcaster),
|
||||
resources.getInteger(R.integer.channelCount),
|
||||
resources.getInteger(R.integer.iFrameInterval),
|
||||
resources.getString(R.string.storagePathImage),
|
||||
resources.getString(R.string.storagePathVideo),
|
||||
resources.getBoolean(R.bool.broadcaster),
|
||||
resources.getString(R.string.watermark),
|
||||
VideoSourceType.valueOf(resources.getString(R.string.videoSourceType))
|
||||
);
|
||||
@@ -199,13 +199,20 @@ public class MediaService extends Service {
|
||||
final String password = sharedPreferences.getString("settings.password", "taoyao");
|
||||
final Context context = this.getApplicationContext();
|
||||
final Resources resources = this.getResources();
|
||||
this.close();
|
||||
if(this.taoyao != null) {
|
||||
if(this.taoyao.needReconnect(port, host, name, clientId, username, password)) {
|
||||
this.close();
|
||||
} else {
|
||||
Log.d(MediaService.class.getSimpleName(), "配置没有改变忽略重连");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 连接信令
|
||||
this.taoyao = new Taoyao(
|
||||
port, host, resources.getString(R.string.version),
|
||||
name, clientId, resources.getString(R.string.clientType), username, password,
|
||||
resources.getString(R.string.version), resources.getString(R.string.clientType),
|
||||
port, host, name, clientId, username, password,
|
||||
resources.getInteger(R.integer.timeout), resources.getString(R.string.encrypt), resources.getString(R.string.encryptSecret),
|
||||
this.mainHandler, context, this.taoyaoListener
|
||||
MediaService.mainHandler, context, this.taoyaoListener
|
||||
);
|
||||
MediaManager.getInstance().initTaoyao(this.taoyao);
|
||||
Toast.makeText(context, "连接信令", Toast.LENGTH_SHORT).show();
|
||||
@@ -268,11 +275,11 @@ public class MediaService extends Service {
|
||||
*/
|
||||
private void settingAudio() {
|
||||
final AudioManager audioManager = this.getApplicationContext().getSystemService(AudioManager.class);
|
||||
Log.i(MediaService.class.getSimpleName(), "当前音频模式:" + audioManager.getMode());
|
||||
Log.i(MediaService.class.getSimpleName(), "当前音频音量:" + audioManager.getStreamVolume(audioManager.getMode()));
|
||||
// Log.i(MediaService.class.getSimpleName(), "当前蓝牙是否打开:" + audioManager.isBluetoothScoOn());
|
||||
// Log.i(MediaService.class.getSimpleName(), "当前耳机是否打开:" + audioManager.isWiredHeadsetOn());
|
||||
// Log.i(MediaService.class.getSimpleName(), "当前电话扬声器是否打开:" + audioManager.isSpeakerphoneOn());
|
||||
Log.d(MediaService.class.getSimpleName(), "当前音频模式:" + audioManager.getMode());
|
||||
Log.d(MediaService.class.getSimpleName(), "当前音频音量:" + audioManager.getStreamVolume(audioManager.getMode()));
|
||||
// Log.d(MediaService.class.getSimpleName(), "当前蓝牙是否打开:" + audioManager.isBluetoothScoOn());
|
||||
// Log.d(MediaService.class.getSimpleName(), "当前耳机是否打开:" + audioManager.isWiredHeadsetOn());
|
||||
// Log.d(MediaService.class.getSimpleName(), "当前电话扬声器是否打开:" + audioManager.isSpeakerphoneOn());
|
||||
// audioManager.setStreamVolume(AudioManager.MODE_IN_COMMUNICATION, audioManager.getStreamMaxVolume(AudioManager.MODE_IN_COMMUNICATION), AudioManager.FLAG_PLAY_SOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@@ -22,18 +23,18 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.i(SettingsActivity.class.getSimpleName(), "onCreate");
|
||||
Log.d(SettingsActivity.class.getSimpleName(), "onCreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
// 布局
|
||||
this.binding = ActivitySettingsBinding.inflate(this.getLayoutInflater());
|
||||
this.setContentView(this.binding.getRoot());
|
||||
// 设置按钮
|
||||
final View root = this.binding.getRoot();
|
||||
root.setZ(100F);
|
||||
this.setContentView(root);
|
||||
this.binding.connect.setOnClickListener(this::settingsPersistent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
Log.i(SettingsActivity.class.getSimpleName(), "onStart");
|
||||
Log.d(SettingsActivity.class.getSimpleName(), "onStart");
|
||||
super.onStart();
|
||||
// 回填配置
|
||||
final SharedPreferences sharedPreferences = this.getSharedPreferences("settings", Context.MODE_PRIVATE);
|
||||
@@ -47,18 +48,18 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
Log.i(SettingsActivity.class.getSimpleName(), "onStop");
|
||||
Log.d(SettingsActivity.class.getSimpleName(), "onStop");
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
Log.i(SettingsActivity.class.getSimpleName(), "onDestroy");
|
||||
Log.d(SettingsActivity.class.getSimpleName(), "onDestroy");
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 持久化日志
|
||||
* 保存配置
|
||||
*
|
||||
* @param view View
|
||||
*/
|
||||
@@ -86,16 +87,19 @@ public class SettingsActivity extends AppCompatActivity {
|
||||
editor.putString("settings.clientId", clientId);
|
||||
editor.putString("settings.username", username);
|
||||
editor.putString("settings.password", password);
|
||||
editor.commit();
|
||||
// 重连信令
|
||||
final Intent serviceIntent = new Intent(this, MediaService.class);
|
||||
serviceIntent.setAction(MediaService.Action.RECONNECT.name());
|
||||
this.startService(serviceIntent);
|
||||
// 预览页面
|
||||
final Intent activityIntent = new Intent(this, MainActivity.class);
|
||||
this.startActivity(activityIntent);
|
||||
// 结束
|
||||
this.finish();
|
||||
if(editor.commit()) {
|
||||
// 重连信令
|
||||
final Intent serviceIntent = new Intent(this, MediaService.class);
|
||||
serviceIntent.setAction(MediaService.Action.RECONNECT.name());
|
||||
this.startService(serviceIntent);
|
||||
// 预览页面
|
||||
final Intent activityIntent = new Intent(this, MainActivity.class);
|
||||
this.startActivity(activityIntent);
|
||||
// 结束
|
||||
this.finish();
|
||||
} else {
|
||||
Toast.makeText(this.getApplicationContext(), "配置保存失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* 开机启动
|
||||
* 开机广播
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ public class TaoyaoReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i(TaoyaoReceiver.class.getSimpleName(), "onReceive:" + intent.getAction());
|
||||
Log.d(TaoyaoReceiver.class.getSimpleName(), "onReceive:" + intent.getAction());
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
||||
this.bootTaoyao(context);
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,10 +8,10 @@
|
||||
<bool name="playVideo">true</bool>
|
||||
<!-- 信令版本 -->
|
||||
<string name="version">1.0.0</string>
|
||||
<!-- 超时时间 -->
|
||||
<integer name="timeout">5000</integer>
|
||||
<!-- 终端类型:CAMERA|MOBILE -->
|
||||
<string name="clientType">MOBILE</string>
|
||||
<!-- 超时时间 -->
|
||||
<integer name="timeout">5000</integer>
|
||||
<!-- 信令加密策略:AES|DES -->
|
||||
<string name="encrypt">DES</string>
|
||||
<!-- 信令加密密钥 -->
|
||||
@@ -34,14 +34,14 @@
|
||||
<bool name="audioProduce">true</bool>
|
||||
<!-- 媒体配置:是否生产视频 -->
|
||||
<bool name="videoProduce">true</bool>
|
||||
<!-- 语音播报 -->
|
||||
<bool name="broadcaster">false</bool>
|
||||
<!-- 图片质量 -->
|
||||
<integer name="imageQuantity">100</integer>
|
||||
<!-- 音频质量 -->
|
||||
<string name="audioQuantity">fd-audio</string>
|
||||
<!-- 视频质量 -->
|
||||
<string name="videoQuantity">fd-video</string>
|
||||
<!-- 语音播报 -->
|
||||
<bool name="broadcaster">false</bool>
|
||||
<!-- 音频通道数量 -->
|
||||
<integer name="channelCount">1</integer>
|
||||
<!-- 视频关键帧频率 -->
|
||||
|
||||
@@ -47,11 +47,9 @@ import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 媒体来源管理器
|
||||
* 媒体管理器
|
||||
*
|
||||
* @author acgist
|
||||
*
|
||||
* TODO:动态码率(BITRATE_MODE_VBR、BITRATE_MODE)
|
||||
*/
|
||||
public final class MediaManager {
|
||||
|
||||
@@ -85,6 +83,10 @@ public final class MediaManager {
|
||||
* 视频质量
|
||||
*/
|
||||
private String videoQuantity;
|
||||
/**
|
||||
* 语音播报
|
||||
*/
|
||||
private boolean broadcaster;
|
||||
/**
|
||||
* 通道数量
|
||||
*/
|
||||
@@ -161,14 +163,14 @@ public final class MediaManager {
|
||||
* JavaAudioDeviceModule
|
||||
*/
|
||||
private JavaAudioDeviceModule javaAudioDeviceModule;
|
||||
/**
|
||||
* 语音播报
|
||||
*/
|
||||
private TextToSpeech textToSpeech;
|
||||
/**
|
||||
* 视频处理
|
||||
*/
|
||||
private VideoProcesser videoProcesser;
|
||||
/**
|
||||
* TTS
|
||||
*/
|
||||
private TextToSpeech textToSpeech;
|
||||
/**
|
||||
* 录屏等待锁
|
||||
*/
|
||||
@@ -241,34 +243,35 @@ public final class MediaManager {
|
||||
* @param imageQuantity 图片质量
|
||||
* @param audioQuantity 音频质量
|
||||
* @param videoQuantity 视频质量
|
||||
* @param broadcaster 是否语音播报
|
||||
* @param channelCount 音频通道数量
|
||||
* @param iFrameInterval 关键帧频率
|
||||
* @param imagePath 图片保存路径
|
||||
* @param videoPath 视频保存路径
|
||||
* @param tts 是否加载TTS
|
||||
* @param watermark 水印信息
|
||||
* @param videoSourceType 视频来源类型
|
||||
*/
|
||||
public void initContext(
|
||||
Handler mainHandler, Context context,
|
||||
int imageQuantity, String audioQuantity, String videoQuantity,
|
||||
int channelCount, int iFrameInterval,
|
||||
String imagePath, String videoPath, boolean tts,
|
||||
boolean broadcaster, int channelCount, int iFrameInterval,
|
||||
String imagePath, String videoPath,
|
||||
String watermark, VideoSourceType videoSourceType
|
||||
) {
|
||||
this.mainHandler = mainHandler;
|
||||
this.context = context;
|
||||
this.imageQuantity = imageQuantity;
|
||||
this.audioQuantity = audioQuantity;
|
||||
this.videoQuantity = videoQuantity;
|
||||
this.channelCount = channelCount;
|
||||
this.iFrameInterval = iFrameInterval;
|
||||
this.imagePath = imagePath;
|
||||
this.videoPath = videoPath;
|
||||
this.watermark = watermark;
|
||||
this.mainHandler = mainHandler;
|
||||
this.context = context;
|
||||
this.imageQuantity = imageQuantity;
|
||||
this.audioQuantity = audioQuantity;
|
||||
this.videoQuantity = videoQuantity;
|
||||
this.broadcaster = broadcaster;
|
||||
this.channelCount = channelCount;
|
||||
this.iFrameInterval = iFrameInterval;
|
||||
this.imagePath = imagePath;
|
||||
this.videoPath = videoPath;
|
||||
this.watermark = watermark;
|
||||
this.videoSourceType = videoSourceType;
|
||||
if(tts) {
|
||||
this.initTTS(context);
|
||||
synchronized (this) {
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,29 +280,21 @@ public final class MediaManager {
|
||||
*/
|
||||
public void initTaoyao(ITaoyao taoyao) {
|
||||
this.taoyao = taoyao;
|
||||
synchronized (this) {
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void initTTS(Context context) {
|
||||
if(this.textToSpeech != null) {
|
||||
public synchronized void broadcast(String text) {
|
||||
if(!this.broadcaster) {
|
||||
return;
|
||||
}
|
||||
Log.i(MediaManager.class.getSimpleName(), "加载TTS");
|
||||
this.textToSpeech = new TextToSpeech(context, new MediaManager.TextToSpeechInitListener());
|
||||
}
|
||||
|
||||
public void broadcast(String text) {
|
||||
if(this.textToSpeech == null) {
|
||||
return;
|
||||
this.textToSpeech = new TextToSpeech(this.context, new MediaManager.TextToSpeechInitListener());
|
||||
}
|
||||
// this.textToSpeech.stop();
|
||||
this.textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null, UUID.randomUUID().toString());
|
||||
}
|
||||
|
||||
public void closeTTS() {
|
||||
if(this.textToSpeech == null) {
|
||||
return;
|
||||
}
|
||||
this.textToSpeech.shutdown();
|
||||
// this.textToSpeech.stop();
|
||||
// this.textToSpeech.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -775,14 +770,16 @@ public final class MediaManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void stopRecord() {
|
||||
public String stopRecord() {
|
||||
synchronized (this) {
|
||||
if(this.recordClient == null) {
|
||||
return;
|
||||
return null;
|
||||
} else {
|
||||
final String filepath = this.recordClient.getFilepath();
|
||||
this.recordClient.close();
|
||||
this.recordClient = null;
|
||||
this.mainHandler.obtainMessage(Config.WHAT_RECORD, Boolean.FALSE).sendToTarget();
|
||||
return filepath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -960,7 +957,7 @@ public final class MediaManager {
|
||||
private class TextToSpeechInitListener implements TextToSpeech.OnInitListener {
|
||||
@Override
|
||||
public void onInit(int status) {
|
||||
Log.i(MediaManager.class.getSimpleName(), "加载TTS:" + status);
|
||||
Log.i(MediaManager.class.getSimpleName(), "加载语音播报:" + status);
|
||||
if(status == TextToSpeech.SUCCESS) {
|
||||
MediaManager.this.textToSpeech.setLanguage(Locale.CANADA);
|
||||
MediaManager.this.textToSpeech.setPitch(1.0F);
|
||||
|
||||
@@ -183,8 +183,10 @@ public class RecordClient extends Client implements VideoSink {
|
||||
audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, this.audioBitRate);
|
||||
// audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, AudioFormat.ENCODING_PCM_16BIT);
|
||||
audioFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC);
|
||||
// 动态码率
|
||||
// audioFormat.setInteger(MediaFormat.KEY_BITRATE_MODE, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR);
|
||||
// audioFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 1024 * 8 * 8); // 设置缓冲大小
|
||||
// 设置缓冲大小
|
||||
// audioFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 1024 * 8 * 8);
|
||||
this.audioCodec = MediaCodec.createEncoderByType(audioType);
|
||||
this.audioCodec.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -46,6 +46,7 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
private final boolean dataProduce;
|
||||
private final boolean audioProduce;
|
||||
private final boolean videoProduce;
|
||||
private boolean produce;
|
||||
private final MediaProperties mediaProperties;
|
||||
private final WebrtcProperties webrtcProperties;
|
||||
private final Map<String, RemoteClient> remoteClients;
|
||||
@@ -57,8 +58,8 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
private Object sctpCapabilities;
|
||||
|
||||
/**
|
||||
* @param name 房间名称
|
||||
* @param roomId 房间ID
|
||||
* @param name 终端名称
|
||||
* @param clientId 当前终端ID
|
||||
* @param password 房间密码
|
||||
* @param taoyao 信令
|
||||
@@ -76,17 +77,17 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
* @param webrtcProperties WebRTC配置
|
||||
*/
|
||||
public Room(
|
||||
String name, String roomId,
|
||||
String roomId, String name,
|
||||
String clientId, String password,
|
||||
ITaoyao taoyao, Handler mainHandler,
|
||||
boolean preview, boolean playAudio, boolean playVideo,
|
||||
boolean preview, boolean playAudio, boolean playVideo,
|
||||
boolean dataConsume, boolean audioConsume, boolean videoConsume,
|
||||
boolean dataProduce, boolean audioProduce, boolean videoProduce,
|
||||
MediaProperties mediaProperties, WebrtcProperties webrtcProperties
|
||||
) {
|
||||
super(taoyao, mainHandler);
|
||||
this.name = name;
|
||||
this.roomId = roomId;
|
||||
this.name = name;
|
||||
this.clientId = clientId;
|
||||
this.password = password;
|
||||
this.preview = preview;
|
||||
@@ -98,9 +99,10 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
this.dataProduce = dataProduce;
|
||||
this.audioProduce = audioProduce;
|
||||
this.videoProduce = videoProduce;
|
||||
this.mediaProperties = mediaProperties;
|
||||
this.produce = false;
|
||||
this.mediaProperties = mediaProperties;
|
||||
this.webrtcProperties = webrtcProperties;
|
||||
this.remoteClients = new ConcurrentHashMap<>();
|
||||
this.remoteClients = new ConcurrentHashMap<>();
|
||||
this.nativeRoomPointer = this.nativeNewRoom(roomId, this);
|
||||
}
|
||||
|
||||
@@ -109,6 +111,7 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
if (this.init) {
|
||||
return true;
|
||||
}
|
||||
Log.i(Room.class.getSimpleName(), "进入房间:" + this.roomId);
|
||||
super.init();
|
||||
this.peerConnectionFactory = this.mediaManager.newClient();
|
||||
this.localClient = new LocalClient(this.name, this.clientId, this.taoyao, this.mainHandler);
|
||||
@@ -141,6 +144,10 @@ public class Room extends CloseableClient implements RouterCallback {
|
||||
}
|
||||
|
||||
public void mediaProduce() {
|
||||
if(this.produce) {
|
||||
return;
|
||||
}
|
||||
this.produce = true;
|
||||
if (this.audioProduce || this.videoProduce) {
|
||||
this.createSendTransport();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user