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

Unified Diff: content/common/gpu/client/gpu_video_encode_accelerator_host.h

Issue 20632002: Add media::VideoEncodeAccelerator with WebRTC integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: b4cd612a Comments, added framerate to RequestEncodingParametersChange Created 7 years, 4 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/client/gpu_video_encode_accelerator_host.h
diff --git a/content/common/gpu/client/gpu_video_encode_accelerator_host.h b/content/common/gpu/client/gpu_video_encode_accelerator_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..b2e54b953ef66d0d969edb3e501ceaed884367cd
--- /dev/null
+++ b/content/common/gpu/client/gpu_video_encode_accelerator_host.h
@@ -0,0 +1,104 @@
+// Copyright (c) 2013 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_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
+#define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
+
+#include <vector>
+
+#include "base/containers/hash_tables.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "ipc/ipc_listener.h"
+#include "media/video/video_encode_accelerator.h"
+
+namespace gfx {
+
+class Size;
+
+} // namespace gfx
+
+namespace media {
+
+class VideoFrame;
+
+} // namespace media
+
+namespace content {
+
+class GpuChannelHost;
+
+// This class is the renderer-side host for the VideoEncodeAccelerator in the
+// GPU process, coordinated over IPC.
+class GpuVideoEncodeAcceleratorHost
+ : public IPC::Listener,
+ public media::VideoEncodeAccelerator,
+ public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> {
+ public:
+ // |client| is assumed to outlive this object. Since the GpuChannelHost does
+ // _not_ own this object, a reference to |gpu_channel_host| is taken.
+ GpuVideoEncodeAcceleratorHost(
+ media::VideoEncodeAccelerator::Client* client,
+ const scoped_refptr<GpuChannelHost>& gpu_channel_host,
+ int32 route_id);
+ virtual ~GpuVideoEncodeAcceleratorHost();
+
+ // Static query for the supported profiles. This query proxies to
+ // GpuVideoEncodeAccelerator::GetSupportedProfiles().
+ static std::vector<SupportedProfile> GetSupportedProfiles();
+
+ // IPC::Listener implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void OnChannelError() OVERRIDE;
+
+ // media::VideoEncodeAccelerator implementation.
+ virtual void Initialize(media::VideoFrame::Format format,
+ const gfx::Size& input_visible_size,
+ media::VideoCodecProfile output_profile,
+ int32 initial_bitrate) OVERRIDE;
+ virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
+ bool force_keyframe) OVERRIDE;
+ virtual void UseOutputBitstreamBuffer(
+ const media::BitstreamBuffer& buffer) OVERRIDE;
+ virtual void RequestEncodingParametersChange(int32 bitrate,
+ uint32 framerate_num,
+ uint32 framerate_denom) OVERRIDE;
+ virtual void Destroy() OVERRIDE;
+
+ private:
+ // IPC handlers, proxying media::VideoEncodeAccelerator::Client for the GPU
+ // process.
+ void OnNotifyInitializeDone();
+ void OnRequireBitstreamBuffers(int input_count,
+ const gfx::Size& input_coded_size,
+ uint32 output_buffer_size);
+ void OnNotifyInputDone(int32 frame_id);
+ void OnBitstreamBufferReady(int32 bitstream_buffer_id,
+ uint32 payload_size,
+ bool key_frame);
+ void OnNotifyError(Error error);
+
+ void Send(IPC::Message* message);
+
+ // Unowned pointer to the client.
+ media::VideoEncodeAccelerator::Client* client_;
+
+ // IPC channel and route ID.
+ scoped_refptr<GpuChannelHost> channel_;
+ const int32 route_id_;
+
+ // media::VideoFrames sent to the encoder.
+ // base::IDMap not used here, since that takes pointers, not scoped_refptr.
+ typedef base::hash_map<int32, scoped_refptr<media::VideoFrame> > FrameMap;
+ FrameMap frame_map_;
+
+ // ID serial number for the next frame to send to the GPU process.
+ int32 next_frame_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698