haikuwebkit/Source/WebCore/platform/MediaUniqueIdentifier.h

36 lines
1.5 KiB
C
Raw Permalink Normal View History

Now Playing artwork doesn't update when changed. https://bugs.webkit.org/show_bug.cgi?id=223731 <rdar://problem/75823923> Source/WebCore: Now Playing and Media Remote requires a unique identifier for the currently playing item. If the same identifier is provided for every call to MRMediaRemoteSetNowPlayingInfo, then some updates may be skipped. In earlier changes, the MediaSessionElement identifier was combined with the Media Element identifier which broke Now Playing as the MediaSession identifier never changes for the lifetime of the web content process. So we create a new method HTMLMediaElement::mediaUniqueIdentifier with a new MediaUniqueIdentifier that willthat will be updated whenever the source of a media element changes and stop using the MediaSession identifier when dealing with Now Playing. Patch by Jean-Yves Avenard <jya@apple.com> on 2021-04-01 Reviewed by Eric Carlson. Manually tested, no framework available to test such change. * WebCore.xcodeproj/project.pbxproj: Add MediaUniqueIdentifier.h * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::prepareForLoad): Use setCurrentSrc instead of directly modifying m_currentSrc. (WebCore::HTMLMediaElement::selectMediaResource): Use setCurrentSrc instead of directly modifying m_currentSrc. (WebCore::HTMLMediaElement::loadResource): Use setCurrentSrc instead of directly modifying m_currentSrc. (WebCore::HTMLMediaElement::setCurrentSrc): Add convenience method, generate new MediaUniqueIdentifier each time m_currentSrc is modified. (WebCore::HTMLMediaElement::mediaUniqueIdentifier const): Return unique media identifier. (WebCore::HTMLMediaElement::mediaSessionUniqueIdentifier const): Deleted. * html/HTMLMediaElement.h: * html/MediaElementSession.cpp: (WebCore::MediaElementSession::nowPlayingInfo const): * platform/audio/NowPlayingInfo.h: Use MediaUniqueIdentifier for uniqueIdentifier member. (WebCore::NowPlayingInfo::decode): * platform/audio/PlatformMediaSessionManager.h: Use MediaUniqueIdentifier instead. (WebCore::PlatformMediaSessionManager::lastUpdatedNowPlayingInfoUniqueIdentifier const): set kMRMediaRemoteNowPlayingInfoArtworkIdentifier in CFDictionary to the source of the artwork. Workaround a bug in Media Controller component. * platform/audio/cocoa/MediaSessionManagerCocoa.h: * platform/audio/cocoa/MediaSessionManagerCocoa.mm: (WebCore::MediaSessionManagerCocoa::setNowPlayingInfo): * platform/mac/MediaRemoteSoftLink.h: Soft-link kMRMediaRemoteNowPlayingInfoArtworkIdentifier symbol. * platform/mac/MediaRemoteSoftLink.mm: * testing/Internals.h: Add missing header. Source/WebCore/PAL: Patch by Jean-Yves Avenard <jya@apple.com> on 2021-04-01 Reviewed by Eric Carlson. * pal/spi/mac/MediaRemoteSPI.h: Canonical link: https://commits.webkit.org/236030@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275359 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-01 15:17:27 +00:00
/*
* Copyright (C) 2021 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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.
*/
#pragma once
#include <wtf/ObjectIdentifier.h>
namespace WebCore {
enum MediaUniqueIdentifierType { };
using MediaUniqueIdentifier = ObjectIdentifier<MediaUniqueIdentifierType>;
}