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

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

Issue 16320005: Define EncodedVideoSource and RtcCapturedEncodingVideoCapturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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 9 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which
10 // relays operation of capture device to browser process and receives response 10 // relays operation of capture device to browser process and receives response
11 // from browser process. 11 // from browser process.
12 12
13 // The media::VideoCapture and VideoCaptureMessageFilter::Delegate are 13 // The media::VideoCapture and VideoCaptureMessageFilter::Delegate are
14 // asynchronous interfaces, which means callers can call those interfaces 14 // asynchronous interfaces, which means callers can call those interfaces
15 // from any threads without worrying about thread safety. 15 // from any threads without worrying about thread safety.
16 // The |capture_message_loop_proxy_| is the working thread of VideoCaptureImpl. 16 // The |capture_message_loop_proxy_| is the working thread of VideoCaptureImpl.
17 // All non-const members are accessed only on that working thread. 17 // All non-const members are accessed only on that working thread.
18 18
19 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 19 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
20 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 20 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
21 21
22 #include <list> 22 #include <list>
23 #include <map> 23 #include <map>
24 24
25 #include "content/common/content_export.h" 25 #include "content/common/content_export.h"
26 #include "content/common/media/video_capture.h" 26 #include "content/common/media/video_capture.h"
27 #include "content/renderer/media/captured_encoded_video_source_impl.h"
27 #include "content/renderer/media/video_capture_message_filter.h" 28 #include "content/renderer/media/video_capture_message_filter.h"
28 #include "media/video/capture/video_capture.h" 29 #include "media/video/capture/video_capture.h"
29 #include "media/video/capture/video_capture_types.h" 30 #include "media/video/capture/video_capture_types.h"
31 #include "media/video/encoded_video_source.h"
30 32
31 namespace base { 33 namespace base {
32 class MessageLoopProxy; 34 class MessageLoopProxy;
33 } 35 }
34 36
35 namespace content { 37 namespace content {
36 38
37 class CONTENT_EXPORT VideoCaptureImpl 39 class CONTENT_EXPORT VideoCaptureImpl
38 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { 40 : public media::VideoCapture,
41 public VideoCaptureMessageFilter::Delegate,
42 public CapturedEncodedVideoSourceImpl {
39 public: 43 public:
40 // media::VideoCapture interface. 44 // media::VideoCapture interface.
41 virtual void StartCapture( 45 virtual void StartCapture(
42 media::VideoCapture::EventHandler* handler, 46 media::VideoCapture::EventHandler* handler,
43 const media::VideoCaptureCapability& capability) OVERRIDE; 47 const media::VideoCaptureCapability& capability) OVERRIDE;
44 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; 48 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE;
45 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE; 49 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE;
46 virtual bool CaptureStarted() OVERRIDE; 50 virtual bool CaptureStarted() OVERRIDE;
47 virtual int CaptureWidth() OVERRIDE; 51 virtual int CaptureWidth() OVERRIDE;
48 virtual int CaptureHeight() OVERRIDE; 52 virtual int CaptureHeight() OVERRIDE;
49 virtual int CaptureFrameRate() OVERRIDE; 53 virtual int CaptureFrameRate() OVERRIDE;
54 virtual media::EncodedVideoSource* GetEncodedVideoSource() OVERRIDE;
50 55
51 // VideoCaptureMessageFilter::Delegate interface. 56 // VideoCaptureMessageFilter::Delegate interface.
52 virtual void OnBufferCreated(base::SharedMemoryHandle handle, 57 virtual void OnBufferCreated(base::SharedMemoryHandle handle,
53 int length, int buffer_id) OVERRIDE; 58 int length, int buffer_id) OVERRIDE;
54 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE; 59 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE;
55 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; 60 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE;
56 virtual void OnDeviceInfoReceived( 61 virtual void OnDeviceInfoReceived(
57 const media::VideoCaptureParams& device_info) OVERRIDE; 62 const media::VideoCaptureParams& device_info) OVERRIDE;
58 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; 63 virtual void OnDelegateAdded(int32 device_id) OVERRIDE;
59 64
60 // Stop/resume delivering video frames to clients, based on flag |suspend|. 65 // Stop/resume delivering video frames to clients, based on flag |suspend|.
61 virtual void SuspendCapture(bool suspend); 66 virtual void SuspendCapture(bool suspend);
62 67
68 // EncodingVideoCaptureMessageFilter::Delegate interface.
69 virtual void OnCapabilityAvailable(
70 const media::VideoEncodingCapability& capability) OVERRIDE;
71 virtual void OnBitstreamCreated(
72 int stream_id,
73 const media::VideoEncodingParameters& params,
74 const std::map<int, base::SharedMemoryHandle>& handles) OVERRIDE;
75 virtual void OnBitstreamDestroyed(int stream_id) OVERRIDE;
76 virtual void OnBitstreamConfigChanged(
77 int stream_id,
78 const media::RuntimeVideoEncodingParameters& params) OVERRIDE;
79 virtual void OnBitstreamReady(
80 int stream_id,
81 int buffer_id,
82 size_t size,
83 const media::BufferEncodingMetadata& metadata) OVERRIDE;
84
85 protected:
86 // Services for CapturedEncodedVideoSourceImpl.
87 virtual int device_id() OVERRIDE;
88 virtual scoped_refptr<base::MessageLoopProxy> app_loop_proxy() OVERRIDE;
89 virtual scoped_refptr<base::MessageLoopProxy> io_loop_proxy() OVERRIDE;
90 virtual void Send(IPC::Message* message) OVERRIDE;
Ami GONE FROM CHROMIUM 2013/06/08 00:18:01 Keep order same as in interface definition.
hshi1 2013/06/10 19:12:31 Done.
91
63 private: 92 private:
64 friend class VideoCaptureImplManager; 93 friend class VideoCaptureImplManager;
65 friend class VideoCaptureImplTest; 94 friend class VideoCaptureImplTest;
66 friend class MockVideoCaptureImpl; 95 friend class MockVideoCaptureImpl;
67 96
68 struct DIBBuffer; 97 struct DIBBuffer;
69 typedef std::map<media::VideoCapture::EventHandler*, 98 typedef std::map<media::VideoCapture::EventHandler*,
70 media::VideoCaptureCapability> ClientInfo; 99 media::VideoCaptureCapability> ClientInfo;
71 100
72 VideoCaptureImpl(media::VideoCaptureSessionId id, 101 VideoCaptureImpl(media::VideoCaptureSessionId id,
(...skipping 18 matching lines...) Expand all
91 void DoSuspendCaptureOnCaptureThread(bool suspend); 120 void DoSuspendCaptureOnCaptureThread(bool suspend);
92 121
93 void Init(); 122 void Init();
94 void DeInit(base::Closure task); 123 void DeInit(base::Closure task);
95 void DoDeInitOnCaptureThread(base::Closure task); 124 void DoDeInitOnCaptureThread(base::Closure task);
96 void StopDevice(); 125 void StopDevice();
97 void RestartCapture(); 126 void RestartCapture();
98 void StartCaptureInternal(); 127 void StartCaptureInternal();
99 void AddDelegateOnIOThread(); 128 void AddDelegateOnIOThread();
100 void RemoveDelegateOnIOThread(base::Closure task); 129 void RemoveDelegateOnIOThread(base::Closure task);
101 virtual void Send(IPC::Message* message);
102 130
103 // Helpers. 131 // Helpers.
104 bool ClientHasDIB() const; 132 bool ClientHasDIB() const;
105 bool RemoveClient(media::VideoCapture::EventHandler* handler, 133 bool RemoveClient(media::VideoCapture::EventHandler* handler,
106 ClientInfo* clients); 134 ClientInfo* clients);
107 135
108 const scoped_refptr<VideoCaptureMessageFilter> message_filter_; 136 const scoped_refptr<VideoCaptureMessageFilter> message_filter_;
109 const scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_; 137 const scoped_refptr<base::MessageLoopProxy> capture_message_loop_proxy_;
110 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; 138 const scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_;
111 int device_id_; 139 int device_id_;
(...skipping 11 matching lines...) Expand all
123 151
124 // The parameter is being used in current capture session. A capture session 152 // The parameter is being used in current capture session. A capture session
125 // starts with StartCapture and ends with StopCapture. 153 // starts with StartCapture and ends with StopCapture.
126 media::VideoCaptureParams current_params_; 154 media::VideoCaptureParams current_params_;
127 155
128 // The information about the device sent from browser process side. 156 // The information about the device sent from browser process side.
129 media::VideoCaptureParams device_info_; 157 media::VideoCaptureParams device_info_;
130 bool device_info_available_; 158 bool device_info_available_;
131 159
132 bool suspended_; 160 bool suspended_;
161 bool encoding_supported_;
133 VideoCaptureState state_; 162 VideoCaptureState state_;
134 163
135 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 164 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
136 }; 165 };
137 166
138 } // namespace content 167 } // namespace content
139 168
140 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 169 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698