Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: Source/core/platform/mediastream/MediaStreamSource.h

Issue 64593002: Move MediaStreamSource to platform/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: also move WebMediaConstraints.cpp Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Ericsson AB. All rights reserved.
3 * Copyright (C) 2012 Google 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 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name of Ericsson nor the names of its contributors
16 * may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef MediaStreamSource_h
33 #define MediaStreamSource_h
34
35 #include "platform/audio/AudioDestinationConsumer.h"
36 #include "platform/mediastream/MediaConstraints.h"
37 #include "wtf/OwnPtr.h"
38 #include "wtf/PassOwnPtr.h"
39 #include "wtf/RefCounted.h"
40 #include "wtf/ThreadingPrimitives.h"
41 #include "wtf/Vector.h"
42 #include "wtf/text/WTFString.h"
43
44 namespace WebCore {
45
46 class MediaStreamSource : public RefCounted<MediaStreamSource> {
47 public:
48 class Observer {
49 public:
50 virtual ~Observer() { }
51 virtual void sourceChangedState() = 0;
52 };
53
54 class ExtraData {
55 public:
56 virtual ~ExtraData() { }
57 };
58
59 enum Type {
60 TypeAudio,
61 TypeVideo
62 };
63
64 enum ReadyState {
65 ReadyStateLive = 0,
66 ReadyStateMuted = 1,
67 ReadyStateEnded = 2
68 };
69
70 static PassRefPtr<MediaStreamSource> create(const String& id, Type, const St ring& name, ReadyState = ReadyStateLive, bool requiresConsumer = false);
71
72 const String& id() const { return m_id; }
73 Type type() const { return m_type; }
74 const String& name() const { return m_name; }
75
76 void setReadyState(ReadyState);
77 ReadyState readyState() const { return m_readyState; }
78
79 void addObserver(Observer*);
80 void removeObserver(Observer*);
81
82 ExtraData* extraData() const { return m_extraData.get(); }
83 void setExtraData(ExtraData* extraData) { m_extraData = adoptPtr(extraData); }
84
85 void setConstraints(PassRefPtr<MediaConstraints> constraints) { m_constraint s = constraints; }
86 MediaConstraints* constraints() { return m_constraints.get(); }
87
88 const String& deviceId() { return m_deviceId; }
89 void setDeviceId(const String& deviceId) { m_deviceId = deviceId; }
90
91 void setAudioFormat(size_t numberOfChannels, float sampleRate);
92 void consumeAudio(AudioBus*, size_t numberOfFrames);
93
94 bool requiresAudioConsumer() const { return m_requiresConsumer; }
95 void addAudioConsumer(PassRefPtr<AudioDestinationConsumer>);
96 bool removeAudioConsumer(AudioDestinationConsumer*);
97 const Vector<RefPtr<AudioDestinationConsumer> >& audioConsumers() { return m _audioConsumers; }
98
99 private:
100 MediaStreamSource(const String& id, Type, const String& name, ReadyState, bo ol requiresConsumer);
101
102 String m_id;
103 Type m_type;
104 String m_name;
105 ReadyState m_readyState;
106 String m_deviceId;
107 bool m_requiresConsumer;
108 Vector<Observer*> m_observers;
109 Mutex m_audioConsumersLock;
110 Vector<RefPtr<AudioDestinationConsumer> > m_audioConsumers;
111 OwnPtr<ExtraData> m_extraData;
112 RefPtr<MediaConstraints> m_constraints;
113 };
114
115 typedef Vector<RefPtr<MediaStreamSource> > MediaStreamSourceVector;
116
117 } // namespace WebCore
118
119 #endif // MediaStreamSource_h
OLDNEW
« no previous file with comments | « Source/core/platform/mediastream/MediaStreamDescriptor.cpp ('k') | Source/core/platform/mediastream/MediaStreamSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698