Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cvh-camera
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Döring
cvh-camera
Commits
003e05f5
Commit
003e05f5
authored
Nov 9, 2020
by
Simon Döring
Browse files
Options
Downloads
Patches
Plain Diff
Add optional passwords
parent
46db272f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
novnc/app/camera-receiver.js
+136
-115
136 additions, 115 deletions
novnc/app/camera-receiver.js
sender/camera-sender-2.html
+5
-1
5 additions, 1 deletion
sender/camera-sender-2.html
sender/camera-sender-2.js
+9
-6
9 additions, 6 deletions
sender/camera-sender-2.js
with
150 additions
and
122 deletions
novnc/app/camera-receiver.js
+
136
−
115
View file @
003e05f5
document
.
addEventListener
(
'
DOMContentLoaded
'
,
function
()
{
var
server
=
'
https://
'
+
window
.
location
.
hostname
+
'
:8089/janus
'
;
var
server
=
'
https://
'
+
window
.
location
.
hostname
+
'
:8089/janus
'
;
var
janus
=
null
;
var
janus
=
null
;
...
@@ -8,24 +11,24 @@ var opaqueId = 'camera-receiver-' + Janus.randomString(12);
...
@@ -8,24 +11,24 @@ var opaqueId = 'camera-receiver-' + Janus.randomString(12);
var
room
=
1000
;
var
room
=
1000
;
var
source
=
null
;
var
source
=
null
;
var
connec
tClicked
=
false
;
var
passwordSubmi
tClicked
=
false
;
var
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
var
passwordButton
=
document
.
getElementById
(
'
noVNC_password_button
'
);
var
roomParam
=
urlParams
.
get
(
'
room
'
);
var
passwordInput
=
document
.
getElementById
(
'
noVNC_password_input
'
);
if
(
roomParam
!=
null
&&
!
isNaN
(
roomParam
))
{
var
currentPassword
=
''
;
room
=
parseInt
(
roomParam
);
var
pin
=
''
;
}
else
{
console
.
log
(
'
Got no valid room in URL search params, using default room
'
+
room
);
}
document
.
addEventListener
(
'
DOMContentLoaded
'
,
function
()
{
passwordInput
.
addEventListener
(
'
input
'
,
function
(
event
)
{
currentPassword
=
event
.
target
.
value
;
});
var
connectButton
=
document
.
getElementById
(
'
noVNC_connect_button
'
);
passwordButton
.
onclick
=
function
()
{
connectButton
.
onclick
=
function
()
{
pin
=
currentPassword
;
connectButton
.
onclick
=
null
;
passwordSubmitClicked
=
true
;
connectClicked
=
true
;
};
};
parseRoomFromURL
();
Janus
.
init
({
debug
:
true
,
callback
:
function
()
{
Janus
.
init
({
debug
:
true
,
callback
:
function
()
{
if
(
!
Janus
.
isWebrtcSupported
())
{
if
(
!
Janus
.
isWebrtcSupported
())
{
alert
(
'
No WebRTC support...
'
);
alert
(
'
No WebRTC support...
'
);
...
@@ -42,11 +45,11 @@ document.addEventListener('DOMContentLoaded', function() {
...
@@ -42,11 +45,11 @@ document.addEventListener('DOMContentLoaded', function() {
videoroomHandle
=
pluginHandle
;
videoroomHandle
=
pluginHandle
;
Janus
.
log
(
'
Plugin attached! (
'
+
videoroomHandle
.
getPlugin
()
+
'
, id=
'
+
videoroomHandle
.
getId
()
+
'
)
'
);
Janus
.
log
(
'
Plugin attached! (
'
+
videoroomHandle
.
getPlugin
()
+
'
, id=
'
+
videoroomHandle
.
getId
()
+
'
)
'
);
if
(
connec
tClicked
)
{
if
(
passwordSubmi
tClicked
)
{
joinRoom
();
joinRoom
();
}
else
{
}
else
{
connect
Button
.
onclick
=
function
()
{
password
Button
.
onclick
=
function
()
{
connectButton
.
onclick
=
null
;
pin
=
currentPassword
;
joinRoom
();
joinRoom
();
};
};
}
}
...
@@ -67,13 +70,13 @@ document.addEventListener('DOMContentLoaded', function() {
...
@@ -67,13 +70,13 @@ document.addEventListener('DOMContentLoaded', function() {
}
}
});
});
}});
}});
});
function
handleMessagePublisher
(
msg
,
jsep
)
{
function
handleMessagePublisher
(
msg
,
jsep
)
{
var
event
=
msg
[
'
videoroom
'
];
var
event
=
msg
[
'
videoroom
'
];
if
(
event
)
{
if
(
event
)
{
if
(
event
===
'
joined
'
)
{
if
(
event
===
'
joined
'
)
{
Janus
.
log
(
'
Successfully joined room
'
+
msg
[
'
room
'
]
+
'
with ID
'
+
msg
[
'
id
'
]);
Janus
.
log
(
'
Successfully joined room
'
+
msg
[
'
room
'
]
+
'
with ID
'
+
msg
[
'
id
'
]);
passwordButton
.
onclick
=
null
;
var
publishers
=
msg
[
'
publishers
'
];
var
publishers
=
msg
[
'
publishers
'
];
if
(
publishers
&&
publishers
.
length
!==
0
)
{
if
(
publishers
&&
publishers
.
length
!==
0
)
{
newRemoteFeed
(
publishers
[
0
][
'
id
'
]);
newRemoteFeed
(
publishers
[
0
][
'
id
'
]);
...
@@ -89,7 +92,11 @@ function handleMessagePublisher(msg, jsep) {
...
@@ -89,7 +92,11 @@ function handleMessagePublisher(msg, jsep) {
video
.
remove
();
video
.
remove
();
}
}
}
else
if
(
msg
[
'
error
'
])
{
}
else
if
(
msg
[
'
error
'
])
{
alert
(
msg
[
'
error
'
]);
if
(
msg
[
'
error_code
'
]
===
433
)
{
console
.
error
(
'
Janus: wrong pin "
'
+
pin
+
'
" for room
'
+
room
);
return
;
}
alert
(
'
Error message:
'
+
msg
[
'
error
'
]
+
'
.
\n
Error object:
'
+
JSON
.
stringify
(
msg
,
null
,
2
));
}
}
}
}
}
}
...
@@ -110,7 +117,8 @@ function newRemoteFeed(id) {
...
@@ -110,7 +117,8 @@ function newRemoteFeed(id) {
request
:
'
join
'
,
request
:
'
join
'
,
room
,
room
,
ptype
:
'
listener
'
,
ptype
:
'
listener
'
,
feed
:
id
feed
:
id
,
pin
};
};
remoteFeedHandle
.
send
({
message
:
listen
});
remoteFeedHandle
.
send
({
message
:
listen
});
},
},
...
@@ -169,7 +177,20 @@ function joinRoom() {
...
@@ -169,7 +177,20 @@ function joinRoom() {
var
register
=
{
var
register
=
{
request
:
'
join
'
,
request
:
'
join
'
,
room
,
room
,
ptype
:
'
publisher
'
ptype
:
'
publisher
'
,
pin
};
};
videoroomHandle
.
send
({
message
:
register
});
videoroomHandle
.
send
({
message
:
register
});
}
}
function
parseRoomFromURL
()
{
var
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
var
roomParam
=
urlParams
.
get
(
'
room
'
);
if
(
roomParam
!=
null
&&
!
isNaN
(
roomParam
))
{
room
=
parseInt
(
roomParam
);
}
else
{
console
.
log
(
'
Got no valid room in URL search params, using default room
'
+
room
);
}
}
});
This diff is collapsed.
Click to expand it.
sender/camera-sender-2.html
+
5
−
1
View file @
003e05f5
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
<link
rel=
"stylesheet"
href=
"camera-sender.css"
>
<link
rel=
"stylesheet"
href=
"camera-sender.css"
>
</head>
</head>
<body>
<body>
<div>
Leave the pin empty if the rooms has none set.
</div>
<select
id=
"room-select"
>
<select
id=
"room-select"
>
<option
value=
"1001"
>
VNC 1
</option>
<option
value=
"1001"
>
VNC 1
</option>
<option
value=
"1002"
>
VNC 2
</option>
<option
value=
"1002"
>
VNC 2
</option>
...
@@ -22,10 +25,11 @@
...
@@ -22,10 +25,11 @@
<option
value=
"stdres-16:9"
>
640x360
</option>
<option
value=
"stdres-16:9"
>
640x360
</option>
<option
value=
"hires-16:9"
>
1280x720
</option>
<option
value=
"hires-16:9"
>
1280x720
</option>
</select>
</select>
<input
type=
"password"
id=
"pin-input"
placeholder=
"Room pin"
/>
<button
id=
"start"
disabled
>
Start
</button>
<button
id=
"start"
disabled
>
Start
</button>
<button
id=
"stop"
disabled
>
Stop
</button>
<button
id=
"stop"
disabled
>
Stop
</button>
<form
id=
"bandwidth-form"
>
<form
id=
"bandwidth-form"
>
<label>
A bandwidth cap can be set here. 0 or negative means
unlimited
.
</label>
<label>
A bandwidth cap can be set here. 0 or negative means
no cap
.
</label>
<br
/>
<br
/>
<input
type=
"text"
id=
"bandwidth-input"
placeholder=
"New bitrate [in kbit/s]"
/>
<input
type=
"text"
id=
"bandwidth-input"
placeholder=
"New bitrate [in kbit/s]"
/>
<input
type=
"submit"
id=
"bandwidth-submit"
value=
"Change"
disabled
/>
<input
type=
"submit"
id=
"bandwidth-submit"
value=
"Change"
disabled
/>
...
...
This diff is collapsed.
Click to expand it.
sender/camera-sender-2.js
+
9
−
6
View file @
003e05f5
...
@@ -30,6 +30,7 @@ document.addEventListener('DOMContentLoaded', function() {
...
@@ -30,6 +30,7 @@ document.addEventListener('DOMContentLoaded', function() {
startButton
.
onclick
=
function
()
{
startButton
.
onclick
=
function
()
{
var
roomSelect
=
document
.
getElementById
(
'
room-select
'
);
var
roomSelect
=
document
.
getElementById
(
'
room-select
'
);
var
resSelect
=
document
.
getElementById
(
'
res-select
'
);
var
resSelect
=
document
.
getElementById
(
'
res-select
'
);
var
pinInput
=
document
.
getElementById
(
'
pin-input
'
);
startButton
.
setAttribute
(
'
disabled
'
,
''
);
startButton
.
setAttribute
(
'
disabled
'
,
''
);
roomSelect
.
setAttribute
(
'
disabled
'
,
''
);
roomSelect
.
setAttribute
(
'
disabled
'
,
''
);
resSelect
.
setAttribute
(
'
disabled
'
,
''
);
resSelect
.
setAttribute
(
'
disabled
'
,
''
);
...
@@ -39,8 +40,9 @@ document.addEventListener('DOMContentLoaded', function() {
...
@@ -39,8 +40,9 @@ document.addEventListener('DOMContentLoaded', function() {
};
};
room
=
parseInt
(
roomSelect
.
value
);
room
=
parseInt
(
roomSelect
.
value
);
sendResolution
=
resSelect
.
value
;
sendResolution
=
resSelect
.
value
;
console
.
log
(
'
sendResolution:
'
,
sendResolution
);
Janus
.
log
(
'
sendResolution:
'
,
sendResolution
);
shareCamera
();
shareCamera
(
pinInput
.
value
);
pinInput
.
value
=
''
;
};
};
startButton
.
removeAttribute
(
'
disabled
'
);
startButton
.
removeAttribute
(
'
disabled
'
);
},
},
...
@@ -93,11 +95,12 @@ document.addEventListener('DOMContentLoaded', function() {
...
@@ -93,11 +95,12 @@ document.addEventListener('DOMContentLoaded', function() {
}});
}});
},
false
);
},
false
);
function
shareCamera
()
{
function
shareCamera
(
pin
)
{
var
register
=
{
var
register
=
{
request
:
'
join
'
,
request
:
'
join
'
,
room
,
room
,
ptype
:
'
publisher
'
ptype
:
'
publisher
'
,
pin
};
};
videoroomHandle
.
send
({
message
:
register
});
videoroomHandle
.
send
({
message
:
register
});
}
}
...
@@ -123,7 +126,7 @@ function handleMessage(msg, jsep) {
...
@@ -123,7 +126,7 @@ function handleMessage(msg, jsep) {
var
event
=
msg
[
'
videoroom
'
];
var
event
=
msg
[
'
videoroom
'
];
if
(
event
)
{
if
(
event
)
{
if
(
event
===
'
joined
'
)
{
if
(
event
===
'
joined
'
)
{
console
.
log
(
'
Joined event:
'
,
msg
);
Janus
.
log
(
'
Joined event:
'
,
msg
);
Janus
.
log
(
'
Successfully joined room
'
+
msg
[
'
room
'
]
+
'
with ID
'
+
msg
[
'
id
'
]);
Janus
.
log
(
'
Successfully joined room
'
+
msg
[
'
room
'
]
+
'
with ID
'
+
msg
[
'
id
'
]);
if
(
msg
[
'
publishers
'
].
length
===
0
)
{
if
(
msg
[
'
publishers
'
].
length
===
0
)
{
videoroomHandle
.
createOffer
({
videoroomHandle
.
createOffer
({
...
@@ -152,7 +155,7 @@ function handleMessage(msg, jsep) {
...
@@ -152,7 +155,7 @@ function handleMessage(msg, jsep) {
}
}
}
}
if
(
event
===
'
event
'
&&
msg
[
'
error
'
])
{
if
(
event
===
'
event
'
&&
msg
[
'
error
'
])
{
alert
(
msg
[
'
error
'
]
);
alert
(
'
Error message:
'
+
msg
[
'
error
'
]
+
'
.
\n
Error object:
'
+
JSON
.
stringify
(
msg
,
null
,
2
)
);
window
.
location
.
reload
();
window
.
location
.
reload
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment