| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 2 * Copyright (C) 2011 Ericsson AB. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. 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 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #if ENABLE(MEDIA_STREAM) | 34 #if ENABLE(MEDIA_STREAM) |
| 35 | 35 |
| 36 #include "modules/mediastream/UserMediaRequest.h" | 36 #include "modules/mediastream/UserMediaRequest.h" |
| 37 | 37 |
| 38 #include "bindings/v8/Dictionary.h" | 38 #include "bindings/v8/Dictionary.h" |
| 39 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 40 #include "core/dom/ExceptionCode.h" | 40 #include "core/dom/ExceptionCode.h" |
| 41 #include "core/dom/SpaceSplitString.h" | 41 #include "core/dom/SpaceSplitString.h" |
| 42 #include "core/platform/mediastream/MediaStreamCenter.h" | 42 #include "core/platform/mediastream/MediaStreamCenter.h" |
| 43 #include "core/platform/mediastream/MediaStreamDescriptor.h" | 43 #include "core/platform/mediastream/MediaStreamDescriptor.h" |
| 44 #include "modules/mediastream/LocalMediaStream.h" | |
| 45 #include "modules/mediastream/MediaConstraintsImpl.h" | 44 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 45 #include "modules/mediastream/MediaStream.h" |
| 46 #include "modules/mediastream/UserMediaController.h" | 46 #include "modules/mediastream/UserMediaController.h" |
| 47 | 47 |
| 48 namespace WebCore { | 48 namespace WebCore { |
| 49 | 49 |
| 50 static PassRefPtr<MediaConstraintsImpl> parseOptions(const Dictionary& options,
const String& mediaType, ExceptionCode& ec) | 50 static PassRefPtr<MediaConstraintsImpl> parseOptions(const Dictionary& options,
const String& mediaType, ExceptionCode& ec) |
| 51 { | 51 { |
| 52 RefPtr<MediaConstraintsImpl> constraints; | 52 RefPtr<MediaConstraintsImpl> constraints; |
| 53 | 53 |
| 54 Dictionary constraintsDictionary; | 54 Dictionary constraintsDictionary; |
| 55 bool ok = options.get(mediaType, constraintsDictionary); | 55 bool ok = options.get(mediaType, constraintsDictionary); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 { | 128 { |
| 129 MediaStreamCenter::instance().queryMediaStreamSources(this); | 129 MediaStreamCenter::instance().queryMediaStreamSources(this); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void UserMediaRequest::didCompleteQuery(const MediaStreamSourceVector& audioSour
ces, const MediaStreamSourceVector& videoSources) | 132 void UserMediaRequest::didCompleteQuery(const MediaStreamSourceVector& audioSour
ces, const MediaStreamSourceVector& videoSources) |
| 133 { | 133 { |
| 134 if (m_controller) | 134 if (m_controller) |
| 135 m_controller->requestUserMedia(this, audioSources, videoSources); | 135 m_controller->requestUserMedia(this, audioSources, videoSources); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void UserMediaRequest::succeed(const MediaStreamSourceVector& audioSources, cons
t MediaStreamSourceVector& videoSources) | |
| 139 { | |
| 140 if (!m_scriptExecutionContext) | |
| 141 return; | |
| 142 | |
| 143 RefPtr<LocalMediaStream> stream = LocalMediaStream::create(m_scriptExecution
Context, audioSources, videoSources); | |
| 144 m_successCallback->handleEvent(stream.get()); | |
| 145 } | |
| 146 | |
| 147 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto
r) | 138 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto
r) |
| 148 { | 139 { |
| 149 if (!m_scriptExecutionContext) | 140 if (!m_scriptExecutionContext) |
| 150 return; | 141 return; |
| 151 | 142 |
| 152 RefPtr<LocalMediaStream> stream = LocalMediaStream::create(m_scriptExecution
Context, streamDescriptor); | 143 RefPtr<MediaStream> stream = MediaStream::create(m_scriptExecutionContext, s
treamDescriptor); |
| 153 m_successCallback->handleEvent(stream.get()); | 144 m_successCallback->handleEvent(stream.get()); |
| 154 } | 145 } |
| 155 | 146 |
| 156 void UserMediaRequest::fail() | 147 void UserMediaRequest::fail() |
| 157 { | 148 { |
| 158 if (!m_scriptExecutionContext) | 149 if (!m_scriptExecutionContext) |
| 159 return; | 150 return; |
| 160 | 151 |
| 161 if (m_errorCallback) { | 152 if (m_errorCallback) { |
| 162 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
NavigatorUserMediaError::PERMISSION_DENIED); | 153 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
NavigatorUserMediaError::PERMISSION_DENIED); |
| 163 m_errorCallback->handleEvent(error.get()); | 154 m_errorCallback->handleEvent(error.get()); |
| 164 } | 155 } |
| 165 } | 156 } |
| 166 | 157 |
| 167 void UserMediaRequest::contextDestroyed() | 158 void UserMediaRequest::contextDestroyed() |
| 168 { | 159 { |
| 169 RefPtr<UserMediaRequest> protect(this); | 160 RefPtr<UserMediaRequest> protect(this); |
| 170 | 161 |
| 171 if (m_controller) { | 162 if (m_controller) { |
| 172 m_controller->cancelUserMediaRequest(this); | 163 m_controller->cancelUserMediaRequest(this); |
| 173 m_controller = 0; | 164 m_controller = 0; |
| 174 } | 165 } |
| 175 | 166 |
| 176 ContextDestructionObserver::contextDestroyed(); | 167 ContextDestructionObserver::contextDestroyed(); |
| 177 } | 168 } |
| 178 | 169 |
| 179 } // namespace WebCore | 170 } // namespace WebCore |
| 180 | 171 |
| 181 #endif // ENABLE(MEDIA_STREAM) | 172 #endif // ENABLE(MEDIA_STREAM) |
| OLD | NEW |