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

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

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) 2012 Google 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 *
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
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * 3. Neither the name of Google Inc. nor the names of its contributors
15 * may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32
33 #include "core/platform/mediastream/MediaStreamSource.h"
34 #include "wtf/PassOwnPtr.h"
35
36 namespace WebCore {
37
38 PassRefPtr<MediaStreamSource> MediaStreamSource::create(const String& id, Type t ype, const String& name, ReadyState readyState, bool requiresConsumer)
39 {
40 return adoptRef(new MediaStreamSource(id, type, name, readyState, requiresCo nsumer));
41 }
42
43 MediaStreamSource::MediaStreamSource(const String& id, Type type, const String& name, ReadyState readyState, bool requiresConsumer)
44 : m_id(id)
45 , m_type(type)
46 , m_name(name)
47 , m_readyState(readyState)
48 , m_requiresConsumer(requiresConsumer)
49 {
50 }
51
52 void MediaStreamSource::setReadyState(ReadyState readyState)
53 {
54 if (m_readyState != ReadyStateEnded && m_readyState != readyState) {
55 m_readyState = readyState;
56 for (Vector<Observer*>::iterator i = m_observers.begin(); i != m_observe rs.end(); ++i)
57 (*i)->sourceChangedState();
58 }
59 }
60
61 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer)
62 {
63 m_observers.append(observer);
64 }
65
66 void MediaStreamSource::removeObserver(MediaStreamSource::Observer* observer)
67 {
68 size_t pos = m_observers.find(observer);
69 if (pos != kNotFound)
70 m_observers.remove(pos);
71 }
72
73 void MediaStreamSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> co nsumer)
74 {
75 ASSERT(m_requiresConsumer);
76 MutexLocker locker(m_audioConsumersLock);
77 m_audioConsumers.append(consumer);
78 }
79
80 bool MediaStreamSource::removeAudioConsumer(AudioDestinationConsumer* consumer)
81 {
82 ASSERT(m_requiresConsumer);
83 MutexLocker locker(m_audioConsumersLock);
84 size_t pos = m_audioConsumers.find(consumer);
85 if (pos != kNotFound) {
86 m_audioConsumers.remove(pos);
87 return true;
88 }
89 return false;
90 }
91
92 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, float sampleRate )
93 {
94 ASSERT(m_requiresConsumer);
95 MutexLocker locker(m_audioConsumersLock);
96 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume rs.begin(); it != m_audioConsumers.end(); ++it)
97 (*it)->setFormat(numberOfChannels, sampleRate);
98 }
99
100 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames)
101 {
102 ASSERT(m_requiresConsumer);
103 MutexLocker locker(m_audioConsumersLock);
104 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume rs.begin(); it != m_audioConsumers.end(); ++it)
105 (*it)->consumeAudio(bus, numberOfFrames);
106 }
107
108 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/mediastream/MediaStreamSource.h ('k') | Source/modules/mediastream/MediaStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698