OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 14 matching lines...) Expand all Loading... |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 // The CaptureManager class manages VideoCapturers to make it possible to share | 28 // The CaptureManager class manages VideoCapturers to make it possible to share |
29 // the same VideoCapturers across multiple instances. E.g. if two instances of | 29 // the same VideoCapturers across multiple instances. E.g. if two instances of |
30 // some class want to listen to same VideoCapturer they can't individually stop | 30 // some class want to listen to same VideoCapturer they can't individually stop |
31 // and start capturing as doing so will affect the other instance. | 31 // and start capturing as doing so will affect the other instance. |
32 // The class employs reference counting on starting and stopping of capturing of | 32 // The class employs reference counting on starting and stopping of capturing of |
33 // frames such that if anyone is still listening it will not be stopped. The | 33 // frames such that if anyone is still listening it will not be stopped. The |
34 // class also provides APIs for attaching VideoRenderers to a specific capturer | 34 // class also provides APIs for attaching VideoRenderers to a specific capturer |
35 // such that the VideoRenderers are fed frames directly from the capturer. In | 35 // such that the VideoRenderers are fed frames directly from the capturer. |
36 // addition, these frames can be altered before being sent to the capturers by | |
37 // way of VideoProcessors. | |
38 // CaptureManager is Thread-unsafe. This means that none of its APIs may be | 36 // CaptureManager is Thread-unsafe. This means that none of its APIs may be |
39 // called concurrently. Note that callbacks are called by the VideoCapturer's | 37 // called concurrently. Note that callbacks are called by the VideoCapturer's |
40 // thread which is normally a separate unmarshalled thread and thus normally | 38 // thread which is normally a separate unmarshalled thread and thus normally |
41 // require lock protection. | 39 // require lock protection. |
42 | 40 |
43 #ifndef TALK_MEDIA_BASE_CAPTUREMANAGER_H_ | 41 #ifndef TALK_MEDIA_BASE_CAPTUREMANAGER_H_ |
44 #define TALK_MEDIA_BASE_CAPTUREMANAGER_H_ | 42 #define TALK_MEDIA_BASE_CAPTUREMANAGER_H_ |
45 | 43 |
46 #include <map> | 44 #include <map> |
47 #include <vector> | 45 #include <vector> |
48 | 46 |
49 #include "talk/media/base/capturerenderadapter.h" | 47 #include "talk/media/base/capturerenderadapter.h" |
50 #include "talk/media/base/videocommon.h" | 48 #include "talk/media/base/videocommon.h" |
51 #include "webrtc/base/sigslotrepeater.h" | 49 #include "webrtc/base/sigslotrepeater.h" |
52 #include "webrtc/base/thread_checker.h" | 50 #include "webrtc/base/thread_checker.h" |
53 | 51 |
54 namespace cricket { | 52 namespace cricket { |
55 | 53 |
56 class VideoCapturer; | 54 class VideoCapturer; |
57 class VideoProcessor; | |
58 class VideoRenderer; | 55 class VideoRenderer; |
59 class VideoCapturerState; | 56 class VideoCapturerState; |
60 | 57 |
61 class CaptureManager : public sigslot::has_slots<> { | 58 class CaptureManager : public sigslot::has_slots<> { |
62 public: | 59 public: |
63 enum RestartOptions { | 60 enum RestartOptions { |
64 kRequestRestart, | 61 kRequestRestart, |
65 kForceRestart | 62 kForceRestart |
66 }; | 63 }; |
67 | 64 |
(...skipping 12 matching lines...) Expand all Loading... |
80 virtual bool RestartVideoCapture(VideoCapturer* video_capturer, | 77 virtual bool RestartVideoCapture(VideoCapturer* video_capturer, |
81 const VideoFormat& previous_format, | 78 const VideoFormat& previous_format, |
82 const VideoFormat& desired_format, | 79 const VideoFormat& desired_format, |
83 RestartOptions options); | 80 RestartOptions options); |
84 | 81 |
85 virtual bool AddVideoRenderer(VideoCapturer* video_capturer, | 82 virtual bool AddVideoRenderer(VideoCapturer* video_capturer, |
86 VideoRenderer* video_renderer); | 83 VideoRenderer* video_renderer); |
87 virtual bool RemoveVideoRenderer(VideoCapturer* video_capturer, | 84 virtual bool RemoveVideoRenderer(VideoCapturer* video_capturer, |
88 VideoRenderer* video_renderer); | 85 VideoRenderer* video_renderer); |
89 | 86 |
90 virtual bool AddVideoProcessor(VideoCapturer* video_capturer, | |
91 VideoProcessor* video_processor); | |
92 virtual bool RemoveVideoProcessor(VideoCapturer* video_capturer, | |
93 VideoProcessor* video_processor); | |
94 | |
95 sigslot::repeater2<VideoCapturer*, CaptureState> SignalCapturerStateChange; | 87 sigslot::repeater2<VideoCapturer*, CaptureState> SignalCapturerStateChange; |
96 | 88 |
97 private: | 89 private: |
98 typedef std::map<VideoCapturer*, VideoCapturerState*> CaptureStates; | 90 typedef std::map<VideoCapturer*, VideoCapturerState*> CaptureStates; |
99 | 91 |
100 bool IsCapturerRegistered(VideoCapturer* video_capturer) const; | 92 bool IsCapturerRegistered(VideoCapturer* video_capturer) const; |
101 bool RegisterVideoCapturer(VideoCapturer* video_capturer); | 93 bool RegisterVideoCapturer(VideoCapturer* video_capturer); |
102 void UnregisterVideoCapturer(VideoCapturerState* capture_state); | 94 void UnregisterVideoCapturer(VideoCapturerState* capture_state); |
103 | 95 |
104 bool StartWithBestCaptureFormat(VideoCapturerState* capture_info, | 96 bool StartWithBestCaptureFormat(VideoCapturerState* capture_info, |
105 VideoCapturer* video_capturer); | 97 VideoCapturer* video_capturer); |
106 | 98 |
107 VideoCapturerState* GetCaptureState(VideoCapturer* video_capturer) const; | 99 VideoCapturerState* GetCaptureState(VideoCapturer* video_capturer) const; |
108 CaptureRenderAdapter* GetAdapter(VideoCapturer* video_capturer) const; | 100 CaptureRenderAdapter* GetAdapter(VideoCapturer* video_capturer) const; |
109 | 101 |
110 rtc::ThreadChecker thread_checker_; | 102 rtc::ThreadChecker thread_checker_; |
111 CaptureStates capture_states_; | 103 CaptureStates capture_states_; |
112 }; | 104 }; |
113 | 105 |
114 } // namespace cricket | 106 } // namespace cricket |
115 | 107 |
116 #endif // TALK_MEDIA_BASE_CAPTUREMANAGER_H_ | 108 #endif // TALK_MEDIA_BASE_CAPTUREMANAGER_H_ |
OLD | NEW |