| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/api/videosource.h" | 11 #include "webrtc/api/videosource.h" |
| 12 | 12 |
| 13 #include <cstdlib> | 13 #include <cstdlib> |
| 14 #include <string> |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "webrtc/api/mediaconstraintsinterface.h" | 17 #include "webrtc/api/mediaconstraintsinterface.h" |
| 17 #include "webrtc/base/arraysize.h" | 18 #include "webrtc/base/arraysize.h" |
| 18 #include "webrtc/pc/channelmanager.h" | 19 #include "webrtc/pc/channelmanager.h" |
| 19 | 20 |
| 20 using cricket::CaptureState; | 21 using cricket::CaptureState; |
| 21 using webrtc::MediaConstraintsInterface; | 22 using webrtc::MediaConstraintsInterface; |
| 22 using webrtc::MediaSourceInterface; | 23 using webrtc::MediaSourceInterface; |
| 23 | 24 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 MediaSourceInterface::SourceState | 51 MediaSourceInterface::SourceState |
| 51 GetReadyState(cricket::CaptureState state) { | 52 GetReadyState(cricket::CaptureState state) { |
| 52 switch (state) { | 53 switch (state) { |
| 53 case cricket::CS_STARTING: | 54 case cricket::CS_STARTING: |
| 54 return MediaSourceInterface::kInitializing; | 55 return MediaSourceInterface::kInitializing; |
| 55 case cricket::CS_RUNNING: | 56 case cricket::CS_RUNNING: |
| 56 return MediaSourceInterface::kLive; | 57 return MediaSourceInterface::kLive; |
| 57 case cricket::CS_FAILED: | 58 case cricket::CS_FAILED: |
| 58 case cricket::CS_NO_DEVICE: | |
| 59 case cricket::CS_STOPPED: | 59 case cricket::CS_STOPPED: |
| 60 return MediaSourceInterface::kEnded; | 60 return MediaSourceInterface::kEnded; |
| 61 case cricket::CS_PAUSED: | 61 case cricket::CS_PAUSED: |
| 62 return MediaSourceInterface::kMuted; | 62 return MediaSourceInterface::kMuted; |
| 63 default: | 63 default: |
| 64 ASSERT(false && "GetReadyState unknown state"); | 64 ASSERT(false && "GetReadyState unknown state"); |
| 65 } | 65 } |
| 66 return MediaSourceInterface::kEnded; | 66 return MediaSourceInterface::kEnded; |
| 67 } | 67 } |
| 68 | 68 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 void VideoSource::RemoveSink( | 396 void VideoSource::RemoveSink( |
| 397 rtc::VideoSinkInterface<cricket::VideoFrame>* output) { | 397 rtc::VideoSinkInterface<cricket::VideoFrame>* output) { |
| 398 sinks_.remove(output); | 398 sinks_.remove(output); |
| 399 channel_manager_->RemoveVideoSink(video_capturer_.get(), output); | 399 channel_manager_->RemoveVideoSink(video_capturer_.get(), output); |
| 400 } | 400 } |
| 401 | 401 |
| 402 // OnStateChange listens to the ChannelManager::SignalVideoCaptureStateChange. | 402 // OnStateChange listens to the ChannelManager::SignalVideoCaptureStateChange. |
| 403 // This signal is triggered for all video capturers. Not only the one we are | 403 // This signal is triggered for all video capturers. Not only the one we are |
| 404 // interested in. | 404 // interested in. |
| 405 void VideoSource::OnStateChange(cricket::VideoCapturer* capturer, | 405 void VideoSource::OnStateChange(cricket::VideoCapturer* capturer, |
| 406 cricket::CaptureState capture_state) { | 406 cricket::CaptureState capture_state) { |
| 407 if (capturer == video_capturer_.get()) { | 407 if (capturer == video_capturer_.get()) { |
| 408 SetState(GetReadyState(capture_state)); | 408 SetState(GetReadyState(capture_state)); |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 | 411 |
| 412 void VideoSource::SetState(SourceState new_state) { | 412 void VideoSource::SetState(SourceState new_state) { |
| 413 // TODO(hbos): Temporarily disabled VERIFY due to webrtc:4776. | 413 // TODO(hbos): Temporarily disabled VERIFY due to webrtc:4776. |
| 414 // if (VERIFY(state_ != new_state)) { | 414 // if (VERIFY(state_ != new_state)) { |
| 415 if (state_ != new_state) { | 415 if (state_ != new_state) { |
| 416 state_ = new_state; | 416 state_ = new_state; |
| 417 FireOnChanged(); | 417 FireOnChanged(); |
| 418 } | 418 } |
| 419 } | 419 } |
| 420 | 420 |
| 421 } // namespace webrtc | 421 } // namespace webrtc |
| OLD | NEW |