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

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

Issue 2534553002: Replace VideoCaptureDataCallback by VideoSinkInterface. (Closed)
Patch Set: Break overlong lines. Created 4 years 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
(...skipping 13 matching lines...) Expand all
24 #include "webrtc/modules/video_capture/video_capture.h" 24 #include "webrtc/modules/video_capture/video_capture.h"
25 25
26 namespace cricket { 26 namespace cricket {
27 27
28 // Factory to allow injection of a VCM impl into WebRtcVideoCapturer. 28 // Factory to allow injection of a VCM impl into WebRtcVideoCapturer.
29 // DeviceInfos do not have a Release() and therefore need an explicit Destroy(). 29 // DeviceInfos do not have a Release() and therefore need an explicit Destroy().
30 class WebRtcVcmFactoryInterface { 30 class WebRtcVcmFactoryInterface {
31 public: 31 public:
32 virtual ~WebRtcVcmFactoryInterface() {} 32 virtual ~WebRtcVcmFactoryInterface() {}
33 virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create( 33 virtual rtc::scoped_refptr<webrtc::VideoCaptureModule> Create(
34 int id,
35 const char* device) = 0; 34 const char* device) = 0;
36 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo(int id) = 0; 35 virtual webrtc::VideoCaptureModule::DeviceInfo* CreateDeviceInfo() = 0;
37 virtual void DestroyDeviceInfo( 36 virtual void DestroyDeviceInfo(
38 webrtc::VideoCaptureModule::DeviceInfo* info) = 0; 37 webrtc::VideoCaptureModule::DeviceInfo* info) = 0;
39 }; 38 };
40 39
41 // WebRTC-based implementation of VideoCapturer. 40 // WebRTC-based implementation of VideoCapturer.
42 class WebRtcVideoCapturer : public VideoCapturer, 41 class WebRtcVideoCapturer : public VideoCapturer,
43 public webrtc::VideoCaptureDataCallback { 42 public rtc::VideoSinkInterface<webrtc::VideoFrame> {
44 public: 43 public:
45 WebRtcVideoCapturer(); 44 WebRtcVideoCapturer();
46 explicit WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory); 45 explicit WebRtcVideoCapturer(WebRtcVcmFactoryInterface* factory);
47 virtual ~WebRtcVideoCapturer(); 46 virtual ~WebRtcVideoCapturer();
48 47
49 bool Init(const Device& device); 48 bool Init(const Device& device);
50 bool Init(const rtc::scoped_refptr<webrtc::VideoCaptureModule>& module); 49 bool Init(const rtc::scoped_refptr<webrtc::VideoCaptureModule>& module);
51 50
52 // Override virtual methods of the parent class VideoCapturer. 51 // Override virtual methods of the parent class VideoCapturer.
53 bool GetBestCaptureFormat(const VideoFormat& desired, 52 bool GetBestCaptureFormat(const VideoFormat& desired,
54 VideoFormat* best_format) override; 53 VideoFormat* best_format) override;
55 CaptureState Start(const VideoFormat& capture_format) override; 54 CaptureState Start(const VideoFormat& capture_format) override;
56 void Stop() override; 55 void Stop() override;
57 bool IsRunning() override; 56 bool IsRunning() override;
58 bool IsScreencast() const override { return false; } 57 bool IsScreencast() const override { return false; }
59 58
60 protected: 59 protected:
61 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants) override; 60 void OnSinkWantsChanged(const rtc::VideoSinkWants& wants) override;
62 // Override virtual methods of the parent class VideoCapturer. 61 // Override virtual methods of the parent class VideoCapturer.
63 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override; 62 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override;
64 63
65 private: 64 private:
66 // Callback when a frame is captured by camera. 65 // Callback when a frame is captured by camera.
67 void OnIncomingCapturedFrame(const int32_t id, 66 void OnFrame(const webrtc::VideoFrame& frame) override;
68 const webrtc::VideoFrame& frame) override;
69 void OnCaptureDelayChanged(const int32_t id,
70 const int32_t delay) override;
71 67
72 // Used to signal captured frames on the same thread as invoked Start(). 68 // Used to signal captured frames on the same thread as invoked Start().
73 // With WebRTC's current VideoCapturer implementations, this will mean a 69 // With WebRTC's current VideoCapturer implementations, this will mean a
74 // thread hop, but in other implementations (e.g. Chrome) it will be called 70 // thread hop, but in other implementations (e.g. Chrome) it will be called
75 // directly from OnIncomingCapturedFrame. 71 // directly from OnIncomingCapturedFrame.
76 // TODO(tommi): Remove this workaround when we've updated the WebRTC capturers 72 // TODO(tommi): Remove this workaround when we've updated the WebRTC capturers
77 // to follow the same contract. 73 // to follow the same contract.
78 void SignalFrameCapturedOnStartThread(const webrtc::VideoFrame& frame); 74 void SignalFrameCapturedOnStartThread(const webrtc::VideoFrame& frame);
79 75
80 std::unique_ptr<WebRtcVcmFactoryInterface> factory_; 76 std::unique_ptr<WebRtcVcmFactoryInterface> factory_;
81 rtc::scoped_refptr<webrtc::VideoCaptureModule> module_; 77 rtc::scoped_refptr<webrtc::VideoCaptureModule> module_;
82 int captured_frames_; 78 int captured_frames_;
83 std::vector<uint8_t> capture_buffer_; 79 std::vector<uint8_t> capture_buffer_;
84 rtc::Thread* start_thread_; // Set in Start(), unset in Stop(); 80 rtc::Thread* start_thread_; // Set in Start(), unset in Stop();
85 81
86 std::unique_ptr<rtc::AsyncInvoker> async_invoker_; 82 std::unique_ptr<rtc::AsyncInvoker> async_invoker_;
87 }; 83 };
88 84
89 } // namespace cricket 85 } // namespace cricket
90 86
91 #endif // WEBRTC_MEDIA_WEBRTC_WEBRTCVIDEOCAPTURER_H_ 87 #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