Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/FatalBulletHit/mainsail
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
FatalBulletHit committed Aug 18, 2024
2 parents 59355fd + 6db486a commit 0d2794d
Show file tree
Hide file tree
Showing 16 changed files with 884 additions and 206 deletions.
68 changes: 29 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@lezer/highlight": "^1.0.0",
"@sindarius/gcodeviewer": "^3.7.11",
"@uiw/codemirror-theme-vscode": "^4.19.11",
"axios": "^1.6.0",
"axios": "^1.7.4",
"codemirror": "^6.0.1",
"core-js": "^3.16.0",
"detect-browser": "^5.3.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"postcss-nesting": "^12.0.1",
"prettier": "^3.0.0",
"sass": "~1.32",
"start-server-and-test": "^2.0.0",
"start-server-and-test": "^2.0.5",
"typescript": "^4.5.5",
"unplugin-vue-components": "^0.22.12",
"vite": "^4.5.3",
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/ConsoleTableEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class ConsoleTableEntry extends Mixins(BaseMixin) {
get entryStyle() {
const classes = ['ma-0', 'flex-nowrap']
classes.push(this.$store.state.gui.console.entryStyle ?? 'default')
if (this.event.type === 'action') classes.push('text--disabled')
if (['action', 'debug'].includes(this.event.type)) classes.push('text--disabled')
return classes
}
Expand All @@ -31,7 +31,7 @@ export default class ConsoleTableEntry extends Mixins(BaseMixin) {
get messageClass() {
const classes = ['console-message']
if (this.event.type === 'action') classes.push('text--disabled')
if (['action', 'debug'].includes(this.event.type)) classes.push('text--disabled')
else if (this.event.message.startsWith('!! ')) classes.push('error--text')
else classes.push('text--primary')
Expand Down
54 changes: 40 additions & 14 deletions src/components/webcams/streamers/WebrtcMediaMTX.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
@Prop({ default: null }) readonly printerUrl!: string | null
@Ref() declare video: HTMLVideoElement
private pc: RTCPeerConnection | null = null
private restartTimeout: any = null
private status: string = 'connecting'
private eTag: string | null = null
private sessionUuid: string | null = null
private queuedCandidates: RTCIceCandidate[] = []
private offerData: OfferData = {
pc: RTCPeerConnection | null = null
restartTimeout: any = null
status: string = 'connecting'
eTag: string | null = null
sessionUuid: string | null = null
queuedCandidates: RTCIceCandidate[] = []
offerData: OfferData = {
iceUfrag: '',
icePwd: '',
medias: [],
}
private RESTART_PAUSE = 2000
RESTART_PAUSE = 2000
mounted() {
this.start()
}
// stop the video and close the streams if the component is going to be destroyed so we don't leave hanging streams
beforeDestroy() {
Expand All @@ -70,9 +74,15 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
let baseUrl = this.camSettings.stream_url
if (!baseUrl.endsWith('/')) baseUrl += '/'
baseUrl = new URL('whep', baseUrl).toString()
try {
baseUrl = new URL('whep', baseUrl).toString()
return this.convertUrl(baseUrl, this.printerUrl)
} catch (e) {
this.log('invalid baseURL', baseUrl)
return this.convertUrl(baseUrl, this.printerUrl)
return null
}
}
// stop and restart the video if the url changes
Expand All @@ -87,7 +97,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
}
// start or stop the video when the expand state changes
@Watch('expanded', { immediate: true })
@Watch('expanded')
expandChanged(newExpanded: boolean): void {
if (!newExpanded) {
this.terminate()
Expand Down Expand Up @@ -189,6 +199,14 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
}
start() {
// stop if url is not valid
if (this.url === null) {
this.log('invalid url')
this.scheduleRestart()
return
}
this.log('requesting ICE servers from ' + this.url)
fetch(this.url, {
Expand Down Expand Up @@ -232,7 +250,7 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
this.offerData = this.parseOffer(offer.sdp ?? '')
this.pc?.setLocalDescription(offer)
fetch(this.url, {
fetch(this.url ?? '', {
method: 'POST',
headers: {
'Content-Type': 'application/sdp',
Expand All @@ -242,7 +260,8 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
.then((res) => {
if (res.status !== 201) throw new Error('bad status code')
this.eTag = res.headers.get('ETag')
this.sessionUuid = res.headers.get('location')
const location = res.headers.get('Location') ?? ''
this.sessionUuid = location?.substring(location.lastIndexOf('/') + 1) ?? null
// fallback for MediaMTX v1.0.x with broken ETag header
if (res.headers.has('E-Tag')) this.eTag = res.headers.get('E-Tag')
Expand Down Expand Up @@ -301,7 +320,14 @@ export default class WebrtcMediaMTX extends Mixins(BaseMixin, WebcamMixin) {
}
sendLocalCandidates(candidates: RTCIceCandidate[]) {
const url = new URL(this.sessionUuid ?? '', this.url).toString()
if (this.sessionUuid === null) {
this.log('Session-UUID is null')
this.scheduleRestart()
return
}
const url = (this.url ?? '') + '/' + this.sessionUuid
fetch(url, {
method: 'PATCH',
headers: {
Expand Down
Loading

0 comments on commit 0d2794d

Please sign in to comment.