OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 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 // The CaptureManager class manages VideoCapturers to make it possible to share | 11 // TODO(perkj): Remove this file once Chrome's gyp file doesn't depend on it. |
12 // the same VideoCapturers across multiple instances. E.g. if two instances of | |
13 // some class want to listen to same VideoCapturer they can't individually stop | |
14 // and start capturing as doing so will affect the other instance. | |
15 // The class employs reference counting on starting and stopping of capturing of | |
16 // frames such that if anyone is still listening it will not be stopped. The | |
17 // class also provides APIs for attaching VideoRenderers to a specific capturer | |
18 // such that the VideoRenderers are fed frames directly from the capturer. | |
19 // CaptureManager is Thread-unsafe. This means that none of its APIs may be | |
20 // called concurrently. Note that callbacks are called by the VideoCapturer's | |
21 // thread which is normally a separate unmarshalled thread and thus normally | |
22 // require lock protection. | |
23 | |
24 #ifndef WEBRTC_MEDIA_BASE_CAPTUREMANAGER_H_ | |
25 #define WEBRTC_MEDIA_BASE_CAPTUREMANAGER_H_ | |
26 | |
27 #include <map> | |
28 #include <vector> | |
29 | |
30 #include "webrtc/base/sigslotrepeater.h" | |
31 #include "webrtc/base/thread_checker.h" | |
32 #include "webrtc/media/base/videocommon.h" | |
33 #include "webrtc/media/base/videocapturer.h" | |
34 #include "webrtc/media/base/videosinkinterface.h" | |
35 | |
36 namespace cricket { | |
37 | |
38 class VideoFrame; | |
39 class VideoCapturerState; | |
40 | |
41 class CaptureManager : public sigslot::has_slots<> { | |
42 public: | |
43 enum RestartOptions { | |
44 kRequestRestart, | |
45 kForceRestart | |
46 }; | |
47 | |
48 CaptureManager(); | |
49 virtual ~CaptureManager(); | |
50 | |
51 virtual bool StartVideoCapture(VideoCapturer* video_capturer, | |
52 const VideoFormat& desired_format); | |
53 virtual bool StopVideoCapture(VideoCapturer* video_capturer, | |
54 const VideoFormat& format); | |
55 | |
56 virtual void AddVideoSink(VideoCapturer* video_capturer, | |
57 rtc::VideoSinkInterface<VideoFrame>* sink); | |
58 virtual void RemoveVideoSink(VideoCapturer* video_capturer, | |
59 rtc::VideoSinkInterface<VideoFrame>* sink); | |
60 | |
61 sigslot::repeater2<VideoCapturer*, CaptureState> SignalCapturerStateChange; | |
62 | |
63 private: | |
64 typedef std::map<VideoCapturer*, VideoCapturerState*> CaptureStates; | |
65 | |
66 bool IsCapturerRegistered(VideoCapturer* video_capturer) const; | |
67 bool RegisterVideoCapturer(VideoCapturer* video_capturer); | |
68 void UnregisterVideoCapturer(VideoCapturerState* capture_state); | |
69 | |
70 bool StartWithBestCaptureFormat(VideoCapturerState* capture_info, | |
71 VideoCapturer* video_capturer); | |
72 | |
73 VideoCapturerState* GetCaptureState(VideoCapturer* video_capturer) const; | |
74 | |
75 rtc::ThreadChecker thread_checker_; | |
76 CaptureStates capture_states_; | |
77 }; | |
78 | |
79 } // namespace cricket | |
80 | |
81 #endif // WEBRTC_MEDIA_BASE_CAPTUREMANAGER_H_ | |
OLD | NEW |