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 // TODO(perkj): This file is added to prepare for changing name of VideoSource | 14 #include <list> |
15 // to VideoCapturerTrackSource. | |
16 | 15 |
17 #endif // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ | 16 #include "webrtc/api/mediastreaminterface.h" |
17 #include "webrtc/api/notifier.h" | |
18 #include "webrtc/api/videosourceinterface.h" | |
19 #include "webrtc/api/videotrackrenderers.h" | |
20 #include "webrtc/base/asyncinvoker.h" | |
21 #include "webrtc/base/scoped_ptr.h" | |
22 #include "webrtc/base/sigslot.h" | |
23 #include "webrtc/media/base/videosinkinterface.h" | |
24 #include "webrtc/media/base/videocapturer.h" | |
25 #include "webrtc/media/base/videocommon.h" | |
26 | |
27 // VideoCapturerTrackSource implements VideoTrackSourceInterface. It owns a | |
28 // cricket::VideoCapturer and make sure the camera is started at a resolution | |
29 // that honors the constraints. | |
pthatcher1
2016/03/09 20:47:14
make sure => make sure
| |
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 | |
32 // transition to kEnded, otherwise it transitions to kLive. | |
33 namespace webrtc { | |
34 | |
35 class MediaConstraintsInterface; | |
36 | |
37 class VideoCapturerTrackSource : public Notifier<VideoTrackSourceInterface>, | |
38 public sigslot::has_slots<> { | |
39 public: | |
40 // Creates an instance of VideoCapturerTrackSource. | |
41 // VideoCapturerTrackSource take ownership of |capturer|. | |
42 // |constraints| can be NULL and in that case the camera is opened using a | |
43 // default resolution. | |
44 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( | |
45 rtc::Thread* worker_thread, | |
46 cricket::VideoCapturer* capturer, | |
47 const webrtc::MediaConstraintsInterface* constraints, | |
48 bool remote); | |
49 | |
50 static rtc::scoped_refptr<VideoTrackSourceInterface> Create( | |
51 rtc::Thread* worker_thread, | |
52 cricket::VideoCapturer* capturer, | |
53 bool remote); | |
54 | |
55 SourceState state() const override { return state_; } | |
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(); | |
62 } | |
63 | |
64 void Stop() override; | |
65 void Restart() override; | |
66 | |
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: | |
72 VideoCapturerTrackSource(rtc::Thread* worker_thread, | |
73 cricket::VideoCapturer* capturer, | |
74 bool remote); | |
75 virtual ~VideoCapturerTrackSource(); | |
76 void Initialize(const webrtc::MediaConstraintsInterface* constraints); | |
77 | |
78 private: | |
79 void OnStateChange(cricket::VideoCapturer* capturer, | |
80 cricket::CaptureState capture_state); | |
81 void SetState(SourceState new_state); | |
82 | |
83 rtc::Thread* signaling_thread_; | |
84 rtc::Thread* worker_thread_; | |
85 rtc::AsyncInvoker invoker_; | |
86 rtc::scoped_ptr<cricket::VideoCapturer> video_capturer_; | |
87 bool started_; | |
88 rtc::scoped_ptr<cricket::VideoRenderer> frame_input_; | |
89 | |
90 cricket::VideoFormat format_; | |
91 cricket::VideoOptions options_; | |
92 SourceState state_; | |
93 const bool remote_; | |
94 }; | |
95 | |
96 } // namespace webrtc | |
97 | |
98 #endif // WEBRTC_API_VIDEOCAPTURERTRACKSOURCE_H_ | |
OLD | NEW |