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

Unified Diff: content/common/gpu/media/gpu_jpeg_decode_accelerator.h

Issue 1016773002: MJPEG acceleration for video capture using VAAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: support multiple jpeg decoder Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/gpu_jpeg_decode_accelerator.h
diff --git a/content/common/gpu/media/gpu_jpeg_decode_accelerator.h b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..9f67af2329dc0a7f57d77d903005bebeb6a529fd
--- /dev/null
+++ b/content/common/gpu/media/gpu_jpeg_decode_accelerator.h
@@ -0,0 +1,105 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
+#define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
+
+#include "base/compiler_specific.h"
wuchengli 2015/04/24 05:54:25 I forgot. Is this used?
kcwu 2015/04/30 19:25:42 Done.
+#include "base/memory/ref_counted.h"
+#include "base/memory/shared_memory.h"
wuchengli 2015/04/24 05:54:25 not used?
kcwu 2015/04/30 19:25:42 Done.
+#include "base/synchronization/waitable_event.h"
+#include "ipc/ipc_listener.h"
+#include "ipc/ipc_sender.h"
+#include "media/video/jpeg_decode_accelerator.h"
+
+struct AcceleratedJpegDecoderMsg_Decode_Params;
wuchengli 2015/04/24 05:54:25 This is not in content namespace?
kcwu 2015/04/30 19:25:42 GPU msg structs are in global namespace.
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace content {
+class GpuChannel;
+
+class GpuJpegDecodeAccelerator : public IPC::Listener,
+ public IPC::Sender,
+ public media::JpegDecodeAccelerator::Client {
+ public:
+ // |channel| must outlive this object.
+ GpuJpegDecodeAccelerator(
+ GpuChannel* channel,
+ int32 host_route_id,
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
+
+ void Destroy();
+
+ // IPC::Listener implementation.
+ bool OnMessageReceived(const IPC::Message& message) override;
+
+ // media::JpegDecodeAccelerator::Client implementation.
+ void VideoFrameReady(int32_t bitstream_buffer_id) override;
+ void NotifyError(int32_t bitstream_buffer_id,
+ media::JpegDecodeAccelerator::Error error) override;
+
+ // Function to delegate sending to actual sender.
+ bool Send(IPC::Message* message) override;
+
+ bool Initialize();
wuchengli 2015/04/24 05:54:25 Add function comments. Put this together with Dest
kcwu 2015/04/30 19:25:42 Done.
+
+ private:
+ ~GpuJpegDecodeAccelerator();
+ class MessageFilter;
+
+ // Handlers for IPC messages.
+ void OnDecode(const AcceleratedJpegDecoderMsg_Decode_Params& params);
+ void OnDestroy();
+
+ // Called on IO thread when |filter_| has been removed.
+ void OnFilterRemoved();
+
+ // The lifetime of objects of this class is managed by a GpuChannel. The
+ // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when
+ // they are destroyed. So a raw pointer is safe.
+ GpuChannel* channel_;
+
+ // Route ID to communicate with the host.
+ int32 host_route_id_;
+
+ // The underlying JpegDecodeAccelerator.
+ scoped_ptr<media::JpegDecodeAccelerator> jpeg_decode_accelerator_;
+
+ // The message filter to run JDA::Decode on IO thread.
+ scoped_refptr<MessageFilter> filter_;
+
+ // Used to wait on for |filter_| to be removed, before we can safely
+ // destroy the JDA.
+ base::WaitableEvent filter_removed_;
+
+ // GPU child message loop.
+ scoped_refptr<base::MessageLoopProxy> child_message_loop_;
+
+ // GPU IO message loop.
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator);
+};
+
+} // namespace content
+
+namespace base {
+
+template <class T>
+struct DefaultDeleter;
+
+// Specialize DefaultDeleter so that scoped_ptr<GpuJpegDecodeAccelerator> always
+// uses "Destroy()" instead of trying to use the destructor.
+template <>
+struct MEDIA_EXPORT DefaultDeleter<content::GpuJpegDecodeAccelerator> {
+ public:
+ void operator()(void* jpeg_decode_accelerator) const;
+};
+
+} // namespace base
+
+#endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_

Powered by Google App Engine
This is Rietveld 408576698