Bug 1286096 - Remove fakeTracks constraint. r=drno,smaug

MozReview-Commit-ID: I9ZsufufRYg

--HG--
extra : rebase_source : 6d3ace3a22ce34586da4899cc0f7b2727a5fc6e0
This commit is contained in:
Jan-Ivar Bruaroey 2016-07-11 19:27:43 -04:00
Родитель 36d85898ac
Коммит 2982c3ee86
7 изменённых файлов: 17 добавлений и 89 удалений

Просмотреть файл

@ -1618,7 +1618,7 @@ already_AddRefed<MediaManager::PledgeSourceSet>
MediaManager::EnumerateRawDevices(uint64_t aWindowId,
MediaSourceEnum aVideoType,
MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks)
bool aFake)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aVideoType != MediaSourceEnum::Other ||
@ -1639,15 +1639,9 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
}
}
if (!aFake) {
// Fake tracks only make sense when we have a fake stream.
aFakeTracks = false;
}
MediaManager::PostTask(NewTaskFrom([id, aWindowId, audioLoopDev,
videoLoopDev, aVideoType,
aAudioType, aFake,
aFakeTracks]() mutable {
aAudioType, aFake]() mutable {
// Only enumerate what's asked for, and only fake cams and mics.
bool hasVideo = aVideoType != MediaSourceEnum::Other;
bool hasAudio = aAudioType != MediaSourceEnum::Other;
@ -1656,7 +1650,7 @@ MediaManager::EnumerateRawDevices(uint64_t aWindowId,
RefPtr<MediaEngine> fakeBackend, realBackend;
if (fakeCams || fakeMics) {
fakeBackend = new MediaEngineDefault(aFakeTracks);
fakeBackend = new MediaEngineDefault();
}
if ((!fakeCams && hasVideo) || (!fakeMics && hasAudio)) {
RefPtr<MediaManager> manager = MediaManager_GetInstance();
@ -2345,14 +2339,11 @@ MediaManager::GetUserMedia(nsPIDOMWindowInner* aWindow,
bool fake = c.mFake.WasPassed()? c.mFake.Value() :
Preferences::GetBool("media.navigator.streams.fake");
bool fakeTracks = c.mFakeTracks.WasPassed()? c.mFakeTracks.Value() : false;
bool askPermission = !privileged &&
(!fake || Preferences::GetBool("media.navigator.permission.fake"));
RefPtr<PledgeSourceSet> p = EnumerateDevicesImpl(windowID, videoType,
audioType, fake,
fakeTracks);
audioType, fake);
p->Then([this, onSuccess, onFailure, windowID, c, listener, askPermission,
prefs, isHTTPS, callID, origin](SourceSet*& aDevices) mutable {
@ -2539,7 +2530,7 @@ already_AddRefed<MediaManager::PledgeSourceSet>
MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
MediaSourceEnum aVideoType,
MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks)
bool aFake)
{
MOZ_ASSERT(NS_IsMainThread());
nsPIDOMWindowInner* window =
@ -2568,13 +2559,12 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
RefPtr<Pledge<nsCString>> p = media::GetOriginKey(origin, privateBrowsing,
persist);
p->Then([id, aWindowId, aVideoType, aAudioType,
aFake, aFakeTracks](const nsCString& aOriginKey) mutable {
aFake](const nsCString& aOriginKey) mutable {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<MediaManager> mgr = MediaManager_GetInstance();
RefPtr<PledgeSourceSet> p = mgr->EnumerateRawDevices(aWindowId,
aVideoType, aAudioType,
aFake, aFakeTracks);
RefPtr<PledgeSourceSet> p = mgr->EnumerateRawDevices(aWindowId, aVideoType,
aAudioType, aFake);
p->Then([id, aWindowId, aOriginKey](SourceSet*& aDevices) mutable {
UniquePtr<SourceSet> devices(aDevices); // secondary result

Просмотреть файл

@ -273,12 +273,12 @@ private:
EnumerateRawDevices(uint64_t aWindowId,
dom::MediaSourceEnum aVideoType,
dom::MediaSourceEnum aAudioType,
bool aFake, bool aFakeTracks);
bool aFake);
already_AddRefed<PledgeSourceSet>
EnumerateDevicesImpl(uint64_t aWindowId,
dom::MediaSourceEnum aVideoSrcType,
dom::MediaSourceEnum aAudioSrcType,
bool aFake = false, bool aFakeTracks = false);
bool aFake = false);
already_AddRefed<PledgeChar>
SelectSettings(
dom::MediaStreamConstraints& aConstraints,

Просмотреть файл

@ -10,8 +10,11 @@
<pre id="test">
<script class="testbody" type="text/javascript">
function startTest() {
navigator.mediaDevices.getUserMedia({audio:true, video:true, fake:true, fakeTracks:true})
.then(function(stream) {
navigator.mediaDevices.getUserMedia({audio:true, video:true, fake:true})
.then(function(orgStream) {
var a = orgStream.getAudioTracks()[0];
var v = orgStream.getVideoTracks()[0];
var stream = new MediaStream([a, a, a, a, v, v, v].map(track => track.clone()));
var element = document.createElement("video");
element.onloadedmetadata = function() {
@ -20,8 +23,7 @@ function startTest() {
SimpleTest.finish();
};
mStream = stream;
element.srcObject = mStream;
element.srcObject = stream;
element.play();
})
.catch(function(reason) {

Просмотреть файл

@ -181,10 +181,6 @@ public:
/* It is an error to call Start() before an Allocate(), and Stop() before
* a Start(). Only Allocate() may be called after a Deallocate(). */
void SetHasFakeTracks(bool aHasFakeTracks) {
mHasFakeTracks = aHasFakeTracks;
}
/* This call reserves but does not start the device. */
virtual nsresult Allocate(const dom::MediaTrackConstraints &aConstraints,
const MediaEnginePrefs &aPrefs,
@ -210,7 +206,6 @@ protected:
#ifdef DEBUG
, mOwningThread(PR_GetCurrentThread())
#endif
, mHasFakeTracks(false)
{}
void AssertIsOnOwningThread()
@ -222,7 +217,6 @@ protected:
#ifdef DEBUG
PRThread* mOwningThread;
#endif
bool mHasFakeTracks;
// Main-thread only:
dom::MediaTrackSettings mSettings;
};

Просмотреть файл

@ -32,11 +32,6 @@ namespace mozilla {
using namespace mozilla::gfx;
// Enable the testing flag fakeTracks and fake in MediaStreamConstraints, will
// return you a MediaStream with additional fake video tracks and audio tracks.
static const int kFakeVideoTrackCount = 2;
static const int kFakeAudioTrackCount = 3;
NS_IMPL_ISUPPORTS(MediaEngineDefaultVideoSource, nsITimerCallback)
/**
* Default video source.
@ -175,12 +170,6 @@ MediaEngineDefaultVideoSource::Start(SourceMediaStream* aStream, TrackID aID,
aStream->AddTrack(aID, 0, new VideoSegment(), SourceMediaStream::ADDTRACK_QUEUED);
if (mHasFakeTracks) {
for (int i = 0; i < kFakeVideoTrackCount; ++i) {
aStream->AddTrack(kTrackCount + i, 0, new VideoSegment(), SourceMediaStream::ADDTRACK_QUEUED);
}
}
// Remember TrackID so we can end it later
mTrackID = aID;
@ -210,11 +199,6 @@ MediaEngineDefaultVideoSource::Stop(SourceMediaStream *aSource, TrackID aID)
mTimer = nullptr;
aSource->EndTrack(aID);
if (mHasFakeTracks) {
for (int i = 0; i < kFakeVideoTrackCount; ++i) {
aSource->EndTrack(kTrackCount + i);
}
}
mState = kStopped;
mImage = nullptr;
@ -314,14 +298,6 @@ MediaEngineDefaultVideoSource::NotifyPull(MediaStreamGraph* aGraph,
// This can fail if either a) we haven't added the track yet, or b)
// we've removed or finished the track.
aSource->AppendToTrack(aID, &segment);
// Generate null data for fake tracks.
if (mHasFakeTracks) {
for (int i = 0; i < kFakeVideoTrackCount; ++i) {
VideoSegment nullSegment;
nullSegment.AppendNullData(delta);
aSource->AppendToTrack(kTrackCount + i, &nullSegment);
}
}
}
}
@ -478,15 +454,6 @@ MediaEngineDefaultAudioSource::Start(SourceMediaStream* aStream, TrackID aID,
AppendToSegment(*segment, mBufferSize);
mSource->AddAudioTrack(aID, AUDIO_RATE, 0, segment, SourceMediaStream::ADDTRACK_QUEUED);
if (mHasFakeTracks) {
for (int i = 0; i < kFakeAudioTrackCount; ++i) {
segment = new AudioSegment();
segment->AppendNullData(mBufferSize);
mSource->AddAudioTrack(kTrackCount + kFakeVideoTrackCount+i,
AUDIO_RATE, 0, segment, SourceMediaStream::ADDTRACK_QUEUED);
}
}
// Remember TrackID so we can finish later
mTrackID = aID;
@ -523,11 +490,6 @@ MediaEngineDefaultAudioSource::Stop(SourceMediaStream *aSource, TrackID aID)
mTimer = nullptr;
aSource->EndTrack(aID);
if (mHasFakeTracks) {
for (int i = 0; i < kFakeAudioTrackCount; ++i) {
aSource->EndTrack(kTrackCount + kFakeVideoTrackCount+i);
}
}
mState = kStopped;
return NS_OK;
@ -574,14 +536,6 @@ MediaEngineDefaultAudioSource::Notify(nsITimer* aTimer)
AppendToSegment(segment, samplesToAppend);
mSource->AppendToTrack(mTrackID, &segment);
// Generate null data for fake tracks.
if (mHasFakeTracks) {
for (int i = 0; i < kFakeAudioTrackCount; ++i) {
AudioSegment nullSegment;
nullSegment.AppendNullData(samplesToAppend);
mSource->AppendToTrack(kTrackCount + kFakeVideoTrackCount+i, &nullSegment);
}
}
return NS_OK;
}
@ -599,7 +553,6 @@ MediaEngineDefault::EnumerateVideoDevices(dom::MediaSourceEnum aMediaSource,
// This no longer is possible since the resolution is being set in Allocate().
RefPtr<MediaEngineVideoSource> newSource = new MediaEngineDefaultVideoSource();
newSource->SetHasFakeTracks(mHasFakeTracks);
mVSources.AppendElement(newSource);
aVSources->AppendElement(newSource);
@ -625,7 +578,6 @@ MediaEngineDefault::EnumerateAudioDevices(dom::MediaSourceEnum aMediaSource,
if (aASources->Length() == 0) {
RefPtr<MediaEngineAudioSource> newSource =
new MediaEngineDefaultAudioSource();
newSource->SetHasFakeTracks(mHasFakeTracks);
mASources.AppendElement(newSource);
aASources->AppendElement(newSource);
}

Просмотреть файл

@ -198,10 +198,7 @@ protected:
class MediaEngineDefault : public MediaEngine
{
public:
explicit MediaEngineDefault(bool aHasFakeTracks = false)
: mHasFakeTracks(aHasFakeTracks)
, mMutex("mozilla::MediaEngineDefault")
{}
explicit MediaEngineDefault() : mMutex("mozilla::MediaEngineDefault") {}
void EnumerateVideoDevices(dom::MediaSourceEnum,
nsTArray<RefPtr<MediaEngineVideoSource> >*) override;
@ -214,9 +211,6 @@ public:
mASources.Clear();
};
protected:
bool mHasFakeTracks;
private:
~MediaEngineDefault() {
Shutdown();

Просмотреть файл

@ -20,10 +20,6 @@ dictionary MediaStreamConstraints {
boolean fake; // For testing purpose. Generates frames of solid
// colors if video is enabled, and sound of 1Khz sine
// wave if audio is enabled.
boolean fakeTracks; // For testing purpose, works only if fake is
// enabled. Enable fakeTracks returns a stream
// with two extra empty video tracks and three
// extra empty audio tracks.
DOMString? peerIdentity = null;
};