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

Side by Side Diff: webrtc/media/engine/webrtcvideocapturer.h

Issue 1817953005: Use rtc::scoped_refptr for WebRtcVideoCapturer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove incorrect early return Created 4 years, 9 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 (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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_MEDIA_ENGINE_WEBRTCVIDEOCAPTURER_H_ 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOCAPTURER_H_
12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOCAPTURER_H_ 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEOCAPTURER_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/asyncinvoker.h" 18 #include "webrtc/base/asyncinvoker.h"
19 #include "webrtc/base/messagehandler.h" 19 #include "webrtc/base/messagehandler.h"
20 #include "webrtc/base/scoped_ref_ptr.h"
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
21 #include "webrtc/media/base/device.h" 22 #include "webrtc/media/base/device.h"
22 #include "webrtc/media/base/videocapturer.h" 23 #include "webrtc/media/base/videocapturer.h"
23 #include "webrtc/media/engine/webrtcvideoframe.h" 24 #include "webrtc/media/engine/webrtcvideoframe.h"
24 #include "webrtc/modules/video_capture/video_capture.h" 25 #include "webrtc/modules/video_capture/video_capture.h"
25 26
26 namespace cricket { 27 namespace cricket {
27 28
28 // Factory to allow injection of a VCM impl into WebRtcVideoCapturer. 29 // Factory to allow injection of a VCM impl into WebRtcVideoCapturer.
29 // DeviceInfos do not have a Release() and therefore need an explicit Destroy(). 30 // DeviceInfos do not have a Release() and therefore need an explicit Destroy().
30 class WebRtcVcmFactoryInterface { 31 class WebRtcVcmFactoryInterface {
31 public: 32 public:
32 virtual ~WebRtcVcmFactoryInterface() {} 33 virtual ~WebRtcVcmFactoryInterface() {}
33 virtual webrtc::VideoCaptureModule* Create( 34 virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create(
34 int id, const char* device) = 0; 35 int id,
36 const char* device) = 0;
35 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) = 0; 37 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) = 0;
36 virtual void DestroyDeviceInfo( 38 virtual void DestroyDeviceInfo(
37 webrtc::VideoCaptureModule::DeviceInfo* info) = 0; 39 webrtc::VideoCaptureModule::DeviceInfo* info) = 0;
38 }; 40 };
39 41
40 // WebRTC-based implementation of VideoCapturer. 42 // WebRTC-based implementation of VideoCapturer.
41 class WebRtcVideoCapturer : public VideoCapturer, 43 class WebRtcVideoCapturer : public VideoCapturer,
42 public webrtc::VideoCaptureDataCallback { 44 public webrtc::VideoCaptureDataCallback {
43 public: 45 public:
44 WebRtcVideoCapturer(); 46 WebRtcVideoCapturer();
45 explicit WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory); 47 explicit WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory);
46 virtual ~WebRtcVideoCapturer(); 48 virtual ~WebRtcVideoCapturer();
47 49
48 bool Init(const Device& device); 50 bool Init(const Device& device);
49 bool Init(webrtc::VideoCaptureModule* module); 51 bool Init(const rtc::scoped_refptr<webrtc::VideoCaptureModule>& module);
50 52
51 // Override virtual methods of the parent class VideoCapturer. 53 // Override virtual methods of the parent class VideoCapturer.
52 bool GetBestCaptureFormat(const VideoFormat& desired, 54 bool GetBestCaptureFormat(const VideoFormat& desired,
53 VideoFormat* best_format) override; 55 VideoFormat* best_format) override;
54 CaptureState Start(const VideoFormat& capture_format) override; 56 CaptureState Start(const VideoFormat& capture_format) override;
55 void Stop() override; 57 void Stop() override;
56 bool IsRunning() override; 58 bool IsRunning() override;
57 bool IsScreencast() const override { return false; } 59 bool IsScreencast() const override { return false; }
58 60
59 protected: 61 protected:
(...skipping 10 matching lines...) Expand all
70 72
71 // Used to signal captured frames on the same thread as invoked Start(). 73 // Used to signal captured frames on the same thread as invoked Start().
72 // With WebRTC's current VideoCapturer implementations, this will mean a 74 // With WebRTC's current VideoCapturer implementations, this will mean a
73 // thread hop, but in other implementations (e.g. Chrome) it will be called 75 // thread hop, but in other implementations (e.g. Chrome) it will be called
74 // directly from OnIncomingCapturedFrame. 76 // directly from OnIncomingCapturedFrame.
75 // TODO(tommi): Remove this workaround when we've updated the WebRTC capturers 77 // TODO(tommi): Remove this workaround when we've updated the WebRTC capturers
76 // to follow the same contract. 78 // to follow the same contract.
77 void SignalFrameCapturedOnStartThread(const webrtc::VideoFrame& frame); 79 void SignalFrameCapturedOnStartThread(const webrtc::VideoFrame& frame);
78 80
79 std::unique_ptr<WebRtcVcmFactoryInterface> factory_; 81 std::unique_ptr<WebRtcVcmFactoryInterface> factory_;
80 webrtc::VideoCaptureModule* module_; 82 rtc::scoped_refptr<webrtc::VideoCaptureModule> module_;
81 int captured_frames_; 83 int captured_frames_;
82 std::vector<uint8_t> capture_buffer_; 84 std::vector<uint8_t> capture_buffer_;
83 rtc::Thread* start_thread_; // Set in Start(), unset in Stop(); 85 rtc::Thread* start_thread_; // Set in Start(), unset in Stop();
84 86
85 std::unique_ptr<rtc::AsyncInvoker> async_invoker_; 87 std::unique_ptr<rtc::AsyncInvoker> async_invoker_;
86 }; 88 };
87 89
88 struct WebRtcCapturedFrame : public CapturedFrame { 90 struct WebRtcCapturedFrame : public CapturedFrame {
89 public: 91 public:
90 WebRtcCapturedFrame(const webrtc::VideoFrame& frame, 92 WebRtcCapturedFrame(const webrtc::VideoFrame& frame,
91 void* buffer, 93 void* buffer,
92 size_t length); 94 size_t length);
93 }; 95 };
94 96
95 } // namespace cricket 97 } // namespace cricket
96 98
97 #endif // WEBRTC_MEDIA_WEBRTC_WEBRTCVIDEOCAPTURER_H_ 99 #endif // WEBRTC_MEDIA_WEBRTC_WEBRTCVIDEOCAPTURER_H_
OLDNEW
« no previous file with comments | « webrtc/media/engine/fakewebrtcvideocapturemodule.h ('k') | webrtc/media/engine/webrtcvideocapturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698