| 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 | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND |
| 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 14 * ANY 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 | 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR |
| 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "public/platform/WebMediaStream.h" | 25 #include "public/platform/WebMediaStream.h" |
| 26 | 26 |
| 27 #include <memory> |
| 27 #include "platform/UUID.h" | 28 #include "platform/UUID.h" |
| 28 #include "platform/mediastream/MediaStreamComponent.h" | 29 #include "platform/mediastream/MediaStreamComponent.h" |
| 29 #include "platform/mediastream/MediaStreamDescriptor.h" | 30 #include "platform/mediastream/MediaStreamDescriptor.h" |
| 30 #include "platform/mediastream/MediaStreamSource.h" | 31 #include "platform/mediastream/MediaStreamSource.h" |
| 32 #include "platform/wtf/PtrUtil.h" |
| 33 #include "platform/wtf/Vector.h" |
| 34 #include "platform/wtf/text/WTFString.h" |
| 31 #include "public/platform/WebMediaStreamSource.h" | 35 #include "public/platform/WebMediaStreamSource.h" |
| 32 #include "public/platform/WebMediaStreamTrack.h" | 36 #include "public/platform/WebMediaStreamTrack.h" |
| 33 #include "public/platform/WebString.h" | 37 #include "public/platform/WebString.h" |
| 34 #include "wtf/PtrUtil.h" | |
| 35 #include "wtf/Vector.h" | |
| 36 #include <memory> | |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 namespace { | 41 namespace { |
| 41 | 42 |
| 42 class ExtraDataContainer : public MediaStreamDescriptor::ExtraData { | 43 class ExtraDataContainer : public MediaStreamDescriptor::ExtraData { |
| 43 public: | 44 public: |
| 44 ExtraDataContainer(std::unique_ptr<WebMediaStream::ExtraData> extraData) | 45 ExtraDataContainer(std::unique_ptr<WebMediaStream::ExtraData> extraData) |
| 45 : m_extraData(std::move(extraData)) {} | 46 : m_extraData(std::move(extraData)) {} |
| 46 | 47 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 87 |
| 87 void WebMediaStream::videoTracks( | 88 void WebMediaStream::videoTracks( |
| 88 WebVector<WebMediaStreamTrack>& webTracks) const { | 89 WebVector<WebMediaStreamTrack>& webTracks) const { |
| 89 size_t numberOfTracks = m_private->numberOfVideoComponents(); | 90 size_t numberOfTracks = m_private->numberOfVideoComponents(); |
| 90 WebVector<WebMediaStreamTrack> result(numberOfTracks); | 91 WebVector<WebMediaStreamTrack> result(numberOfTracks); |
| 91 for (size_t i = 0; i < numberOfTracks; ++i) | 92 for (size_t i = 0; i < numberOfTracks; ++i) |
| 92 result[i] = m_private->videoComponent(i); | 93 result[i] = m_private->videoComponent(i); |
| 93 webTracks.swap(result); | 94 webTracks.swap(result); |
| 94 } | 95 } |
| 95 | 96 |
| 97 WebMediaStreamTrack WebMediaStream::getAudioTrack( |
| 98 const WebString& trackId) const { |
| 99 size_t numberOfTracks = m_private->numberOfAudioComponents(); |
| 100 String id = trackId; |
| 101 for (size_t i = 0; i < numberOfTracks; ++i) { |
| 102 MediaStreamComponent* audioComponent = m_private->audioComponent(i); |
| 103 DCHECK(audioComponent); |
| 104 if (audioComponent->id() == id) |
| 105 return m_private->audioComponent(i); |
| 106 } |
| 107 return nullptr; |
| 108 } |
| 109 |
| 110 WebMediaStreamTrack WebMediaStream::getVideoTrack( |
| 111 const WebString& trackId) const { |
| 112 size_t numberOfTracks = m_private->numberOfVideoComponents(); |
| 113 String id = trackId; |
| 114 for (size_t i = 0; i < numberOfTracks; ++i) { |
| 115 MediaStreamComponent* videoComponent = m_private->videoComponent(i); |
| 116 DCHECK(videoComponent); |
| 117 if (videoComponent->id() == id) |
| 118 return m_private->videoComponent(i); |
| 119 } |
| 120 return nullptr; |
| 121 } |
| 122 |
| 96 void WebMediaStream::addTrack(const WebMediaStreamTrack& track) { | 123 void WebMediaStream::addTrack(const WebMediaStreamTrack& track) { |
| 97 ASSERT(!isNull()); | 124 ASSERT(!isNull()); |
| 98 m_private->addRemoteTrack(track); | 125 m_private->addRemoteTrack(track); |
| 99 } | 126 } |
| 100 | 127 |
| 101 void WebMediaStream::removeTrack(const WebMediaStreamTrack& track) { | 128 void WebMediaStream::removeTrack(const WebMediaStreamTrack& track) { |
| 102 ASSERT(!isNull()); | 129 ASSERT(!isNull()); |
| 103 m_private->removeRemoteTrack(track); | 130 m_private->removeRemoteTrack(track); |
| 104 } | 131 } |
| 105 | 132 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 133 video.push_back(component); | 160 video.push_back(component); |
| 134 } | 161 } |
| 135 m_private = MediaStreamDescriptor::create(label, audio, video); | 162 m_private = MediaStreamDescriptor::create(label, audio, video); |
| 136 } | 163 } |
| 137 | 164 |
| 138 void WebMediaStream::assign(const WebMediaStream& other) { | 165 void WebMediaStream::assign(const WebMediaStream& other) { |
| 139 m_private = other.m_private; | 166 m_private = other.m_private; |
| 140 } | 167 } |
| 141 | 168 |
| 142 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |