[Mac MediaStream] implement AVFoundation backed MediaStreamSource

https://bugs.webkit.org/show_bug.cgi?id=123316

Source/WebCore: 

Reviewed by Jer Noble

No new tests, existing tests updated.

* CMakeLists.txt: Add MediaStreamSourceStates.cpp.

* Modules/mediastream/MediaSourceStates.cpp:
(WebCore::MediaSourceStates::MediaSourceStates): m_SourceStates -> m_sourceStates.
(WebCore::MediaSourceStates::sourceType): Ditto.
(WebCore::MediaSourceStates::facingMode): Ditto.
* Modules/mediastream/MediaSourceStates.h: Ditto.
* Modules/mediastream/MediaSourceStates.idl: Mark some attributes as optional.

* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack):
(WebCore::MediaStream::removeTrack):
(WebCore::MediaStream::addRemoteSource):
(WebCore::MediaStream::removeRemoteSource):

* Modules/mediastream/MediaStreamCapabilities.cpp:
(WebCore::MediaStreamCapabilities::sourceType): MediaSourceStates -> MediaStreamSourceStates
(WebCore::MediaStreamCapabilities::facingMode): Ditto.

* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack): Don't observe source changes directly, let the
    private track do that. Change private track parameter to ref because it can't be NULL.
(WebCore::MediaStreamTrack::~MediaStreamTrack): Ditto.
(WebCore::MediaStreamTrack::setSource): Pass through to private track.
(WebCore::MediaStreamTrack::stopped): Ditto.
(WebCore::MediaStreamTrack::states): Ditto.
(WebCore::MediaStreamTrack::capabilities): Ditto.
(WebCore::MediaStreamTrack::applyConstraints): Ditto.
(WebCore::MediaStreamTrack::stopProducingData): Ditto.
(WebCore::MediaStreamTrack::trackReadyStateChanged): Renamed from sourceStateChanged. Don't
    schedule an 'ended' event if called as a side effect of the stop() method having been
    called as per spec.
(WebCore::MediaStreamTrack::trackMutedChanged): Renamed from sourceMutedChanged.
(WebCore::MediaStreamTrack::trackEnabledChanged): Renamed from sourceEnabledChanged.
(WebCore::MediaStreamTrack::stop): Pass through to private track.
* Modules/mediastream/MediaStreamTrack.h:
(WebCore::MediaStreamTrack::Observer::~Observer): Add virtual destructor.

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::callSuccessHandler): Set track, not source, constraints.

* WebCore.xcodeproj/project.pbxproj: Add new files.

* bindings/js/JSMediaSourceStatesCustom.cpp:
(WebCore::JSMediaSourceStates::facingMode): Return jsUndefined when the facing mode
    is Unknown.

* platform/mediastream/MediaStreamCenter.h: Remove unused class forward defines and
    undefined method prototype.

* platform/mediastream/MediaStreamDescriptor.cpp:
(WebCore::MediaStreamDescriptor::addSource): ASSERT if source is kind None.
(WebCore::MediaStreamDescriptor::removeSource): Ditto.
(WebCore::MediaStreamDescriptor::MediaStreamDescriptor):

* platform/mediastream/MediaStreamSource.cpp:
(WebCore::MediaStreamSource::setReadyState): Call startProducingData when readyState changes
    to Live, stopProducingData when it changes to Ended.
(WebCore::MediaStreamSource::removeObserver): Call stop() when there are no more observers.
(WebCore::MediaStreamSource::setEnabled): If passed false, do nothing unless all observers
    are disabled. Call startProducingData/stopProducingData when becoming enabled/disabled.
(WebCore::MediaStreamSource::stop): Don't bother checking to see if other observers have
    stopped, the spec says that track.stop() should permanently stop the track's source.
* platform/mediastream/MediaStreamSource.h:
(WebCore::MediaStreamSource::name): Make virtual so derived classes can override.
(WebCore::MediaStreamSource::setName): Ditto.
(WebCore::MediaStreamSource::readyState): Ditto.
(WebCore::MediaStreamSource::enabled): Ditto.
(WebCore::MediaStreamSource::muted): Ditto.
(WebCore::MediaStreamSource::setReadonly): Ditto.
(WebCore::MediaStreamSource::remote): Ditto.
(WebCore::MediaStreamSource::setRemote): Ditto.
(WebCore::MediaStreamSource::startProducingData): Added.
(WebCore::MediaStreamSource::stopProducingData): Added.

* platform/mediastream/MediaStreamSourceCapabilities.h: Move MediaStreamSourceStates to
    its own file.

* platform/mediastream/MediaStreamSourceStates.cpp: Added.
(WebCore::MediaStreamSourceStates::facingMode): Moved here from MediaSourceStates so the 
    strings are available to platform code.
(WebCore::MediaStreamSourceStates::sourceType): Ditto.
* platform/mediastream/MediaStreamSourceStates.h: Added, moved from MediaStreamSourceCapabilities.h.

* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::create): Pass private track to constructor as PassRefPtr.
(WebCore::MediaStreamTrackPrivate::MediaStreamTrackPrivate): Initialize member variables.
(WebCore::MediaStreamTrackPrivate::~MediaStreamTrackPrivate): Unregister as source observer.
(WebCore::MediaStreamTrackPrivate::setSource): Unregister/register as source observer.
(WebCore::MediaStreamTrackPrivate::setEnabled): Enable/disable source, call client.
(WebCore::MediaStreamTrackPrivate::stop): New. Set readyState to Ended, optionally stop source.
(WebCore::MediaStreamTrackPrivate::setReadyState): Inline the logic from shouldFireTrackReadyStateChanged.
(WebCore::MediaStreamTrackPrivate::constraints): New, passthrough to the source.
(WebCore::MediaStreamTrackPrivate::states): Ditto.
(WebCore::MediaStreamTrackPrivate::type): Ditto.
(WebCore::MediaStreamTrackPrivate::capabilities): Ditto.
(WebCore::MediaStreamTrackPrivate::applyConstraints): Ditto.
(WebCore::MediaStreamTrackPrivate::sourceReadyStateChanged): React to source changes.
(WebCore::MediaStreamTrackPrivate::sourceMutedChanged): Ditto.
(WebCore::MediaStreamTrackPrivate::sourceEnabledChanged): Ditto.
(WebCore::MediaStreamTrackPrivate::observerIsEnabled): Respond to source query.
(WebCore::MediaStreamTrackPrivate::observerIsStopped): Ditto.
* platform/mediastream/MediaStreamTrackPrivate.h:

* platform/mediastream/mac/AVAudioCaptureSource.h: Added.
* platform/mediastream/mac/AVAudioCaptureSource.mm: Added.

* platform/mediastream/mac/AVCaptureDeviceManager.h: Added.
* platform/mediastream/mac/AVCaptureDeviceManager.mm: Added.

* platform/mediastream/mac/AVMediaCaptureSource.h: Added.
* platform/mediastream/mac/AVMediaCaptureSource.mm: Added.

* platform/mediastream/mac/AVVideoCaptureSource.h: Added.
* platform/mediastream/mac/AVVideoCaptureSource.mm: Added.

* platform/mediastream/mac/MediaStreamCenterMac.cpp:
(WebCore::MediaStreamCenterMac::validateRequestConstraints): Implement.
(WebCore::MediaStreamCenterMac::createMediaStream): Ditto.
(WebCore::MediaStreamCenterMac::getMediaStreamTrackSources): Ditto.

* platform/mock/MockMediaStreamCenter.cpp:
(WebCore::initializeMockSources): Update for MediaStreamSourceStates changes.
(WebCore::MockMediaStreamCenter::createMediaStream):

LayoutTests: 

Reviewed by Jer Noble.

* fast/mediastream/MediaStream-add-remove-tracks-expected.txt: Updated.
* fast/mediastream/MediaStream-add-remove-tracks.html: Ditto.
* fast/mediastream/MediaStreamConstructor-expected.txt: Ditto.
* fast/mediastream/MediaStreamConstructor.html: Ditto.
* fast/mediastream/MediaStreamTrack-getSources.html: Remove typo.
* fast/mediastream/MediaStreamTrack-expected.txt: Updated results.
* fast/mediastream/MediaStreamTrack.html: Update to test track.stop() behavior.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158220 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 35793310
2013-10-29 Eric Carlson <eric.carlson@apple.com>
[Mac MediaStream] implement AVFoundation backed MediaStreamSource
https://bugs.webkit.org/show_bug.cgi?id=123316
Reviewed by Jer Noble.
* fast/mediastream/MediaStream-add-remove-tracks-expected.txt: Updated.
* fast/mediastream/MediaStream-add-remove-tracks.html: Ditto.
* fast/mediastream/MediaStreamConstructor-expected.txt: Ditto.
* fast/mediastream/MediaStreamConstructor.html: Ditto.
* fast/mediastream/MediaStreamTrack-getSources.html: Remove typo.
* fast/mediastream/MediaStreamTrack-expected.txt: Updated results.
* fast/mediastream/MediaStreamTrack.html: Update to test track.stop() behavior.
2013-10-29 Zoltan Horvath <zoltan@webkit.org>
[CSS Regions][CSS Shapes] Layout error when the shape has negative top coordinate and it's applied on the second region
......
......@@ -42,12 +42,14 @@ PASS stream1.getVideoTracks().length is 1
PASS stream1.getAudioTracks().length is 2
PASS stream1.getVideoTracks().length is 2
*** after all tracks have been removed, stream.ended should return true
*** remove all tracks, stream.ended should return true
PASS stream2.getAudioTracks().length is 0
PASS stream2.getVideoTracks().length is 0
PASS stream2.ended is true
*** it should be impossible to add a track after the stream has ended
PASS stream1.addTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
PASS stream1.removeTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
PASS stream2.addTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
PASS stream2.removeTrack(audioTrack) threw exception Error: InvalidStateError: DOM Exception 11.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -109,14 +109,16 @@ function gotStream2(s) {
shouldBe('stream1.getAudioTracks().length', '2');
shouldBe('stream1.getVideoTracks().length', '2');
debug("<br>*** after all tracks have been removed, stream.ended should return true");
debug("<br>*** remove all tracks, stream.ended should return true");
tryRemoveTrack(stream2, stream2.getAudioTracks()[0]);
tryRemoveTrack(stream2, stream2.getVideoTracks()[0]);
shouldBe('stream2.getAudioTracks().length', '0');
shouldBe('stream2.getVideoTracks().length', '0');
shouldBeTrue('stream2.ended');
debug("<br>*** it should be impossible to add a track after the stream has ended");
shouldThrow('stream1.addTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
shouldThrow('stream1.removeTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
shouldThrow('stream2.addTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
shouldThrow('stream2.removeTrack(audioTrack)', '"Error: InvalidStateError: DOM Exception 11"');
setTimeout(finishJSTest, 0);
}
......
......@@ -78,6 +78,7 @@ PASS newStream.constructor.toString() is '[object webkitMediaStreamConstructor]'
PASS newStream.getAudioTracks().length is nAudio
PASS newStream.getVideoTracks().length is nVideo
PASS checkIdAttribute(newStream.id) is true
PASS successfullyParsed is true
TEST COMPLETE
......@@ -84,6 +84,8 @@ function testConstructor(s) {
verifyStream("new webkitMediaStream([stream.getVideoTracks()[0]])", 0, 1);
verifyStream("new webkitMediaStream([stream.getAudioTracks()[0], stream.getVideoTracks()[0]])", 1, 1);
verifyStream("new webkitMediaStream([stream.getVideoTracks()[0], stream.getAudioTracks()[0], stream.getVideoTracks()[0]])", 1, 1);
finishJSTest();
}
function verifyStream(script, numAudioTracks, numVideoTracks) {
......
......@@ -26,8 +26,8 @@ checking track.capabilities()
max : 60
supported : true
aspectRatio
min : 1.3333333730697632
max : 1.7777777910232544
min : 1.33
max : 1.78
supported : true
facingMode
0 : user
......@@ -35,11 +35,14 @@ checking track.capabilities()
checking track.states()
PASS states.sourceId is capabilities.sourceId[0]
PASS states.sourceType is "camera"
width : 1920
height : 1080
frameRate : 30
aspectRatio : 1.7777777910232544
facingMode : user
states.volume = undefined
states.width = 1920
states.sourceId = 239c24b0-2b15-11e3-8224-0800200c9a66
states.height = 1080
states.sourceType = camera
states.facingMode = user
states.frameRate = 30
states.aspectRatio = 1.78
audioTrack = mediaStream.getAudioTracks()[0]
PASS track.readyState is "live"
......@@ -53,7 +56,14 @@ checking track.capabilities()
checking track.states()
PASS states.sourceId is capabilities.sourceId[0]
PASS states.sourceType is "microphone"
volume : 50
states.volume = 50
states.width = undefined
states.sourceId = 239c24b1-2b15-11e3-8224-0800200c9a66
states.height = undefined
states.sourceType = microphone
states.facingMode = undefined
states.frameRate = undefined
states.aspectRatio = undefined
videoTrack2 = videoTrack.clone()
PASS track.readyState is "live"
......@@ -76,8 +86,8 @@ checking track.capabilities()
max : 60
supported : true
aspectRatio
min : 1.3333333730697632
max : 1.7777777910232544
min : 1.33
max : 1.78
supported : true
facingMode
0 : user
......@@ -85,11 +95,14 @@ checking track.capabilities()
checking track.states()
PASS states.sourceId is capabilities.sourceId[0]
PASS states.sourceType is "camera"
width : 1920
height : 1080
frameRate : 30
aspectRatio : 1.7777777910232544
facingMode : user
states.volume = undefined
states.width = 1920
states.sourceId = 239c24b0-2b15-11e3-8224-0800200c9a66
states.height = 1080
states.sourceType = camera
states.facingMode = user
states.frameRate = 30
states.aspectRatio = 1.78
PASS videoTrack.id is not videoTrack2.id
PASS videoTrack.kind is videoTrack2.kind
PASS videoTrack.label is videoTrack2.label
......@@ -97,9 +110,12 @@ PASS videoTrack.muted is videoTrack2.muted
PASS videoTrack.enabled is videoTrack2.enabled
PASS videoTrack.readyState is videoTrack2.readyState
videoTrack.stop()
track.stop() should not fire 'ended' on the track it is called on, but it should end all tracks using the same source
videoTrack2.stop()
PASS Track onended callback succeeded.
PASS videoTrack is event.target
PASS videoTrack.readyState is "ended"
PASS videoTrack2.readyState is "ended"
PASS successfullyParsed is true
......
......@@ -31,7 +31,7 @@
primeTimeout("Timeout waiting for webkitGetUserMedia()");
constraints = _constraints;
callback = _callback;
debug("<br>*** calling navigator.webkitGetUserMedia() ***");
debug("<br>*** calling navigator.webkitGetUserMedia() ***");
shouldNotThrow("navigator.webkitGetUserMedia(constraints, callback, error)");
} catch (e) {
testFailed('webkitGetUserMedia threw exception :' + e);
......
......@@ -23,11 +23,13 @@
finishJSTest();
}
}
function onTrackEnded()
{
testPassed('Track onended callback succeeded.');
shouldBe('videoTrack', 'event.target');
shouldBeEqualToString('videoTrack.readyState', 'ended');
shouldBeEqualToString('videoTrack2.readyState', 'ended');
debug("");
finishJSTest();
}
......@@ -56,12 +58,19 @@
testPassed('Track onmute callback succeeded.');
shouldBeEqual('videoTrack.muted', true);
}
function limitPrecision(value, precision)
{
if (typeof value === "number" && value % 1 != 0)
return value.toFixed(precision);
return value;
}
function logCapabilityRange(name, range)
{
debug(" " + name);
debug(" min : " + range.min);
debug(" max : " + range.max);
debug(" min : " + limitPrecision(range.min, 2));
debug(" max : " + limitPrecision(range.max, 2));
debug(" supported : " + range.supported);
}
......@@ -69,7 +78,7 @@
{
debug(" " + name);
for (i = 0; i < list.length; i++)
debug(" " + i + " : " + list[i]);
debug(" " + i + " : " + list[i]);
}
function checkCapabilities(track)
......@@ -94,16 +103,13 @@
capabilities = track.capabilities();
states = track.states();
shouldBe('states.sourceId', 'capabilities.sourceId[0]');
if (track.kind == "video") {
if (track.kind == "video")
shouldBeEqualToString('states.sourceType', 'camera');
debug(" width : " + states.width);
debug(" height : " + states.height);
debug(" frameRate : " + states.frameRate);
debug(" aspectRatio : " + states.aspectRatio);
debug(" facingMode : " + states.facingMode);
} else {
else
shouldBeEqualToString('states.sourceType', 'microphone');
debug(" volume : " + states.volume);
for (var property in states) {
if (states.hasOwnProperty(property))
debug(" states." + property + " = " + limitPrecision(states[property], 2));
}
}
......@@ -136,6 +142,7 @@
debug("");
evalAndLog("videoTrack2 = videoTrack.clone()");
videoTrack2.onended = onTrackEnded;
checkTrack(videoTrack2);
shouldNotBe('videoTrack.id', 'videoTrack2.id');
shouldBe('videoTrack.kind', 'videoTrack2.kind');
......@@ -145,7 +152,8 @@
shouldBe('videoTrack.readyState', 'videoTrack2.readyState');
debug("");
evalAndLog("videoTrack.stop()");
debug("track.stop() should not fire 'ended' on the track it is called on, but it should end all tracks using the same source");
evalAndLog("videoTrack2.stop()");
}
function start()
......
......@@ -1990,6 +1990,7 @@ set(WebCore_SOURCES
platform/mediastream/MediaStreamDescriptor.cpp
platform/mediastream/MediaStreamTrackPrivate.cpp
platform/mediastream/MediaStreamSource.cpp
platform/mediastream/MediaStreamSourceStates.cpp
platform/mediastream/RTCIceCandidateDescriptor.cpp
platform/mediastream/RTCPeerConnectionHandler.cpp
platform/mediastream/RTCSessionDescriptionDescriptor.cpp
......
2013-10-29 Eric Carlson <eric.carlson@apple.com>
[Mac MediaStream] implement AVFoundation backed MediaStreamSource
https://bugs.webkit.org/show_bug.cgi?id=123316
Reviewed by Jer Noble
No new tests, existing tests updated.
* CMakeLists.txt: Add MediaStreamSourceStates.cpp.
* Modules/mediastream/MediaSourceStates.cpp:
(WebCore::MediaSourceStates::MediaSourceStates): m_SourceStates -> m_sourceStates.
(WebCore::MediaSourceStates::sourceType): Ditto.
(WebCore::MediaSourceStates::facingMode): Ditto.
* Modules/mediastream/MediaSourceStates.h: Ditto.
* Modules/mediastream/MediaSourceStates.idl: Mark some attributes as optional.
* Modules/mediastream/MediaStream.cpp:
(WebCore::MediaStream::addTrack):
(WebCore::MediaStream::removeTrack):
(WebCore::MediaStream::addRemoteSource):
(WebCore::MediaStream::removeRemoteSource):
* Modules/mediastream/MediaStreamCapabilities.cpp:
(WebCore::MediaStreamCapabilities::sourceType): MediaSourceStates -> MediaStreamSourceStates
(WebCore::MediaStreamCapabilities::facingMode): Ditto.
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::MediaStreamTrack): Don't observe source changes directly, let the
private track do that. Change private track parameter to ref because it can't be NULL.
(WebCore::MediaStreamTrack::~MediaStreamTrack): Ditto.
(WebCore::MediaStreamTrack::setSource): Pass through to private track.
(WebCore::MediaStreamTrack::stopped): Ditto.
(WebCore::MediaStreamTrack::states): Ditto.
(WebCore::MediaStreamTrack::capabilities): Ditto.
(WebCore::MediaStreamTrack::applyConstraints): Ditto.
(WebCore::MediaStreamTrack::stopProducingData): Ditto.
(WebCore::MediaStreamTrack::trackReadyStateChanged): Renamed from sourceStateChanged. Don't
schedule an 'ended' event if called as a side effect of the stop() method having been
called as per spec.
(WebCore::MediaStreamTrack::trackMutedChanged): Renamed from sourceMutedChanged.
(WebCore::MediaStreamTrack::trackEnabledChanged): Renamed from sourceEnabledChanged.
(WebCore::MediaStreamTrack::stop): Pass through to private track.
* Modules/mediastream/MediaStreamTrack.h:
(WebCore::MediaStreamTrack::Observer::~Observer): Add virtual destructor.
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::callSuccessHandler): Set track, not source, constraints.
* WebCore.xcodeproj/project.pbxproj: Add new files.
* bindings/js/JSMediaSourceStatesCustom.cpp:
(WebCore::JSMediaSourceStates::facingMode): Return jsUndefined when the facing mode
is Unknown.
* platform/mediastream/MediaStreamCenter.h: Remove unused class forward defines and
undefined method prototype.
* platform/mediastream/MediaStreamDescriptor.cpp:
(WebCore::MediaStreamDescriptor::addSource): ASSERT if source is kind None.
(WebCore::MediaStreamDescriptor::removeSource): Ditto.
(WebCore::MediaStreamDescriptor::MediaStreamDescriptor):
* platform/mediastream/MediaStreamSource.cpp:
(WebCore::MediaStreamSource::setReadyState): Call startProducingData when readyState changes
to Live, stopProducingData when it changes to Ended.
(WebCore::MediaStreamSource::removeObserver): Call stop() when there are no more observers.
(WebCore::MediaStreamSource::setEnabled): If passed false, do nothing unless all observers
are disabled. Call startProducingData/stopProducingData when becoming enabled/disabled.
(WebCore::MediaStreamSource::stop): Don't bother checking to see if other observers have
stopped, the spec says that track.stop() should permanently stop the track's source.
* platform/mediastream/MediaStreamSource.h:
(WebCore::MediaStreamSource::name): Make virtual so derived classes can override.
(WebCore::MediaStreamSource::setName): Ditto.
(WebCore::MediaStreamSource::readyState): Ditto.
(WebCore::MediaStreamSource::enabled): Ditto.
(WebCore::MediaStreamSource::muted): Ditto.
(WebCore::MediaStreamSource::setReadonly): Ditto.
(WebCore::MediaStreamSource::remote): Ditto.
(WebCore::MediaStreamSource::setRemote): Ditto.
(WebCore::MediaStreamSource::startProducingData): Added.
(WebCore::MediaStreamSource::stopProducingData): Added.
* platform/mediastream/MediaStreamSourceCapabilities.h: Move MediaStreamSourceStates to
its own file.
* platform/mediastream/MediaStreamSourceStates.cpp: Added.
(WebCore::MediaStreamSourceStates::facingMode): Moved here from MediaSourceStates so the
strings are available to platform code.
(WebCore::MediaStreamSourceStates::sourceType): Ditto.
* platform/mediastream/MediaStreamSourceStates.h: Added, moved from MediaStreamSourceCapabilities.h.
* platform/mediastream/MediaStreamTrackPrivate.cpp:
(WebCore::MediaStreamTrackPrivate::create): Pass private track to constructor as PassRefPtr.
(WebCore::MediaStreamTrackPrivate::MediaStreamTrackPrivate): Initialize member variables.
(WebCore::MediaStreamTrackPrivate::~MediaStreamTrackPrivate): Unregister as source observer.
(WebCore::MediaStreamTrackPrivate::setSource): Unregister/register as source observer.
(WebCore::MediaStreamTrackPrivate::setEnabled): Enable/disable source, call client.
(WebCore::MediaStreamTrackPrivate::stop): New. Set readyState to Ended, optionally stop source.
(WebCore::MediaStreamTrackPrivate::setReadyState): Inline the logic from shouldFireTrackReadyStateChanged.
(WebCore::MediaStreamTrackPrivate::constraints): New, passthrough to the source.
(WebCore::MediaStreamTrackPrivate::states): Ditto.
(WebCore::MediaStreamTrackPrivate::type): Ditto.
(WebCore::MediaStreamTrackPrivate::capabilities): Ditto.
(WebCore::MediaStreamTrackPrivate::applyConstraints): Ditto.
(WebCore::MediaStreamTrackPrivate::sourceReadyStateChanged): React to source changes.
(WebCore::MediaStreamTrackPrivate::sourceMutedChanged): Ditto.
(WebCore::MediaStreamTrackPrivate::sourceEnabledChanged): Ditto.
(WebCore::MediaStreamTrackPrivate::observerIsEnabled): Respond to source query.
(WebCore::MediaStreamTrackPrivate::observerIsStopped): Ditto.
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/mac/AVAudioCaptureSource.h: Added.
* platform/mediastream/mac/AVAudioCaptureSource.mm: Added.
* platform/mediastream/mac/AVCaptureDeviceManager.h: Added.
* platform/mediastream/mac/AVCaptureDeviceManager.mm: Added.
* platform/mediastream/mac/AVMediaCaptureSource.h: Added.
* platform/mediastream/mac/AVMediaCaptureSource.mm: Added.
* platform/mediastream/mac/AVVideoCaptureSource.h: Added.
* platform/mediastream/mac/AVVideoCaptureSource.mm: Added.
* platform/mediastream/mac/MediaStreamCenterMac.cpp:
(WebCore::MediaStreamCenterMac::validateRequestConstraints): Implement.
(WebCore::MediaStreamCenterMac::createMediaStream): Ditto.
(WebCore::MediaStreamCenterMac::getMediaStreamTrackSources): Ditto.
* platform/mock/MockMediaStreamCenter.cpp:
(WebCore::initializeMockSources): Update for MediaStreamSourceStates changes.
(WebCore::MockMediaStreamCenter::createMediaStream):
2013-10-29 Zoltan Horvath <zoltan@webkit.org>
[CSS Regions][CSS Shapes] Layout error when the shape has negative top coordinate and it's applied on the second region
......
......@@ -37,10 +37,10 @@ namespace WebCore {
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, const Dictionary& audioConstraints)
{
return adoptRef(new AudioStreamTrack(context, MediaStreamTrackPrivate::create(0), &audioConstraints));
return adoptRef(new AudioStreamTrack(context, *MediaStreamTrackPrivate::create(0), &audioConstraints));
}
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackPrivate> privateTrack)
RefPtr<AudioStreamTrack> AudioStreamTrack::create(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack)
{
return adoptRef(new AudioStreamTrack(context, privateTrack, 0));
}
......@@ -50,7 +50,7 @@ RefPtr<AudioStreamTrack> AudioStreamTrack::create(MediaStreamTrack* track)
return adoptRef(new AudioStreamTrack(track));
}
AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext* context, PassRefPtr<MediaStreamTrackPrivate> privateTrack, const Dictionary* audioConstraints)
AudioStreamTrack::AudioStreamTrack(ScriptExecutionContext* context, MediaStreamTrackPrivate& privateTrack, const Dictionary* audioConstraints)
: MediaStreamTrack(context, privateTrack, audioConstraints)
{
}
......
......@@ -40,7 +40,7 @@ class ScriptExecutionContext;
class AudioStreamTrack FINAL : public MediaStreamTrack {
public:
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, const Dictionary&);
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, PassRefPtr<MediaStreamTrackPrivate>);
static RefPtr<AudioStreamTrack> create(ScriptExecutionContext*, MediaStreamTrackPrivate&);
static RefPtr<AudioStreamTrack> create(MediaStreamTrack*);
virtual ~AudioStreamTrack() { }
......@@ -48,7 +48,7 @@ public:
virtual const AtomicString& kind() const OVERRIDE;
private:
AudioStreamTrack(ScriptExecutionContext*, PassRefPtr<MediaStreamTrackPrivate>, const Dictionary*);
AudioStreamTrack(ScriptExecutionContext*, MediaStreamTrackPrivate&, const Dictionary*);
explicit AudioStreamTrack(MediaStreamTrack*);
};
......
......@@ -39,59 +39,18 @@ RefPtr<MediaSourceStates> MediaSourceStates::create(const MediaStreamSourceState
}
MediaSourceStates::MediaSourceStates(const MediaStreamSourceStates& states)
: m_SourceStates(states)
: m_sourceStates(states)
{
}
const AtomicString& MediaSourceStates::facingMode(MediaStreamSourceStates::VideoFacingMode mode)
{
static NeverDestroyed<AtomicString> userFacing("user", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> environmentFacing("environment", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> leftFacing("left", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> rightFacing("right", AtomicString::ConstructFromLiteral);
switch (mode) {
case MediaStreamSourceStates::User:
return userFacing;
case MediaStreamSourceStates::Environment:
return environmentFacing;
case MediaStreamSourceStates::Left:
return leftFacing;
case MediaStreamSourceStates::Right:
return rightFacing;
}
ASSERT_NOT_REACHED();
return emptyAtom;
}
const AtomicString& MediaSourceStates::sourceType(MediaStreamSourceStates::SourceType sourceType)
{
static NeverDestroyed<AtomicString> none("none", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> camera("camera", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> microphone("microphone", AtomicString::ConstructFromLiteral);
switch (sourceType) {
case MediaStreamSourceStates::None:
return none;
case MediaStreamSourceStates::Camera:
return camera;
case MediaStreamSourceStates::Microphone:
return microphone;
}
ASSERT_NOT_REACHED();
return emptyAtom;
}
const AtomicString& MediaSourceStates::sourceType() const
{
return MediaSourceStates::sourceType(m_SourceStates.sourceType);
return MediaStreamSourceStates::sourceType(m_sourceStates.sourceType());
}
const AtomicString& MediaSourceStates::facingMode() const
{
return MediaSourceStates::facingMode(m_SourceStates.facingMode);
return MediaStreamSourceStates::facingMode(m_sourceStates.facingMode());
}
......
......@@ -39,24 +39,21 @@ class MediaSourceStates : public RefCounted<MediaSourceStates>, public ScriptWra
public:
static RefPtr<MediaSourceStates> create(const MediaStreamSourceStates&);
static const AtomicString& sourceType(MediaStreamSourceStates::SourceType);
static const AtomicString& facingMode(MediaStreamSourceStates::VideoFacingMode);
const AtomicString& sourceType() const;
const AtomicString& sourceId() const { return m_SourceStates.sourceId; }
unsigned long width() const { return m_SourceStates.width; }
unsigned long height() const { return m_SourceStates.height; }
float frameRate() const { return m_SourceStates.frameRate; }
float aspectRatio() const { return m_SourceStates.aspectRatio; }
const AtomicString& sourceId() const { return m_sourceStates.sourceId(); }
unsigned long width() const { return m_sourceStates.width(); }
unsigned long height() const { return m_sourceStates.height(); }
float frameRate() const { return m_sourceStates.frameRate(); }
float aspectRatio() const { return m_sourceStates.aspectRatio(); }
const AtomicString& facingMode() const;
unsigned long volume() const { return m_SourceStates.volume; }
unsigned long volume() const { return m_sourceStates.volume(); }
bool hasVideoSource() const { return m_SourceStates.sourceType == MediaStreamSourceStates::Camera; }
bool hasVideoSource() const { return m_sourceStates.sourceType() == MediaStreamSourceStates::Camera; }
private:
explicit MediaSourceStates(const MediaStreamSourceStates&);
MediaStreamSourceStates m_SourceStates;
MediaStreamSourceStates m_sourceStates;
};
} // namespace WebCore
......
......@@ -34,11 +34,11 @@ enum VideoFacingModeEnum { "user", "environment", "left", "right" };
readonly attribute SourceTypeEnum sourceType;
readonly attribute DOMString sourceId;
[CustomGetter] readonly attribute unsigned long width;
[CustomGetter] readonly attribute unsigned long height;
[CustomGetter] readonly attribute float frameRate;
[CustomGetter] readonly attribute float aspectRatio;
[CustomGetter] readonly attribute VideoFacingModeEnum facingMode;
[CustomGetter] readonly attribute unsigned long volume;
[CustomGetter] readonly attribute unsigned long? width;
[CustomGetter] readonly attribute unsigned long? height;
[CustomGetter] readonly attribute float? frameRate;
[CustomGetter] readonly attribute float? aspectRatio;
[CustomGetter] readonly attribute VideoFacingModeEnum? facingMode;
[CustomGetter] readonly attribute unsigned long? volume;
};
......@@ -122,7 +122,7 @@ MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStream
size_t numberOfAudioTracks = m_descriptor->numberOfAudioTracks();
m_audioTracks.reserveCapacity(numberOfAudioTracks);
for (size_t i = 0; i < numberOfAudioTracks; i++) {
track = AudioStreamTrack::create(context, m_descriptor->audioTracks(i));
track = AudioStreamTrack::create(context, *m_descriptor->audioTracks(i));
track->addObserver(this);
m_audioTracks.append(track.release());
}
......@@ -130,7 +130,7 @@ MediaStream::MediaStream(ScriptExecutionContext* context, PassRefPtr<MediaStream
size_t numberOfVideoTracks = m_descriptor->numberOfVideoTracks();
m_videoTracks.reserveCapacity(numberOfVideoTracks);
for (size_t i = 0; i < numberOfVideoTracks; i++) {
track = VideoStreamTrack::create(context, m_descriptor->videoTracks(i));
track = VideoStreamTrack::create(context, *m_descriptor->videoTracks(i));
track->addObserver(this);
m_videoTracks.append(track.release());
}
......@@ -191,6 +191,9 @@ void MediaStream::addTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCode&
case MediaStreamSource::Video:
m_videoTracks.append(track);
break;
case MediaStreamSource::None:
ASSERT_NOT_REACHED();
break;
}
track->addObserver(this);
......@@ -223,6 +226,9 @@ void MediaStream::removeTrack(PassRefPtr<MediaStreamTrack> prpTrack, ExceptionCo
if (pos != notFound)
m_videoTracks.remove(pos);
break;
case MediaStreamSource::None:
ASSERT_NOT_REACHED();
break;
}
if (pos == notFound)
......@@ -308,13 +314,16 @@ void MediaStream::addRemoteSource(MediaStreamSource* source)
RefPtr<MediaStreamTrack> track;
switch (source->type()) {
case MediaStreamSource::Audio:
track = AudioStreamTrack::create(scriptExecutionContext(), MediaStreamTrackPrivate::create(source));