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

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: Updated due to sheu@. 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/video_capture_message_filter.h" 27 #include "content/renderer/media/video_capture_message_filter.h"
28 #include "media/video/capture/video_capture.h" 28 #include "media/video/capture/video_capture.h"
29 #include "media/video/capture/video_capture_types.h" 29 #include "media/video/capture/video_capture_types.h"
30 #include "media/video/encoded_video_source.h"
30 31
31 namespace base { 32 namespace base {
32 class MessageLoopProxy; 33 class MessageLoopProxy;
33 } 34 }
34 35
35 namespace content { 36 namespace content {
36 37
37 class CONTENT_EXPORT VideoCaptureImpl 38 class CONTENT_EXPORT VideoCaptureImpl
38 : public media::VideoCapture, public VideoCaptureMessageFilter::Delegate { 39 : public media::VideoCapture,
40 public VideoCaptureMessageFilter::Delegate,
41 public media::EncodedVideoSource {
39 public: 42 public:
40 // media::VideoCapture interface. 43 // media::VideoCapture interface.
41 virtual void StartCapture( 44 virtual void StartCapture(
42 media::VideoCapture::EventHandler* handler, 45 media::VideoCapture::EventHandler* handler,
43 const media::VideoCaptureCapability& capability) OVERRIDE; 46 const media::VideoCaptureCapability& capability) OVERRIDE;
44 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE; 47 virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE;
45 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE; 48 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) OVERRIDE;
46 virtual bool CaptureStarted() OVERRIDE; 49 virtual bool CaptureStarted() OVERRIDE;
47 virtual int CaptureWidth() OVERRIDE; 50 virtual int CaptureWidth() OVERRIDE;
48 virtual int CaptureHeight() OVERRIDE; 51 virtual int CaptureHeight() OVERRIDE;
49 virtual int CaptureFrameRate() OVERRIDE; 52 virtual int CaptureFrameRate() OVERRIDE;
50 53
51 // VideoCaptureMessageFilter::Delegate interface. 54 // VideoCaptureMessageFilter::Delegate interface.
52 virtual void OnBufferCreated(base::SharedMemoryHandle handle, 55 virtual void OnBufferCreated(base::SharedMemoryHandle handle,
53 int length, int buffer_id) OVERRIDE; 56 int length, int buffer_id) OVERRIDE;
54 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE; 57 virtual void OnBufferReceived(int buffer_id, base::Time timestamp) OVERRIDE;
55 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE; 58 virtual void OnStateChanged(VideoCaptureState state) OVERRIDE;
56 virtual void OnDeviceInfoReceived( 59 virtual void OnDeviceInfoReceived(
57 const media::VideoCaptureParams& device_info) OVERRIDE; 60 const media::VideoCaptureParams& device_info) OVERRIDE;
58 virtual void OnDelegateAdded(int32 device_id) OVERRIDE; 61 virtual void OnDelegateAdded(int32 device_id) OVERRIDE;
62 virtual void OnEncodingCapabilitiesAvailable(
63 const media::VideoEncodingCapabilities& capabilities) OVERRIDE;
64 virtual void OnEncodedBitstreamOpened(
65 const media::VideoEncodingParameters& params,
66 const std::vector<base::SharedMemoryHandle>& buffers,
67 int buffer_size) OVERRIDE;
68 virtual void OnEncodedBitstreamClosed() OVERRIDE;
69 virtual void OnEncodingConfigChanged(
70 const media::RuntimeVideoEncodingParameters& params) OVERRIDE;
71 virtual void OnEncodedBufferReady(
72 int buffer_id,
73 int size,
74 const media::BufferEncodingMetadata& metadata) OVERRIDE;
75
76 // media::EncodedVideoSource interface.
77 virtual void RequestCapabilities(
78 const RequestCapabilitiesCallback& callback) OVERRIDE;
79 virtual void OpenBitstream(
80 media::EncodedVideoSource::Client* client,
81 const media::VideoEncodingParameters& params) OVERRIDE;
82 virtual void CloseBitstream() OVERRIDE;
83 virtual void ReturnBitstreamBuffer(
84 scoped_refptr<const media::EncodedBitstreamBuffer> buffer) OVERRIDE;
85 virtual void TrySetBitstreamConfig(
86 const media::RuntimeVideoEncodingParameters& params) OVERRIDE;
59 87
60 // Stop/resume delivering video frames to clients, based on flag |suspend|. 88 // Stop/resume delivering video frames to clients, based on flag |suspend|.
61 virtual void SuspendCapture(bool suspend); 89 virtual void SuspendCapture(bool suspend);
62 90
63 private: 91 private:
64 friend class VideoCaptureImplManager; 92 friend class VideoCaptureImplManager;
65 friend class VideoCaptureImplTest; 93 friend class VideoCaptureImplTest;
66 friend class MockVideoCaptureImpl; 94 friend class MockVideoCaptureImpl;
67 95
68 struct DIBBuffer; 96 struct DIBBuffer;
(...skipping 14 matching lines...) Expand all
83 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle, 111 void DoBufferCreatedOnCaptureThread(base::SharedMemoryHandle handle,
84 int length, int buffer_id); 112 int length, int buffer_id);
85 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp); 113 void DoBufferReceivedOnCaptureThread(int buffer_id, base::Time timestamp);
86 void DoStateChangedOnCaptureThread(VideoCaptureState state); 114 void DoStateChangedOnCaptureThread(VideoCaptureState state);
87 void DoDeviceInfoReceivedOnCaptureThread( 115 void DoDeviceInfoReceivedOnCaptureThread(
88 const media::VideoCaptureParams& device_info); 116 const media::VideoCaptureParams& device_info);
89 void DoDelegateAddedOnCaptureThread(int32 device_id); 117 void DoDelegateAddedOnCaptureThread(int32 device_id);
90 118
91 void DoSuspendCaptureOnCaptureThread(bool suspend); 119 void DoSuspendCaptureOnCaptureThread(bool suspend);
92 120
121 void StartFetchCapabilities();
122 void DoNotifyBitstreamOpenedOnCaptureThread(
123 const media::VideoEncodingParameters& params,
124 const std::vector<base::SharedMemoryHandle>& buffers,
125 int buffer_size);
126 void DoNotifyBitstreamClosedOnCaptureThread();
127 void DoNotifyBitstreamConfigChangedOnCaptureThread(
128 const media::RuntimeVideoEncodingParameters& params);
129 void DoNotifyBitstreamBufferReadyOnCaptureThread(
130 int buffer_id, int size,
131 const media::BufferEncodingMetadata& metadata);
132 void DoNotifyCapabilitiesAvailableOnCaptureThread(
133 const media::VideoEncodingCapabilities& capabilities);
134
93 void Init(); 135 void Init();
94 void DeInit(base::Closure task); 136 void DeInit(base::Closure task);
95 void DoDeInitOnCaptureThread(base::Closure task); 137 void DoDeInitOnCaptureThread(base::Closure task);
96 void StopDevice(); 138 void StopDevice();
97 void RestartCapture(); 139 void RestartCapture();
98 void StartCaptureInternal(); 140 void StartCaptureInternal();
99 void AddDelegateOnIOThread(); 141 void AddDelegateOnIOThread();
100 void RemoveDelegateOnIOThread(base::Closure task); 142 void RemoveDelegateOnIOThread(base::Closure task);
101 virtual void Send(IPC::Message* message); 143 virtual void Send(IPC::Message* message);
102 144
(...skipping 22 matching lines...) Expand all
125 // starts with StartCapture and ends with StopCapture. 167 // starts with StartCapture and ends with StopCapture.
126 media::VideoCaptureParams current_params_; 168 media::VideoCaptureParams current_params_;
127 169
128 // The information about the device sent from browser process side. 170 // The information about the device sent from browser process side.
129 media::VideoCaptureParams device_info_; 171 media::VideoCaptureParams device_info_;
130 bool device_info_available_; 172 bool device_info_available_;
131 173
132 bool suspended_; 174 bool suspended_;
133 VideoCaptureState state_; 175 VideoCaptureState state_;
134 176
177 // Video encoding capabilities as reported by the device.
178 media::VideoEncodingCapabilities capabilities_;
179 // Callback for RequestCapabilities().
180 RequestCapabilitiesCallback callback_;
181 // Pointer to the EVS client.
182 media::EncodedVideoSource::Client* client_;
183 // Bitstream buffers returned by the video capture device. Unowned.
184 std::vector<base::SharedMemory*> bitstream_buffers_;
185
135 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 186 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
136 }; 187 };
137 188
138 } // namespace content 189 } // namespace content
139 190
140 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 191 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698