|
@@ -159,6 +159,7 @@ if ("function" === typeof importScripts) {
|
|
|
};
|
|
|
|
|
|
Decoder.prototype.isSeqJump = function (a, b) {
|
|
|
+ console.log("[xmedia] isSeqJump,a:%s, b:%s",a,b);
|
|
|
return this.distance(a, b) >= CACHE_BUF_LENGTH - 1;
|
|
|
};
|
|
|
|
|
@@ -173,7 +174,7 @@ if ("function" === typeof importScripts) {
|
|
|
//end refactor
|
|
|
|
|
|
Decoder.prototype.resetDecoder = function () {
|
|
|
- console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
this.isFirstFrame = 1;
|
|
|
this.expected_frameCnt = 1;
|
|
|
|
|
@@ -227,6 +228,7 @@ if ("function" === typeof importScripts) {
|
|
|
this.cntBufInc = 0;
|
|
|
this.prevBufNum = 0;
|
|
|
this.MAX_TRY_TO_DEC_BUFNUM = 3;
|
|
|
+ console.log("[xmedia] resetDecoder");
|
|
|
this.skipFrameUntilI = true;
|
|
|
|
|
|
this.consumerPrevPts = -1;
|
|
@@ -347,10 +349,10 @@ if ("function" === typeof importScripts) {
|
|
|
if (!this.slotHasMedia(index)) {
|
|
|
// pure meta
|
|
|
// debugger
|
|
|
- console.log(
|
|
|
- "[xmedia] return on meta, prev: %s, cur: %s",
|
|
|
- mediaArray[index].pts
|
|
|
- );
|
|
|
+ // console.log(
|
|
|
+ // "[xmedia] return on meta, prev: %s, cur: %s",
|
|
|
+ // mediaArray[index].pts
|
|
|
+ // );
|
|
|
this.consumerPrevPts = mediaArray[index].pts;
|
|
|
return true;
|
|
|
}
|
|
@@ -401,6 +403,11 @@ if ("function" === typeof importScripts) {
|
|
|
};
|
|
|
|
|
|
Decoder.prototype.slotHasContent = function (index) {
|
|
|
+ console.log("[xmedia] slotHasContent ------------ 000, media: %s, meta: %s, pts: %s",
|
|
|
+ (mediaArray[index].media == null),
|
|
|
+ (mediaArray[index].meta == null),
|
|
|
+ mediaArray[index].pts
|
|
|
+ );
|
|
|
return (
|
|
|
mediaArray[index].media != null &&
|
|
|
mediaArray[index].meta != null &&
|
|
@@ -421,7 +428,7 @@ if ("function" === typeof importScripts) {
|
|
|
mediaArray[index].media.length,
|
|
|
);
|
|
|
// var loginfo = 'pts: %s, isIDR: %s, length: %s', mediaArray[index].pts, mediaArray[index].isIDR, mediaArray[index].media.length
|
|
|
-
|
|
|
+ //I帧返回false,P帧返回true
|
|
|
needToSkip = this.skipFrameUntilI && !mediaArray[index].isIDR;
|
|
|
var loginfo =
|
|
|
"index:" +
|
|
@@ -438,7 +445,6 @@ if ("function" === typeof importScripts) {
|
|
|
needToSkip;
|
|
|
|
|
|
// console.log("procBufItem", index, mediaArray[index]);
|
|
|
-
|
|
|
if (this.slotHasContent(index) && !needToSkip) {
|
|
|
console.log("[xmedia] %s ------------ 001", mediaArray[index].pts);
|
|
|
if(mediaArray[index].metadata.mediaSrc){
|
|
@@ -464,7 +470,15 @@ if ("function" === typeof importScripts) {
|
|
|
// console.log("mediaArray[index].isIDR: this.skipFrameUntilI = false")
|
|
|
this.skipFrameUntilI = false;
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
|
|
|
+ this.slotHasMedia(index)
|
|
|
+ console.log("[xmedia] %s ------------ 005", mediaArray[index].pts);
|
|
|
+ this.dropPkt += 1;
|
|
|
+ }
|
|
|
+ /*
|
|
|
+ else {
|
|
|
console.log("[xmedia] %s ------------ 004", mediaArray[index].pts);
|
|
|
if (this.slotHasMedia(index)) { //非空帧
|
|
|
console.log("[xmedia] %s ------------ 005", mediaArray[index].pts);
|
|
@@ -502,6 +516,7 @@ if ("function" === typeof importScripts) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
console.log('procBufItem');
|
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.procBufItem, " + loginfo);
|
|
|
this.lastObj = mediaArray[index];
|
|
@@ -509,7 +524,7 @@ if ("function" === typeof importScripts) {
|
|
|
};
|
|
|
|
|
|
Decoder.prototype.flushBuffer = function (untilIDR) {
|
|
|
- console.log('Work-IT2:flushBuffer');
|
|
|
+ //console.log('Work-IT2:flushBuffer');
|
|
|
this.dumpJitterBufInfo("Entering Decoder.prototype.flushBuffer");
|
|
|
this.skipFrameUntilI = true;
|
|
|
var breakWhenIDR = false;
|
|
@@ -535,7 +550,7 @@ if ("function" === typeof importScripts) {
|
|
|
this.resetBufItem(index);
|
|
|
}
|
|
|
if (!breakWhenIDR) {
|
|
|
- console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 TRUE");
|
|
|
this.isFirstFrame = true;
|
|
|
}
|
|
|
this.dumpJitterBufInfo("Leaving Decoder.prototype.flushBuffer");
|
|
@@ -886,7 +901,7 @@ if ("function" === typeof importScripts) {
|
|
|
};
|
|
|
|
|
|
Decoder.prototype.receiveFrame = function (data) {
|
|
|
- console.log("[xmedia] receiveFrame");
|
|
|
+ //console.log("[xmedia] receiveFrame");
|
|
|
var key = data.cachedKey;
|
|
|
var pts = data.frameCnt;
|
|
|
var meta = data.data.subarray(0, data.metaLen);
|
|
@@ -905,7 +920,7 @@ if ("function" === typeof importScripts) {
|
|
|
// this.updateMediaMetaStats(data);
|
|
|
|
|
|
if (this.isFirstFrame) {
|
|
|
- console.log("[xmedia] isFirstFrame = true. pts:%s", pts);
|
|
|
+ //console.log("[xmedia] isFirstFrame = true. pts:%s", pts);
|
|
|
if (this.isPFrame(data.isIDR, media.byteLength)) {
|
|
|
// MARKER META1META2
|
|
|
this.packetsDrop += 1;
|
|
@@ -915,7 +930,7 @@ if ("function" === typeof importScripts) {
|
|
|
this.prevSeq = this.seqDiff(pts, 1, 65536);
|
|
|
this.readPtr = this.writePtr = pts % CACHE_BUF_LENGTH;
|
|
|
if (data.isIDR) {
|
|
|
- console.log("[xmedia] isFirstFrame 设置 FALSE");
|
|
|
+ //console.log("[xmedia] isFirstFrame 设置 FALSE");
|
|
|
this.isFirstFrame = false;
|
|
|
}
|
|
|
}
|