1/* 2 * Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 15 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 16 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 17 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 19 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY 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 MediaStreamTrackPrivate_h 27#define MediaStreamTrackPrivate_h 28 29#if ENABLE(MEDIA_STREAM) 30 31#include "MediaStreamSource.h" 32#include <wtf/PassRefPtr.h> 33#include <wtf/RefCounted.h> 34#include <wtf/text/AtomicString.h> 35 36namespace WebCore { 37 38class MediaSourceStates; 39class MediaStreamSourceCapabilities; 40 41class MediaStreamTrackPrivateClient { 42public: 43 virtual ~MediaStreamTrackPrivateClient() { } 44 45 virtual void trackReadyStateChanged() = 0; 46 virtual void trackMutedChanged() = 0; 47 virtual void trackEnabledChanged() = 0; 48}; 49 50class MediaStreamTrackPrivate : public RefCounted<MediaStreamTrackPrivate>, public MediaStreamSource::Observer { 51public: 52 static PassRefPtr<MediaStreamTrackPrivate> create(PassRefPtr<MediaStreamSource>); 53 54 virtual ~MediaStreamTrackPrivate(); 55 56 const String& id() const; 57 const String& label() const; 58 59 bool ended() const; 60 61 bool muted() const; 62 void setMuted(bool); 63 64 bool readonly() const; 65 bool remote() const; 66 67 bool enabled() const { return m_enabled; } 68 void setEnabled(bool); 69 70 void setReadyState(MediaStreamSource::ReadyState); 71 MediaStreamSource::ReadyState readyState() const; 72 73 RefPtr<MediaStreamTrackPrivate> clone(); 74 75 MediaStreamSource* source() const { return m_source.get(); } 76 void setSource(PassRefPtr<MediaStreamSource>); 77 78 enum StopBehavior { StopTrackAndStopSource, StopTrackOnly }; 79 void stop(StopBehavior); 80 bool stopped() const { return m_stopped; } 81 82 void setClient(MediaStreamTrackPrivateClient* client) { m_client = client; } 83 84 MediaStreamSource::Type type() const; 85 86 const MediaStreamSourceStates& states() const; 87 RefPtr<MediaStreamSourceCapabilities> capabilities() const; 88 89 RefPtr<MediaConstraints> constraints() const; 90 void applyConstraints(PassRefPtr<MediaConstraints>); 91 92 void configureTrackRendering(); 93 94protected: 95 explicit MediaStreamTrackPrivate(const MediaStreamTrackPrivate&); 96 MediaStreamTrackPrivate(PassRefPtr<MediaStreamSource>); 97 98private: 99 MediaStreamTrackPrivateClient* client() const { return m_client; } 100 101 // MediaStreamSourceObserver 102 virtual void sourceReadyStateChanged() override final; 103 virtual void sourceMutedChanged() override final; 104 virtual void sourceEnabledChanged() override final; 105 virtual bool observerIsEnabled() override final; 106 107 RefPtr<MediaStreamSource> m_source; 108 MediaStreamTrackPrivateClient* m_client; 109 RefPtr<MediaConstraints> m_constraints; 110 MediaStreamSource::ReadyState m_readyState; 111 mutable String m_id; 112 113 bool m_muted; 114 bool m_enabled; 115 bool m_stopped; 116 bool m_ignoreMutations; 117}; 118 119} // namespace WebCore 120 121#endif // ENABLE(MEDIA_STREAM) 122 123#endif // MediaStreamTrackPrivate_h 124