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 COMPUTER, 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 COMPUTER, 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/PassOwnPtr.h> 36#include <wtf/RefCounted.h> 37#include <wtf/text/WTFString.h> 38 39namespace WebCore { 40 41class AudioTrack; 42 43class AudioTrackClient { 44public: 45 virtual ~AudioTrackClient() { } 46 virtual void audioTrackEnabledChanged(AudioTrack*) = 0; 47}; 48 49class AudioTrack : public TrackBase, public AudioTrackPrivateClient { 50public: 51 static PassRefPtr<AudioTrack> create(AudioTrackClient* client, PassRefPtr<AudioTrackPrivate> trackPrivate) 52 { 53 return adoptRef(new AudioTrack(client, trackPrivate)); 54 } 55 virtual ~AudioTrack(); 56 57 AtomicString id() const { return m_id; } 58 void setId(const AtomicString& id) { m_id = id; } 59 60 static const AtomicString& alternativeKeyword(); 61 static const AtomicString& descriptionKeyword(); 62 static const AtomicString& mainKeyword(); 63 static const AtomicString& mainDescKeyword(); 64 static const AtomicString& translationKeyword(); 65 static const AtomicString& commentaryKeyword(); 66 virtual const AtomicString& defaultKindKeyword() const OVERRIDE { return emptyAtom; } 67 68 bool enabled() const { return m_enabled; } 69 virtual void setEnabled(const bool); 70 71 virtual void clearClient() OVERRIDE { m_client = 0; } 72 AudioTrackClient* client() const { return m_client; } 73 74 size_t inbandTrackIndex(); 75 76protected: 77 AudioTrack(AudioTrackClient*, PassRefPtr<AudioTrackPrivate>); 78 79private: 80 virtual bool isValidKind(const AtomicString&) const OVERRIDE; 81 virtual void willRemoveAudioTrackPrivate(AudioTrackPrivate*) OVERRIDE; 82 83 AtomicString m_id; 84 bool m_enabled; 85 AudioTrackClient* m_client; 86 87 RefPtr<AudioTrackPrivate> m_private; 88}; 89 90inline AudioTrack* toAudioTrack(TrackBase* track) 91{ 92 ASSERT(track->type() == TrackBase::AudioTrack); 93 return static_cast<AudioTrack*>(track); 94} 95 96} // namespace WebCore 97 98#endif 99#endif 100