зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1213517 - Wire up getSettings(). r=padenot
MozReview-Commit-ID: EX5FIo3rCoi --HG-- extra : rebase_source : c9a814eb3fbc0a7455ec7c290c3c074cf1b45e7e
This commit is contained in:
Родитель
89411754e1
Коммит
018c5b2f42
|
@ -356,6 +356,13 @@ public:
|
||||||
mVideoDevice->GetMediaSource() == dom::MediaSourceEnum::Browser;
|
mVideoDevice->GetMediaSource() == dom::MediaSourceEnum::Browser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GetSettings(dom::MediaTrackSettings& aOutSettings)
|
||||||
|
{
|
||||||
|
if (mVideoDevice) {
|
||||||
|
mVideoDevice->GetSource()->GetSettings(aOutSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// implement in .cpp to avoid circular dependency with MediaOperationTask
|
// implement in .cpp to avoid circular dependency with MediaOperationTask
|
||||||
// Can be invoked from EITHER MainThread or MSG thread
|
// Can be invoked from EITHER MainThread or MSG thread
|
||||||
void Stop();
|
void Stop();
|
||||||
|
@ -1135,6 +1142,11 @@ public:
|
||||||
return mListener->ApplyConstraintsToTrack(aWindow, mTrackID, aConstraints);
|
return mListener->ApplyConstraintsToTrack(aWindow, mTrackID, aConstraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
GetSettings(dom::MediaTrackSettings& aOutSettings) override
|
||||||
|
{
|
||||||
|
mListener->GetSettings(aOutSettings);
|
||||||
|
}
|
||||||
|
|
||||||
void Stop() override
|
void Stop() override
|
||||||
{
|
{
|
||||||
|
|
|
@ -250,14 +250,16 @@ MediaStreamTrack::Stop()
|
||||||
mReadyState = MediaStreamTrackState::Ended;
|
mReadyState = MediaStreamTrackState::Ended;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaStreamTrack::GetConstraints(dom::MediaTrackConstraints& aResult)
|
void
|
||||||
|
MediaStreamTrack::GetConstraints(dom::MediaTrackConstraints& aResult)
|
||||||
{
|
{
|
||||||
aResult = mConstraints;
|
aResult = mConstraints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult)
|
void
|
||||||
|
MediaStreamTrack::GetSettings(dom::MediaTrackSettings& aResult)
|
||||||
{
|
{
|
||||||
aResult = mSettings;
|
GetSource().GetSettings(aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Promise>
|
already_AddRefed<Promise>
|
||||||
|
|
|
@ -134,6 +134,12 @@ public:
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
const dom::MediaTrackConstraints& aConstraints);
|
const dom::MediaTrackConstraints& aConstraints);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same for GetSettings (no-op).
|
||||||
|
*/
|
||||||
|
virtual void
|
||||||
|
GetSettings(dom::MediaTrackSettings& aResult) {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the source interface when all registered sinks have unregistered.
|
* Called by the source interface when all registered sinks have unregistered.
|
||||||
*/
|
*/
|
||||||
|
@ -213,6 +219,9 @@ public:
|
||||||
|
|
||||||
MediaSourceEnum GetMediaSource() const override { return mMediaSource; }
|
MediaSourceEnum GetMediaSource() const override { return mMediaSource; }
|
||||||
|
|
||||||
|
void
|
||||||
|
GetSettings(dom::MediaTrackSettings& aResult) override {}
|
||||||
|
|
||||||
void Stop() override {}
|
void Stop() override {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -436,7 +445,6 @@ protected:
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
const bool mRemote;
|
const bool mRemote;
|
||||||
dom::MediaTrackConstraints mConstraints;
|
dom::MediaTrackConstraints mConstraints;
|
||||||
dom::MediaTrackSettings mSettings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -197,6 +197,12 @@ public:
|
||||||
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
|
||||||
const nsString& aDeviceId) const = 0;
|
const nsString& aDeviceId) const = 0;
|
||||||
|
|
||||||
|
void GetSettings(dom::MediaTrackSettings& aOutSettings)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
aOutSettings = mSettings;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Only class' own members can be initialized in constructor initializer list.
|
// Only class' own members can be initialized in constructor initializer list.
|
||||||
explicit MediaEngineSource(MediaEngineState aState)
|
explicit MediaEngineSource(MediaEngineState aState)
|
||||||
|
@ -217,6 +223,8 @@ protected:
|
||||||
PRThread* mOwningThread;
|
PRThread* mOwningThread;
|
||||||
#endif
|
#endif
|
||||||
bool mHasFakeTracks;
|
bool mHasFakeTracks;
|
||||||
|
// Main-thread only:
|
||||||
|
dom::MediaTrackSettings mSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,6 +36,9 @@ MediaEngineRemoteVideoSource::MediaEngineRemoteVideoSource(
|
||||||
mInShutdown(false)
|
mInShutdown(false)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other);
|
MOZ_ASSERT(aMediaSource != dom::MediaSourceEnum::Other);
|
||||||
|
mSettings.mWidth.Construct(0);
|
||||||
|
mSettings.mHeight.Construct(0);
|
||||||
|
mSettings.mFrameRate.Construct(0);
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +330,7 @@ MediaEngineRemoteVideoSource::UpdateExisting(AllocationHandle* aHandle,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
mState = kAllocated;
|
mState = kAllocated;
|
||||||
mLastCapability = mCapability;
|
SetLastCapability(mCapability);
|
||||||
LOG(("Video device %d allocated for %s", mCaptureIndex,
|
LOG(("Video device %d allocated for %s", mCaptureIndex,
|
||||||
aHandle->mOrigin.get()));
|
aHandle->mOrigin.get()));
|
||||||
break;
|
break;
|
||||||
|
@ -342,7 +345,7 @@ MediaEngineRemoteVideoSource::UpdateExisting(AllocationHandle* aHandle,
|
||||||
LOG(("StartCapture failed"));
|
LOG(("StartCapture failed"));
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
mLastCapability = mCapability;
|
SetLastCapability(mCapability);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -357,6 +360,23 @@ MediaEngineRemoteVideoSource::UpdateExisting(AllocationHandle* aHandle,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MediaEngineRemoteVideoSource::SetLastCapability(
|
||||||
|
const webrtc::CaptureCapability& aCapability)
|
||||||
|
{
|
||||||
|
mLastCapability = mCapability;
|
||||||
|
|
||||||
|
webrtc::CaptureCapability cap = aCapability;
|
||||||
|
RefPtr<MediaEngineRemoteVideoSource> that = this;
|
||||||
|
|
||||||
|
NS_DispatchToMainThread(media::NewRunnableFrom([this, that, cap]() mutable {
|
||||||
|
mSettings.mWidth.Value() = cap.width;
|
||||||
|
mSettings.mHeight.Value() = cap.height;
|
||||||
|
mSettings.mFrameRate.Value() = cap.maxFPS;
|
||||||
|
return NS_OK;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MediaEngineRemoteVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
MediaEngineRemoteVideoSource::NotifyPull(MediaStreamGraph* aGraph,
|
||||||
SourceMediaStream* aSource,
|
SourceMediaStream* aSource,
|
||||||
|
|
|
@ -130,6 +130,7 @@ private:
|
||||||
void Init();
|
void Init();
|
||||||
size_t NumCapabilities() const override;
|
size_t NumCapabilities() const override;
|
||||||
void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut) const override;
|
void GetCapability(size_t aIndex, webrtc::CaptureCapability& aOut) const override;
|
||||||
|
void SetLastCapability(const webrtc::CaptureCapability& aCapability);
|
||||||
|
|
||||||
/* UpdateExisting - Centralized function to apply constraints and restart
|
/* UpdateExisting - Centralized function to apply constraints and restart
|
||||||
* device as needed, considering all allocations and changes to one.
|
* device as needed, considering all allocations and changes to one.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче