[MSE][Mac] Move AVStreamDataParser off-main-thread.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 May 2014 00:21:00 +0000 (00:21 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 May 2014 00:21:00 +0000 (00:21 +0000)
commitf969f46661eb7e68b1c3bd13a0f792b846de35b8
tree3c3dd2ef2b2be4bbef98067a77fb078f1eacfcb6
parenta56dc9f76f53f0842e1b2437aa10ad6dbc92a0ef
[MSE][Mac] Move AVStreamDataParser off-main-thread.
https://bugs.webkit.org/show_bug.cgi?id=132698

Reviewed by Eric Carlson.

-[AVStreamDataParser appendStreamData:] can casue the main thread to hang when a
large amount of media data is appended at once. Move the actual parsing of data
to a background (synchronous) dispatch queue, and split SourceBuffer::appendBufferTimerFired
into two functions, the latter of which will be called after the background queue
completes.

* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::appendBufferTimerFired): Split into sourceBufferPrivateAppendComplete.
(WebCore::SourceBuffer::sourceBufferPrivateAppendComplete): Split from appendBufferTimerFired.
* Modules/mediasource/SourceBuffer.h:
* platform/graphics/SourceBufferPrivate.h:
* platform/graphics/SourceBufferPrivateClient.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): Re-dispatch to the
        web thread.
(-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): Ditto.
(-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): Ditto.
(-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): Ditto.
(-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): Ditto.
(-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): Ditto.
(WebCore::globalDataParserQueue): Added.
(WebCore::SourceBufferPrivateAVFObjC::append): Dispatch to the globalDataParserQueue.
(WebCore::SourceBufferPrivateAVFObjC::appendCompleted): Added.
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockSourceBufferPrivate::append): Adopt sourceBufferPrivateAppendComplete.
* platform/mock/mediasource/MockSourceBufferPrivate.h:

Update SourceBufferPrivateGStreamer to match the new append return value:
* platform/graphics/gstreamer/SourceBufferPrivateGStreamer.cpp:
(WebCore::SourceBufferPrivateGStreamer::append):
* platform/graphics/gstreamer/SourceBufferPrivateGStreamer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168508 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/platform/graphics/SourceBufferPrivate.h
Source/WebCore/platform/graphics/SourceBufferPrivateClient.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Source/WebCore/platform/graphics/gstreamer/SourceBufferPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/SourceBufferPrivateGStreamer.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h