blob: 88c6a92631646ea0b13815e1c00f6fa5c381fa52 [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.
#ifndef SERVICES_VIDEO_CAPTURE_RECEIVER_MOJO_TO_MEDIA_ADAPTER_H_
#define SERVICES_VIDEO_CAPTURE_RECEIVER_MOJO_TO_MEDIA_ADAPTER_H_
#include "base/single_thread_task_runner.h"
#include "media/capture/video/video_frame_receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/video_capture/public/mojom/video_frame_handler.mojom.h"
namespace video_capture {
// Adapter that allows a mojom::VideoFrameReceiver to be used in place of
// a media::VideoFrameReceiver.
class ReceiverMojoToMediaAdapter : public media::VideoFrameReceiver {
public:
ReceiverMojoToMediaAdapter(mojo::Remote<mojom::VideoFrameHandler> handler);
~ReceiverMojoToMediaAdapter() override;
base::WeakPtr<media::VideoFrameReceiver> GetWeakPtr();
// media::VideoFrameReceiver implementation.
void OnNewBuffer(int buffer_id,
media::mojom::VideoBufferHandlePtr buffer_handle) override;
void OnFrameReadyInBuffer(
int buffer_id,
int frame_feedback_id,
std::unique_ptr<
media::VideoCaptureDevice::Client::Buffer::ScopedAccessPermission>
access_permission,
media::mojom::VideoFrameInfoPtr frame_info) override;
void OnBufferRetired(int buffer_id) override;
void OnError(media::VideoCaptureError error) override;
void OnFrameDropped(media::VideoCaptureFrameDropReason reason) override;
void OnLog(const std::string& message) override;
void OnStarted() override;
void OnStartedUsingGpuDecode() override;
void OnStopped() override;
private:
mojo::Remote<mojom::VideoFrameHandler> video_frame_handler_;
base::WeakPtrFactory<ReceiverMojoToMediaAdapter> weak_factory_{this};
};
} // namespace video_capture
#endif // SERVICES_VIDEO_CAPTURE_RECEIVER_MOJO_TO_MEDIA_ADAPTER_H_