OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_API_ANDROIDVIDEOCAPTURER_H_ | |
12 #define WEBRTC_API_ANDROIDVIDEOCAPTURER_H_ | |
13 | |
14 #include <string> | |
15 #include <vector> | |
16 | |
17 #include "webrtc/base/thread_checker.h" | |
18 #include "webrtc/common_video/include/video_frame_buffer.h" | |
19 #include "webrtc/media/base/videocapturer.h" | |
20 | |
21 namespace webrtc { | |
22 | |
23 class AndroidVideoCapturer; | |
24 | |
25 class AndroidVideoCapturerDelegate : public rtc::RefCountInterface { | |
26 public: | |
27 virtual ~AndroidVideoCapturerDelegate() {} | |
28 // Start capturing. The implementation of the delegate must call | |
29 // AndroidVideoCapturer::OnCapturerStarted with the result of this request. | |
30 virtual void Start(int width, int height, int framerate, | |
31 AndroidVideoCapturer* capturer) = 0; | |
32 | |
33 // Stops capturing. | |
34 // The delegate may not call into AndroidVideoCapturer after this call. | |
35 virtual void Stop() = 0; | |
36 | |
37 virtual std::vector<cricket::VideoFormat> GetSupportedFormats() = 0; | |
38 }; | |
39 | |
40 // Android implementation of cricket::VideoCapturer for use with WebRtc | |
41 // PeerConnection. | |
42 class AndroidVideoCapturer : public cricket::VideoCapturer { | |
43 public: | |
44 explicit AndroidVideoCapturer( | |
45 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate); | |
46 virtual ~AndroidVideoCapturer(); | |
47 | |
48 // Called from JNI when the capturer has been started. | |
49 void OnCapturerStarted(bool success); | |
50 | |
51 // Called from JNI to request a new video format. | |
52 void OnOutputFormatRequest(int width, int height, int fps); | |
53 | |
54 AndroidVideoCapturerDelegate* delegate() { return delegate_.get(); } | |
55 | |
56 // cricket::VideoCapturer implementation. | |
57 bool GetBestCaptureFormat(const cricket::VideoFormat& desired, | |
58 cricket::VideoFormat* best_format) override; | |
59 | |
60 // Expose these protected methods as public, to be used by the | |
61 // AndroidVideoCapturerJni. | |
62 using VideoCapturer::AdaptFrame; | |
63 using VideoCapturer::OnFrame; | |
64 | |
65 private: | |
66 // cricket::VideoCapturer implementation. | |
67 // Video frames will be delivered using | |
68 // cricket::VideoCapturer::SignalFrameCaptured on the thread that calls Start. | |
69 cricket::CaptureState Start( | |
70 const cricket::VideoFormat& capture_format) override; | |
71 void Stop() override; | |
72 bool IsRunning() override; | |
73 bool IsScreencast() const override { return false; } | |
74 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override; | |
75 | |
76 bool running_; | |
77 rtc::scoped_refptr<AndroidVideoCapturerDelegate> delegate_; | |
78 | |
79 rtc::ThreadChecker thread_checker_; | |
80 }; | |
81 | |
82 } // namespace webrtc | |
83 | |
84 #endif // WEBRTC_API_ANDROIDVIDEOCAPTURER_H_ | |
OLD | NEW |