Move openvidu-recording to openvidu-recording-node
This commit is contained in:
parent
f4577851ad
commit
1aa3b42427
@ -4,6 +4,11 @@ logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
@ -16,11 +21,12 @@ lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
@ -29,15 +35,18 @@ bower_components
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Typescript v1 declaration files
|
||||
typings/
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
@ -45,6 +54,15 @@ typings/
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
@ -54,11 +72,58 @@ typings/
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
# dotenv environment variable files
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
.vscode/
|
||||
*.mp4
|
||||
*.mov
|
||||
*.ogg
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,14 +1,30 @@
|
||||
[](http://www.apache.org/licenses/LICENSE-2.0)
|
||||
[](https://github.com/OpenVidu/openvidu/actions/workflows/openvidu-ce-test.yml)
|
||||
[](https://docs.openvidu.io/en/stable/?badge=stable)
|
||||
[](https://hub.docker.com/r/openvidu/openvidu-server-kms)
|
||||
[](https://openvidu.discourse.group/)
|
||||
# OpenVidu Recording
|
||||
|
||||
[![][OpenViduLogo]](http://openvidu.io)
|
||||
Simple video-call application with recording capabilities. It includes a backend built with Node.js with Express and a frontend built with plain HTML, CSS and JavaScript.
|
||||
|
||||
openvidu-recording-node
|
||||
===
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/tutorials/advanced-tutorials/node/).
|
||||
|
||||
Visit [docs.openvidu.io/en/stable/tutorials/openvidu-recording-node/](http://docs.openvidu.io/en/stable/tutorials/openvidu-recording-node/)
|
||||
## Prerequisites
|
||||
|
||||
[OpenViduLogo]: https://secure.gravatar.com/avatar/5daba1d43042f2e4e85849733c8e5702?s=120
|
||||
- [Node](https://nodejs.org/en/download)
|
||||
|
||||
## Run
|
||||
|
||||
1. Download repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/OpenVidu/openvidu-livekit-tutorials.git
|
||||
cd openvidu-livekit-tutorials/advanced-features/openvidu-recording
|
||||
```
|
||||
|
||||
2. Install dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Run the application
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
FROM node:16-alpine3.16
|
||||
|
||||
# Copy openvidu-recording-node
|
||||
COPY . /opt/openvidu-recording-node
|
||||
|
||||
# Install openvidu-recording-node dependencies
|
||||
RUN npm --prefix /opt/openvidu-recording-node install
|
||||
|
||||
WORKDIR /opt/openvidu-recording-node
|
||||
|
||||
COPY docker/entrypoint.sh .
|
||||
|
||||
ENTRYPOINT [ "./entrypoint.sh" ]
|
||||
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No version argument provided. Usage: \"./create_image.sh <IMAGE_NAME>\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd ../
|
||||
docker build --pull --no-cache --rm=true -f docker/Dockerfile -t "$1" .
|
||||
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec node server.js "$*"
|
||||
@ -1,21 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDgzCCAmugAwIBAgIJALDBPXTrlAhlMA0GCSqGSIb3DQEBCwUAMFgxCzAJBgNV
|
||||
BAYTAkVTMRMwEQYDVQQIDApTb21lLVN0YXRlMREwDwYDVQQKDAhPcGVuVmlkdTEh
|
||||
MB8GCSqGSIb3DQEJARYSb3BlbnZpZHVAZ21haWwuY29tMB4XDTE3MDUzMDE1MjQx
|
||||
N1oXDTI3MDUyODE1MjQxN1owWDELMAkGA1UEBhMCRVMxEzARBgNVBAgMClNvbWUt
|
||||
U3RhdGUxETAPBgNVBAoMCE9wZW5WaWR1MSEwHwYJKoZIhvcNAQkBFhJvcGVudmlk
|
||||
dUBnbWFpbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDbK/i
|
||||
LN80IBnGUbzA4AFl4KQEX6RCreythnfOSnIcQSTP+KjesZMFgsGV0LteDxeCJ+kq
|
||||
4YoS+CW7ojvOEz3xjCgo4tFdevz8ZoeO0RBQIbARbPako4OXC6vWs6LHwCR0aDWo
|
||||
9HfS1Uusb8g77csRPRlNA3DGR8dcRTiEBdfHS6Jh/7V7XiDlaxPXj+iIY8PyCqOf
|
||||
gv4clDt17R+dendDsgYxbmZaodrppNocMQIyUaDIwI4DZOa8nQYk9uuUhkiAFAQB
|
||||
O642bx6NI0qDu5KgtMmbaS6s+rMnrL8eeZOicqff6XoC6tk6GE8Fo4iYkxp2gAiT
|
||||
sigaSwpNRWhupISVAgMBAAGjUDBOMB0GA1UdDgQWBBTi3sXqpf42vUNehFU6y4Pn
|
||||
PTJFRDAfBgNVHSMEGDAWgBTi3sXqpf42vUNehFU6y4PnPTJFRDAMBgNVHRMEBTAD
|
||||
AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBfl0C7XAbPdJzCjCsboMTzfC2B4uwspbST
|
||||
MbUGnmNkTwzeOOsrLQmlCznKGprYV9vGR0MwBzYw2swWCzg/2MLN8swW7NF9gMkK
|
||||
K61AANxT0qZV/aZhdM7W//pHJoQYsBsQT7cuTrL/VB/niD81uMA/mSWyXIn8KDIy
|
||||
CPY6jiZ4qiIJnQWhWm1Cazv6O7wjDisvB1cCJhDvBv42KkFwtigt5MQnBEGOI2LD
|
||||
iKCkXfj33E5B6n0sEel68WgYi6rx2tsR9lzAjCRF+jgNd7FfeUi999m7ykgEACR5
|
||||
OYRqkVcIXz30r9RxQyFqZLNzyO9oaVZpex8ZbWwEzNXG2ccddnMJ
|
||||
-----END CERTIFICATE-----
|
||||
@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAw2yv4izfNCAZxlG8wOABZeCkBF+kQq3srYZ3zkpyHEEkz/io
|
||||
3rGTBYLBldC7Xg8XgifpKuGKEvglu6I7zhM98YwoKOLRXXr8/GaHjtEQUCGwEWz2
|
||||
pKODlwur1rOix8AkdGg1qPR30tVLrG/IO+3LET0ZTQNwxkfHXEU4hAXXx0uiYf+1
|
||||
e14g5WsT14/oiGPD8gqjn4L+HJQ7de0fnXp3Q7IGMW5mWqHa6aTaHDECMlGgyMCO
|
||||
A2TmvJ0GJPbrlIZIgBQEATuuNm8ejSNKg7uSoLTJm2kurPqzJ6y/HnmTonKn3+l6
|
||||
AurZOhhPBaOImJMadoAIk7IoGksKTUVobqSElQIDAQABAoIBAGr/2HFjFjbpGJOw
|
||||
b0O/oqRQUh2e7EYiCoOcK37E3iPAO1KvmG6OFayfwjSwG9bNNpbqGU2EPeBTA/3v
|
||||
PwV/HZxinB5+yhl/3IKp9LDqoR7uwwNXgNf2O3d5SXX91zO9bXhbEn5WlEDYzl00
|
||||
uxKtCVF//ZlgN+AoruxDbkVDGbkhKHGzvqOW+BWwbYHPOttQ9TQx2ss5+DekpDFV
|
||||
/FuvXGOcSSV/N+WbDwsqUiM8ovkcflEgQjZYlAY4Ro2U2buf3fKEmy1jxSznNp30
|
||||
QA4WyYypyS8Hz6S/F4nsjtS3ufCurrWBv4vt2qB+8tH//07NUacjQWZdvEAtaJ+G
|
||||
IyJgsOUCgYEA38b2SQiw74fwoK6so2XdpCzOObLQBOT1aeZQjt3v8XZ0MPzwWJZm
|
||||
VkMBmolcEw24xA3jHhOQYafAGjRdaKxlRbJyGJqwENfAs7hO5JSLLWWXsorJQcb7
|
||||
1OVTFPt7NZopx2Kw7kGGuj9884w57cSl9lsuMptqk8W7pbTo5opOfl8CgYEA35CR
|
||||
x23kaFDh8+zKUuSdIrkUJ66cazgOfF0FYKiDewd1sGEdZT+gq7Wo8Hi8cp9q+Kuq
|
||||
MkGrTzu21yMi2fo7RKoSOtV4RQViu6PuoYR/KvRq4F4abHEAivAG4xhPQife84IB
|
||||
NkDQXaE9EXTP7DXPwj4HV8CnC9LC2qPFU7GVeYsCgYBWPK6c5qSJKrIouif9sDwC
|
||||
EOJIighwWmvZK9DPvefB/gw49MEK4qr9g0US8Oxyy07w/wkPhiqV97eoYZW9yPIe
|
||||
Me6WXMaNNxgkKlr86+HW1NfpDmMQ3kYefWHPLDsHJSoElJvqtYXeMKlOkjOg1a+/
|
||||
iNP83Lftyr3N1jIK5jHpsQKBgE1+clm7qOnT547C7JrxLdrEZs0ehI/R3YuUPvHz
|
||||
V6gEvPHHqAXZmVsL3CSG5WOiCNVrw9Ip2zTa0RUf08vVJkg1353PMyJRrJi4SVZp
|
||||
dB8ym/1sASLHxNVkQC7l1UtsQKcN0Fe6/b8GzgFICW6qdHqzP55WZFD/3JUnIZZS
|
||||
PyrjAoGBAMfuE0Nrw9Fq7f8+U/SsqiW9djJp4R34EF5n8qHkotfRoAbGktCGxLoF
|
||||
QMbB9X0ibRMpxEKPHj+V0FXu9zUKFuqoriRc3alQYLNzJEdKeQQ/AN5xjG3ilM6D
|
||||
/FunImbvSdJLjR9Ue6vlFdOquHevBCFDiHOJPQJ/y4qyZR5Avluw
|
||||
-----END RSA PRIVATE KEY-----
|
||||
3581
advanced-features/openvidu-recording-node/package-lock.json
generated
3581
advanced-features/openvidu-recording-node/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,27 +1,17 @@
|
||||
{
|
||||
"name": "openvidu-recording-node",
|
||||
"version": "2.27.0",
|
||||
"description": "",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js",
|
||||
"test": "ng test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/OpenVidu/openvidu-tutorials.git"
|
||||
},
|
||||
"author": "openvidu@gmail.com",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/OpenVidu/openvidu-tutorials/issues"
|
||||
},
|
||||
"homepage": "https://github.com/OpenVidu/openvidu-tutorials#readme",
|
||||
"dependencies": {
|
||||
"body-parser": "1.20.0",
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "16.0.1",
|
||||
"express": "4.18.1",
|
||||
"livekit-server-sdk": "1.2.2"
|
||||
}
|
||||
"name": "openvidu-recording",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple video-call application with recording capabilities",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.635.0",
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "16.4.5",
|
||||
"express": "4.19.2",
|
||||
"livekit-server-sdk": "2.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,348 +1,381 @@
|
||||
var LivekitClient = window.LivekitClient;
|
||||
// When running OpenVidu locally, leave this variable empty
|
||||
// For other deployment type, configure it with correct URL depending on your deployment
|
||||
var LIVEKIT_URL = "";
|
||||
configureLiveKitUrl();
|
||||
|
||||
const LivekitClient = window.LivekitClient;
|
||||
var room;
|
||||
var myRoomName;
|
||||
var token;
|
||||
var nickname;
|
||||
var numVideos = 0;
|
||||
|
||||
var localVideoPublication;
|
||||
var localAudioPublication;
|
||||
|
||||
/* OPENVIDU METHODS */
|
||||
|
||||
function joinRoom() {
|
||||
// --- 0) Change the button ---
|
||||
|
||||
document.getElementById('join-btn').disabled = true;
|
||||
document.getElementById('join-btn').innerHTML = 'Joining...';
|
||||
const myParticipantName = `Participant${Math.floor(Math.random() * 100)}`;
|
||||
const myRoomName = $('#roomName').val();
|
||||
|
||||
room = new LivekitClient.Room();
|
||||
|
||||
room.on(
|
||||
LivekitClient.RoomEvent.TrackSubscribed,
|
||||
(track, publication, participant) => {
|
||||
const element = track.attach();
|
||||
element.id = track.sid;
|
||||
document.getElementById('video-container').appendChild(element);
|
||||
if (track.kind === 'video') {
|
||||
var audioTrackId;
|
||||
var videoTrackId;
|
||||
participant.getTracks().forEach((track) => {
|
||||
if (track.kind === 'audio') {
|
||||
audioTrackId = track.trackInfo.sid;
|
||||
} else if (track.kind === 'video') {
|
||||
videoTrackId = track.trackInfo.sid;
|
||||
}
|
||||
});
|
||||
addIndividualRecordingButton(element.id, videoTrackId, audioTrackId);
|
||||
updateNumVideos(1);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// On every new Track destroyed...
|
||||
room.on(
|
||||
LivekitClient.RoomEvent.TrackUnsubscribed,
|
||||
(track, publication, participant) => {
|
||||
track.detach();
|
||||
document.getElementById(track.sid)?.remove();
|
||||
if (track.kind === 'video') {
|
||||
// removeUserData(participant);
|
||||
updateNumVideos(-1);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
room.on(LivekitClient.RoomEvent.RecordingStatusChanged, (isRecording) => {
|
||||
console.log('Recording status changed: ' + status);
|
||||
if (!isRecording) {
|
||||
listRecordings();
|
||||
}
|
||||
});
|
||||
|
||||
getToken(myRoomName, myParticipantName).then(async (token) => {
|
||||
const livekitUrl = getLivekitUrlFromMetadata(token);
|
||||
|
||||
try {
|
||||
await room.connect(livekitUrl, token);
|
||||
|
||||
var participantName = $('#user').val();
|
||||
$('#room-title').text(myRoomName);
|
||||
$('#join').hide();
|
||||
$('#room').show();
|
||||
|
||||
const [audioPublication, videoPublication] = await Promise.all([
|
||||
room.localParticipant.setMicrophoneEnabled(true),
|
||||
room.localParticipant.setCameraEnabled(true),
|
||||
]);
|
||||
localVideoPublication = videoPublication;
|
||||
localAudioPublication = audioPublication;
|
||||
|
||||
console.log('Connected to room ' + myRoomName);
|
||||
const element = videoPublication.track.attach();
|
||||
element.id = videoPublication.track.sid;
|
||||
document.getElementById('video-container').appendChild(element);
|
||||
addIndividualRecordingButton(
|
||||
element.id,
|
||||
videoPublication.track.sid,
|
||||
audioPublication.track.sid
|
||||
);
|
||||
updateNumVideos(1);
|
||||
} catch (error) {
|
||||
console.warn(
|
||||
'There was an error connecting to the room:',
|
||||
error.code,
|
||||
error.message
|
||||
);
|
||||
enableBtn();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
function configureLiveKitUrl() {
|
||||
// If LIVEKIT_URL is not configured, use default value from OpenVidu Local deployment
|
||||
if (!LIVEKIT_URL) {
|
||||
if (window.location.hostname === "localhost") {
|
||||
LIVEKIT_URL = "ws://localhost:7880/";
|
||||
} else {
|
||||
LIVEKIT_URL = "wss://" + window.location.hostname + ":7443/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function leaveRoom() {
|
||||
room.disconnect();
|
||||
room = null;
|
||||
async function joinRoom() {
|
||||
// Disable 'Join' button
|
||||
document.getElementById("join-button").disabled = true;
|
||||
document.getElementById("join-button").innerText = "Joining...";
|
||||
|
||||
$('#video-container').empty();
|
||||
numVideos = 0;
|
||||
// Initialize a new Room object
|
||||
room = new LivekitClient.Room();
|
||||
|
||||
$('#join').show();
|
||||
$('#room').hide();
|
||||
// Specify the actions when events take place in the room
|
||||
// On every new Track received...
|
||||
room.on(LivekitClient.RoomEvent.TrackSubscribed, (track, _publication, participant) => {
|
||||
addTrack(track, participant.identity);
|
||||
});
|
||||
|
||||
enableBtn();
|
||||
// On every new Track destroyed...
|
||||
room.on(LivekitClient.RoomEvent.TrackUnsubscribed, (track, _publication, participant) => {
|
||||
track.detach();
|
||||
document.getElementById(track.sid)?.remove();
|
||||
|
||||
if (track.kind === "video") {
|
||||
removeVideoContainer(participant.identity);
|
||||
}
|
||||
});
|
||||
|
||||
room.on(LivekitClient.RoomEvent.RecordingStatusChanged, async (isRecording) => {
|
||||
await updateRecordingInfo(isRecording);
|
||||
});
|
||||
|
||||
try {
|
||||
// Get the room name and participant name from the form
|
||||
const roomName = document.getElementById("room-name").value;
|
||||
const userName = document.getElementById("participant-name").value;
|
||||
|
||||
// Get a token from your application server with the room name and participant name
|
||||
const token = await getToken(roomName, userName);
|
||||
|
||||
// Connect to the room with the LiveKit URL and the token
|
||||
await room.connect(LIVEKIT_URL, token);
|
||||
|
||||
// Hide the 'Join room' page and show the 'Room' page
|
||||
document.getElementById("room-title").innerText = roomName;
|
||||
document.getElementById("join").hidden = true;
|
||||
document.getElementById("room").hidden = false;
|
||||
|
||||
// Publish your camera and microphone
|
||||
await room.localParticipant.enableCameraAndMicrophone();
|
||||
const localVideoTrack = this.room.localParticipant.videoTrackPublications.values().next().value.track;
|
||||
addTrack(localVideoTrack, userName, true);
|
||||
} catch (error) {
|
||||
console.log("There was an error connecting to the room:", error.message);
|
||||
await leaveRoom();
|
||||
}
|
||||
}
|
||||
|
||||
/* OPENVIDU METHODS */
|
||||
function addTrack(track, participantIdentity, local = false) {
|
||||
const element = track.attach();
|
||||
element.id = track.sid;
|
||||
|
||||
function enableBtn() {
|
||||
document.getElementById('join-btn').disabled = false;
|
||||
document.getElementById('join-btn').innerHTML = 'Join!';
|
||||
/* If the track is a video track, we create a container and append the video element to it
|
||||
with the participant's identity */
|
||||
if (track.kind === "video") {
|
||||
const videoContainer = createVideoContainer(participantIdentity, local);
|
||||
videoContainer.append(element);
|
||||
appendParticipantData(videoContainer, participantIdentity + (local ? " (You)" : ""));
|
||||
} else {
|
||||
document.getElementById("layout-container").append(element);
|
||||
}
|
||||
}
|
||||
|
||||
/* APPLICATION REST METHODS */
|
||||
async function leaveRoom() {
|
||||
// Leave the room by calling 'disconnect' method over the Room object
|
||||
await room.disconnect();
|
||||
|
||||
function getToken(roomName, participantName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Video-call chosen by the user
|
||||
httpRequest(
|
||||
'POST',
|
||||
'token',
|
||||
{ roomName, participantName },
|
||||
'Error generating token',
|
||||
(response) => resolve(response.token)
|
||||
);
|
||||
});
|
||||
// Remove all HTML elements inside the layout container
|
||||
removeAllLayoutElements();
|
||||
|
||||
// Back to 'Join room' page
|
||||
document.getElementById("join").hidden = false;
|
||||
document.getElementById("room").hidden = true;
|
||||
|
||||
// Enable 'Join' button
|
||||
document.getElementById("join-button").disabled = false;
|
||||
document.getElementById("join-button").innerText = "Join!";
|
||||
}
|
||||
|
||||
async function httpRequest(method, url, body, errorMsg, successCallback) {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: method === 'GET' ? undefined : JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
successCallback(data);
|
||||
} else {
|
||||
console.warn(errorMsg);
|
||||
console.warn('Error: ' + response.statusText);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
function startComposedRecording() {
|
||||
var hasAudio = $('#has-audio-checkbox').prop('checked');
|
||||
var hasVideo = $('#has-video-checkbox').prop('checked');
|
||||
|
||||
httpRequest(
|
||||
'POST',
|
||||
'recordings/start',
|
||||
{
|
||||
roomName: room.roomInfo.name,
|
||||
outputMode: 'COMPOSED',
|
||||
videoOnly: hasVideo && !hasAudio,
|
||||
audioOnly: hasAudio && !hasVideo,
|
||||
},
|
||||
'Start recording WRONG',
|
||||
(res) => {
|
||||
console.log(res);
|
||||
document.getElementById('forceRecordingId').value = res.id;
|
||||
checkBtnsRecordings();
|
||||
$('#textarea-http').text(JSON.stringify(res, null, '\t'));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function startIndividualRecording(videoTrackId, audioTrackId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
httpRequest(
|
||||
'POST',
|
||||
'recordings/start',
|
||||
{
|
||||
roomName: room.roomInfo.name,
|
||||
outputMode: 'INDIVIDUAL',
|
||||
audioTrackId,
|
||||
videoTrackId,
|
||||
},
|
||||
'Start recording WRONG',
|
||||
(res) => {
|
||||
console.log(res);
|
||||
$('#textarea-http').text(JSON.stringify(res.info, null, '\t'));
|
||||
resolve(res);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function stopRecording(id) {
|
||||
var forceRecordingId = id ? id : $('#forceRecordingId').val();
|
||||
httpRequest(
|
||||
'POST',
|
||||
'recordings/stop',
|
||||
{
|
||||
recordingId: forceRecordingId,
|
||||
},
|
||||
'Stop recording WRONG',
|
||||
(res) => {
|
||||
console.log(res);
|
||||
$('#forceRecordingId').val('');
|
||||
$('#textarea-http').text(JSON.stringify(res.info, null, '\t'));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function listRecordings() {
|
||||
httpRequest('GET', 'recordings/list', {}, 'List recordings WRONG', (res) => {
|
||||
console.log(res);
|
||||
$('#recording-list').empty();
|
||||
if (res.recordings && res.recordings.length > 0) {
|
||||
res.recordings.forEach((recording) => {
|
||||
var li = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
a.href = recording.path;
|
||||
a.target = '_blank';
|
||||
a.appendChild(document.createTextNode(recording.name));
|
||||
li.appendChild(a);
|
||||
$('#recording-list').append(li);
|
||||
});
|
||||
$('#delete-recordings-btn').prop('disabled', res.recordings.length === 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteRecordings() {
|
||||
httpRequest('DELETE', 'recordings', {}, 'Delete recordings WRONG', (res) => {
|
||||
console.log(res);
|
||||
$('#recording-list').empty();
|
||||
$('#delete-recordings-btn').prop('disabled', true);
|
||||
$('#textarea-http').text(JSON.stringify(res, null, '\t'));
|
||||
});
|
||||
}
|
||||
|
||||
/* APPLICATION REST METHODS */
|
||||
|
||||
/* APPLICATION BROWSER METHODS */
|
||||
|
||||
events = '';
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
// Gracefully leave room
|
||||
if (room) {
|
||||
removeUser();
|
||||
leaveRoom();
|
||||
}
|
||||
window.onbeforeunload = () => {
|
||||
room?.disconnect();
|
||||
};
|
||||
|
||||
function getLivekitUrlFromMetadata(token) {
|
||||
if (!token) throw new Error('Trying to get metadata from an empty token');
|
||||
try {
|
||||
const base64Url = token.split('.')[1];
|
||||
const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
|
||||
const jsonPayload = decodeURIComponent(
|
||||
window
|
||||
.atob(base64)
|
||||
.split('')
|
||||
.map((c) => {
|
||||
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
|
||||
})
|
||||
.join('')
|
||||
);
|
||||
window.onload = generateFormValues;
|
||||
|
||||
const payload = JSON.parse(jsonPayload);
|
||||
if (!payload?.metadata) throw new Error('Token does not contain metadata');
|
||||
const metadata = JSON.parse(payload.metadata);
|
||||
return metadata.livekitUrl;
|
||||
} catch (error) {
|
||||
throw new Error('Error decoding and parsing token: ' + error);
|
||||
}
|
||||
function generateFormValues() {
|
||||
document.getElementById("room-name").value = "Test Room";
|
||||
document.getElementById("participant-name").value = "Participant" + Math.floor(Math.random() * 100);
|
||||
}
|
||||
|
||||
function updateNumVideos(i) {
|
||||
numVideos += i;
|
||||
$('video').removeClass();
|
||||
switch (numVideos) {
|
||||
case 1:
|
||||
$('video').addClass('two');
|
||||
break;
|
||||
case 2:
|
||||
$('video').addClass('two');
|
||||
break;
|
||||
case 3:
|
||||
$('video').addClass('three');
|
||||
break;
|
||||
case 4:
|
||||
$('video').addClass('four');
|
||||
break;
|
||||
}
|
||||
function createVideoContainer(participantIdentity, local = false) {
|
||||
const videoContainer = document.createElement("div");
|
||||
videoContainer.id = `camera-${participantIdentity}`;
|
||||
videoContainer.className = "video-container";
|
||||
const layoutContainer = document.getElementById("layout-container");
|
||||
|
||||
if (local) {
|
||||
layoutContainer.prepend(videoContainer);
|
||||
} else {
|
||||
layoutContainer.append(videoContainer);
|
||||
}
|
||||
|
||||
return videoContainer;
|
||||
}
|
||||
|
||||
function checkBtnsRecordings() {
|
||||
if (document.getElementById('forceRecordingId').value === '') {
|
||||
document.getElementById('buttonStopRecording').disabled = true;
|
||||
} else {
|
||||
document.getElementById('buttonStopRecording').disabled = false;
|
||||
}
|
||||
function appendParticipantData(videoContainer, participantIdentity) {
|
||||
const dataElement = document.createElement("div");
|
||||
dataElement.className = "participant-data";
|
||||
dataElement.innerHTML = `<p>${participantIdentity}</p>`;
|
||||
videoContainer.prepend(dataElement);
|
||||
}
|
||||
|
||||
function addIndividualRecordingButton(elementId, videoTrackId, audioTrackId) {
|
||||
const div = document.createElement('div');
|
||||
|
||||
var button = document.createElement('button');
|
||||
// button.id = elementId + '-button';
|
||||
button.className = 'recording-track-button btn btn-sm';
|
||||
|
||||
button.innerHTML = 'Record Track';
|
||||
button.style = 'position: absolute; left: 0; z-index: 1000;';
|
||||
|
||||
button.onclick = async () => {
|
||||
if (button.innerHTML === 'Record Track') {
|
||||
button.innerHTML = 'Stop Recording';
|
||||
button.className = 'recording-track-button btn btn-sm btn-danger';
|
||||
var res = await startIndividualRecording(videoTrackId, audioTrackId);
|
||||
button.id = res.info.egressId;
|
||||
} else {
|
||||
button.innerHTML = 'Record Track';
|
||||
button.className = 'recording-track-button btn btn-sm';
|
||||
stopRecording(button.id);
|
||||
}
|
||||
};
|
||||
div.appendChild(button);
|
||||
var element = document.getElementById(elementId);
|
||||
element.parentNode.insertBefore(div, element.nextSibling);
|
||||
function removeVideoContainer(participantIdentity) {
|
||||
const videoContainer = document.getElementById(`camera-${participantIdentity}`);
|
||||
videoContainer?.remove();
|
||||
}
|
||||
|
||||
function clearHttpTextarea() {
|
||||
$('#textarea-http').text('');
|
||||
function removeAllLayoutElements() {
|
||||
const layoutElements = document.getElementById("layout-container").children;
|
||||
Array.from(layoutElements).forEach((element) => {
|
||||
element.remove();
|
||||
});
|
||||
}
|
||||
|
||||
/* APPLICATION BROWSER METHODS */
|
||||
/**
|
||||
* --------------------------------------------
|
||||
* GETTING A TOKEN FROM YOUR APPLICATION SERVER
|
||||
* --------------------------------------------
|
||||
* The method below request the creation of a token to
|
||||
* your application server. This prevents the need to expose
|
||||
* your LiveKit API key and secret to the client side.
|
||||
*
|
||||
* In this sample code, there is no user control at all. Anybody could
|
||||
* access your application server endpoints. In a real production
|
||||
* environment, your application server must identify the user to allow
|
||||
* access to the endpoints.
|
||||
*/
|
||||
async function getToken(roomName, participantName) {
|
||||
const response = await fetch("/token", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName,
|
||||
participantName
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(`Failed to get token: ${error.errorMessage}`);
|
||||
}
|
||||
|
||||
const token = await response.json();
|
||||
return token.token;
|
||||
}
|
||||
|
||||
async function openRecordingsDialog() {
|
||||
const recordingsDialog = document.getElementById("recordings-dialog");
|
||||
recordingsDialog.showModal();
|
||||
await updateRecordingInfo(room.isRecording);
|
||||
}
|
||||
|
||||
function closeRecordingsDialog() {
|
||||
const recordingsDialog = document.getElementById("recordings-dialog");
|
||||
recordingsDialog.close();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("recordings-dialog").addEventListener("close", () => {
|
||||
const recordingVideo = document.getElementById("recording-video");
|
||||
|
||||
if (recordingVideo) {
|
||||
recordingVideo.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function updateRecordingInfo(isRecording) {
|
||||
const recordingButton = document.getElementById("recording-button");
|
||||
const recordingText = document.getElementById("recording-text");
|
||||
|
||||
if (isRecording) {
|
||||
recordingButton.disabled = false;
|
||||
recordingButton.innerText = "Stop Recording";
|
||||
recordingButton.className = "btn btn-danger";
|
||||
recordingText.hidden = false;
|
||||
} else {
|
||||
recordingButton.disabled = false;
|
||||
recordingButton.innerText = "Start Recording";
|
||||
recordingButton.className = "btn btn-primary";
|
||||
recordingText.hidden = true;
|
||||
}
|
||||
|
||||
await listRecordings();
|
||||
}
|
||||
|
||||
async function manageRecording() {
|
||||
const recordingButton = document.getElementById("recording-button");
|
||||
|
||||
if (recordingButton.innerText === "Start Recording") {
|
||||
recordingButton.disabled = true;
|
||||
recordingButton.innerText = "Starting...";
|
||||
await startRecording();
|
||||
} else {
|
||||
recordingButton.disabled = true;
|
||||
recordingButton.innerText = "Stopping...";
|
||||
await stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
async function startRecording() {
|
||||
const response = await fetch("/recordings/start", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName: room.name
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function stopRecording() {
|
||||
const response = await fetch("/recordings/stop", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName: room.name
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRecording(recordingName) {
|
||||
const response = await fetch(`/recordings/${recordingName}`, {
|
||||
method: "DELETE"
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
await listRecordings();
|
||||
}
|
||||
|
||||
async function listRecordings() {
|
||||
const response = await fetch(`/recordings?roomName=${room.name}`);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
const body = await response.json();
|
||||
const recordings = body.recordings;
|
||||
|
||||
showRecordingList(recordings);
|
||||
}
|
||||
|
||||
function showRecordingList(recordings) {
|
||||
const recordingsList = document.getElementById("recording-list");
|
||||
|
||||
if (recordings.length === 0) {
|
||||
recordingsList.innerHTML = "<span>There are no recordings available</span>";
|
||||
} else {
|
||||
recordingsList.innerHTML = "";
|
||||
}
|
||||
|
||||
recordings.forEach((recording) => {
|
||||
const recordingName = recording.name;
|
||||
const recordingDuration = secondsToHms(recording.duration);
|
||||
const recordingSize = formatBytes(recording.size);
|
||||
const recordingDate = new Date(recording.startedAt).toLocaleString();
|
||||
|
||||
const recordingContainer = document.createElement("div");
|
||||
recordingContainer.className = "recording-container";
|
||||
recordingContainer.id = recordingName;
|
||||
|
||||
recordingContainer.innerHTML = `
|
||||
<i class="fa-solid fa-file-video"></i>
|
||||
<div class="recording-info">
|
||||
<p class="recording-name">${recordingName}</p>
|
||||
<p class="recording-details">${recordingDuration} | ${recordingSize}</p>
|
||||
<p class="recording-date">${recordingDate}</p>
|
||||
</div>
|
||||
<div class="recording-actions">
|
||||
<button title="Play" class="icon-button" onclick="displayRecording('${recordingName}')">
|
||||
<i class="fa-solid fa-play"></i>
|
||||
</button>
|
||||
<button title="Delete" class="icon-button delete-button" onclick="deleteRecording('${recordingName}')">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
recordingsList.append(recordingContainer);
|
||||
});
|
||||
}
|
||||
|
||||
function displayRecording(recordingName) {
|
||||
const recordingContainer = document.getElementById("recording-video-container");
|
||||
let recordingVideo = document.getElementById("recording-video");
|
||||
|
||||
if (!recordingVideo) {
|
||||
recordingVideo = document.createElement("video");
|
||||
recordingVideo.id = "recording-video";
|
||||
recordingVideo.width = 600;
|
||||
recordingVideo.controls = true;
|
||||
recordingVideo.autoplay = true;
|
||||
recordingContainer.append(recordingVideo);
|
||||
}
|
||||
|
||||
recordingVideo.src = `/recordings/${recordingName}`;
|
||||
}
|
||||
|
||||
function secondsToHms(seconds) {
|
||||
const h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = Math.floor((seconds % 3600) % 60);
|
||||
|
||||
const hDisplay = h > 0 ? h + "h " : "";
|
||||
const mDisplay = m > 0 ? m + "m " : "";
|
||||
const sDisplay = s + "s";
|
||||
return hDisplay + mDisplay + sDisplay;
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
if (bytes === 0) {
|
||||
return "0Bytes";
|
||||
}
|
||||
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const decimals = i < 2 ? 0 : 1;
|
||||
|
||||
return (bytes / Math.pow(k, i)).toFixed(decimals) + sizes[i];
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
@ -1,121 +1,104 @@
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>OpenVidu Recording</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
|
||||
|
||||
<head>
|
||||
<title>openvidu-recording-node</title>
|
||||
<!-- Bootstrap -->
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8">
|
||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
|
||||
<!-- Font Awesome -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
|
||||
integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
|
||||
crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
|
||||
crossorigin="anonymous">
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
|
||||
crossorigin="anonymous"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/livekit-client@2.5.0/dist/livekit-client.umd.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</head>
|
||||
|
||||
<link rel="styleSheet" href="style.css" type="text/css" media="screen">
|
||||
<script src="https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js"></script>
|
||||
<script src="app.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip({
|
||||
html: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<a href="/" title="Home"><h1>OpenVidu Recording</h1></a>
|
||||
<div id="links">
|
||||
<a
|
||||
href="https://github.com/OpenVidu/openvidu-livekit-tutorials/tree/master/advanced-features/openvidu-recording"
|
||||
title="GitHub Repository"
|
||||
target="_blank"
|
||||
>
|
||||
<i class="fa-brands fa-github"></i>
|
||||
</a>
|
||||
<a
|
||||
href="https://livekit-tutorials.openvidu.io/tutorials/advanced-tutorials/openvidu-recording/"
|
||||
title="Documentation"
|
||||
target="_blank"
|
||||
>
|
||||
<i class="fa-solid fa-book"></i>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<div id="join">
|
||||
<div id="join-dialog">
|
||||
<h2>Join a Video Room</h2>
|
||||
<form onsubmit="joinRoom(); return false">
|
||||
<div>
|
||||
<label for="participant-name">Participant</label>
|
||||
<input id="participant-name" class="form-control" type="text" required />
|
||||
</div>
|
||||
<div>
|
||||
<label for="room-name">Room</label>
|
||||
<input id="room-name" class="form-control" type="text" required />
|
||||
</div>
|
||||
<button id="join-button" class="btn btn-lg btn-success" type="submit">Join!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img class="demo-logo" src="images/openvidu_vert_white_bg_trans_cropped.png" /> Recording Node</a>
|
||||
<a class="navbar-brand nav-icon" href="https://github.com/OpenVidu/openvidu-livekit-tutorials/tree/master/openvidu-recording-node"
|
||||
title="GitHub Repository" target="_blank">
|
||||
<i class="fa fa-github" aria-hidden="true"></i>
|
||||
</a>
|
||||
<a class="navbar-brand nav-icon" href="#" title="Documentation"
|
||||
target="_blank">
|
||||
<i class="fa fa-book" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="main-container" class="container">
|
||||
<div id="join" class="vertical-center">
|
||||
<div id="img-div">
|
||||
<img src="images/openvidu_grey_bg_transp_cropped.png" />
|
||||
</div>
|
||||
<div id="join-dialog" class="jumbotron">
|
||||
<h1>Join a video room</h1>
|
||||
<form class="form-group" onsubmit="return false">
|
||||
<p>
|
||||
<label>Room</label>
|
||||
<input class="form-control" type="text" id="roomName" value="RoomA" required>
|
||||
</p>
|
||||
<p class="text-center">
|
||||
<button class="btn btn-lg btn-success" id="join-btn" onclick="joinRoom()">Join!</button>
|
||||
</p>
|
||||
</form>
|
||||
<hr>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="room" style="display: none">
|
||||
<div id="room-header">
|
||||
<h1 id="room-title"></h1>
|
||||
<input class="btn btn-sm btn-danger" type="button" id="buttonLeaveRoom" onmouseup="leaveRoom()"
|
||||
value="Leave room">
|
||||
</div>
|
||||
<div id="video-container" class="col-md-12"></div>
|
||||
<div id="recording-btns">
|
||||
<div class="btns">
|
||||
<input class="btn btn-md" type="button" id="buttonStartRecording" onmouseup="startComposedRecording()" value="Start Composed recording">
|
||||
<form>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" id="has-audio-checkbox" checked>Has audio
|
||||
</label>
|
||||
<label class="checkbox-inline">
|
||||
<input type="checkbox" id="has-video-checkbox" checked>Has video
|
||||
</label>
|
||||
</form>
|
||||
</div>
|
||||
<div class="btns">
|
||||
<input class="btn btn-md" type="button" id="buttonListRecording" onmouseup="listRecordings()" value="List recordings">
|
||||
<div class="vertical-separator-bottom"></div>
|
||||
<input class="btn btn-md btn-danger" type="button" id="buttonStopRecording" onmouseup="stopRecording()" value="Stop recording"
|
||||
disabled>
|
||||
<input class="form-control" id="forceRecordingId" type="text" onkeyup="checkBtnsRecordings()">
|
||||
</div>
|
||||
<div class="textarea-container" id="textarea-http-container">
|
||||
<button type="button" class="btn btn-outline-secondary" id="clear-http-btn" onclick="clearHttpTextarea()">Clear</button>
|
||||
<span>HTTP responses</span>
|
||||
<textarea id="textarea-http" readonly="true" class="form-control" name="textarea-http"></textarea>
|
||||
</div>
|
||||
<div class="textarea-container" id="recordings-list-container">
|
||||
<button type="button" class="btn btn-md btn-danger" id="delete-recordings-btn" onclick="deleteRecordings()" disabled>Delete All</button>
|
||||
<span>Recordings list</span>
|
||||
<ul id="recording-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<div class="text-muted">OpenVidu © 2023</div>
|
||||
<a href="http://www.openvidu.io/" target="_blank">
|
||||
<img class="openvidu-logo" src="images/openvidu_globe_bg_transp_cropped.png" />
|
||||
</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
<div id="room" hidden>
|
||||
<div id="room-header">
|
||||
<h2 id="room-title"></h2>
|
||||
<button class="btn btn-primary" id="open-recordings-dialog" onclick="openRecordingsDialog()">
|
||||
Recordings
|
||||
</button>
|
||||
<button class="btn btn-danger" id="leave-room-button" onclick="leaveRoom()">Leave Room</button>
|
||||
</div>
|
||||
<div id="layout-container"></div>
|
||||
<dialog id="recordings-dialog">
|
||||
<h2>Recordings</h2>
|
||||
<div id="recording-controls">
|
||||
<button class="btn btn-primary" id="recording-button" onclick="manageRecording()">Start Recording</button>
|
||||
<div id="recording-text" hidden>Room is being recorded</div>
|
||||
</div>
|
||||
<div id="recording-video-container"></div>
|
||||
<div id="recording-list"></div>
|
||||
<button class="btn btn-secondary" id="close-recordings-dialog" onclick="closeRecordingsDialog()">Close</button>
|
||||
</dialog>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p class="text">Made with love by <span>OpenVidu Team</span></p>
|
||||
<a href="https://openvidu.io/" target="_blank">
|
||||
<img id="openvidu-logo" src="images/openvidu_logo.png" alt="OpenVidu logo" />
|
||||
</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,474 +0,0 @@
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
nav {
|
||||
height: 50px;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
background-color: #4d4d4d !important;
|
||||
border-color: #4d4d4d !important;
|
||||
border-top-right-radius: 0 !important;
|
||||
border-top-left-radius: 0 !important;
|
||||
}
|
||||
|
||||
.navbar-header {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
padding: 5px 15px 5px 15px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
nav a {
|
||||
color: #ccc !important;
|
||||
}
|
||||
|
||||
nav i.fa {
|
||||
font-size: 40px;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
nav a:hover {
|
||||
color: #a9a9a9 !important;
|
||||
}
|
||||
|
||||
nav i.fa:hover {
|
||||
color: #a9a9a9;
|
||||
}
|
||||
|
||||
#main-container {
|
||||
padding-bottom: 80px;
|
||||
height: 100%;
|
||||
margin-top: -70px;
|
||||
}
|
||||
|
||||
.vertical-center {
|
||||
width: -webkit-fit-content;
|
||||
width: fit-content;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.vertical-center#not-logged form {
|
||||
width: -moz-fit-content;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.vertical-center#not-logged table {
|
||||
width: -moz-fit-content;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.vertical-center table {
|
||||
margin-top: 3em !important;
|
||||
}
|
||||
|
||||
.horizontal-center {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
color: #0088aa;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
border-color: #0088aa;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
|
||||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(0, 136, 170, 0.6);
|
||||
}
|
||||
|
||||
input.btn {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.btn {
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background-color: #06d362 !important;
|
||||
border-color: #06d362;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background-color: #1abd61 !important;
|
||||
border-color: #1abd61;
|
||||
}
|
||||
|
||||
.btn-info {
|
||||
background-color: #0088aa !important;
|
||||
border-color: #0088aa;
|
||||
}
|
||||
|
||||
.btn-info:hover {
|
||||
background-color: #00708c !important;
|
||||
border-color: #00708c;
|
||||
}
|
||||
|
||||
.btn-warning {
|
||||
background-color: #ffcc00 !important;
|
||||
border-color: #ffcc00;
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.btn-warning:hover {
|
||||
background-color: #eabb3a !important;
|
||||
border-color: #eabb3a;
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.btn-warning:active {
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.btn-warning:focus {
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.btn-warning:active:focus {
|
||||
color: #4d4d4d;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
background-color: #4d4d4d;
|
||||
}
|
||||
|
||||
.footer .text-muted {
|
||||
margin: 20px 0;
|
||||
float: left;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.openvidu-logo {
|
||||
height: 35px;
|
||||
float: right;
|
||||
margin: 12px 0;
|
||||
-webkit-transition: all 0.1s ease-in-out;
|
||||
-moz-transition: all 0.1s ease-in-out;
|
||||
-o-transition: all 0.1s ease-in-out;
|
||||
transition: all 0.1s ease-in-out;
|
||||
}
|
||||
|
||||
.openvidu-logo:hover {
|
||||
-webkit-filter: grayscale(0.5);
|
||||
filter: grayscale(0.5);
|
||||
}
|
||||
|
||||
.demo-logo {
|
||||
margin: 0;
|
||||
height: 22px;
|
||||
float: left;
|
||||
padding-right: 8px;
|
||||
}
|
||||
|
||||
a:hover .demo-logo {
|
||||
-webkit-filter: brightness(0.7);
|
||||
filter: brightness(0.7);
|
||||
}
|
||||
|
||||
#join {
|
||||
padding-top: 40px;
|
||||
}
|
||||
|
||||
#not-logged {
|
||||
padding-top: 40px;
|
||||
}
|
||||
|
||||
#join-dialog h1 {
|
||||
color: #4d4d4d;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#join-dialog label {
|
||||
color: #0088aa;
|
||||
}
|
||||
|
||||
#join-dialog input.btn {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
#join-dialog hr {
|
||||
background: #4d4d4d;
|
||||
}
|
||||
|
||||
#img-div {
|
||||
text-align: center;
|
||||
padding-bottom: 3em;
|
||||
}
|
||||
|
||||
#img-div img {
|
||||
height: 15%;
|
||||
}
|
||||
|
||||
#logged {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#join {
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
#room-header {
|
||||
margin-bottom: 20px;
|
||||
height: 8%;
|
||||
margin-top: 70px;
|
||||
}
|
||||
|
||||
#room-header form {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#room-header input.btn {
|
||||
float: right;
|
||||
margin-top: 20px;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#room-title {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#room-header .form-control {
|
||||
width: initial;
|
||||
float: right;
|
||||
margin: 18px 0px 0px 5px;
|
||||
}
|
||||
|
||||
#video-container {
|
||||
width: 100%;
|
||||
max-height: 42%;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#video-container video.two {
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
#video-container video.three {
|
||||
max-width: 33.33%;
|
||||
}
|
||||
|
||||
#video-container video.four {
|
||||
max-width: 25%;
|
||||
}
|
||||
|
||||
#video-container div {
|
||||
position: absolute;
|
||||
display: inline-flex;
|
||||
margin-left: calc(-50% + 15px);
|
||||
}
|
||||
|
||||
#video-container p {
|
||||
display: inline-block;
|
||||
background: #f8f8f8;
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
color: #777777;
|
||||
font-weight: bold;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
#video-container p.userName {
|
||||
float: right;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 0px;
|
||||
font-weight: lighter;
|
||||
font-size: 12px;
|
||||
background: #777777;
|
||||
color: #f8f8f8;
|
||||
}
|
||||
|
||||
video {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-height: 100%;
|
||||
object-fit: scale-down;
|
||||
}
|
||||
|
||||
#room {
|
||||
height: 100%;
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
#room img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: inline-block;
|
||||
object-fit: contain;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
#room #video-container img {
|
||||
position: relative;
|
||||
float: left;
|
||||
width: 50%;
|
||||
cursor: pointer;
|
||||
object-fit: cover;
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
table i {
|
||||
cursor: pointer;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#tooltip-div {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#tooltip-div hr {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
#login-info {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#login-info form {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#login-info div {
|
||||
display: inline;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
#name-user {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#recording-btns {
|
||||
display: inline-block;
|
||||
padding-left: 15px;
|
||||
padding-top: 20px;
|
||||
width: 100%;
|
||||
height: 40%;
|
||||
}
|
||||
|
||||
#recording-btns .btns {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
#recording-btns .btns .form-control {
|
||||
width: initial;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
#recording-btns .btns form {
|
||||
display: inline;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#recording-btns textarea {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.textarea-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
height: 74%;
|
||||
margin-top: 20px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
#textarea-http-container {
|
||||
width: 59%;
|
||||
}
|
||||
|
||||
#recordings-list-container {
|
||||
width: 39%;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.textarea-container button {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
right: 1px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.textarea-container span {
|
||||
position: absolute;
|
||||
bottom: 1px;
|
||||
right: 1px;
|
||||
padding: 3px;
|
||||
border-bottom-right-radius: 4px;
|
||||
z-index: 1;
|
||||
color: #a5a5a5;
|
||||
background-color: #ededee;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.textarea-container textarea {
|
||||
height: 100%;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.vertical-separator-bottom {
|
||||
width: 2px;
|
||||
height: 34px;
|
||||
display: inline-block;
|
||||
background-color: #cbcbcb;
|
||||
margin: 0 8px 0 8px;
|
||||
margin-bottom: -12px;
|
||||
}
|
||||
|
||||
.vertical-separator-top {
|
||||
width: 2px;
|
||||
height: 30px;
|
||||
background-color: #cbcbcb;
|
||||
margin: 20px 8px 0 15px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* xs ans md screen resolutions*/
|
||||
|
||||
@media screen and (max-width: 991px) {
|
||||
#join {
|
||||
padding-top: inherit;
|
||||
}
|
||||
|
||||
#not-logged {
|
||||
padding-top: inherit;
|
||||
}
|
||||
|
||||
.container .navbar-header {
|
||||
margin-right: 0 !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
padding: 9px 8px 9px 8px;
|
||||
}
|
||||
|
||||
nav i.fa {
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
.vertical-center {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
#img-div {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
#img-div img {
|
||||
height: 10%;
|
||||
}
|
||||
}
|
||||
@ -1,200 +0,0 @@
|
||||
/* CONFIGURATION */
|
||||
require('dotenv').config(
|
||||
!!process.env.CONFIG ? { path: process.env.CONFIG } : {}
|
||||
);
|
||||
// For demo purposes we ignore self-signed certificate
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
||||
|
||||
// Node imports
|
||||
const express = require('express');
|
||||
const fs = require('fs');
|
||||
var path = require('path');
|
||||
const https = require('https');
|
||||
const bodyParser = require('body-parser');
|
||||
const AccessToken = require('livekit-server-sdk').AccessToken;
|
||||
const EgressClient = require('livekit-server-sdk').EgressClient;
|
||||
const cors = require('cors');
|
||||
const app = express();
|
||||
|
||||
// Environment variable: PORT where the node server is listening
|
||||
const SERVER_PORT = process.env.SERVER_PORT || 5000;
|
||||
// Environment variable: api key shared with our LiveKit deployment
|
||||
const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY || 'devkey';
|
||||
// Environment variable: api secret shared with our LiveKit deployment
|
||||
const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET || 'secret';
|
||||
// Environment variable: url of our LiveKit deployment
|
||||
const LIVEKIT_URL = process.env.LIVEKIT_URL || 'ws://localhost:7880';
|
||||
// Environment variable: path where the recordings will be stored
|
||||
const RECORDINGS_PATH = process.env.RECORDINGS_PATH || '/recordings';
|
||||
|
||||
// Listen (start app with node server.js)
|
||||
const options = {
|
||||
key: fs.readFileSync('openvidukey.pem'),
|
||||
cert: fs.readFileSync('openviducert.pem'),
|
||||
};
|
||||
|
||||
const livekitUrlHostname = LIVEKIT_URL.replace(/^ws:/, 'http:').replace(
|
||||
/^wss:/,
|
||||
'https:'
|
||||
);
|
||||
const egressClient = new EgressClient(
|
||||
livekitUrlHostname,
|
||||
LIVEKIT_API_KEY,
|
||||
LIVEKIT_API_SECRET
|
||||
);
|
||||
|
||||
// Enable CORS support
|
||||
app.use(
|
||||
cors({
|
||||
origin: '*',
|
||||
})
|
||||
);
|
||||
|
||||
// Set the static files location
|
||||
app.use(express.static(__dirname + '/public'));
|
||||
// Parse application/x-www-form-urlencoded
|
||||
app.use(
|
||||
bodyParser.urlencoded({
|
||||
extended: 'true',
|
||||
})
|
||||
);
|
||||
// Parse application/json
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// Parse application/vnd.api+json as json
|
||||
app.use(
|
||||
bodyParser.json({
|
||||
type: 'application/vnd.api+json',
|
||||
})
|
||||
);
|
||||
|
||||
https.createServer(options, app).listen(SERVER_PORT, () => {
|
||||
console.log(`App listening on port ${SERVER_PORT}`);
|
||||
console.log(`LIVEKIT API KEY: ${LIVEKIT_API_KEY}`);
|
||||
console.log(`LIVEKIT API SECRET: ${LIVEKIT_API_SECRET}`);
|
||||
console.log(`LIVEKIT URL: ${LIVEKIT_URL}`);
|
||||
console.log();
|
||||
console.log('Access the app at https://localhost:' + SERVER_PORT);
|
||||
});
|
||||
|
||||
/* Session API */
|
||||
|
||||
app.post('/token', (req, res) => {
|
||||
const { roomName, participantName } = req.body;
|
||||
|
||||
console.log(
|
||||
`Getting a token for room '${roomName}' and participant '${participantName}'`
|
||||
);
|
||||
|
||||
if (!roomName || !participantName) {
|
||||
res
|
||||
.status(400)
|
||||
.json({ message: 'roomName and participantName are required' });
|
||||
return;
|
||||
}
|
||||
|
||||
const at = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, {
|
||||
identity: participantName,
|
||||
// add metadata to the token, which will be available in the participant's metadata
|
||||
metadata: JSON.stringify({ livekitUrl: LIVEKIT_URL }),
|
||||
});
|
||||
at.addGrant({
|
||||
roomJoin: true,
|
||||
room: roomName,
|
||||
});
|
||||
res.status(200).json({ token: at.toJwt() });
|
||||
});
|
||||
|
||||
/* Recording API */
|
||||
|
||||
// Start recording
|
||||
app.post('/recordings/start', async function (req, res) {
|
||||
const {
|
||||
roomName,
|
||||
outputMode,
|
||||
videoOnly,
|
||||
audioOnly,
|
||||
audioTrackId,
|
||||
videoTrackId,
|
||||
} = req.body;
|
||||
const output = {
|
||||
fileType: 0, // file type chosen based on codecs
|
||||
filepath: `/recordings/${roomName}-${new Date().getTime()}`,
|
||||
disableManifest: true,
|
||||
};
|
||||
console.log('Starting recording', roomName);
|
||||
try {
|
||||
let egressInfo;
|
||||
if (outputMode === 'COMPOSED') {
|
||||
console.log('Starting COMPOSED recording', roomName);
|
||||
egressInfo = await egressClient.startRoomCompositeEgress(
|
||||
roomName,
|
||||
output,
|
||||
{
|
||||
layout: 'grid',
|
||||
audioOnly,
|
||||
videoOnly,
|
||||
}
|
||||
);
|
||||
} else if (outputMode === 'INDIVIDUAL') {
|
||||
console.log('Starting INDIVIDUAL recording', roomName);
|
||||
egressInfo = await egressClient.startTrackCompositeEgress(
|
||||
roomName,
|
||||
output,
|
||||
{
|
||||
audioTrackId,
|
||||
videoTrackId,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
res.status(400).json({ message: 'outputMode is required' });
|
||||
return;
|
||||
}
|
||||
res.status(200).json({ message: 'recording started', info: egressInfo });
|
||||
} catch (error) {
|
||||
console.log('Error starting recording', error);
|
||||
res.status(200).json({ message: 'error starting recording' });
|
||||
}
|
||||
});
|
||||
|
||||
// Stop recording
|
||||
app.post('/recordings/stop', async function (req, res) {
|
||||
const recordingId = req.body.recordingId;
|
||||
try {
|
||||
if (!recordingId) {
|
||||
res.status(400).json({ message: 'recordingId is required' });
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Stopping recording ${recordingId}`);
|
||||
const egressInfo = await egressClient.stopEgress(recordingId);
|
||||
res.status(200).json({ message: 'recording stopped', info: egressInfo });
|
||||
} catch (error) {
|
||||
console.log('Error stopping recording', error);
|
||||
res.status(200).json({ message: 'error stopping recording' });
|
||||
}
|
||||
});
|
||||
|
||||
// List all recordings
|
||||
app.get('/recordings/list', function (req, res) {
|
||||
const recordings = [];
|
||||
fs.readdirSync(RECORDINGS_PATH, { recursive: true }).forEach((value) => {
|
||||
// copy file to public folder for development purposes
|
||||
fs.copyFileSync(`${RECORDINGS_PATH}/${value}`, `public/${value}`);
|
||||
const newRec = { name: value, path: `/${value}` };
|
||||
recordings.push(newRec);
|
||||
});
|
||||
console.log(recordings);
|
||||
res.status(200).json({ recordings });
|
||||
});
|
||||
|
||||
// Delete all recordings
|
||||
app.delete('/recordings', function (req, res) {
|
||||
fs.readdirSync(RECORDINGS_PATH, { recursive: true }).forEach((value) => {
|
||||
fs.unlinkSync(`${RECORDINGS_PATH}/${value}`);
|
||||
if (fs.existsSync(`public/${value}`)) {
|
||||
fs.unlinkSync(`public/${value}`);
|
||||
}
|
||||
});
|
||||
res.status(200).json({ message: 'All recordings deleted' });
|
||||
});
|
||||
129
advanced-features/openvidu-recording/.gitignore
vendored
129
advanced-features/openvidu-recording/.gitignore
vendored
@ -1,129 +0,0 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# Snowpack dependency directory (https://snowpack.dev/)
|
||||
web_modules/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional stylelint cache
|
||||
.stylelintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variable files
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
.parcel-cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
out
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# vuepress v2.x temp and cache directory
|
||||
.temp
|
||||
.cache
|
||||
|
||||
# Docusaurus cache and generated files
|
||||
.docusaurus
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
@ -1,30 +0,0 @@
|
||||
# OpenVidu Recording
|
||||
|
||||
Simple video-call application with recording capabilities. It includes a backend built with Node.js with Express and a frontend built with plain HTML, CSS and JavaScript.
|
||||
|
||||
For further information, check the [tutorial documentation](https://livekit-tutorials.openvidu.io/tutorials/advanced-tutorials/node/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Node](https://nodejs.org/en/download)
|
||||
|
||||
## Run
|
||||
|
||||
1. Download repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/OpenVidu/openvidu-livekit-tutorials.git
|
||||
cd openvidu-livekit-tutorials/advanced-features/openvidu-recording
|
||||
```
|
||||
|
||||
2. Install dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. Run the application
|
||||
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
2543
advanced-features/openvidu-recording/package-lock.json
generated
2543
advanced-features/openvidu-recording/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "openvidu-recording",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple video-call application with recording capabilities",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.635.0",
|
||||
"cors": "2.8.5",
|
||||
"dotenv": "16.4.5",
|
||||
"express": "4.19.2",
|
||||
"livekit-server-sdk": "2.6.1"
|
||||
}
|
||||
}
|
||||
@ -1,381 +0,0 @@
|
||||
// When running OpenVidu locally, leave this variable empty
|
||||
// For other deployment type, configure it with correct URL depending on your deployment
|
||||
var LIVEKIT_URL = "";
|
||||
configureLiveKitUrl();
|
||||
|
||||
const LivekitClient = window.LivekitClient;
|
||||
var room;
|
||||
|
||||
function configureLiveKitUrl() {
|
||||
// If LIVEKIT_URL is not configured, use default value from OpenVidu Local deployment
|
||||
if (!LIVEKIT_URL) {
|
||||
if (window.location.hostname === "localhost") {
|
||||
LIVEKIT_URL = "ws://localhost:7880/";
|
||||
} else {
|
||||
LIVEKIT_URL = "wss://" + window.location.hostname + ":7443/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function joinRoom() {
|
||||
// Disable 'Join' button
|
||||
document.getElementById("join-button").disabled = true;
|
||||
document.getElementById("join-button").innerText = "Joining...";
|
||||
|
||||
// Initialize a new Room object
|
||||
room = new LivekitClient.Room();
|
||||
|
||||
// Specify the actions when events take place in the room
|
||||
// On every new Track received...
|
||||
room.on(LivekitClient.RoomEvent.TrackSubscribed, (track, _publication, participant) => {
|
||||
addTrack(track, participant.identity);
|
||||
});
|
||||
|
||||
// On every new Track destroyed...
|
||||
room.on(LivekitClient.RoomEvent.TrackUnsubscribed, (track, _publication, participant) => {
|
||||
track.detach();
|
||||
document.getElementById(track.sid)?.remove();
|
||||
|
||||
if (track.kind === "video") {
|
||||
removeVideoContainer(participant.identity);
|
||||
}
|
||||
});
|
||||
|
||||
room.on(LivekitClient.RoomEvent.RecordingStatusChanged, async (isRecording) => {
|
||||
await updateRecordingInfo(isRecording);
|
||||
});
|
||||
|
||||
try {
|
||||
// Get the room name and participant name from the form
|
||||
const roomName = document.getElementById("room-name").value;
|
||||
const userName = document.getElementById("participant-name").value;
|
||||
|
||||
// Get a token from your application server with the room name and participant name
|
||||
const token = await getToken(roomName, userName);
|
||||
|
||||
// Connect to the room with the LiveKit URL and the token
|
||||
await room.connect(LIVEKIT_URL, token);
|
||||
|
||||
// Hide the 'Join room' page and show the 'Room' page
|
||||
document.getElementById("room-title").innerText = roomName;
|
||||
document.getElementById("join").hidden = true;
|
||||
document.getElementById("room").hidden = false;
|
||||
|
||||
// Publish your camera and microphone
|
||||
await room.localParticipant.enableCameraAndMicrophone();
|
||||
const localVideoTrack = this.room.localParticipant.videoTrackPublications.values().next().value.track;
|
||||
addTrack(localVideoTrack, userName, true);
|
||||
} catch (error) {
|
||||
console.log("There was an error connecting to the room:", error.message);
|
||||
await leaveRoom();
|
||||
}
|
||||
}
|
||||
|
||||
function addTrack(track, participantIdentity, local = false) {
|
||||
const element = track.attach();
|
||||
element.id = track.sid;
|
||||
|
||||
/* If the track is a video track, we create a container and append the video element to it
|
||||
with the participant's identity */
|
||||
if (track.kind === "video") {
|
||||
const videoContainer = createVideoContainer(participantIdentity, local);
|
||||
videoContainer.append(element);
|
||||
appendParticipantData(videoContainer, participantIdentity + (local ? " (You)" : ""));
|
||||
} else {
|
||||
document.getElementById("layout-container").append(element);
|
||||
}
|
||||
}
|
||||
|
||||
async function leaveRoom() {
|
||||
// Leave the room by calling 'disconnect' method over the Room object
|
||||
await room.disconnect();
|
||||
|
||||
// Remove all HTML elements inside the layout container
|
||||
removeAllLayoutElements();
|
||||
|
||||
// Back to 'Join room' page
|
||||
document.getElementById("join").hidden = false;
|
||||
document.getElementById("room").hidden = true;
|
||||
|
||||
// Enable 'Join' button
|
||||
document.getElementById("join-button").disabled = false;
|
||||
document.getElementById("join-button").innerText = "Join!";
|
||||
}
|
||||
|
||||
window.onbeforeunload = () => {
|
||||
room?.disconnect();
|
||||
};
|
||||
|
||||
window.onload = generateFormValues;
|
||||
|
||||
function generateFormValues() {
|
||||
document.getElementById("room-name").value = "Test Room";
|
||||
document.getElementById("participant-name").value = "Participant" + Math.floor(Math.random() * 100);
|
||||
}
|
||||
|
||||
function createVideoContainer(participantIdentity, local = false) {
|
||||
const videoContainer = document.createElement("div");
|
||||
videoContainer.id = `camera-${participantIdentity}`;
|
||||
videoContainer.className = "video-container";
|
||||
const layoutContainer = document.getElementById("layout-container");
|
||||
|
||||
if (local) {
|
||||
layoutContainer.prepend(videoContainer);
|
||||
} else {
|
||||
layoutContainer.append(videoContainer);
|
||||
}
|
||||
|
||||
return videoContainer;
|
||||
}
|
||||
|
||||
function appendParticipantData(videoContainer, participantIdentity) {
|
||||
const dataElement = document.createElement("div");
|
||||
dataElement.className = "participant-data";
|
||||
dataElement.innerHTML = `<p>${participantIdentity}</p>`;
|
||||
videoContainer.prepend(dataElement);
|
||||
}
|
||||
|
||||
function removeVideoContainer(participantIdentity) {
|
||||
const videoContainer = document.getElementById(`camera-${participantIdentity}`);
|
||||
videoContainer?.remove();
|
||||
}
|
||||
|
||||
function removeAllLayoutElements() {
|
||||
const layoutElements = document.getElementById("layout-container").children;
|
||||
Array.from(layoutElements).forEach((element) => {
|
||||
element.remove();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------
|
||||
* GETTING A TOKEN FROM YOUR APPLICATION SERVER
|
||||
* --------------------------------------------
|
||||
* The method below request the creation of a token to
|
||||
* your application server. This prevents the need to expose
|
||||
* your LiveKit API key and secret to the client side.
|
||||
*
|
||||
* In this sample code, there is no user control at all. Anybody could
|
||||
* access your application server endpoints. In a real production
|
||||
* environment, your application server must identify the user to allow
|
||||
* access to the endpoints.
|
||||
*/
|
||||
async function getToken(roomName, participantName) {
|
||||
const response = await fetch("/token", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName,
|
||||
participantName
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(`Failed to get token: ${error.errorMessage}`);
|
||||
}
|
||||
|
||||
const token = await response.json();
|
||||
return token.token;
|
||||
}
|
||||
|
||||
async function openRecordingsDialog() {
|
||||
const recordingsDialog = document.getElementById("recordings-dialog");
|
||||
recordingsDialog.showModal();
|
||||
await updateRecordingInfo(room.isRecording);
|
||||
}
|
||||
|
||||
function closeRecordingsDialog() {
|
||||
const recordingsDialog = document.getElementById("recordings-dialog");
|
||||
recordingsDialog.close();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("recordings-dialog").addEventListener("close", () => {
|
||||
const recordingVideo = document.getElementById("recording-video");
|
||||
|
||||
if (recordingVideo) {
|
||||
recordingVideo.remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function updateRecordingInfo(isRecording) {
|
||||
const recordingButton = document.getElementById("recording-button");
|
||||
const recordingText = document.getElementById("recording-text");
|
||||
|
||||
if (isRecording) {
|
||||
recordingButton.disabled = false;
|
||||
recordingButton.innerText = "Stop Recording";
|
||||
recordingButton.className = "btn btn-danger";
|
||||
recordingText.hidden = false;
|
||||
} else {
|
||||
recordingButton.disabled = false;
|
||||
recordingButton.innerText = "Start Recording";
|
||||
recordingButton.className = "btn btn-primary";
|
||||
recordingText.hidden = true;
|
||||
}
|
||||
|
||||
await listRecordings();
|
||||
}
|
||||
|
||||
async function manageRecording() {
|
||||
const recordingButton = document.getElementById("recording-button");
|
||||
|
||||
if (recordingButton.innerText === "Start Recording") {
|
||||
recordingButton.disabled = true;
|
||||
recordingButton.innerText = "Starting...";
|
||||
await startRecording();
|
||||
} else {
|
||||
recordingButton.disabled = true;
|
||||
recordingButton.innerText = "Stopping...";
|
||||
await stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
async function startRecording() {
|
||||
const response = await fetch("/recordings/start", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName: room.name
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function stopRecording() {
|
||||
const response = await fetch("/recordings/stop", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
roomName: room.name
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteRecording(recordingName) {
|
||||
const response = await fetch(`/recordings/${recordingName}`, {
|
||||
method: "DELETE"
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
await listRecordings();
|
||||
}
|
||||
|
||||
async function listRecordings() {
|
||||
const response = await fetch(`/recordings?roomName=${room.name}`);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
console.error(error.errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
const body = await response.json();
|
||||
const recordings = body.recordings;
|
||||
|
||||
showRecordingList(recordings);
|
||||
}
|
||||
|
||||
function showRecordingList(recordings) {
|
||||
const recordingsList = document.getElementById("recording-list");
|
||||
|
||||
if (recordings.length === 0) {
|
||||
recordingsList.innerHTML = "<span>There are no recordings available</span>";
|
||||
} else {
|
||||
recordingsList.innerHTML = "";
|
||||
}
|
||||
|
||||
recordings.forEach((recording) => {
|
||||
const recordingName = recording.name;
|
||||
const recordingDuration = secondsToHms(recording.duration);
|
||||
const recordingSize = formatBytes(recording.size);
|
||||
const recordingDate = new Date(recording.startedAt).toLocaleString();
|
||||
|
||||
const recordingContainer = document.createElement("div");
|
||||
recordingContainer.className = "recording-container";
|
||||
recordingContainer.id = recordingName;
|
||||
|
||||
recordingContainer.innerHTML = `
|
||||
<i class="fa-solid fa-file-video"></i>
|
||||
<div class="recording-info">
|
||||
<p class="recording-name">${recordingName}</p>
|
||||
<p class="recording-details">${recordingDuration} | ${recordingSize}</p>
|
||||
<p class="recording-date">${recordingDate}</p>
|
||||
</div>
|
||||
<div class="recording-actions">
|
||||
<button title="Play" class="icon-button" onclick="displayRecording('${recordingName}')">
|
||||
<i class="fa-solid fa-play"></i>
|
||||
</button>
|
||||
<button title="Delete" class="icon-button delete-button" onclick="deleteRecording('${recordingName}')">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
recordingsList.append(recordingContainer);
|
||||
});
|
||||
}
|
||||
|
||||
function displayRecording(recordingName) {
|
||||
const recordingContainer = document.getElementById("recording-video-container");
|
||||
let recordingVideo = document.getElementById("recording-video");
|
||||
|
||||
if (!recordingVideo) {
|
||||
recordingVideo = document.createElement("video");
|
||||
recordingVideo.id = "recording-video";
|
||||
recordingVideo.width = 600;
|
||||
recordingVideo.controls = true;
|
||||
recordingVideo.autoplay = true;
|
||||
recordingContainer.append(recordingVideo);
|
||||
}
|
||||
|
||||
recordingVideo.src = `/recordings/${recordingName}`;
|
||||
}
|
||||
|
||||
function secondsToHms(seconds) {
|
||||
const h = Math.floor(seconds / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = Math.floor((seconds % 3600) % 60);
|
||||
|
||||
const hDisplay = h > 0 ? h + "h " : "";
|
||||
const mDisplay = m > 0 ? m + "m " : "";
|
||||
const sDisplay = s + "s";
|
||||
return hDisplay + mDisplay + sDisplay;
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
if (bytes === 0) {
|
||||
return "0Bytes";
|
||||
}
|
||||
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
const decimals = i < 2 ? 0 : 1;
|
||||
|
||||
return (bytes / Math.pow(k, i)).toFixed(decimals) + sizes[i];
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.3 KiB |
@ -1,104 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>OpenVidu Recording</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
|
||||
<!-- Font Awesome -->
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css"
|
||||
integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A=="
|
||||
crossorigin="anonymous"
|
||||
referrerpolicy="no-referrer"
|
||||
/>
|
||||
|
||||
<link rel="stylesheet" href="styles.css" type="text/css" media="screen" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/livekit-client@2.5.0/dist/livekit-client.umd.js"></script>
|
||||
<script src="app.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<a href="/" title="Home"><h1>OpenVidu Recording</h1></a>
|
||||
<div id="links">
|
||||
<a
|
||||
href="https://github.com/OpenVidu/openvidu-livekit-tutorials/tree/master/advanced-features/openvidu-recording"
|
||||
title="GitHub Repository"
|
||||
target="_blank"
|
||||
>
|
||||
<i class="fa-brands fa-github"></i>
|
||||
</a>
|
||||
<a
|
||||
href="https://livekit-tutorials.openvidu.io/tutorials/advanced-tutorials/openvidu-recording/"
|
||||
title="Documentation"
|
||||
target="_blank"
|
||||
>
|
||||
<i class="fa-solid fa-book"></i>
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<div id="join">
|
||||
<div id="join-dialog">
|
||||
<h2>Join a Video Room</h2>
|
||||
<form onsubmit="joinRoom(); return false">
|
||||
<div>
|
||||
<label for="participant-name">Participant</label>
|
||||
<input id="participant-name" class="form-control" type="text" required />
|
||||
</div>
|
||||
<div>
|
||||
<label for="room-name">Room</label>
|
||||
<input id="room-name" class="form-control" type="text" required />
|
||||
</div>
|
||||
<button id="join-button" class="btn btn-lg btn-success" type="submit">Join!</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="room" hidden>
|
||||
<div id="room-header">
|
||||
<h2 id="room-title"></h2>
|
||||
<button class="btn btn-primary" id="open-recordings-dialog" onclick="openRecordingsDialog()">
|
||||
Recordings
|
||||
</button>
|
||||
<button class="btn btn-danger" id="leave-room-button" onclick="leaveRoom()">Leave Room</button>
|
||||
</div>
|
||||
<div id="layout-container"></div>
|
||||
<dialog id="recordings-dialog">
|
||||
<h2>Recordings</h2>
|
||||
<div id="recording-controls">
|
||||
<button class="btn btn-primary" id="recording-button" onclick="manageRecording()">Start Recording</button>
|
||||
<div id="recording-text" hidden>Room is being recorded</div>
|
||||
</div>
|
||||
<div id="recording-video-container"></div>
|
||||
<div id="recording-list"></div>
|
||||
<button class="btn btn-secondary" id="close-recordings-dialog" onclick="closeRecordingsDialog()">Close</button>
|
||||
</dialog>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<p class="text">Made with love by <span>OpenVidu Team</span></p>
|
||||
<a href="https://openvidu.io/" target="_blank">
|
||||
<img id="openvidu-logo" src="images/openvidu_logo.png" alt="OpenVidu logo" />
|
||||
</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user