Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Yoann HOUPERT
hublot
Commits
634b88f1
Commit
634b88f1
authored
Jun 13, 2017
by
Tom JORQUERA
Browse files
Merge branch 'issue-23' into 'master'
Issue 23 Closes #23 and #24 See merge request !22
parents
37327664
f22bef0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
14 deletions
+62
-14
client/robot/robot.js
client/robot/robot.js
+28
-11
client/robot/robot.test.js
client/robot/robot.test.js
+34
-3
No files found.
client/robot/robot.js
View file @
634b88f1
...
...
@@ -11,7 +11,8 @@ const config = arguments[1];
robotController
.
external
.
load
(
config
);
robot
=
{
recordedParticipants
:
{},
recordedParticipantsWS
:
{},
participantsMediaRecorders
:
{},
processAudio
(
stream
,
callback
,
interval
)
{
const
mediaRecorder
=
new
MediaRecorder
(
stream
);
...
...
@@ -54,22 +55,35 @@ robot = {
}
},
recordParticipant
(
easyrtcid
)
{
const
stream
=
robotController
.
getRemoteStream
(
easyrtcid
);
const
ws
=
robotLib
.
stt
.
getTranscriptSocket
(
e
=>
{
console
.
log
(
'
>
'
+
e
.
text
);
robotLib
.
reco
.
send
(
{
from
:
room
,
text
:
e
.
from
+
'
\t
'
+
e
.
until
+
'
\t
'
+
easyrtcid
+
'
\t
'
+
e
.
text
});
});
robot
.
participantsMediaRecorders
[
easyrtcid
]
=
robot
.
processAudio
(
stream
,
e
=>
ws
.
send
(
e
.
data
),
100
);
robot
.
recordedParticipantsWS
[
easyrtcid
]
=
ws
;
},
stopRecordParticipant
(
easyrtcid
)
{
robot
.
participantsMediaRecorders
[
easyrtcid
].
stop
();
robot
.
recordedParticipantsWS
[
easyrtcid
].
close
();
},
start
:
()
=>
{
robotLib
.
stt
=
robotLib
.
stt
(
config
);
robotLib
.
reco
=
robotLib
.
reco
(
config
);
robotLib
.
archive
=
robotLib
.
archive
(
config
);
robotController
.
onAttendeePush
=
(
e
,
data
)
=>
{
const
stream
=
robotController
.
getRemoteStream
(
data
.
easyrtcid
);
const
ws
=
robotLib
.
stt
.
getTranscriptSocket
(
e
=>
{
console
.
log
(
'
>
'
+
e
.
text
);
robotLib
.
reco
.
send
(
{
from
:
room
,
text
:
e
.
from
+
'
\t
'
+
e
.
until
+
'
\t
'
+
data
.
easyrtcid
+
'
\t
'
+
e
.
text
});
});
robot
.
processAudio
(
stream
,
e
=>
ws
.
send
(
e
.
data
),
100
);
robot
.
recordParticipant
(
data
.
easyrtcid
);
};
robotController
.
onAttendeeRemove
=
(
e
,
data
)
=>
{
robot
.
stopRecordParticipant
(
data
.
easyrtcid
);
};
robotLib
.
reco
.
start
(
room
);
...
...
@@ -78,5 +92,8 @@ robot = {
.
then
(
robot
.
processReco
)
.
catch
(
console
.
error
),
8000
);
// Record current participants already present in the room
robotController
.
getParticipants
().
map
(
robot
.
recordParticipant
);
}
};
client/robot/robot.test.js
View file @
634b88f1
...
...
@@ -7,29 +7,40 @@ describe('client/robot', () => {
type
:
'
mediaRecorder
'
,
stream
,
started
:
false
,
stopped
:
false
,
interval
:
null
,
start
(
interval
)
{
this
.
started
=
true
;
this
.
interval
=
interval
;
},
stop
()
{
this
.
started
=
false
;
this
.
stopped
=
true
;
}
};
global
.
MediaRecorder
.
instance
=
res
;
global
.
MediaRecorder
.
instance
s
[
stream
.
id
]
=
res
;
return
res
;
};
global
.
MediaRecorder
.
instances
=
{};
global
.
robotController
=
{
external
:
{
load
:
()
=>
{}
},
getParticipants
:
()
=>
[
'
someid1
'
,
'
someid2
'
],
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
})
};
global
.
robotLib
=
{
sttDataSent
:
[],
closed
:
false
,
stt
:
()
=>
({
getTranscriptSocket
:
()
=>
({
send
(
data
)
{
global
.
robotLib
.
sttDataSent
.
push
(
data
);
},
close
()
{
global
.
robotLib
.
closed
=
true
;
}
})
}),
...
...
@@ -73,12 +84,32 @@ describe('client/robot', () => {
expect
(
callbackCalled
).
toBe
(
'
somedata
'
);
});
test
(
'
should start transcribing users already present on `start`
'
,
()
=>
{
global
.
robot
.
start
();
const
e1
=
{
data
:
'
somedata1
'
};
global
.
MediaRecorder
.
instances
.
someid1
.
ondataavailable
(
e1
);
expect
(
global
.
robotLib
.
sttDataSent
[
0
]).
toBe
(
e1
.
data
);
const
e2
=
{
data
:
'
somedata2
'
};
global
.
MediaRecorder
.
instances
.
someid2
.
ondataavailable
(
e2
);
expect
(
global
.
robotLib
.
sttDataSent
[
1
]).
toBe
(
e2
.
data
);
});
test
(
'
should start transcribing stream on user connection after `start`
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robotController
.
onAttendeePush
({},
{
easyrt
i
c
:
'
testid
'
});
global
.
robotController
.
onAttendeePush
({},
{
easyrtc
id
:
'
testid
'
});
const
e
=
{
data
:
'
somedata
'
};
global
.
MediaRecorder
.
instance
.
ondataavailable
(
e
);
global
.
MediaRecorder
.
instance
s
.
testid
.
ondataavailable
(
e
);
expect
(
global
.
robotLib
.
sttDataSent
[
0
]).
toBe
(
e
.
data
);
});
test
(
'
should stop transcribing stream on user disconnect
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
MediaRecorder
.
instances
.
someid1
.
stopped
).
toBeTruthy
();
expect
(
global
.
robotLib
.
closed
).
toBeTruthy
();
});
});
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