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 29 matching lines...) Expand all Loading... |
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 "modules/mediastream/MediaConstraintsImpl.h" | 42 #include "modules/mediastream/MediaConstraintsImpl.h" |
43 #include "modules/mediastream/MediaStream.h" | 43 #include "modules/mediastream/MediaStream.h" |
44 #include "modules/mediastream/UserMediaController.h" | 44 #include "modules/mediastream/UserMediaController.h" |
45 #include "platform/mediastream/MediaStreamCenter.h" | 45 #include "platform/mediastream/MediaStreamCenter.h" |
46 #include "platform/mediastream/MediaStreamDescriptor.h" | 46 #include "platform/mediastream/MediaStreamDescriptor.h" |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 static blink::WebMediaConstraints parseOptions(const Dictionary& options, const
String& mediaType, ExceptionState& exceptionState) | 50 static WebMediaConstraints parseOptions(const Dictionary& options, const String&
mediaType, ExceptionState& exceptionState) |
51 { | 51 { |
52 blink::WebMediaConstraints constraints; | 52 WebMediaConstraints constraints; |
53 | 53 |
54 Dictionary constraintsDictionary; | 54 Dictionary constraintsDictionary; |
55 bool ok = options.get(mediaType, constraintsDictionary); | 55 bool ok = options.get(mediaType, constraintsDictionary); |
56 if (ok && !constraintsDictionary.isUndefinedOrNull()) | 56 if (ok && !constraintsDictionary.isUndefinedOrNull()) |
57 constraints = MediaConstraintsImpl::create(constraintsDictionary, except
ionState); | 57 constraints = MediaConstraintsImpl::create(constraintsDictionary, except
ionState); |
58 else { | 58 else { |
59 bool mediaRequested = false; | 59 bool mediaRequested = false; |
60 DictionaryHelper::get(options, mediaType, mediaRequested); | 60 DictionaryHelper::get(options, 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 UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaC
ontroller* controller, const Dictionary& options, PassOwnPtr<NavigatorUserMediaS
uccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCallback> err
orCallback, ExceptionState& exceptionState) | 68 UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaC
ontroller* controller, const Dictionary& options, PassOwnPtr<NavigatorUserMediaS
uccessCallback> successCallback, PassOwnPtr<NavigatorUserMediaErrorCallback> err
orCallback, ExceptionState& exceptionState) |
69 { | 69 { |
70 blink::WebMediaConstraints audio = parseOptions(options, "audio", exceptionS
tate); | 70 WebMediaConstraints audio = parseOptions(options, "audio", exceptionState); |
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 WebMediaConstraints video = parseOptions(options, "video", exceptionState); |
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 new UserMediaRequest(context, controller, audio, video, successCallba
ck, errorCallback); | 83 return new UserMediaRequest(context, controller, audio, video, successCallba
ck, 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, WebMediaConstraints audio, WebMediaConstraints video, PassOwnPtr<
NavigatorUserMediaSuccessCallback> successCallback, PassOwnPtr<NavigatorUserMedi
aErrorCallback> 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 { |
94 } | 94 } |
95 | 95 |
96 UserMediaRequest::~UserMediaRequest() | 96 UserMediaRequest::~UserMediaRequest() |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 bool UserMediaRequest::audio() const | 100 bool UserMediaRequest::audio() const |
101 { | 101 { |
102 return !m_audio.isNull(); | 102 return !m_audio.isNull(); |
103 } | 103 } |
104 | 104 |
105 bool UserMediaRequest::video() const | 105 bool UserMediaRequest::video() const |
106 { | 106 { |
107 return !m_video.isNull(); | 107 return !m_video.isNull(); |
108 } | 108 } |
109 | 109 |
110 blink::WebMediaConstraints UserMediaRequest::audioConstraints() const | 110 WebMediaConstraints UserMediaRequest::audioConstraints() const |
111 { | 111 { |
112 return m_audio; | 112 return m_audio; |
113 } | 113 } |
114 | 114 |
115 blink::WebMediaConstraints UserMediaRequest::videoConstraints() const | 115 WebMediaConstraints UserMediaRequest::videoConstraints() const |
116 { | 116 { |
117 return m_video; | 117 return m_video; |
118 } | 118 } |
119 | 119 |
120 Document* UserMediaRequest::ownerDocument() | 120 Document* UserMediaRequest::ownerDocument() |
121 { | 121 { |
122 if (ExecutionContext* context = executionContext()) { | 122 if (ExecutionContext* context = executionContext()) { |
123 return toDocument(context); | 123 return toDocument(context); |
124 } | 124 } |
125 | 125 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 { | 179 { |
180 if (m_controller) { | 180 if (m_controller) { |
181 m_controller->cancelUserMediaRequest(this); | 181 m_controller->cancelUserMediaRequest(this); |
182 m_controller = 0; | 182 m_controller = 0; |
183 } | 183 } |
184 | 184 |
185 ContextLifecycleObserver::contextDestroyed(); | 185 ContextLifecycleObserver::contextDestroyed(); |
186 } | 186 } |
187 | 187 |
188 } // namespace blink | 188 } // namespace blink |
OLD | NEW |