| 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 #ifndef WEBRTC_API_VIDEOSOURCE_H_ | 11 #ifndef WEBRTC_API_VIDEOSOURCE_H_ |
| 12 #define WEBRTC_API_VIDEOSOURCE_H_ | 12 #define WEBRTC_API_VIDEOSOURCE_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 | 15 |
| 16 #include "webrtc/api/mediastreaminterface.h" | 16 #include "webrtc/api/mediastreaminterface.h" |
| 17 #include "webrtc/api/notifier.h" | 17 #include "webrtc/api/notifier.h" |
| 18 #include "webrtc/api/videosourceinterface.h" | 18 #include "webrtc/api/videosourceinterface.h" |
| 19 #include "webrtc/api/videotrackrenderers.h" | 19 #include "webrtc/api/videotrackrenderers.h" |
| 20 #include "webrtc/base/asyncinvoker.h" |
| 20 #include "webrtc/base/scoped_ptr.h" | 21 #include "webrtc/base/scoped_ptr.h" |
| 21 #include "webrtc/base/sigslot.h" | 22 #include "webrtc/base/sigslot.h" |
| 22 #include "webrtc/media/base/videosinkinterface.h" | 23 #include "webrtc/media/base/videosinkinterface.h" |
| 23 #include "webrtc/media/base/videocapturer.h" | 24 #include "webrtc/media/base/videocapturer.h" |
| 24 #include "webrtc/media/base/videocommon.h" | 25 #include "webrtc/media/base/videocommon.h" |
| 25 | 26 |
| 26 // VideoSource implements VideoSourceInterface. It owns a | 27 // VideoSource implements VideoSourceInterface. It owns a |
| 27 // cricket::VideoCapturer and make sure the camera is started at a resolution | 28 // cricket::VideoCapturer and make sure the camera is started at a resolution |
| 28 // that honors the constraints. | 29 // that honors the constraints. |
| 29 // The state is set depending on the result of starting the capturer. | 30 // The state is set depending on the result of starting the capturer. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 class MediaConstraintsInterface; | 42 class MediaConstraintsInterface; |
| 42 | 43 |
| 43 class VideoSource : public Notifier<VideoSourceInterface>, | 44 class VideoSource : public Notifier<VideoSourceInterface>, |
| 44 public sigslot::has_slots<> { | 45 public sigslot::has_slots<> { |
| 45 public: | 46 public: |
| 46 // Creates an instance of VideoSource. | 47 // Creates an instance of VideoSource. |
| 47 // VideoSource take ownership of |capturer|. | 48 // VideoSource take ownership of |capturer|. |
| 48 // |constraints| can be NULL and in that case the camera is opened using a | 49 // |constraints| can be NULL and in that case the camera is opened using a |
| 49 // default resolution. | 50 // default resolution. |
| 50 static rtc::scoped_refptr<VideoSource> Create( | 51 static rtc::scoped_refptr<VideoSource> Create( |
| 51 cricket::ChannelManager* channel_manager, | 52 rtc::Thread* worker_thread, |
| 52 cricket::VideoCapturer* capturer, | 53 cricket::VideoCapturer* capturer, |
| 53 const webrtc::MediaConstraintsInterface* constraints, | 54 const webrtc::MediaConstraintsInterface* constraints, |
| 54 bool remote); | 55 bool remote); |
| 55 | 56 |
| 56 SourceState state() const override { return state_; } | 57 SourceState state() const override { return state_; } |
| 57 bool remote() const override { return remote_; } | 58 bool remote() const override { return remote_; } |
| 58 | 59 |
| 59 virtual const cricket::VideoOptions* options() const { return &options_; } | 60 virtual const cricket::VideoOptions* options() const { return &options_; } |
| 60 | 61 |
| 61 virtual cricket::VideoCapturer* GetVideoCapturer() { | 62 virtual cricket::VideoCapturer* GetVideoCapturer() { |
| 62 return video_capturer_.get(); | 63 return video_capturer_.get(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void Stop() override; | 66 void Stop() override; |
| 66 void Restart() override; | 67 void Restart() override; |
| 67 | 68 |
| 68 // |output| will be served video frames as long as the underlying capturer | 69 // |output| will be served video frames as long as the underlying capturer |
| 69 // is running video frames. | 70 // is running video frames. |
| 70 virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); | 71 virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); |
| 71 virtual void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); | 72 virtual void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); |
| 72 | 73 |
| 73 protected: | 74 protected: |
| 74 VideoSource(cricket::ChannelManager* channel_manager, | 75 VideoSource(rtc::Thread* worker_thread, |
| 75 cricket::VideoCapturer* capturer, | 76 cricket::VideoCapturer* capturer, |
| 76 bool remote); | 77 bool remote); |
| 77 virtual ~VideoSource(); | 78 virtual ~VideoSource(); |
| 78 void Initialize(const webrtc::MediaConstraintsInterface* constraints); | 79 void Initialize(const webrtc::MediaConstraintsInterface* constraints); |
| 79 | 80 |
| 80 private: | 81 private: |
| 81 void OnStateChange(cricket::VideoCapturer* capturer, | 82 void OnStateChange(cricket::VideoCapturer* capturer, |
| 82 cricket::CaptureState capture_state); | 83 cricket::CaptureState capture_state); |
| 83 void SetState(SourceState new_state); | 84 void SetState(SourceState new_state); |
| 84 | 85 |
| 85 cricket::ChannelManager* channel_manager_; | 86 rtc::Thread* signaling_thread_; |
| 87 rtc::Thread* worker_thread_; |
| 88 rtc::AsyncInvoker invoker_; |
| 86 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; | 89 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; |
| 90 bool started_; |
| 87 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; | 91 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; |
| 88 | 92 |
| 89 std::list<rtc::VideoSinkInterface<cricket::VideoFrame>*> sinks_; | |
| 90 | |
| 91 cricket::VideoFormat format_; | 93 cricket::VideoFormat format_; |
| 92 cricket::VideoOptions options_; | 94 cricket::VideoOptions options_; |
| 93 SourceState state_; | 95 SourceState state_; |
| 94 const bool remote_; | 96 const bool remote_; |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 } // namespace webrtc | 99 } // namespace webrtc |
| 98 | 100 |
| 99 #endif // WEBRTC_API_VIDEOSOURCE_H_ | 101 #endif // WEBRTC_API_VIDEOSOURCE_H_ |
| OLD | NEW |