| 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
|
| index bedf7fb6c35b705f3e1967be0841f25610aa7521..dd424117bdfd158151923a38414ebf685f7610a8 100644
|
| --- a/content/common/gpu/client/gpu_video_encode_accelerator_host.h
|
| +++ b/content/common/gpu/client/gpu_video_encode_accelerator_host.h
|
| @@ -10,6 +10,8 @@
|
| #include "base/containers/hash_tables.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/threading/non_thread_safe.h"
|
| +#include "content/common/gpu/client/command_buffer_proxy_impl.h"
|
| #include "ipc/ipc_listener.h"
|
| #include "media/video/video_encode_accelerator.h"
|
|
|
| @@ -34,14 +36,13 @@ class GpuChannelHost;
|
| class GpuVideoEncodeAcceleratorHost
|
| : public IPC::Listener,
|
| public media::VideoEncodeAccelerator,
|
| - public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> {
|
| + public CommandBufferProxyImpl::DeletionObserver,
|
| + public base::NonThreadSafe {
|
| public:
|
| - // Since the GpuChannelHost does _not_ own this object, a reference to
|
| - // |gpu_channel_host| is taken.
|
| - GpuVideoEncodeAcceleratorHost(
|
| - const scoped_refptr<GpuChannelHost>& gpu_channel_host,
|
| - int32 route_id);
|
| - virtual ~GpuVideoEncodeAcceleratorHost();
|
| + // Both |channel| and |impl| are guaranteed to outlive |this|. (See comments
|
| + // for |channel_| and |impl_|.)
|
| + GpuVideoEncodeAcceleratorHost(GpuChannelHost* channel,
|
| + CommandBufferProxyImpl* impl);
|
|
|
| // Static query for the supported profiles. This query proxies to
|
| // GpuVideoEncodeAccelerator::GetSupportedProfiles().
|
| @@ -52,7 +53,7 @@ class GpuVideoEncodeAcceleratorHost
|
| virtual void OnChannelError() OVERRIDE;
|
|
|
| // media::VideoEncodeAccelerator implementation.
|
| - virtual void Initialize(media::VideoFrame::Format format,
|
| + virtual bool Initialize(media::VideoFrame::Format input_format,
|
| const gfx::Size& input_visible_size,
|
| media::VideoCodecProfile output_profile,
|
| uint32 initial_bitrate,
|
| @@ -65,14 +66,20 @@ class GpuVideoEncodeAcceleratorHost
|
| uint32 framerate_num) OVERRIDE;
|
| virtual void Destroy() OVERRIDE;
|
|
|
| + // CommandBufferProxyImpl::DeletionObserver implemetnation.
|
| + virtual void OnWillDeleteImpl() OVERRIDE;
|
| +
|
| private:
|
| - // Notify |client_| when an error has occured. Used when notifying from
|
| - // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy.
|
| - void NotifyError(Error error);
|
| + // Only Destroy() should be deleting |this|.
|
| + virtual ~GpuVideoEncodeAcceleratorHost();
|
| +
|
| + // Notify |client_| of an error. Posts a task to avoid re-entrancy.
|
| + void PostNotifyError(Error);
|
| +
|
| + void Send(IPC::Message* message);
|
|
|
| // IPC handlers, proxying media::VideoEncodeAccelerator::Client for the GPU
|
| - // process.
|
| - void OnNotifyInitializeDone();
|
| + // process. Should not be called directly.
|
| void OnRequireBitstreamBuffers(uint32 input_count,
|
| const gfx::Size& input_coded_size,
|
| uint32 output_buffer_size);
|
| @@ -82,18 +89,19 @@ class GpuVideoEncodeAcceleratorHost
|
| bool key_frame);
|
| void OnNotifyError(Error error);
|
|
|
| - void Send(IPC::Message* message);
|
| + // Unowned reference to the GpuChannelHost to send IPC messages to the GPU
|
| + // process. |channel_| outlives |impl_|, so |channel_| also outlives |this|.
|
| + GpuChannelHost* channel_;
|
|
|
| - // Pointer for client callbacks on the media::VideoEncodeAccelerator::Client
|
| - // interface.
|
| + // Route ID for the associated encoder in the GPU process.
|
| + int32 encoder_route_id_;
|
| +
|
| + // The client that will receive callbacks from the encoder.
|
| Client* client_;
|
| - // |client_ptr_factory_| is used for callbacks that need to be done through
|
| - // a PostTask() to avoid re-entrancy on the client.
|
| - scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
|
|
|
| - // IPC channel and route ID.
|
| - scoped_refptr<GpuChannelHost> channel_;
|
| - const int32 route_id_;
|
| + // Unowned reference to the CommandBufferProxyImpl that created us. |this|
|
| + // registers as a DeletionObserver of |impl_|, so |impl_| outlives |this|.
|
| + CommandBufferProxyImpl* impl_;
|
|
|
| // media::VideoFrames sent to the encoder.
|
| // base::IDMap not used here, since that takes pointers, not scoped_refptr.
|
| @@ -103,6 +111,9 @@ class GpuVideoEncodeAcceleratorHost
|
| // ID serial number for the next frame to send to the GPU process.
|
| int32 next_frame_id_;
|
|
|
| + // weak_ptr factory for posting tasks back to itself.
|
| + base::WeakPtrFactory<GpuVideoEncodeAcceleratorHost> weak_this_factory_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost);
|
| };
|
|
|
|
|