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 options.get(mediaType, mediaRequested); | 58 options.get(mediaType, mediaRequested); |
59 if (mediaRequested) | 59 if (mediaRequested) |
60 constraints = MediaConstraintsImpl::create(); | 60 constraints = MediaConstraintsImpl::create(); |
61 } | 61 } |
62 | 62 |
63 return constraints.release(); | 63 return constraints.release(); |
64 } | 64 } |
65 | 65 |
66 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ScriptExecutionContext* co
ntext, UserMediaController* controller, const Dictionary& options, PassRefPtr<Na
vigatorUserMediaSuccessCallback> successCallback, PassRefPtr<NavigatorUserMediaE
rrorCallback> errorCallback, ExceptionState& es) | 66 PassRefPtr<UserMediaRequest> UserMediaRequest::create(ScriptExecutionContext* co
ntext, UserMediaController* controller, const Dictionary& options, PassRefPtr<Na
vigatorUserMediaSuccessCallback> successCallback, PassRefPtr<NavigatorUserMediaE
rrorCallback> errorCallback, ExceptionState& es) |
67 { | 67 { |
68 RefPtr<MediaConstraintsImpl> audio = parseOptions(options, ASCIILiteral("aud
io"), es); | 68 RefPtr<MediaConstraintsImpl> audio = parseOptions(options, "audio", es); |
69 if (es.hadException()) | 69 if (es.hadException()) |
70 return 0; | 70 return 0; |
71 | 71 |
72 RefPtr<MediaConstraintsImpl> video = parseOptions(options, ASCIILiteral("vid
eo"), es); | 72 RefPtr<MediaConstraintsImpl> video = parseOptions(options, "video", es); |
73 if (es.hadException()) | 73 if (es.hadException()) |
74 return 0; | 74 return 0; |
75 | 75 |
76 if (!audio && !video) | 76 if (!audio && !video) |
77 return 0; | 77 return 0; |
78 | 78 |
79 return adoptRef(new UserMediaRequest(context, controller, audio.release(), v
ideo.release(), successCallback, errorCallback)); | 79 return adoptRef(new UserMediaRequest(context, controller, audio.release(), v
ideo.release(), successCallback, errorCallback)); |
80 } | 80 } |
81 | 81 |
82 UserMediaRequest::UserMediaRequest(ScriptExecutionContext* context, UserMediaCon
troller* controller, PassRefPtr<MediaConstraintsImpl> audio, PassRefPtr<MediaCon
straintsImpl> video, PassRefPtr<NavigatorUserMediaSuccessCallback> successCallba
ck, PassRefPtr<NavigatorUserMediaErrorCallback> errorCallback) | 82 UserMediaRequest::UserMediaRequest(ScriptExecutionContext* context, UserMediaCon
troller* controller, PassRefPtr<MediaConstraintsImpl> audio, PassRefPtr<MediaCon
straintsImpl> video, PassRefPtr<NavigatorUserMediaSuccessCallback> successCallba
ck, PassRefPtr<NavigatorUserMediaErrorCallback> errorCallback) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 m_successCallback->handleEvent(stream.get()); | 148 m_successCallback->handleEvent(stream.get()); |
149 } | 149 } |
150 | 150 |
151 void UserMediaRequest::fail(const String& description) | 151 void UserMediaRequest::fail(const String& description) |
152 { | 152 { |
153 if (!m_scriptExecutionContext) | 153 if (!m_scriptExecutionContext) |
154 return; | 154 return; |
155 | 155 |
156 if (m_errorCallback) { | 156 if (m_errorCallback) { |
157 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
ASCIILiteral("PERMISSION_DENIED"), description, String()); | 157 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
"PERMISSION_DENIED", description, String()); |
158 m_errorCallback->handleEvent(error.get()); | 158 m_errorCallback->handleEvent(error.get()); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) | 162 void UserMediaRequest::failConstraint(const String& constraintName, const String
& description) |
163 { | 163 { |
164 ASSERT(!constraintName.isEmpty()); | 164 ASSERT(!constraintName.isEmpty()); |
165 if (!m_scriptExecutionContext) | 165 if (!m_scriptExecutionContext) |
166 return; | 166 return; |
167 | 167 |
168 if (m_errorCallback) { | 168 if (m_errorCallback) { |
169 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
ASCIILiteral("CONSTRAINT_NOT_SATISFIED"), description, constraintName); | 169 RefPtr<NavigatorUserMediaError> error = NavigatorUserMediaError::create(
"CONSTRAINT_NOT_SATISFIED", description, constraintName); |
170 m_errorCallback->handleEvent(error.get()); | 170 m_errorCallback->handleEvent(error.get()); |
171 } | 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 |