[*] 复用factory
This commit is contained in:
@@ -373,23 +373,31 @@ nginx -s reload
|
|||||||
## 安装Android终端
|
## 安装Android终端
|
||||||
|
|
||||||
```
|
```
|
||||||
# Android Studio
|
cd /data/taoyao/taoyao-client-android/taoyao
|
||||||
|
|
||||||
|
# Mac | Linux
|
||||||
|
sh ./gradlew --no-daemon assembleRelease
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
./gradlew.bat --no-daemon assembleRelease
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置防火墙
|
## 配置防火墙
|
||||||
|
|
||||||
```
|
```
|
||||||
# 终端服务:建议使用Nginx代理
|
# Nginx端口
|
||||||
firewall-cmd --zone=public --add-port=443/tcp --permanent
|
firewall-cmd --zone=public --add-port=443/tcp --permanent
|
||||||
|
# 终端服务:建议使用Nginx代理
|
||||||
firewall-cmd --zone=public --add-port=8443/tcp --permanent
|
firewall-cmd --zone=public --add-port=8443/tcp --permanent
|
||||||
# 信令服务(WebSocket)
|
# 信令服务(WebSocket)
|
||||||
firewall-cmd --zone=public --add-port=8888/tcp --permanent
|
firewall-cmd --zone=public --add-port=8888/tcp --permanent
|
||||||
# 信令服务(Socket):没有启用不用添加规则
|
# 信令服务(Socket):没有启用不用添加规则
|
||||||
firewall-cmd --zone=public --add-port=9999/tcp --permanent
|
firewall-cmd --zone=public --add-port=9999/tcp --permanent
|
||||||
# 媒体服务(数据)
|
# 媒体服务
|
||||||
firewall-cmd --zone=public --add-port=40000-49999/udp --permanent
|
firewall-cmd --zone=public --add-port=40000-49999/udp --permanent
|
||||||
|
|
||||||
firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
|
firewall-cmd --list-all
|
||||||
firewall-cmd --list-ports
|
firewall-cmd --list-ports
|
||||||
|
|
||||||
# 删除端口
|
# 删除端口
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class MainActivity extends AppCompatActivity implements Serializable {
|
|||||||
}
|
}
|
||||||
this.threadHandler.post(() -> {
|
this.threadHandler.post(() -> {
|
||||||
// 进入房间
|
// 进入房间
|
||||||
Taoyao.taoyao.roomEnter("1e6707a5-6846-405e-95de-632aa01569aa", null);
|
Taoyao.taoyao.roomEnter("91f81c0a-0556-4087-b9a4-5889fac36fb6", null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,8 +244,8 @@ public class MainActivity extends AppCompatActivity implements Serializable {
|
|||||||
private void previewVideo(Message message) {
|
private void previewVideo(Message message) {
|
||||||
final GridLayout video = this.binding.video;
|
final GridLayout video = this.binding.video;
|
||||||
final int count = video.getChildCount();
|
final int count = video.getChildCount();
|
||||||
final GridLayout.Spec rowSpec = GridLayout.spec(count / 2, 1, 0);
|
final GridLayout.Spec rowSpec = GridLayout.spec(count / 2, 1.0F);
|
||||||
final GridLayout.Spec columnSpec = GridLayout.spec(count % 2, 1, 0);
|
final GridLayout.Spec columnSpec = GridLayout.spec(count % 2, 1.0F);
|
||||||
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(rowSpec, columnSpec);
|
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(rowSpec, columnSpec);
|
||||||
layoutParams.width = 0;
|
layoutParams.width = 0;
|
||||||
layoutParams.height = 0;
|
layoutParams.height = 0;
|
||||||
|
|||||||
@@ -11,8 +11,9 @@
|
|||||||
android:id="@+id/video"
|
android:id="@+id/video"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:columnCount="2"
|
android:columnCount="2">
|
||||||
android:rowCount="2" />
|
|
||||||
|
</GridLayout>
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
android:id="@+id/settings"
|
android:id="@+id/settings"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace acgist {
|
|||||||
class Room : public RouterCallback {
|
class Room : public RouterCallback {
|
||||||
public:
|
public:
|
||||||
std::string roomId;
|
std::string roomId;
|
||||||
|
webrtc::PeerConnectionFactoryInterface* factory;
|
||||||
mediasoupclient::Device* device;
|
mediasoupclient::Device* device;
|
||||||
mediasoupclient::PeerConnection* peerConnection;
|
mediasoupclient::PeerConnection* peerConnection;
|
||||||
mediasoupclient::SendTransport* sendTransport;
|
mediasoupclient::SendTransport* sendTransport;
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ namespace acgist {
|
|||||||
webrtc::PeerConnectionFactoryInterface* factory,
|
webrtc::PeerConnectionFactoryInterface* factory,
|
||||||
webrtc::PeerConnectionInterface::RTCConfiguration& rtcConfiguration
|
webrtc::PeerConnectionInterface::RTCConfiguration& rtcConfiguration
|
||||||
) {
|
) {
|
||||||
|
this->factory = factory;
|
||||||
nlohmann::json json;
|
nlohmann::json json;
|
||||||
// TODO:全局
|
// TODO:全局
|
||||||
mediasoupclient::PeerConnection::Options options;
|
mediasoupclient::PeerConnection::Options options;
|
||||||
@@ -174,26 +175,32 @@ namespace acgist {
|
|||||||
|
|
||||||
void Room::createSendTransport(JNIEnv* env, std::string body) {
|
void Room::createSendTransport(JNIEnv* env, std::string body) {
|
||||||
nlohmann::json json = nlohmann::json::parse(body);
|
nlohmann::json json = nlohmann::json::parse(body);
|
||||||
|
mediasoupclient::PeerConnection::Options options;
|
||||||
|
options.factory = this->factory;
|
||||||
this->sendTransport = this->device->CreateSendTransport(
|
this->sendTransport = this->device->CreateSendTransport(
|
||||||
this->sendListener,
|
this->sendListener,
|
||||||
json["transportId"],
|
json["transportId"],
|
||||||
json["iceCandidates"],
|
|
||||||
json["iceParameters"],
|
json["iceParameters"],
|
||||||
|
json["iceCandidates"],
|
||||||
json["dtlsParameters"],
|
json["dtlsParameters"],
|
||||||
json["sctpParameters"]
|
json["sctpParameters"],
|
||||||
|
&options
|
||||||
// TODO:全局options
|
// TODO:全局options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::createRecvTransport(JNIEnv* env, std::string body) {
|
void Room::createRecvTransport(JNIEnv* env, std::string body) {
|
||||||
nlohmann::json json = nlohmann::json::parse(body);
|
nlohmann::json json = nlohmann::json::parse(body);
|
||||||
|
mediasoupclient::PeerConnection::Options options;
|
||||||
|
options.factory = this->factory;
|
||||||
this->recvTransport = this->device->CreateRecvTransport(
|
this->recvTransport = this->device->CreateRecvTransport(
|
||||||
this->recvListener,
|
this->recvListener,
|
||||||
json["transportId"],
|
json["transportId"],
|
||||||
json["iceCandidates"],
|
|
||||||
json["iceParameters"],
|
json["iceParameters"],
|
||||||
|
json["iceCandidates"],
|
||||||
json["dtlsParameters"],
|
json["dtlsParameters"],
|
||||||
json["sctpParameters"]
|
json["sctpParameters"],
|
||||||
|
&options
|
||||||
// TODO:全局options
|
// TODO:全局options
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.acgist.taoyao.media;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioRecord;
|
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaCodecList;
|
import android.media.MediaCodecList;
|
||||||
import android.media.projection.MediaProjection;
|
import android.media.projection.MediaProjection;
|
||||||
@@ -42,9 +41,6 @@ import org.webrtc.VideoFrame;
|
|||||||
import org.webrtc.VideoSource;
|
import org.webrtc.VideoSource;
|
||||||
import org.webrtc.VideoTrack;
|
import org.webrtc.VideoTrack;
|
||||||
import org.webrtc.audio.JavaAudioDeviceModule;
|
import org.webrtc.audio.JavaAudioDeviceModule;
|
||||||
import org.webrtc.voiceengine.WebRtcAudioManager;
|
|
||||||
import org.webrtc.voiceengine.WebRtcAudioRecord;
|
|
||||||
import org.webrtc.voiceengine.WebRtcAudioUtils;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.acgist.taoyao.media.audio;
|
||||||
|
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioManager;
|
||||||
|
import org.webrtc.voiceengine.WebRtcAudioRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 混音
|
||||||
|
*
|
||||||
|
* WebRtcAudioTrack#AudioTrackThread :远程音频
|
||||||
|
* WebRtcAudioRecord#AudioRecordThread:本地音频
|
||||||
|
*
|
||||||
|
* @author acgist
|
||||||
|
*/
|
||||||
|
public class AudioMixer {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.acgist.taoyao.media.client;
|
package com.acgist.taoyao.media.client;
|
||||||
|
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
|
import android.media.AudioManager;
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
import android.media.MediaCodecInfo;
|
import android.media.MediaCodecInfo;
|
||||||
import android.media.MediaFormat;
|
import android.media.MediaFormat;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class Room extends CloseableClient implements RouterCallback {
|
|||||||
"producing", true,
|
"producing", true,
|
||||||
"consuming", false,
|
"consuming", false,
|
||||||
"sctpCapabilities", this.dataProduce ? this.sctpCapabilities : null
|
"sctpCapabilities", this.dataProduce ? this.sctpCapabilities : null
|
||||||
));
|
));
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
Log.w(Room.class.getSimpleName(), "创建发送通道失败");
|
Log.w(Room.class.getSimpleName(), "创建发送通道失败");
|
||||||
return;
|
return;
|
||||||
@@ -164,6 +164,7 @@ public class Room extends CloseableClient implements RouterCallback {
|
|||||||
private void createRecvTransport() {
|
private void createRecvTransport() {
|
||||||
final Message response = this.taoyao.request(this.taoyao.buildMessage(
|
final Message response = this.taoyao.request(this.taoyao.buildMessage(
|
||||||
"media::transport::webrtc::create",
|
"media::transport::webrtc::create",
|
||||||
|
"roomId", this.roomId,
|
||||||
"forceTcp", false,
|
"forceTcp", false,
|
||||||
"producing", false,
|
"producing", false,
|
||||||
"consuming", true,
|
"consuming", true,
|
||||||
|
|||||||
@@ -30,6 +30,6 @@ public class Config {
|
|||||||
/**
|
/**
|
||||||
* 默认声音大小
|
* 默认声音大小
|
||||||
*/
|
*/
|
||||||
public static final double DEFAULT_VOLUME = 100.0D;
|
public static final double DEFAULT_VOLUME = 10.0D;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1603,6 +1603,7 @@ class Taoyao extends RemoteClient {
|
|||||||
/**
|
/**
|
||||||
* 解决浏览器的自动播放策略问题
|
* 解决浏览器的自动播放策略问题
|
||||||
*/
|
*/
|
||||||
|
// TODO:完全关闭以后释放资源
|
||||||
{
|
{
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||||
stream.getAudioTracks().forEach((audioTrack) => {
|
stream.getAudioTracks().forEach((audioTrack) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user