This commit is contained in:
acgist
2022-12-03 17:37:06 +08:00
parent 7f5ee58fbb
commit 2908faf9df
3 changed files with 13 additions and 6 deletions

View File

@@ -65,7 +65,7 @@ public class MeetingManager {
*/ */
public Meeting create(String sn) { public Meeting create(String sn) {
final Meeting meeting = new Meeting(); final Meeting meeting = new Meeting();
meeting.setId("1"); meeting.setId(this.idService.buildIdToString());
meeting.setSns(new CopyOnWriteArrayList<>()); meeting.setSns(new CopyOnWriteArrayList<>());
meeting.setCreator(sn); meeting.setCreator(sn);
meeting.addSn(sn); meeting.addSn(sn);

View File

@@ -491,6 +491,7 @@ function TaoyaoClient(
return this; return this;
}; };
/** 设置媒体 */ /** 设置媒体 */
// TODOstream判断
this.buildStream = async function(videoId, stream, track) { this.buildStream = async function(videoId, stream, track) {
if(!this.video && videoId) { if(!this.video && videoId) {
this.video = document.getElementById(videoId); this.video = document.getElementById(videoId);
@@ -534,6 +535,7 @@ function TaoyaoClient(
this.buildAudioTrack = function(track) { this.buildAudioTrack = function(track) {
// 关闭旧的 // 关闭旧的
// 创建新的 // 创建新的
track.sn = this.sn;
this.audioStatus = true; this.audioStatus = true;
this.audioTrack.push(track); this.audioTrack.push(track);
if(this.audioEnabled) { if(this.audioEnabled) {
@@ -544,6 +546,7 @@ function TaoyaoClient(
this.buildVideoTrack = function(track) { this.buildVideoTrack = function(track) {
// 关闭旧的 // 关闭旧的
// 创建新的 // 创建新的
track.sn = this.sn;
this.videoStatus = true; this.videoStatus = true;
this.videoTrack.push(track); this.videoTrack.push(track);
if(this.videoEnabled) { if(this.videoEnabled) {
@@ -564,6 +567,7 @@ function TaoyaoClient(
mediaChannel.ontrack = function(e) { mediaChannel.ontrack = function(e) {
console.debug('Mesh Media Track', self.sn, e); console.debug('Mesh Media Track', self.sn, e);
let remote = self.taoyao.remoteClientFilter(self.sn); let remote = self.taoyao.remoteClientFilter(self.sn);
// TODO判断数量
remote.buildStream(remote.sn, e.streams[0], e.track); remote.buildStream(remote.sn, e.streams[0], e.track);
}; };
mediaChannel.onicecandidate = function(e) { mediaChannel.onicecandidate = function(e) {
@@ -761,9 +765,9 @@ function Taoyao(
// 远程通道 // 远程通道
this.remoteMediaChannel = new RTCPeerConnection(defaultRPCConfig); this.remoteMediaChannel = new RTCPeerConnection(defaultRPCConfig);
this.remoteMediaChannel.ontrack = function(e) { this.remoteMediaChannel.ontrack = function(e) {
console.debug('Remote Media Track', e); console.debug('Remote Media Track', e.track.sn, e);
// TODO匹配 let remote = self.taoyao.remoteClientFilter(e.track.sn);
let remote = self.remoteClient[0]; // TODO判断数量
remote.buildStream(remote.sn, e.streams[0], e.track); remote.buildStream(remote.sn, e.streams[0], e.track);
}; };
this.remoteMediaChannel.onicecandidate = function(e) { this.remoteMediaChannel.onicecandidate = function(e) {

View File

@@ -50,6 +50,10 @@
meetingId: null meetingId: null
}, },
mounted() { mounted() {
// 设置帐号
let sn = prompt('你的账号', signalConfig.sn);
signalConfig.sn = sn;
// 加载桃夭
let self = this; let self = this;
this.taoyao = new Taoyao('local'); this.taoyao = new Taoyao('local');
this.remoteClient = this.taoyao.remoteClient; this.remoteClient = this.taoyao.remoteClient;
@@ -70,8 +74,6 @@
}, },
// 创建会议 // 创建会议
create: function(event) { create: function(event) {
let sn = prompt('你的账号', signalConfig.sn);
signalConfig.sn = sn;
let self = this; let self = this;
this.taoyao.meetingCreate(data => { this.taoyao.meetingCreate(data => {
self.taoyao.meetingEnter(data.body.id); self.taoyao.meetingEnter(data.body.id);
@@ -84,6 +86,7 @@
// 进入会议 // 进入会议
enter: function(sn) { enter: function(sn) {
let id = prompt('房间标识'); let id = prompt('房间标识');
let password = prompt('房间密码');
if(id) { if(id) {
this.taoyao.meetingEnter(id); this.taoyao.meetingEnter(id);
} }