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

Side by Side Diff: webrtc/api/objc/avfoundationvideocapturer.h

Issue 1838933004: Improve iOS frame capture threading. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2015 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 #ifndef WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ 11 #ifndef WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_
12 #define WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_ 12 #define WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_
13 13
14 #include "webrtc/base/scoped_ptr.h" 14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/media/base/videocapturer.h" 15 #include "webrtc/media/base/videocapturer.h"
16 #include "webrtc/video_frame.h" 16 #include "webrtc/video_frame.h"
17 17
18 #import <AVFoundation/AVFoundation.h> 18 #import <AVFoundation/AVFoundation.h>
19 19
20 @class RTCAVFoundationVideoCapturerInternal; 20 @class RTCAVFoundationVideoCapturerInternal;
21 21
22 namespace rtc { 22 namespace rtc {
23 class Thread; 23 class Thread;
24 } // namespace rtc 24 } // namespace rtc
25 25
26 namespace webrtc { 26 namespace webrtc {
27 27
28 class AVFoundationVideoCapturer : public cricket::VideoCapturer { 28 class AVFoundationVideoCapturer : public cricket::VideoCapturer,
29 public rtc::MessageHandler {
29 public: 30 public:
30 AVFoundationVideoCapturer(); 31 AVFoundationVideoCapturer();
31 ~AVFoundationVideoCapturer(); 32 ~AVFoundationVideoCapturer();
32 33
33 cricket::CaptureState Start(const cricket::VideoFormat& format) override; 34 cricket::CaptureState Start(const cricket::VideoFormat& format) override;
34 void Stop() override; 35 void Stop() override;
35 bool IsRunning() override; 36 bool IsRunning() override;
36 bool IsScreencast() const override { 37 bool IsScreencast() const override {
37 return false; 38 return false;
38 } 39 }
39 bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override { 40 bool GetPreferredFourccs(std::vector<uint32_t> *fourccs) override {
40 fourccs->push_back(cricket::FOURCC_NV12); 41 fourccs->push_back(cricket::FOURCC_NV12);
41 return true; 42 return true;
42 } 43 }
43 44
44 /** Returns the active capture session. */ 45 // Returns the active capture session. Calls to the capture session should
46 // occur on the RTCDispatcherTypeCaptureSession queue in RTCDispatcher.
45 AVCaptureSession* GetCaptureSession(); 47 AVCaptureSession* GetCaptureSession();
46 48
47 /** 49 // Returns whether the rear-facing camera can be used.
48 * Returns whether the rear-facing camera can be used. 50 // e.g. It can't be used because it doesn't exist.
49 * e.g. It can't be used because it doesn't exist.
50 */
51 bool CanUseBackCamera() const; 51 bool CanUseBackCamera() const;
52 52
53 /** Switches the camera being used (either front or back). */ 53 // Switches the camera being used (either front or back).
54 void SetUseBackCamera(bool useBackCamera); 54 void SetUseBackCamera(bool useBackCamera);
55 bool GetUseBackCamera() const; 55 bool GetUseBackCamera() const;
56 56
57 /** 57 // Converts the sample buffer into a cricket::CapturedFrame and signals the
58 * Converts the sample buffer into a cricket::CapturedFrame and signals the 58 // frame for capture.
59 * frame for capture.
60 */
61 void CaptureSampleBuffer(CMSampleBufferRef sampleBuffer); 59 void CaptureSampleBuffer(CMSampleBufferRef sampleBuffer);
62 60
61 // Handles messages from posts.
62 void OnMessage(rtc::Message *msg) override;
63
63 private: 64 private:
64 /** 65 void OnFrameMessage(CVImageBufferRef image_buffer, int64_t capture_time);
65 * Used to signal frame capture on the thread that capturer was started on.
66 */
67 void SignalFrameCapturedOnStartThread(const cricket::CapturedFrame *frame);
68 66
69 RTCAVFoundationVideoCapturerInternal *_capturer; 67 RTCAVFoundationVideoCapturerInternal *_capturer;
70 rtc::Thread *_startThread; // Set in Start(), unset in Stop(). 68 rtc::Thread *_startThread; // Set in Start(), unset in Stop().
71 }; // AVFoundationVideoCapturer 69 }; // AVFoundationVideoCapturer
72 70
73 } // namespace webrtc 71 } // namespace webrtc
74 72
75 #endif // TALK_APP_WEBRTC_OBJC_AVFOUNDATION_CAPTURER_H_ 73 #endif // WEBRTC_API_OBJC_AVFOUNDATION_VIDEO_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698