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.
6 #include "core/html/track/VideoTrack.h"
8 #include "core/html/HTMLMediaElement.h"
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
)
19 VideoTrack::~VideoTrack()
23 DEFINE_TRACE(VideoTrack
)
25 TrackBase::trace(visitor
);
28 void VideoTrack::setSelected(bool selected
)
30 if (selected
== m_selected
)
33 m_selected
= selected
;
36 WebMediaPlayer::TrackId selectedTrackId
= trackId();
37 mediaElement()->selectedVideoTrackChanged(selected
? &selectedTrackId
: 0);
41 const AtomicString
& VideoTrack::alternativeKeyword()
43 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("alternative", AtomicString::ConstructFromLiteral
));
47 const AtomicString
& VideoTrack::captionsKeyword()
49 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("captions", AtomicString::ConstructFromLiteral
));
53 const AtomicString
& VideoTrack::mainKeyword()
55 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("main", AtomicString::ConstructFromLiteral
));
59 const AtomicString
& VideoTrack::signKeyword()
61 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("sign", AtomicString::ConstructFromLiteral
));
65 const AtomicString
& VideoTrack::subtitlesKeyword()
67 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("subtitles", AtomicString::ConstructFromLiteral
));
71 const AtomicString
& VideoTrack::commentaryKeyword()
73 DEFINE_STATIC_LOCAL(const AtomicString
, keyword
, ("commentary", AtomicString::ConstructFromLiteral
));
77 bool VideoTrack::isValidKindKeyword(const String
& kind
)
79 return (kind
== alternativeKeyword())
80 || (kind
== captionsKeyword())
81 || (kind
== mainKeyword())
82 || (kind
== signKeyword())
83 || (kind
== subtitlesKeyword())
84 || (kind
== commentaryKeyword())
85 || (kind
== emptyAtom
);
88 AtomicString
VideoTrack::defaultKind() const