blob: acdddbdc3003cd458357939ed94a5e7336b133f4 [file] [log] [blame]
// 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.
#include <stdint.h>
#include <memory>
#include "base/macros.h"
#include "media/mojo/interfaces/mjpeg_decode_accelerator.mojom.h"
#include "media/video/mjpeg_decode_accelerator.h"
namespace base {
class SequencedTaskRunner;
namespace media {
// A MjpegDecodeAccelerator, for use in the browser process, that proxies to a
// mojom::MjpegDecodeAccelerator. Created on the owner's thread, otherwise
// operating and deleted on |io_task_runner|.
class MojoMjpegDecodeAccelerator : public MjpegDecodeAccelerator {
scoped_refptr<base::SequencedTaskRunner> io_task_runner,
mojom::MjpegDecodeAcceleratorPtrInfo jpeg_decoder);
~MojoMjpegDecodeAccelerator() override;
// MjpegDecodeAccelerator implementation.
// |client| is called on the IO thread, but is never called into after the
// MojoMjpegDecodeAccelerator is destroyed.
bool Initialize(Client* client) override;
void InitializeAsync(Client* client, InitCB init_cb) override;
void Decode(const BitstreamBuffer& bitstream_buffer,
const scoped_refptr<VideoFrame>& video_frame) override;
bool IsSupported() override;
void OnInitializeDone(InitCB init_cb,
MjpegDecodeAccelerator::Client* client,
bool success);
void OnDecodeAck(int32_t bitstream_buffer_id,
::media::MjpegDecodeAccelerator::Error error);
void OnLostConnectionToJpegDecoder();
scoped_refptr<base::SequencedTaskRunner> io_task_runner_;
Client* client_ = nullptr;
// Used to safely pass the mojom::MjpegDecodeAcceleratorPtr from one thread to
// another. It is set in the constructor and consumed in InitializeAsync().
// TODO(mcasas): s/jpeg_decoder_/jda_/
mojom::MjpegDecodeAcceleratorPtrInfo jpeg_decoder_info_;
mojom::MjpegDecodeAcceleratorPtr jpeg_decoder_;
} // namespace media