| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "media/capture/video/video_capture_device.h" | 21 #include "device/capture/video/video_capture_device.h" |
| 22 #include "media/video/jpeg_decode_accelerator.h" | 22 #include "media/video/jpeg_decode_accelerator.h" |
| 23 | 23 |
| 24 namespace gpu { | 24 namespace gpu { |
| 25 class GpuChannelHost; | 25 class GpuChannelHost; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace media { | 28 namespace media { |
| 29 class VideoFrame; | 29 class VideoFrame; |
| 30 } | 30 } |
| 31 | 31 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 // Enumeration of decoder status. The enumeration is published for clients to | 46 // Enumeration of decoder status. The enumeration is published for clients to |
| 47 // decide the behavior according to STATUS. | 47 // decide the behavior according to STATUS. |
| 48 enum STATUS { | 48 enum STATUS { |
| 49 INIT_PENDING, // Default value while waiting initialization finished. | 49 INIT_PENDING, // Default value while waiting initialization finished. |
| 50 INIT_PASSED, // Initialization succeed. | 50 INIT_PASSED, // Initialization succeed. |
| 51 FAILED, // JPEG decode is not supported, initialization failed, or | 51 FAILED, // JPEG decode is not supported, initialization failed, or |
| 52 // decode error. | 52 // decode error. |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 typedef base::Callback<void( | 55 typedef base::Callback<void( |
| 56 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer>, | 56 std::unique_ptr<device::VideoCaptureDevice::Client::Buffer>, |
| 57 const scoped_refptr<media::VideoFrame>&)> | 57 const scoped_refptr<media::VideoFrame>&)> |
| 58 DecodeDoneCB; | 58 DecodeDoneCB; |
| 59 | 59 |
| 60 // |decode_done_cb| is called on the IO thread when decode succeed. This can | 60 // |decode_done_cb| is called on the IO thread when decode succeed. This can |
| 61 // be on any thread. |decode_done_cb| is never called after | 61 // be on any thread. |decode_done_cb| is never called after |
| 62 // VideoCaptureGpuJpegDecoder is destroyed. | 62 // VideoCaptureGpuJpegDecoder is destroyed. |
| 63 explicit VideoCaptureGpuJpegDecoder(const DecodeDoneCB& decode_done_cb); | 63 explicit VideoCaptureGpuJpegDecoder(const DecodeDoneCB& decode_done_cb); |
| 64 ~VideoCaptureGpuJpegDecoder() override; | 64 ~VideoCaptureGpuJpegDecoder() override; |
| 65 | 65 |
| 66 // Creates and intializes decoder asynchronously. | 66 // Creates and intializes decoder asynchronously. |
| 67 void Initialize(); | 67 void Initialize(); |
| 68 | 68 |
| 69 // Returns initialization status. | 69 // Returns initialization status. |
| 70 STATUS GetStatus() const; | 70 STATUS GetStatus() const; |
| 71 | 71 |
| 72 // Decodes a JPEG picture. | 72 // Decodes a JPEG picture. |
| 73 void DecodeCapturedData( | 73 void DecodeCapturedData( |
| 74 const uint8_t* data, | 74 const uint8_t* data, |
| 75 size_t in_buffer_size, | 75 size_t in_buffer_size, |
| 76 const media::VideoCaptureFormat& frame_format, | 76 const media::VideoCaptureFormat& frame_format, |
| 77 base::TimeTicks reference_time, | 77 base::TimeTicks reference_time, |
| 78 base::TimeDelta timestamp, | 78 base::TimeDelta timestamp, |
| 79 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> out_buffer); | 79 std::unique_ptr<device::VideoCaptureDevice::Client::Buffer> out_buffer); |
| 80 | 80 |
| 81 // JpegDecodeAccelerator::Client implementation. | 81 // JpegDecodeAccelerator::Client implementation. |
| 82 // These will be called on IO thread. | 82 // These will be called on IO thread. |
| 83 void VideoFrameReady(int32_t buffer_id) override; | 83 void VideoFrameReady(int32_t buffer_id) override; |
| 84 void NotifyError(int32_t buffer_id, | 84 void NotifyError(int32_t buffer_id, |
| 85 media::JpegDecodeAccelerator::Error error) override; | 85 media::JpegDecodeAccelerator::Error error) override; |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 // Initialization helper, to establish GPU channel. | 88 // Initialization helper, to establish GPU channel. |
| 89 static void EstablishGpuChannelOnUIThread( | 89 static void EstablishGpuChannelOnUIThread( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 std::unique_ptr<base::SharedMemory> in_shared_memory_; | 128 std::unique_ptr<base::SharedMemory> in_shared_memory_; |
| 129 | 129 |
| 130 STATUS decoder_status_; | 130 STATUS decoder_status_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); | 132 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 } // namespace content | 135 } // namespace content |
| 136 | 136 |
| 137 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 137 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
| OLD | NEW |