| 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_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ | 5 #ifndef MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ |
| 6 #define MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ | 6 #define MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/callback_forward.h" |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 10 #include "media/base/demuxer_stream.h" | 11 #include "media/base/demuxer_stream.h" |
| 11 #include "media/mojo/interfaces/demuxer_stream.mojom.h" | 12 #include "media/mojo/interfaces/demuxer_stream.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 class DemuxerStream; | 16 class DemuxerStream; |
| 16 | 17 |
| 17 // This class wraps a media::DemuxerStream and exposes it as a | 18 // This class wraps a media::DemuxerStream and exposes it as a |
| 18 // mojom::DemuxerStream for use as a proxy from remote applications. | 19 // mojom::DemuxerStream for use as a proxy from remote applications. |
| 19 class MojoDemuxerStreamImpl : public mojom::DemuxerStream { | 20 class MojoDemuxerStreamImpl : public mojom::DemuxerStream { |
| 20 public: | 21 public: |
| 21 // |stream| is the underlying DemuxerStream we are proxying for. | 22 // |stream| is the underlying DemuxerStream we are proxying for. |
| 22 // Note: |this| does not take ownership of |stream|. | 23 // Note: |this| does not take ownership of |stream|. |
| 23 MojoDemuxerStreamImpl(media::DemuxerStream* stream, | 24 MojoDemuxerStreamImpl(media::DemuxerStream* stream, |
| 24 mojo::InterfaceRequest<mojom::DemuxerStream> request); | 25 mojo::InterfaceRequest<mojom::DemuxerStream> request); |
| 25 ~MojoDemuxerStreamImpl() override; | 26 ~MojoDemuxerStreamImpl() override; |
| 26 | 27 |
| 27 // mojom::DemuxerStream implementation. | 28 // mojom::DemuxerStream implementation. |
| 28 // InitializeCallback and ReadCallback are defined in | 29 // InitializeCallback and ReadCallback are defined in |
| 29 // mojom::DemuxerStream. | 30 // mojom::DemuxerStream. |
| 30 void Initialize(const InitializeCallback& callback) override; | 31 void Initialize(const InitializeCallback& callback) override; |
| 31 void Read(const ReadCallback& callback) override; | 32 void Read(const ReadCallback& callback) override; |
| 32 void EnableBitstreamConverter() override; | 33 void EnableBitstreamConverter() override; |
| 33 | 34 |
| 34 // Sets an error handler that will be called if a connection error occurs on | 35 // Sets an error handler that will be called if a connection error occurs on |
| 35 // the bound message pipe. | 36 // the bound message pipe. |
| 36 void set_connection_error_handler(const mojo::Closure& error_handler) { | 37 void set_connection_error_handler(const base::Closure& error_handler) { |
| 37 binding_.set_connection_error_handler(error_handler); | 38 binding_.set_connection_error_handler(error_handler); |
| 38 } | 39 } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 void OnBufferReady(const ReadCallback& callback, | 42 void OnBufferReady(const ReadCallback& callback, |
| 42 media::DemuxerStream::Status status, | 43 media::DemuxerStream::Status status, |
| 43 const scoped_refptr<media::DecoderBuffer>& buffer); | 44 const scoped_refptr<media::DecoderBuffer>& buffer); |
| 44 | 45 |
| 45 mojo::Binding<mojom::DemuxerStream> binding_; | 46 mojo::Binding<mojom::DemuxerStream> binding_; |
| 46 | 47 |
| 47 // See constructor. We do not own |stream_|. | 48 // See constructor. We do not own |stream_|. |
| 48 media::DemuxerStream* stream_; | 49 media::DemuxerStream* stream_; |
| 49 | 50 |
| 50 // DataPipe for serializing the data section of DecoderBuffer into. | 51 // DataPipe for serializing the data section of DecoderBuffer into. |
| 51 mojo::ScopedDataPipeProducerHandle stream_pipe_; | 52 mojo::ScopedDataPipeProducerHandle stream_pipe_; |
| 52 | 53 |
| 53 base::WeakPtrFactory<MojoDemuxerStreamImpl> weak_factory_; | 54 base::WeakPtrFactory<MojoDemuxerStreamImpl> weak_factory_; |
| 54 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamImpl); | 55 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamImpl); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace media | 58 } // namespace media |
| 58 | 59 |
| 59 #endif // MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ | 60 #endif // MEDIA_MOJO_CLIENTS_MOJO_DEMUXER_STREAM_IMPL_H_ |
| OLD | NEW |