Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / mojo / services / mojo_demuxer_stream_impl.h
blob09021140c4437ad432260bcb898c319982b6cbd6
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/strong_binding.h"
14 namespace media {
15 class DemuxerStream;
17 // This class wraps a media::DemuxerStream and exposes it as a
18 // interfaces::DemuxerStream for use as a proxy from remote applications.
19 class MojoDemuxerStreamImpl : public interfaces::DemuxerStream {
20 public:
21 // |stream| is the underlying DemuxerStream we are proxying for.
22 // Note: |this| does not take ownership of |stream|.
23 MojoDemuxerStreamImpl(
24 media::DemuxerStream* stream,
25 mojo::InterfaceRequest<interfaces::DemuxerStream> request);
26 ~MojoDemuxerStreamImpl() override;
28 // interfaces::DemuxerStream implementation.
29 // InitializeCallback and ReadCallback are defined in
30 // interfaces::DemuxerStream.
31 void Initialize(const InitializeCallback& callback) override;
32 void Read(const ReadCallback& callback) override;
34 private:
35 void OnBufferReady(const ReadCallback& callback,
36 media::DemuxerStream::Status status,
37 const scoped_refptr<media::DecoderBuffer>& buffer);
39 mojo::StrongBinding<interfaces::DemuxerStream> binding_;
41 // See constructor. We do not own |stream_|.
42 media::DemuxerStream* stream_;
44 // DataPipe for serializing the data section of DecoderBuffer into.
45 mojo::ScopedDataPipeProducerHandle stream_pipe_;
47 base::WeakPtrFactory<MojoDemuxerStreamImpl> weak_factory_;
48 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamImpl);
51 } // namespace media
53 #endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_IMPL_H_