[*] 添加判断

This commit is contained in:
acgist
2023-08-26 12:55:25 +08:00
parent 032021a72f
commit 298378266a

View File

@@ -306,6 +306,10 @@ namespace acgist {
webrtc::PeerConnectionFactoryInterface* factory,
webrtc::PeerConnectionInterface::RTCConfiguration& rtcConfiguration
) {
if(this->device->IsLoaded()) {
LOG_W("配置已经加载");
return;
}
this->factory = factory;
this->rtcConfiguration = new webrtc::PeerConnectionInterface::RTCConfiguration(rtcConfiguration);
mediasoupclient::PeerConnection::Options options;
@@ -360,9 +364,14 @@ namespace acgist {
{ "opusStereo", true },
{ "opusDtx", true }
};
rtc::scoped_refptr<webrtc::AudioTrackInterface> track = mediaStream->GetAudioTracks()[0];
if(track->state() == webrtc::MediaStreamTrackInterface::TrackState::kEnded) {
LOG_W("音频媒体状态错误");
return;
}
this->audioProducer = this->sendTransport->Produce(
this->producerListener,
mediaStream->GetAudioTracks()[0],
track,
nullptr,
&codecOptions,
nullptr
@@ -399,9 +408,14 @@ namespace acgist {
// encodings.emplace_back(max);
// 强制设置编码器
// nlohmann::json codec = this->device->GetRtpCapabilities()["codec"];
rtc::scoped_refptr<webrtc::VideoTrackInterface> track = mediaStream->GetVideoTracks()[0];
if(track->state() == webrtc::MediaStreamTrackInterface::TrackState::kEnded) {
LOG_W("视频媒体状态错误");
return;
}
this->videoProducer = this->sendTransport->Produce(
this->producerListener,
mediaStream->GetVideoTracks()[0],
track,
nullptr,
&codecOptions,
nullptr