| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 else { | 58 else { |
| 59 bool mediaRequested = false; | 59 bool mediaRequested = false; |
| 60 options.get(mediaType, mediaRequested); | 60 options.get(mediaType, mediaRequested); |
| 61 if (mediaRequested) | 61 if (mediaRequested) |
| 62 constraints = MediaConstraintsImpl::create(); | 62 constraints = MediaConstraintsImpl::create(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 return constraints; | 65 return constraints; |
| 66 } | 66 } |
| 67 | 67 |
| 68 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ExecutionContext* context,
UserMediaController* controller, const Dictionary& options, PassOwnPtr<Navigato
rUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCa
llback> errorCallback, ExceptionState& exceptionState) | 68 PassRefPtrWillBeRawPtr<UserMediaRequest> UserMediaRequest::create(ExecutionConte
xt* context, UserMediaController* controller, const Dictionary& options, PassOwn
Ptr<NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUser
MediaErrorCallback> errorCallback, ExceptionState& exceptionState) |
| 69 { | 69 { |
| 70 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS
tate); | 70 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS
tate); |
| 71 if (exceptionState.hadException()) | 71 if (exceptionState.hadException()) |
| 72 return nullptr; | 72 return nullptr; |
| 73 | 73 |
| 74 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS
tate); | 74 blink::WebMediaConstraints video = parseOptions(options, "video", exceptionS
tate); |
| 75 if (exceptionState.hadException()) | 75 if (exceptionState.hadException()) |
| 76 return nullptr; | 76 return nullptr; |
| 77 | 77 |
| 78 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"); | 79 exceptionState.throwDOMException(SyntaxError, "At least one of audio and
video must be requested"); |
| 80 return nullptr; | 80 return nullptr; |
| 81 } | 81 } |
| 82 | 82 |
| 83 return adoptRef(new UserMediaRequest(context, controller, audio, video, succ
essCallback, errorCallback)); | 83 return adoptRefWillBeNoop(new UserMediaRequest(context, controller, audio, v
ideo, successCallback, errorCallback)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 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) |
| 87 : ContextLifecycleObserver(context) | 87 : ContextLifecycleObserver(context) |
| 88 , m_audio(audio) | 88 , m_audio(audio) |
| 89 , m_video(video) | 89 , m_video(video) |
| 90 , m_controller(controller) | 90 , m_controller(controller) |
| 91 , m_successCallback(successCallback) | 91 , m_successCallback(successCallback) |
| 92 , m_errorCallback(errorCallback) | 92 , m_errorCallback(errorCallback) |
| 93 { | 93 { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 { | 130 { |
| 131 if (m_controller) | 131 if (m_controller) |
| 132 m_controller->requestUserMedia(this); | 132 m_controller->requestUserMedia(this); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto
r) | 135 void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescripto
r) |
| 136 { | 136 { |
| 137 if (!executionContext()) | 137 if (!executionContext()) |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), streamD
escriptor); | 140 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex
t(), streamDescriptor); |
| 141 | 141 |
| 142 MediaStreamTrackVector audioTracks = stream->getAudioTracks(); | 142 MediaStreamTrackVector audioTracks = stream->getAudioTracks(); |
| 143 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au
dioTracks.end(); ++iter) { | 143 for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != au
dioTracks.end(); ++iter) { |
| 144 (*iter)->component()->source()->setConstraints(m_audio); | 144 (*iter)->component()->source()->setConstraints(m_audio); |
| 145 } | 145 } |
| 146 | 146 |
| 147 MediaStreamTrackVector videoTracks = stream->getVideoTracks(); | 147 MediaStreamTrackVector videoTracks = stream->getVideoTracks(); |
| 148 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi
deoTracks.end(); ++iter) { | 148 for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != vi
deoTracks.end(); ++iter) { |
| 149 (*iter)->component()->source()->setConstraints(m_video); | 149 (*iter)->component()->source()->setConstraints(m_video); |
| 150 } | 150 } |
| 151 | 151 |
| 152 m_successCallback->handleEvent(stream.get()); | 152 m_successCallback->handleEvent(stream.get()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void UserMediaRequest::fail(const String& description) | 155 void UserMediaRequest::fail(const String& description) |
| 156 { | 156 { |
| 157 if (!executionContext()) | 157 if (!executionContext()) |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi
gatorUserMediaError::NamePermissionDenied, description, String()); | 160 RefPtrWillBeRawPtr<NavigatorUserMediaError> error = NavigatorUserMediaError:
:create(NavigatorUserMediaError::NamePermissionDenied, description, String()); |
| 161 m_errorCallback->handleEvent(error.get()); | 161 m_errorCallback->handleEvent(error.get()); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) | 164 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) |
| 165 { | 165 { |
| 166 ASSERT(!constraintName.isEmpty()); | 166 ASSERT(!constraintName.isEmpty()); |
| 167 if (!executionContext()) | 167 if (!executionContext()) |
| 168 return; | 168 return; |
| 169 | 169 |
| 170 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(Navi
gatorUserMediaError::NameConstraintNotSatisfied, description, constraintName); | 170 RefPtrWillBeRawPtr<NavigatorUserMediaError> error = NavigatorUserMediaError:
:create(NavigatorUserMediaError::NameConstraintNotSatisfied, description, constr
aintName); |
| 171 m_errorCallback->handleEvent(error.get()); | 171 m_errorCallback->handleEvent(error.get()); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void UserMediaRequest::contextDestroyed() | 174 void UserMediaRequest::contextDestroyed() |
| 175 { | 175 { |
| 176 RefPtr<UserMediaRequest> protect(this); | 176 RefPtrWillBeRawPtr<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 |