[MSE][Mac] Add a new MSE-compatible MediaPlayerPrivate implementation, MediaPlayerPri...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Dec 2013 22:43:46 +0000 (22:43 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Dec 2013 22:43:46 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123378

Reviewed by Eric Carlson.

Add an AVFoundation implementation of MediaPlayerPrivate which creates and uses
MediaSourcePrivate and SourceBufferPrivate subclasses.

Add the new media engine to the list of installed engines:
* platform/MediaSample.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::installedMediaEngines):
* platform/graphics/MediaPlayer.h:

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

Drive by fix for ports who implement seekDouble():
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::seekWithTolerance):

Add new Video and AudioTrackPrivate types which handle their own enable state:
* platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp: Added
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC):
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack):
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::setAssetTrack):
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::assetTrack):
(WebCore::AudioTrackPrivateMediaSourceAVFObjC::setEnabled):
* platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h: Added
* platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp: Added.
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::VideoTrackPrivateMediaSourceAVFObjC):
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack):
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::setAssetTrack):
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::assetTrack):
(WebCore::VideoTrackPrivateMediaSourceAVFObjC::setSelected):
* platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h: Added.

Add a new MediaPlayerPrivate which can handle MediaSource objects:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: Added.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: Added.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::create):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable):
(WebCore::mimeTypeCache):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cancelLoad):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::prepareToPlay):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformMedia):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::playInternal):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paused):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasVideo):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasAudio):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVisible):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationDouble):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::currentTimeDouble):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::startTimeDouble):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::initialTime):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seeking):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setRateDouble):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::networkState):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::readyState):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekable):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::maxTimeSeekableDouble):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::minTimeSeekable):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setSize):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasAvailableVideoFrame):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsAcceleratedRendering):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::movieLoadType):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::prepareForRendering):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::engineDescription):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::languageOfPrimaryAudioTrack):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::extraMemoryCost):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateDuration):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateStates):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setReadyState):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer):

Add a new MediaSourcePrivate implementation:
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h: Added.
(WebCore::MediaSourcePrivateAVFObjC::player):
(WebCore::MediaSourcePrivateAVFObjC::activeSourceBuffers):
* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: Added.
(WebCore::MediaSourcePrivateAVFObjC::create):
(WebCore::MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC):
(WebCore::MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC):
(WebCore::MediaSourcePrivateAVFObjC::addSourceBuffer):
(WebCore::MediaSourcePrivateAVFObjC::removeSourceBuffer):
(WebCore::MediaSourcePrivateAVFObjC::duration):
(WebCore::MediaSourcePrivateAVFObjC::setDuration):
(WebCore::MediaSourcePrivateAVFObjC::markEndOfStream):
(WebCore::MediaSourcePrivateAVFObjC::unmarkEndOfStream):
(WebCore::MediaSourcePrivateAVFObjC::readyState):
(WebCore::MediaSourcePrivateAVFObjC::setReadyState):
(WebCore::MediaSourcePrivateAVFObjC::sourceBufferPrivateDidChangeActiveState):
(WebCore::MediaSourcePrivateAVFObjCHasAudio):
(WebCore::MediaSourcePrivateAVFObjC::hasAudio):
(WebCore::MediaSourcePrivateAVFObjCHasVideo):
(WebCore::MediaSourcePrivateAVFObjC::hasVideo):
(WebCore::MediaSourcePrivateAVFObjC::seekToTime):

Add a new SourceBufferPrivate implementation:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Added.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: Added.
(-[WebAVStreamDataParserListener initWithParser:parent:WebCore::]):
(-[WebAVStreamDataParserListener dealloc]):
(-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]):
(-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]):
(-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]):
(-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]):
(WebCore::MediaSampleAVFObjC::create):
(WebCore::MediaSampleAVFObjC::~MediaSampleAVFObjC):
(WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC):
(WebCore::MediaSampleAVFObjC::platformSample):
(WebCore::CMSampleBufferIsRandomAccess):
(WebCore::MediaSampleAVFObjC::flags):
(WebCore::MediaDescriptionAVFObjC::create):
(WebCore::MediaDescriptionAVFObjC::~MediaDescriptionAVFObjC):
(WebCore::MediaDescriptionAVFObjC::MediaDescriptionAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::create):
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
(WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
(WebCore::SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError):
(WebCore::callProcessCodedFrameForEachSample):
(WebCore::SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackID):
(WebCore::SourceBufferPrivateAVFObjC::processCodedFrame):
(WebCore::SourceBufferPrivateAVFObjC::didReachEndOfTrackWithTrackID):
(WebCore::SourceBufferPrivateAVFObjC::setClient):
(WebCore::SourceBufferPrivateAVFObjC::append):
(WebCore::SourceBufferPrivateAVFObjC::abort):
(WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource):
(WebCore::SourceBufferPrivateAVFObjC::readyState):
(WebCore::SourceBufferPrivateAVFObjC::setReadyState):
(WebCore::SourceBufferPrivateAVFObjC::evictCodedFrames):
(WebCore::SourceBufferPrivateAVFObjC::isFull):
(WebCore::SourceBufferPrivateAVFObjC::hasVideo):
(WebCore::SourceBufferPrivateAVFObjC::hasAudio):
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
(WebCore::createNonDisplayingCopy):
(WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples):
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
(WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples):
(WebCore::SourceBufferPrivateAVFObjC::setActive):
(WebCore::SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime):
(WebCore::SourceBufferPrivateAVFObjC::seekToTime):
* platform/mac/PlatformClockCM.h:

Add a SOFT_LINK_CLASS_OPTIONAL macro:
* platform/mac/SoftLinking.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160251 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h [new file with mode: 0644]
Source/WebCore/platform/mac/PlatformClockCM.h
Source/WebCore/platform/mac/SoftLinking.h

index 93df477..5c47781 100644 (file)
@@ -1,3 +1,176 @@
+2013-11-15  Jer Noble  <jer.noble@apple.com>
+
+        [MSE][Mac] Add a new MSE-compatible MediaPlayerPrivate implementation, MediaPlayerPrivateMediaSourceAVFObjC
+        https://bugs.webkit.org/show_bug.cgi?id=123378
+
+        Reviewed by Eric Carlson.
+
+        Add an AVFoundation implementation of MediaPlayerPrivate which creates and uses
+        MediaSourcePrivate and SourceBufferPrivate subclasses.
+
+        Add the new media engine to the list of installed engines:
+        * platform/MediaSample.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::installedMediaEngines):
+        * platform/graphics/MediaPlayer.h:
+
+        Add the new files to the project:
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Drive by fix for ports who implement seekDouble():
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::seekWithTolerance):
+
+        Add new Video and AudioTrackPrivate types which handle their own enable state:
+        * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp: Added
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC):
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack):
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::setAssetTrack):
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::assetTrack):
+        (WebCore::AudioTrackPrivateMediaSourceAVFObjC::setEnabled):
+        * platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h: Added
+        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp: Added.
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::VideoTrackPrivateMediaSourceAVFObjC):
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack):
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::setAssetTrack):
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::assetTrack):
+        (WebCore::VideoTrackPrivateMediaSourceAVFObjC::setSelected):
+        * platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h: Added.
+
+        Add a new MediaPlayerPrivate which can handle MediaSource objects:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: Added.
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: Added.
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::create):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable):
+        (WebCore::mimeTypeCache):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::load):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::cancelLoad):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::prepareToPlay):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformMedia):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::platformLayer):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::playInternal):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paused):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::naturalSize):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasVideo):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasAudio):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setVisible):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationDouble):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::currentTimeDouble):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::startTimeDouble):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::initialTime):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seeking):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setRateDouble):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::networkState):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::readyState):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekable):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::maxTimeSeekableDouble):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::minTimeSeekable):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setSize):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paint):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::hasAvailableVideoFrame):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsAcceleratedRendering):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::movieLoadType):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::prepareForRendering):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::engineDescription):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::languageOfPrimaryAudioTrack):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::extraMemoryCost):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::destroyLayer):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateDuration):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::updateStates):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setReadyState):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer):
+        (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer):
+
+        Add a new MediaSourcePrivate implementation:
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h: Added.
+        (WebCore::MediaSourcePrivateAVFObjC::player):
+        (WebCore::MediaSourcePrivateAVFObjC::activeSourceBuffers):
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm: Added.
+        (WebCore::MediaSourcePrivateAVFObjC::create):
+        (WebCore::MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC):
+        (WebCore::MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC):
+        (WebCore::MediaSourcePrivateAVFObjC::addSourceBuffer):
+        (WebCore::MediaSourcePrivateAVFObjC::removeSourceBuffer):
+        (WebCore::MediaSourcePrivateAVFObjC::duration):
+        (WebCore::MediaSourcePrivateAVFObjC::setDuration):
+        (WebCore::MediaSourcePrivateAVFObjC::markEndOfStream):
+        (WebCore::MediaSourcePrivateAVFObjC::unmarkEndOfStream):
+        (WebCore::MediaSourcePrivateAVFObjC::readyState):
+        (WebCore::MediaSourcePrivateAVFObjC::setReadyState):
+        (WebCore::MediaSourcePrivateAVFObjC::sourceBufferPrivateDidChangeActiveState):
+        (WebCore::MediaSourcePrivateAVFObjCHasAudio):
+        (WebCore::MediaSourcePrivateAVFObjC::hasAudio):
+        (WebCore::MediaSourcePrivateAVFObjCHasVideo):
+        (WebCore::MediaSourcePrivateAVFObjC::hasVideo):
+        (WebCore::MediaSourcePrivateAVFObjC::seekToTime):
+
+        Add a new SourceBufferPrivate implementation:
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: Added.
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: Added.
+        (-[WebAVStreamDataParserListener initWithParser:parent:WebCore::]):
+        (-[WebAVStreamDataParserListener dealloc]):
+        (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]):
+        (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]):
+        (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]):
+        (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]):
+        (WebCore::MediaSampleAVFObjC::create):
+        (WebCore::MediaSampleAVFObjC::~MediaSampleAVFObjC):
+        (WebCore::MediaSampleAVFObjC::MediaSampleAVFObjC):
+        (WebCore::MediaSampleAVFObjC::platformSample):
+        (WebCore::CMSampleBufferIsRandomAccess):
+        (WebCore::MediaSampleAVFObjC::flags):
+        (WebCore::MediaDescriptionAVFObjC::create):
+        (WebCore::MediaDescriptionAVFObjC::~MediaDescriptionAVFObjC):
+        (WebCore::MediaDescriptionAVFObjC::MediaDescriptionAVFObjC):
+        (WebCore::SourceBufferPrivateAVFObjC::create):
+        (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+        (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
+        (WebCore::SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset):
+        (WebCore::SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError):
+        (WebCore::callProcessCodedFrameForEachSample):
+        (WebCore::SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackID):
+        (WebCore::SourceBufferPrivateAVFObjC::processCodedFrame):
+        (WebCore::SourceBufferPrivateAVFObjC::didReachEndOfTrackWithTrackID):
+        (WebCore::SourceBufferPrivateAVFObjC::setClient):
+        (WebCore::SourceBufferPrivateAVFObjC::append):
+        (WebCore::SourceBufferPrivateAVFObjC::abort):
+        (WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource):
+        (WebCore::SourceBufferPrivateAVFObjC::readyState):
+        (WebCore::SourceBufferPrivateAVFObjC::setReadyState):
+        (WebCore::SourceBufferPrivateAVFObjC::evictCodedFrames):
+        (WebCore::SourceBufferPrivateAVFObjC::isFull):
+        (WebCore::SourceBufferPrivateAVFObjC::hasVideo):
+        (WebCore::SourceBufferPrivateAVFObjC::hasAudio):
+        (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
+        (WebCore::createNonDisplayingCopy):
+        (WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples):
+        (WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
+        (WebCore::SourceBufferPrivateAVFObjC::isReadyForMoreSamples):
+        (WebCore::SourceBufferPrivateAVFObjC::setActive):
+        (WebCore::SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime):
+        (WebCore::SourceBufferPrivateAVFObjC::seekToTime):
+        * platform/mac/PlatformClockCM.h:
+
+        Add a SOFT_LINK_CLASS_OPTIONAL macro:
+        * platform/mac/SoftLinking.h:
+
 2013-12-06  Alexey Proskuryakov  <ap@apple.com>
 
         Remove some duplicate checks from SerializedScriptValue
index 4eaeea4..aefd3b9 100644 (file)
@@ -993,12 +993,12 @@ void SourceBuffer::sourceBufferPrivateDidReceiveSample(SourceBufferPrivate*, Pas
 
 bool SourceBuffer::sourceBufferPrivateHasAudio(const SourceBufferPrivate*) const
 {
-    return m_audioTracks->length();
+    return m_audioTracks && m_audioTracks->length();
 }
 
 bool SourceBuffer::sourceBufferPrivateHasVideo(const SourceBufferPrivate*) const
 {
-    return m_videoTracks->length();
+    return m_videoTracks && m_videoTracks->length();
 }
 
 void SourceBuffer::videoTrackSelectedChanged(VideoTrack* track)
index 6955bb4..6120d8a 100644 (file)
                CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
                CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */; };
                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CD5393D2175E018600C07123 /* JSMemoryInfo.h */; };
+               CD54A762180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */; };
+               CD54A763180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */; };
                CD54DE4717468B6F005E5B36 /* AudioSessionManagerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54DE4517468B6F005E5B36 /* AudioSessionManagerMac.cpp */; };
                CD54DE4B17469C6D005E5B36 /* AudioSessionMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */; };
                CD61FE671794AADB004101EB /* MediaSourceRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B1A942E115B5CE2200D525D1 /* MediaSourceRegistry.cpp */; };
                CD82030D1395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */; };
                CD8203101395ACE700F956C6 /* WebWindowAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD8203111395ACE700F956C6 /* WebWindowAnimation.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */; };
+               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */; };
+               CD8B5A43180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */; };
                CD8B5A46180DFF4E008B8E65 /* VideoTrackMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A45180DFF4E008B8E65 /* VideoTrackMediaSource.h */; };
                CD8B5A49180E138B008B8E65 /* TextTrackMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A48180E138B008B8E65 /* TextTrackMediaSource.h */; };
                CD8B5A4C180E17C0008B8E65 /* AudioTrackMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8B5A4B180E17C0008B8E65 /* AudioTrackMediaSource.h */; };
                CDC69DD71632026C007C38DF /* WebCoreFullScreenWarningView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */; };
                CDC69DDA16371FD4007C38DF /* WebCoreFullScreenPlaceholderView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC69DD816371FD3007C38DF /* WebCoreFullScreenPlaceholderView.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CDC69DDB16371FD4007C38DF /* WebCoreFullScreenPlaceholderView.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC69DD916371FD3007C38DF /* WebCoreFullScreenPlaceholderView.mm */; };
+               CDC8B5A2180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC8B5A0180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.mm */; };
+               CDC8B5A3180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A1180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h */; };
+               CDC8B5A6180474F70016E685 /* MediaSourcePrivateAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC8B5A4180474F70016E685 /* MediaSourcePrivateAVFObjC.mm */; };
+               CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A5180474F70016E685 /* MediaSourcePrivateAVFObjC.h */; };
+               CDC8B5AA18047FF10016E685 /* SourceBufferPrivateAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDC8B5A818047FF10016E685 /* SourceBufferPrivateAVFObjC.mm */; };
+               CDC8B5AB18047FF10016E685 /* SourceBufferPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */; };
                CDC8B5AD1804AE5D0016E685 /* SourceBufferPrivateClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */; };
                CDD525D7145B6DD0008D204D /* JSHTMLMediaElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDF65CCC145B6AFE00C4C7AA /* JSHTMLMediaElementCustom.cpp */; };
                CDD7089618359F6F002B3DC6 /* SampleMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDD7089418359F6E002B3DC6 /* SampleMap.cpp */; };
                CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMemoryInfo.cpp; sourceTree = "<group>"; };
                CD5393D2175E018600C07123 /* JSMemoryInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMemoryInfo.h; sourceTree = "<group>"; };
                CD54A75E180F535000B076C9 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
+               CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AudioTrackPrivateMediaSourceAVFObjC.cpp; path = objc/AudioTrackPrivateMediaSourceAVFObjC.cpp; sourceTree = "<group>"; };
+               CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioTrackPrivateMediaSourceAVFObjC.h; path = objc/AudioTrackPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
                CD54DE4517468B6F005E5B36 /* AudioSessionManagerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSessionManagerMac.cpp; sourceTree = "<group>"; };
                CD54DE4917469C6D005E5B36 /* AudioSessionMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioSessionMac.cpp; sourceTree = "<group>"; };
                CD641EB11818F5ED00EE4C41 /* MediaSourcePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourcePrivate.h; sourceTree = "<group>"; };
                CD8203091395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenHUDWindowController.mm; sourceTree = "<group>"; };
                CD82030E1395ACE700F956C6 /* WebWindowAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebWindowAnimation.h; sourceTree = "<group>"; };
                CD82030F1395ACE700F956C6 /* WebWindowAnimation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebWindowAnimation.mm; sourceTree = "<group>"; };
+               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTrackPrivateMediaSourceAVFObjC.cpp; path = objc/VideoTrackPrivateMediaSourceAVFObjC.cpp; sourceTree = "<group>"; };
+               CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoTrackPrivateMediaSourceAVFObjC.h; path = objc/VideoTrackPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
                CD8B5A44180DD8D6008B8E65 /* VideoTrackMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = VideoTrackMediaSource.idl; sourceTree = "<group>"; };
                CD8B5A45180DFF4E008B8E65 /* VideoTrackMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoTrackMediaSource.h; sourceTree = "<group>"; };
                CD8B5A47180E1361008B8E65 /* TextTrackMediaSource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = TextTrackMediaSource.idl; sourceTree = "<group>"; };
                CDC69DD51632026C007C38DF /* WebCoreFullScreenWarningView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenWarningView.mm; sourceTree = "<group>"; };
                CDC69DD816371FD3007C38DF /* WebCoreFullScreenPlaceholderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreFullScreenPlaceholderView.h; sourceTree = "<group>"; };
                CDC69DD916371FD3007C38DF /* WebCoreFullScreenPlaceholderView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreFullScreenPlaceholderView.mm; sourceTree = "<group>"; };
+               CDC8B5A0180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MediaPlayerPrivateMediaSourceAVFObjC.mm; path = objc/MediaPlayerPrivateMediaSourceAVFObjC.mm; sourceTree = "<group>"; };
+               CDC8B5A1180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaPlayerPrivateMediaSourceAVFObjC.h; path = objc/MediaPlayerPrivateMediaSourceAVFObjC.h; sourceTree = "<group>"; };
+               CDC8B5A4180474F70016E685 /* MediaSourcePrivateAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MediaSourcePrivateAVFObjC.mm; path = objc/MediaSourcePrivateAVFObjC.mm; sourceTree = "<group>"; };
+               CDC8B5A5180474F70016E685 /* MediaSourcePrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaSourcePrivateAVFObjC.h; path = objc/MediaSourcePrivateAVFObjC.h; sourceTree = "<group>"; };
+               CDC8B5A818047FF10016E685 /* SourceBufferPrivateAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SourceBufferPrivateAVFObjC.mm; path = objc/SourceBufferPrivateAVFObjC.mm; sourceTree = "<group>"; };
+               CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceBufferPrivateAVFObjC.h; path = objc/SourceBufferPrivateAVFObjC.h; sourceTree = "<group>"; };
                CDC8B5AC1804AE5D0016E685 /* SourceBufferPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceBufferPrivateClient.h; sourceTree = "<group>"; };
                CDCE5CD014633BC900D47CCA /* EventTargetFactory.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventTargetFactory.in; sourceTree = "<group>"; };
                CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentation.h; sourceTree = "<group>"; };
                DF9AFD6F13FC31B00015FEB7 /* objc */ = {
                        isa = PBXGroup;
                        children = (
-                               CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
-                               CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
-                               CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */,
                                CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */,
+                               CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */,
+                               CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */,
+                               CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
+                               CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
+                               CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
                                07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */,
                                07AA6B6A166D019500D45671 /* InbandTextTrackPrivateAVFObjC.mm */,
                                07367DDD172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.h */,
                                07367DDE172CA67F00D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.mm */,
                                DF9AFD7013FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.h */,
                                DF9AFD7113FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm */,
-                               CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
-                               CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
+                               CDC8B5A1180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h */,
+                               CDC8B5A0180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.mm */,
+                               CDC8B5A5180474F70016E685 /* MediaSourcePrivateAVFObjC.h */,
+                               CDC8B5A4180474F70016E685 /* MediaSourcePrivateAVFObjC.mm */,
+                               CDC8B5A918047FF10016E685 /* SourceBufferPrivateAVFObjC.h */,
+                               CDC8B5A818047FF10016E685 /* SourceBufferPrivateAVFObjC.mm */,
                                CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */,
                                CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */,
+                               CD8B5A40180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp */,
+                               CD8B5A41180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h */,
+                               CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
+                               CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
                        );
                        name = objc;
                        sourceTree = "<group>";
                                85BCBC130ABBA87D00381160 /* DOMHTMLDocument.h in Headers */,
                                85E711A60AC5D5350053270F /* DOMHTMLDocumentInternal.h in Headers */,
                                85DF2EED0AA387CB00AD64C5 /* DOMHTMLElement.h in Headers */,
+                               CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */,
                                85E711A70AC5D5350053270F /* DOMHTMLElementInternal.h in Headers */,
                                8540756A0AD6CBF900620C57 /* DOMHTMLEmbedElement.h in Headers */,
                                855247D00AD850B80012093B /* DOMHTMLEmbedElementInternal.h in Headers */,
                                85031B420A44EFC700F992E0 /* Event.h in Headers */,
                                4138D3351244054800323D33 /* EventContext.h in Headers */,
                                CDAB6D2917C7DE6C00C60B34 /* MediaControlsHost.h in Headers */,
+                               CDC8B5A3180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.h in Headers */,
                                418A06D0133C04D500CD379C /* EventDispatcher.h in Headers */,
                                BC60D90C0D2A17CE00B9918F /* EventException.h in Headers */,
                                97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
                                078E091517D14D1C00420AA1 /* MediaStream.h in Headers */,
                                0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */,
                                77EF62F412F9DB7400C77BD2 /* JSWebGLVertexArrayObjectOES.h in Headers */,
+                               CDC8B5AB18047FF10016E685 /* SourceBufferPrivateAVFObjC.h in Headers */,
                                31C0FF3E0E4CEFAC007D6FE5 /* JSWebKitAnimationEvent.h in Headers */,
                                A2E8AE3816A49840006BB3AA /* JSWebKitCSSFilterRule.h in Headers */,
                                310603751432819C00ABF4BA /* JSWebKitCSSFilterValue.h in Headers */,
                                E4AFD00C0DAF335400F5F55C /* SMILTime.h in Headers */,
                                E4AFD00E0DAF335500F5F55C /* SMILTimeContainer.h in Headers */,
                                51ABAE1B103C18FF008C5260 /* SocketStreamError.h in Headers */,
+                               CD54A763180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h in Headers */,
                                510D4A34103165EE0049EA54 /* SocketStreamErrorBase.h in Headers */,
                                51ABAE1E103C1913008C5260 /* SocketStreamHandle.h in Headers */,
                                51D719BE181106E00016DC51 /* IDBCallbacks.h in Headers */,
                                1A2E6E5A0CC55213004A2062 /* SQLValue.h in Headers */,
                                93F1996308245E59001E9ABC /* SSLKeyGenerator.h in Headers */,
                                BC7FA62D0D1F0EFF00DB22A9 /* StaticNodeList.h in Headers */,
+                               CD8B5A43180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.h in Headers */,
                                A5AFB350115151A700B045CB /* StepRange.h in Headers */,
                                1AC2D845171734A100652FC0 /* Storage.h in Headers */,
                                51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */,
                                A7CFB3D10B7ED10A0070C32D /* DragImage.cpp in Sources */,
                                A7CFB3D50B7ED1180070C32D /* DragImageMac.mm in Sources */,
                                498770DB1242C535002226BA /* DrawingBuffer.cpp in Sources */,
+                               CDC8B5A6180474F70016E685 /* MediaSourcePrivateAVFObjC.mm in Sources */,
                                498771531243F9FA002226BA /* DrawingBufferMac.mm in Sources */,
                                078E091217D14CEE00420AA1 /* UserMediaController.cpp in Sources */,
                                FD6ED2C7136B8E66003CF072 /* DynamicsCompressor.cpp in Sources */,
                                07969DB917D14151007FF842 /* JSRTCPeerConnection.cpp in Sources */,
                                E0FEF372B27C53EAC1C1FBEE /* EventSource.cpp in Sources */,
                                E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */,
+                               CD8B5A42180D149A008B8E65 /* VideoTrackPrivateMediaSourceAVFObjC.cpp in Sources */,
                                BC60D8F20D2A11E000B9918F /* ExceptionBase.cpp in Sources */,
                                973DC63F145A9409002842C2 /* ExceptionCodeDescription.cpp in Sources */,
                                A7CACDB113CE875C00BBBE3F /* ExceptionCodePlaceholder.cpp in Sources */,
                                F50664F7157F52DC00AC226F /* FormController.cpp in Sources */,
                                514C766F0CE923A1007EF3CD /* FormData.cpp in Sources */,
                                085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */,
+                               CDC8B5AA18047FF10016E685 /* SourceBufferPrivateAVFObjC.mm in Sources */,
                                A8136D390973A8E700D74463 /* FormDataList.cpp in Sources */,
                                7EE6846612D26E3800E79415 /* FormDataStreamCFNet.cpp in Sources */,
                                514C764F0CE9234E007EF3CD /* FormDataStreamMac.mm in Sources */,
                                65DF31F909D1CC60000BE325 /* JSElement.cpp in Sources */,
                                BC2ED5550C6B9BD300920BFF /* JSElementCustom.cpp in Sources */,
                                65DF322F09D1DDBC000BE325 /* JSEntity.cpp in Sources */,
+                               CD54A762180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp in Sources */,
                                93F9B7740BA5FDDC00854064 /* JSEntityReference.cpp in Sources */,
                                2ECF7ADC10162B3800427DE7 /* JSErrorEvent.cpp in Sources */,
                                F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */,
                                B2227A560D00BF220071B782 /* SVGParserUtilities.cpp in Sources */,
                                84C6784C1214814700A92902 /* SVGPathBlender.cpp in Sources */,
                                8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */,
+                               CDC8B5A2180463470016E685 /* MediaPlayerPrivateMediaSourceAVFObjC.mm in Sources */,
                                8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */,
                                8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */,
                                B2227A580D00BF220071B782 /* SVGPathElement.cpp in Sources */,
index 1096fb7..744d3c7 100644 (file)
 namespace WebCore {
 
 class MockSampleBox;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
 
 struct PlatformSample {
     enum {
         None,
         MockSampleBoxType,
+        CMSampleBufferType,
     } type;
     union {
         MockSampleBox* mockSampleBox;
+        CMSampleBufferRef cmSampleBuffer;
     } sample;
 };
 
@@ -56,6 +59,7 @@ public:
     enum SampleFlags {
         None = 0,
         IsSync = 1 << 0,
+        NonDisplaying = 1 << 1,
     };
     virtual SampleFlags flags() const = 0;
     virtual PlatformSample platformSample() = 0;
index 2264333..64658f7 100644 (file)
@@ -57,6 +57,9 @@
 #include "MediaPlayerPrivateQTKit.h"
 #if USE(AVFOUNDATION)
 #include "MediaPlayerPrivateAVFoundationObjC.h"
+#if ENABLE(MEDIA_SOURCE)
+#include "MediaPlayerPrivateMediaSourceAVFObjC.h"
+#endif
 #endif
 #elif OS(WINCE)
 #include "MediaPlayerPrivateWinCE.h"
@@ -213,6 +216,9 @@ static Vector<MediaPlayerFactory*>& installedMediaEngines(RequeryEngineOptions r
         if (Settings::isAVFoundationEnabled()) {
 #if PLATFORM(MAC) || PLATFORM(IOS)
             MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(addMediaEngine);
+#if ENABLE(MEDIA_SOURCE)
+            MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(addMediaEngine);
+#endif
 #elif PLATFORM(WIN)
             MediaPlayerPrivateAVFoundationCF::registerMediaEngine(addMediaEngine);
 #endif
index 8df01b1..d4e2190 100644 (file)
@@ -43,8 +43,9 @@
 #include <runtime/Uint8Array.h>
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
+#include <wtf/MediaTime.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/text/StringHash.h>
 
@@ -56,6 +57,7 @@
 #include "PlatformTextTrackMenu.h"
 #endif
 
+OBJC_CLASS AVAsset;
 OBJC_CLASS AVPlayer;
 OBJC_CLASS QTMovie;
 
@@ -86,7 +88,8 @@ struct PlatformMedia {
         ChromiumMediaPlayerType,
         QtMediaPlayerType,
         AVFoundationMediaPlayerType,
-        AVFoundationCFMediaPlayerType
+        AVFoundationCFMediaPlayerType,
+        AVFoundationAssetType,
     } type;
 
     union {
@@ -97,6 +100,7 @@ struct PlatformMedia {
         MediaPlayerPrivateInterface* qtMediaPlayer;
         AVPlayer* avfMediaPlayer;
         AVCFPlayer* avcfMediaPlayer;
+        AVAsset* avfAsset;
     } media;
 };
 
index 3fbde63..436c68b 100644 (file)
@@ -79,7 +79,7 @@ public:
 
     virtual void seek(float) { }
     virtual void seekDouble(double time) { seek(time); }
-    virtual void seekWithTolerance(double time, double, double) { seek(time); }
+    virtual void seekWithTolerance(double time, double, double) { seekDouble(time); }
 
     virtual bool seeking() const = 0;
 
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp b/Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.cpp
new file mode 100644 (file)
index 0000000..edd5773
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "AudioTrackPrivateMediaSourceAVFObjC.h"
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+#include "AVTrackPrivateAVFObjCImpl.h"
+#include "SourceBufferPrivateAVFObjC.h"
+
+namespace WebCore {
+
+AudioTrackPrivateMediaSourceAVFObjC::AudioTrackPrivateMediaSourceAVFObjC(AVAssetTrack* track, SourceBufferPrivateAVFObjC* parent)
+    : m_impl(std::make_unique<AVTrackPrivateAVFObjCImpl>(track))
+    , m_parent(parent)
+    , m_trackID(-1)
+    , m_enabled(false)
+{
+    resetPropertiesFromTrack();
+}
+
+void AudioTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack()
+{
+    m_trackID = m_impl->trackID();
+
+    setKind(m_impl->audioKind());
+    setId(m_impl->id());
+    setLabel(m_impl->label());
+    setLanguage(m_impl->language());
+}
+
+void AudioTrackPrivateMediaSourceAVFObjC::setAssetTrack(AVAssetTrack *track)
+{
+    m_impl = std::make_unique<AVTrackPrivateAVFObjCImpl>(track);
+    resetPropertiesFromTrack();
+}
+
+AVAssetTrack* AudioTrackPrivateMediaSourceAVFObjC::assetTrack()
+{
+    return m_impl->assetTrack();
+}
+
+bool AudioTrackPrivateMediaSourceAVFObjC::enabled() const
+{
+    return m_enabled;
+}
+
+void AudioTrackPrivateMediaSourceAVFObjC::setEnabled(bool enabled)
+{
+    if (m_enabled == enabled)
+        return;
+
+    m_enabled = enabled;
+    m_parent->trackDidChangeEnabled(this);
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/AudioTrackPrivateMediaSourceAVFObjC.h
new file mode 100644 (file)
index 0000000..54b469e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef AudioTrackPrivateMediaSourceAVFObjC_h
+#define AudioTrackPrivateMediaSourceAVFObjC_h
+
+#include "AudioTrackPrivateAVF.h"
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+OBJC_CLASS AVAssetTrack;
+OBJC_CLASS AVPlayerItemTrack;
+
+namespace WebCore {
+
+class AVTrackPrivateAVFObjCImpl;
+class SourceBufferPrivateAVFObjC;
+
+class AudioTrackPrivateMediaSourceAVFObjC FINAL : public AudioTrackPrivateAVF {
+    WTF_MAKE_NONCOPYABLE(AudioTrackPrivateMediaSourceAVFObjC)
+public:
+    static RefPtr<AudioTrackPrivateMediaSourceAVFObjC> create(AVAssetTrack* track, SourceBufferPrivateAVFObjC* parent)
+    {
+        return adoptRef(new AudioTrackPrivateMediaSourceAVFObjC(track, parent));
+    }
+
+    virtual bool enabled() const OVERRIDE;
+    virtual void setEnabled(bool) OVERRIDE;
+
+    void setAssetTrack(AVAssetTrack*);
+    AVAssetTrack* assetTrack();
+
+    int trackID() { return m_trackID; }
+
+private:
+    explicit AudioTrackPrivateMediaSourceAVFObjC(AVAssetTrack*, SourceBufferPrivateAVFObjC* parent);
+    
+    void resetPropertiesFromTrack();
+
+    std::unique_ptr<AVTrackPrivateAVFObjCImpl> m_impl;
+    SourceBufferPrivateAVFObjC* m_parent;
+    int m_trackID;
+    bool m_enabled;
+};
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
new file mode 100644 (file)
index 0000000..968161f
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MediaPlayerPrivateMediaSourceAVFObjC_h
+#define MediaPlayerPrivateMediaSourceAVFObjC_h
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#include "MediaPlayerPrivate.h"
+#include "SourceBufferPrivateClient.h"
+#include <wtf/MediaTime.h>
+
+OBJC_CLASS AVAsset;
+OBJC_CLASS AVSampleBufferDisplayLayer;
+
+typedef struct OpaqueCMTimebase* CMTimebaseRef;
+
+namespace WebCore {
+
+class PlatformClockCM;
+class MediaSourcePrivateAVFObjC;
+
+class MediaPlayerPrivateMediaSourceAVFObjC : public MediaPlayerPrivateInterface {
+public:
+    MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer*);
+    virtual ~MediaPlayerPrivateMediaSourceAVFObjC();
+
+    static void registerMediaEngine(MediaEngineRegistrar);
+
+    void addDisplayLayer(AVSampleBufferDisplayLayer*);
+    void removeDisplayLayer(AVSampleBufferDisplayLayer*);
+
+    virtual MediaPlayer::NetworkState networkState() const OVERRIDE;
+    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
+    void setReadyState(MediaPlayer::ReadyState);
+    void setNetworkState(MediaPlayer::NetworkState);
+
+    void seekInternal(double, double, double);
+    void setLoadingProgresssed(bool flag) { m_loadingProgressed = flag; }
+    void setHasAvailableVideoFrame(bool flag) { m_hasAvailableVideoFrame = flag; }
+
+private:
+    // MediaPlayerPrivateInterface
+    virtual void load(const String& url) OVERRIDE;
+    virtual void load(const String& url, PassRefPtr<HTMLMediaSource>) OVERRIDE;
+    virtual void cancelLoad() OVERRIDE;
+
+    virtual void prepareToPlay() OVERRIDE;
+    virtual PlatformMedia platformMedia() const OVERRIDE;
+#if USE(ACCELERATED_COMPOSITING)
+    virtual PlatformLayer* platformLayer() const OVERRIDE;
+#endif
+
+    virtual void play() OVERRIDE;
+    void playInternal();
+
+    virtual void pause() OVERRIDE;
+    void pauseInternal();
+
+    virtual bool paused() const OVERRIDE;
+
+    virtual bool supportsScanning() const OVERRIDE;
+
+    virtual IntSize naturalSize() const OVERRIDE;
+
+    virtual bool hasVideo() const OVERRIDE;
+    virtual bool hasAudio() const OVERRIDE;
+
+    virtual void setVisible(bool) OVERRIDE;
+
+    virtual double durationDouble() const OVERRIDE;
+    virtual double currentTimeDouble() const OVERRIDE;
+    virtual double startTimeDouble() const OVERRIDE;
+    virtual double initialTime() const OVERRIDE;
+
+    virtual void seekWithTolerance(double time, double negativeThreshold, double positiveThreshold) OVERRIDE;
+    virtual bool seeking() const OVERRIDE;
+    virtual void setRateDouble(double) OVERRIDE;
+
+    virtual PassRefPtr<TimeRanges> seekable() const OVERRIDE;
+    virtual double maxTimeSeekableDouble() const OVERRIDE;
+    virtual double minTimeSeekable() const OVERRIDE;
+    virtual PassRefPtr<TimeRanges> buffered() const OVERRIDE;
+
+    virtual bool didLoadingProgress() const OVERRIDE;
+
+    virtual void setSize(const IntSize&) OVERRIDE;
+
+    virtual void paint(GraphicsContext*, const IntRect&) OVERRIDE;
+    virtual void paintCurrentFrameInContext(GraphicsContext*, const IntRect&) OVERRIDE;
+
+    virtual bool hasAvailableVideoFrame() const OVERRIDE;
+
+#if USE(ACCELERATED_COMPOSITING)
+    virtual bool supportsAcceleratedRendering() const OVERRIDE;
+    // called when the rendering system flips the into or out of accelerated rendering mode.
+    virtual void acceleratedRenderingStateChanged() OVERRIDE;
+#endif
+
+    virtual MediaPlayer::MovieLoadType movieLoadType() const OVERRIDE;
+
+    virtual void prepareForRendering() OVERRIDE;
+
+    virtual String engineDescription() const OVERRIDE;
+
+    virtual String languageOfPrimaryAudioTrack() const OVERRIDE;
+
+    virtual size_t extraMemoryCost() const OVERRIDE;
+
+    void ensureLayer();
+    void destroyLayer();
+    void durationChanged();
+
+    // MediaPlayer Factory Methods
+    static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
+    static bool isAvailable();
+    static void getSupportedTypes(HashSet<String>& types);
+    static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
+
+    friend class MediaSourcePrivateAVFObjC;
+
+    MediaPlayer* m_player;
+    RefPtr<HTMLMediaSource> m_mediaSource;
+    RefPtr<MediaSourcePrivateAVFObjC> m_mediaSourcePrivate;
+    RetainPtr<AVAsset> m_asset;
+    RetainPtr<AVSampleBufferDisplayLayer> m_sampleBufferDisplayLayer;
+    std::unique_ptr<PlatformClockCM> m_clock;
+    MediaPlayer::NetworkState m_networkState;
+    MediaPlayer::ReadyState m_readyState;
+    bool m_seeking;
+    mutable bool m_loadingProgressed;
+    bool m_hasAvailableVideoFrame;
+};
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#endif // MediaPlayerPrivateMediaSourceAVFObjC_h
+
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
new file mode 100644 (file)
index 0000000..9880b9f
--- /dev/null
@@ -0,0 +1,438 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "MediaPlayerPrivateMediaSourceAVFObjC.h"
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#import "HTMLMediaSource.h"
+#import "MediaSourcePrivateAVFObjC.h"
+#import "PlatformClockCM.h"
+#import "SoftLinking.h"
+#import <AVFoundation/AVSampleBufferDisplayLayer.h>
+#import <AVFoundation/AVAsset.h>
+#import <CoreMedia/CMSync.h>
+#import <objc_runtime.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/Functional.h>
+#import <wtf/MainThread.h>
+
+#pragma mark -
+#pragma mark Soft Linking
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
+
+SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVAsset)
+SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVURLAsset)
+SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVSampleBufferDisplayLayer)
+SOFT_LINK_CLASS_OPTIONAL(AVFoundation, AVStreamDataParser)
+
+namespace WebCore {
+
+#pragma mark -
+#pragma mark MediaPlayerPrivateMediaSourceAVFObjC
+
+MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC(MediaPlayer* player)
+    : m_player(player)
+    , m_clock(new PlatformClockCM())
+    , m_networkState(MediaPlayer::Empty)
+    , m_readyState(MediaPlayer::HaveNothing)
+    , m_seeking(false)
+    , m_loadingProgressed(false)
+{
+}
+
+MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC()
+{
+}
+
+#pragma mark -
+#pragma mark MediaPlayer Factory Methods
+
+void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
+{
+    if (isAvailable())
+        registrar(create, getSupportedTypes, supportsType, 0, 0, 0);
+}
+
+PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateMediaSourceAVFObjC::create(MediaPlayer* player)
+{
+    return adoptPtr(new MediaPlayerPrivateMediaSourceAVFObjC(player));
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::isAvailable()
+{
+    return AVFoundationLibrary() && CoreMediaLibrary() && getAVStreamDataParserClass();
+}
+
+static HashSet<String> mimeTypeCache()
+{
+    DEFINE_STATIC_LOCAL(HashSet<String>, cache, ());
+    static bool typeListInitialized = false;
+
+    if (typeListInitialized)
+        return cache;
+    typeListInitialized = true;
+
+    NSArray *types = [getAVURLAssetClass() audiovisualMIMETypes];
+    for (NSString *mimeType in types)
+        cache.add(mimeType);
+    
+    return cache;
+} 
+
+void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String>& types)
+{
+    types = mimeTypeCache();
+}
+
+MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters& parameters)
+{
+    // This engine does not support non-media-source sources.
+    if (!parameters.isMediaSource)
+        return MediaPlayer::IsNotSupported;
+
+    if (!mimeTypeCache().contains(parameters.type))
+        return MediaPlayer::IsNotSupported;
+
+    // The spec says:
+    // "Implementors are encouraged to return "maybe" unless the type can be confidently established as being supported or not."
+    if (parameters.codecs.isEmpty())
+        return MediaPlayer::MayBeSupported;
+
+    NSString *typeString = [NSString stringWithFormat:@"%@; codecs=\"%@\"", (NSString *)parameters.type, (NSString *)parameters.codecs];
+    return [getAVURLAssetClass() isPlayableExtendedMIMEType:typeString] ? MediaPlayer::IsSupported : MediaPlayer::MayBeSupported;;
+}
+
+#pragma mark -
+#pragma mark MediaPlayerPrivateInterface Overrides
+
+void MediaPlayerPrivateMediaSourceAVFObjC::load(const String&)
+{
+    ASSERT_NOT_REACHED();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::load(const String& url, PassRefPtr<HTMLMediaSource> source)
+{
+    UNUSED_PARAM(url);
+
+    m_mediaSource = source;
+    m_mediaSourcePrivate = MediaSourcePrivateAVFObjC::create(this);
+
+    m_mediaSource->setPrivateAndOpen(*m_mediaSourcePrivate);
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::cancelLoad()
+{
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::prepareToPlay()
+{
+}
+
+PlatformMedia MediaPlayerPrivateMediaSourceAVFObjC::platformMedia() const
+{
+    PlatformMedia pm;
+    pm.type = PlatformMedia::AVFoundationAssetType;
+    pm.media.avfAsset = m_asset.get();
+    return pm;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* MediaPlayerPrivateMediaSourceAVFObjC::platformLayer() const
+{
+    return m_sampleBufferDisplayLayer.get();
+}
+#endif
+
+void MediaPlayerPrivateMediaSourceAVFObjC::play()
+{
+    callOnMainThread(WTF::bind(&MediaPlayerPrivateMediaSourceAVFObjC::playInternal, this));
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::playInternal()
+{
+    m_clock->start();
+    m_player->rateChanged();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::pause()
+{
+    callOnMainThread(WTF::bind(&MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal, this));
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::pauseInternal()
+{
+    m_clock->stop();
+    m_player->rateChanged();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::paused() const
+{
+    return !m_clock->isRunning();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::supportsScanning() const
+{
+    return true;
+}
+
+IntSize MediaPlayerPrivateMediaSourceAVFObjC::naturalSize() const
+{
+    // FIXME(125156): Report the intrinsic size of the enabled video track.
+    return IntSize();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::hasVideo() const
+{
+    return m_mediaSourcePrivate->hasVideo();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::hasAudio() const
+{
+    return m_mediaSourcePrivate->hasAudio();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setVisible(bool)
+{
+    // No-op.
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::durationDouble() const
+{
+    return m_mediaSource->duration();
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::currentTimeDouble() const
+{
+    return m_clock->currentTime();
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::startTimeDouble() const
+{
+    return 0;
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::initialTime() const
+{
+    return 0;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance(double time, double negativeThreshold, double positiveThreshold)
+{
+    m_seeking = true;
+    callOnMainThread(WTF::bind(&MediaPlayerPrivateMediaSourceAVFObjC::seekInternal, this, time, negativeThreshold, positiveThreshold));
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::seekInternal(double time, double negativeThreshold, double positiveThreshold)
+{
+    MediaTime seekTime = m_mediaSourcePrivate->seekToTime(MediaTime::createWithDouble(time), MediaTime::createWithDouble(positiveThreshold), MediaTime::createWithDouble(negativeThreshold));
+    m_clock->setCurrentMediaTime(seekTime);
+    m_seeking = false;
+    m_player->timeChanged();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::seeking() const
+{
+    return m_seeking;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setRateDouble(double rate)
+{
+    m_clock->setPlayRate(rate);
+    m_player->rateChanged();
+}
+
+MediaPlayer::NetworkState MediaPlayerPrivateMediaSourceAVFObjC::networkState() const
+{
+    return m_networkState;
+}
+
+MediaPlayer::ReadyState MediaPlayerPrivateMediaSourceAVFObjC::readyState() const
+{
+    return m_readyState;
+}
+
+PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::seekable() const
+{
+    return TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble());
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::maxTimeSeekableDouble() const
+{
+    return durationDouble();
+}
+
+double MediaPlayerPrivateMediaSourceAVFObjC::minTimeSeekable() const
+{
+    return startTimeDouble();
+}
+
+PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::buffered() const
+{
+    return m_mediaSource->buffered();
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::didLoadingProgress() const
+{
+    bool loadingProgressed = m_loadingProgressed;
+    m_loadingProgressed = false;
+    return loadingProgressed;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setSize(const IntSize&)
+{
+    // No-op.
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::paint(GraphicsContext*, const IntRect&)
+{
+    // FIXME(125157): Implement painting.
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::paintCurrentFrameInContext(GraphicsContext*, const IntRect&)
+{
+    // FIXME(125157): Implement painting.
+}
+
+bool MediaPlayerPrivateMediaSourceAVFObjC::hasAvailableVideoFrame() const
+{
+    return m_hasAvailableVideoFrame;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+bool MediaPlayerPrivateMediaSourceAVFObjC::supportsAcceleratedRendering() const
+{
+    return true;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::acceleratedRenderingStateChanged()
+{
+    if (m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player))
+        ensureLayer();
+    else
+        destroyLayer();
+}
+#endif
+
+MediaPlayer::MovieLoadType MediaPlayerPrivateMediaSourceAVFObjC::movieLoadType() const
+{
+    return MediaPlayer::StoredStream;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::prepareForRendering()
+{
+    // No-op.
+}
+
+String MediaPlayerPrivateMediaSourceAVFObjC::engineDescription() const
+{
+    static NeverDestroyed<String> description(ASCIILiteral("AVFoundation MediaSource Engine"));
+    return description;
+}
+
+String MediaPlayerPrivateMediaSourceAVFObjC::languageOfPrimaryAudioTrack() const
+{
+    // FIXME(125158): implement languageOfPrimaryAudioTrack()
+    return emptyString();
+}
+
+size_t MediaPlayerPrivateMediaSourceAVFObjC::extraMemoryCost() const
+{
+    return 0;
+}
+
+#pragma mark -
+#pragma mark Utility Methods
+
+void MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer()
+{
+    if (m_sampleBufferDisplayLayer)
+        return;
+
+    m_sampleBufferDisplayLayer = adoptNS([[getAVSampleBufferDisplayLayerClass() alloc] init]);
+    [m_sampleBufferDisplayLayer setControlTimebase:m_clock->timebase()];
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::destroyLayer()
+{
+    if (!m_sampleBufferDisplayLayer)
+        return;
+
+    [m_sampleBufferDisplayLayer setControlTimebase:0];
+    m_sampleBufferDisplayLayer = nullptr;
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::durationChanged()
+{
+    m_player->durationChanged();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
+{
+    if (m_readyState == readyState)
+        return;
+
+    m_readyState = readyState;
+    m_player->readyStateChanged();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::setNetworkState(MediaPlayer::NetworkState networkState)
+{
+    if (m_networkState == networkState)
+        return;
+
+    m_networkState = networkState;
+    m_player->networkStateChanged();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::addDisplayLayer(AVSampleBufferDisplayLayer* displayLayer)
+{
+    ASSERT(displayLayer);
+    if (displayLayer == m_sampleBufferDisplayLayer)
+        return;
+
+    m_sampleBufferDisplayLayer = displayLayer;
+    [m_sampleBufferDisplayLayer setControlTimebase:m_clock->timebase()];
+    m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
+
+    // FIXME: move this somewhere appropriate:
+    m_player->firstVideoFrameAvailable();
+}
+
+void MediaPlayerPrivateMediaSourceAVFObjC::removeDisplayLayer(AVSampleBufferDisplayLayer* displayLayer)
+{
+    if (displayLayer != m_sampleBufferDisplayLayer)
+        return;
+
+    m_sampleBufferDisplayLayer = nullptr;
+    m_player->mediaPlayerClient()->mediaPlayerRenderingModeChanged(m_player);
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.h
new file mode 100644 (file)
index 0000000..1834009
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef MediaSourcePrivateAVFObjC_h
+#define MediaSourcePrivateAVFObjC_h
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#include "MediaSourcePrivate.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+OBJC_CLASS AVAsset;
+OBJC_CLASS AVStreamDataParser;
+OBJC_CLASS NSError;
+OBJC_CLASS NSObject;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
+
+namespace WebCore {
+
+class MediaPlayerPrivateMediaSourceAVFObjC;
+class SourceBufferPrivateAVFObjC;
+class TimeRanges;
+
+class MediaSourcePrivateAVFObjC FINAL : public MediaSourcePrivate {
+public:
+    static RefPtr<MediaSourcePrivateAVFObjC> create(MediaPlayerPrivateMediaSourceAVFObjC*);
+    virtual ~MediaSourcePrivateAVFObjC();
+
+    MediaPlayerPrivateMediaSourceAVFObjC* player() const { return m_player; }
+    const Vector<SourceBufferPrivateAVFObjC*>& activeSourceBuffers() const { return m_activeSourceBuffers; }
+
+    virtual AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) OVERRIDE;
+    virtual double duration() OVERRIDE;
+    virtual void setDuration(double) OVERRIDE;
+    virtual void markEndOfStream(EndOfStreamStatus) OVERRIDE;
+    virtual void unmarkEndOfStream() OVERRIDE;
+    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
+    virtual void setReadyState(MediaPlayer::ReadyState) OVERRIDE;
+
+    bool hasAudio() const;
+    bool hasVideo() const;
+
+    MediaTime seekToTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
+
+private:
+    MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC*);
+
+    void sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateAVFObjC*, bool active);
+    void sourceBufferPrivateDidReceiveInitializationSegment(SourceBufferPrivateAVFObjC*);
+    void monitorSourceBuffers();
+    void removeSourceBuffer(SourceBufferPrivate*);
+
+    friend class SourceBufferPrivateAVFObjC;
+
+    MediaPlayerPrivateMediaSourceAVFObjC* m_player;
+    double m_duration;
+    Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers;
+    Vector<SourceBufferPrivateAVFObjC*> m_activeSourceBuffers;
+    bool m_isEnded;
+};
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm
new file mode 100644 (file)
index 0000000..c56b50b
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "MediaSourcePrivateAVFObjC.h"
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#import "ContentType.h"
+#import "ExceptionCodePlaceholder.h"
+#import "MediaPlayerPrivateMediaSourceAVFObjC.h"
+#import "SourceBufferPrivateAVFObjC.h"
+#import "NotImplemented.h"
+#import "SoftLinking.h"
+#import <objc/runtime.h>
+#import <wtf/text/AtomicString.h>
+#import <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+#pragma mark -
+#pragma mark MediaSourcePrivateAVFObjC
+
+RefPtr<MediaSourcePrivateAVFObjC> MediaSourcePrivateAVFObjC::create(MediaPlayerPrivateMediaSourceAVFObjC* parent)
+{
+    return adoptRef(new MediaSourcePrivateAVFObjC(parent));
+}
+
+MediaSourcePrivateAVFObjC::MediaSourcePrivateAVFObjC(MediaPlayerPrivateMediaSourceAVFObjC* parent)
+    : m_player(parent)
+    , m_duration(std::numeric_limits<double>::quiet_NaN())
+    , m_isEnded(false)
+{
+}
+
+MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC()
+{
+}
+
+MediaSourcePrivate::AddStatus MediaSourcePrivateAVFObjC::addSourceBuffer(const ContentType& contentType, RefPtr<SourceBufferPrivate>& outPrivate)
+{
+    MediaEngineSupportParameters parameters;
+    parameters.isMediaSource = true;
+    parameters.type = contentType.type();
+    parameters.codecs = contentType.parameter(ASCIILiteral("codecs"));
+    if (MediaPlayerPrivateMediaSourceAVFObjC::supportsType(parameters) == MediaPlayer::IsNotSupported)
+        return NotSupported;
+
+    m_sourceBuffers.append(SourceBufferPrivateAVFObjC::create(this));
+    outPrivate = m_sourceBuffers.last();
+
+    return Ok;
+}
+
+void MediaSourcePrivateAVFObjC::removeSourceBuffer(SourceBufferPrivate* buffer)
+{
+    ASSERT(m_sourceBuffers.contains(buffer));
+
+    size_t pos = m_activeSourceBuffers.find(buffer);
+    if (pos != notFound)
+        m_activeSourceBuffers.remove(pos);
+
+    pos = m_sourceBuffers.find(buffer);
+    m_sourceBuffers.remove(pos);
+}
+
+double MediaSourcePrivateAVFObjC::duration()
+{
+    return m_duration;
+}
+
+void MediaSourcePrivateAVFObjC::setDuration(double duration)
+{
+    if (duration == m_duration)
+        return;
+
+    m_duration = duration;
+}
+
+void MediaSourcePrivateAVFObjC::markEndOfStream(EndOfStreamStatus) 
+{
+    // FIXME(125159): implement markEndOfStream()
+    m_isEnded = true;
+}
+
+void MediaSourcePrivateAVFObjC::unmarkEndOfStream() 
+{
+    // FIXME(125159): implement unmarkEndOfStream()
+    m_isEnded = false;
+}
+
+MediaPlayer::ReadyState MediaSourcePrivateAVFObjC::readyState() const
+{
+    return m_player->readyState();
+}
+
+void MediaSourcePrivateAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
+{
+    m_player->setReadyState(readyState);
+}
+
+void MediaSourcePrivateAVFObjC::sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateAVFObjC* buffer, bool active)
+{
+    if (active && !m_activeSourceBuffers.contains(buffer))
+        m_activeSourceBuffers.append(buffer);
+
+    if (!active) {
+        size_t position = m_activeSourceBuffers.find(buffer);
+        if (position != notFound)
+            m_activeSourceBuffers.remove(position);
+    }
+}
+
+static bool MediaSourcePrivateAVFObjCHasAudio(PassRefPtr<SourceBufferPrivateAVFObjC> prpSourceBuffer)
+{
+    RefPtr<SourceBufferPrivateAVFObjC> sourceBuffer = prpSourceBuffer;
+    return sourceBuffer->hasAudio();
+}
+
+bool MediaSourcePrivateAVFObjC::hasAudio() const
+{
+    return std::any_of(m_activeSourceBuffers.begin(), m_activeSourceBuffers.end(), MediaSourcePrivateAVFObjCHasAudio);
+}
+
+static bool MediaSourcePrivateAVFObjCHasVideo(PassRefPtr<SourceBufferPrivateAVFObjC> prpSourceBuffer)
+{
+    RefPtr<SourceBufferPrivateAVFObjC> sourceBuffer = prpSourceBuffer;
+    return sourceBuffer->hasVideo();
+}
+
+bool MediaSourcePrivateAVFObjC::hasVideo() const
+{
+    return std::any_of(m_activeSourceBuffers.begin(), m_activeSourceBuffers.end(), MediaSourcePrivateAVFObjCHasVideo);
+}
+
+MediaTime MediaSourcePrivateAVFObjC::seekToTime(MediaTime targetTime, MediaTime negativeThreshold, MediaTime positiveThreshold)
+{
+    MediaTime seekTime = targetTime;
+    for (auto it = m_activeSourceBuffers.begin(), end = m_activeSourceBuffers.end(); it != end; ++it) {
+        MediaTime sourceSeekTime = (*it)->fastSeekTimeForMediaTime(targetTime, negativeThreshold, positiveThreshold);
+        if (abs(targetTime - sourceSeekTime) > abs(targetTime - seekTime))
+            seekTime = sourceSeekTime;
+    }
+
+    for (auto it = m_activeSourceBuffers.begin(), end = m_activeSourceBuffers.end(); it != end; ++it)
+        (*it)->seekToTime(seekTime);
+
+    return seekTime;
+}
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
new file mode 100644 (file)
index 0000000..75889c1
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef SourceBufferPrivateAVFObjC_h
+#define SourceBufferPrivateAVFObjC_h
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#include "SourceBufferPrivate.h"
+#include <wtf/Deque.h>
+#include <wtf/HashMap.h>
+#include <wtf/MediaTime.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
+
+OBJC_CLASS AVAsset;
+OBJC_CLASS AVStreamDataParser;
+OBJC_CLASS AVSampleBufferDisplayLayer;
+OBJC_CLASS NSError;
+OBJC_CLASS NSObject;
+typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
+typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
+
+namespace WebCore {
+
+class MediaSourcePrivateAVFObjC;
+class TimeRanges;
+class AudioTrackPrivate;
+class VideoTrackPrivate;
+class AudioTrackPrivateMediaSourceAVFObjC;
+class VideoTrackPrivateMediaSourceAVFObjC;
+
+class SourceBufferPrivateAVFObjC FINAL : public SourceBufferPrivate {
+public:
+    static RefPtr<SourceBufferPrivateAVFObjC> create(MediaSourcePrivateAVFObjC*);
+    virtual ~SourceBufferPrivateAVFObjC();
+
+    // AVStreamDataParser delegate methods
+    void didParseStreamDataAsAsset(AVAsset*);
+    void didFailToParseStreamDataWithError(NSError*);
+    void didProvideMediaDataForTrackID(int trackID, CMSampleBufferRef, const String& mediaType, unsigned flags);
+    void didReachEndOfTrackWithTrackID(int trackID, const String& mediaType);
+
+    bool processCodedFrame(int trackID, CMSampleBufferRef, const String& mediaType);
+
+    bool hasVideo() const;
+    bool hasAudio() const;
+
+    void trackDidChangeEnabled(VideoTrackPrivateMediaSourceAVFObjC*);
+    void trackDidChangeEnabled(AudioTrackPrivateMediaSourceAVFObjC*);
+
+    void seekToTime(MediaTime);
+    MediaTime fastSeekTimeForMediaTime(MediaTime, MediaTime negativeThreshold, MediaTime positiveThreshold);
+
+private:
+    explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*);
+
+    // SourceBufferPrivate overrides
+    virtual void setClient(SourceBufferPrivateClient*) OVERRIDE;
+    virtual AppendResult append(const unsigned char* data, unsigned length) OVERRIDE;
+    virtual void abort() OVERRIDE;
+    virtual void removedFromMediaSource() OVERRIDE;
+    virtual MediaPlayer::ReadyState readyState() const OVERRIDE;
+    virtual void setReadyState(MediaPlayer::ReadyState) OVERRIDE;
+    virtual void evictCodedFrames() OVERRIDE;
+    virtual bool isFull() OVERRIDE;
+    virtual void flushAndEnqueueNonDisplayingSamples(Vector<RefPtr<MediaSample>>, AtomicString trackID) OVERRIDE;
+    virtual void enqueueSample(PassRefPtr<MediaSample>, AtomicString trackID) OVERRIDE;
+    virtual bool isReadyForMoreSamples() OVERRIDE;
+    virtual void setActive(bool) OVERRIDE;
+
+    Vector<RefPtr<VideoTrackPrivate>> m_videoTracks;
+    Vector<RefPtr<AudioTrackPrivate>> m_audioTracks;
+
+    RetainPtr<AVStreamDataParser> m_parser;
+    RetainPtr<AVAsset> m_asset;
+    RetainPtr<AVSampleBufferDisplayLayer> m_displayLayer;
+    RetainPtr<NSObject> m_delegate;
+
+    MediaSourcePrivateAVFObjC* m_parent;
+    SourceBufferPrivateClient* m_client;
+
+    bool m_parsingSucceeded;
+    int m_enabledVideoTrackID;
+};
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
new file mode 100644 (file)
index 0000000..dd74136
--- /dev/null
@@ -0,0 +1,554 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+#import "SourceBufferPrivateAVFObjC.h"
+
+#if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
+
+#import "ExceptionCodePlaceholder.h"
+#import "Logging.h"
+#import "MediaDescription.h"
+#import "MediaPlayerPrivateMediaSourceAVFObjC.h"
+#import "MediaSample.h"
+#import "MediaSourcePrivateAVFObjC.h"
+#import "MediaTimeMac.h"
+#import "NotImplemented.h"
+#import "SoftLinking.h"
+#import "SourceBufferPrivateClient.h"
+#import "TimeRanges.h"
+#import "AudioTrackPrivateMediaSourceAVFObjC.h"
+#import "VideoTrackPrivateMediaSourceAVFObjC.h"
+#import "InbandTextTrackPrivateAVFObjC.h"
+#import <AVFoundation/AVAssetTrack.h>
+#import <AVFoundation/AVSampleBufferDisplayLayer.h>
+#import <objc/runtime.h>
+#import <wtf/text/AtomicString.h>
+#import <wtf/text/CString.h>
+#import <wtf/HashCountedSet.h>
+#import <wtf/WeakPtr.h>
+#import <map>
+
+#pragma mark -
+#pragma mark Soft Linking
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_FRAMEWORK_OPTIONAL(CoreMedia)
+
+SOFT_LINK_CLASS(AVFoundation, AVAssetTrack)
+SOFT_LINK_CLASS(AVFoundation, AVStreamDataParser)
+SOFT_LINK_CLASS(AVFoundation, AVSampleBufferDisplayLayer)
+
+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaTypeVideo, NSString *)
+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaTypeAudio, NSString *)
+SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaTypeText, NSString *)
+
+SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime);
+SOFT_LINK_CONSTANT(CoreMedia, kCMTimeInvalid, CMTime);
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleAttachmentKey_DoNotDisplay, CFStringRef)
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleAttachmentKey_NotSync, CFStringRef)
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleBufferAttachmentKey_DrainAfterDecoding, CFStringRef)
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleBufferAttachmentKey_ResetDecoderBeforeDecoding, CFStringRef)
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleBufferAttachmentKey_EmptyMedia, CFStringRef)
+SOFT_LINK_CONSTANT(CoreMedia, kCMSampleBufferAttachmentKey_DisplayEmptyMediaImmediately, CFStringRef)
+
+SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicVisual, NSString*)
+SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicAudible, NSString*)
+SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicLegible, NSString*)
+
+SOFT_LINK(CoreMedia, CMFormatDescriptionGetMediaType, CMMediaType, (CMFormatDescriptionRef desc), (desc))
+SOFT_LINK(CoreMedia, CMSampleBufferCreate, OSStatus, (CFAllocatorRef allocator, CMBlockBufferRef dataBuffer, Boolean dataReady, CMSampleBufferMakeDataReadyCallback makeDataReadyCallback, void *makeDataReadyRefcon, CMFormatDescriptionRef formatDescription, CMItemCount numSamples, CMItemCount numSampleTimingEntries, const CMSampleTimingInfo *sampleTimingArray, CMItemCount numSampleSizeEntries, const size_t *sampleSizeArray, CMSampleBufferRef *sBufOut), (allocator, dataBuffer, dataReady, makeDataReadyCallback, makeDataReadyRefcon, formatDescription, numSamples, numSampleTimingEntries, sampleTimingArray, numSampleSizeEntries, sampleSizeArray, sBufOut))
+SOFT_LINK(CoreMedia, CMSampleBufferCreateCopy, OSStatus, (CFAllocatorRef allocator, CMSampleBufferRef sbuf, CMSampleBufferRef *sbufCopyOut), (allocator, sbuf, sbufCopyOut))
+SOFT_LINK(CoreMedia, CMSampleBufferCallForEachSample, OSStatus, (CMSampleBufferRef sbuf, OSStatus (*callback)( CMSampleBufferRef sampleBuffer, CMItemCount index, void *refcon), void *refcon), (sbuf, callback, refcon))
+SOFT_LINK(CoreMedia, CMSampleBufferGetDecodeTimeStamp, CMTime, (CMSampleBufferRef sbuf), (sbuf))
+SOFT_LINK(CoreMedia, CMSampleBufferGetDuration, CMTime, (CMSampleBufferRef sbuf), (sbuf))
+SOFT_LINK(CoreMedia, CMSampleBufferGetPresentationTimeStamp, CMTime, (CMSampleBufferRef sbuf), (sbuf))
+SOFT_LINK(CoreMedia, CMSampleBufferGetSampleAttachmentsArray, CFArrayRef, (CMSampleBufferRef sbuf, Boolean createIfNecessary), (sbuf, createIfNecessary))
+SOFT_LINK(CoreMedia, CMFormatDescriptionGetMediaSubType, FourCharCode, (CMFormatDescriptionRef desc), (desc))
+SOFT_LINK(CoreMedia, CMSetAttachment, void, (CMAttachmentBearerRef target, CFStringRef key, CFTypeRef value, CMAttachmentMode attachmentMode), (target, key, value, attachmentMode))
+
+#define AVMediaTypeVideo getAVMediaTypeVideo()
+#define AVMediaTypeAudio getAVMediaTypeAudio()
+#define AVMediaTypeText getAVMediaTypeText()
+#define kCMTimeZero getkCMTimeZero()
+#define kCMTimeInvalid getkCMTimeInvalid()
+#define kCMSampleAttachmentKey_NotSync getkCMSampleAttachmentKey_NotSync()
+#define kCMSampleAttachmentKey_DoNotDisplay getkCMSampleAttachmentKey_DoNotDisplay()
+#define kCMSampleBufferAttachmentKey_ResetDecoderBeforeDecoding getkCMSampleBufferAttachmentKey_ResetDecoderBeforeDecoding()
+#define kCMSampleBufferAttachmentKey_DrainAfterDecoding getkCMSampleBufferAttachmentKey_DrainAfterDecoding()
+#define kCMSampleBufferAttachmentKey_EmptyMedia getkCMSampleBufferAttachmentKey_EmptyMedia()
+#define kCMSampleBufferAttachmentKey_DisplayEmptyMediaImmediately getkCMSampleBufferAttachmentKey_DisplayEmptyMediaImmediately()
+
+#define AVMediaCharacteristicVisual getAVMediaCharacteristicVisual()
+#define AVMediaCharacteristicAudible getAVMediaCharacteristicAudible()
+#define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
+
+#pragma mark -
+#pragma mark AVStreamDataParser
+@class AVStreamDataParserInternal;
+
+NS_CLASS_AVAILABLE(TBD, TBD)
+@interface AVStreamDataParser : NSObject
+- (void)setDelegate:(id)delegate;
+- (void)appendStreamData:(NSData *)data;
+- (void)setShouldProvideMediaData:(BOOL)shouldProvideMediaData forTrackID:(CMPersistentTrackID)trackID;
+- (BOOL)shouldProvideMediaDataForTrackID:(CMPersistentTrackID)trackID;
+@end
+
+#pragma mark -
+#pragma mark WebAVStreamDataParserListener
+
+@interface WebAVStreamDataParserListener : NSObject {
+    WebCore::SourceBufferPrivateAVFObjC* _parent;
+    AVStreamDataParser* _parser;
+}
+- (id)initWithParser:(AVStreamDataParser*)parser parent:(WebCore::SourceBufferPrivateAVFObjC*)parent;
+@end
+
+@implementation WebAVStreamDataParserListener
+- (id)initWithParser:(AVStreamDataParser*)parser parent:(WebCore::SourceBufferPrivateAVFObjC*)parent
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    ASSERT(parent);
+    _parent = parent;
+    _parser = parser;
+    [_parser setDelegate:self];
+    return self;
+}
+
+- (void)dealloc
+{
+    [_parser setDelegate:nil];
+    [super dealloc];
+}
+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didParseStreamDataAsAsset:(AVAsset *)asset
+{
+#if ASSERT_DISABLED
+    UNUSED_PARAM(streamDataParser);
+#endif
+    ASSERT(streamDataParser == _parser);
+    _parent->didParseStreamDataAsAsset(asset);
+}
+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didFailToParseStreamDataWithError:(NSError *)error
+{
+#if ASSERT_DISABLED
+    UNUSED_PARAM(streamDataParser);
+#endif
+    ASSERT(streamDataParser == _parser);
+    _parent->didFailToParseStreamDataWithError(error);
+}
+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideMediaData:(CMSampleBufferRef)mediaData forTrackID:(CMPersistentTrackID)trackID mediaType:(NSString *)mediaType flags:(NSUInteger)flags
+{
+#if ASSERT_DISABLED
+    UNUSED_PARAM(streamDataParser);
+#endif
+    ASSERT(streamDataParser == _parser);
+    _parent->didProvideMediaDataForTrackID(trackID, mediaData, mediaType, flags);
+}
+
+- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didReachEndOfTrackWithTrackID:(CMPersistentTrackID)trackID mediaType:(NSString *)mediaType
+{
+#if ASSERT_DISABLED
+    UNUSED_PARAM(streamDataParser);
+#endif
+    ASSERT(streamDataParser == _parser);
+    _parent->didReachEndOfTrackWithTrackID(trackID, mediaType);
+}
+@end
+
+namespace WebCore {
+
+#pragma mark -
+#pragma mark MediaSampleAVFObjC
+
+class MediaSampleAVFObjC FINAL : public MediaSample {
+public:
+    static RefPtr<MediaSampleAVFObjC> create(CMSampleBufferRef sample, int trackID) { return adoptRef(new MediaSampleAVFObjC(sample, trackID)); }
+    virtual ~MediaSampleAVFObjC() { }
+
+    virtual MediaTime presentationTime() const OVERRIDE { return toMediaTime(CMSampleBufferGetPresentationTimeStamp(m_sample.get())); }
+    virtual MediaTime decodeTime() const OVERRIDE { return toMediaTime(CMSampleBufferGetDecodeTimeStamp(m_sample.get())); }
+    virtual MediaTime duration() const OVERRIDE { return toMediaTime(CMSampleBufferGetDuration(m_sample.get())); }
+    virtual AtomicString trackID() const OVERRIDE { return m_id; }
+
+    virtual SampleFlags flags() const OVERRIDE;
+    virtual PlatformSample platformSample() OVERRIDE;
+
+protected:
+    MediaSampleAVFObjC(CMSampleBufferRef sample, int trackID)
+        : m_sample(sample)
+        , m_id(String::format("%d", trackID))
+    {
+    }
+
+    RetainPtr<CMSampleBufferRef> m_sample;
+    AtomicString m_id;
+};
+
+PlatformSample MediaSampleAVFObjC::platformSample()
+{
+    PlatformSample sample = { PlatformSample::CMSampleBufferType, { .cmSampleBuffer = m_sample.get() } };
+    return sample;
+}
+
+static bool CMSampleBufferIsRandomAccess(CMSampleBufferRef sample)
+{
+    CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sample, false);
+    for (CFIndex i = 0, count = CFArrayGetCount(attachments); i < count; ++i) {
+        CFDictionaryRef attachmentDict = (CFDictionaryRef)CFArrayGetValueAtIndex(attachments, i);
+        if (!CFDictionaryContainsKey(attachmentDict, kCMSampleAttachmentKey_NotSync))
+            return true;
+    }
+    return false;
+}
+
+MediaSample::SampleFlags MediaSampleAVFObjC::flags() const
+{
+    int returnValue = MediaSample::None;
+
+    if (CMSampleBufferIsRandomAccess(m_sample.get()))
+        returnValue |= MediaSample::IsSync;
+
+    return SampleFlags(returnValue);
+}
+
+#pragma mark -
+#pragma mark MediaDescriptionAVFObjC
+
+class MediaDescriptionAVFObjC FINAL : public MediaDescription {
+public:
+    static RefPtr<MediaDescriptionAVFObjC> create(AVAssetTrack* track) { return adoptRef(new MediaDescriptionAVFObjC(track)); }
+    virtual ~MediaDescriptionAVFObjC() { }
+
+    virtual AtomicString codec() const OVERRIDE { return m_codec; }
+    virtual bool isVideo() const OVERRIDE { return m_isVideo; }
+    virtual bool isAudio() const OVERRIDE { return m_isAudio; }
+    virtual bool isText() const OVERRIDE { return m_isText; }
+    
+protected:
+    MediaDescriptionAVFObjC(AVAssetTrack* track)
+        : m_isVideo([track hasMediaCharacteristic:AVMediaCharacteristicVisual])
+        , m_isAudio([track hasMediaCharacteristic:AVMediaCharacteristicAudible])
+        , m_isText([track hasMediaCharacteristic:AVMediaCharacteristicLegible])
+    {
+        NSArray* formatDescriptions = [track formatDescriptions];
+        CMFormatDescriptionRef description = [formatDescriptions count] ? (CMFormatDescriptionRef)[formatDescriptions objectAtIndex:0] : 0;
+        if (description) {
+            FourCharCode codec = CMFormatDescriptionGetMediaSubType(description);
+            m_codec = AtomicString(reinterpret_cast<LChar*>(&codec), 4);
+        }
+    }
+
+    AtomicString m_codec;
+    bool m_isVideo;
+    bool m_isAudio;
+    bool m_isText;
+};
+
+#pragma mark -
+#pragma mark SourceBufferPrivateAVFObjC
+
+RefPtr<SourceBufferPrivateAVFObjC> SourceBufferPrivateAVFObjC::create(MediaSourcePrivateAVFObjC* parent)
+{
+    return adoptRef(new SourceBufferPrivateAVFObjC(parent));
+}
+
+SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
+    : m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
+    , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:this]))
+    , m_parent(parent)
+    , m_client(0)
+    , m_parsingSucceeded(true)
+{
+}
+
+SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC()
+{
+    if (m_displayLayer) {
+        m_parent->player()->removeDisplayLayer(m_displayLayer.get());
+        [m_displayLayer flushAndRemoveImage];
+        [m_displayLayer stopRequestingMediaData];
+        m_displayLayer = nullptr;
+    }
+}
+
+void SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(AVAsset* asset)
+{
+    LOG(Media, "SourceBufferPrivateAVFObjC::didParseStreamDataAsAsset(%p)", this);
+
+    m_asset = asset;
+
+    SourceBufferPrivateClient::InitializationSegment segment;
+    segment.duration = toMediaTime([m_asset duration]);
+
+    for (AVAssetTrack* track in [m_asset tracks]) {
+        if ([track hasMediaCharacteristic:AVMediaCharacteristicVisual]) {
+            SourceBufferPrivateClient::InitializationSegment::VideoTrackInformation info;
+            info.track = VideoTrackPrivateMediaSourceAVFObjC::create(track, this);
+            info.description = MediaDescriptionAVFObjC::create(track);
+            segment.videoTracks.append(info);
+        } else if ([track hasMediaCharacteristic:AVMediaCharacteristicAudible]) {
+            SourceBufferPrivateClient::InitializationSegment::AudioTrackInformation info;
+            info.track = AudioTrackPrivateMediaSourceAVFObjC::create(track, this);
+            info.description = MediaDescriptionAVFObjC::create(track);
+            segment.audioTracks.append(info);
+        }
+
+        // FIXME(125161): Add TextTrack support
+    }
+
+    if (m_client)
+        m_client->sourceBufferPrivateDidReceiveInitializationSegment(this, segment);
+}
+
+void SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError(NSError* error)
+{
+#if LOG_DISABLED
+    UNUSED_PARAM(error);
+#endif
+    LOG(Media, "SourceBufferPrivateAVFObjC::didFailToParseStreamDataWithError(%p) - error:\"%s\"", this, String([error description]).utf8().data());
+
+    m_parsingSucceeded = false;
+}
+
+struct ProcessCodedFrameInfo {
+    SourceBufferPrivateAVFObjC* sourceBuffer;
+    int trackID;
+    const String& mediaType;
+};
+
+static OSStatus callProcessCodedFrameForEachSample(CMSampleBufferRef sampleBuffer, CMItemCount, void *refcon)
+{
+    ProcessCodedFrameInfo* info = static_cast<ProcessCodedFrameInfo*>(refcon);
+    return info->sourceBuffer->processCodedFrame(info->trackID, sampleBuffer, info->mediaType);
+}
+
+void SourceBufferPrivateAVFObjC::didProvideMediaDataForTrackID(int trackID, CMSampleBufferRef sampleBuffer, const String& mediaType, unsigned flags)
+{
+    UNUSED_PARAM(flags);
+
+    ProcessCodedFrameInfo info = {this, trackID, mediaType};
+    CMSampleBufferCallForEachSample(sampleBuffer, &callProcessCodedFrameForEachSample, &info);
+}
+
+bool SourceBufferPrivateAVFObjC::processCodedFrame(int trackID, CMSampleBufferRef sampleBuffer, const String&)
+{
+    if (m_client)
+        m_client->sourceBufferPrivateDidReceiveSample(this, MediaSampleAVFObjC::create(sampleBuffer, trackID));
+
+    return true;
+}
+
+void SourceBufferPrivateAVFObjC::didReachEndOfTrackWithTrackID(int trackID, const String& mediaType)
+{
+    UNUSED_PARAM(mediaType);
+    UNUSED_PARAM(trackID);
+    notImplemented();
+}
+
+void SourceBufferPrivateAVFObjC::setClient(SourceBufferPrivateClient* client)
+{
+    m_client = client;
+}
+
+SourceBufferPrivate::AppendResult SourceBufferPrivateAVFObjC::append(const unsigned char* data, unsigned length)
+{
+    m_parsingSucceeded = true;
+
+    LOG(Media, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data, length);
+    [m_parser appendStreamData:[NSData dataWithBytes:data length:length]];
+
+    if (m_parsingSucceeded)
+        m_parent->player()->setLoadingProgresssed(true);
+
+    return m_parsingSucceeded ? AppendSucceeded : ParsingFailed;
+}
+
+void SourceBufferPrivateAVFObjC::abort()
+{
+    notImplemented();
+}
+
+void SourceBufferPrivateAVFObjC::removedFromMediaSource()
+{
+    if (m_displayLayer) {
+        m_parent->player()->removeDisplayLayer(m_displayLayer.get());
+        [m_displayLayer flush];
+        [m_displayLayer stopRequestingMediaData];
+        m_displayLayer = nullptr;
+    }
+
+    m_parent->removeSourceBuffer(this);
+}
+
+MediaPlayer::ReadyState SourceBufferPrivateAVFObjC::readyState() const
+{
+    return m_parent->player()->readyState();
+}
+
+void SourceBufferPrivateAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
+{
+    m_parent->player()->setReadyState(readyState);
+}
+
+void SourceBufferPrivateAVFObjC::evictCodedFrames()
+{
+    notImplemented();
+}
+
+bool SourceBufferPrivateAVFObjC::isFull()
+{
+    notImplemented();
+    return false;
+}
+
+
+bool SourceBufferPrivateAVFObjC::hasVideo() const
+{
+    if (!m_client)
+        return false;
+
+    return m_client->sourceBufferPrivateHasVideo(this);
+}
+
+bool SourceBufferPrivateAVFObjC::hasAudio() const
+{
+    if (!m_client)
+        return false;
+
+    return m_client->sourceBufferPrivateHasAudio(this);
+}
+
+void SourceBufferPrivateAVFObjC::trackDidChangeEnabled(VideoTrackPrivateMediaSourceAVFObjC* track)
+{
+    int trackID = track->trackID();
+    if (!track->selected() && m_enabledVideoTrackID == trackID) {
+        m_enabledVideoTrackID = -1;
+        [m_parser setShouldProvideMediaData:NO forTrackID:trackID];
+    } else if (track->selected()) {
+        m_enabledVideoTrackID = trackID;
+        [m_parser setShouldProvideMediaData:YES forTrackID:trackID];
+        if (!m_displayLayer) {
+            m_displayLayer = [[getAVSampleBufferDisplayLayerClass() alloc] init];
+            [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
+                if (m_client)
+                    m_client->sourceBufferPrivateDidBecomeReadyForMoreSamples(this);
+            }];
+            m_parent->player()->addDisplayLayer(m_displayLayer.get());
+        }
+    }
+}
+
+void SourceBufferPrivateAVFObjC::trackDidChangeEnabled(AudioTrackPrivateMediaSourceAVFObjC*)
+{
+    // No-op.
+}
+
+static RetainPtr<CMSampleBufferRef> createNonDisplayingCopy(CMSampleBufferRef sampleBuffer)
+{
+    CMSampleBufferRef newSampleBuffer = 0;
+    CMSampleBufferCreateCopy(kCFAllocatorDefault, sampleBuffer, &newSampleBuffer);
+    if (!newSampleBuffer)
+        return sampleBuffer;
+
+    CFArrayRef attachmentsArray = CMSampleBufferGetSampleAttachmentsArray(newSampleBuffer, true);
+    for (CFIndex i = 0; i < CFArrayGetCount(attachmentsArray); ++i) {
+        CFMutableDictionaryRef attachments = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachmentsArray, i);
+        CFDictionarySetValue(attachments, kCMSampleAttachmentKey_DoNotDisplay, kCFBooleanTrue);
+    }
+
+    return adoptCF(newSampleBuffer);
+}
+
+void SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples(Vector<RefPtr<MediaSample>> mediaSamples, AtomicString trackID)
+{
+    if (trackID.toInt() != m_enabledVideoTrackID)
+        return;
+
+    LOG(Media, "SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples(%p) samples: %d samples, trackId: %d", this, mediaSamples.size(), trackID.toInt());
+
+    [m_displayLayer flush];
+
+    for (auto it = mediaSamples.begin(), end = mediaSamples.end(); it != end; ++it) {
+        RefPtr<MediaSample>& mediaSample = *it;
+
+        PlatformSample platformSample = mediaSample->platformSample();
+        ASSERT(platformSample.type == PlatformSample::CMSampleBufferType);
+
+        RetainPtr<CMSampleBufferRef> sampleBuffer = createNonDisplayingCopy(platformSample.sample.cmSampleBuffer);
+
+        [m_displayLayer enqueueSampleBuffer:sampleBuffer.get()];
+    }
+
+    m_parent->player()->setHasAvailableVideoFrame(false);
+}
+
+void SourceBufferPrivateAVFObjC::enqueueSample(PassRefPtr<MediaSample> prpMediaSample, AtomicString trackID)
+{
+    if (trackID.toInt() != m_enabledVideoTrackID)
+        return;
+
+    RefPtr<MediaSample> mediaSample = prpMediaSample;
+
+    PlatformSample platformSample = mediaSample->platformSample();
+    if (platformSample.type != PlatformSample::CMSampleBufferType)
+        return;
+
+    [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
+    m_parent->player()->setHasAvailableVideoFrame(true);
+}
+
+bool SourceBufferPrivateAVFObjC::isReadyForMoreSamples()
+{
+    return [m_displayLayer isReadyForMoreMediaData];
+}
+
+void SourceBufferPrivateAVFObjC::setActive(bool isActive)
+{
+    m_parent->sourceBufferPrivateDidChangeActiveState(this, isActive);
+}
+
+MediaTime SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime(MediaTime time, MediaTime negativeThreshold, MediaTime positiveThreshold)
+{
+    if (m_client)
+        return m_client->sourceBufferPrivateFastSeekTimeForMediaTime(this, time, negativeThreshold, positiveThreshold);
+    return time;
+}
+
+void SourceBufferPrivateAVFObjC::seekToTime(MediaTime time)
+{
+    if (m_client)
+        m_client->sourceBufferPrivateSeekToTime(this, time);
+}
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp b/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.cpp
new file mode 100644 (file)
index 0000000..54bd88c
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "VideoTrackPrivateMediaSourceAVFObjC.h"
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+#include "AVTrackPrivateAVFObjCImpl.h"
+#include "SourceBufferPrivateAVFObjC.h"
+
+namespace WebCore {
+
+VideoTrackPrivateMediaSourceAVFObjC::VideoTrackPrivateMediaSourceAVFObjC(AVAssetTrack* track, SourceBufferPrivateAVFObjC* parent)
+    : m_impl(std::make_unique<AVTrackPrivateAVFObjCImpl>(track))
+    , m_parent(parent)
+    , m_trackID(-1)
+    , m_selected(false)
+{
+    resetPropertiesFromTrack();
+}
+
+void VideoTrackPrivateMediaSourceAVFObjC::resetPropertiesFromTrack()
+{
+    m_trackID = m_impl->trackID();
+
+    setKind(m_impl->videoKind());
+    setId(m_impl->id());
+    setLabel(m_impl->label());
+    setLanguage(m_impl->language());
+}
+
+void VideoTrackPrivateMediaSourceAVFObjC::setAssetTrack(AVAssetTrack *track)
+{
+    m_impl = std::make_unique<AVTrackPrivateAVFObjCImpl>(track);
+    resetPropertiesFromTrack();
+}
+
+AVAssetTrack* VideoTrackPrivateMediaSourceAVFObjC::assetTrack()
+{
+    return m_impl->assetTrack();
+}
+
+
+bool VideoTrackPrivateMediaSourceAVFObjC::selected() const
+{
+    return m_selected;
+}
+
+void VideoTrackPrivateMediaSourceAVFObjC::setSelected(bool selected)
+{
+    if (m_selected == selected)
+        return;
+
+    m_selected = selected;
+    m_parent->trackDidChangeEnabled(this);
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h b/Source/WebCore/platform/graphics/avfoundation/objc/VideoTrackPrivateMediaSourceAVFObjC.h
new file mode 100644 (file)
index 0000000..b336e1b
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef VideoTrackPrivateMediaSourceAVFObjC_h
+#define VideoTrackPrivateMediaSourceAVFObjC_h
+
+#include "VideoTrackPrivateAVF.h"
+
+#if ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+OBJC_CLASS AVAssetTrack;
+OBJC_CLASS AVPlayerItemTrack;
+
+namespace WebCore {
+
+class AVTrackPrivateAVFObjCImpl;
+class SourceBufferPrivateAVFObjC;
+
+class VideoTrackPrivateMediaSourceAVFObjC FINAL : public VideoTrackPrivateAVF {
+    WTF_MAKE_NONCOPYABLE(VideoTrackPrivateMediaSourceAVFObjC)
+public:
+    static RefPtr<VideoTrackPrivateMediaSourceAVFObjC> create(AVAssetTrack* track, SourceBufferPrivateAVFObjC* parent)
+    {
+        return adoptRef(new VideoTrackPrivateMediaSourceAVFObjC(track, parent));
+    }
+
+    virtual bool selected() const OVERRIDE;
+    virtual void setSelected(bool) OVERRIDE;
+
+    void setAssetTrack(AVAssetTrack*);
+    AVAssetTrack* assetTrack();
+
+    int trackID() { return m_trackID; }
+
+private:
+    explicit VideoTrackPrivateMediaSourceAVFObjC(AVAssetTrack*, SourceBufferPrivateAVFObjC* parent);
+    
+    void resetPropertiesFromTrack();
+
+    std::unique_ptr<AVTrackPrivateAVFObjCImpl> m_impl;
+    SourceBufferPrivateAVFObjC* m_parent;
+    int m_trackID;
+    bool m_selected;
+};
+
+}
+
+#endif // ENABLE(MEDIA_SOURCE) && ENABLE(VIDEO_TRACK)
+
+#endif
index 9ee49a7..87e72c8 100644 (file)
@@ -55,6 +55,8 @@ public:
     virtual void stop() OVERRIDE;
     virtual bool isRunning() const OVERRIDE { return m_running; }
 
+    CMTimebaseRef timebase() const { return m_timebase.get(); }
+
 private:
     void initializeWithTimingSource(CMClockRef);
 
index 81c510a..5541b00 100644 (file)
         return class##className; \
     }
 
+#define SOFT_LINK_CLASS_OPTIONAL(framework, className) \
+    static Class init##className(); \
+    static Class (*get##className##Class)() = init##className; \
+    static Class class##className; \
+    \
+    static Class className##Function() \
+    { \
+        return class##className; \
+    }\
+    \
+    static Class init##className() \
+    { \
+        framework##Library(); \
+        class##className = objc_getClass(#className); \
+        get##className##Class = className##Function; \
+        return class##className; \
+    }
+
 #define SOFT_LINK_POINTER(framework, name, type) \
     static type init##name(); \
     static type (*get##name)() = init##name; \