• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "config.h"
6 #include "core/html/track/VideoTrack.h"
7 
8 #include "core/html/HTMLMediaElement.h"
9 
10 namespace blink {
11 
VideoTrack(const String & id,const AtomicString & kind,const AtomicString & label,const AtomicString & language,bool selected)12 VideoTrack::VideoTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool selected)
13     : TrackBase(TrackBase::VideoTrack, label, language, id)
14     , m_selected(selected)
15 {
16     setKind(kind);
17 }
18 
~VideoTrack()19 VideoTrack::~VideoTrack()
20 {
21 }
22 
setSelected(bool selected)23 void VideoTrack::setSelected(bool selected)
24 {
25     if (selected == m_selected)
26         return;
27 
28     m_selected = selected;
29 
30     if (mediaElement()) {
31         blink::WebMediaPlayer::TrackId selectedTrackId = trackId();
32         mediaElement()->selectedVideoTrackChanged(selected ? &selectedTrackId : 0);
33     }
34 }
35 
alternativeKeyword()36 const AtomicString& VideoTrack::alternativeKeyword()
37 {
38     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("alternative", AtomicString::ConstructFromLiteral));
39     return keyword;
40 }
41 
captionsKeyword()42 const AtomicString& VideoTrack::captionsKeyword()
43 {
44     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("captions", AtomicString::ConstructFromLiteral));
45     return keyword;
46 }
47 
mainKeyword()48 const AtomicString& VideoTrack::mainKeyword()
49 {
50     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main", AtomicString::ConstructFromLiteral));
51     return keyword;
52 }
53 
signKeyword()54 const AtomicString& VideoTrack::signKeyword()
55 {
56     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("sign", AtomicString::ConstructFromLiteral));
57     return keyword;
58 }
59 
subtitlesKeyword()60 const AtomicString& VideoTrack::subtitlesKeyword()
61 {
62     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("subtitles", AtomicString::ConstructFromLiteral));
63     return keyword;
64 }
65 
commentaryKeyword()66 const AtomicString& VideoTrack::commentaryKeyword()
67 {
68     DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("commentary", AtomicString::ConstructFromLiteral));
69     return keyword;
70 }
71 
isValidKind(const AtomicString & kind) const72 bool VideoTrack::isValidKind(const AtomicString& kind) const
73 {
74     return (kind == alternativeKeyword())
75         || (kind == captionsKeyword())
76         || (kind == mainKeyword())
77         || (kind == signKeyword())
78         || (kind == subtitlesKeyword())
79         || (kind == commentaryKeyword());
80 }
81 
defaultKind() const82 AtomicString VideoTrack::defaultKind() const
83 {
84     return emptyAtom;
85 }
86 
87 }
88