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 |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "webrtc/media/base/videosinkinterface.h" | 23 #include "webrtc/media/base/videosinkinterface.h" |
24 #include "webrtc/media/base/videocapturer.h" | 24 #include "webrtc/media/base/videocapturer.h" |
25 #include "webrtc/media/base/videocommon.h" | 25 #include "webrtc/media/base/videocommon.h" |
26 | 26 |
27 // VideoSource implements VideoSourceInterface. It owns a | 27 // VideoSource implements VideoSourceInterface. It owns a |
28 // 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 |
29 // that honors the constraints. | 29 // that honors the constraints. |
30 // 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. |
31 // If the constraint can't be met or the capturer fails to start, the state | 31 // If the constraint can't be met or the capturer fails to start, the state |
32 // transition to kEnded, otherwise it transitions to kLive. | 32 // transition to kEnded, otherwise it transitions to kLive. |
33 | |
34 namespace cricket { | |
35 | |
36 class ChannelManager; | |
37 | |
38 } // namespace cricket | |
39 | |
40 namespace webrtc { | 33 namespace webrtc { |
41 | 34 |
42 class MediaConstraintsInterface; | 35 class MediaConstraintsInterface; |
43 | 36 |
44 class VideoSource : public Notifier<VideoSourceInterface>, | 37 class VideoSource : public Notifier<VideoSourceInterface>, |
45 public sigslot::has_slots<> { | 38 public sigslot::has_slots<> { |
46 public: | 39 public: |
47 // Creates an instance of VideoSource. | 40 // Creates an instance of VideoSource. |
48 // VideoSource take ownership of |capturer|. | 41 // VideoSource take ownership of |capturer|. |
49 // |constraints| can be NULL and in that case the camera is opened using a | 42 // |constraints| can be NULL and in that case the camera is opened using a |
50 // default resolution. | 43 // default resolution. |
51 static rtc::scoped_refptr<VideoSource> Create( | 44 static rtc::scoped_refptr<VideoSource> Create( |
52 rtc::Thread* worker_thread, | 45 rtc::Thread* worker_thread, |
53 cricket::VideoCapturer* capturer, | 46 cricket::VideoCapturer* capturer, |
54 const webrtc::MediaConstraintsInterface* constraints, | 47 const webrtc::MediaConstraintsInterface* constraints, |
55 bool remote); | 48 bool remote); |
56 | 49 |
57 SourceState state() const override { return state_; } | 50 SourceState state() const override { return state_; } |
58 bool remote() const override { return remote_; } | 51 bool remote() const override { return remote_; } |
59 | 52 |
60 virtual const cricket::VideoOptions* options() const { return &options_; } | 53 virtual const cricket::VideoOptions* options() const { return &options_; } |
61 | 54 |
62 virtual cricket::VideoCapturer* GetVideoCapturer() { | 55 virtual cricket::VideoCapturer* GetVideoCapturer() { |
63 return video_capturer_.get(); | 56 return video_capturer_.get(); |
64 } | 57 } |
65 | 58 |
66 void Stop() override; | 59 void Stop() override; |
67 void Restart() override; | 60 void Restart() override; |
68 | 61 |
69 // |output| will be served video frames as long as the underlying capturer | 62 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
70 // is running video frames. | 63 const rtc::VideoSinkWants& wants) override; |
71 virtual void AddSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); | 64 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; |
72 virtual void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* output); | |
73 | 65 |
74 protected: | 66 protected: |
75 VideoSource(rtc::Thread* worker_thread, | 67 VideoSource(rtc::Thread* worker_thread, |
76 cricket::VideoCapturer* capturer, | 68 cricket::VideoCapturer* capturer, |
77 bool remote); | 69 bool remote); |
78 virtual ~VideoSource(); | 70 virtual ~VideoSource(); |
79 void Initialize(const webrtc::MediaConstraintsInterface* constraints); | 71 void Initialize(const webrtc::MediaConstraintsInterface* constraints); |
80 | 72 |
81 private: | 73 private: |
82 void OnStateChange(cricket::VideoCapturer* capturer, | 74 void OnStateChange(cricket::VideoCapturer* capturer, |
83 cricket::CaptureState capture_state); | 75 cricket::CaptureState capture_state); |
84 void SetState(SourceState new_state); | 76 void SetState(SourceState new_state); |
85 | 77 |
86 rtc::Thread* signaling_thread_; | 78 rtc::Thread* signaling_thread_; |
87 rtc::Thread* worker_thread_; | 79 rtc::Thread* worker_thread_; |
88 rtc::AsyncInvoker invoker_; | 80 rtc::AsyncInvoker invoker_; |
89 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; | 81 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; |
90 bool started_; | 82 bool started_; |
91 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; | 83 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; |
92 | 84 |
93 cricket::VideoFormat format_; | 85 cricket::VideoFormat format_; |
94 cricket::VideoOptions options_; | 86 cricket::VideoOptions options_; |
95 SourceState state_; | 87 SourceState state_; |
96 const bool remote_; | 88 const bool remote_; |
97 }; | 89 }; |
98 | 90 |
99 } // namespace webrtc | 91 } // namespace webrtc |
100 | 92 |
101 #endif // WEBRTC_API_VIDEOSOURCE_H_ | 93 #endif // WEBRTC_API_VIDEOSOURCE_H_ |
OLD | NEW |