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

Side by Side Diff: content/renderer/media/rtc_video_capture_delegate.h

Issue 120893002: Eliminate video capture thread in renderer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "content/common/media/video_capture.h" 10 #include "content/common/media/video_capture.h"
11 #include "content/renderer/media/video_capture_impl_manager.h"
12 #include "media/video/capture/video_capture.h" 11 #include "media/video/capture/video_capture.h"
13 12
14 namespace content { 13 namespace content {
15 14
15 class VideoCaptureHandle;
16
16 // Implements a simple reference counted video capturer that guarantees that 17 // Implements a simple reference counted video capturer that guarantees that
17 // methods in RtcVideoCaptureDelegateEventHandler is only called from when 18 // methods in RtcVideoCaptureDelegateEventHandler is only called from when
18 // StartCapture have been called until after StopCapture have been called. 19 // StartCapture have been called until after StopCapture have been called.
19 // It uses VideoCaptureImplManager to start / stop and receive I420 frames 20 // It uses VideoCaptureImplManager to start / stop and receive I420 frames
20 // from Chrome's video capture implementation. 21 // from Chrome's video capture implementation.
21 class RtcVideoCaptureDelegate 22 class RtcVideoCaptureDelegate
22 : public base::RefCountedThreadSafe<RtcVideoCaptureDelegate>, 23 : public base::RefCountedThreadSafe<RtcVideoCaptureDelegate>,
23 public media::VideoCapture::EventHandler { 24 public media::VideoCapture::EventHandler {
24 public: 25 public:
25 enum CaptureState { 26 enum CaptureState {
26 CAPTURE_STOPPED, // The capturer has been stopped or hasn't started yet. 27 CAPTURE_STOPPED, // The capturer has been stopped or hasn't started yet.
27 CAPTURE_RUNNING, // The capturer has been started successfully and is now 28 CAPTURE_RUNNING, // The capturer has been started successfully and is now
28 // capturing. 29 // capturing.
29 CAPTURE_FAILED, // The capturer failed to start. 30 CAPTURE_FAILED, // The capturer failed to start.
30 }; 31 };
31 32
32 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>&)> 33 typedef base::Callback<void(const scoped_refptr<media::VideoFrame>&)>
33 FrameCapturedCallback; 34 FrameCapturedCallback;
34 typedef base::Callback<void(CaptureState)> StateChangeCallback; 35 typedef base::Callback<void(CaptureState)> StateChangeCallback;
35 36
36 RtcVideoCaptureDelegate(const media::VideoCaptureSessionId id, 37 RtcVideoCaptureDelegate(const media::VideoCaptureSessionId id);
37 VideoCaptureImplManager* vc_manager);
38 38
39 void StartCapture(const media::VideoCaptureParams& params, 39 void StartCapture(const media::VideoCaptureParams& params,
40 const FrameCapturedCallback& captured_callback, 40 const FrameCapturedCallback& captured_callback,
41 const StateChangeCallback& state_callback); 41 const StateChangeCallback& state_callback);
42 void StopCapture(); 42 void StopCapture();
43 43
44 // media::VideoCapture::EventHandler implementation. 44 // media::VideoCapture::EventHandler implementation.
45 // These functions are called from a thread owned by |vc_manager_|. 45 // These functions are called from a thread that |capture_engine_| runs on.
perkj_chrome 2014/01/07 06:21:44 While you are at it- make these OVERRIDES protecte
Alpha Left Google 2014/01/08 00:23:36 Done.
46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE; 46 virtual void OnStarted(media::VideoCapture* capture) OVERRIDE;
47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE; 47 virtual void OnStopped(media::VideoCapture* capture) OVERRIDE;
48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE; 48 virtual void OnPaused(media::VideoCapture* capture) OVERRIDE;
49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE; 49 virtual void OnError(media::VideoCapture* capture, int error_code) OVERRIDE;
50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE; 50 virtual void OnRemoved(media::VideoCapture* capture) OVERRIDE;
51 virtual void OnFrameReady( 51 virtual void OnFrameReady(
52 media::VideoCapture* capture, 52 media::VideoCapture* capture,
53 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; 53 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE;
54 54
55 private: 55 private:
56 friend class base::RefCountedThreadSafe<RtcVideoCaptureDelegate>; 56 friend class base::RefCountedThreadSafe<RtcVideoCaptureDelegate>;
57 57
58 virtual ~RtcVideoCaptureDelegate(); 58 virtual ~RtcVideoCaptureDelegate();
59 59
60 void OnFrameReadyOnCaptureThread( 60 void OnFrameReadyOnCaptureThread(
61 media::VideoCapture* capture, 61 media::VideoCapture* capture,
62 const scoped_refptr<media::VideoFrame>& frame); 62 const scoped_refptr<media::VideoFrame>& frame);
63 void OnErrorOnCaptureThread(media::VideoCapture* capture); 63 void OnErrorOnCaptureThread(media::VideoCapture* capture);
64 void OnRemovedOnCaptureThread(media::VideoCapture* capture); 64 void OnRemovedOnCaptureThread(media::VideoCapture* capture);
65 65
66 // The id identifies which video capture device is used for this video 66 // The id identifies which video capture device is used for this video
67 // capture session. 67 // capture session.
68 media::VideoCaptureSessionId session_id_; 68 media::VideoCaptureSessionId session_id_;
69 // The video capture manager handles open/close of video capture devices. 69 scoped_ptr<VideoCaptureHandle> capture_engine_;
70 scoped_refptr<VideoCaptureImplManager> vc_manager_;
71 media::VideoCapture* capture_engine_;
72 70
73 // Accessed on the thread where StartCapture is called. 71 // Accessed on the thread where StartCapture is called.
74 bool got_first_frame_; 72 bool got_first_frame_;
75 bool error_occured_; 73 bool error_occured_;
76 74
77 // |captured_callback_| is provided to this class in StartCapture and must be 75 // |captured_callback_| is provided to this class in StartCapture and must be
78 // valid until StopCapture is called. 76 // valid until StopCapture is called.
79 FrameCapturedCallback captured_callback_; 77 FrameCapturedCallback captured_callback_;
80 // |state_callback_| is provided to this class in StartCapture and must be 78 // |state_callback_| is provided to this class in StartCapture and must be
81 // valid until StopCapture is called. 79 // valid until StopCapture is called.
82 StateChangeCallback state_callback_; 80 StateChangeCallback state_callback_;
83 // Message loop of the caller of StartCapture. 81 // Message loop of the caller of StartCapture.
84 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 82 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
85 }; 83 };
86 84
87 } // namespace content 85 } // namespace content
88 86
89 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_ 87 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_CAPTURE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698