mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
add bitrate switcher. (#15)
This commit is contained in:
parent
ba931ea52e
commit
b27b8e028d
@ -164,12 +164,16 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
this._reconnector.webrtc.config = this._state.webrtc.config
|
this._reconnector.webrtc.config = this._state.webrtc.config
|
||||||
}
|
}
|
||||||
|
|
||||||
public setVideo(video: string) {
|
public setVideo(video: string, bitrate: number = 0) {
|
||||||
if (!this._state.webrtc.videos.includes(video)) {
|
if (video != '' && !this._state.webrtc.videos.includes(video)) {
|
||||||
throw new Error('video id not found')
|
throw new Error('video id not found')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.websocket.send(EVENT.SIGNAL_VIDEO, { video })
|
if (video == '' && bitrate == 0) {
|
||||||
|
throw new Error('video id and bitrate cannot be empty')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.websocket.send(EVENT.SIGNAL_VIDEO, { video, bitrate })
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLogger(scope?: string): Logger {
|
public getLogger(scope?: string): Logger {
|
||||||
|
@ -194,9 +194,10 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
|||||||
this.emit('connection.webrtc.sdp.candidate', 'remote', candidate)
|
this.emit('connection.webrtc.sdp.candidate', 'remote', candidate)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected [EVENT.SIGNAL_VIDEO]({ video }: message.SignalVideo) {
|
protected [EVENT.SIGNAL_VIDEO]({ video, bitrate }: message.SignalVideo) {
|
||||||
this._localLog.debug(`EVENT.SIGNAL_VIDEO`, { video })
|
this._localLog.debug(`EVENT.SIGNAL_VIDEO`, { video, bitrate })
|
||||||
Vue.set(this._state.connection.webrtc, 'video', video)
|
Vue.set(this._state.connection.webrtc, 'video', video)
|
||||||
|
Vue.set(this._state.connection.webrtc, 'bitrate', bitrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected [EVENT.SIGNAL_CLOSE]() {
|
protected [EVENT.SIGNAL_CLOSE]() {
|
||||||
|
@ -154,6 +154,7 @@
|
|||||||
},
|
},
|
||||||
stats: null,
|
stats: null,
|
||||||
video: null,
|
video: null,
|
||||||
|
bitrate: null,
|
||||||
videos: [],
|
videos: [],
|
||||||
},
|
},
|
||||||
screencast: true, // TODO: Should get by API call.
|
screencast: true, // TODO: Should get by API call.
|
||||||
@ -417,8 +418,8 @@
|
|||||||
this.connection.websocket.send(EVENT.SCREEN_SET, { width, height, rate })
|
this.connection.websocket.send(EVENT.SCREEN_SET, { width, height, rate })
|
||||||
}
|
}
|
||||||
|
|
||||||
public setWebRTCVideo(video: string) {
|
public setWebRTCVideo(video: string, bitrate: number = 0) {
|
||||||
this.connection.setVideo(video)
|
this.connection.setVideo(video, bitrate)
|
||||||
}
|
}
|
||||||
|
|
||||||
public addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender {
|
public addTrack(track: MediaStreamTrack, ...streams: MediaStream[]): RTCRtpSender {
|
||||||
|
@ -56,6 +56,7 @@ export interface SignalDescription {
|
|||||||
|
|
||||||
export interface SignalVideo {
|
export interface SignalVideo {
|
||||||
video: string
|
video: string
|
||||||
|
bitrate: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -38,6 +38,7 @@ export interface WebRTC {
|
|||||||
config: ReconnectorConfig
|
config: ReconnectorConfig
|
||||||
stats: WebRTCStats | null
|
stats: WebRTCStats | null
|
||||||
video: string | null
|
video: string | null
|
||||||
|
bitrate: number | null
|
||||||
videos: string[]
|
videos: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +158,9 @@
|
|||||||
{{ video }}
|
{{ video }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
or
|
||||||
|
<input type="text" v-model="bitrate" style="width: 60px" placeholder="Bitrate" />
|
||||||
|
<button @click="neko.setWebRTCVideo('', Number(bitrate))">Set</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -446,7 +449,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Vue, Component, Prop } from 'vue-property-decorator'
|
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
|
||||||
import Neko from '~/component/main.vue'
|
import Neko from '~/component/main.vue'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -456,6 +459,12 @@
|
|||||||
@Prop() readonly neko!: Neko
|
@Prop() readonly neko!: Neko
|
||||||
|
|
||||||
clipboardText: string = ''
|
clipboardText: string = ''
|
||||||
|
bitrate: number | null = null
|
||||||
|
|
||||||
|
@Watch('neko.state.connection.webrtc.bitrate')
|
||||||
|
onBitrateChange(val: number) {
|
||||||
|
this.bitrate = val
|
||||||
|
}
|
||||||
|
|
||||||
shift = false
|
shift = false
|
||||||
get letters(): number[] {
|
get letters(): number[] {
|
||||||
|
Loading…
Reference in New Issue
Block a user