Commit 5c4c8fc3 authored by Linshizhi's avatar Linshizhi

update

parent ed7a15b7
...@@ -39,6 +39,11 @@ static List *protos; ...@@ -39,6 +39,11 @@ static List *protos;
static List *ctxs; static List *ctxs;
static PktBuffer *pktBuffer; static PktBuffer *pktBuffer;
static int framerate = 30;
static int timescale = 90000;
static int duration;
static AVRational tb;
void protoNodeDestr(void *v) { void protoNodeDestr(void *v) {
destroyMMProto((MMProto**)&v); destroyMMProto((MMProto**)&v);
} }
...@@ -49,6 +54,9 @@ void ctxNodeDestr(void *v) { ...@@ -49,6 +54,9 @@ void ctxNodeDestr(void *v) {
EM_PORT_API(int) muxInit(int numOfStreams_) { EM_PORT_API(int) muxInit(int numOfStreams_) {
tb = av_make_q(1, timescale);
duration = timescale / framerate;
numOfStreams = numOfStreams_; numOfStreams = numOfStreams_;
protos = createList(); protos = createList();
...@@ -180,6 +188,23 @@ int contextInitializes() { ...@@ -180,6 +188,23 @@ int contextInitializes() {
return OK; return OK;
} }
void pktTimestampSetup(AVPacket *pkt) {
static int idx = 0;
int pts = idx * duration,
dts = (idx - 1) * duration;
pkt->pts = idx * duration;
pkt->dts = (idx - 1) * duration;
pkt->duration = duration;
pkt->stream_index = 0;
pkt->pos = -1;
printf("PTS: %ld, DTS: %ld\n", pkt->pts, pkt->dts);
++idx;
}
int writeToOFormat() { int writeToOFormat() {
int i = inProcContext; int i = inProcContext;
...@@ -199,6 +224,7 @@ int writeToOFormat() { ...@@ -199,6 +224,7 @@ int writeToOFormat() {
goto NEXT; goto NEXT;
} }
pktTimestampSetup(pkt);
streamWriteFrame(octx, pkt); streamWriteFrame(octx, pkt);
printf("Writed\n"); printf("Writed\n");
......
...@@ -4,25 +4,25 @@ import { sleep, waitCond } from "../src/utils.js"; ...@@ -4,25 +4,25 @@ import { sleep, waitCond } from "../src/utils.js";
let paraEnc; let paraEnc;
const RGBAFrameSize = 1920*1080*4; const RGBAFrameSize = 1920*1080*4;
// beforeEach(async () => { beforeEach(async () => {
// let trNum = navigator.hardwareConcurrency; let trNum = navigator.hardwareConcurrency;
// paraEnc = new ParaEncoder(trNum, { paraEnc = new ParaEncoder(trNum, {
// codec: "H264", codec: "H264",
// config: { config: {
// encchnlsize: RGBAFrameSize * 10, encchnlsize: RGBAFrameSize * 10,
// bridgechnlsize: Math.pow(2, 25), bridgechnlsize: Math.pow(2, 25),
// } }
// }); });
// await paraEnc.init(); await paraEnc.init();
// }, 20000); }, 20000);
describe("ParaEncoder", () => { describe("ParaEncoder", () => {
xit("Encode With ParaEncoder", async () => { fit("Encode With ParaEncoder", async () => {
const data = new Uint8Array([...Array(RGBAFrameSize).keys()]); const data = new Uint8Array([...Array(RGBAFrameSize).keys()]);
let st = new Date(); let st = new Date();
for (let i = 0; i < 3000; ++i) { for (let i = 0; i < 300; ++i) {
await paraEnc.encode(data); await paraEnc.encode(data);
} }
......
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