| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
| 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
| 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #include "public/platform/WebMediaStream.h" | 27 #include "public/platform/WebMediaStream.h" |
| 28 | 28 |
| 29 #include "core/platform/UUID.h" | 29 #include "core/platform/UUID.h" |
| 30 #include "core/platform/chromium/support/WebMediaStreamPrivate.h" | |
| 31 #include "core/platform/mediastream/MediaStreamComponent.h" | 30 #include "core/platform/mediastream/MediaStreamComponent.h" |
| 31 #include "core/platform/mediastream/MediaStreamDescriptor.h" |
| 32 #include "core/platform/mediastream/MediaStreamSource.h" | 32 #include "core/platform/mediastream/MediaStreamSource.h" |
| 33 #include "public/platform/WebMediaStreamSource.h" | 33 #include "public/platform/WebMediaStreamSource.h" |
| 34 #include "public/platform/WebMediaStreamTrack.h" | 34 #include "public/platform/WebMediaStreamTrack.h" |
| 35 #include "public/platform/WebString.h" | 35 #include "public/platform/WebString.h" |
| 36 #include <wtf/OwnPtr.h> | 36 #include <wtf/OwnPtr.h> |
| 37 #include <wtf/PassOwnPtr.h> | 37 #include <wtf/PassOwnPtr.h> |
| 38 #include <wtf/Vector.h> | 38 #include <wtf/Vector.h> |
| 39 | 39 |
| 40 using namespace WebCore; | 40 using namespace WebCore; |
| 41 | 41 |
| 42 namespace WebKit { | 42 namespace WebKit { |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 class ExtraDataContainer : public WebMediaStreamPrivate::ExtraData { | 46 class ExtraDataContainer : public MediaStreamDescriptor::ExtraData { |
| 47 public: | 47 public: |
| 48 ExtraDataContainer(WebMediaStream::ExtraData* extraData) : m_extraData(adopt
Ptr(extraData)) { } | 48 ExtraDataContainer(WebMediaStream::ExtraData* extraData) : m_extraData(adopt
Ptr(extraData)) { } |
| 49 | 49 |
| 50 WebMediaStream::ExtraData* extraData() { return m_extraData.get(); } | 50 WebMediaStream::ExtraData* extraData() { return m_extraData.get(); } |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 OwnPtr<WebMediaStream::ExtraData> m_extraData; | 53 OwnPtr<WebMediaStream::ExtraData> m_extraData; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 WebMediaStream::WebMediaStream(WebMediaStreamPrivate* stream) | 58 WebMediaStream::WebMediaStream(const PassRefPtr<WebCore::MediaStreamDescriptor>&
mediaStreamDescriptor) |
| 59 : m_private(stream) | 59 : m_private(mediaStreamDescriptor) |
| 60 { | 60 { |
| 61 } | 61 } |
| 62 | 62 |
| 63 WebMediaStream::WebMediaStream(WebCore::MediaStreamDescriptor* mediaStreamDescri
ptor) |
| 64 : m_private(mediaStreamDescriptor) |
| 65 { |
| 66 } |
| 67 |
| 63 void WebMediaStream::reset() | 68 void WebMediaStream::reset() |
| 64 { | 69 { |
| 65 m_private.reset(); | 70 m_private.reset(); |
| 66 } | 71 } |
| 67 | 72 |
| 68 WebString WebMediaStream::label() const | 73 WebString WebMediaStream::label() const |
| 69 { | 74 { |
| 70 return m_private->id(); | 75 return m_private->id(); |
| 71 } | 76 } |
| 72 | 77 |
| 73 WebString WebMediaStream::id() const | 78 WebString WebMediaStream::id() const |
| 74 { | 79 { |
| 75 return m_private->id(); | 80 return m_private->id(); |
| 76 } | 81 } |
| 77 | 82 |
| 78 WebMediaStream::ExtraData* WebMediaStream::extraData() const | 83 WebMediaStream::ExtraData* WebMediaStream::extraData() const |
| 79 { | 84 { |
| 80 RefPtr<WebMediaStreamPrivate::ExtraData> data = m_private->extraData(); | 85 RefPtr<MediaStreamDescriptor::ExtraData> data = m_private->extraData(); |
| 81 if (!data) | 86 if (!data) |
| 82 return 0; | 87 return 0; |
| 83 return static_cast<ExtraDataContainer*>(data.get())->extraData(); | 88 return static_cast<ExtraDataContainer*>(data.get())->extraData(); |
| 84 } | 89 } |
| 85 | 90 |
| 86 void WebMediaStream::setExtraData(ExtraData* extraData) | 91 void WebMediaStream::setExtraData(ExtraData* extraData) |
| 87 { | 92 { |
| 88 m_private->setExtraData(adoptRef(new ExtraDataContainer(extraData))); | 93 m_private->setExtraData(adoptRef(new ExtraDataContainer(extraData))); |
| 89 } | 94 } |
| 90 | 95 |
| 91 void WebMediaStream::audioTracks(WebVector<WebMediaStreamTrack>& webTracks) cons
t | 96 void WebMediaStream::audioTracks(WebVector<WebMediaStreamTrack>& webTracks) cons
t |
| 92 { | 97 { |
| 93 size_t numberOfTracks = m_private->numberOfAudioComponents(); | 98 size_t numberOfTracks = m_private->numberOfAudioComponents(); |
| 94 WebVector<WebMediaStreamTrack> result(numberOfTracks); | 99 WebVector<WebMediaStreamTrack> result(numberOfTracks); |
| 95 for (size_t i = 0; i < numberOfTracks; ++i) | 100 for (size_t i = 0; i < numberOfTracks; ++i) |
| 96 result[i] = m_private->audioComponent(i); | 101 result[i] = m_private->audioComponent(i); |
| 97 webTracks.swap(result); | 102 webTracks.swap(result); |
| 98 } | 103 } |
| 99 | 104 |
| 100 void WebMediaStream::videoTracks(WebVector<WebMediaStreamTrack>& webTracks) cons
t | 105 void WebMediaStream::videoTracks(WebVector<WebMediaStreamTrack>& webTracks) cons
t |
| 101 { | 106 { |
| 102 size_t numberOfTracks = m_private->numberOfVideoComponents(); | 107 size_t numberOfTracks = m_private->numberOfVideoComponents(); |
| 103 WebVector<WebMediaStreamTrack> result(numberOfTracks); | 108 WebVector<WebMediaStreamTrack> result(numberOfTracks); |
| 104 for (size_t i = 0; i < numberOfTracks; ++i) | 109 for (size_t i = 0; i < numberOfTracks; ++i) |
| 105 result[i] = m_private->videoComponent(i); | 110 result[i] = m_private->videoComponent(i); |
| 106 webTracks.swap(result); | 111 webTracks.swap(result); |
| 107 } | 112 } |
| 108 | 113 |
| 109 unsigned WebMediaStream::numberOfAudioComponents() const | |
| 110 { | |
| 111 return m_private->numberOfAudioComponents(); | |
| 112 } | |
| 113 | |
| 114 WebCore::MediaStreamComponent* WebMediaStream::audioComponent(unsigned index) co
nst | |
| 115 { | |
| 116 return m_private->audioComponent(index); | |
| 117 } | |
| 118 | |
| 119 unsigned WebMediaStream::numberOfVideoComponents() const | |
| 120 { | |
| 121 return m_private->numberOfVideoComponents(); | |
| 122 } | |
| 123 | |
| 124 WebCore::MediaStreamComponent* WebMediaStream::videoComponent(unsigned index) co
nst | |
| 125 { | |
| 126 return m_private->videoComponent(index); | |
| 127 } | |
| 128 | |
| 129 void WebMediaStream::addComponent(WebCore::MediaStreamComponent* component) | |
| 130 { | |
| 131 ASSERT(!isNull()); | |
| 132 m_private->addComponent(component); | |
| 133 } | |
| 134 | |
| 135 void WebMediaStream::removeComponent(WebCore::MediaStreamComponent* component) | |
| 136 { | |
| 137 ASSERT(!isNull()); | |
| 138 m_private->removeComponent(component); | |
| 139 } | |
| 140 | |
| 141 void WebMediaStream::trackEnded() | |
| 142 { | |
| 143 m_private->client()->trackEnded(); | |
| 144 } | |
| 145 | |
| 146 void WebMediaStream::streamEnded() | |
| 147 { | |
| 148 m_private->client()->streamEnded(); | |
| 149 } | |
| 150 | |
| 151 bool WebMediaStream::ended() const | |
| 152 { | |
| 153 return m_private->ended(); | |
| 154 } | |
| 155 | |
| 156 void WebMediaStream::setEnded() | |
| 157 { | |
| 158 m_private->setEnded(); | |
| 159 } | |
| 160 | |
| 161 WebMediaStreamClient* WebMediaStream::client() | |
| 162 { | |
| 163 return m_private->client(); | |
| 164 } | |
| 165 | |
| 166 void WebMediaStream::setClient(WebMediaStreamClient* client) | |
| 167 { | |
| 168 m_private->setClient(client); | |
| 169 } | |
| 170 | |
| 171 void WebMediaStream::addTrack(const WebMediaStreamTrack& track) | 114 void WebMediaStream::addTrack(const WebMediaStreamTrack& track) |
| 172 { | 115 { |
| 173 ASSERT(!isNull()); | 116 ASSERT(!isNull()); |
| 174 m_private->addRemoteTrack(track); | 117 m_private->addRemoteTrack(track); |
| 175 } | 118 } |
| 176 | 119 |
| 177 void WebMediaStream::removeTrack(const WebMediaStreamTrack& track) | 120 void WebMediaStream::removeTrack(const WebMediaStreamTrack& track) |
| 178 { | 121 { |
| 179 ASSERT(!isNull()); | 122 ASSERT(!isNull()); |
| 180 m_private->removeRemoteTrack(track); | 123 m_private->removeRemoteTrack(track); |
| 181 } | 124 } |
| 182 | 125 |
| 126 WebMediaStream& WebMediaStream::operator=(const PassRefPtr<WebCore::MediaStreamD
escriptor>& mediaStreamDescriptor) |
| 127 { |
| 128 m_private = mediaStreamDescriptor; |
| 129 return *this; |
| 130 } |
| 131 |
| 132 WebMediaStream::operator PassRefPtr<WebCore::MediaStreamDescriptor>() const |
| 133 { |
| 134 return m_private.get(); |
| 135 } |
| 136 |
| 137 WebMediaStream::operator WebCore::MediaStreamDescriptor*() const |
| 138 { |
| 139 return m_private.get(); |
| 140 } |
| 141 |
| 183 void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
StreamSource>& audioSources, const WebVector<WebMediaStreamSource>& videoSources
) | 142 void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
StreamSource>& audioSources, const WebVector<WebMediaStreamSource>& videoSources
) |
| 184 { | 143 { |
| 185 MediaStreamComponentVector audio, video; | 144 MediaStreamComponentVector audio, video; |
| 186 for (size_t i = 0; i < audioSources.size(); ++i) { | 145 for (size_t i = 0; i < audioSources.size(); ++i) { |
| 187 MediaStreamSource* source = audioSources[i]; | 146 MediaStreamSource* source = audioSources[i]; |
| 188 audio.append(MediaStreamComponent::create(source->id(), source)); | 147 audio.append(MediaStreamComponent::create(source->id(), source)); |
| 189 } | 148 } |
| 190 for (size_t i = 0; i < videoSources.size(); ++i) { | 149 for (size_t i = 0; i < videoSources.size(); ++i) { |
| 191 MediaStreamSource* source = videoSources[i]; | 150 MediaStreamSource* source = videoSources[i]; |
| 192 video.append(MediaStreamComponent::create(source->id(), source)); | 151 video.append(MediaStreamComponent::create(source->id(), source)); |
| 193 } | 152 } |
| 194 m_private = WebMediaStreamPrivate::create(label, audio, video); | 153 m_private = MediaStreamDescriptor::create(label, audio, video); |
| 195 } | 154 } |
| 196 | 155 |
| 197 void WebMediaStream::initialize(const WebVector<WebMediaStreamTrack>& audioTrack
s, const WebVector<WebMediaStreamTrack>& videoTracks) | 156 void WebMediaStream::initialize(const WebVector<WebMediaStreamTrack>& audioTrack
s, const WebVector<WebMediaStreamTrack>& videoTracks) |
| 198 { | 157 { |
| 199 initialize(WebCore::createCanonicalUUIDString(), audioTracks, videoTracks); | 158 initialize(createCanonicalUUIDString(), audioTracks, videoTracks); |
| 200 } | 159 } |
| 201 | 160 |
| 202 void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
StreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks) | 161 void WebMediaStream::initialize(const WebString& label, const WebVector<WebMedia
StreamTrack>& audioTracks, const WebVector<WebMediaStreamTrack>& videoTracks) |
| 203 { | 162 { |
| 204 MediaStreamComponentVector audio, video; | 163 MediaStreamComponentVector audio, video; |
| 205 for (size_t i = 0; i < audioTracks.size(); ++i) { | 164 for (size_t i = 0; i < audioTracks.size(); ++i) { |
| 206 MediaStreamComponent* component = audioTracks[i]; | 165 MediaStreamComponent* component = audioTracks[i]; |
| 207 audio.append(component); | 166 audio.append(component); |
| 208 } | 167 } |
| 209 for (size_t i = 0; i < videoTracks.size(); ++i) { | 168 for (size_t i = 0; i < videoTracks.size(); ++i) { |
| 210 MediaStreamComponent* component = videoTracks[i]; | 169 MediaStreamComponent* component = videoTracks[i]; |
| 211 video.append(component); | 170 video.append(component); |
| 212 } | 171 } |
| 213 m_private = WebMediaStreamPrivate::create(label, audio, video); | 172 m_private = MediaStreamDescriptor::create(label, audio, video); |
| 214 } | 173 } |
| 215 | 174 |
| 216 void WebMediaStream::assign(const WebMediaStream& other) | 175 void WebMediaStream::assign(const WebMediaStream& other) |
| 217 { | 176 { |
| 218 m_private = other.m_private; | 177 m_private = other.m_private; |
| 219 } | 178 } |
| 220 | 179 |
| 221 } // namespace WebKit | 180 } // namespace WebKit |
| OLD | NEW |