Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: talk/app/webrtc/androidvideocapturer.h

Issue 1307973002: AndroidVideoCapturerJni: Fix threading issues (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressing tommi@s comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | talk/app/webrtc/androidvideocapturer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | talk/app/webrtc/androidvideocapturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698