Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
ParaEncode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ParaEncode
Commits
baaeb9f7
Commit
baaeb9f7
authored
Apr 26, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement Encoder.
parent
0bf24f43
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
4 deletions
+35
-4
encWW.js
src/workers/encWW.js
+35
-4
No files found.
src/workers/encWW.js
View file @
baaeb9f7
...
...
@@ -4,6 +4,7 @@ let isInited = false;
let
isBridged
=
false
;
let
src
=
null
;
let
bridge
=
null
;
let
size
=
null
;
// Number of bytes for each read
// from channel
...
...
@@ -34,6 +35,9 @@ async function main(msg) {
if
(
!
isInited
)
await
init
(
msg
);
break
;
case
MESSAGE_TYPE
.
BRIDGE
:
if
(
!
isBridged
)
await
bridging
(
msg
);
case
MESSAGE_TYPE
.
DATA
:
await
steps
();
break
;
...
...
@@ -44,6 +48,13 @@ async function main(msg) {
}
}
async
function
bridging
(
msg
)
{
let
info
=
getInfoFromMsg
(
msg
);
bridge
=
new
Channel
(
info
.
size
,
SharedArrayBuffer
,
info
.
shm
);
isBridged
=
true
;
}
async
function
init
(
msg
)
{
let
info
=
getInfoFromMsg
(
msg
);
src
=
new
Channel
(
info
.
size
,
SharedArrayBuffer
,
info
.
shm
);
...
...
@@ -53,8 +64,7 @@ async function init(msg) {
await
sleep
(
100
);
let
size
=
encoder
.
_malloc
(
4
);
let
mem
=
encoder
.
_encode
(
size
);
console
.
log
(
encoder
.
getValue
(
size
,
'i32'
));
let
ret
=
encoder
.
_encodeInit
(
1920
,
1080
,
30
);
isInited
=
true
;
}
...
...
@@ -65,9 +75,14 @@ async function init(msg) {
async
function
step
()
{
// Read RGB Frame from Channel.
let
data
=
src
.
readData
(
READ_SIZE
);
if
(
data
.
byteLength
==
0
)
{
return
false
;
}
/* RGB Frame Processing */
return
await
RGBProcessing
(
data
);
await
RGBProcessing
(
data
);
return
true
;
}
async
function
steps
()
{
...
...
@@ -98,9 +113,24 @@ async function steps() {
async
function
RGBProcessing
(
frame
)
{
// Encode RGB Frame into H264 Frame
let
h264frame
=
encoder
.
encode
(
frame
,
size
);
let
frameSize
=
encoder
.
getValue
(
size
,
'i32'
);
let
h264frame_
=
encoder
.
HEAP8
.
subarray
(
h264frame
,
h264frame
+
frameSize
);
// Push to Muxer
bridge
.
push
(
h264frame_
);
// To Check that is Muxer in executing
let
flag
=
bridge
.
readPriv
()
if
(
flag
&
PRIV_FLAGS
.
EXECUTING
==
0
)
{
// Muxer is idle, send a Data message to
// Muxer to wake it up.
postMessage
(
makeMsg
(
Data
,
{}));
}
return
fals
e
;
return
tru
e
;
}
...
...
@@ -396,6 +426,7 @@ const MESSAGE_TYPE = Object.freeze({
/* Notify to oppsite that there is datas
* within shared memory */
DATA
:
4
,
BRIDGE
:
5
,
MSG_MAX
:
5
,
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment