Index: content/browser/renderer_host/media/video_capture_device_client.h |
diff --git a/content/browser/renderer_host/media/video_capture_device_client.h b/content/browser/renderer_host/media/video_capture_device_client.h |
index 6d73f0c95ca0b4df47769ad904c5eb7cb06e74e6..7def9a0b55f3582e2e3086689d71c25ecae2bc7b 100644 |
--- a/content/browser/renderer_host/media/video_capture_device_client.h |
+++ b/content/browser/renderer_host/media/video_capture_device_client.h |
@@ -8,24 +8,61 @@ |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/synchronization/lock.h" |
#include "content/common/content_export.h" |
#include "media/video/capture/video_capture_device.h" |
+#include "media/video/jpeg_decode_accelerator.h" |
+ |
+namespace base { |
+class WaitableEvent; |
+} // namespace base |
namespace content { |
class VideoCaptureBufferPool; |
class VideoCaptureController; |
+struct CapturedData { |
wuchengli
2015/04/14 09:41:44
Can this be moved to video_capture_device_client.c
kcwu
2015/04/14 20:02:35
Done.
|
+ uint8* data; |
+ int length; |
+ media::VideoCaptureFormat frame_format; |
+ int rotation; |
+ base::TimeTicks timestamp; |
+}; |
+ |
+// TODO(kcwu): convert to class |
wuchengli
2015/04/14 09:41:44
Remove. Make it a class.
kcwu
2015/04/14 20:02:34
Done.
|
+struct JpegDecodeTask { |
wuchengli
2015/04/14 09:41:44
s/JpegDecodeTask/JpegDecodeData/ is better. A task
kcwu
2015/04/14 20:02:35
Done.
|
+ JpegDecodeTask(); |
+ |
+ base::Lock lock_; |
+ |
+ bool decoding; |
+ |
+ CapturedData captured_data; |
+ |
+ scoped_ptr<base::SharedMemory> in_shared_memory; |
wuchengli
2015/04/14 09:41:44
Need variable comments for JpegDecodeTask and Capt
kcwu
2015/04/16 14:38:27
Done.
|
+ // |in_buffer| is backed by |in_shared_memory|. |
+ scoped_ptr<media::BitstreamBuffer> in_buffer; |
+ |
+ scoped_refptr<media::VideoCaptureDevice::Client::Buffer> out_buffer; |
+ // |out_frame| is backed by |out_buffer|. |
+ scoped_refptr<media::VideoFrame> out_frame; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(JpegDecodeTask); |
+}; |
+ |
// Receives events from the VideoCaptureDevice and posts them to a |controller_| |
// on the IO thread. An instance of this class may safely outlive its target |
// VideoCaptureController. This is a shallow class meant to convert incoming |
// frames and holds no significant state. |
// |
-// Methods of this class may be called from any thread, and in practice will |
-// often be called on some auxiliary thread depending on the platform and the |
-// device type; including, for example, the DirectShow thread on Windows, the |
-// v4l2_thread on Linux, and the UI thread for tab capture. |
+// Methods of this class may be called from any thread if not specified, and in |
+// practice will often be called on some auxiliary thread depending on the |
+// platform and the device type; including, for example, the DirectShow thread |
+// on Windows, the v4l2_thread on Linux, and the UI thread for tab capture. |
class CONTENT_EXPORT VideoCaptureDeviceClient |
- : public media::VideoCaptureDevice::Client { |
+ : public media::VideoCaptureDevice::Client, |
+ public media::JpegDecodeAccelerator::Client { |
public: |
VideoCaptureDeviceClient( |
const base::WeakPtr<VideoCaptureController>& controller, |
@@ -33,6 +70,7 @@ class CONTENT_EXPORT VideoCaptureDeviceClient |
~VideoCaptureDeviceClient() override; |
// VideoCaptureDevice::Client implementation. |
+ bool InitializeJpegDecoder() override; |
void OnIncomingCapturedData( |
const uint8* data, |
int length, |
@@ -48,15 +86,32 @@ class CONTENT_EXPORT VideoCaptureDeviceClient |
void OnError(const std::string& reason) override; |
void OnLog(const std::string& message) override; |
+ // JpegDecodeAccelerator::Client implementation. |
+ // These will be called in IO thread. |
+ virtual void VideoFrameReady(int32_t buffer_id) override; |
+ virtual void NotifyError(int32_t buffer_id, |
+ media::JpegDecodeAccelerator::Error error) override; |
+ |
private: |
+ // TODO(kcwu): better name |
+ void OnIncomingCapturedData2(const CapturedData& captured_data); |
+ bool PrepareJpegDecode(const CapturedData& captured_data, |
+ const scoped_refptr<Buffer> out_buffer); |
+ |
// The controller to which we post events. |
const base::WeakPtr<VideoCaptureController> controller_; |
+ bool jpeg_failed_; |
wuchengli
2015/04/14 09:41:44
Remove this. Let's not do fallback now. If a platf
kcwu
2015/04/16 14:38:27
Removed. But still do fallback. Some kind of fallb
|
+ scoped_ptr<media::JpegDecodeAccelerator> jpeg_decoder_; |
+ JpegDecodeTask jpeg_decode_task_; |
wuchengli
2015/04/14 09:41:44
Put all jpeg variables together. Move these beside
kcwu
2015/04/14 20:02:34
Done.
|
+ |
// The pool of shared-memory buffers used for capturing. |
const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; |
media::VideoPixelFormat last_captured_pixel_format_; |
+ int32 next_bitstream_buffer_id_; |
wuchengli
2015/04/14 09:41:44
Better to have jpeg in the name. s/next_bitstream_
kcwu
2015/04/14 20:02:34
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceClient); |
}; |