1/* 2 * Copyright (C) 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2011, 2012, 2013 Apple Inc. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 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. ``AS IS'' AND ANY 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#ifndef AudioTrack_h 28#define AudioTrack_h 29 30#if ENABLE(VIDEO_TRACK) 31 32#include "AudioTrackPrivate.h" 33#include "ExceptionCode.h" 34#include "TrackBase.h" 35#include <wtf/RefCounted.h> 36#include <wtf/text/WTFString.h> 37 38namespace WebCore { 39 40class AudioTrack; 41 42class AudioTrackClient { 43public: 44 virtual ~AudioTrackClient() { } 45 virtual void audioTrackEnabledChanged(AudioTrack*) = 0; 46}; 47 48class AudioTrack : public TrackBase, public AudioTrackPrivateClient { 49public: 50 static PassRefPtr<AudioTrack> create(AudioTrackClient* client, PassRefPtr<AudioTrackPrivate> trackPrivate) 51 { 52 return adoptRef(new AudioTrack(client, trackPrivate)); 53 } 54 virtual ~AudioTrack(); 55 56 static const AtomicString& alternativeKeyword(); 57 static const AtomicString& descriptionKeyword(); 58 static const AtomicString& mainKeyword(); 59 static const AtomicString& mainDescKeyword(); 60 static const AtomicString& translationKeyword(); 61 static const AtomicString& commentaryKeyword(); 62 virtual const AtomicString& defaultKindKeyword() const override { return emptyAtom; } 63 64 virtual bool enabled() const override { return m_enabled; } 65 virtual void setEnabled(const bool); 66 67 virtual void clearClient() override { m_client = 0; } 68 AudioTrackClient* client() const { return m_client; } 69 70 size_t inbandTrackIndex(); 71 72 void setPrivate(PassRefPtr<AudioTrackPrivate>); 73 74protected: 75 AudioTrack(AudioTrackClient*, PassRefPtr<AudioTrackPrivate>); 76 77private: 78 virtual bool isValidKind(const AtomicString&) const override; 79 80 virtual void enabledChanged(AudioTrackPrivate*, bool) override; 81 virtual void idChanged(TrackPrivateBase*, const AtomicString&) override; 82 virtual void labelChanged(TrackPrivateBase*, const AtomicString&) override; 83 virtual void languageChanged(TrackPrivateBase*, const AtomicString&) override; 84 virtual void willRemove(TrackPrivateBase*) override; 85 86 void updateKindFromPrivate(); 87 88 bool m_enabled; 89 AudioTrackClient* m_client; 90 91 RefPtr<AudioTrackPrivate> m_private; 92}; 93 94inline AudioTrack* toAudioTrack(TrackBase* track) 95{ 96 ASSERT_WITH_SECURITY_IMPLICATION(track->type() == TrackBase::AudioTrack); 97 return static_cast<AudioTrack*>(track); 98} 99 100} // namespace WebCore 101 102#endif 103#endif 104