[WTF] Clean up StringStatics.cpp by using LazyNeverDestroyed<> for Atoms
[WebKit-https.git] / Source / WebCore / platform / graphics / avfoundation / objc / InbandTextTrackPrivateLegacyAVFObjC.mm
index edb3142..65392f8 100644 (file)
  *    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
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE 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
@@ -25,7 +25,7 @@
 
 #import "config.h"
 
-#if ENABLE(VIDEO) && USE(AVFOUNDATION) && HAVE(AVFOUNDATION_TEXT_TRACK_SUPPORT) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT) && !PLATFORM(IOS)
 
 #import "InbandTextTrackPrivateLegacyAVFObjC.h"
 
 #import "Logging.h"
 #import "MediaPlayerPrivateAVFoundationObjC.h"
 #import "SoftLinking.h"
-#import <AVFoundation/AVFoundation.h>
 #import <objc/runtime.h>
-#import <wtf/UnusedParam.h>
 
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
-#define AVPlayerItem getAVPlayerItemClass()
 
 SOFT_LINK_CLASS(AVFoundation, AVPlayerItem)
 SOFT_LINK_CLASS(AVFoundation, AVMetadataItem)
 #define AVMediaTypeClosedCaption getAVMediaTypeClosedCaption()
-#define AVMediaCharacteristicContainsOnlyForcedSubtitles getAVMediaCharacteristicContainsOnlyForcedSubtitles()
-#define AVMediaCharacteristicIsMainProgramContent getAVMediaCharacteristicIsMainProgramContent()
-#define AVMediaCharacteristicEasyToRead getAVMediaCharacteristicEasyToRead()
 
 SOFT_LINK_POINTER(AVFoundation, AVMediaTypeClosedCaption, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicLegible, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVMetadataCommonKeyTitle, NSString *)
 SOFT_LINK_POINTER(AVFoundation, AVMetadataKeySpaceCommon, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaTypeSubtitle, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicContainsOnlyForcedSubtitles, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsMainProgramContent, NSString *)
-SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicEasyToRead, NSString *)
 
+#define AVPlayerItem getAVPlayerItemClass()
 #define AVMetadataItem getAVMetadataItemClass()
 #define AVMediaCharacteristicLegible getAVMediaCharacteristicLegible()
 #define AVMetadataCommonKeyTitle getAVMetadataCommonKeyTitle()
 #define AVMetadataKeySpaceCommon getAVMetadataKeySpaceCommon()
-#define AVMediaTypeSubtitle getAVMediaTypeSubtitle()
-#define AVMediaCharacteristicTranscribesSpokenDialogForAccessibility getAVMediaCharacteristicTranscribesSpokenDialogForAccessibility()
-#define AVMediaCharacteristicDescribesMusicAndSoundForAccessibility getAVMediaCharacteristicDescribesMusicAndSoundForAccessibility()
-
-using namespace WebCore;
-using namespace std;
 
 namespace WebCore {
 
 InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC(MediaPlayerPrivateAVFoundationObjC* player, AVPlayerItemTrack* track)
-    : InbandTextTrackPrivateAVF(player)
+    : InbandTextTrackPrivateAVF(player, InbandTextTrackPrivate::Generic)
     , m_playerItemTrack(track)
 {
 }
@@ -88,65 +71,33 @@ InbandTextTrackPrivate::Kind InbandTextTrackPrivateLegacyAVFObjC::kind() const
     if (!m_playerItemTrack)
         return InbandTextTrackPrivate::None;
 
-    AVAssetTrack *assetTrack = [m_playerItemTrack assetTrack];
-    NSString *mediaType = [assetTrack mediaType];
-    
-    if ([mediaType isEqualToString:AVMediaTypeClosedCaption])
-        return InbandTextTrackPrivate::Captions;
-    if ([mediaType isEqualToString:AVMediaTypeSubtitle]) {
-
-        if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles])
-            return InbandTextTrackPrivate::Forced;
-
-        // An "SDH" track is a subtitle track created for the deaf or hard-of-hearing. "captions" in WebVTT are
-        // "labeled as appropriate for the hard-of-hearing", so tag SDH sutitles as "captions".
-        if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicTranscribesSpokenDialogForAccessibility])
-            return InbandTextTrackPrivate::Captions;
-        if ([assetTrack hasMediaCharacteristic:AVMediaCharacteristicDescribesMusicAndSoundForAccessibility])
-            return InbandTextTrackPrivate::Captions;
-        
-        return InbandTextTrackPrivate::Subtitles;
-    }
-
     return InbandTextTrackPrivate::Captions;
 }
 
 bool InbandTextTrackPrivateLegacyAVFObjC::isClosedCaptions() const
 {
-    if (!m_playerItemTrack)
-        return false;
-    
-    return [[[m_playerItemTrack assetTrack] mediaType] isEqualToString:AVMediaTypeClosedCaption];
+    return m_playerItemTrack;
 }
 
 bool InbandTextTrackPrivateLegacyAVFObjC::containsOnlyForcedSubtitles() const
 {
-    if (!m_playerItemTrack)
-        return false;
-    
-    return [[m_playerItemTrack assetTrack] hasMediaCharacteristic:AVMediaCharacteristicContainsOnlyForcedSubtitles];
+    return false;
 }
 
 bool InbandTextTrackPrivateLegacyAVFObjC::isMainProgramContent() const
 {
-    if (!m_playerItemTrack)
-        return false;
-    
-    return [[m_playerItemTrack assetTrack] hasMediaCharacteristic:AVMediaCharacteristicIsMainProgramContent];
+    return m_playerItemTrack;
 }
 
 bool InbandTextTrackPrivateLegacyAVFObjC::isEasyToRead() const
 {
-    if (!m_playerItemTrack)
-        return false;
-
-    return [[m_playerItemTrack assetTrack] hasMediaCharacteristic:AVMediaCharacteristicEasyToRead];
+    return false;
 }
 
 AtomicString InbandTextTrackPrivateLegacyAVFObjC::label() const
 {
     if (!m_playerItemTrack)
-        return emptyAtom;
+        return emptyAtom();
 
     NSString *title = 0;
 
@@ -161,16 +112,16 @@ AtomicString InbandTextTrackPrivateLegacyAVFObjC::label() const
             title = [[titles objectAtIndex:0] stringValue];
     }
 
-    return title ? AtomicString(title) : emptyAtom;
+    return title ? AtomicString(title) : emptyAtom();
 }
 
 AtomicString InbandTextTrackPrivateLegacyAVFObjC::language() const
 {
     if (!m_playerItemTrack)
-        return emptyAtom;
+        return emptyAtom();
 
     NSString *languageCode = [[m_playerItemTrack assetTrack] languageCode];
-    RetainPtr<NSLocale> locale(AdoptNS, [[NSLocale alloc] initWithLocaleIdentifier:languageCode]);
+    RetainPtr<NSLocale> locale = adoptNS([[NSLocale alloc] initWithLocaleIdentifier:languageCode]);
     return [locale localeIdentifier];
 }