Skip to content

Instantly share code, notes, and snippets.

@jan-ivar
Created November 21, 2018 19:02
Show Gist options
  • Save jan-ivar/8ae414f053fcc8ff9b246311310fb657 to your computer and use it in GitHub Desktop.
Save jan-ivar/8ae414f053fcc8ff9b246311310fb657 to your computer and use it in GitHub Desktop.
already_AddRefed<Promise>
MediaDevices::GetUserMedia(const MediaStreamConstraints& aConstraints,
CallerType aCallerType,
ErrorResult &aRv)
{
RefPtr<Promise> p = Promise::Create(GetParentObject(), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
MediaManager::Get()->GetUserMedia(GetOwner(), aConstraints, aCallerType)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
[p](RefPtr<DOMMediaStream>&& aStream) mutable {
p->MaybeResolve(std::move(aStream));
},
[p](RefPtr<MediaStreamError>&& error) mutable {
p->MaybeReject(std::move(error));
}
);
return p.forget();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment