Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
galene
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
galene
Commits
eb21c1ab
Commit
eb21c1ab
authored
Mar 25, 2022
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Maintain stream information for oneself.
We used to maintain stream information for all users except oneself.
parent
e303992e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
40 deletions
+37
-40
static/galene.js
static/galene.js
+3
-3
static/protocol.js
static/protocol.js
+34
-37
No files found.
static/galene.js
View file @
eb21c1ab
...
...
@@ -1049,7 +1049,7 @@ function removeFilter(c) {
if
(
!
(
old
instanceof
Filter
))
throw
new
Error
(
'
userdata.filter is not a filter
'
);
c
.
s
tream
=
old
.
inputStream
;
c
.
s
etStream
(
old
.
inputStream
)
;
old
.
stop
();
c
.
userdata
.
filter
=
null
;
}
...
...
@@ -1066,7 +1066,7 @@ function setFilter(c) {
return
;
let
filter
=
new
Filter
(
c
.
stream
,
c
.
userdata
.
filterDefinition
);
c
.
s
tream
=
filter
.
outputStream
;
c
.
s
etStream
(
filter
.
outputStream
)
;
c
.
userdata
.
filter
=
filter
;
}
...
...
@@ -1162,7 +1162,7 @@ function setUpStream(c, stream) {
if
(
c
.
stream
!=
null
)
throw
new
Error
(
"
Setting nonempty stream
"
);
c
.
s
tream
=
stream
;
c
.
s
etStream
(
stream
)
;
try
{
setFilter
(
c
);
...
...
static/protocol.js
View file @
eb21c1ab
...
...
@@ -66,7 +66,7 @@ function newLocalId() {
* @property {string} username
* @property {Array<string>} permissions
* @property {Object<string,any>} data
* @property {Object<string,Object<string,boolean>>}
down
* @property {Object<string,Object<string,boolean>>}
streams
*/
/**
...
...
@@ -359,7 +359,7 @@ ServerConnection.prototype.connect = async function(url) {
username
:
m
.
username
,
permissions
:
m
.
permissions
||
[],
data
:
m
.
data
||
{},
down
:
{},
streams
:
{},
};
break
;
case
'
change
'
:
...
...
@@ -369,7 +369,7 @@ ServerConnection.prototype.connect = async function(url) {
username
:
m
.
username
,
permissions
:
m
.
permissions
||
[],
data
:
m
.
data
||
{},
down
:
{},
streams
:
{},
};
}
else
{
sc
.
users
[
m
.
id
].
username
=
m
.
username
;
...
...
@@ -593,7 +593,6 @@ ServerConnection.prototype.newUpStream = function(localId) {
};
pc
.
ontrack
=
console
.
error
;
return
c
;
};
...
...
@@ -750,7 +749,7 @@ ServerConnection.prototype.gotOffer = async function(id, label, source, username
return
;
}
c
.
stream
=
e
.
streams
[
0
];
let
changed
=
recomputeUserStreams
(
sc
,
source
,
c
);
let
changed
=
recomputeUserStreams
(
sc
,
source
);
if
(
c
.
ondowntrack
)
{
c
.
ondowntrack
.
call
(
c
,
e
.
track
,
e
.
transceiver
,
e
.
streams
[
0
],
...
...
@@ -1061,6 +1060,19 @@ function Stream(sc, id, localId, pc, up) {
this
.
onstats
=
null
;
}
/**
* setStream sets the stream of an upwards connection.
*
* @param {MediaStream} stream
*/
Stream
.
prototype
.
setStream
=
function
(
stream
)
{
let
c
=
this
;
c
.
stream
=
stream
;
let
changed
=
recomputeUserStreams
(
c
.
sc
,
c
.
sc
.
id
);
if
(
changed
&&
c
.
sc
.
onuser
)
c
.
sc
.
onuser
.
call
(
c
.
sc
,
c
.
sc
.
id
,
"
change
"
);
}
/**
* close closes a stream.
*
...
...
@@ -1096,20 +1108,23 @@ Stream.prototype.close = function(replace) {
}
}
let
userid
;
if
(
c
.
up
)
{
userid
=
c
.
sc
.
id
;
if
(
c
.
sc
.
up
[
c
.
id
]
===
c
)
delete
(
c
.
sc
.
up
[
c
.
id
]);
else
console
.
warn
(
'
Closing unknown stream
'
);
}
else
{
userid
=
c
.
source
;
if
(
c
.
sc
.
down
[
c
.
id
]
===
c
)
delete
(
c
.
sc
.
down
[
c
.
id
]);
else
console
.
warn
(
'
Closing unknown stream
'
);
let
changed
=
recomputeUserStreams
(
c
.
sc
,
c
.
source
);
if
(
changed
&&
c
.
sc
.
onuser
)
c
.
sc
.
onuser
.
call
(
c
.
sc
,
c
.
source
,
"
change
"
);
}
let
changed
=
recomputeUserStreams
(
c
.
sc
,
userid
);
if
(
changed
&&
c
.
sc
.
onuser
)
c
.
sc
.
onuser
.
call
(
c
.
sc
,
userid
,
"
change
"
);
c
.
sc
=
null
;
if
(
c
.
onclose
)
...
...
@@ -1117,53 +1132,35 @@ Stream.prototype.close = function(replace) {
};
/**
* recomputeUserStreams recomputes the user.
down
array for a given user.
* recomputeUserStreams recomputes the user.
streams
array for a given user.
* It returns true if anything changed.
*
* @param {ServerConnection} sc
* @param {string} id
* @param {Stream} [c]
* @returns {boolean}
*/
function
recomputeUserStreams
(
sc
,
id
,
c
)
{
function
recomputeUserStreams
(
sc
,
id
)
{
let
user
=
sc
.
users
[
id
];
if
(
!
user
)
{
console
.
warn
(
"
recomputing streams for unknown user
"
);
return
false
;
}
if
(
c
)
{
let
changed
=
false
;
if
(
!
user
.
down
[
c
.
label
])
user
.
down
[
c
.
label
]
=
{};
c
.
stream
.
getTracks
().
forEach
(
t
=>
{
if
(
!
user
.
down
[
c
.
label
][
t
.
kind
])
{
user
.
down
[
c
.
label
][
t
.
kind
]
=
true
;
changed
=
true
;
}
});
return
changed
;
}
if
(
!
user
.
down
||
Object
.
keys
(
user
.
down
).
length
===
0
)
return
false
;
let
old
=
user
.
down
;
user
.
down
=
{};
for
(
id
in
sc
.
down
)
{
let
c
=
sc
.
down
[
id
];
let
streams
=
id
===
sc
.
id
?
sc
.
up
:
sc
.
down
;
let
old
=
user
.
streams
;
user
.
streams
=
{};
for
(
id
in
streams
)
{
let
c
=
streams
[
id
];
if
(
!
c
.
stream
)
continue
;
if
(
!
user
.
down
[
c
.
label
])
user
.
down
[
c
.
label
]
=
{};
if
(
!
user
.
streams
[
c
.
label
])
user
.
streams
[
c
.
label
]
=
{};
c
.
stream
.
getTracks
().
forEach
(
t
=>
{
user
.
down
[
c
.
label
][
t
.
kind
]
=
true
;
user
.
streams
[
c
.
label
][
t
.
kind
]
=
true
;
});
}
// might lead to false positives. Oh, well.
return
JSON
.
stringify
(
old
)
!=
JSON
.
stringify
(
user
.
down
);
return
JSON
.
stringify
(
old
)
!=
JSON
.
stringify
(
user
.
streams
);
}
/**
...
...
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