Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
awrtc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
awrtc
Commits
a2f18bba
Commit
a2f18bba
authored
Sep 14, 2021
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get devices
parent
de54ce47
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
7 deletions
+74
-7
.gitignore
.gitignore
+2
-0
segmentrtc.html
build/segmentrtc.html
+72
-7
yarn.lock
yarn.lock
+0
-0
No files found.
.gitignore
View file @
a2f18bba
...
@@ -2,3 +2,4 @@ build/apps
...
@@ -2,3 +2,4 @@ build/apps
build/awrtc
build/awrtc
build/bundle
build/bundle
node_modules
node_modules
.idea
\ No newline at end of file
build/segmentrtc.html
View file @
a2f18bba
...
@@ -178,6 +178,66 @@
...
@@ -178,6 +178,66 @@
)
)
)
)
);
);
function
gotDevices
(
deviceInfos
)
{
// Handles being called several times to update labels. Preserve values.
var
devices
=
{
audioinput
:
[],
audiooutput
:
[],
videoinput
:
[]};
for
(
let
i
=
0
;
i
!==
deviceInfos
.
length
;
++
i
)
{
const
deviceInfo
=
deviceInfos
[
i
];
const
option
=
{
value
:
deviceInfo
.
deviceId
};
if
(
!
(
deviceInfo
.
kind
in
devices
)){
devices
[
deviceInfo
.
kind
]
=
[];
}
devices
[
deviceInfo
.
kind
].
push
(
option
);
var
count
=
devices
[
deviceInfo
.
kind
].
length
;
if
(
deviceInfo
.
kind
===
'audioinput'
)
{
option
.
text
=
deviceInfo
.
label
||
`microphone
${
count
}
`
;
}
else
if
(
deviceInfo
.
kind
===
'audiooutput'
)
{
option
.
text
=
deviceInfo
.
label
||
`speaker
${
count
}
`
;
}
else
if
(
deviceInfo
.
kind
===
'videoinput'
)
{
option
.
text
=
deviceInfo
.
label
||
`camera
${
count
}
`
;
}
else
{
console
.
log
(
'Some other kind of source/device: '
,
deviceInfo
);
}
}
console
.
log
(
devices
);
/*const values = selectors.map(select => select.value);
selectors.forEach(select => {
while (select.firstChild) {
select.removeChild(select.firstChild);
}
});
for (let i = 0; i !== deviceInfos.length; ++i) {
const deviceInfo = deviceInfos[i];
const option = document.createElement('option');
option.value = deviceInfo.deviceId;
if (deviceInfo.kind === 'audioinput') {
option.text = deviceInfo.label || `microphone ${audioInputSelect.length + 1}`;
audioInputSelect.appendChild(option);
} else if (deviceInfo.kind === 'audiooutput') {
option.text = deviceInfo.label || `speaker ${audioOutputSelect.length + 1}`;
audioOutputSelect.appendChild(option);
} else if (deviceInfo.kind === 'videoinput') {
option.text = deviceInfo.label || `camera ${videoSelect.length + 1}`;
videoSelect.appendChild(option);
} else {
console.log('Some other kind of source/device: ', deviceInfo);
continue;
}
}
selectors.forEach((select, selectorIndex) => {
if (Array.prototype.slice.call(select.childNodes).some(n => n.value === values[selectorIndex])) {
select.value = values[selectorIndex];
}
});*/
}
var
handleError
=
function
(
e
)
{
console
.
log
(
'Error'
,
e
)
}
navigator
.
mediaDevices
.
enumerateDevices
().
then
(
gotDevices
).
catch
(
handleError
);
const
videoElement
=
document
.
getElementsByClassName
(
'input_video'
)[
0
];
const
videoElement
=
document
.
getElementsByClassName
(
'input_video'
)[
0
];
const
canvasElement
=
window
.
canvasElement
=
document
.
getElementsByClassName
(
'output_canvas'
)[
0
];
const
canvasElement
=
window
.
canvasElement
=
document
.
getElementsByClassName
(
'output_canvas'
)[
0
];
const
segmentations
=
[
false
,
false
,
false
,
false
];
const
segmentations
=
[
false
,
false
,
false
,
false
];
...
@@ -251,15 +311,19 @@
...
@@ -251,15 +311,19 @@
let
instance
=
new
apps
.
videoinputapp
(
document
.
querySelector
(
"#videoinputapp1"
),
canvas
);
let
instance
=
new
apps
.
videoinputapp
(
document
.
querySelector
(
"#videoinputapp1"
),
canvas
);
instance
.
mUiRemoteVideoParent
=
remoteVideoEl
;
instance
.
mUiRemoteVideoParent
=
remoteVideoEl
;
const
selfieSegmentation
=
new
SelfieSegmentation
({
locateFile
:
(
file
)
=>
{
var
doSegmentation
=
false
;
if
(
doSegmentation
){
const
selfieSegmentation
=
new
SelfieSegmentation
(
{
locateFile
:
(
file
)
=>
{
return
`https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/
${
file
}
`
;
return
`https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/
${
file
}
`
;
}});
}
selfieSegmentation
.
setOptions
({
}
);
selfieSegmentation
.
setOptions
(
{
modelSelection
:
1
,
modelSelection
:
1
,
}
);
}
);
selfieSegmentation
.
onResults
(
function
()
{
selfieSegmentation
.
onResults
(
function
()
{
window
.
onResults
.
apply
(
this
,
arguments
)
window
.
onResults
.
apply
(
this
,
arguments
)
}
);
}
);
const
camera
=
new
Camera
(
videoElement
,
{
const
camera
=
new
Camera
(
videoElement
,
{
onFrame
:
async
()
=>
{
onFrame
:
async
()
=>
{
...
@@ -269,6 +333,7 @@
...
@@ -269,6 +333,7 @@
height
:
h
//,720
height
:
h
//,720
});
});
camera
.
start
();
camera
.
start
();
}
D
.
ext
(
D
(
'.callapp_button'
)[
0
],
{
onclick
:
function
()
{
D
.
ext
(
D
(
'.callapp_button'
)[
0
],
{
onclick
:
function
()
{
}});
}});
...
...
yarn.lock
0 → 100644
View file @
a2f18bba
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment