| 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/sequence_checker.h" | 18 #include "base/sequence_checker.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/threading/thread.h" | 20 #include "base/threading/thread.h" |
| 21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
| 22 #include "media/capture/video/video_capture_jpeg_decoder.h" | 22 #include "media/capture/video/video_capture_jpeg_decoder.h" |
| 23 #include "media/video/jpeg_decode_accelerator.h" | 23 #include "media/video/jpeg_decode_accelerator.h" |
| 24 | 24 |
| 25 namespace gpu { | |
| 26 class GpuChannelHost; | |
| 27 } | |
| 28 | |
| 29 namespace content { | 25 namespace content { |
| 30 | 26 |
| 31 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes | 27 // Adapter to GpuJpegDecodeAccelerator for VideoCaptureDevice::Client. It takes |
| 32 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading | 28 // care of GpuJpegDecodeAccelerator creation, shared memory, and threading |
| 33 // issues. | 29 // issues. |
| 34 // | 30 // |
| 35 // All public methods except JpegDecodeAccelerator::Client ones should be called | 31 // All public methods except JpegDecodeAccelerator::Client ones should be called |
| 36 // on the same thread. JpegDecodeAccelerator::Client methods should be called on | 32 // on the same thread. JpegDecodeAccelerator::Client methods should be called on |
| 37 // the IO thread. | 33 // the IO thread. |
| 38 class CONTENT_EXPORT VideoCaptureGpuJpegDecoder | 34 class CONTENT_EXPORT VideoCaptureGpuJpegDecoder |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 base::TimeDelta timestamp, | 55 base::TimeDelta timestamp, |
| 60 media::VideoCaptureDevice::Client::Buffer out_buffer) override; | 56 media::VideoCaptureDevice::Client::Buffer out_buffer) override; |
| 61 | 57 |
| 62 // JpegDecodeAccelerator::Client implementation. | 58 // JpegDecodeAccelerator::Client implementation. |
| 63 // These will be called on IO thread. | 59 // These will be called on IO thread. |
| 64 void VideoFrameReady(int32_t buffer_id) override; | 60 void VideoFrameReady(int32_t buffer_id) override; |
| 65 void NotifyError(int32_t buffer_id, | 61 void NotifyError(int32_t buffer_id, |
| 66 media::JpegDecodeAccelerator::Error error) override; | 62 media::JpegDecodeAccelerator::Error error) override; |
| 67 | 63 |
| 68 private: | 64 private: |
| 69 // Initialization helper, to establish GPU channel. | |
| 70 static void EstablishGpuChannelOnUIThread( | |
| 71 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
| 72 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this); | |
| 73 | |
| 74 static void GpuChannelEstablishedOnUIThread( | |
| 75 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
| 76 base::WeakPtr<VideoCaptureGpuJpegDecoder> weak_this, | |
| 77 scoped_refptr<gpu::GpuChannelHost> established_channel_host); | |
| 78 | |
| 79 void FinishInitialization( | |
| 80 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host); | |
| 81 | |
| 82 // Returns true if the decoding of last frame is not finished yet. | 65 // Returns true if the decoding of last frame is not finished yet. |
| 83 bool IsDecoding_Locked() const; | 66 bool IsDecoding_Locked() const; |
| 84 | 67 |
| 85 // Records |decoder_status_| to histogram. | 68 // Records |decoder_status_| to histogram. |
| 86 void RecordInitDecodeUMA_Locked(); | 69 void RecordInitDecodeUMA_Locked(); |
| 87 | 70 |
| 88 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host_; | |
| 89 | |
| 90 // The underlying JPEG decode accelerator. | 71 // The underlying JPEG decode accelerator. |
| 91 std::unique_ptr<media::JpegDecodeAccelerator> decoder_; | 72 std::unique_ptr<media::JpegDecodeAccelerator> decoder_; |
| 92 | 73 |
| 93 // The callback to run when decode succeeds. | 74 // The callback to run when decode succeeds. |
| 94 const DecodeDoneCB decode_done_cb_; | 75 const DecodeDoneCB decode_done_cb_; |
| 95 | 76 |
| 96 const base::Callback<void(const std::string&)> send_log_message_cb_; | 77 const base::Callback<void(const std::string&)> send_log_message_cb_; |
| 97 bool has_received_decoded_frame_; | 78 bool has_received_decoded_frame_; |
| 98 | 79 |
| 99 // Guards |decode_done_closure_| and |decoder_status_|. | 80 // Guards |decode_done_closure_| and |decoder_status_|. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 115 STATUS decoder_status_; | 96 STATUS decoder_status_; |
| 116 | 97 |
| 117 SEQUENCE_CHECKER(sequence_checker_); | 98 SEQUENCE_CHECKER(sequence_checker_); |
| 118 | 99 |
| 119 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); | 100 DISALLOW_COPY_AND_ASSIGN(VideoCaptureGpuJpegDecoder); |
| 120 }; | 101 }; |
| 121 | 102 |
| 122 } // namespace content | 103 } // namespace content |
| 123 | 104 |
| 124 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ | 105 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_GPU_JPEG_DECODER_H_ |
| OLD | NEW |