summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/html/track/VideoTrack.cpp
blob: 5a93e6ed0f75113fc94553243b4662ed5897e4c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"
#include "core/html/track/VideoTrack.h"

#include "core/html/HTMLMediaElement.h"

namespace WebCore {

VideoTrack::VideoTrack(const String& id, const AtomicString& kind, const AtomicString& label, const AtomicString& language, bool selected)
    : TrackBase(TrackBase::VideoTrack, label, language, id)
    , m_selected(selected)
{
    ScriptWrappable::init(this);
    setKind(kind);
}

VideoTrack::~VideoTrack()
{
}

void VideoTrack::setSelected(bool selected)
{
    if (selected == m_selected)
        return;

    m_selected = selected;

    if (mediaElement()) {
        blink::WebMediaPlayer::TrackId selectedTrackId = trackId();
        mediaElement()->selectedVideoTrackChanged(selected ? &selectedTrackId : 0);
    }
}

const AtomicString& VideoTrack::alternativeKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("alternative", AtomicString::ConstructFromLiteral));
    return keyword;
}

const AtomicString& VideoTrack::captionsKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("captions", AtomicString::ConstructFromLiteral));
    return keyword;
}

const AtomicString& VideoTrack::mainKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("main", AtomicString::ConstructFromLiteral));
    return keyword;
}

const AtomicString& VideoTrack::signKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("sign", AtomicString::ConstructFromLiteral));
    return keyword;
}

const AtomicString& VideoTrack::subtitlesKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("subtitles", AtomicString::ConstructFromLiteral));
    return keyword;
}

const AtomicString& VideoTrack::commentaryKeyword()
{
    DEFINE_STATIC_LOCAL(const AtomicString, keyword, ("commentary", AtomicString::ConstructFromLiteral));
    return keyword;
}

bool VideoTrack::isValidKind(const AtomicString& kind) const
{
    return (kind == alternativeKeyword())
        || (kind == captionsKeyword())
        || (kind == mainKeyword())
        || (kind == signKeyword())
        || (kind == subtitlesKeyword())
        || (kind == commentaryKeyword());
}

AtomicString VideoTrack::defaultKind() const
{
    return emptyAtom;
}

}