| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 MediaStreamTrack* MediaStreamTrack::Create(ExecutionContext* context, | 59 MediaStreamTrack* MediaStreamTrack::Create(ExecutionContext* context, |
| 60 MediaStreamComponent* component) { | 60 MediaStreamComponent* component) { |
| 61 return new MediaStreamTrack(context, component); | 61 return new MediaStreamTrack(context, component); |
| 62 } | 62 } |
| 63 | 63 |
| 64 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, | 64 MediaStreamTrack::MediaStreamTrack(ExecutionContext* context, |
| 65 MediaStreamComponent* component) | 65 MediaStreamComponent* component) |
| 66 : ContextLifecycleObserver(context), | 66 : ContextLifecycleObserver(context), |
| 67 ready_state_(MediaStreamSource::kReadyStateLive), | 67 ready_state_(component->Source()->GetReadyState()), |
| 68 is_iterating_registered_media_streams_(false), | 68 is_iterating_registered_media_streams_(false), |
| 69 stopped_(false), | 69 stopped_(false), |
| 70 component_(component), | 70 component_(component), |
| 71 // The source's constraints aren't yet initialized at creation time. | 71 // The source's constraints aren't yet initialized at creation time. |
| 72 constraints_() { | 72 constraints_() { |
| 73 component_->Source()->AddObserver(this); | 73 component_->Source()->AddObserver(this); |
| 74 | 74 |
| 75 // If the source is already non-live at this point, the observer won't have |
| 76 // been called. Check the muted state manually. |
| 77 if (ready_state_ == MediaStreamSource::kReadyStateMuted) |
| 78 component_->SetMuted(true); |
| 79 |
| 75 if (component_->Source() && | 80 if (component_->Source() && |
| 76 component_->Source()->GetType() == MediaStreamSource::kTypeVideo) { | 81 component_->Source()->GetType() == MediaStreamSource::kTypeVideo) { |
| 77 // ImageCapture::create() only throws if |this| track is not of video type. | 82 // ImageCapture::create() only throws if |this| track is not of video type. |
| 78 NonThrowableExceptionState exception_state; | 83 NonThrowableExceptionState exception_state; |
| 79 image_capture_ = ImageCapture::Create(context, this, exception_state); | 84 image_capture_ = ImageCapture::Create(context, this, exception_state); |
| 80 } | 85 } |
| 81 } | 86 } |
| 82 | 87 |
| 83 MediaStreamTrack::~MediaStreamTrack() {} | 88 MediaStreamTrack::~MediaStreamTrack() {} |
| 84 | 89 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 181 } |
| 177 } | 182 } |
| 178 | 183 |
| 179 component_->SetContentHint(translated_hint); | 184 component_->SetContentHint(translated_hint); |
| 180 } | 185 } |
| 181 | 186 |
| 182 String MediaStreamTrack::readyState() const { | 187 String MediaStreamTrack::readyState() const { |
| 183 if (Ended()) | 188 if (Ended()) |
| 184 return "ended"; | 189 return "ended"; |
| 185 | 190 |
| 191 // Although muted is tracked as a ReadyState, only "live" and "ended" are |
| 192 // visible externally. |
| 186 switch (ready_state_) { | 193 switch (ready_state_) { |
| 187 case MediaStreamSource::kReadyStateLive: | 194 case MediaStreamSource::kReadyStateLive: |
| 195 case MediaStreamSource::kReadyStateMuted: |
| 188 return "live"; | 196 return "live"; |
| 189 case MediaStreamSource::kReadyStateMuted: | |
| 190 return "muted"; | |
| 191 case MediaStreamSource::kReadyStateEnded: | 197 case MediaStreamSource::kReadyStateEnded: |
| 192 return "ended"; | 198 return "ended"; |
| 193 } | 199 } |
| 194 | 200 |
| 195 NOTREACHED(); | 201 NOTREACHED(); |
| 196 return String(); | 202 return String(); |
| 197 } | 203 } |
| 198 | 204 |
| 199 void MediaStreamTrack::stopTrack(ExceptionState& exception_state) { | 205 void MediaStreamTrack::stopTrack(ExceptionState& exception_state) { |
| 200 if (Ended()) | 206 if (Ended()) |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 | 415 |
| 410 DEFINE_TRACE(MediaStreamTrack) { | 416 DEFINE_TRACE(MediaStreamTrack) { |
| 411 visitor->Trace(registered_media_streams_); | 417 visitor->Trace(registered_media_streams_); |
| 412 visitor->Trace(component_); | 418 visitor->Trace(component_); |
| 413 visitor->Trace(image_capture_); | 419 visitor->Trace(image_capture_); |
| 414 EventTargetWithInlineData::Trace(visitor); | 420 EventTargetWithInlineData::Trace(visitor); |
| 415 ContextLifecycleObserver::Trace(visitor); | 421 ContextLifecycleObserver::Trace(visitor); |
| 416 } | 422 } |
| 417 | 423 |
| 418 } // namespace blink | 424 } // namespace blink |
| OLD | NEW |