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