зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 015cb0829df5 (bug 1213517)
This commit is contained in:
Родитель
725d265c2c
Коммит
3366ed3525
|
@ -74,7 +74,6 @@
|
||||||
#include "AudioStreamTrack.h"
|
#include "AudioStreamTrack.h"
|
||||||
#include "VideoStreamTrack.h"
|
#include "VideoStreamTrack.h"
|
||||||
#include "MediaTrackList.h"
|
#include "MediaTrackList.h"
|
||||||
#include "MediaStreamError.h"
|
|
||||||
|
|
||||||
#include "AudioChannelService.h"
|
#include "AudioChannelService.h"
|
||||||
|
|
||||||
|
@ -2122,15 +2121,13 @@ public:
|
||||||
return mElement->GetCORSMode();
|
return mElement->GetCORSMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<PledgeVoid>
|
already_AddRefed<Promise>
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
const dom::MediaTrackConstraints& aConstraints) override
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
|
ErrorResult &aRv) override
|
||||||
{
|
{
|
||||||
RefPtr<PledgeVoid> p = new PledgeVoid();
|
NS_ERROR("ApplyConstraints not implemented for media element capture");
|
||||||
p->Reject(new dom::MediaStreamError(aWindow,
|
return nullptr;
|
||||||
NS_LITERAL_STRING("OverconstrainedError"),
|
|
||||||
NS_LITERAL_STRING("")));
|
|
||||||
return p.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop() override
|
void Stop() override
|
||||||
|
|
|
@ -1110,18 +1110,32 @@ public:
|
||||||
return mPeerIdentity;
|
return mPeerIdentity;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<PledgeVoid>
|
already_AddRefed<Promise>
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
const MediaTrackConstraints& aConstraints) override
|
const MediaTrackConstraints& aConstraints,
|
||||||
|
ErrorResult &aRv) override
|
||||||
{
|
{
|
||||||
|
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(aWindow);
|
||||||
|
RefPtr<Promise> promise = Promise::Create(go, aRv);
|
||||||
|
|
||||||
if (sInShutdown) {
|
if (sInShutdown) {
|
||||||
RefPtr<PledgeVoid> p = new PledgeVoid();
|
RefPtr<MediaStreamError> error = new MediaStreamError(aWindow,
|
||||||
p->Reject(new MediaStreamError(aWindow,
|
NS_LITERAL_STRING("AbortError"),
|
||||||
NS_LITERAL_STRING("AbortError"),
|
NS_LITERAL_STRING("In shutdown"));
|
||||||
NS_LITERAL_STRING("In shutdown")));
|
promise->MaybeReject(error);
|
||||||
return p.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
return mListener->ApplyConstraintsToTrack(aWindow, mTrackID, aConstraints);
|
|
||||||
|
typedef media::Pledge<bool, MediaStreamError*> PledgeVoid;
|
||||||
|
|
||||||
|
RefPtr<PledgeVoid> p =
|
||||||
|
mListener->ApplyConstraintsToTrack(aWindow, mTrackID, aConstraints);
|
||||||
|
p->Then([promise](bool& aDummy) mutable {
|
||||||
|
promise->MaybeResolve(false);
|
||||||
|
}, [promise](MediaStreamError*& reason) mutable {
|
||||||
|
promise->MaybeReject(reason);
|
||||||
|
});
|
||||||
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3369,14 +3383,14 @@ GetUserMediaCallbackMediaStreamListener::StopSharing()
|
||||||
|
|
||||||
// ApplyConstraints for track
|
// ApplyConstraints for track
|
||||||
|
|
||||||
auto
|
already_AddRefed<media::Pledge<bool, dom::MediaStreamError*>>
|
||||||
GetUserMediaCallbackMediaStreamListener::ApplyConstraintsToTrack(
|
GetUserMediaCallbackMediaStreamListener::ApplyConstraintsToTrack(
|
||||||
nsPIDOMWindowInner* aWindow,
|
nsPIDOMWindowInner* aWindow,
|
||||||
TrackID aTrackID,
|
TrackID aTrackID,
|
||||||
const MediaTrackConstraints& aConstraints) -> already_AddRefed<PledgeVoid>
|
const MediaTrackConstraints& aConstraints)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
RefPtr<PledgeVoid> p = new PledgeVoid();
|
RefPtr<media::Pledge<bool, dom::MediaStreamError*>> p = new media::Pledge<bool, dom::MediaStreamError*>();
|
||||||
|
|
||||||
// XXX to support multiple tracks of a type in a stream, this should key off
|
// XXX to support multiple tracks of a type in a stream, this should key off
|
||||||
// the TrackID and not just the type
|
// the TrackID and not just the type
|
||||||
|
@ -3429,7 +3443,7 @@ GetUserMediaCallbackMediaStreamListener::ApplyConstraintsToTrack(
|
||||||
if (!mgr) {
|
if (!mgr) {
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
RefPtr<PledgeVoid> p = mgr->mOutstandingVoidPledges.Remove(id);
|
RefPtr<media::Pledge<bool, dom::MediaStreamError*>> p = mgr->mOutstandingVoidPledges.Remove(id);
|
||||||
if (p) {
|
if (p) {
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
p->Resolve(false);
|
p->Resolve(false);
|
||||||
|
|
|
@ -256,7 +256,6 @@ public:
|
||||||
private:
|
private:
|
||||||
typedef media::Pledge<SourceSet*, dom::MediaStreamError*> PledgeSourceSet;
|
typedef media::Pledge<SourceSet*, dom::MediaStreamError*> PledgeSourceSet;
|
||||||
typedef media::Pledge<const char*, dom::MediaStreamError*> PledgeChar;
|
typedef media::Pledge<const char*, dom::MediaStreamError*> PledgeChar;
|
||||||
typedef media::Pledge<bool, dom::MediaStreamError*> PledgeVoid;
|
|
||||||
|
|
||||||
static bool IsPrivileged();
|
static bool IsPrivileged();
|
||||||
static bool IsLoop(nsIURI* aDocURI);
|
static bool IsLoop(nsIURI* aDocURI);
|
||||||
|
@ -322,7 +321,7 @@ private:
|
||||||
|
|
||||||
media::CoatCheck<PledgeSourceSet> mOutstandingPledges;
|
media::CoatCheck<PledgeSourceSet> mOutstandingPledges;
|
||||||
media::CoatCheck<PledgeChar> mOutstandingCharPledges;
|
media::CoatCheck<PledgeChar> mOutstandingCharPledges;
|
||||||
media::CoatCheck<PledgeVoid> mOutstandingVoidPledges;
|
media::CoatCheck<media::Pledge<bool, dom::MediaStreamError*>> mOutstandingVoidPledges;
|
||||||
#if defined(MOZ_B2G_CAMERA) && defined(MOZ_WIDGET_GONK)
|
#if defined(MOZ_B2G_CAMERA) && defined(MOZ_WIDGET_GONK)
|
||||||
RefPtr<nsDOMCameraManager> mCameraManager;
|
RefPtr<nsDOMCameraManager> mCameraManager;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,9 +10,6 @@
|
||||||
#include "nsIUUIDGenerator.h"
|
#include "nsIUUIDGenerator.h"
|
||||||
#include "nsServiceManagerUtils.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "MediaStreamListener.h"
|
#include "MediaStreamListener.h"
|
||||||
#include "systemservices/MediaUtils.h"
|
|
||||||
|
|
||||||
#include "mozilla/dom/Promise.h"
|
|
||||||
|
|
||||||
#ifdef LOG
|
#ifdef LOG
|
||||||
#undef LOG
|
#undef LOG
|
||||||
|
@ -41,16 +38,21 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaStreamTrackSource)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrincipal)
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPrincipal)
|
||||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||||
|
|
||||||
auto
|
already_AddRefed<Promise>
|
||||||
MediaStreamTrackSource::ApplyConstraints(
|
MediaStreamTrackSource::ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
nsPIDOMWindowInner* aWindow,
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
const dom::MediaTrackConstraints& aConstraints) -> already_AddRefed<PledgeVoid>
|
ErrorResult &aRv)
|
||||||
{
|
{
|
||||||
RefPtr<PledgeVoid> p = new PledgeVoid();
|
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(aWindow);
|
||||||
p->Reject(new MediaStreamError(aWindow,
|
RefPtr<Promise> promise = Promise::Create(go, aRv);
|
||||||
NS_LITERAL_STRING("OverconstrainedError"),
|
MOZ_RELEASE_ASSERT(!aRv.Failed());
|
||||||
NS_LITERAL_STRING("")));
|
|
||||||
return p.forget();
|
promise->MaybeReject(new MediaStreamError(
|
||||||
|
aWindow,
|
||||||
|
NS_LITERAL_STRING("OverconstrainedError"),
|
||||||
|
NS_LITERAL_STRING(""),
|
||||||
|
NS_LITERAL_STRING("")));
|
||||||
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -270,28 +272,8 @@ MediaStreamTrack::ApplyConstraints(const MediaTrackConstraints& aConstraints,
|
||||||
"constraints %s", this, NS_ConvertUTF16toUTF8(str).get()));
|
"constraints %s", this, NS_ConvertUTF16toUTF8(str).get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef media::Pledge<bool, MediaStreamError*> PledgeVoid;
|
|
||||||
|
|
||||||
nsPIDOMWindowInner* window = mOwningStream->GetParentObject();
|
nsPIDOMWindowInner* window = mOwningStream->GetParentObject();
|
||||||
|
return GetSource().ApplyConstraints(window, aConstraints, aRv);
|
||||||
nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(window);
|
|
||||||
RefPtr<Promise> promise = Promise::Create(go, aRv);
|
|
||||||
|
|
||||||
// Forward constraints to the source.
|
|
||||||
//
|
|
||||||
// After GetSource().ApplyConstraints succeeds (after it's been to media-thread
|
|
||||||
// and back), and no sooner, do we set mConstraints to the newly applied values.
|
|
||||||
|
|
||||||
// Keep a reference to this, to make sure it's still here when we get back.
|
|
||||||
RefPtr<MediaStreamTrack> that = this;
|
|
||||||
RefPtr<PledgeVoid> p = GetSource().ApplyConstraints(window, aConstraints);
|
|
||||||
p->Then([this, that, promise, aConstraints](bool& aDummy) mutable {
|
|
||||||
mConstraints = aConstraints;
|
|
||||||
promise->MaybeResolve(false);
|
|
||||||
}, [promise](MediaStreamError*& reason) mutable {
|
|
||||||
promise->MaybeReject(reason);
|
|
||||||
});
|
|
||||||
return promise.forget();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaStreamGraph*
|
MediaStreamGraph*
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "PrincipalChangeObserver.h"
|
#include "PrincipalChangeObserver.h"
|
||||||
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
#include "mozilla/dom/MediaStreamTrackBinding.h"
|
||||||
#include "mozilla/dom/MediaTrackSettingsBinding.h"
|
#include "mozilla/dom/MediaTrackSettingsBinding.h"
|
||||||
#include "mozilla/media/MediaUtils.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
|
@ -39,7 +38,6 @@ namespace dom {
|
||||||
|
|
||||||
class AudioStreamTrack;
|
class AudioStreamTrack;
|
||||||
class VideoStreamTrack;
|
class VideoStreamTrack;
|
||||||
class MediaStreamError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface through which a MediaStreamTrack can communicate with its
|
* Common interface through which a MediaStreamTrack can communicate with its
|
||||||
|
@ -124,15 +122,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual nsresult TakePhoto(MediaEnginePhotoCallback*) const { return NS_ERROR_NOT_IMPLEMENTED; }
|
virtual nsresult TakePhoto(MediaEnginePhotoCallback*) const { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||||
|
|
||||||
typedef media::Pledge<bool, dom::MediaStreamError*> PledgeVoid;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We provide a fallback solution to ApplyConstraints() here.
|
* We provide a fallback solution to ApplyConstraints() here.
|
||||||
* Sources that support ApplyConstraints() will have to override it.
|
* Sources that support ApplyConstraints() will have to override it.
|
||||||
*/
|
*/
|
||||||
virtual already_AddRefed<PledgeVoid>
|
virtual already_AddRefed<Promise>
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
const dom::MediaTrackConstraints& aConstraints) = 0;
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
|
ErrorResult &aRv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the source interface when all registered sinks have unregistered.
|
* Called by the source interface when all registered sinks have unregistered.
|
||||||
|
@ -213,13 +210,6 @@ public:
|
||||||
|
|
||||||
MediaSourceEnum GetMediaSource() const override { return mMediaSource; }
|
MediaSourceEnum GetMediaSource() const override { return mMediaSource; }
|
||||||
|
|
||||||
already_AddRefed<PledgeVoid>
|
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
|
||||||
const dom::MediaTrackConstraints& aConstraints) override
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stop() override {}
|
void Stop() override {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#include "mozilla/dom/RTCStatsReportBinding.h"
|
#include "mozilla/dom/RTCStatsReportBinding.h"
|
||||||
#include "MediaStreamTrack.h"
|
#include "MediaStreamTrack.h"
|
||||||
#include "VideoStreamTrack.h"
|
#include "VideoStreamTrack.h"
|
||||||
#include "MediaStreamError.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -1637,18 +1636,4 @@ LocalSourceStreamInfo::ForgetPipelineByTrackId_m(const std::string& trackId)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
|
|
||||||
auto
|
|
||||||
RemoteTrackSource::ApplyConstraints(
|
|
||||||
nsPIDOMWindowInner* aWindow,
|
|
||||||
const dom::MediaTrackConstraints& aConstraints) -> already_AddRefed<PledgeVoid>
|
|
||||||
{
|
|
||||||
RefPtr<PledgeVoid> p = new PledgeVoid();
|
|
||||||
p->Reject(new dom::MediaStreamError(aWindow,
|
|
||||||
NS_LITERAL_STRING("OverconstrainedError"),
|
|
||||||
NS_LITERAL_STRING("")));
|
|
||||||
return p.forget();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
@ -168,9 +168,14 @@ public:
|
||||||
return dom::MediaSourceEnum::Other;
|
return dom::MediaSourceEnum::Other;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<PledgeVoid>
|
already_AddRefed<dom::Promise>
|
||||||
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
ApplyConstraints(nsPIDOMWindowInner* aWindow,
|
||||||
const dom::MediaTrackConstraints& aConstraints) override;
|
const dom::MediaTrackConstraints& aConstraints,
|
||||||
|
ErrorResult &aRv) override
|
||||||
|
{
|
||||||
|
NS_ERROR("Can't ApplyConstraints() a remote source!");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Stop() override { NS_ERROR("Can't stop a remote source!"); }
|
void Stop() override { NS_ERROR("Can't stop a remote source!"); }
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче