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
24cd1715
Commit
24cd1715
authored
May 12, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove Debug Printf
parent
64dbc5eb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
41 deletions
+38
-41
karma.conf.js
karma.conf.js
+4
-2
encWW.js
resources/workers/encWW.js
+0
-1
muxWW.js
resources/workers/muxWW.js
+0
-7
muxer.c
src/wasms/muxer.c
+27
-24
wasm-build.sh
wasm-build.sh
+7
-7
No files found.
karma.conf.js
View file @
24cd1715
...
@@ -22,7 +22,8 @@ module.exports = function(config) {
...
@@ -22,7 +22,8 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
// list of files / patterns to load in the browser
files
:
[
files
:
[
{
pattern
:
'./temp.debug.wasm'
,
included
:
false
,
served
:
true
},
{
pattern
:
'./muxer.debug.wasm'
,
included
:
false
,
served
:
true
},
{
pattern
:
'./encoder.debug.wasm'
,
included
:
false
,
served
:
true
},
{
pattern
:
'src/**/*.js'
,
included
:
false
,
served
:
true
},
{
pattern
:
'src/**/*.js'
,
included
:
false
,
served
:
true
},
{
pattern
:
'tests/**/*.js'
,
included
:
true
},
{
pattern
:
'tests/**/*.js'
,
included
:
true
},
{
pattern
:
'resources/**/*.js'
,
included
:
false
,
served
:
true
},
{
pattern
:
'resources/**/*.js'
,
included
:
false
,
served
:
true
},
...
@@ -36,7 +37,8 @@ module.exports = function(config) {
...
@@ -36,7 +37,8 @@ module.exports = function(config) {
'/src'
:
'/base/src/'
,
'/src'
:
'/base/src/'
,
'/resources'
:
'/base/resources/'
,
'/resources'
:
'/base/resources/'
,
'/workers'
:
'/base/tests/workers/'
,
'/workers'
:
'/base/tests/workers/'
,
'/temp.debug.wasm'
:
'/base/temp.debug.wasm'
'/muxer.debug.wasm'
:
'/base/muxer.debug.wasm'
,
'/encoder.debug.wasm'
:
'/base/encoder.debug.wasm'
,
},
},
// preprocess matching files before serving them to the browser
// preprocess matching files before serving them to the browser
...
...
resources/workers/encWW.js
View file @
24cd1715
...
@@ -211,7 +211,6 @@ async function RGBProcessing(frame) {
...
@@ -211,7 +211,6 @@ async function RGBProcessing(frame) {
// Unit of interval is millionsecond
// Unit of interval is millionsecond
async
function
sendToMuxerUntilSuccess
(
size
,
interval
)
{
async
function
sendToMuxerUntilSuccess
(
size
,
interval
)
{
console
.
log
(
"Send to Muxer"
);
while
(
!
sendToMuxer
(
size
))
{
while
(
!
sendToMuxer
(
size
))
{
await
sleep
(
interval
);
await
sleep
(
interval
);
}
}
...
...
resources/workers/muxWW.js
View file @
24cd1715
...
@@ -113,8 +113,6 @@ async function deBridging() {
...
@@ -113,8 +113,6 @@ async function deBridging() {
async
function
step
()
{
async
function
step
()
{
let
chn
=
undefined
;
let
chn
=
undefined
;
console
.
log
(
"Step"
);
// Read Datas
// Read Datas
for
(
let
i
=
0
;
i
<
numOfEncs
;
++
i
)
{
for
(
let
i
=
0
;
i
<
numOfEncs
;
++
i
)
{
...
@@ -123,13 +121,11 @@ async function step() {
...
@@ -123,13 +121,11 @@ async function step() {
chn
=
channels
[
i
];
chn
=
channels
[
i
];
let
data
=
chn
.
readData
(
MUX_BUFFER_SIZE
);
let
data
=
chn
.
readData
(
MUX_BUFFER_SIZE
);
console
.
log
(
"Mux Receive ("
+
data
.
byteLength
+
" Bytes ) "
+
data
)
if
(
data
.
byteLength
==
0
)
{
if
(
data
.
byteLength
==
0
)
{
// Check EOF
// Check EOF
let
flag
=
chn
.
readPriv
();
let
flag
=
chn
.
readPriv
();
if
(
flag
&
PRIV_FLAGS
.
EOF
)
{
if
(
flag
&
PRIV_FLAGS
.
EOF
)
{
console
.
log
(
"MUXER: EOF "
+
i
);
muxer
.
_eof
(
i
);
muxer
.
_eof
(
i
);
++
eofCount
;
++
eofCount
;
...
@@ -138,7 +134,6 @@ async function step() {
...
@@ -138,7 +134,6 @@ async function step() {
continue
;
continue
;
}
}
console
.
log
(
"MUXWW Push to "
+
i
+
" with length "
+
data
.
byteLength
);
/* Write data into wasm */
/* Write data into wasm */
muxBuffer
=
muxer
.
_malloc
(
data
.
byteLength
);
muxBuffer
=
muxer
.
_malloc
(
data
.
byteLength
);
...
@@ -149,7 +144,6 @@ async function step() {
...
@@ -149,7 +144,6 @@ async function step() {
// Handle Datas
// Handle Datas
done
=
muxer
.
_muxStep
();
done
=
muxer
.
_muxStep
();
console
.
log
(
"Mux step done"
)
return
true
;
return
true
;
}
}
...
@@ -158,7 +152,6 @@ async function steps() {
...
@@ -158,7 +152,6 @@ async function steps() {
inExec
=
true
;
inExec
=
true
;
while
(
await
step
())
{
while
(
await
step
())
{
console
.
log
(
"Done: "
+
done
);
if
(
done
)
if
(
done
)
break
;
break
;
await
sleep
(
SLEEP_INTERVAL
);
await
sleep
(
SLEEP_INTERVAL
);
...
...
src/wasms/muxer.c
View file @
24cd1715
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#define OK 0
#define OK 0
#define ERROR 1
#define ERROR 1
#define TERMINATED 2
typedef
enum
{
typedef
enum
{
...
@@ -37,12 +38,24 @@ static List *protos;
...
@@ -37,12 +38,24 @@ static List *protos;
static
List
*
ctxs
;
static
List
*
ctxs
;
static
PktBuffer
*
pktBuffer
;
static
PktBuffer
*
pktBuffer
;
void
protoNodeDestr
(
void
*
v
)
{
destroyMMProto
((
MMProto
**
)
&
v
);
}
void
ctxNodeDestr
(
void
*
v
)
{
streamClose
((
StreamContext
**
)
&
v
);
}
EM_PORT_API
(
int
)
muxInit
(
int
numOfStreams_
)
{
EM_PORT_API
(
int
)
muxInit
(
int
numOfStreams_
)
{
numOfStreams
=
numOfStreams_
;
numOfStreams
=
numOfStreams_
;
protos
=
createList
();
protos
=
createList
();
listSetDestructor
(
protos
,
protoNodeDestr
);
ctxs
=
createList
();
ctxs
=
createList
();
listSetDestructor
(
ctxs
,
ctxNodeDestr
);
pktBuffer
=
createPktBuffer
(
numOfStreams
);
pktBuffer
=
createPktBuffer
(
numOfStreams
);
for
(
int
i
=
0
;
i
<
numOfStreams
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numOfStreams
;
++
i
)
{
...
@@ -62,11 +75,8 @@ EM_PORT_API(int) muxPush(int sIdx, uint8_t *data, size_t size) {
...
@@ -62,11 +75,8 @@ EM_PORT_API(int) muxPush(int sIdx, uint8_t *data, size_t size) {
MMProto
*
p
=
listGet
(
protos
,
sIdx
);
MMProto
*
p
=
listGet
(
protos
,
sIdx
);
if
(
p
)
{
if
(
p
)
{
printf
(
"MUXER WASM: Proto %d Push Size %ld
\n
"
,
sIdx
,
size
);
mmpPush
(
p
,
data
,
size
);
mmpPush
(
p
,
data
,
size
);
printf
(
"MUXER WASM: Proto %d Buffer Size is %d
\n
"
,
sIdx
,
mmpBufferSize
(
p
));
}
else
{
}
else
{
printf
(
"MUXER WASM: muxPush fail to get proto %d
\n
"
,
sIdx
);
return
1
;
return
1
;
}
}
...
@@ -97,13 +107,10 @@ int buffering() {
...
@@ -97,13 +107,10 @@ int buffering() {
if
(
ctx
->
state
!=
CONTEXT_RUN
)
if
(
ctx
->
state
!=
CONTEXT_RUN
)
continue
;
continue
;
printf
(
"MUXER WASM: Buffer for context %d
\n
"
,
i
);
pkt
=
pkt
==
NULL
?
av_packet_alloc
()
:
pkt
;
pkt
=
pkt
==
NULL
?
av_packet_alloc
()
:
pkt
;
ret
=
streamReadFrame
(
ctx
->
sc
,
pkt
);
ret
=
streamReadFrame
(
ctx
->
sc
,
pkt
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
if
(
ret
==
AVERROR_EOF
)
{
if
(
ret
==
AVERROR_EOF
)
{
printf
(
"MUXER WASM: buffering() EOF
\n
"
);
ctx
->
state
=
CONTEXT_FIN
;
ctx
->
state
=
CONTEXT_FIN
;
pktBufPush
(
pktBuffer
,
i
,
createNULLPacket
());
pktBufPush
(
pktBuffer
,
i
,
createNULLPacket
());
break
;
break
;
...
@@ -112,7 +119,6 @@ int buffering() {
...
@@ -112,7 +119,6 @@ int buffering() {
continue
;
continue
;
}
}
printf
(
"MUXER WASM: BUFFER INTO %d
\n
"
,
i
);
/* Buffer the packet */
/* Buffer the packet */
pktBufPush
(
pktBuffer
,
i
,
pkt
);
pktBufPush
(
pktBuffer
,
i
,
pkt
);
pkt
=
NULL
;
pkt
=
NULL
;
...
@@ -149,15 +155,13 @@ int contextInitializes() {
...
@@ -149,15 +155,13 @@ int contextInitializes() {
ProtoInfo
info
=
{
ProtoInfo
info
=
{
.
proto
=
(
Proto
*
)
listGet
(
protos
,
i
),
.
proto
=
(
Proto
*
)
listGet
(
protos
,
i
),
.
destructor
=
(
ProtoDestructor
)
destroyMMProto
,
.
destructor
=
NULL
,
.
ofmt
=
NULL
.
ofmt
=
NULL
};
};
ctx
->
sc
=
createInStreamContext
(
""
,
info
,
AVMEDIA_TYPE_VIDEO
);
ctx
->
sc
=
createInStreamContext
(
""
,
info
,
AVMEDIA_TYPE_VIDEO
);
ctx
->
state
=
CONTEXT_RUN
;
ctx
->
state
=
CONTEXT_RUN
;
printf
(
"MUXER WASM: CONTEXT %d init
\n
"
,
i
);
++
initNum
;
++
initNum
;
if
(
!
octx
)
{
if
(
!
octx
)
{
...
@@ -181,19 +185,18 @@ int writeToOFormat() {
...
@@ -181,19 +185,18 @@ int writeToOFormat() {
AVPacket
*
pkt
=
pktBufPop
(
pktBuffer
,
i
);
AVPacket
*
pkt
=
pktBufPop
(
pktBuffer
,
i
);
if
(
pkt
==
NULL
)
{
if
(
pkt
==
NULL
)
{
printf
(
"MUXER WASM: writeToOFormat() NULL PKT
\n
"
);
goto
EXIT
;
goto
EXIT
;
}
}
if
(
pkt
->
data
==
NULL
&&
pkt
->
size
==
0
)
{
if
(
pkt
->
data
==
NULL
&&
pkt
->
size
==
0
)
{
/* EOF */
/* EOF */
if
(
++
finNum
==
numOfStreams
)
if
(
++
finNum
==
numOfStreams
)
{
goto
FINISH
;
goto
FINISH
;
goto
EXIT
;
}
goto
NEXT
;
}
}
streamWriteFrame
(
octx
,
pkt
);
streamWriteFrame
(
octx
,
pkt
);
printf
(
"MUXER WASM: WriteToOutput(): Index %d...Done
\n
"
,
i
);
av_packet_free
(
&
pkt
);
av_packet_free
(
&
pkt
);
...
@@ -210,34 +213,34 @@ int writeToOFormat() {
...
@@ -210,34 +213,34 @@ int writeToOFormat() {
streamWriteTrailer
(
octx
);
streamWriteTrailer
(
octx
);
streamClose
(
&
octx
);
streamClose
(
&
octx
);
return
OK
;
return
TERMINATED
;
}
}
EM_PORT_API
(
int
)
muxStep
(
void
)
{
EM_PORT_API
(
int
)
muxStep
(
void
)
{
printf
(
"MuxStep Start
\n
"
)
;
int
ret
=
0
;
printf
(
"MuxStep Buffering()
\n
"
);
/* Buffer all packets from muxPush() into
/* Buffer all packets from muxPush() into
* Packet Buffer */
* Packet Buffer */
buffering
();
buffering
();
printf
(
"MuxStep Init()
\n
"
);
/* Do Streaming Context Initialization
/* Do Streaming Context Initialization
* if required */
* if required */
if
(
initNum
<
numOfStreams
)
if
(
initNum
<
numOfStreams
)
contextInitializes
();
contextInitializes
();
printf
(
"MuxStep Write()
\n
"
);
/* Write into output format in order of
/* Write into output format in order of
* stream index */
* stream index */
writeToOFormat
();
ret
=
writeToOFormat
();
if
(
ret
==
TERMINATED
)
{
printf
(
"MuxStep Done
\n
"
);
destroyList
(
&
protos
);
//destroyList(&ctxs);
destroyPktBuffer
(
&
pktBuffer
);
return
1
;
}
return
OK
;
return
0
;
}
}
EM_PORT_API
(
int
)
eof
(
int
i
)
{
EM_PORT_API
(
int
)
eof
(
int
i
)
{
...
...
wasm-build.sh
View file @
24cd1715
...
@@ -17,7 +17,8 @@ THIRD_DIR=${WORKPATH}/lib/third/build
...
@@ -17,7 +17,8 @@ THIRD_DIR=${WORKPATH}/lib/third/build
FFMPEG_PROTO
=
${
WORKPATH
}
/src/protos/src
FFMPEG_PROTO
=
${
WORKPATH
}
/src/protos/src
WASM_DIR
=
${
WORKPATH
}
/src/wasms
WASM_DIR
=
${
WORKPATH
}
/src/wasms
DEBUG
=
"-O3"
ENCODER_DEBUG
=
"-O1 -g -fno-inline -gseparate-dwarf=encoder.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/encoder.debug.wasm"
MUXER_DEBUG
=
"-O1 -g -fno-inline -gseparate-dwarf=muxer.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/muxer.debug.wasm"
#DEBUG="-g2"
#DEBUG="-g2"
BUILD_DIR
=
${
WORKPATH
}
/Build
BUILD_DIR
=
${
WORKPATH
}
/Build
...
@@ -63,9 +64,10 @@ fi
...
@@ -63,9 +64,10 @@ fi
###############################################################################
###############################################################################
# FFMPEG Core #
# FFMPEG Core #
###############################################################################
###############################################################################
cd
${
DEMO_PATH
}
#--closure 压缩胶水代码,有可能会造成变量重复定义。生产发布可设为1
#--closure 压缩胶水代码,有可能会造成变量重复定义。生产发布可设为1
OPTIM_FLAGS
=
"
$DEBUG
--closure 0"
ENCODER_OPTIM_FLAGS
=
"
$ENCODER_DEBUG
--closure 0"
MUXER_OPTIM_FLAGS
=
"
$MUXER_DEBUG
--closure 0"
if
[[
"
$FFMPEG_ST
"
!=
"yes"
]]
;
then
if
[[
"
$FFMPEG_ST
"
!=
"yes"
]]
;
then
EXTRA_FLAGS_ENCODER
=(
EXTRA_FLAGS_ENCODER
=(
...
@@ -112,8 +114,7 @@ FLAGS_ENCODER=(
...
@@ -112,8 +114,7 @@ FLAGS_ENCODER=(
-s
INITIAL_MEMORY
=
268435456
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
-s
INITIAL_MEMORY
=
268435456
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
--pre-js
$WORKPATH
/pre.js
--pre-js
$WORKPATH
/pre.js
--post-js
$WORKPATH
/post.js
--post-js
$WORKPATH
/post.js
#-gseparate-dwarf=./encoder.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/encoder.debug.wasm
$ENCODER_OPTIM_FLAGS
$OPTIM_FLAGS
${
EXTRA_FLAGS_ENCODER
[@]
}
${
EXTRA_FLAGS_ENCODER
[@]
}
)
)
...
@@ -137,8 +138,7 @@ FLAGS_MUXER=(
...
@@ -137,8 +138,7 @@ FLAGS_MUXER=(
-s
INITIAL_MEMORY
=
536870912
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
-s
INITIAL_MEMORY
=
536870912
# 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
--pre-js
$WORKPATH
/pre.js
--pre-js
$WORKPATH
/pre.js
--post-js
$WORKPATH
/post.js
--post-js
$WORKPATH
/post.js
#-gseparate-dwarf=./muxer.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/muxer.debug.wasm
$MUXER_OPTIM_FLAGS
$OPTIM_FLAGS
${
EXTRA_FLAGS_MUXER
[@]
}
${
EXTRA_FLAGS_MUXER
[@]
}
)
)
...
...
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