Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
96808305
Unverified
提交
96808305
authored
6月 14, 2020
作者:
Iñaki Baz Castillo
提交者:
GitHub
6月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Producer scores for Consumers (#421)
上级
ca0ddda4
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
86 行增加
和
40 行删除
+86
-40
Consumer.d.ts
lib/Consumer.d.ts
+5
-0
Consumer.d.ts.map
lib/Consumer.d.ts.map
+2
-2
Consumer.js
lib/Consumer.js
+1
-1
Consumer.ts
src/Consumer.ts
+7
-1
test-Consumer.js
test/test-Consumer.js
+4
-2
test-PipeTransport.js
test/test-PipeTransport.js
+8
-4
Consumer.hpp
worker/include/RTC/Consumer.hpp
+2
-0
Producer.hpp
worker/include/RTC/Producer.hpp
+7
-2
RtpStream.hpp
worker/include/RTC/RtpStream.hpp
+4
-0
Consumer.cpp
worker/src/RTC/Consumer.cpp
+8
-0
PipeConsumer.cpp
worker/src/RTC/PipeConsumer.cpp
+3
-2
Producer.cpp
worker/src/RTC/Producer.cpp
+21
-14
Router.cpp
worker/src/RTC/Router.cpp
+3
-0
SimpleConsumer.cpp
worker/src/RTC/SimpleConsumer.cpp
+2
-3
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+7
-3
SvcConsumer.cpp
worker/src/RTC/SvcConsumer.cpp
+2
-6
没有找到文件。
lib/Consumer.d.ts
浏览文件 @
96808305
...
...
@@ -70,6 +70,11 @@ export declare type ConsumerScore = {
* The score of the currently selected RTP stream of the producer.
*/
producerScore
:
number
;
/**
* The scores of all RTP streams in the producer (just useful when the
* producer uses simulcast).
*/
producerScores
:
number
[];
};
export
declare
type
ConsumerLayers
=
{
/**
...
...
lib/Consumer.d.ts.map
浏览文件 @
96808305
{"version":3,"file":"Consumer.d.ts","sourceRoot":"","sources":["../src/Consumer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACN,SAAS,EACT,eAAe,EACf,aAAa,EACb,MAAM,iBAAiB,CAAC;AAEzB,oBAAY,eAAe,GAC3B;IACC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,eAAe,CAAC,EAAE,cAAc,CAAC;IAEjC;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;CACd,CAAA;AAED;;GAEG;AACH,oBAAY,sBAAsB,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjF;;GAEG;AACH,oBAAY,sBAAsB,GAClC;IACC;;OAEG;IACH,IAAI,EAAE,sBAAsB,CAAC;IAE7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,KAAK,CAAC;IAExB;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC;CACV,CAAA;AAED,oBAAY,aAAa,GACzB;IACC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACtB,CAAA;AAED,oBAAY,cAAc,GAC1B;IACC;;OAEG;I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D;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAYpC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;OAEG;IACG,gBAAgB,CAAC,KAAK,GAAE,sBAAsB,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3E,OAAO,CAAC,0BAA0B;CA4GlC"}
\ No newline at end of file
lib/Consumer.js
浏览文件 @
96808305
...
...
@@ -16,7 +16,7 @@ class Consumer extends EnhancedEventEmitter_1.EnhancedEventEmitter {
* @emits @close
* @emits @producerclose
*/
constructor
({
internal
,
data
,
channel
,
appData
,
paused
,
producerPaused
,
score
=
{
score
:
10
,
producerScore
:
10
},
preferredLayers
})
{
constructor
({
internal
,
data
,
channel
,
appData
,
paused
,
producerPaused
,
score
=
{
score
:
10
,
producerScore
:
10
,
producerScores
:
[]
},
preferredLayers
})
{
super
();
// Closed flag.
this
.
_closed
=
false
;
...
...
src/Consumer.ts
浏览文件 @
96808305
...
...
@@ -90,6 +90,12 @@ export type ConsumerScore =
* The score of the currently selected RTP stream of the producer.
*/
producerScore
:
number
;
/**
* The scores of all RTP streams in the producer ordered by encoding (just
* useful when the producer uses simulcast).
*/
producerScores
:
number
[];
}
export
type
ConsumerLayers
=
...
...
@@ -206,7 +212,7 @@ export class Consumer extends EnhancedEventEmitter
appData
,
paused
,
producerPaused
,
score
=
{
score
:
10
,
producerScore
:
10
},
score
=
{
score
:
10
,
producerScore
:
10
,
producerScores
:
[]
},
preferredLayers
}:
{
...
...
test/test-Consumer.js
浏览文件 @
96808305
...
...
@@ -308,7 +308,8 @@ test('transport.consume() succeeds', async () =>
expect
(
audioConsumer
.
paused
).
toBe
(
false
);
expect
(
audioConsumer
.
producerPaused
).
toBe
(
false
);
expect
(
audioConsumer
.
priority
).
toBe
(
1
);
expect
(
audioConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
0
});
expect
(
audioConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
0
,
producerScores
:
[
0
]
});
expect
(
audioConsumer
.
preferredLayers
).
toBeUndefined
();
expect
(
audioConsumer
.
currentLayers
).
toBeUndefined
();
expect
(
audioConsumer
.
appData
).
toEqual
({
baz
:
'LOL'
});
...
...
@@ -389,7 +390,8 @@ test('transport.consume() succeeds', async () =>
expect
(
videoConsumer
.
paused
).
toBe
(
true
);
expect
(
videoConsumer
.
producerPaused
).
toBe
(
true
);
expect
(
videoConsumer
.
priority
).
toBe
(
1
);
expect
(
videoConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
0
});
expect
(
videoConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
0
,
producerScores
:
[
0
,
0
,
0
,
0
]
});
expect
(
videoConsumer
.
preferredLayers
).
toEqual
({
spatialLayer
:
3
,
temporalLayer
:
0
});
expect
(
videoConsumer
.
currentLayers
).
toBeUndefined
();
expect
(
videoConsumer
.
appData
).
toEqual
({
baz
:
'LOL'
});
...
...
test/test-PipeTransport.js
浏览文件 @
96808305
...
...
@@ -283,7 +283,8 @@ test('router.pipeToRouter() succeeds with audio', async () =>
expect
(
pipeConsumer
.
type
).
toBe
(
'pipe'
);
expect
(
pipeConsumer
.
paused
).
toBe
(
false
);
expect
(
pipeConsumer
.
producerPaused
).
toBe
(
false
);
expect
(
pipeConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
10
});
expect
(
pipeConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
10
,
producerScores
:
[]
});
expect
(
pipeConsumer
.
appData
).
toEqual
({});
expect
(
pipeProducer
.
id
).
toBe
(
audioProducer
.
id
);
...
...
@@ -399,7 +400,8 @@ test('router.pipeToRouter() succeeds with video', async () =>
expect
(
pipeConsumer
.
type
).
toBe
(
'pipe'
);
expect
(
pipeConsumer
.
paused
).
toBe
(
false
);
expect
(
pipeConsumer
.
producerPaused
).
toBe
(
true
);
expect
(
pipeConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
10
});
expect
(
pipeConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
10
,
producerScores
:
[]
});
expect
(
pipeConsumer
.
appData
).
toEqual
({});
expect
(
pipeProducer
.
id
).
toBe
(
videoProducer
.
id
);
...
...
@@ -554,7 +556,8 @@ test('router.createPipeTransport() with enableRtx succeeds', async () =>
expect
(
pipeConsumer
.
type
).
toBe
(
'pipe'
);
expect
(
pipeConsumer
.
paused
).
toBe
(
false
);
expect
(
pipeConsumer
.
producerPaused
).
toBe
(
true
);
expect
(
pipeConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
10
});
expect
(
pipeConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
10
,
producerScores
:
[]
});
expect
(
pipeConsumer
.
appData
).
toEqual
({});
pipeTransport
.
close
();
...
...
@@ -737,7 +740,8 @@ test('transport.consume() for a pipe Producer succeeds', async () =>
expect
(
videoConsumer
.
type
).
toBe
(
'simulcast'
);
expect
(
videoConsumer
.
paused
).
toBe
(
false
);
expect
(
videoConsumer
.
producerPaused
).
toBe
(
true
);
expect
(
videoConsumer
.
score
).
toEqual
({
score
:
10
,
producerScore
:
0
});
expect
(
videoConsumer
.
score
).
toEqual
(
{
score
:
10
,
producerScore
:
0
,
producerScores
:
[
0
,
0
,
0
]
});
expect
(
videoConsumer
.
appData
).
toEqual
({});
},
2000
);
...
...
worker/include/RTC/Consumer.hpp
浏览文件 @
96808305
...
...
@@ -126,6 +126,7 @@ namespace RTC
void
ProducerResumed
();
virtual
void
ProducerRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
mappedSsrc
)
=
0
;
virtual
void
ProducerNewRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
mappedSsrc
)
=
0
;
void
ProducerRtpStreamScores
(
const
std
::
vector
<
uint8_t
>*
scores
);
virtual
void
ProducerRtpStreamScore
(
RTC
::
RtpStream
*
rtpStream
,
uint8_t
score
,
uint8_t
previousScore
)
=
0
;
virtual
void
ProducerRtcpSenderReport
(
RTC
::
RtpStream
*
rtpStream
,
bool
first
)
=
0
;
...
...
@@ -176,6 +177,7 @@ namespace RTC
RTC
::
RtpParameters
::
Type
type
{
RTC
::
RtpParameters
::
Type
::
NONE
};
std
::
vector
<
RTC
::
RtpEncodingParameters
>
consumableRtpEncodings
;
struct
RTC
::
RtpHeaderExtensionIds
rtpHeaderExtensionIds
;
const
std
::
vector
<
uint8_t
>*
producerRtpStreamScores
;
// Others.
std
::
unordered_set
<
uint8_t
>
supportedCodecPayloadTypes
;
uint64_t
lastRtcpSentTime
{
0u
};
...
...
worker/include/RTC/Producer.hpp
浏览文件 @
96808305
...
...
@@ -110,10 +110,14 @@ namespace RTC
{
return
this
->
paused
;
}
std
::
map
<
RTC
::
RtpStreamRecv
*
,
uint32_t
>&
GetRtpStreams
()
const
std
::
map
<
RTC
::
RtpStreamRecv
*
,
uint32_t
>&
GetRtpStreams
()
{
return
this
->
mapRtpStreamMappedSsrc
;
}
const
std
::
vector
<
uint8_t
>*
GetRtpStreamScores
()
const
{
return
std
::
addressof
(
this
->
rtpStreamScores
);
}
ReceiveRtpPacketResult
ReceiveRtpPacket
(
RTC
::
RtpPacket
*
packet
);
void
ReceiveRtcpSenderReport
(
RTC
::
RTCP
::
SenderReport
*
report
);
void
ReceiveRtcpXrDelaySinceLastRr
(
RTC
::
RTCP
::
DelaySinceLastRr
::
SsrcInfo
*
ssrcInfo
);
...
...
@@ -161,7 +165,8 @@ namespace RTC
RTC
::
RtpParameters
rtpParameters
;
RTC
::
RtpParameters
::
Type
type
{
RTC
::
RtpParameters
::
Type
::
NONE
};
struct
RtpMapping
rtpMapping
;
std
::
vector
<
RTC
::
RtpStreamRecv
*>
rtpStreamsByEncodingIdx
;
std
::
vector
<
RTC
::
RtpStreamRecv
*>
rtpStreamByEncodingIdx
;
std
::
vector
<
uint8_t
>
rtpStreamScores
;
std
::
map
<
uint32_t
,
RTC
::
RtpStreamRecv
*>
mapRtxSsrcRtpStream
;
std
::
map
<
RTC
::
RtpStreamRecv
*
,
uint32_t
>
mapRtpStreamMappedSsrc
;
std
::
map
<
uint32_t
,
uint32_t
>
mapMappedSsrcSsrc
;
...
...
worker/include/RTC/RtpStream.hpp
浏览文件 @
96808305
...
...
@@ -58,6 +58,10 @@ namespace RTC
void
FillJson
(
json
&
jsonObject
)
const
;
virtual
void
FillJsonStats
(
json
&
jsonObject
);
uint32_t
GetEncodingIdx
()
const
{
return
this
->
params
.
encodingIdx
;
}
uint32_t
GetSsrc
()
const
{
return
this
->
params
.
ssrc
;
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
96808305
...
...
@@ -427,6 +427,14 @@ namespace RTC
Channel
::
Notifier
::
Emit
(
this
->
id
,
"producerresume"
);
}
void
Consumer
::
ProducerRtpStreamScores
(
const
std
::
vector
<
uint8_t
>*
scores
)
{
MS_TRACE
();
// This is gonna be a constant pointer.
this
->
producerRtpStreamScores
=
scores
;
}
// The caller (Router) is supposed to proceed with the deletion of this Consumer
// right after calling this method. Otherwise ugly things may happen.
void
Consumer
::
ProducerClosed
()
...
...
worker/src/RTC/PipeConsumer.cpp
浏览文件 @
96808305
...
...
@@ -83,8 +83,9 @@ namespace RTC
MS_TRACE
();
// NOTE: Hardcoded values in PipeTransport.
jsonObject
[
"score"
]
=
10
;
jsonObject
[
"producerScore"
]
=
10
;
jsonObject
[
"score"
]
=
10
;
jsonObject
[
"producerScore"
]
=
10
;
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
PipeConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
96808305
...
...
@@ -46,6 +46,11 @@ namespace RTC
// Evaluate type.
this
->
type
=
RTC
::
RtpParameters
::
GetType
(
this
->
rtpParameters
);
// Reserve a slot in rtpStreamByEncodingIdx and rtpStreamsScores vectors
// for each RTP stream.
this
->
rtpStreamByEncodingIdx
.
resize
(
this
->
rtpParameters
.
encodings
.
size
(),
nullptr
);
this
->
rtpStreamScores
.
resize
(
this
->
rtpParameters
.
encodings
.
size
(),
0u
);
auto
&
encoding
=
this
->
rtpParameters
.
encodings
[
0
];
auto
*
mediaCodec
=
this
->
rtpParameters
.
GetCodecForEncoding
(
encoding
);
...
...
@@ -111,9 +116,6 @@ namespace RTC
for
(
auto
&
encoding
:
*
jsonEncodingsIt
)
{
// Reserve a slot in rtpStreamsByEncodingIdx vector.
this
->
rtpStreamsByEncodingIdx
.
emplace_back
(
nullptr
);
if
(
!
encoding
.
is_object
())
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.encodings"
);
...
...
@@ -292,7 +294,8 @@ namespace RTC
}
this
->
mapSsrcRtpStream
.
clear
();
this
->
rtpStreamsByEncodingIdx
.
clear
();
this
->
rtpStreamByEncodingIdx
.
clear
();
this
->
rtpStreamScores
.
clear
();
this
->
mapRtxSsrcRtpStream
.
clear
();
this
->
mapRtpStreamMappedSsrc
.
clear
();
this
->
mapMappedSsrcSsrc
.
clear
();
...
...
@@ -372,7 +375,7 @@ namespace RTC
jsonObject
[
"rtpStreams"
]
=
json
::
array
();
auto
jsonRtpStreamsIt
=
jsonObject
.
find
(
"rtpStreams"
);
for
(
auto
*
rtpStream
:
this
->
rtpStream
s
ByEncodingIdx
)
for
(
auto
*
rtpStream
:
this
->
rtpStreamByEncodingIdx
)
{
if
(
!
rtpStream
)
continue
;
...
...
@@ -418,7 +421,7 @@ namespace RTC
{
MS_TRACE
();
for
(
auto
*
rtpStream
:
this
->
rtpStream
s
ByEncodingIdx
)
for
(
auto
*
rtpStream
:
this
->
rtpStreamByEncodingIdx
)
{
if
(
!
rtpStream
)
continue
;
...
...
@@ -1035,9 +1038,8 @@ namespace RTC
MS_ASSERT
(
this
->
mapSsrcRtpStream
.
find
(
ssrc
)
==
this
->
mapSsrcRtpStream
.
end
(),
"RtpStream with given SSRC already exists"
);
MS_ASSERT
(
!
this
->
rtpStream
s
ByEncodingIdx
[
encodingIdx
],
!
this
->
rtpStreamByEncodingIdx
[
encodingIdx
],
"RtpStream for given encoding index already exists"
);
auto
&
encoding
=
this
->
rtpParameters
.
encodings
[
encodingIdx
];
...
...
@@ -1114,8 +1116,9 @@ namespace RTC
auto
*
rtpStream
=
new
RTC
::
RtpStreamRecv
(
this
,
params
);
// Insert into the maps.
this
->
mapSsrcRtpStream
[
ssrc
]
=
rtpStream
;
this
->
rtpStreamsByEncodingIdx
[
encodingIdx
]
=
rtpStream
;
this
->
mapSsrcRtpStream
[
ssrc
]
=
rtpStream
;
this
->
rtpStreamByEncodingIdx
[
encodingIdx
]
=
rtpStream
;
this
->
rtpStreamScores
[
encodingIdx
]
=
rtpStream
->
GetScore
();
// Set the mapped SSRC.
this
->
mapRtpStreamMappedSsrc
[
rtpStream
]
=
encodingMapping
.
mappedSsrc
;
...
...
@@ -1387,16 +1390,17 @@ namespace RTC
json
data
=
json
::
array
();
// Iterate all streams and notify their scores.
for
(
auto
&
kv
:
this
->
mapSsrcRtpStream
)
for
(
auto
*
rtpStream
:
this
->
rtpStreamByEncodingIdx
)
{
auto
*
rtpStream
=
kv
.
second
;
if
(
!
rtpStream
)
continue
;
data
.
emplace_back
(
json
::
value_t
::
object
);
auto
&
jsonEntry
=
data
[
data
.
size
()
-
1
];
jsonEntry
[
"ssrc"
]
=
rtpStream
->
GetSsrc
();
jsonEntry
[
"encodingIdx"
]
=
rtpStream
->
GetEncodingIdx
();
jsonEntry
[
"ssrc"
]
=
rtpStream
->
GetSsrc
();
if
(
!
rtpStream
->
GetRid
().
empty
())
jsonEntry
[
"rid"
]
=
rtpStream
->
GetRid
();
...
...
@@ -1498,6 +1502,9 @@ namespace RTC
{
MS_TRACE
();
// Update the vector of scores.
this
->
rtpStreamScores
[
rtpStream
->
GetEncodingIdx
()]
=
score
;
// Notify the listener.
this
->
listener
->
OnProducerRtpStreamScore
(
this
,
rtpStream
,
score
,
previousScore
);
...
...
worker/src/RTC/Router.cpp
浏览文件 @
96808305
...
...
@@ -743,6 +743,9 @@ namespace RTC
consumer
->
ProducerRtpStream
(
rtpStream
,
mappedSsrc
);
}
// Provide the Consumer with the scores of all streams in the Producer.
consumer
->
ProducerRtpStreamScores
(
producer
->
GetRtpStreamScores
());
}
inline
void
Router
::
OnTransportConsumerClosed
(
RTC
::
Transport
*
/*transport*/
,
RTC
::
Consumer
*
consumer
)
...
...
worker/src/RTC/SimpleConsumer.cpp
浏览文件 @
96808305
...
...
@@ -75,6 +75,8 @@ namespace RTC
jsonObject
[
"producerScore"
]
=
this
->
producerRtpStream
->
GetScore
();
else
jsonObject
[
"producerScore"
]
=
0
;
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SimpleConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
...
...
@@ -115,9 +117,6 @@ namespace RTC
MS_TRACE
();
this
->
producerRtpStream
=
rtpStream
;
// Emit the score event.
EmitScore
();
}
void
SimpleConsumer
::
ProducerNewRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
/*mappedSsrc*/
)
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
96808305
...
...
@@ -187,6 +187,8 @@ namespace RTC
jsonObject
[
"producerScore"
]
=
producerCurrentRtpStream
->
GetScore
();
else
jsonObject
[
"producerScore"
]
=
0
;
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SimulcastConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
...
...
@@ -309,6 +311,9 @@ namespace RTC
this
->
producerRtpStreams
[
spatialLayer
]
=
rtpStream
;
// Emit the score event.
EmitScore
();
if
(
IsActive
())
MayChangeLayers
();
}
...
...
@@ -318,9 +323,8 @@ namespace RTC
{
MS_TRACE
();
// Emit score event only if the stream whose score changed is the current one.
if
(
rtpStream
==
GetProducerCurrentRtpStream
())
EmitScore
();
// Emit the score event.
EmitScore
();
if
(
RTC
::
Consumer
::
IsActive
())
{
...
...
worker/src/RTC/SvcConsumer.cpp
浏览文件 @
96808305
...
...
@@ -166,6 +166,8 @@ namespace RTC
jsonObject
[
"producerScore"
]
=
this
->
producerRtpStream
->
GetScore
();
else
jsonObject
[
"producerScore"
]
=
0
;
jsonObject
[
"producerScores"
]
=
*
this
->
producerRtpStreamScores
;
}
void
SvcConsumer
::
HandleRequest
(
Channel
::
Request
*
request
)
...
...
@@ -268,9 +270,6 @@ namespace RTC
MS_TRACE
();
this
->
producerRtpStream
=
rtpStream
;
// Emit the score event.
EmitScore
();
}
void
SvcConsumer
::
ProducerNewRtpStream
(
RTC
::
RtpStream
*
rtpStream
,
uint32_t
/*mappedSsrc*/
)
...
...
@@ -279,9 +278,6 @@ namespace RTC
this
->
producerRtpStream
=
rtpStream
;
// Request a key frame.
RequestKeyFrame
();
// Emit the score event.
EmitScore
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论