| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | |
| 3 * Copyright (C) 2013 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 are | |
| 7 * met: | |
| 8 * | |
| 9 * * Redistributions of source code must retain the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer. | |
| 11 * * Redistributions in binary form must reproduce the above | |
| 12 * copyright notice, this list of conditions and the following disclaimer | |
| 13 * in the documentation and/or other materials provided with the | |
| 14 * distribution. | |
| 15 * * Neither the name of Google Inc. nor the names of its | |
| 16 * contributors may be used to endorse or promote products derived from | |
| 17 * this 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 #include "config.h" | |
| 33 | |
| 34 #include "core/platform/chromium/support/WebMediaStreamPrivate.h" | |
| 35 | |
| 36 #include "core/platform/UUID.h" | |
| 37 #include "core/platform/mediastream/MediaStreamComponent.h" | |
| 38 #include "core/platform/mediastream/MediaStreamSource.h" | |
| 39 #include "wtf/RefCounted.h" | |
| 40 #include "wtf/Vector.h" | |
| 41 | |
| 42 namespace WebKit { | |
| 43 | |
| 44 PassRefPtr<WebMediaStreamPrivate> WebMediaStreamPrivate::create(const WebCore::M
ediaStreamSourceVector& audioSources, const WebCore::MediaStreamSourceVector& vi
deoSources) | |
| 45 { | |
| 46 return adoptRef(new WebMediaStreamPrivate(WebCore::createCanonicalUUIDString
(), audioSources, videoSources)); | |
| 47 } | |
| 48 | |
| 49 PassRefPtr<WebMediaStreamPrivate> WebMediaStreamPrivate::create(const String& id
, const WebCore::MediaStreamComponentVector& audioComponents, const WebCore::Med
iaStreamComponentVector& videoComponents) | |
| 50 { | |
| 51 return adoptRef(new WebMediaStreamPrivate(id, audioComponents, videoComponen
ts)); | |
| 52 } | |
| 53 | |
| 54 void WebMediaStreamPrivate::addComponent(WebCore::MediaStreamComponent* componen
t) | |
| 55 { | |
| 56 switch (component->source()->type()) { | |
| 57 case WebCore::MediaStreamSource::TypeAudio: | |
| 58 if (m_audioComponents.find(component) == notFound) | |
| 59 m_audioComponents.append(component); | |
| 60 break; | |
| 61 case WebCore::MediaStreamSource::TypeVideo: | |
| 62 if (m_videoComponents.find(component) == notFound) | |
| 63 m_videoComponents.append(component); | |
| 64 break; | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 void WebMediaStreamPrivate::removeComponent(WebCore::MediaStreamComponent* compo
nent) | |
| 69 { | |
| 70 size_t pos = notFound; | |
| 71 switch (component->source()->type()) { | |
| 72 case WebCore::MediaStreamSource::TypeAudio: | |
| 73 pos = m_audioComponents.find(component); | |
| 74 if (pos != notFound) | |
| 75 m_audioComponents.remove(pos); | |
| 76 break; | |
| 77 case WebCore::MediaStreamSource::TypeVideo: | |
| 78 pos = m_videoComponents.find(component); | |
| 79 if (pos != notFound) | |
| 80 m_videoComponents.remove(pos); | |
| 81 break; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 void WebMediaStreamPrivate::addRemoteTrack(WebCore::MediaStreamComponent* compon
ent) | |
| 86 { | |
| 87 if (m_client) | |
| 88 m_client->addRemoteTrack(component); | |
| 89 else | |
| 90 addComponent(component); | |
| 91 } | |
| 92 | |
| 93 void WebMediaStreamPrivate::removeRemoteTrack(WebCore::MediaStreamComponent* com
ponent) | |
| 94 { | |
| 95 if (m_client) | |
| 96 m_client->removeRemoteTrack(component); | |
| 97 else | |
| 98 removeComponent(component); | |
| 99 } | |
| 100 | |
| 101 WebMediaStreamPrivate::WebMediaStreamPrivate(const String& id, const WebCore::Me
diaStreamSourceVector& audioSources, const WebCore::MediaStreamSourceVector& vid
eoSources) | |
| 102 : m_client(0) | |
| 103 , m_id(id) | |
| 104 , m_ended(false) | |
| 105 { | |
| 106 ASSERT(m_id.length()); | |
| 107 | |
| 108 for (size_t i = 0; i < audioSources.size(); i++) | |
| 109 m_audioComponents.append(WebCore::MediaStreamComponent::create(WebMediaS
tream(this), audioSources[i])); | |
| 110 | |
| 111 for (size_t i = 0; i < videoSources.size(); i++) | |
| 112 m_videoComponents.append(WebCore::MediaStreamComponent::create(WebMediaS
tream(this), videoSources[i])); | |
| 113 } | |
| 114 | |
| 115 WebMediaStreamPrivate::WebMediaStreamPrivate(const String& id, const WebCore::Me
diaStreamComponentVector& audioComponents, const WebCore::MediaStreamComponentVe
ctor& videoComponents) | |
| 116 : m_client(0) | |
| 117 , m_id(id) | |
| 118 , m_ended(false) | |
| 119 { | |
| 120 ASSERT(m_id.length()); | |
| 121 for (WebCore::MediaStreamComponentVector::const_iterator iter = audioCompone
nts.begin(); iter != audioComponents.end(); ++iter) { | |
| 122 (*iter)->setStream(this); | |
| 123 m_audioComponents.append((*iter)); | |
| 124 } | |
| 125 for (WebCore::MediaStreamComponentVector::const_iterator iter = videoCompone
nts.begin(); iter != videoComponents.end(); ++iter) { | |
| 126 (*iter)->setStream(this); | |
| 127 m_videoComponents.append((*iter)); | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 } // namespace WebKit | |
| OLD | NEW |