Log Message
AVStreamSession isn't always available, make a HAVE compile flag for it https://bugs.webkit.org/show_bug.cgi?id=193889 <rdar://problem/47452863>
Reviewed by Jer Noble. Source/WebCore: No new tests, no functional change. * page/Settings.yaml: * page/SettingsBase.cpp: (WebCore::SettingsBase::platformDefaultMediaSourceEnabled): * page/SettingsBase.h: * page/cocoa/SettingsBaseCocoa.mm: (WebCore::SettingsBase::platformDefaultMediaSourceEnabled): * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm: (WebCore::CDMPrivateMediaSourceAVFObjC::createSession): * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h: * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged): Fix logging. (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: Use a HashMap to associate CMSampleBuffer with SourceBufferPrivateAVFObjC. (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): isEqualTo -> isEqualToString. (WebCore::sourceBufferMap): (WebCore::nextMapID): (WebCore::bufferWasConsumedCallback): (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID): (WebCore::SourceBufferPrivateAVFObjC::append): (WebCore::SourceBufferPrivateAVFObjC::destroyParser): (WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError): (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): (WebCore::SourceBufferPrivateAVFObjC::bufferWasConsumed): (-[WebBufferConsumedContext initWithParent:]): Deleted. (-[WebBufferConsumedContext parent]): Deleted. Source/WTF: * wtf/FeatureDefines.h:
Modified Paths
- trunk/Source/WTF/ChangeLog
- trunk/Source/WTF/wtf/FeatureDefines.h
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/PAL/pal/spi/mac/AVFoundationSPI.h
- trunk/Source/WebCore/page/Settings.yaml
- trunk/Source/WebCore/page/SettingsBase.cpp
- trunk/Source/WebCore/page/SettingsBase.h
- trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm
- trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h
- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
Diff
Modified: trunk/Source/WTF/ChangeLog (240591 => 240592)
--- trunk/Source/WTF/ChangeLog 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WTF/ChangeLog 2019-01-28 19:19:20 UTC (rev 240592)
@@ -1,3 +1,13 @@
+2019-01-28 Eric Carlson <[email protected]>
+
+ AVStreamSession isn't always available, make a HAVE compile flag for it
+ https://bugs.webkit.org/show_bug.cgi?id=193889
+ <rdar://problem/47452863>
+
+ Reviewed by Jer Noble.
+
+ * wtf/FeatureDefines.h:
+
2018-12-15 Darin Adler <[email protected]>
Replace many uses of String::format with more type-safe alternatives
Modified: trunk/Source/WTF/wtf/FeatureDefines.h (240591 => 240592)
--- trunk/Source/WTF/wtf/FeatureDefines.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WTF/wtf/FeatureDefines.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -177,6 +177,14 @@
#endif
#endif
+#if !defined(HAVE_AVSTREAMSESSION)
+#define HAVE_AVSTREAMSESSION 0
+#endif
+
+#if !defined(ENABLE_MEDIA_SOURCE)
+#define ENABLE_MEDIA_SOURCE 0
+#endif
+
#endif /* PLATFORM(IOS_FAMILY) */
/* --------- Apple WATCHOS port --------- */
@@ -255,6 +263,14 @@
#define ENABLE_WEBPROCESS_WINDOWSERVER_BLOCKING ENABLE_WEBPROCESS_NSRUNLOOP
#endif
+#if !defined(HAVE_AVSTREAMSESSION)
+#define HAVE_AVSTREAMSESSION 1
+#endif
+
+#if !defined(ENABLE_MEDIA_SOURCE)
+#define ENABLE_MEDIA_SOURCE 1
+#endif
+
#endif /* PLATFORM(MAC) */
#if PLATFORM(COCOA)
Modified: trunk/Source/WebCore/ChangeLog (240591 => 240592)
--- trunk/Source/WebCore/ChangeLog 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/ChangeLog 2019-01-28 19:19:20 UTC (rev 240592)
@@ -1,3 +1,51 @@
+2019-01-28 Eric Carlson <[email protected]>
+
+ AVStreamSession isn't always available, make a HAVE compile flag for it
+ https://bugs.webkit.org/show_bug.cgi?id=193889
+ <rdar://problem/47452863>
+
+ Reviewed by Jer Noble.
+
+ No new tests, no functional change.
+
+ * page/Settings.yaml:
+ * page/SettingsBase.cpp:
+ (WebCore::SettingsBase::platformDefaultMediaSourceEnabled):
+ * page/SettingsBase.h:
+ * page/cocoa/SettingsBaseCocoa.mm:
+ (WebCore::SettingsBase::platformDefaultMediaSourceEnabled):
+ * platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
+ (WebCore::CDMPrivateMediaSourceAVFObjC::createSession):
+ * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h:
+ * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm:
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::durationChanged): Fix logging.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged):
+
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+
+ Use a HashMap to associate CMSampleBuffer with SourceBufferPrivateAVFObjC.
+
+ (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): isEqualTo
+ -> isEqualToString.
+ (WebCore::sourceBufferMap):
+ (WebCore::nextMapID):
+ (WebCore::bufferWasConsumedCallback):
+ (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+ (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC):
+ (WebCore::SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID):
+ (WebCore::SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID):
+ (WebCore::SourceBufferPrivateAVFObjC::append):
+ (WebCore::SourceBufferPrivateAVFObjC::destroyParser):
+ (WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError):
+ (WebCore::SourceBufferPrivateAVFObjC::enqueueSample):
+ (WebCore::SourceBufferPrivateAVFObjC::bufferWasConsumed):
+ (-[WebBufferConsumedContext initWithParent:]): Deleted.
+ (-[WebBufferConsumedContext parent]): Deleted.
+
2019-01-28 Rob Buis <[email protected]>
Update MIME type parser
Modified: trunk/Source/WebCore/PAL/pal/spi/mac/AVFoundationSPI.h (240591 => 240592)
--- trunk/Source/WebCore/PAL/pal/spi/mac/AVFoundationSPI.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/AVFoundationSPI.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -40,7 +40,7 @@
#import <AVKit/AVPlayerViewController_WebKitOnly.h>
#endif
-#if !PLATFORM(IOS_FAMILY)
+#if ENABLE(MEDIA_SOURCE)
#import <AVFoundation/AVStreamDataParser.h>
#endif
Modified: trunk/Source/WebCore/page/Settings.yaml (240591 => 240592)
--- trunk/Source/WebCore/page/Settings.yaml 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/page/Settings.yaml 2019-01-28 19:19:20 UTC (rev 240592)
@@ -450,7 +450,7 @@
initial: false
mediaSourceEnabled:
- initial: true
+ initial: platformDefaultMediaSourceEnabled()
conditional: MEDIA_SOURCE
sourceBufferChangeTypeEnabled:
Modified: trunk/Source/WebCore/page/SettingsBase.cpp (240591 => 240592)
--- trunk/Source/WebCore/page/SettingsBase.cpp 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/page/SettingsBase.cpp 2019-01-28 19:19:20 UTC (rev 240592)
@@ -117,6 +117,13 @@
}
#endif
+#if ENABLE(MEDIA_SOURCE) && !PLATFORM(COCOA)
+bool SettingsBase::platformDefaultMediaSourceEnabled()
+{
+ return true;
+}
+#endif
+
const AtomicString& SettingsBase::standardFontFamily(UScriptCode script) const
{
return m_fontGenericFamilies->standardFontFamily(script);
Modified: trunk/Source/WebCore/page/SettingsBase.h (240591 => 240592)
--- trunk/Source/WebCore/page/SettingsBase.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/page/SettingsBase.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -116,6 +116,10 @@
WEBCORE_EXPORT static float defaultMinimumZoomFontSize();
WEBCORE_EXPORT static bool defaultDownloadableBinaryFontsEnabled();
+#if ENABLE(MEDIA_SOURCE)
+ static bool platformDefaultMediaSourceEnabled();
+#endif
+
static const unsigned defaultMaximumHTMLParserDOMTreeDepth = 512;
static const unsigned defaultMaximumRenderTreeDepth = 512;
Modified: trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm (240591 => 240592)
--- trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/page/cocoa/SettingsBaseCocoa.mm 2019-01-28 19:19:20 UTC (rev 240592)
@@ -90,6 +90,11 @@
setSansSerifFontFamily("Helvetica", USCRIPT_COMMON);
}
+bool SettingsBase::platformDefaultMediaSourceEnabled()
+{
+ return true;
+}
+
#else
void SettingsBase::initializeDefaultFontFamilies()
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm 2019-01-28 19:19:20 UTC (rev 240592)
@@ -124,7 +124,11 @@
if (keySystemStringView.substring(14, 1).toInt() == 3 && CDMSessionAVContentKeySession::isAvailable())
session = std::make_unique<CDMSessionAVContentKeySession>(protocolVersions, *this, client);
else
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
session = std::make_unique<CDMSessionAVStreamSession>(protocolVersions, *this, client);
+#else
+ return nullptr;
+#endif
m_sessions.append(session.get());
return WTFMove(session);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -31,7 +31,7 @@
#include <wtf/RetainPtr.h>
#include <wtf/WeakPtr.h>
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(MEDIA_SOURCE)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(MEDIA_SOURCE)
OBJC_CLASS AVStreamSession;
OBJC_CLASS WebCDMSessionAVStreamSessionObserver;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.mm 2019-01-28 19:19:20 UTC (rev 240592)
@@ -26,7 +26,7 @@
#import "config.h"
#import "CDMSessionAVStreamSession.h"
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(MEDIA_SOURCE)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA) && ENABLE(MEDIA_SOURCE)
#import "CDMPrivateMediaSourceAVFObjC.h"
#import "LegacyCDM.h"
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -109,7 +109,7 @@
void setTextTrackRepresentation(TextTrackRepresentation*) override;
void syncTextTrackBounds() override;
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
bool hasStreamSession() { return m_streamSession; }
AVStreamSession *streamSession();
void setCDMSession(LegacyCDMSession*) override;
@@ -121,17 +121,17 @@
void cdmInstanceDetached(CDMInstance&) final;
void attemptToDecryptWithInstance(CDMInstance&) final;
bool waitingForKey() const final;
-
void waitingForKeyChanged();
#endif
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA)
- void keyNeeded(Uint8Array*);
-
void outputObscuredDueToInsufficientExternalProtectionChanged(bool);
void beginSimulatedHDCPError() override { outputObscuredDueToInsufficientExternalProtectionChanged(true); }
void endSimulatedHDCPError() override { outputObscuredDueToInsufficientExternalProtectionChanged(false); }
+
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA)
+ void keyNeeded(Uint8Array*);
#endif
+
#if ENABLE(ENCRYPTED_MEDIA)
void initializationDataEncountered(const String&, RefPtr<ArrayBuffer>&&);
#endif
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm 2019-01-28 19:19:20 UTC (rev 240592)
@@ -55,6 +55,7 @@
#pragma mark - Soft Linking
#import <pal/cf/CoreMediaSoftLink.h>
+#import "CoreVideoSoftLink.h"
SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
@@ -829,7 +830,7 @@
weakThis->pauseInternal();
if (now < duration) {
- LOG(MediaSource, " ERROR: boundary time observer called before duration!", weakThis.get());
+ LOG(MediaSource, "MediaPlayerPrivateMediaSourceAVFObjC::durationChanged(%p) ERROR: boundary time observer called before duration!", weakThis.get());
[weakThis->m_synchronizer setRate:0 time:PAL::toCMTime(duration)];
}
weakThis->m_player->timeChanged();
@@ -884,7 +885,7 @@
m_sizeChangeObserverWeakPtrFactory.revokeAll();
}
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
AVStreamSession* MediaPlayerPrivateMediaSourceAVFObjC::streamSession()
{
if (!getAVStreamSessionClass() || ![getAVStreamSessionClass() instancesRespondToSelector:@selector(initWithStorageDirectoryAtURL:)])
@@ -918,11 +919,14 @@
for (auto& sourceBuffer : m_mediaSourcePrivate->sourceBuffers())
sourceBuffer->setCDMSession(m_session.get());
}
+#endif // HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if ENABLE(LEGACY_ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA)
void MediaPlayerPrivateMediaSourceAVFObjC::keyNeeded(Uint8Array* initData)
{
m_player->keyNeeded(initData);
}
+#endif
void MediaPlayerPrivateMediaSourceAVFObjC::outputObscuredDueToInsufficientExternalProtectionChanged(bool obscured)
{
@@ -933,7 +937,6 @@
UNUSED_PARAM(obscured);
#endif
}
-#endif
#if ENABLE(ENCRYPTED_MEDIA)
void MediaPlayerPrivateMediaSourceAVFObjC::cdmInstanceAttached(CDMInstance& instance)
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h 2019-01-28 19:19:20 UTC (rev 240592)
@@ -77,7 +77,7 @@
ALLOW_NEW_API_WITHOUT_GUARDS_END
};
-class SourceBufferPrivateAVFObjC final : public SourceBufferPrivate {
+class SourceBufferPrivateAVFObjC final : public SourceBufferPrivate, public CanMakeWeakPtr<SourceBufferPrivateAVFObjC> {
public:
static Ref<SourceBufferPrivateAVFObjC> create(MediaSourcePrivateAVFObjC*);
virtual ~SourceBufferPrivateAVFObjC();
@@ -195,6 +195,7 @@
bool m_waitingForKey { true };
int m_enabledVideoTrackID { -1 };
int m_protectedTrackID { -1 };
+ uint64_t m_mapID;
};
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (240591 => 240592)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2019-01-28 19:11:54 UTC (rev 240591)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2019-01-28 19:19:20 UTC (rev 240592)
@@ -354,13 +354,13 @@
RetainPtr<AVSampleBufferDisplayLayer> layer = (AVSampleBufferDisplayLayer *)object;
ASSERT(_layers.contains(layer.get()));
- if ([keyPath isEqualTo:@"error"]) {
+ if ([keyPath isEqualToString:@"error"]) {
RetainPtr<NSError> error = [change valueForKey:NSKeyValueChangeNewKey];
callOnMainThread([parent = _parent, layer = WTFMove(layer), error = WTFMove(error)] {
if (parent)
parent->layerDidReceiveError(layer.get(), error.get());
});
- } else if ([keyPath isEqualTo:@"outputObscuredDueToInsufficientExternalProtection"]) {
+ } else if ([keyPath isEqualToString:@"outputObscuredDueToInsufficientExternalProtection"]) {
callOnMainThread([parent = _parent, obscured = [[change valueForKey:NSKeyValueChangeNewKey] boolValue]] {
if (parent)
parent->outputObscuredDueToInsufficientExternalProtectionChanged(obscured);
@@ -375,7 +375,7 @@
RetainPtr<NSError> error = [change valueForKey:NSKeyValueChangeNewKey];
ASSERT(_renderers.contains(renderer.get()));
- ASSERT([keyPath isEqualTo:@"error"]);
+ ASSERT([keyPath isEqualToString:@"error"]);
callOnMainThread([parent = _parent, renderer = WTFMove(renderer), error = WTFMove(error)] {
if (parent)
@@ -398,30 +398,6 @@
}
@end
-#pragma mark -
-
-@interface WebBufferConsumedContext : NSObject {
- WeakPtr<WebCore::SourceBufferPrivateAVFObjC> _parent;
-}
-@property (readonly) WebCore::SourceBufferPrivateAVFObjC* parent;
-@end
-
-@implementation WebBufferConsumedContext
-- (id)initWithParent:(WeakPtr<WebCore::SourceBufferPrivateAVFObjC>)parent
-{
- self = [super init];
- if (self)
- _parent = parent;
- return self;
-}
-
-@dynamic parent;
-- (WebCore::SourceBufferPrivateAVFObjC*)parent
-{
- return _parent.get();
-}
-@end
-
namespace WebCore {
using namespace PAL;
@@ -461,26 +437,39 @@
#pragma mark -
#pragma mark SourceBufferPrivateAVFObjC
-static NSString *kBufferConsumedContext = @"BufferConsumedContext";
+static HashMap<uint64_t, WeakPtr<SourceBufferPrivateAVFObjC>>& sourceBufferMap()
+{
+ static NeverDestroyed<HashMap<uint64_t, WeakPtr<SourceBufferPrivateAVFObjC>>> map;
+ return map;
+}
-static void bufferWasConsumedCallback(CMNotificationCenterRef, const void*, CFStringRef notificationName, const void*, CFTypeRef payload)
+static uint64_t nextMapID()
{
+ static uint64_t mapID = 0;
+ return ++mapID;
+}
+
+static void bufferWasConsumedCallback(CMNotificationCenterRef, const void* listener, CFStringRef notificationName, const void*, CFTypeRef)
+{
+ LOG(MediaSource, "bufferWasConsumedCallback - nofication %s", [(__bridge NSString *)notificationName UTF8String]);
+
+ if (!CFEqual(kCMSampleBufferConsumerNotification_BufferConsumed, notificationName))
+ return;
+
if (!isMainThread()) {
- callOnMainThread([notificationName, payload = retainPtr(payload)] {
- bufferWasConsumedCallback(nullptr, nullptr, notificationName, nullptr, payload.get());
+ callOnMainThread([notificationName, listener] {
+ bufferWasConsumedCallback(nullptr, listener, notificationName, nullptr, nullptr);
});
return;
}
- if (!CFEqual(kCMSampleBufferConsumerNotification_BufferConsumed, notificationName))
+ uint64_t mapID = reinterpret_cast<uint64_t>(listener);
+ if (!mapID) {
+ LOG(MediaSource, "bufferWasConsumedCallback - ERROR: didn't find ID %llu in map", mapID);
return;
+ }
- ASSERT(CFGetTypeID(payload) == CFDictionaryGetTypeID());
- WebBufferConsumedContext *context = [(__bridge NSDictionary *)payload valueForKey:kBufferConsumedContext];
- if (!context)
- return;
-
- if (auto sourceBuffer = context.parent)
+ if (auto sourceBuffer = sourceBufferMap().get(mapID).get())
sourceBuffer->bufferWasConsumed();
}
@@ -495,14 +484,18 @@
, m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:createWeakPtr()]))
, m_isAppendingGroup(adoptOSObject(dispatch_group_create()))
, m_mediaSource(parent)
+ , m_mapID(nextMapID())
{
- CMNotificationCenterAddListener(CMNotificationCenterGetDefaultLocalCenter(), this, bufferWasConsumedCallback, kCMSampleBufferConsumerNotification_BufferConsumed, nullptr, 0);
+ CMNotificationCenterAddListener(CMNotificationCenterGetDefaultLocalCenter(), reinterpret_cast<void*>(m_mapID), bufferWasConsumedCallback, kCMSampleBufferConsumerNotification_BufferConsumed, nullptr, 0);
m_delegate.get().abortSemaphore = Box<Semaphore>::create(0);
+
+ sourceBufferMap().add(m_mapID, makeWeakPtr(*this));
}
SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC()
{
ASSERT(!m_client);
+ sourceBufferMap().remove(m_mapID);
destroyParser();
destroyRenderers();
@@ -628,7 +621,7 @@
ASSERT(m_parser);
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
LOG(MediaSource, "SourceBufferPrivateAVFObjC::willProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID);
m_protectedTrackID = trackID;
@@ -649,7 +642,7 @@
if (!m_mediaSource)
return;
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
LOG(MediaSource, "SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID);
m_protectedTrackID = trackID;
auto initDataArray = Uint8Array::create([initData length]);
@@ -666,7 +659,6 @@
#endif
#if ENABLE(ENCRYPTED_MEDIA) && HAVE(AVCONTENTKEYSESSION)
- //
auto initDataBuffer = SharedBuffer::create(initData);
auto keyIDs = CDMPrivateFairPlayStreaming::extractKeyIDsSinf(initDataBuffer);
if (!keyIDs)
@@ -713,7 +705,7 @@
void SourceBufferPrivateAVFObjC::append(Vector<unsigned char>&& data)
{
- LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data.data(), data.size());
+ LOG(MediaSource, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data.data(), (int)data.size());
// FIXME: Avoid the data copy by wrapping around the Vector<> object.
RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data.data() length:data.size()]);
@@ -770,7 +762,7 @@
void SourceBufferPrivateAVFObjC::destroyParser()
{
-#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
+#if HAVE(AVSTREAMSESSION) && ENABLE(LEGACY_ENCRYPTED_MEDIA)
if (m_mediaSource && m_mediaSource->player()->hasStreamSession())
[m_mediaSource->player()->streamSession() removeStreamDataParser:m_parser.get()];
#endif
@@ -988,7 +980,7 @@
void SourceBufferPrivateAVFObjC::layerDidReceiveError(AVSampleBufferDisplayLayer *layer, NSError *error)
{
- LOG(MediaSource, "SourceBufferPrivateAVFObjC::layerDidReceiveError(%p): layer(%p), error(%@)", this, layer, [error description]);
+ LOG(MediaSource, "SourceBufferPrivateAVFObjC::layerDidReceiveError(%p): layer(%p), error(%s)", this, layer, [[error description] UTF8String]);
// FIXME(142246): Remove the following once <rdar://problem/20027434> is resolved.
bool anyIgnored = false;
@@ -1025,7 +1017,7 @@
void SourceBufferPrivateAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRenderer *renderer, NSError *error)
ALLOW_NEW_API_WITHOUT_GUARDS_END
{
- LOG(MediaSource, "SourceBufferPrivateAVFObjC::rendererDidReceiveError(%p): renderer(%p), error(%@)", this, renderer, [error description]);
+ LOG(MediaSource, "SourceBufferPrivateAVFObjC::rendererDidReceiveError(%p): renderer(%p), error(%s)", this, renderer, [[error description] UTF8String]);
if ([error code] == 'HDCP')
m_hdcpError = error;
@@ -1098,7 +1090,7 @@
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(platformSample.sample.cmSampleBuffer);
FloatSize formatSize = FloatSize(CMVideoFormatDescriptionGetPresentationDimensions(formatDescription, true, true));
if (!m_cachedSize || formatSize != m_cachedSize.value()) {
- LOG(MediaSource, "SourceBufferPrivateAVFObjC::enqueueSample(%p) - size change detected: {width=%lf, height=%lf}", formatSize.width(), formatSize.height());
+ LOG(MediaSource, "SourceBufferPrivateAVFObjC::enqueueSample(%p) - size change detected: {width=%lf, height=%lf}", this, formatSize.width(), formatSize.height());
bool sizeWasNull = !m_cachedSize;
m_cachedSize = formatSize;
if (m_mediaSource) {
@@ -1114,11 +1106,10 @@
if (m_displayLayer) {
if (m_mediaSource && !m_mediaSource->player()->hasAvailableVideoFrame() && !sample->isNonDisplaying()) {
- auto context = adoptNS([[WebBufferConsumedContext alloc] initWithParent:createWeakPtr()]);
CMSampleBufferRef rawSampleCopy;
CMSampleBufferCreateCopy(kCFAllocatorDefault, platformSample.sample.cmSampleBuffer, &rawSampleCopy);
auto sampleCopy = adoptCF(rawSampleCopy);
- CMSetAttachment(sampleCopy.get(), kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed, (__bridge CFDictionaryRef)@{kBufferConsumedContext: context.get()}, kCMAttachmentMode_ShouldNotPropagate);
+ CMSetAttachment(sampleCopy.get(), kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed, (__bridge CFDictionaryRef)@{ (__bridge NSString *)kCMSampleBufferAttachmentKey_PostNotificationWhenConsumed : @(YES) }, kCMAttachmentMode_ShouldNotPropagate);
[m_displayLayer enqueueSampleBuffer:sampleCopy.get()];
} else
[m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
@@ -1133,6 +1124,8 @@
void SourceBufferPrivateAVFObjC::bufferWasConsumed()
{
+ LOG(MediaSource, "SourceBufferPrivateAVFObjC::bufferWasConsumed(%p)", this);
+
if (m_mediaSource)
m_mediaSource->player()->setHasAvailableVideoFrame(true);
}
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
