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

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

Issue 10451087: for readability review. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: modify comments Created 8 years, 5 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 // VideoCaptureImpl represents a capture device in renderer process. It provides 5 // VideoCaptureImpl represents a capture device in renderer process. It provides
6 // interfaces for clients to Start/Stop capture. It also communicates to clients 6 // interfaces for clients to Start/Stop capture. It also communicates to clients
7 // when buffer is ready, state of capture device is changed. 7 // when buffer is ready, state of capture device is changed.
8 8
9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which
10 // relays operation of capture device to browser process and receives response
11 // from browser process.
12
13 // The media::VideoCapture and VideoCaptureMessageFilter::Delegate are
14 // asynchronous interfaces, which means callers can call those interfaces
15 // from any threads without worrying about thread safety.
16 // The |capture_message_loop_proxy_| is the working thread of VideoCaptureImpl.
17 // All non-const members are accessed only on that working thread.
18
9 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 19 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
10 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 20 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
11 21
12 #include <list> 22 #include <list>
13 #include <map> 23 #include <map>
14 24
15 #include "content/common/content_export.h" 25 #include "content/common/content_export.h"
16 #include "content/common/media/video_capture.h" 26 #include "content/common/media/video_capture.h"
17 #include "content/renderer/media/video_capture_message_filter.h" 27 #include "content/renderer/media/video_capture_message_filter.h"
18 #include "media/video/capture/video_capture.h" 28 #include "media/video/capture/video_capture.h"
(...skipping 25 matching lines...) Expand all
44 virtual void OnDeviceInfoReceived( 54 virtual void OnDeviceInfoReceived(
45 const media::VideoCaptureParams& device_info) OVERRIDE; 55 const media::VideoCaptureParams& device_info) OVERRIDE;
46 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; 56 virtual void OnDelegateAdded(int32 device_id) OVERRIDE;
47 57
48 private: 58 private:
49 friend class VideoCaptureImplManager; 59 friend class VideoCaptureImplManager;
50 friend class VideoCaptureImplTest; 60 friend class VideoCaptureImplTest;
51 friend class MockVideoCaptureImpl; 61 friend class MockVideoCaptureImpl;
52 62
53 struct DIBBuffer; 63 struct DIBBuffer;
64 typedef std::map<media::VideoCapture::EventHandler*,
65 media::VideoCaptureCapability> ClientInfo;
54 66
55 VideoCaptureImpl(media::VideoCaptureSessionId id, 67 VideoCaptureImpl(media::VideoCaptureSessionId id,
56 base::MessageLoopProxy* capture_message_loop_proxy, 68 base::MessageLoopProxy* capture_message_loop_proxy,
57 VideoCaptureMessageFilter* filter); 69 VideoCaptureMessageFilter* filter);
58 virtual ~VideoCaptureImpl(); 70 virtual ~VideoCaptureImpl();
59 71
60 void DoStartCapture(media::VideoCapture::EventHandler* handler, 72 void DoStartCaptureOnCaptureThread(
61 const media::VideoCaptureCapability& capability); 73 media::VideoCapture::EventHandler* handler,
62 void DoStopCapture(media::VideoCapture::EventHandler* handler); 74 const media::VideoCaptureCapability& capability);
63 void DoFeedBuffer(scoped_refptr<VideoFrameBuffer> buffer); 75 void DoStopCaptureOnCaptureThread(media::VideoCapture::EventHandler* handler);
76 void DoFeedBufferOnCaptureThread(scoped_refptr<VideoFrameBuffer> buffer);
64 77
65 void DoBufferCreated(base::SharedMemoryHandle handle, 78 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle,
66 int length, int buffer_id); 79 int length, int buffer_id);
67 void DoBufferReceived(int buffer_id, base::Time timestamp); 80 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp);
68 void DoStateChanged(video_capture::State state); 81 void DoStateChangedOnCaptureThread(video_capture::State state);
69 void DoDeviceInfoReceived(const media::VideoCaptureParams& device_info); 82 void DoDeviceInfoReceivedOnCaptureThread(
70 void DoDelegateAdded(int32 device_id); 83 const media::VideoCaptureParams& device_info);
84 void DoDelegateAddedOnCaptureThread(int32 device_id);
71 85
72 void Init(); 86 void Init();
73 void DeInit(base::Closure task); 87 void DeInit(base::Closure task);
74 void DoDeInit(base::Closure task); 88 void DoDeInitOnCaptureThread(base::Closure task);
75 void StopDevice(); 89 void StopDevice();
76 void RestartCapture(); 90 void RestartCapture();
77 void StartCaptureInternal(); 91 void StartCaptureInternal();
78 void AddDelegateOnIOThread(); 92 void AddDelegateOnIOThread();
79 void RemoveDelegateOnIOThread(base::Closure task); 93 void RemoveDelegateOnIOThread(base::Closure task);
80 virtual void Send(IPC::Message* message); 94 virtual void Send(IPC::Message* message);
81 95
82 // Helpers. 96 // Helpers.
83 bool ClientHasDIB(); 97 bool ClientHasDIB() const;
98 bool RemoveClient(media::VideoCapture::EventHandler* handler,
99 ClientInfo* clients);
84 100
85 scoped_refptr<VideoCaptureMessageFilter> message_filter_; 101 const scoped_refptr<VideoCaptureMessageFilter> message_filter_;
86 scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_; 102 const scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_;
87 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 103 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
88 int device_id_; 104 int device_id_;
89 105
90 // Pool of DIBs. 106 // Pool of DIBs. The key is buffer_id.
91 typedef std::map<int /* buffer_id */, DIBBuffer*> CachedDIB; 107 typedef std::map<int, DIBBuffer*> CachedDIB;
92 CachedDIB cached_dibs_; 108 CachedDIB cached_dibs_;
93 109
94 typedef std::map<media::VideoCapture::EventHandler*,
95 media::VideoCaptureCapability> ClientInfo;
96 ClientInfo clients_; 110 ClientInfo clients_;
97 111
98 ClientInfo clients_pending_on_filter_; 112 ClientInfo clients_pending_on_filter_;
99 ClientInfo clients_pending_on_restart_; 113 ClientInfo clients_pending_on_restart_;
100 114
101 media::VideoCaptureCapability::Format video_type_; 115 media::VideoCaptureCapability::Format video_type_;
102 116
103 // The parameter is being used in current capture session. A capture session 117 // The parameter is being used in current capture session. A capture session
104 // starts with StartCapture and ends with StopCapture. 118 // starts with StartCapture and ends with StopCapture.
105 media::VideoCaptureParams current_params_; 119 media::VideoCaptureParams current_params_;
106 120
107 // The information about the device sent from browser process side. 121 // The information about the device sent from browser process side.
108 media::VideoCaptureParams device_info_; 122 media::VideoCaptureParams device_info_;
109 bool device_info_available_; 123 bool device_info_available_;
110 124
111 video_capture::State state_; 125 video_capture::State state_;
112 126
113 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 127 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
114 }; 128 };
115 129
116 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 130 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/capture_video_decoder_unittest.cc ('k') | content/renderer/media/video_capture_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698