| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 #ifndef TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ | 27 #ifndef TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ |
| 28 #define TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ | 28 #define TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ |
| 29 | 29 |
| 30 #include <string> | 30 #include <string> |
| 31 #include <vector> | 31 #include <vector> |
| 32 | 32 |
| 33 #include "talk/media/base/videocapturer.h" | 33 #include "talk/media/base/videocapturer.h" |
| 34 #include "webrtc/base/thread_checker.h" | 34 #include "webrtc/base/thread_checker.h" |
| 35 #include "webrtc/common_video/interface/video_frame_buffer.h" |
| 35 | 36 |
| 36 namespace webrtc { | 37 namespace webrtc { |
| 37 | 38 |
| 38 class AndroidVideoCapturer; | 39 class AndroidVideoCapturer; |
| 39 | 40 |
| 40 class AndroidVideoCapturerDelegate : public rtc::RefCountInterface { | 41 class AndroidVideoCapturerDelegate : public rtc::RefCountInterface { |
| 41 public: | 42 public: |
| 42 virtual ~AndroidVideoCapturerDelegate() {} | 43 virtual ~AndroidVideoCapturerDelegate() {} |
| 43 // Start capturing. The implementation of the delegate must call | 44 // Start capturing. The implementation of the delegate must call |
| 44 // AndroidVideoCapturer::OnCapturerStarted with the result of this request. | 45 // AndroidVideoCapturer::OnCapturerStarted with the result of this request. |
| 45 virtual void Start(int width, int height, int framerate, | 46 virtual void Start(int width, int height, int framerate, |
| 46 AndroidVideoCapturer* capturer) = 0; | 47 AndroidVideoCapturer* capturer) = 0; |
| 47 | 48 |
| 48 // Stops capturing. | 49 // Stops capturing. |
| 49 // The delegate may not call into AndroidVideoCapturer after this call. | 50 // The delegate may not call into AndroidVideoCapturer after this call. |
| 50 virtual void Stop() = 0; | 51 virtual void Stop() = 0; |
| 51 | 52 |
| 52 // Notify that a frame received in OnIncomingFrame with |time_stamp| has been | |
| 53 // processed and can be returned. May be called on an arbitrary thread. | |
| 54 virtual void ReturnBuffer(int64 time_stamp) = 0; | |
| 55 | |
| 56 // Must returns a JSON string "{{width=xxx, height=xxx, framerate = xxx}}" | 53 // Must returns a JSON string "{{width=xxx, height=xxx, framerate = xxx}}" |
| 57 virtual std::string GetSupportedFormats() = 0; | 54 virtual std::string GetSupportedFormats() = 0; |
| 58 }; | 55 }; |
| 59 | 56 |
| 60 // Android implementation of cricket::VideoCapturer for use with WebRtc | 57 // Android implementation of cricket::VideoCapturer for use with WebRtc |
| 61 // PeerConnection. | 58 // PeerConnection. |
| 62 class AndroidVideoCapturer : public cricket::VideoCapturer { | 59 class AndroidVideoCapturer : public cricket::VideoCapturer { |
| 63 public: | 60 public: |
| 64 explicit AndroidVideoCapturer( | 61 explicit AndroidVideoCapturer( |
| 65 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate); | 62 const rtc::scoped_refptr<AndroidVideoCapturerDelegate>& delegate); |
| 66 virtual ~AndroidVideoCapturer(); | 63 virtual ~AndroidVideoCapturer(); |
| 67 | 64 |
| 68 // Called from JNI when the capturer has been started. | 65 // Called from JNI when the capturer has been started. |
| 69 void OnCapturerStarted(bool success); | 66 void OnCapturerStarted(bool success); |
| 70 | 67 |
| 71 // Called from JNI when a new frame has been captured. | 68 // Called from JNI when a new frame has been captured. |
| 72 void OnIncomingFrame(void* video_frame, | 69 // Argument |buffer| is intentionally by value, for use with rtc::Bind. |
| 73 int length, | 70 void OnIncomingFrame(rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer, |
| 74 int width, | |
| 75 int height, | |
| 76 int rotation, | 71 int rotation, |
| 77 int64 time_stamp); | 72 int64 time_stamp); |
| 78 | 73 |
| 79 // Called from JNI to request a new video format. | 74 // Called from JNI to request a new video format. |
| 80 void OnOutputFormatRequest(int width, int height, int fps); | 75 void OnOutputFormatRequest(int width, int height, int fps); |
| 81 | 76 |
| 82 AndroidVideoCapturerDelegate* delegate() { return delegate_.get(); } | 77 AndroidVideoCapturerDelegate* delegate() { return delegate_.get(); } |
| 83 | 78 |
| 84 private: | 79 private: |
| 85 // cricket::VideoCapturer implementation. | 80 // cricket::VideoCapturer implementation. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 | 94 |
| 100 class FrameFactory; | 95 class FrameFactory; |
| 101 FrameFactory* frame_factory_; // Owned by cricket::VideoCapturer. | 96 FrameFactory* frame_factory_; // Owned by cricket::VideoCapturer. |
| 102 | 97 |
| 103 cricket::CaptureState current_state_; | 98 cricket::CaptureState current_state_; |
| 104 }; | 99 }; |
| 105 | 100 |
| 106 } // namespace webrtc | 101 } // namespace webrtc |
| 107 | 102 |
| 108 #endif // TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ | 103 #endif // TALK_APP_WEBRTC_ANDROIDVIDEOCAPTURER_H_ |
| OLD | NEW |