1/*
2 * Copyright (C) 2014 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24 * THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef InbandMetadataTextTrackPrivateAVF_h
28#define InbandMetadataTextTrackPrivateAVF_h
29
30#if ENABLE(VIDEO) && USE(AVFOUNDATION)
31#include "InbandTextTrackPrivate.h"
32
33namespace WebCore {
34
35#if ENABLE(DATACUE_VALUE)
36class IncompleteMetaDataCue {
37public:
38    IncompleteMetaDataCue(double time, PassRefPtr<SerializedPlatformRepresentation> cueData)
39        : m_cueData(cueData)
40        , m_startTime(time)
41    {
42    }
43    ~IncompleteMetaDataCue() { }
44
45    RefPtr<SerializedPlatformRepresentation> cueData() const { return m_cueData; }
46    double startTime() const { return m_startTime; }
47
48private:
49    RefPtr<SerializedPlatformRepresentation> m_cueData;
50    double m_startTime;
51};
52#endif
53
54class InbandMetadataTextTrackPrivateAVF : public InbandTextTrackPrivate {
55public:
56    static PassRefPtr<InbandMetadataTextTrackPrivateAVF> create(Kind, CueFormat, const AtomicString& id = emptyAtom);
57
58    ~InbandMetadataTextTrackPrivateAVF();
59
60    virtual Kind kind() const override { return m_kind; }
61    virtual AtomicString id() const override { return m_id; }
62    virtual AtomicString inBandMetadataTrackDispatchType() const override { return m_inBandMetadataTrackDispatchType; }
63    void setInBandMetadataTrackDispatchType(const AtomicString& value) { m_inBandMetadataTrackDispatchType = value; }
64
65#if ENABLE(DATACUE_VALUE)
66    void addDataCue(double start, double end, PassRefPtr<SerializedPlatformRepresentation>, const String&);
67    void updatePendingCueEndTimes(double);
68#endif
69
70    void flushPartialCues();
71
72private:
73    InbandMetadataTextTrackPrivateAVF(Kind, CueFormat, const AtomicString&);
74
75    Kind m_kind;
76    AtomicString m_id;
77    AtomicString m_inBandMetadataTrackDispatchType;
78    double m_currentCueStartTime;
79#if ENABLE(DATACUE_VALUE)
80    Vector<IncompleteMetaDataCue*> m_incompleteCues;
81#endif
82};
83
84} // namespace WebCore
85
86#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)
87
88#endif // InbandMetadataTextTrackPrivateAVF_h
89