Commit 24cd1715 authored by Linshizhi's avatar Linshizhi

Remove Debug Printf

parent 64dbc5eb
......@@ -22,7 +22,8 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
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: 'tests/**/*.js', included: true },
{ pattern: 'resources/**/*.js', included: false, served: true },
......@@ -36,7 +37,8 @@ module.exports = function(config) {
'/src': '/base/src/',
'/resources': '/base/resources/',
'/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
......
......@@ -211,7 +211,6 @@ async function RGBProcessing(frame) {
// Unit of interval is millionsecond
async function sendToMuxerUntilSuccess(size, interval) {
console.log("Send to Muxer");
while (!sendToMuxer(size)) {
await sleep(interval);
}
......
......@@ -113,8 +113,6 @@ async function deBridging() {
async function step() {
let chn = undefined;
console.log("Step");
// Read Datas
for (let i = 0; i < numOfEncs; ++i) {
......@@ -123,13 +121,11 @@ async function step() {
chn = channels[i];
let data = chn.readData(MUX_BUFFER_SIZE);
console.log("Mux Receive (" + data.byteLength + " Bytes ) " + data)
if (data.byteLength == 0) {
// Check EOF
let flag = chn.readPriv();
if (flag & PRIV_FLAGS.EOF) {
console.log("MUXER: EOF " + i);
muxer._eof(i);
++eofCount;
......@@ -138,7 +134,6 @@ async function step() {
continue;
}
console.log("MUXWW Push to " + i + " with length " + data.byteLength);
/* Write data into wasm */
muxBuffer = muxer._malloc(data.byteLength);
......@@ -149,7 +144,6 @@ async function step() {
// Handle Datas
done = muxer._muxStep();
console.log("Mux step done")
return true;
}
......@@ -158,7 +152,6 @@ async function steps() {
inExec = true;
while (await step()) {
console.log("Done: " + done);
if (done)
break;
await sleep(SLEEP_INTERVAL);
......
......@@ -12,6 +12,7 @@
#define OK 0
#define ERROR 1
#define TERMINATED 2
typedef enum {
......@@ -37,12 +38,24 @@ static List *protos;
static List *ctxs;
static PktBuffer *pktBuffer;
void protoNodeDestr(void *v) {
destroyMMProto((MMProto**)&v);
}
void ctxNodeDestr(void *v) {
streamClose((StreamContext**)&v);
}
EM_PORT_API(int) muxInit(int numOfStreams_) {
numOfStreams = numOfStreams_;
protos = createList();
listSetDestructor(protos, protoNodeDestr);
ctxs = createList();
listSetDestructor(ctxs, ctxNodeDestr);
pktBuffer = createPktBuffer(numOfStreams);
for (int i = 0; i < numOfStreams; ++i) {
......@@ -62,11 +75,8 @@ EM_PORT_API(int) muxPush(int sIdx, uint8_t *data, size_t size) {
MMProto *p = listGet(protos, sIdx);
if (p) {
printf("MUXER WASM: Proto %d Push Size %ld\n", sIdx, size);
mmpPush(p, data, size);
printf("MUXER WASM: Proto %d Buffer Size is %d\n", sIdx, mmpBufferSize(p));
} else {
printf("MUXER WASM: muxPush fail to get proto %d\n", sIdx);
return 1;
}
......@@ -97,13 +107,10 @@ int buffering() {
if (ctx->state != CONTEXT_RUN)
continue;
printf("MUXER WASM: Buffer for context %d\n", i);
pkt = pkt == NULL ? av_packet_alloc() : pkt;
ret = streamReadFrame(ctx->sc, pkt);
if (ret < 0) {
if (ret == AVERROR_EOF) {
printf("MUXER WASM: buffering() EOF\n");
ctx->state = CONTEXT_FIN;
pktBufPush(pktBuffer, i, createNULLPacket());
break;
......@@ -112,7 +119,6 @@ int buffering() {
continue;
}
printf("MUXER WASM: BUFFER INTO %d\n", i);
/* Buffer the packet */
pktBufPush(pktBuffer, i, pkt);
pkt = NULL;
......@@ -149,15 +155,13 @@ int contextInitializes() {
ProtoInfo info = {
.proto = (Proto*)listGet(protos, i),
.destructor = (ProtoDestructor)destroyMMProto,
.destructor = NULL,
.ofmt = NULL
};
ctx->sc = createInStreamContext("", info, AVMEDIA_TYPE_VIDEO);
ctx->state = CONTEXT_RUN;
printf("MUXER WASM: CONTEXT %d init\n", i);
++initNum;
if (!octx) {
......@@ -181,19 +185,18 @@ int writeToOFormat() {
AVPacket *pkt = pktBufPop(pktBuffer, i);
if (pkt == NULL) {
printf("MUXER WASM: writeToOFormat() NULL PKT\n");
goto EXIT;
}
if (pkt->data == NULL && pkt->size == 0) {
/* EOF */
if (++finNum == numOfStreams)
if (++finNum == numOfStreams) {
goto FINISH;
goto EXIT;
}
goto NEXT;
}
streamWriteFrame(octx, pkt);
printf("MUXER WASM: WriteToOutput(): Index %d...Done\n", i);
av_packet_free(&pkt);
......@@ -210,34 +213,34 @@ int writeToOFormat() {
streamWriteTrailer(octx);
streamClose(&octx);
return OK;
return TERMINATED;
}
EM_PORT_API(int) muxStep(void) {
printf("MuxStep Start\n");
int ret = 0;
printf("MuxStep Buffering()\n");
/* Buffer all packets from muxPush() into
* Packet Buffer */
buffering();
printf("MuxStep Init()\n");
/* Do Streaming Context Initialization
* if required */
if (initNum < numOfStreams)
contextInitializes();
printf("MuxStep Write()\n");
/* Write into output format in order of
* stream index */
writeToOFormat();
printf("MuxStep Done\n");
ret = writeToOFormat();
if (ret == TERMINATED) {
destroyList(&protos);
//destroyList(&ctxs);
destroyPktBuffer(&pktBuffer);
return 1;
}
return OK;
return 0;
}
EM_PORT_API(int) eof(int i) {
......
......@@ -17,7 +17,8 @@ THIRD_DIR=${WORKPATH}/lib/third/build
FFMPEG_PROTO=${WORKPATH}/src/protos/src
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"
BUILD_DIR=${WORKPATH}/Build
......@@ -63,9 +64,10 @@ fi
###############################################################################
# FFMPEG Core #
###############################################################################
cd ${DEMO_PATH}
#--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
EXTRA_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
--pre-js $WORKPATH/pre.js
--post-js $WORKPATH/post.js
#-gseparate-dwarf=./encoder.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/encoder.debug.wasm
$OPTIM_FLAGS
$ENCODER_OPTIM_FLAGS
${EXTRA_FLAGS_ENCODER[@]}
)
......@@ -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
--pre-js $WORKPATH/pre.js
--post-js $WORKPATH/post.js
#-gseparate-dwarf=./muxer.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/muxer.debug.wasm
$OPTIM_FLAGS
$MUXER_OPTIM_FLAGS
${EXTRA_FLAGS_MUXER[@]}
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment