video / audio source change

screen-share
Mustafa Yontar 4 years ago
parent 3c87a375c3
commit 332040e2b9
  1. 51
      src/App.vue
  2. 43
      src/lib/RemoteFeed.vue
  3. 42
      src/lib/VueJanus.vue
  4. 2
      src/plugins/janus.js

@ -1,44 +1,8 @@
<template> <template>
<v-app> <v-app>
<v-app-bar
app
color="primary"
dark
>
<div class="d-flex align-center">
<v-img
alt="Vuetify Logo"
class="shrink mr-2"
contain
src="https://cdn.vuetifyjs.com/images/logos/vuetify-logo-dark.png"
transition="scale-transition"
width="40"
/>
<v-img
alt="Vuetify Name"
class="shrink mt-1 hidden-sm-and-down"
contain
min-width="100"
src="https://cdn.vuetifyjs.com/images/logos/vuetify-name-dark.png"
width="100"
/>
</div>
<v-spacer></v-spacer>
<v-btn
href="https://github.com/vuetifyjs/vuetify/releases/latest"
target="_blank"
text
>
<span class="mr-2">Latest Release</span>
<v-icon>mdi-open-in-new</v-icon>
</v-btn>
</v-app-bar>
<v-content> <v-content>
<VueJanus server="https://vid.w3ic.org/janus" :room="room" username="vuettest"/> <v-text-field v-if="!start" v-model="username" label="please enter name"></v-text-field> <v-btn v-if="!start" @click="startM">Start</v-btn>
<VueJanus v-if="start" server="https://vid.w3ic.org/janus" :room="room" :username="username"/>
</v-content> </v-content>
</v-app> </v-app>
</template> </template>
@ -55,9 +19,18 @@ export default {
data: () => ({ data: () => ({
test: ' ', test: ' ',
room:1234 room:1234,
username: '',
start:false
}), }),
mounted () { mounted () {
},
methods: {
startM () {
if (this.username) {
this.start = true
}
}
} }
}; };
</script> </script>

@ -2,7 +2,15 @@
<div class="vid_main"> <div class="vid_main">
<video ref="feed_video" width="100%" height="100%" autoplay playsinline/> <video ref="feed_video" width="100%" height="100%" autoplay playsinline/>
<div class="info">{{ bitrate }}</div> <div class="info">{{ bitrate }}</div>
<div class="actions"></div> <div class="infoSlow">Slow Connection</div>
<div class="actions">
<v-slider
v-model="volume"
:min="0"
:max="100"
light
></v-slider>
</div>
</div> </div>
</template> </template>
@ -13,15 +21,23 @@
janusInit: Object, janusInit: Object,
opaqueId: String, opaqueId: String,
room: Number, room: Number,
mypvtid: String, mypvtid: Number,
feedid: String feedid: Number
}, },
name: "RemoteFeed", name: "RemoteFeed",
data: () => ({ data: () => ({
remoteFeed: null, remoteFeed: null,
bitrateTimer: null, bitrateTimer: null,
bitrate: 0 muted: false,
bitrate: 0,
volume: 100
}), }),
watch: {
volume (old, newVal) {
console.log(parseFloat(newVal) * 0.01)
this.$refs.feed_video.volume = parseFloat(newVal) * 0.01
}
},
mounted () { mounted () {
console.log(this.janusInit) console.log(this.janusInit)
this.janusInit.attach({ this.janusInit.attach({
@ -42,6 +58,10 @@
}) })
}, },
methods: { methods: {
mute () {
this.muted = !this.muted
this.$refs.feed_video.muted = this.muted
},
onSuccess (pluginHandle) { onSuccess (pluginHandle) {
this.remoteFeed = pluginHandle; this.remoteFeed = pluginHandle;
this.remoteFeed.simulcastStarted = false; this.remoteFeed.simulcastStarted = false;
@ -59,6 +79,7 @@
this.$refs.feed_video.srcObject = stream this.$refs.feed_video.srcObject = stream
setInterval(() => { setInterval(() => {
console.log(this.remoteFeed.getBitrate())
this.bitrate = this.remoteFeed.getBitrate() this.bitrate = this.remoteFeed.getBitrate()
},1000) },1000)
}, },
@ -72,6 +93,11 @@
onMessage (msg, jsep) { onMessage (msg, jsep) {
console.log(msg) console.log(msg)
console.log(jsep) console.log(jsep)
if (msg["janus"]) {
console.log("######################")
console.log("nn",msg)
}
console.log("-------------------------") console.log("-------------------------")
var event = msg["videoroom"]; var event = msg["videoroom"];
if(msg["error"] !== undefined && msg["error"] !== null) { if(msg["error"] !== undefined && msg["error"] !== null) {
@ -112,10 +138,19 @@
position: absolute; position: absolute;
bottom:0; bottom:0;
left:0; left:0;
color:#fff;
width:100%;
} }
.vid_main { .vid_main {
position: relative; position: relative;
} }
.infoSlow {
position: absolute;
right: 0;
bottom:0;
color:#fff;
display:none
}
.info { .info {
position: absolute; position: absolute;
right: 0; right: 0;

@ -1,5 +1,6 @@
<template> <template>
<v-container> <v-container>
<v-btn @click="deviceSelectDialog = true">change</v-btn>
<v-dialog <v-dialog
v-model="deviceSelectDialog" v-model="deviceSelectDialog"
max-width="290" max-width="290"
@ -17,6 +18,7 @@
item-value="deviceId" item-value="deviceId"
item-text="label" item-text="label"
></v-select> ></v-select>
<v-checkbox label="No Video" v-model="noVid"></v-checkbox>
</v-col> </v-col>
<v-col md="12" cols="12"> <v-col md="12" cols="12">
<v-select <v-select
@ -51,7 +53,6 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-btn @click="genRemoteFeed">Remote Feed</v-btn>
<v-row> <v-row>
<v-col cols="12" md="3"> <v-col cols="12" md="3">
<video ref="ownstream" class="rounded centered" id="myvideo" width="100%" height="100%" autoplay <video ref="ownstream" class="rounded centered" id="myvideo" width="100%" height="100%" autoplay
@ -65,8 +66,6 @@
</template> </template>
<script> <script>
import RemoteFeed from "@/lib/RemoteFeed"; import RemoteFeed from "@/lib/RemoteFeed";
export default { export default {
components: {RemoteFeed}, components: {RemoteFeed},
@ -85,9 +84,11 @@
mypvtid: '', mypvtid: '',
selectedVideo: null, selectedVideo: null,
selectedAudio: null, selectedAudio: null,
started: false,
videoDevices: [], videoDevices: [],
audioDevices: [], audioDevices: [],
deviceSelectDialog: false, deviceSelectDialog: false,
noVid: false,
remoteStreams: [] remoteStreams: []
} }
}, },
@ -159,11 +160,8 @@
}) })
}, },
janusMessage: function (msg, jsep) { janusMessage: function (msg, jsep) {
// this.$janus.debug(" ::: Got a message (publisher) :::");
console.log(msg); console.log(msg);
// this.$janus.debug(jsep);
var event = msg["videoroom"]; var event = msg["videoroom"];
// this.$janus.debug("Event: " + event);
if (event !== undefined) { if (event !== undefined) {
if (event === "joined") { if (event === "joined") {
this.myid = msg["id"]; this.myid = msg["id"];
@ -174,7 +172,6 @@
this.controlPublishers(msg) this.controlPublishers(msg)
} }
} else if(event === "event") { } else if(event === "event") {
// Any new feed to attach to?
if (msg["publishers"] !== undefined && msg["publishers"] !== null) { if (msg["publishers"] !== undefined && msg["publishers"] !== null) {
this.controlPublishers(msg) this.controlPublishers(msg)
@ -193,15 +190,11 @@
this.pluginHandle.handleRemoteJsep({jsep: jsep}); this.pluginHandle.handleRemoteJsep({jsep: jsep});
var audio = msg["audio_codec"]; var audio = msg["audio_codec"];
if (this.mystream && this.mystream.getAudioTracks() && this.mystream.getAudioTracks().length > 0 && !audio) { if (this.mystream && this.mystream.getAudioTracks() && this.mystream.getAudioTracks().length > 0 && !audio) {
// Audio has been rejected
//toastr.warning("Our audio stream has been rejected, viewers won't hear us");
console.log("Our audio stream has been rejected, viewers won't hear us"); console.log("Our audio stream has been rejected, viewers won't hear us");
} }
} }
}, },
onlocalstream: function (stream) { onlocalstream: function (stream) {
// this.$janus.debug(" ::: Got a local stream :::");
// this.$janus.debug(stream);
this.mystream = stream this.mystream = stream
console.log(this.$refs) console.log(this.$refs)
console.log(this.$refs["ownstream"]) console.log(this.$refs["ownstream"])
@ -212,7 +205,7 @@
this.deviceSelectDialog = false this.deviceSelectDialog = false
var media = { var media = {
audioRecv: false, videoRecv: false, audioSend: true, videoSend: true, audioRecv: false, videoRecv: false, audioSend: true, videoSend: !this.noVid,
audio: { audio: {
deviceId: { deviceId: {
exact: this.selectedAudio exact: this.selectedAudio
@ -244,14 +237,25 @@
mediaState: function (medium, on) { mediaState: function (medium, on) {
this.$janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium); this.$janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
}, },
changeDevice: function () {
this.$refs.ownstream.setSinkId(this.selectedVideo)
this.$refs.ownstream.setSinkId(this.selectedAudio)
},
selectDevice: function () { selectDevice: function () {
console.log(this.selectedVideo) if (!this.started) {
console.log(this.selectedAudio) console.log(this.selectedVideo)
// this.$refs.ownstream.setSinkId(this.selectedVideo) console.log(this.selectedAudio)
// this.$refs.ownstream.setSinkId(this.selectedAudio) this.started = true
var register = {
var register = {"request": "join", "room": this.room, "ptype": "publisher", "display": this.username}; "request": "join",
this.pluginHandle.send({"message": register}); "room": this.room,
"ptype": "publisher",
"display": this.username
};
this.pluginHandle.send({"message": register});
} else {
this.restartDevices()
}
}, },
janusSuccess: function () { janusSuccess: function () {
this.opaqueId = "videoroomtest-" + this.$janus.randomString(12); this.opaqueId = "videoroomtest-" + this.$janus.randomString(12);

@ -9,7 +9,7 @@ const JanusPlugin = {
install(Vue, options) { install(Vue, options) {
console.log('install call') console.log('install call')
console.log(_janus) console.log(_janus)
_janus.init({debug: true, callback: function() { _janus.init({debug: 'all', callback: function() {
Vue.prototype.$janus = _janus Vue.prototype.$janus = _janus
}}) }})
} }

Loading…
Cancel
Save