| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2011 Ericsson AB. 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "core/dom/ExecutionContext.h" | 31 #include "core/dom/ExecutionContext.h" |
| 32 #include "core/events/Event.h" | 32 #include "core/events/Event.h" |
| 33 #include "modules/mediastream/MediaStreamTrackSourcesCallback.h" | 33 #include "modules/mediastream/MediaStreamTrackSourcesCallback.h" |
| 34 #include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" | 34 #include "modules/mediastream/MediaStreamTrackSourcesRequestImpl.h" |
| 35 #include "platform/mediastream/MediaStreamCenter.h" | 35 #include "platform/mediastream/MediaStreamCenter.h" |
| 36 #include "platform/mediastream/MediaStreamComponent.h" | 36 #include "platform/mediastream/MediaStreamComponent.h" |
| 37 #include "public/platform/WebSourceInfo.h" | 37 #include "public/platform/WebSourceInfo.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 PassRefPtr<MediaStreamTrack> MediaStreamTrack::create(ExecutionContext* context,
MediaStreamComponent* component) | 41 PassRefPtrWillBeRawPtr<MediaStreamTrack> MediaStreamTrack::create(ExecutionConte
xt* context, MediaStreamComponent* component) |
| 42 { | 42 { |
| 43 RefPtr<MediaStreamTrack> track = adoptRef(new MediaStreamTrack(context, comp
onent)); | 43 RefPtrWillBeRawPtr<MediaStreamTrack> track = adoptRefWillBeRefCountedGarbage
Collected(new MediaStreamTrack(context, component)); |
| 44 track->suspendIfNeeded(); | 44 track->suspendIfNeeded(); |
| 45 return track.release(); | 45 return track.release(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, MediaStreamCompone
nt* component) | 48 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, MediaStreamCompone
nt* component) |
| 49 : ActiveDOMObject(context) | 49 : ActiveDOMObject(context) |
| 50 , m_readyState(MediaStreamSource::ReadyStateLive) | 50 , m_readyState(MediaStreamSource::ReadyStateLive) |
| 51 , m_isIteratingObservers(false) | 51 , m_isIteratingObservers(false) |
| 52 , m_stopped(false) | 52 , m_stopped(false) |
| 53 , m_component(component) | 53 , m_component(component) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 case MediaStreamSource::ReadyStateEnded: | 116 case MediaStreamSource::ReadyStateEnded: |
| 117 return "ended"; | 117 return "ended"; |
| 118 } | 118 } |
| 119 | 119 |
| 120 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 121 return String(); | 121 return String(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void MediaStreamTrack::getSources(ExecutionContext* context, PassOwnPtr<MediaStr
eamTrackSourcesCallback> callback, ExceptionState& exceptionState) | 124 void MediaStreamTrack::getSources(ExecutionContext* context, PassOwnPtr<MediaStr
eamTrackSourcesCallback> callback, ExceptionState& exceptionState) |
| 125 { | 125 { |
| 126 RefPtr<MediaStreamTrackSourcesRequest> request = MediaStreamTrackSourcesRequ
estImpl::create(context->securityOrigin()->toString(), callback); | 126 RefPtrWillBeRawPtr<MediaStreamTrackSourcesRequest> request = MediaStreamTrac
kSourcesRequestImpl::create(context->securityOrigin()->toString(), callback); |
| 127 if (!MediaStreamCenter::instance().getMediaStreamTrackSources(request.releas
e())) | 127 if (!MediaStreamCenter::instance().getMediaStreamTrackSources(request.releas
e())) |
| 128 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToExecute("getSources", "MediaStreamTrack", "Functionality not implemented
yet")); | 128 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f
ailedToExecute("getSources", "MediaStreamTrack", "Functionality not implemented
yet")); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void MediaStreamTrack::stopTrack(ExceptionState& exceptionState) | 131 void MediaStreamTrack::stopTrack(ExceptionState& exceptionState) |
| 132 { | 132 { |
| 133 if (ended()) | 133 if (ended()) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 m_readyState = MediaStreamSource::ReadyStateEnded; | 136 m_readyState = MediaStreamSource::ReadyStateEnded; |
| 137 MediaStreamCenter::instance().didStopMediaStreamTrack(component()); | 137 MediaStreamCenter::instance().didStopMediaStreamTrack(component()); |
| 138 dispatchEvent(Event::create(EventTypeNames::ended)); | 138 dispatchEvent(Event::create(EventTypeNames::ended)); |
| 139 propagateTrackEnded(); | 139 propagateTrackEnded(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 PassRefPtr<MediaStreamTrack> MediaStreamTrack::clone(ExecutionContext* context) | 142 PassRefPtrWillBeRawPtr<MediaStreamTrack> MediaStreamTrack::clone(ExecutionContex
t* context) |
| 143 { | 143 { |
| 144 RefPtr<MediaStreamComponent> clonedComponent = MediaStreamComponent::create(
component()->source()); | 144 RefPtr<MediaStreamComponent> clonedComponent = MediaStreamComponent::create(
component()->source()); |
| 145 RefPtr<MediaStreamTrack> clonedTrack = MediaStreamTrack::create(context, clo
nedComponent.get()); | 145 RefPtrWillBeRawPtr<MediaStreamTrack> clonedTrack = MediaStreamTrack::create(
context, clonedComponent.get()); |
| 146 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent.get(
)); | 146 MediaStreamCenter::instance().didCreateMediaStreamTrack(clonedComponent.get(
)); |
| 147 return clonedTrack.release(); | 147 return clonedTrack.release(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool MediaStreamTrack::ended() const | 150 bool MediaStreamTrack::ended() const |
| 151 { | 151 { |
| 152 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); | 152 return m_stopped || (m_readyState == MediaStreamSource::ReadyStateEnded); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void MediaStreamTrack::sourceChangedState() | 155 void MediaStreamTrack::sourceChangedState() |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 { | 214 { |
| 215 return EventTargetNames::MediaStreamTrack; | 215 return EventTargetNames::MediaStreamTrack; |
| 216 } | 216 } |
| 217 | 217 |
| 218 ExecutionContext* MediaStreamTrack::executionContext() const | 218 ExecutionContext* MediaStreamTrack::executionContext() const |
| 219 { | 219 { |
| 220 return ActiveDOMObject::executionContext(); | 220 return ActiveDOMObject::executionContext(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 } // namespace WebCore | 223 } // namespace WebCore |
| OLD | NEW |