1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_IMPL_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_IMPL_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "media/base/demuxer_stream.h"
11 #include "media/mojo/interfaces/demuxer_stream.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h"
17 // This class wraps a media::DemuxerStream and exposes it as a
18 // mojo::DemuxerStream for use as a proxy from remote applications.
19 class MojoDemuxerStreamImpl
: public mojo::InterfaceImpl
<mojo::DemuxerStream
> {
21 // |stream| is the underlying DemuxerStream we are proxying for.
22 // Note: |this| does not take ownership of |stream|.
23 explicit MojoDemuxerStreamImpl(media::DemuxerStream
* stream
);
24 ~MojoDemuxerStreamImpl() override
;
26 // mojo::DemuxerStream implementation.
27 void Read(const mojo::Callback
<void(mojo::DemuxerStream::Status
,
28 mojo::MediaDecoderBufferPtr
)>& callback
)
34 // |callback| is the callback that was passed to the initiating Read()
35 // call by our client.
36 // |status| and |buffer| are the standard media::ReadCB parameters.
37 typedef mojo::Callback
<void(mojo::DemuxerStream::Status
,
38 mojo::MediaDecoderBufferPtr
)> BufferReadyCB
;
39 void OnBufferReady(const BufferReadyCB
& callback
,
40 media::DemuxerStream::Status status
,
41 const scoped_refptr
<media::DecoderBuffer
>& buffer
);
43 // See constructor. We do not own |stream_|.
44 media::DemuxerStream
* stream_
;
46 // DataPipe for serializing the data section of DecoderBuffer into.
47 mojo::ScopedDataPipeProducerHandle stream_pipe_
;
49 base::WeakPtrFactory
<MojoDemuxerStreamImpl
> weak_factory_
;
50 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamImpl
);
55 #endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_IMPL_H_