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_VIDEOCAPTURERTRACKSOURCE_H_ | 11 #ifndef WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ |
12 #define WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ | 12 #define WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ |
13 | 13 |
14 #include <list> | |
15 | |
16 #include "webrtc/api/mediastreaminterface.h" | 14 #include "webrtc/api/mediastreaminterface.h" |
17 #include "webrtc/api/notifier.h" | 15 #include "webrtc/api/videotracksource.h" |
18 #include "webrtc/api/videosourceinterface.h" | |
19 #include "webrtc/api/videotrackrenderers.h" | |
20 #include "webrtc/base/asyncinvoker.h" | 16 #include "webrtc/base/asyncinvoker.h" |
21 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
22 #include "webrtc/base/sigslot.h" | 18 #include "webrtc/base/sigslot.h" |
23 #include "webrtc/media/base/videosinkinterface.h" | |
24 #include "webrtc/media/base/videocapturer.h" | 19 #include "webrtc/media/base/videocapturer.h" |
25 #include "webrtc/media/base/videocommon.h" | 20 #include "webrtc/media/base/videocommon.h" |
26 | 21 |
27 // VideoCapturerTrackSource implements VideoTrackSourceInterface. It owns a | 22 // VideoCapturerTrackSource implements VideoTrackSourceInterface. It owns a |
28 // cricket::VideoCapturer and make sure the camera is started at a resolution | 23 // cricket::VideoCapturer and make sure the camera is started at a resolution |
29 // that honors the constraints. | 24 // that honors the constraints. |
30 // The state is set depending on the result of starting the capturer. | 25 // The state is set depending on the result of starting the capturer. |
31 // If the constraint can't be met or the capturer fails to start, the state | 26 // If the constraint can't be met or the capturer fails to start, the state |
32 // transition to kEnded, otherwise it transitions to kLive. | 27 // transition to kEnded, otherwise it transitions to kLive. |
33 namespace webrtc { | 28 namespace webrtc { |
34 | 29 |
35 class MediaConstraintsInterface; | 30 class MediaConstraintsInterface; |
36 | 31 |
37 class VideoCapturerTrackSource : public Notifier<VideoTrackSourceInterface>, | 32 class VideoCapturerTrackSource : public VideoTrackSource, |
38 public sigslot::has_slots<> { | 33 public sigslot::has_slots<> { |
39 public: | 34 public: |
40 // Creates an instance of VideoCapturerTrackSource. | 35 // Creates an instance of VideoCapturerTrackSource. |
41 // VideoCapturerTrackSource take ownership of |capturer|. | 36 // VideoCapturerTrackSource take ownership of |capturer|. |
42 // |constraints| can be NULL and in that case the camera is opened using a | 37 // |constraints| can be NULL and in that case the camera is opened using a |
43 // default resolution. | 38 // default resolution. |
44 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( | 39 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( |
45 rtc::Thread* worker_thread, | 40 rtc::Thread* worker_thread, |
46 cricket::VideoCapturer* capturer, | 41 cricket::VideoCapturer* capturer, |
47 const webrtc::MediaConstraintsInterface* constraints, | 42 const webrtc::MediaConstraintsInterface* constraints, |
48 bool remote); | 43 bool remote); |
49 | 44 |
50 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( | 45 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( |
51 rtc::Thread* worker_thread, | 46 rtc::Thread* worker_thread, |
52 cricket::VideoCapturer* capturer, | 47 cricket::VideoCapturer* capturer, |
53 bool remote); | 48 bool remote); |
54 | 49 |
55 SourceState state() const override { return state_; } | 50 cricket::VideoCapturer* GetVideoCapturer() override { |
56 bool remote() const override { return remote_; } | |
57 | |
58 virtual const cricket::VideoOptions* options() const { return &options_; } | |
59 | |
60 virtual cricket::VideoCapturer* GetVideoCapturer() { | |
61 return video_capturer_.get(); | 51 return video_capturer_.get(); |
62 } | 52 } |
63 | 53 |
| 54 bool is_screencast() const override { |
| 55 return video_capturer_->IsScreencast(); |
| 56 } |
| 57 bool needs_denoising() const override { return needs_denoising_; } |
| 58 |
64 void Stop() override; | 59 void Stop() override; |
65 void Restart() override; | 60 void Restart() override; |
66 | 61 |
67 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | |
68 const rtc::VideoSinkWants& wants) override; | |
69 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; | |
70 | |
71 protected: | 62 protected: |
72 VideoCapturerTrackSource(rtc::Thread* worker_thread, | 63 VideoCapturerTrackSource(rtc::Thread* worker_thread, |
73 cricket::VideoCapturer* capturer, | 64 cricket::VideoCapturer* capturer, |
74 bool remote); | 65 bool remote); |
75 virtual ~VideoCapturerTrackSource(); | 66 virtual ~VideoCapturerTrackSource(); |
76 void Initialize(const webrtc::MediaConstraintsInterface* constraints); | 67 void Initialize(const webrtc::MediaConstraintsInterface* constraints); |
77 | 68 |
78 private: | 69 private: |
79 void OnStateChange(cricket::VideoCapturer* capturer, | 70 void OnStateChange(cricket::VideoCapturer* capturer, |
80 cricket::CaptureState capture_state); | 71 cricket::CaptureState capture_state); |
81 void SetState(SourceState new_state); | |
82 | 72 |
83 rtc::Thread* signaling_thread_; | 73 rtc::Thread* signaling_thread_; |
84 rtc::Thread* worker_thread_; | |
85 rtc::AsyncInvoker invoker_; | 74 rtc::AsyncInvoker invoker_; |
86 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; | 75 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; |
87 bool started_; | 76 bool started_; |
88 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; | |
89 | |
90 cricket::VideoFormat format_; | 77 cricket::VideoFormat format_; |
91 cricket::VideoOptions options_; | 78 bool needs_denoising_; |
92 SourceState state_; | |
93 const bool remote_; | |
94 }; | 79 }; |
95 | 80 |
96 } // namespace webrtc | 81 } // namespace webrtc |
97 | 82 |
98 #endif // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ | 83 #endif // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ |
OLD | NEW |