blob: 78ac8388acf84613daab1fab20d2ac773fe96b84 [file] [log] [blame]
// Copyright 2016 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.
#include "base/single_thread_task_runner.h"
#include "base/unguessable_token.h"
#include "media/base/video_frame.h"
namespace media {
// StreamTextureWrapper encapsulates a StreamTexture's creation, initialization
// and registration for later retrieval (in the Browser process).
class MEDIA_EXPORT StreamTextureWrapper {
using StreamTextureWrapperInitCB = base::Callback<void(bool)>;
StreamTextureWrapper() {}
// Initialize the underlying StreamTexture.
// See StreamTextureWrapperImpl.
virtual void Initialize(
const base::Closure& received_frame_cb,
const gfx::Size& natural_size,
scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
const StreamTextureWrapperInitCB& init_cb) = 0;
// Called whenever the video's natural size changes.
// See StreamTextureWrapperImpl.
virtual void UpdateTextureSize(const gfx::Size& natural_size) = 0;
// Returns the latest frame.
// See StreamTextureWrapperImpl.
virtual scoped_refptr<VideoFrame> GetCurrentFrame() = 0;
// Sends the StreamTexture to the browser process, to fulfill the request
// identified by |request_token|.
// See StreamTextureWrapperImpl.
virtual void ForwardStreamTextureForSurfaceRequest(
const base::UnguessableToken& request_token) = 0;
// Clears the |received_frame_cb| passed in Initialize().
// Should be safe to call from any thread.
virtual void ClearReceivedFrameCBOnAnyThread() = 0;
struct Deleter {
inline void operator()(StreamTextureWrapper* ptr) const { ptr->Destroy(); }
virtual ~StreamTextureWrapper() {}
// Safely destroys the StreamTextureWrapper.
// See StreamTextureWrapperImpl.
virtual void Destroy() = 0;
typedef std::unique_ptr<StreamTextureWrapper, StreamTextureWrapper::Deleter>
} // namespace media