OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "modules/mediastream/MediaStreamTrack.h" | 27 #include "modules/mediastream/MediaStreamTrack.h" |
28 | 28 |
29 #include "core/dom/Event.h" | 29 #include "core/dom/Event.h" |
30 #include "core/dom/ScriptExecutionContext.h" | 30 #include "core/dom/ScriptExecutionContext.h" |
31 #include "core/platform/mediastream/MediaStreamCenter.h" | 31 #include "core/platform/mediastream/MediaStreamCenter.h" |
32 #include "core/platform/mediastream/MediaStreamComponent.h" | 32 #include "core/platform/mediastream/MediaStreamComponent.h" |
| 33 #include "modules/mediastream/MediaStreamTrackSourcesCallback.h" |
| 34 #include "modules/mediastream/MediaStreamTrackSourcesRequest.h" |
33 #include "public/platform/WebSourceInfo.h" | 35 #include "public/platform/WebSourceInfo.h" |
34 #include "weborigin/SecurityOrigin.h" | |
35 | 36 |
36 namespace WebCore { | 37 namespace WebCore { |
37 | 38 |
38 PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* co
ntext, MediaStreamComponent* component) | 39 PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ScriptExecutionContext* co
ntext, MediaStreamComponent* component) |
39 { | 40 { |
40 RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, comp
onent)); | 41 RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, comp
onent)); |
41 track->suspendIfNeeded(); | 42 track->suspendIfNeeded(); |
42 return track.release(); | 43 return track.release(); |
43 } | 44 } |
44 | 45 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 case MediaStreamSource::ReadyStateMuted: | 112 case MediaStreamSource::ReadyStateMuted: |
112 return ASCIILiteral("muted"); | 113 return ASCIILiteral("muted"); |
113 case MediaStreamSource::ReadyStateEnded: | 114 case MediaStreamSource::ReadyStateEnded: |
114 return ASCIILiteral("ended"); | 115 return ASCIILiteral("ended"); |
115 } | 116 } |
116 | 117 |
117 ASSERT_NOT_REACHED(); | 118 ASSERT_NOT_REACHED(); |
118 return String(); | 119 return String(); |
119 } | 120 } |
120 | 121 |
121 SourceInfoVector MediaStreamTrack::getSourceInfos(ScriptExecutionContext* contex
t, ExceptionCode& ec) | 122 void MediaStreamTrack::getSources(ScriptExecutionContext* context, PassRefPtr<Me
diaStreamTrackSourcesCallback> callback, ExceptionCode& ec) |
122 { | 123 { |
123 WebKit::WebVector<WebKit::WebSourceInfo> webSourceInfos; | 124 RefPtr<MediaStreamTrackSourcesRequest> request = MediaStreamTrackSourcesRequ
est::create(context, callback); |
124 bool ok = MediaStreamCenter::instance().getSourceInfos(context->securityOrig
in()->toString(), webSourceInfos); | 125 bool ok = MediaStreamCenter::instance().getMediaStreamTrackSources(request.r
elease()); |
125 if (!ok) { | 126 if (!ok) |
126 ec = NOT_SUPPORTED_ERR; | 127 ec = NOT_SUPPORTED_ERR; |
127 return SourceInfoVector(); | |
128 } | |
129 | |
130 SourceInfoVector sourceInfos; | |
131 for (size_t i = 0; i < webSourceInfos.size(); ++i) | |
132 sourceInfos.append(SourceInfo::create(webSourceInfos[i])); | |
133 | |
134 return sourceInfos; | |
135 } | 128 } |
136 | 129 |
137 bool MediaStreamTrack::ended() const | 130 bool MediaStreamTrack::ended() const |
138 { | 131 { |
139 return m_stopped || (m_component->source()->readyState() == MediaStreamSourc
e::ReadyStateEnded); | 132 return m_stopped || (m_component->source()->readyState() == MediaStreamSourc
e::ReadyStateEnded); |
140 } | 133 } |
141 | 134 |
142 void MediaStreamTrack::sourceChangedState() | 135 void MediaStreamTrack::sourceChangedState() |
143 { | 136 { |
144 if (m_stopped) | 137 if (m_stopped) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 { | 184 { |
192 return &m_eventTargetData; | 185 return &m_eventTargetData; |
193 } | 186 } |
194 | 187 |
195 EventTargetData* MediaStreamTrack::ensureEventTargetData() | 188 EventTargetData* MediaStreamTrack::ensureEventTargetData() |
196 { | 189 { |
197 return &m_eventTargetData; | 190 return &m_eventTargetData; |
198 } | 191 } |
199 | 192 |
200 } // namespace WebCore | 193 } // namespace WebCore |
OLD | NEW |