зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654112 - Constify VideoConduit members that are based on prefs. r=ng
Differential Revision: https://phabricator.services.mozilla.com/D112848
This commit is contained in:
Родитель
fb59b8db08
Коммит
2c32da060a
|
@ -143,7 +143,46 @@ void TransceiverImpl::InitAudio() {
|
|||
}
|
||||
|
||||
void TransceiverImpl::InitVideo() {
|
||||
mConduit = VideoSessionConduit::Create(mCallWrapper, mStsThread, mPCHandle);
|
||||
VideoSessionConduit::Options options;
|
||||
options.mVideoLatencyTestEnable =
|
||||
Preferences::GetBool("media.video.test_latency", false);
|
||||
options.mMinBitrate = std::max(
|
||||
0,
|
||||
Preferences::GetInt("media.peerconnection.video.min_bitrate", 0) * 1000);
|
||||
options.mStartBitrate = std::max(
|
||||
0, Preferences::GetInt("media.peerconnection.video.start_bitrate", 0) *
|
||||
1000);
|
||||
options.mPrefMaxBitrate = std::max(
|
||||
0,
|
||||
Preferences::GetInt("media.peerconnection.video.max_bitrate", 0) * 1000);
|
||||
if (options.mMinBitrate != 0 &&
|
||||
options.mMinBitrate < kViEMinCodecBitrate_bps) {
|
||||
options.mMinBitrate = kViEMinCodecBitrate_bps;
|
||||
}
|
||||
if (options.mStartBitrate < options.mMinBitrate) {
|
||||
options.mStartBitrate = options.mMinBitrate;
|
||||
}
|
||||
if (options.mPrefMaxBitrate &&
|
||||
options.mStartBitrate > options.mPrefMaxBitrate) {
|
||||
options.mStartBitrate = options.mPrefMaxBitrate;
|
||||
}
|
||||
// XXX We'd love if this was a live param for testing adaptation/etc
|
||||
// in automation
|
||||
options.mMinBitrateEstimate =
|
||||
std::max(0, Preferences::GetInt(
|
||||
"media.peerconnection.video.min_bitrate_estimate", 0) *
|
||||
1000);
|
||||
options.mSpatialLayers = std::max(
|
||||
1, Preferences::GetInt("media.peerconnection.video.svc.spatial", 0));
|
||||
options.mTemporalLayers = std::max(
|
||||
1, Preferences::GetInt("media.peerconnection.video.svc.temporal", 0));
|
||||
options.mDenoising =
|
||||
Preferences::GetBool("media.peerconnection.video.denoising", false);
|
||||
options.mLockScaling =
|
||||
Preferences::GetBool("media.peerconnection.video.lock_scaling", false);
|
||||
|
||||
mConduit = VideoSessionConduit::Create(mCallWrapper, mStsThread,
|
||||
std::move(options), mPCHandle);
|
||||
|
||||
if (!mConduit) {
|
||||
MOZ_MTLOG(ML_ERROR, mPCHandle << "[" << mMid << "]: " << __FUNCTION__
|
||||
|
|
|
@ -6,18 +6,14 @@
|
|||
#define MEDIA_CONDUIT_ABSTRACTION_
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
#include "CodecConfig.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "jsapi/PeerConnectionCtx.h"
|
||||
#include "jsapi/RTCStatsReport.h"
|
||||
#include "MediaConduitErrors.h"
|
||||
#include "mozilla/media/MediaUtils.h"
|
||||
#include "mozilla/RefCounted.h"
|
||||
#include "TaskQueueWrapper.h"
|
||||
#include "VideoTypes.h"
|
||||
#include "WebrtcVideoCodecFactory.h"
|
||||
#include "RtcpEventObserver.h"
|
||||
|
@ -25,7 +21,6 @@
|
|||
#include "mozilla/dom/RTCRtpSourcesBinding.h"
|
||||
|
||||
// libwebrtc includes
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
#include "call/call.h"
|
||||
|
||||
|
@ -319,6 +314,19 @@ class VideoDecoder : public CodecPluginID {
|
|||
*/
|
||||
class VideoSessionConduit : public MediaSessionConduit {
|
||||
public:
|
||||
struct Options {
|
||||
bool mVideoLatencyTestEnable = false;
|
||||
// All in bps.
|
||||
int mMinBitrate = 0;
|
||||
int mStartBitrate = 0;
|
||||
int mPrefMaxBitrate = 0;
|
||||
int mMinBitrateEstimate = 0;
|
||||
bool mDenoising = false;
|
||||
bool mLockScaling = false;
|
||||
uint8_t mSpatialLayers = 1;
|
||||
uint8_t mTemporalLayers = 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Factory function to create and initialize a Video Conduit Session
|
||||
* @param webrtc::Call instance shared by paired audio and video
|
||||
|
@ -328,7 +336,8 @@ class VideoSessionConduit : public MediaSessionConduit {
|
|||
*/
|
||||
static RefPtr<VideoSessionConduit> Create(
|
||||
RefPtr<WebrtcCallWrapper> aCall,
|
||||
nsCOMPtr<nsISerialEventTarget> aStsThread, std::string aPCHandle);
|
||||
nsCOMPtr<nsISerialEventTarget> aStsThread, Options aOptions,
|
||||
std::string aPCHandle);
|
||||
|
||||
enum FrameRequestType {
|
||||
FrameRequestNone,
|
||||
|
|
|
@ -289,7 +289,7 @@ bool operator!=(const rtc::VideoSinkWants& aThis,
|
|||
*/
|
||||
RefPtr<VideoSessionConduit> VideoSessionConduit::Create(
|
||||
RefPtr<WebrtcCallWrapper> aCall, nsCOMPtr<nsISerialEventTarget> aStsThread,
|
||||
std::string aPCHandle) {
|
||||
Options aOptions, std::string aPCHandle) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aCall, "missing required parameter: aCall");
|
||||
CSFLogVerbose(LOGTAG, "%s", __FUNCTION__);
|
||||
|
@ -298,8 +298,8 @@ RefPtr<VideoSessionConduit> VideoSessionConduit::Create(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto obj =
|
||||
MakeRefPtr<WebrtcVideoConduit>(aCall, aStsThread, std::move(aPCHandle));
|
||||
auto obj = MakeRefPtr<WebrtcVideoConduit>(
|
||||
aCall, aStsThread, std::move(aOptions), std::move(aPCHandle));
|
||||
if (obj->Init() != kMediaConduitNoError) {
|
||||
CSFLogError(LOGTAG, "%s VideoConduit Init Failed ", __FUNCTION__);
|
||||
return nullptr;
|
||||
|
@ -310,7 +310,7 @@ RefPtr<VideoSessionConduit> VideoSessionConduit::Create(
|
|||
|
||||
WebrtcVideoConduit::WebrtcVideoConduit(
|
||||
RefPtr<WebrtcCallWrapper> aCall, nsCOMPtr<nsISerialEventTarget> aStsThread,
|
||||
std::string aPCHandle)
|
||||
Options aOptions, std::string aPCHandle)
|
||||
: mTransportMonitor("WebrtcVideoConduit"),
|
||||
mStsThread(aStsThread),
|
||||
mMutex("WebrtcVideoConduit::mMutex"),
|
||||
|
@ -322,6 +322,15 @@ WebrtcVideoConduit::WebrtcVideoConduit(
|
|||
mEngineTransmitting(false),
|
||||
mEngineReceiving(false),
|
||||
mSendingFramerate(DEFAULT_VIDEO_MAX_FRAMERATE),
|
||||
mVideoLatencyTestEnable(aOptions.mVideoLatencyTestEnable),
|
||||
mMinBitrate(aOptions.mMinBitrate),
|
||||
mStartBitrate(aOptions.mStartBitrate),
|
||||
mPrefMaxBitrate(aOptions.mPrefMaxBitrate),
|
||||
mMinBitrateEstimate(aOptions.mMinBitrateEstimate),
|
||||
mDenoising(aOptions.mDenoising),
|
||||
mLockScaling(aOptions.mLockScaling),
|
||||
mSpatialLayers(aOptions.mSpatialLayers),
|
||||
mTemporalLayers(aOptions.mTemporalLayers),
|
||||
mActiveCodecMode(webrtc::VideoCodecMode::kRealtimeVideo),
|
||||
mCodecMode(webrtc::VideoCodecMode::kRealtimeVideo),
|
||||
mCall(aCall),
|
||||
|
@ -869,93 +878,17 @@ webrtc::Call::Stats WebrtcVideoConduit::GetCallStats() const {
|
|||
return mCall->Call()->GetStats();
|
||||
}
|
||||
|
||||
MediaConduitErrorCode WebrtcVideoConduit::InitMain() {
|
||||
MediaConduitErrorCode WebrtcVideoConduit::Init() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrefService> prefs =
|
||||
do_GetService("@mozilla.org/preferences-service;1", &rv);
|
||||
if (!NS_WARN_IF(NS_FAILED(rv))) {
|
||||
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);
|
||||
CSFLogDebug(LOGTAG, "%s this=%p", __FUNCTION__, this);
|
||||
|
||||
if (branch) {
|
||||
int32_t temp;
|
||||
Unused << NS_WARN_IF(NS_FAILED(branch->GetBoolPref(
|
||||
"media.video.test_latency", &mVideoLatencyTestEnable)));
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.min_bitrate", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mMinBitrate = KBPS(temp);
|
||||
}
|
||||
}
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.start_bitrate", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mStartBitrate = KBPS(temp);
|
||||
}
|
||||
}
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.max_bitrate", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mPrefMaxBitrate = KBPS(temp);
|
||||
}
|
||||
}
|
||||
if (mMinBitrate != 0 && mMinBitrate < kViEMinCodecBitrate_bps) {
|
||||
mMinBitrate = kViEMinCodecBitrate_bps;
|
||||
}
|
||||
if (mStartBitrate < mMinBitrate) {
|
||||
mStartBitrate = mMinBitrate;
|
||||
}
|
||||
if (mPrefMaxBitrate && mStartBitrate > mPrefMaxBitrate) {
|
||||
mStartBitrate = mPrefMaxBitrate;
|
||||
}
|
||||
// XXX We'd love if this was a live param for testing adaptation/etc
|
||||
// in automation
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.min_bitrate_estimate", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mMinBitrateEstimate = temp; // bps!
|
||||
}
|
||||
}
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.svc.spatial", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mSpatialLayers = temp;
|
||||
}
|
||||
}
|
||||
if (!NS_WARN_IF(NS_FAILED(branch->GetIntPref(
|
||||
"media.peerconnection.video.svc.temporal", &temp)))) {
|
||||
if (temp >= 0) {
|
||||
mTemporalLayers = temp;
|
||||
}
|
||||
}
|
||||
Unused << NS_WARN_IF(NS_FAILED(branch->GetBoolPref(
|
||||
"media.peerconnection.video.denoising", &mDenoising)));
|
||||
Unused << NS_WARN_IF(NS_FAILED(branch->GetBoolPref(
|
||||
"media.peerconnection.video.lock_scaling", &mLockScaling)));
|
||||
}
|
||||
}
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if (mozilla::camera::VideoEngine::SetAndroidObjects() != 0) {
|
||||
CSFLogError(LOGTAG, "%s: could not set Android objects", __FUNCTION__);
|
||||
return kMediaConduitSessionNotInited;
|
||||
}
|
||||
#endif // MOZ_WIDGET_ANDROID
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs initialization of the MANDATORY components of the Video Engine
|
||||
*/
|
||||
MediaConduitErrorCode WebrtcVideoConduit::Init() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s this=%p", __FUNCTION__, this);
|
||||
MediaConduitErrorCode result;
|
||||
result = InitMain();
|
||||
if (result != kMediaConduitNoError) {
|
||||
return result;
|
||||
}
|
||||
|
||||
CSFLogDebug(LOGTAG, "%s Initialization Done", __FUNCTION__);
|
||||
return kMediaConduitNoError;
|
||||
|
|
|
@ -222,11 +222,10 @@ class WebrtcVideoConduit
|
|||
|
||||
WebrtcVideoConduit(RefPtr<WebrtcCallWrapper> aCall,
|
||||
nsCOMPtr<nsISerialEventTarget> aStsThread,
|
||||
std::string aPCHandle);
|
||||
Options aOptions, std::string aPCHandle);
|
||||
virtual ~WebrtcVideoConduit();
|
||||
|
||||
MediaConduitErrorCode InitMain();
|
||||
virtual MediaConduitErrorCode Init();
|
||||
MediaConduitErrorCode Init();
|
||||
|
||||
std::vector<uint32_t> GetLocalSSRCs() override;
|
||||
bool SetLocalSSRCs(const std::vector<uint32_t>& ssrcs,
|
||||
|
@ -375,34 +374,28 @@ class WebrtcVideoConduit
|
|||
// Accessed under mMutex.
|
||||
unsigned int mSendingFramerate;
|
||||
|
||||
// Written on main thread at creation,
|
||||
// then written or read on any thread under mTransportMonitor.
|
||||
bool mVideoLatencyTestEnable = false;
|
||||
|
||||
// Accessed from any thread under mTransportMonitor.
|
||||
uint64_t mVideoLatencyAvg = 0;
|
||||
|
||||
const bool mVideoLatencyTestEnable;
|
||||
|
||||
// All in bps.
|
||||
// All written on main thread and guarded by mMutex, except for reads on main.
|
||||
int mMinBitrate = 0;
|
||||
int mStartBitrate = 0;
|
||||
int mPrefMaxBitrate = 0;
|
||||
const int mMinBitrate;
|
||||
const int mStartBitrate;
|
||||
const int mPrefMaxBitrate;
|
||||
const int mMinBitrateEstimate;
|
||||
|
||||
// Max bitrate in bps as provided by negotiation. Call thread only.
|
||||
int mNegotiatedMaxBitrate = 0;
|
||||
int mMinBitrateEstimate = 0;
|
||||
|
||||
// Set to true to force denoising on.
|
||||
// Written at creation, then read anywhere.
|
||||
bool mDenoising = false;
|
||||
const bool mDenoising;
|
||||
|
||||
// Set to true to ignore sink wants (scaling due to bwe and cpu usage).
|
||||
// Written at creation, then read anywhere.
|
||||
bool mLockScaling = false;
|
||||
const bool mLockScaling;
|
||||
|
||||
// Written at creation, then read anywhere.
|
||||
uint8_t mSpatialLayers = 1;
|
||||
|
||||
// Written at creation, then read anywhere.
|
||||
uint8_t mTemporalLayers = 1;
|
||||
const uint8_t mSpatialLayers;
|
||||
const uint8_t mTemporalLayers;
|
||||
|
||||
static const unsigned int sAlphaNum = 7;
|
||||
static const unsigned int sAlphaDen = 8;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "MediaTrackGraph.h"
|
||||
#include "MediaTrackListener.h"
|
||||
#include "MediaStreamTrack.h"
|
||||
#include "TaskQueueWrapper.h"
|
||||
#include "transportflow.h"
|
||||
#include "transportlayerloopback.h"
|
||||
#include "transportlayerdtls.h"
|
||||
|
|
|
@ -46,7 +46,8 @@ class VideoConduitTest : public Test {
|
|||
VideoConduitTest()
|
||||
: mCallWrapper(MockCallWrapper::Create()),
|
||||
mVideoConduit(MakeRefPtr<WebrtcVideoConduit>(
|
||||
mCallWrapper, GetCurrentSerialEventTarget(), "")) {
|
||||
mCallWrapper, GetCurrentSerialEventTarget(),
|
||||
VideoSessionConduit::Options(), "")) {
|
||||
NSS_NoDB_Init(nullptr);
|
||||
|
||||
mVideoConduit->SetLocalSSRCs({42}, {43});
|
||||
|
|
Загрузка…
Ссылка в новой задаче