source: trunk/Source/WebCore/platform/mediastream/MediaStreamCenter.h @ 174190

Revision 158220, 2.7 KB checked in by eric.carlson@apple.com, 11 months ago (diff)

[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.
Line 
1/*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer
13 *    in the documentation and/or other materials provided with the
14 *    distribution.
15 * 3. Neither the name of Ericsson nor the names of its contributors
16 *    may be used to endorse or promote products derived from this
17 *    software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef MediaStreamCenter_h
33#define MediaStreamCenter_h
34
35#if ENABLE(MEDIA_STREAM)
36
37#include "MediaStreamSource.h"
38#include <wtf/PassRefPtr.h>
39#include <wtf/text/WTFString.h>
40
41namespace WebCore {
42
43class MediaConstraints;
44class MediaStreamCreationClient;
45class MediaStreamSourceStates;
46class MediaStreamTrackSourcesRequestClient;
47
48class MediaStreamCenter {
49public:
50    virtual ~MediaStreamCenter();
51
52    static MediaStreamCenter& shared();
53    static void setSharedStreamCenter(MediaStreamCenter*);
54
55    virtual void validateRequestConstraints(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints) = 0;
56
57    virtual void createMediaStream(PassRefPtr<MediaStreamCreationClient>, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints) = 0;
58
59    virtual bool getMediaStreamTrackSources(PassRefPtr<MediaStreamTrackSourcesRequestClient>) = 0;
60
61protected:
62    MediaStreamCenter();
63
64    static MediaStreamCenter& platformCenter();
65};
66
67} // namespace WebCore
68
69#endif // ENABLE(MEDIA_STREAM)
70
71#endif // MediaStreamCenter_h
Note: See TracBrowser for help on using the repository browser.