| 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 16 matching lines...) Expand all Loading... |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "config.h" | 32 #include "config.h" |
| 33 | 33 |
| 34 #include "modules/mediastream/UserMediaRequest.h" | 34 #include "modules/mediastream/UserMediaRequest.h" |
| 35 | 35 |
| 36 #include "bindings/v8/Dictionary.h" | 36 #include "bindings/v8/Dictionary.h" |
| 37 #include "bindings/v8/ExceptionMessages.h" |
| 37 #include "bindings/v8/ExceptionState.h" | 38 #include "bindings/v8/ExceptionState.h" |
| 38 #include "core/dom/Document.h" | 39 #include "core/dom/Document.h" |
| 40 #include "core/dom/ExceptionCode.h" |
| 39 #include "core/dom/SpaceSplitString.h" | 41 #include "core/dom/SpaceSplitString.h" |
| 40 #include "modules/mediastream/MediaConstraintsImpl.h" | 42 #include "modules/mediastream/MediaConstraintsImpl.h" |
| 41 #include "modules/mediastream/MediaStream.h" | 43 #include "modules/mediastream/MediaStream.h" |
| 42 #include "modules/mediastream/UserMediaController.h" | 44 #include "modules/mediastream/UserMediaController.h" |
| 43 #include "platform/mediastream/MediaStreamCenter.h" | 45 #include "platform/mediastream/MediaStreamCenter.h" |
| 44 #include "platform/mediastream/MediaStreamDescriptor.h" | 46 #include "platform/mediastream/MediaStreamDescriptor.h" |
| 45 | 47 |
| 46 namespace WebCore { | 48 namespace WebCore { |
| 47 | 49 |
| 48 static blink::WebMediaConstraints parseOptions(const Dictionary& options, const
String& mediaType, ExceptionState& exceptionState) | 50 static blink::WebMediaConstraints parseOptions(const Dictionary& options, const
String& mediaType, ExceptionState& exceptionState) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 66 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ExecutionContext* context,
UserMediaController* controller, const Dictionary& options, PassOwnPtr<Navigato
rUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCa
llback> errorCallback, ExceptionState& exceptionState) | 68 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ExecutionContext* context,
UserMediaController* controller, const Dictionary& options, PassOwnPtr<Navigato
rUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCa
llback> errorCallback, ExceptionState& exceptionState) |
| 67 { | 69 { |
| 68 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS
tate); | 70 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS
tate); |
| 69 if (exceptionState.hadException()) | 71 if (exceptionState.hadException()) |
| 70 return nullptr; | 72 return nullptr; |
| 71 | 73 |
| 72 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS
tate); | 74 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS
tate); |
| 73 if (exceptionState.hadException()) | 75 if (exceptionState.hadException()) |
| 74 return nullptr; | 76 return nullptr; |
| 75 | 77 |
| 76 if (audio.isNull() && video.isNull()) | 78 if (audio.isNull() && video.isNull()) { |
| 79 exceptionState.throwDOMException(SyntaxError, "At least one of audio and
video must be requested"); |
| 77 return nullptr; | 80 return nullptr; |
| 81 } |
| 78 | 82 |
| 79 return adoptRef(new UserMediaRequest(context, controller, audio, video, succ
essCallback, errorCallback)); | 83 return adoptRef(new UserMediaRequest(context, controller, audio, video, succ
essCallback, errorCallback)); |
| 80 } | 84 } |
| 81 | 85 |
| 82 UserMediaRequest::UserMediaRequest(ExecutionContext* context, UserMediaControlle
r* controller, blink::WebMediaConstraints audio, blink::WebMediaConstraints vide
o, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<Nav
igatorUserMediaErrorCallback> errorCallback) | 86 UserMediaRequest::UserMediaRequest(ExecutionContext* context, UserMediaControlle
r* controller, blink::WebMediaConstraints audio, blink::WebMediaConstraints vide
o, PassOwnPtr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<Nav
igatorUserMediaErrorCallback> errorCallback) |
| 83 : ContextLifecycleObserver(context) | 87 : ContextLifecycleObserver(context) |
| 84 , m_audio(audio) | 88 , m_audio(audio) |
| 85 , m_video(video) | 89 , m_video(video) |
| 86 , m_controller(controller) | 90 , m_controller(controller) |
| 87 , m_successCallback(successCallback) | 91 , m_successCallback(successCallback) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 150 } |
| 147 | 151 |
| 148 m_successCallback->handleEvent(stream.get()); | 152 m_successCallback->handleEvent(stream.get()); |
| 149 } | 153 } |
| 150 | 154 |
| 151 void UserMediaRequest::fail(const String& description) | 155 void UserMediaRequest::fail(const String& description) |
| 152 { | 156 { |
| 153 if (!executionContext()) | 157 if (!executionContext()) |
| 154 return; | 158 return; |
| 155 | 159 |
| 156 if (m_errorCallback) { | 160 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi
gatorUserMediaError::NamePermissionDenied, description, String()); |
| 157 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
NavigatorUserMediaError::NamePermissionDenied, description, String()); | 161 m_errorCallback->handleEvent(error.get()); |
| 158 m_errorCallback->handleEvent(error.get()); | |
| 159 } | |
| 160 } | 162 } |
| 161 | 163 |
| 162 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) | 164 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) |
| 163 { | 165 { |
| 164 ASSERT(!constraintName.isEmpty()); | 166 ASSERT(!constraintName.isEmpty()); |
| 165 if (!executionContext()) | 167 if (!executionContext()) |
| 166 return; | 168 return; |
| 167 | 169 |
| 168 if (m_errorCallback) { | 170 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi
gatorUserMediaError::NameConstraintNotSatisfied, description, constraintName); |
| 169 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
NavigatorUserMediaError::NameConstraintNotSatisfied, description, constraintName
); | 171 m_errorCallback->handleEvent(error.get()); |
| 170 m_errorCallback->handleEvent(error.get()); | |
| 171 } | |
| 172 } | 172 } |
| 173 | 173 |
| 174 void UserMediaRequest::contextDestroyed() | 174 void UserMediaRequest::contextDestroyed() |
| 175 { | 175 { |
| 176 RefPtr<UserMediaRequest> protect(this); | 176 RefPtr<UserMediaRequest> protect(this); |
| 177 | 177 |
| 178 if (m_controller) { | 178 if (m_controller) { |
| 179 m_controller->cancelUserMediaRequest(this); | 179 m_controller->cancelUserMediaRequest(this); |
| 180 m_controller = 0; | 180 m_controller = 0; |
| 181 } | 181 } |
| 182 | 182 |
| 183 ContextLifecycleObserver::contextDestroyed(); | 183 ContextLifecycleObserver::contextDestroyed(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace WebCore | 186 } // namespace WebCore |
| OLD | NEW |