Commit c5046445 authored by jer.noble@apple.com's avatar jer.noble@apple.com

[Mac] Add support for VideoTrack to MediaPlayerPrivateAVFObjC

https://bugs.webkit.org/show_bug.cgi?id=122122

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/track/video-track.html

Refactor the methods which query AVAssetTrack and AVPlayerItemTrack into an Impl class, and
use that class to reset the properties of both AudioTrackAVFObjC and the new VideoTrackAVFObjC.

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

Add the new implementation class, shared by AudioTrackAVFObjC and VideoTrackAVFObjC:
* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.h: Added.
(WebCore::AVTrackPrivateAVFObjCImpl::create): Simple factory.
(WebCore::AVTrackPrivateAVFObjCImpl::playerItemTrack): Simple getter.
* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm: Added.
(WebCore::AVTrackPrivateAVFObjCImpl::AVTrackPrivateAVFObjCImpl): Simple constructor.
(WebCore::AVTrackPrivateAVFObjCImpl::enabled): Pass to AVPlayerItemTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::setEnabled): Ditto.
(WebCore::AVTrackPrivateAVFObjCImpl::audioKind): Distinguish between Alternative and Main content.
(WebCore::AVTrackPrivateAVFObjCImpl::videoKind): Distinguish between Alternative, Main, Caption,
    and Description content.
(WebCore::AVTrackPrivateAVFObjCImpl::id): Pass to AVAssetTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::label): Retrieve the Title metadata in the user's preferred
    language.
(WebCore::AVTrackPrivateAVFObjCImpl::language): Pass to languageForAVAssetTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::languageForAVAssetTrack): Moved from AudioTrackPrivateAVFObjC.
* platform/graphics/avfoundation/VideoTrackPrivateAVF.h: Copied from Source/WebCore/platform/graphics/avfoundation/AudioTrackPrivateAVF.h.
(WebCore::VideoTrackPrivateAVF::kind): Simple getter.
(WebCore::VideoTrackPrivateAVF::id): Ditto.
(WebCore::VideoTrackPrivateAVF::label): Ditto.
(WebCore::VideoTrackPrivateAVF::language): Ditto.
(WebCore::VideoTrackPrivateAVF::setKind): Simple setter.
(WebCore::VideoTrackPrivateAVF::setId): Ditto.
(WebCore::VideoTrackPrivateAVF::setLabel): Ditto.
(WebCore::VideoTrackPrivateAVF::setLanguage): Ditto.
(WebCore::VideoTrackPrivateAVF::VideoTrackPrivateAVF): Simple constructor.
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
(WebCore::AudioTrackPrivateAVFObjC::AudioTrackPrivateAVFObjC): Create a AVTrackPrivateAVFObjCImpl.
(WebCore::AudioTrackPrivateAVFObjC::resetPropertiesFromTrack): Retrieve properties from m_impl.
(WebCore::AudioTrackPrivateAVFObjC::setPlayerItemTrack): Create a new AVTrackPrivateAVFObjCImpl.
(WebCore::AudioTrackPrivateAVFObjC::playerItemTrack): Pass to m_impl.
(WebCore::AudioTrackPrivateAVFObjC::setEnabled): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Refactor implementation into
    template method determineChangedTracksFromNewTracksAndOldItems().
(WebCore::determineChangedTracksFromNewTracksAndOldItems): Refactored.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks): Pass to determineChangedTracksFromNewTracksAndOldItems.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack): Changed class hosting
    languageForAVAssetTrack.
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp: Added.
(WebCore::VideoTrackPrivateAVFObjC::VideoTrackPrivateAVFObjC): Create a AVTrackPrivateAVFObjCImpl.
(WebCore::VideoTrackPrivateAVFObjC::resetPropertiesFromTrack): Retrieve properties from m_impl.
(WebCore::VideoTrackPrivateAVFObjC::setPlayerItemTrack): Create a new AVTrackPrivateAVFObjCImpl.
(WebCore::VideoTrackPrivateAVFObjC::playerItemTrack): Pass to m_impl.
(WebCore::VideoTrackPrivateAVFObjC::setSelected): Ditto.
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.h: Added.
(WebCore::VideoTrackPrivateAVFObjC::create): Simple factory.

LayoutTests:

* media/track/video-track-expected.txt: Added.
* media/track/video-track.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156722 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 456ec210
2013-09-30 Jer Noble <jer.noble@apple.com>
[Mac] Add support for VideoTrack to MediaPlayerPrivateAVFObjC
https://bugs.webkit.org/show_bug.cgi?id=122122
Reviewed by Eric Carlson.
* media/track/video-track-expected.txt: Added.
* media/track/video-track.html: Added.
2013-10-01 Myles C. Maxfield <mmaxfield@apple.com>
Center misspelling dots across width of word
In-band video tracks.
EVENT(addtrack)
EXPECTED (event.track == 'video.videoTracks[0]') OK
EVENT(canplaythrough)
** Check initial in-band track states
EXPECTED (video.videoTracks.length == '1') OK
** Unload video file, check track count
RUN(video.src = '')
EXPECTED (video.videoTracks.length == '0') OK
END OF TEST
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=../media-file.js></script>
<script src=../video-test.js></script>
<script>
var addtrackEventCount = 0;
function trackAdded(event)
{
consoleWrite("EVENT(" + event.type + ")");
compareTracks("event.track", "video.videoTracks[" + addtrackEventCount + "]");
++addtrackEventCount;
consoleWrite("");
}
function compareTracks(track1, track2)
{
var equal = (eval(track1) == eval(track2));
reportExpected(equal, track1, "==", track2, track1);
}
function canplaythrough()
{
consoleWrite("<br><i>** Check initial in-band track states<" + "/i>");
testExpected("video.videoTracks.length", 1);
consoleWrite("<br><i>** Unload video file, check track count<" + "/i>");
run("video.src = ''");
testExpected("video.videoTracks.length", 0);
consoleWrite("");
endTest();
}
function setup()
{
findMediaElement();
video.videoTracks.addEventListener("addtrack", trackAdded);
video.src = findMediaFile('video', '../content/test');
waitForEvent('canplaythrough', canplaythrough);
}
</script>
</head>
<body onload="setup()">
<video controls></video>
<p>In-band video tracks.</p>
</body>
</html>
2013-09-30 Jer Noble <jer.noble@apple.com>
[Mac] Add support for VideoTrack to MediaPlayerPrivateAVFObjC
https://bugs.webkit.org/show_bug.cgi?id=122122
Reviewed by Eric Carlson.
Test: media/track/video-track.html
Refactor the methods which query AVAssetTrack and AVPlayerItemTrack into an Impl class, and
use that class to reset the properties of both AudioTrackAVFObjC and the new VideoTrackAVFObjC.
Add new files to project:
* WebCore.xcodeproj/project.pbxproj:
Add the new implementation class, shared by AudioTrackAVFObjC and VideoTrackAVFObjC:
* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.h: Added.
(WebCore::AVTrackPrivateAVFObjCImpl::create): Simple factory.
(WebCore::AVTrackPrivateAVFObjCImpl::playerItemTrack): Simple getter.
* platform/graphics/avfoundation/AVTrackPrivateAVFObjCImpl.mm: Added.
(WebCore::AVTrackPrivateAVFObjCImpl::AVTrackPrivateAVFObjCImpl): Simple constructor.
(WebCore::AVTrackPrivateAVFObjCImpl::enabled): Pass to AVPlayerItemTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::setEnabled): Ditto.
(WebCore::AVTrackPrivateAVFObjCImpl::audioKind): Distinguish between Alternative and Main content.
(WebCore::AVTrackPrivateAVFObjCImpl::videoKind): Distinguish between Alternative, Main, Caption,
and Description content.
(WebCore::AVTrackPrivateAVFObjCImpl::id): Pass to AVAssetTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::label): Retrieve the Title metadata in the user's preferred
language.
(WebCore::AVTrackPrivateAVFObjCImpl::language): Pass to languageForAVAssetTrack.
(WebCore::AVTrackPrivateAVFObjCImpl::languageForAVAssetTrack): Moved from AudioTrackPrivateAVFObjC.
* platform/graphics/avfoundation/VideoTrackPrivateAVF.h: Copied from Source/WebCore/platform/graphics/avfoundation/AudioTrackPrivateAVF.h.
(WebCore::VideoTrackPrivateAVF::kind): Simple getter.
(WebCore::VideoTrackPrivateAVF::id): Ditto.
(WebCore::VideoTrackPrivateAVF::label): Ditto.
(WebCore::VideoTrackPrivateAVF::language): Ditto.
(WebCore::VideoTrackPrivateAVF::setKind): Simple setter.
(WebCore::VideoTrackPrivateAVF::setId): Ditto.
(WebCore::VideoTrackPrivateAVF::setLabel): Ditto.
(WebCore::VideoTrackPrivateAVF::setLanguage): Ditto.
(WebCore::VideoTrackPrivateAVF::VideoTrackPrivateAVF): Simple constructor.
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.h:
* platform/graphics/avfoundation/objc/AudioTrackPrivateAVFObjC.mm:
(WebCore::AudioTrackPrivateAVFObjC::AudioTrackPrivateAVFObjC): Create a AVTrackPrivateAVFObjCImpl.
(WebCore::AudioTrackPrivateAVFObjC::resetPropertiesFromTrack): Retrieve properties from m_impl.
(WebCore::AudioTrackPrivateAVFObjC::setPlayerItemTrack): Create a new AVTrackPrivateAVFObjCImpl.
(WebCore::AudioTrackPrivateAVFObjC::playerItemTrack): Pass to m_impl.
(WebCore::AudioTrackPrivateAVFObjC::setEnabled): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Refactor implementation into
template method determineChangedTracksFromNewTracksAndOldItems().
(WebCore::determineChangedTracksFromNewTracksAndOldItems): Refactored.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateAudioTracks): Pass to determineChangedTracksFromNewTracksAndOldItems.
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateVideoTracks): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::languageOfPrimaryAudioTrack): Changed class hosting
languageForAVAssetTrack.
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.cpp: Added.
(WebCore::VideoTrackPrivateAVFObjC::VideoTrackPrivateAVFObjC): Create a AVTrackPrivateAVFObjCImpl.
(WebCore::VideoTrackPrivateAVFObjC::resetPropertiesFromTrack): Retrieve properties from m_impl.
(WebCore::VideoTrackPrivateAVFObjC::setPlayerItemTrack): Create a new AVTrackPrivateAVFObjCImpl.
(WebCore::VideoTrackPrivateAVFObjC::playerItemTrack): Pass to m_impl.
(WebCore::VideoTrackPrivateAVFObjC::setSelected): Ditto.
* platform/graphics/avfoundation/objc/VideoTrackPrivateAVFObjC.h: Added.
(WebCore::VideoTrackPrivateAVFObjC::create): Simple factory.
2013-10-01 Andreas Kling <akling@apple.com>
Leaf EventTarget subclasses should be FINAL.
......@@ -5241,6 +5241,11 @@
CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; };
CD27F6E51457685A0078207D /* JSMediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E2145767580078207D /* JSMediaController.cpp */; };
CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */; };
CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */; };
CD336F6417FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6317FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h */; };
CD336F6717FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */; };
CD336F6817FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */; };
CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; };
CD3A495217A9C8C600274E42 /* MediaSourceBase.h in Headers */ = {isa = PBXBuildFile; fileRef = CD3A495117A9C8B600274E42 /* MediaSourceBase.h */; };
CD3A495417A9CC9000274E42 /* MediaSourceBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD3A495017A9C8B600274E42 /* MediaSourceBase.cpp */; };
......@@ -12104,6 +12109,11 @@
CD27F6E3145767580078207D /* JSMediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaController.h; sourceTree = "<group>"; };
CD27F6E4145767870078207D /* MediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaController.h; sourceTree = "<group>"; };
CD27F6E6145770D30078207D /* MediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaController.cpp; sourceTree = "<group>"; };
CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVTrackPrivateAVFObjCImpl.mm; sourceTree = "<group>"; };
CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVTrackPrivateAVFObjCImpl.h; sourceTree = "<group>"; };
CD336F6317FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoTrackPrivateAVF.h; sourceTree = "<group>"; };
CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VideoTrackPrivateAVFObjC.cpp; path = objc/VideoTrackPrivateAVFObjC.cpp; sourceTree = "<group>"; };
CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VideoTrackPrivateAVFObjC.h; path = objc/VideoTrackPrivateAVFObjC.h; sourceTree = "<group>"; };
CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiagnosticLoggingKeys.cpp; sourceTree = "<group>"; };
CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingKeys.h; sourceTree = "<group>"; };
CD3A495017A9C8B600274E42 /* MediaSourceBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceBase.cpp; sourceTree = "<group>"; };
......@@ -13336,6 +13346,7 @@
07B442D5166C70B000556CAD /* InbandTextTrackPrivateAVF.h */,
076F0D0912B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.cpp */,
076F0D0A12B8192700C26AA4 /* MediaPlayerPrivateAVFoundation.h */,
CD336F6317FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h */,
);
path = avfoundation;
sourceTree = "<group>";
......@@ -19841,6 +19852,8 @@
DF9AFD6F13FC31B00015FEB7 /* objc */ = {
isa = PBXGroup;
children = (
CD336F5F17F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm */,
CD336F6017F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h */,
CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */,
CDE3A85617F6020400C5BE20 /* AudioTrackPrivateAVFObjC.h */,
07AA6B69166D019500D45671 /* InbandTextTrackPrivateAVFObjC.h */,
......@@ -19851,6 +19864,8 @@
DF9AFD7113FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm */,
CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
CD336F6517FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp */,
CD336F6617FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h */,
);
name = objc;
sourceTree = "<group>";
......@@ -23072,6 +23087,7 @@
8485227E1190162C006EDC7F /* JSSVGVKernElement.h in Headers */,
078E092017D14D1C00420AA1 /* RTCDTMFSender.h in Headers */,
71DCB7021568197600862271 /* JSSVGZoomAndPan.h in Headers */,
CD336F6417FA0A4D00DDDCD0 /* VideoTrackPrivateAVF.h in Headers */,
B2FA3E190AB75A6F000E5AC4 /* JSSVGZoomEvent.h in Headers */,
65DF320409D1CC60000BE325 /* JSText.h in Headers */,
933A14B90B7D1D5200A53FFD /* JSTextEvent.h in Headers */,
......@@ -23431,6 +23447,7 @@
9746AF2C14F4DDE6003E7A70 /* PositionCallback.h in Headers */,
9746AF2E14F4DDE6003E7A70 /* PositionError.h in Headers */,
9746AF3014F4DDE6003E7A70 /* PositionErrorCallback.h in Headers */,
CD336F6817FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.h in Headers */,
37919C240B7D188600A56998 /* PositionIterator.h in Headers */,
9746AF3214F4DDE6003E7A70 /* PositionOptions.h in Headers */,
C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */,
......@@ -24403,6 +24420,7 @@
A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */,
BCDFD48E0E305290009D10AD /* XMLHttpRequestUpload.h in Headers */,
A833C80D0A2CF25600D57664 /* XMLNames.h in Headers */,
CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */,
E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */,
1ACE53EB0A8D18E70022947D /* XMLSerializer.h in Headers */,
5905ADC01302F3CE00F116DF /* XMLTreeViewer.h in Headers */,
......@@ -25986,6 +26004,7 @@
1A494BFA0A122F4400FDAFC1 /* JSHTMLElement.cpp in Sources */,
07969DB117D14151007FF842 /* JSRTCDTMFToneChangeEvent.cpp in Sources */,
BC5823F50C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp in Sources */,
CD336F6717FA0AC600DDDCD0 /* VideoTrackPrivateAVFObjC.cpp in Sources */,
938E65F709F0985D008A48EC /* JSHTMLElementWrapperFactory.cpp in Sources */,
BC6D44EC0C07F2ED0072D2C9 /* JSHTMLEmbedElement.cpp in Sources */,
BC6D44BE0C07EFB60072D2C9 /* JSHTMLEmbedElementCustom.cpp in Sources */,
......@@ -26402,6 +26421,7 @@
5DA5E0FC102B953800088CF9 /* JSWebSocket.cpp in Sources */,
65DF320509D1CC60000BE325 /* JSWheelEvent.cpp in Sources */,
E1C8BE5D0E8BD15A0064CB7D /* JSWorker.cpp in Sources */,
CD336F6117F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.mm in Sources */,
E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */,
E182568F0EF2B02D00933242 /* JSWorkerGlobalScope.cpp in Sources */,
E1C36D340EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp in Sources */,
/*
* 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 AVTrackPrivateAVFObjCImpl_h
#define AVTrackPrivateAVFObjCImpl_h
#if ENABLE(VIDEO_TRACK)
#include "AudioTrackPrivate.h"
#include "VideoTrackPrivate.h"
#include <wtf/OwnPtr.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS AVAssetTrack;
OBJC_CLASS AVPlayerItemTrack;
namespace WebCore {
class AVTrackPrivateAVFObjCImpl {
public:
static OwnPtr<AVTrackPrivateAVFObjCImpl> create(AVPlayerItemTrack* track)
{
return createOwned<AVTrackPrivateAVFObjCImpl>(track);
}
AVTrackPrivateAVFObjCImpl(AVPlayerItemTrack*);
AVPlayerItemTrack* playerItemTrack() const { return m_playerItemTrack.get(); }
bool enabled() const;
void setEnabled(bool);
AudioTrackPrivate::Kind audioKind() const;
VideoTrackPrivate::Kind videoKind() const;
AtomicString id() const;
AtomicString label() const;
AtomicString language() const;
static String languageForAVAssetTrack(AVAssetTrack*);
private:
RetainPtr<AVPlayerItemTrack> m_playerItemTrack;
};
}
#endif // ENABLE(VIDEO_TRACK)
#endif
/*
* 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 "AVTrackPrivateAVFObjCImpl.h"
#if ENABLE(VIDEO_TRACK)
#import "SoftLinking.h"
#import <objc/runtime.h>
#import <AVFoundation/AVAssetTrack.h>
#import <AVFoundation/AVPlayerItemTrack.h>
#import <AVFoundation/AVMetadataItem.h>
SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
SOFT_LINK_CLASS(AVFoundation, AVAssetTrack)
SOFT_LINK_CLASS(AVFoundation, AVPlayerItemTrack)
SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicDescribesVideoForAccessibility, NSString *)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString *)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
#define AVMetadataItem getAVMetadataItemClass()
#define AVMediaCharacteristicIsMainProgramContent getAVMediaCharacteristicIsMainProgramContent()
#define AVMediaCharacteristicDescribesVideoForAccessibility getAVMediaCharacteristicDescribesVideoForAccessibility()
#define AVMediaCharacteristicIsAuxiliaryContent getAVMediaCharacteristicIsAuxiliaryContent()
#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
#define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
#define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
namespace WebCore {
AVTrackPrivateAVFObjCImpl::AVTrackPrivateAVFObjCImpl(AVPlayerItemTrack* track)
: m_playerItemTrack(track)
{
}
bool AVTrackPrivateAVFObjCImpl::enabled() const
{
return [m_playerItemTrack.get() isEnabled];
}
void AVTrackPrivateAVFObjCImpl::setEnabled(bool enabled)
{
[m_playerItemTrack.get() setEnabled:enabled];
}
AudioTrackPrivate::Kind AVTrackPrivateAVFObjCImpl::audioKind() const
{
AVAssetTrack* assetTrack = [m_playerItemTrack.get() assetTrack];
if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
return AudioTrackPrivate::Alternative;
else if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
return AudioTrackPrivate::Main;
return AudioTrackPrivate::None;
}
VideoTrackPrivate::Kind AVTrackPrivateAVFObjCImpl::videoKind() const
{
AVAssetTrack* assetTrack = [m_playerItemTrack.get() assetTrack];
if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesVideoForAccessibility])
return VideoTrackPrivate::Sign;
else if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
return VideoTrackPrivate::Captions;
else if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsAuxiliaryContent])
return VideoTrackPrivate::Alternative;
else if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent])
return VideoTrackPrivate::Main;
return VideoTrackPrivate::None;
}
AtomicString AVTrackPrivateAVFObjCImpl::id() const
{
return String::format("%d", [[m_playerItemTrack.get() assetTrack] trackID]);
}
AtomicString AVTrackPrivateAVFObjCImpl::label() const
{
NSArray *titles = [AVMetadataItem metadataItemsFromArray:[[m_playerItemTrack.get() assetTrack] commonMetadata] withKey:AVMetadataCommonKeyTitle keySpace:AVMetadataKeySpaceCommon];
if (![titles count])
return emptyAtom;
// If possible, return a title in one of the user's preferred languages.
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles filteredAndSortedAccordingToPreferredLanguages:[NSLocale preferredLanguages]];
#else
NSArray *titlesForPreferredLanguages = [AVMetadataItem metadataItemsFromArray:titles withLocale:[NSLocale currentLocale]];
#endif
if ([titlesForPreferredLanguages count])
return [[titlesForPreferredLanguages objectAtIndex:0] stringValue];
return [[titles objectAtIndex:0] stringValue];
}
AtomicString AVTrackPrivateAVFObjCImpl::language() const
{
return languageForAVAssetTrack([m_playerItemTrack.get() assetTrack]);
}
String AVTrackPrivateAVFObjCImpl::languageForAVAssetTrack(AVAssetTrack* track)
{
NSString *language = [track extendedLanguageTag];
// If the language code is stored as a QuickTime 5-bit packed code there aren't enough bits for a full
// RFC 4646 language tag so extendedLanguageTag returns NULL. In this case languageCode will return the
// ISO 639-2/T language code so check it.
if (!language)
language = [track languageCode];
// Some legacy tracks have "und" as a language, treat that the same as no language at all.
if (!language || [language isEqualToString:@"und"])
return emptyString();
return language;
}
}
#endif // ENABLE(VIDEO_TRACK)
/*
* 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 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.
*/
#ifndef VideoTrackPrivateAVF_h
#define VideoTrackPrivateAVF_h
#if ENABLE(VIDEO_TRACK)
#include "VideoTrackPrivate.h"
namespace WebCore {
class VideoTrackPrivateAVF : public VideoTrackPrivate {
WTF_MAKE_NONCOPYABLE(VideoTrackPrivateAVF)
public:
virtual Kind kind() const OVERRIDE { return m_kind; }
virtual AtomicString id() const OVERRIDE { return m_id; }
virtual AtomicString label() const OVERRIDE { return m_label; }
virtual AtomicString language() const OVERRIDE { return m_language; }
protected:
void setKind(Kind kind) { m_kind = kind; }
void setId(AtomicString newId) { m_id = newId; }
void setLabel(AtomicString label) { m_label = label; }
void setLanguage(AtomicString language) { m_language = language; }
Kind m_kind;
AtomicString m_id;
AtomicString m_label;
AtomicString m_language;
VideoTrackPrivateAVF()
: m_kind(None)
{
}
};
}
#endif // ENABLE(VIDEO_TRACK)
#endif // VideoTrackPrivateAVF_h
......@@ -29,13 +29,14 @@
#if ENABLE(VIDEO_TRACK)
#include "AudioTrackPrivateAVF.h"
#include <wtf/RetainPtr.h>
#include <wtf/OwnPtr.h>
OBJC_CLASS AVAssetTrack;
OBJC_CLASS AVPlayerItemTrack;
namespace WebCore {
class AVTrackPrivateAVFObjCImpl;
class AudioTrackPrivateAVFObjC : public AudioTrackPrivateAVF {
WTF_MAKE_NONCOPYABLE(AudioTrackPrivateAVFObjC)
public:
......@@ -47,16 +48,13 @@ public:
virtual void setEnabled(bool);
void setPlayerItemTrack(AVPlayerItemTrack*);
AVPlayerItemTrack* playerItemTrack() { return m_playerItemTrack.get(); }
static String languageForAVAssetTrack(AVAssetTrack*);
AVPlayerItemTrack* playerItemTrack();
private:
AudioTrackPrivateAVFObjC(AVPlayerItemTrack*);
void resetPropertiesFromTrack();
RetainPtr<AVPlayerItemTrack> m_playerItemTrack;
OwnPtr<AVTrackPrivateAVFObjCImpl> m_impl;
};
}
......
......@@ -25,128 +25,42 @@
#import "config.h"
#import "AudioTrackPrivateAVFObjC.h"
#import "AVTrackPrivateAVFObjCImpl.h"
#if ENABLE(VIDEO_TRACK)
#import "SoftLinking.h"
#import <objc/runtime.h>
#import <AVFoundation/AVAssetTrack.h>
#import <AVFoundation/AVPlayerItemTrack.h>
#import <AVFoundation/AVMetadataItem.h>
SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
SOFT_LINK_CLASS(AVFoundation, AVAssetTrack)
SOFT_LINK_CLASS(AVFoundation, AVPlayerItemTrack)
SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
SOFT_LINK_POINTER(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
#define AVMetadataItem getAVMetadataItemClass()
#define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
#define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesVideoForAccessibility, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString *)
SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
#define AVMediaCharacteristicIsMainProgramContent getAVMediaCharacteristicIsMainProgramContent()
#define AVMediaCharacteristicDescribesVideoForAccessibility getAVMediaCharacteristicDescribesVideoForAccessibility()
#define AVMediaCharacteristicIsAuxiliaryContent getAVMediaCharacteristicIsAuxiliaryContent()
#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
#else
#define AVMediaCharacteristicIsMainProgramContent @"public.main-program-content"
#define AVMediaCharacteristicDescribesVideoForAccessibility @"public.accessibility.describes-video"
#define AVMediaCharacteristicIsAuxiliaryContent @"public.auxiliary-content"
#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility @"public.accessibility.transcribes-spoken-dialog"
#endif
namespace WebCore {
AudioTrackPrivateAVFObjC::AudioTrackPrivateAVFObjC(AVPlayerItemTrack* track)
: m_playerItemTrack(track)
: m_impl(AVTrackPrivateAVFObjCImpl::create(track))
{
resetPropertiesFromTrack();
}