From 4aeddecce6fc7df1d2f8c0084fee1ff29066aaaf Mon Sep 17 00:00:00 2001 From: cloudwebrtc Date: Sat, 4 Jun 2022 18:54:06 +0800 Subject: [PATCH] m97_release. --- include/rtc_mediaconstraints.h | 2 -- src/rtc_mediaconstraints_impl.cc | 2 -- src/rtc_peerconnection_impl.cc | 13 ++++++++++--- src/rtc_video_frame_impl.cc | 4 ---- src/win/base_allocator.cc | 4 ++-- src/win/codecutils.cc | 15 ++++++++------- src/win/codecutils.h | 2 +- src/win/mediautils.cc | 2 +- src/win/msdkvideodecoder.cc | 26 +++++++++++--------------- src/win/msdkvideodecoder.h | 5 ++--- src/win/msdkvideoencoderfactory.cc | 2 +- 11 files changed, 36 insertions(+), 41 deletions(-) diff --git a/include/rtc_mediaconstraints.h b/include/rtc_mediaconstraints.h index 44d0042941..04ad3b3b56 100644 --- a/include/rtc_mediaconstraints.h +++ b/include/rtc_mediaconstraints.h @@ -45,8 +45,6 @@ class RTCMediaConstraints : public RefCountInterface { LIB_WEBRTC_API static const char* kValueFalse; // false // PeerConnection constraint keys. - // Temporary pseudo-constraints used to enable DTLS-SRTP - LIB_WEBRTC_API static const char* kEnableDtlsSrtp; // Enable DTLS-SRTP // Temporary pseudo-constraints used to enable DataChannels LIB_WEBRTC_API static const char* kEnableRtpDataChannels; // Enable RTP DataChannels diff --git a/src/rtc_mediaconstraints_impl.cc b/src/rtc_mediaconstraints_impl.cc index 2ee5201dc6..b3400d17b7 100644 --- a/src/rtc_mediaconstraints_impl.cc +++ b/src/rtc_mediaconstraints_impl.cc @@ -41,8 +41,6 @@ const char* RTCMediaConstraints::kValueTrue = webrtc::MediaConstraints::kValueTrue; const char* RTCMediaConstraints::kValueFalse = webrtc::MediaConstraints::kValueFalse; -const char* RTCMediaConstraints::kEnableDtlsSrtp = - webrtc::MediaConstraints::kEnableDtlsSrtp; const char* RTCMediaConstraints::kEnableDscp = webrtc::MediaConstraints::kEnableDscp; const char* RTCMediaConstraints::kEnableIPv6 = diff --git a/src/rtc_peerconnection_impl.cc b/src/rtc_peerconnection_impl.cc index deef8f66e5..21155aa8ca 100644 --- a/src/rtc_peerconnection_impl.cc +++ b/src/rtc_peerconnection_impl.cc @@ -422,11 +422,18 @@ scoped_refptr RTCPeerConnectionImpl::CreateDataChannel( init.protocol = to_std_string(dataChannelDict->protocol); init.reliable = dataChannelDict->reliable; - rtc::scoped_refptr rtc_data_channel = - rtc_peerconnection_->CreateDataChannel(to_std_string(label), &init); + webrtc::RTCErrorOr> result = + rtc_peerconnection_->CreateDataChannelOrError(to_std_string(label), &init); + + if (!result.ok()) { + RTC_LOG(LS_ERROR) << "CreateDataChannel failed: " + << ToString(result.error().type()) << " " + << result.error().message(); + return nullptr; + } data_channel_ = scoped_refptr( - new RefCountedObject(rtc_data_channel)); + new RefCountedObject(result.MoveValue())); dataChannelDict->id = init.id; return data_channel_; diff --git a/src/rtc_video_frame_impl.cc b/src/rtc_video_frame_impl.cc index a03941c8c9..5196ace6e5 100644 --- a/src/rtc_video_frame_impl.cc +++ b/src/rtc_video_frame_impl.cc @@ -105,16 +105,12 @@ libwebrtc::RTCVideoFrame::VideoRotation VideoFrameBufferImpl::rotation() { switch (rotation_) { case webrtc::kVideoRotation_0: return RTCVideoFrame::kVideoRotation_0; - break; case webrtc::kVideoRotation_90: return RTCVideoFrame::kVideoRotation_90; - break; case webrtc::kVideoRotation_180: return RTCVideoFrame::kVideoRotation_180; - break; case webrtc::kVideoRotation_270: return RTCVideoFrame::kVideoRotation_270; - break; default: break; } diff --git a/src/win/base_allocator.cc b/src/win/base_allocator.cc index 8f5f044213..da5bcfce74 100644 --- a/src/win/base_allocator.cc +++ b/src/win/base_allocator.cc @@ -194,7 +194,7 @@ mfxStatus BaseFrameAllocator::FreeFrames(mfxFrameAllocResponse *response) // check whether response is an external decoder response std::list::iterator i = - std::find_if( m_ExtResponses.begin(), m_ExtResponses.end(), std::bind1st(IsSame(), *response)); + std::find_if( m_ExtResponses.begin(), m_ExtResponses.end(), std::bind(IsSame(), std::placeholders::_1, *response)); if (i != m_ExtResponses.end()) { @@ -208,7 +208,7 @@ mfxStatus BaseFrameAllocator::FreeFrames(mfxFrameAllocResponse *response) // if not found so far, then search in internal responses std::list::iterator i2 = - std::find_if(m_responses.begin(), m_responses.end(), std::bind1st(IsSame(), *response)); + std::find_if(m_responses.begin(), m_responses.end(), std::bind(IsSame(), std::placeholders::_1, *response)); if (i2 != m_responses.end()) { diff --git a/src/win/codecutils.cc b/src/win/codecutils.cc index 83f404b121..914a5c39c9 100644 --- a/src/win/codecutils.cc +++ b/src/win/codecutils.cc @@ -7,15 +7,16 @@ #include "absl/types/optional.h" #include "media/base/media_constants.h" #include "src/win/codecutils.h" +#include "api/video_codecs/h264_profile_level_id.h" namespace owt { namespace base { -webrtc::SdpVideoFormat CreateH264Format(webrtc::H264::Profile profile, - webrtc::H264::Level level, +webrtc::SdpVideoFormat CreateH264Format(webrtc::H264Profile profile, + webrtc::H264Level level, const std::string& packetization_mode) { const absl::optional profile_string = - webrtc::H264::ProfileLevelIdToString(webrtc::H264::ProfileLevelId(profile, level)); + webrtc::H264ProfileLevelIdToString(webrtc::H264ProfileLevelId(profile, level)); return webrtc::SdpVideoFormat( cricket::kH264CodecName, {{cricket::kH264FmtpProfileLevelId, *profile_string}, @@ -25,10 +26,10 @@ webrtc::SdpVideoFormat CreateH264Format(webrtc::H264::Profile profile, std::vector CodecUtils::SupportedH264Codecs() { return { - CreateH264Format(webrtc::H264::kProfileBaseline, webrtc::H264::kLevel3_1, "1"), - CreateH264Format(webrtc::H264::kProfileBaseline, webrtc::H264::kLevel3_1, "0"), - CreateH264Format(webrtc::H264::kProfileConstrainedBaseline, webrtc::H264::kLevel3_1, "1"), - CreateH264Format(webrtc::H264::kProfileConstrainedBaseline, webrtc::H264::kLevel3_1, + CreateH264Format(webrtc::H264Profile::kProfileBaseline, webrtc::H264Level::kLevel3_1, "1"), + CreateH264Format(webrtc::H264Profile::kProfileBaseline, webrtc::H264Level::kLevel3_1, "0"), + CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, webrtc::H264Level::kLevel3_1, "1"), + CreateH264Format(webrtc::H264Profile::kProfileConstrainedBaseline, webrtc::H264Level::kLevel3_1, "0")}; } diff --git a/src/win/codecutils.h b/src/win/codecutils.h index 23370362eb..3d6b963ed5 100644 --- a/src/win/codecutils.h +++ b/src/win/codecutils.h @@ -8,7 +8,7 @@ #include #include "api/video_codecs/sdp_video_format.h" #include "api/video/video_codec_type.h" -#include "media/base/h264_profile_level_id.h" + namespace owt { namespace base { class CodecUtils { diff --git a/src/win/mediautils.cc b/src/win/mediautils.cc index df57d6ae02..3dc7a2628e 100644 --- a/src/win/mediautils.cc +++ b/src/win/mediautils.cc @@ -149,7 +149,7 @@ absl::optional StringToAV1Profile(const std::string& str) { case 2: return AV1Profile::kProfessional; default: - return absl::nullopt; + break; } return absl::nullopt; } diff --git a/src/win/msdkvideodecoder.cc b/src/win/msdkvideodecoder.cc index f9527dc0b9..339a314893 100644 --- a/src/win/msdkvideodecoder.cc +++ b/src/win/msdkvideodecoder.cc @@ -148,25 +148,21 @@ bool MSDKVideoDecoder::CreateD3D11Device() { return true; } -int32_t MSDKVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings, int32_t numberOfCores) { +bool MSDKVideoDecoder::Configure(const Settings& settings) { RTC_LOG(LS_INFO) << "InitDecode enter"; - if (!codecSettings){ - RTC_LOG(LS_ERROR) << "Invalid codec settings passed to decoder"; - return WEBRTC_VIDEO_CODEC_ERROR; - } - codec_type_ = codecSettings->codecType; + + codec_type_ = settings.codec_type(); timestamps_.clear(); ntp_time_ms_.clear(); - if (&codec_ != codecSettings) - codec_ = *codecSettings; + settings_ = settings; //return decoder_thread_->Invoke(RTC_FROM_HERE, // Bind(&MSDKVideoDecoder::InitDecodeOnCodecThread, this)); - return decoder_thread_->Invoke( + return decoder_thread_->Invoke( RTC_FROM_HERE, [this] { - return InitDecodeOnCodecThread(); + return InitDecodeOnCodecThread() == WEBRTC_VIDEO_CODEC_OK; }); } @@ -186,8 +182,8 @@ int32_t MSDKVideoDecoder::InitDecodeOnCodecThread() { m_video_param_extracted = false; mfxStatus sts; - width_ = codec_.width; - height_ = codec_.height; + width_ = settings_.max_render_resolution().Width(); + height_ = settings_.max_render_resolution().Height(); uint32_t codec_id = MFX_CODEC_AVC; if (inited_) { @@ -204,11 +200,11 @@ int32_t MSDKVideoDecoder::InitDecodeOnCodecThread() { if (!m_mfx_session_) { return WEBRTC_VIDEO_CODEC_ERROR; } - if (codec_.codecType == webrtc::kVideoCodecVP8) { + if (settings_.codec_type() == webrtc::kVideoCodecVP8) { codec_id = MFX_CODEC_VP8; - } else if (codec_.codecType == webrtc::kVideoCodecVP9) { + } else if (settings_.codec_type() == webrtc::kVideoCodecVP9) { codec_id = MFX_CODEC_VP9; - } else if (codec_.codecType == webrtc::kVideoCodecAV1) { + } else if (settings_.codec_type() == webrtc::kVideoCodecAV1) { codec_id = MFX_CODEC_AV1; } diff --git a/src/win/msdkvideodecoder.h b/src/win/msdkvideodecoder.h index d2eef13b53..8d51e922b2 100644 --- a/src/win/msdkvideodecoder.h +++ b/src/win/msdkvideodecoder.h @@ -55,8 +55,7 @@ class MSDKVideoDecoder : public webrtc::VideoDecoder { static std::unique_ptr Create(cricket::VideoCodec format); - int32_t InitDecode(const webrtc::VideoCodec* codecSettings, int32_t numberOfCores) - override; + bool Configure(const Settings& settings) override; int32_t Decode( const webrtc::EncodedImage& inputImage, bool missingFrames, @@ -109,7 +108,7 @@ class MSDKVideoDecoder : public webrtc::VideoDecoder { int height_; std::unique_ptr decoder_thread_; // Thread on which the decoder will be working on. - webrtc::VideoCodec codec_; + webrtc::VideoDecoder::Settings settings_; webrtc::DecodedImageCallback* callback_; webrtc::Mutex timestampCS_; std::vector ntp_time_ms_; diff --git a/src/win/msdkvideoencoderfactory.cc b/src/win/msdkvideoencoderfactory.cc index f29c31c0f9..a87341520d 100644 --- a/src/win/msdkvideoencoderfactory.cc +++ b/src/win/msdkvideoencoderfactory.cc @@ -12,7 +12,7 @@ #include "src/win/codecutils.h" #include "src/win/msdkvideoencoder.h" //#include "common_video/h264/profile_level_id.h" -#include "media/base/vp9_profile.h" +//#include "media/base/vp9_profile.h" namespace owt { namespace base {