1/* 2 * Copyright (C) 2012-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 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#ifndef InbandTextTrackPrivateClient_h 27#define InbandTextTrackPrivateClient_h 28 29#include "Color.h" 30#include "TrackPrivateBase.h" 31 32#if ENABLE(DATACUE_VALUE) 33#include "SerializedPlatformRepresentation.h" 34#endif 35 36#if ENABLE(VIDEO_TRACK) 37 38namespace WebCore { 39 40class InbandTextTrackPrivate; 41class ISOWebVTTCue; 42 43class GenericCueData : public RefCounted<GenericCueData> { 44public: 45 46 static PassRefPtr<GenericCueData> create() { return adoptRef(new GenericCueData()); } 47 virtual ~GenericCueData() { } 48 49 double startTime() const { return m_startTime; } 50 void setStartTime(double startTime) { m_startTime = startTime; } 51 52 double endTime() const { return m_endTime; } 53 void setEndTime(double endTime) { m_endTime = endTime; } 54 55 String id() const { return m_id; } 56 void setId(String id) { m_id = id; } 57 58 String content() const { return m_content; } 59 void setContent(String content) { m_content = content; } 60 61 double line() const { return m_line; } 62 void setLine(double line) { m_line = line; } 63 64 double position() const { return m_position; } 65 void setPosition(double position) { m_position = position; } 66 67 double size() const { return m_size; } 68 void setSize(double size) { m_size = size; } 69 70 enum Alignment { 71 None, 72 Start, 73 Middle, 74 End 75 }; 76 Alignment align() const { return m_align; } 77 void setAlign(Alignment align) { m_align = align; } 78 79 String fontName() const { return m_fontName; } 80 void setFontName(String fontName) { m_fontName = fontName; } 81 82 double baseFontSize() const { return m_baseFontSize; } 83 void setBaseFontSize(double baseFontSize) { m_baseFontSize = baseFontSize; } 84 85 double relativeFontSize() const { return m_relativeFontSize; } 86 void setRelativeFontSize(double relativeFontSize) { m_relativeFontSize = relativeFontSize; } 87 88 Color foregroundColor() const { return m_foregroundColor; } 89 void setForegroundColor(RGBA32 color) { m_foregroundColor.setRGB(color); } 90 91 Color backgroundColor() const { return m_backgroundColor; } 92 void setBackgroundColor(RGBA32 color) { m_backgroundColor.setRGB(color); } 93 94 Color highlightColor() const { return m_highlightColor; } 95 void setHighlightColor(RGBA32 color) { m_highlightColor.setRGB(color); } 96 97 enum Status { 98 Uninitialized, 99 Partial, 100 Complete, 101 }; 102 Status status() { return m_status; } 103 void setStatus(Status status) { m_status = status; } 104 105 bool doesExtendCueData(const GenericCueData&) const; 106 107private: 108 GenericCueData() 109 : m_startTime(0) 110 , m_endTime(0) 111 , m_line(-1) 112 , m_position(-1) 113 , m_size(-1) 114 , m_align(None) 115 , m_baseFontSize(0) 116 , m_relativeFontSize(0) 117 , m_status(Uninitialized) 118 { 119 } 120 121 double m_startTime; 122 double m_endTime; 123 String m_id; 124 String m_content; 125 double m_line; 126 double m_position; 127 double m_size; 128 Alignment m_align; 129 String m_fontName; 130 double m_baseFontSize; 131 double m_relativeFontSize; 132 Color m_foregroundColor; 133 Color m_backgroundColor; 134 Color m_highlightColor; 135 Status m_status; 136}; 137 138inline bool GenericCueData::doesExtendCueData(const GenericCueData& other) const 139{ 140 if (m_relativeFontSize != other.m_relativeFontSize) 141 return false; 142 if (m_baseFontSize != other.m_baseFontSize) 143 return false; 144 if (m_position != other.m_position) 145 return false; 146 if (m_line != other.m_line) 147 return false; 148 if (m_size != other.m_size) 149 return false; 150 if (m_align != other.m_align) 151 return false; 152 if (m_foregroundColor != other.m_foregroundColor) 153 return false; 154 if (m_backgroundColor != other.m_backgroundColor) 155 return false; 156 if (m_highlightColor != other.m_highlightColor) 157 return false; 158 if (m_fontName != other.m_fontName) 159 return false; 160 if (m_id != other.m_id) 161 return false; 162 if (m_content != other.m_content) 163 return false; 164 165 return true; 166} 167 168class InbandTextTrackPrivateClient : public TrackPrivateBaseClient { 169public: 170 virtual ~InbandTextTrackPrivateClient() { } 171 172 virtual void addDataCue(InbandTextTrackPrivate*, double start, double end, const void*, unsigned) = 0; 173 174#if ENABLE(DATACUE_VALUE) 175 virtual void addDataCue(InbandTextTrackPrivate*, double start, double end, PassRefPtr<SerializedPlatformRepresentation>, const String&) = 0; 176 virtual void updateDataCue(InbandTextTrackPrivate*, double start, double end, PassRefPtr<SerializedPlatformRepresentation>) = 0; 177 virtual void removeDataCue(InbandTextTrackPrivate*, double start, double end, PassRefPtr<SerializedPlatformRepresentation>) = 0; 178#endif 179 180 virtual void addGenericCue(InbandTextTrackPrivate*, PassRefPtr<GenericCueData>) = 0; 181 virtual void updateGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0; 182 virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) = 0; 183 184 virtual void parseWebVTTFileHeader(InbandTextTrackPrivate*, String) { ASSERT_NOT_REACHED(); } 185 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char* data, unsigned length) = 0; 186 virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const ISOWebVTTCue&) = 0; 187}; 188 189} // namespace WebCore 190 191#endif 192#endif 193