| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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. |
| 4 |
| 5 #ifndef MEDIA_MOJO_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_ |
| 6 #define MEDIA_MOJO_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/callback_forward.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "media/base/data_source.h" |
| 14 #include "media/mojo/interfaces/data_source.mojom.h" |
| 15 #include "mojo/public/cpp/bindings/binding.h" |
| 16 |
| 17 namespace media { |
| 18 |
| 19 class DataSource; |
| 20 class MojoDataBufferWriter; |
| 21 |
| 22 // This class wraps a media::DataSource and exposes it as a |
| 23 // mojom::DataSource for use as a proxy from remote applications. |
| 24 class MojoDataSourceImpl : public mojom::DataSource { |
| 25 public: |
| 26 // |data_source| is the underlying DataSource we are proxying for. |
| 27 // Note: |this| does not take ownership of |data_source|. |
| 28 MojoDataSourceImpl(media::DataSource* data_source, |
| 29 mojo::InterfaceRequest<mojom::DataSource> request); |
| 30 ~MojoDataSourceImpl() override; |
| 31 |
| 32 // mojom::DataSource implementation. |
| 33 void Initialize(const InitializeCallback& callback) final; |
| 34 void Read(int64_t position, int size, const ReadCallback& callback) final; |
| 35 void Stop() final; |
| 36 void Abort() final; |
| 37 void GetSize(const GetSizeCallback& callback) final; |
| 38 void IsStreaming(const IsStreamingCallback& callback) final; |
| 39 void SetBitrate(int bitrate) final; |
| 40 |
| 41 // Sets an error handler that will be called if a connection error occurs on |
| 42 // the bound message pipe. |
| 43 void set_connection_error_handler(const base::Closure& error_handler) { |
| 44 binding_.set_connection_error_handler(error_handler); |
| 45 } |
| 46 |
| 47 private: |
| 48 void OnRead(const ReadCallback& callback, |
| 49 std::unique_ptr<uint8_t[]> data, |
| 50 int size); |
| 51 |
| 52 mojo::Binding<mojom::DataSource> binding_; |
| 53 |
| 54 // See constructor. We do not own |stream_|. |
| 55 media::DataSource* data_source_; |
| 56 |
| 57 std::unique_ptr<MojoDataBufferWriter> mojo_data_buffer_writer_; |
| 58 |
| 59 base::WeakPtrFactory<MojoDataSourceImpl> weak_factory_; |
| 60 DISALLOW_COPY_AND_ASSIGN(MojoDataSourceImpl); |
| 61 }; |
| 62 |
| 63 } // namespace media |
| 64 |
| 65 #endif // MEDIA_MOJO_CLIENTS_MOJO_DATA_SOURCE_IMPL_H_ |
| OLD | NEW |