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 30 matching lines...) Expand all Loading... |
41 #include "modules/mediastream/MediaConstraintsImpl.h" | 41 #include "modules/mediastream/MediaConstraintsImpl.h" |
42 #include "modules/mediastream/MediaStream.h" | 42 #include "modules/mediastream/MediaStream.h" |
43 #include "modules/mediastream/MediaStreamConstraints.h" | 43 #include "modules/mediastream/MediaStreamConstraints.h" |
44 #include "modules/mediastream/MediaTrackConstraintSet.h" | 44 #include "modules/mediastream/MediaTrackConstraintSet.h" |
45 #include "modules/mediastream/UserMediaController.h" | 45 #include "modules/mediastream/UserMediaController.h" |
46 #include "platform/mediastream/MediaStreamCenter.h" | 46 #include "platform/mediastream/MediaStreamCenter.h" |
47 #include "platform/mediastream/MediaStreamDescriptor.h" | 47 #include "platform/mediastream/MediaStreamDescriptor.h" |
48 | 48 |
49 namespace blink { | 49 namespace blink { |
50 | 50 |
51 static WebMediaConstraints parseOptions(const BooleanOrMediaTrackConstraintSet&
options, MediaErrorState& errorState) | 51 static WebMediaConstraints parseOptions(ExecutionContext* context, const Boolean
OrMediaTrackConstraintSet& options, MediaErrorState& errorState) |
52 { | 52 { |
53 WebMediaConstraints constraints; | 53 WebMediaConstraints constraints; |
54 | 54 |
55 Dictionary constraintsDictionary; | 55 Dictionary constraintsDictionary; |
56 if (options.isNull()) { | 56 if (options.isNull()) { |
57 // Do nothing. | 57 // Do nothing. |
58 } else if (options.isMediaTrackConstraintSet()) { | 58 } else if (options.isMediaTrackConstraintSet()) { |
59 constraints = MediaConstraintsImpl::create(options.getAsMediaTrackConstr
aintSet(), errorState); | 59 constraints = MediaConstraintsImpl::create(context, options.getAsMediaTr
ackConstraintSet(), errorState); |
60 } else { | 60 } else { |
61 ASSERT(options.isBoolean()); | 61 ASSERT(options.isBoolean()); |
62 if (options.getAsBoolean()) { | 62 if (options.getAsBoolean()) { |
63 constraints = MediaConstraintsImpl::create(); | 63 constraints = MediaConstraintsImpl::create(); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 return constraints; | 67 return constraints; |
68 } | 68 } |
69 | 69 |
70 UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaC
ontroller* controller, const MediaStreamConstraints& options, NavigatorUserMedia
SuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback
, MediaErrorState& errorState) | 70 UserMediaRequest* UserMediaRequest::create(ExecutionContext* context, UserMediaC
ontroller* controller, const MediaStreamConstraints& options, NavigatorUserMedia
SuccessCallback* successCallback, NavigatorUserMediaErrorCallback* errorCallback
, MediaErrorState& errorState) |
71 { | 71 { |
72 WebMediaConstraints audio = parseOptions(options.audio(), errorState); | 72 WebMediaConstraints audio = parseOptions(context, options.audio(), errorStat
e); |
73 if (errorState.hadException()) | 73 if (errorState.hadException()) |
74 return nullptr; | 74 return nullptr; |
75 | 75 |
76 WebMediaConstraints video = parseOptions(options.video(), errorState); | 76 WebMediaConstraints video = parseOptions(context, options.video(), errorStat
e); |
77 if (errorState.hadException()) | 77 if (errorState.hadException()) |
78 return nullptr; | 78 return nullptr; |
79 | 79 |
80 if (audio.isNull() && video.isNull()) { | 80 if (audio.isNull() && video.isNull()) { |
81 errorState.throwDOMException(SyntaxError, "At least one of audio and vid
eo must be requested"); | 81 errorState.throwDOMException(SyntaxError, "At least one of audio and vid
eo must be requested"); |
82 return nullptr; | 82 return nullptr; |
83 } | 83 } |
84 | 84 |
85 return new UserMediaRequest(context, controller, audio, video, successCallba
ck, errorCallback); | 85 return new UserMediaRequest(context, controller, audio, video, successCallba
ck, errorCallback); |
86 } | 86 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 DEFINE_TRACE(UserMediaRequest) | 209 DEFINE_TRACE(UserMediaRequest) |
210 { | 210 { |
211 visitor->trace(m_controller); | 211 visitor->trace(m_controller); |
212 visitor->trace(m_successCallback); | 212 visitor->trace(m_successCallback); |
213 visitor->trace(m_errorCallback); | 213 visitor->trace(m_errorCallback); |
214 ContextLifecycleObserver::trace(visitor); | 214 ContextLifecycleObserver::trace(visitor); |
215 } | 215 } |
216 | 216 |
217 } // namespace blink | 217 } // namespace blink |
OLD | NEW |