| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_PACKET_CONSUMER_H_ |
| 6 #define SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_PACKET_CONSUMER_H_ |
| 7 | 7 |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/task_runner.h" | 9 #include "base/task_runner.h" |
| 10 #include "mojo/common/binding_set.h" | 10 #include "mojo/common/binding_set.h" |
| 11 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h" | 11 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h" |
| 12 #include "mojo/services/media/common/interfaces/media_transport.mojom.h" | 12 #include "mojo/services/media/common/interfaces/media_transport.mojom.h" |
| 13 #include "services/media/framework/models/active_source.h" | 13 #include "services/media/framework/models/active_source.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 // Implements MediaConsumer::Flush on behalf of MediaConsumer to avoid name | 18 // Implements MediaPacketConsumer::Flush on behalf of MediaPacketConsumer to |
| 19 // avoid name |
| 19 // conflict with Part::Flush. | 20 // conflict with Part::Flush. |
| 20 class MojoConsumerMediaConsumer : public MediaConsumer { | 21 class MojoPacketConsumerMediaPacketConsumer : public MediaPacketConsumer { |
| 21 // MediaConsumer implementation. | 22 // MediaPacketConsumer implementation. |
| 22 void Flush(const FlushCallback& callback) override; | 23 void Flush(const FlushCallback& callback) override; |
| 23 | 24 |
| 24 // Implements MediaConsumer::Flush. | 25 // Implements MediaPacketConsumer::Flush. |
| 25 virtual void MediaConsumerFlush(const FlushCallback& callback) = 0; | 26 virtual void MediaPacketConsumerFlush(const FlushCallback& callback) = 0; |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 // Implements MediaConsumer to receive a stream from across mojo. | 29 // Implements MediaPacketConsumer to receive a stream from across mojo. |
| 29 class MojoConsumer : public MojoConsumerMediaConsumer, public ActiveSource { | 30 class MojoPacketConsumer : public MojoPacketConsumerMediaPacketConsumer, |
| 31 public ActiveSource { |
| 30 public: | 32 public: |
| 31 using PrimeRequestedCallback = std::function<void(const PrimeCallback&)>; | 33 using PrimeRequestedCallback = std::function<void(const PrimeCallback&)>; |
| 32 using FlushRequestedCallback = std::function<void(const FlushCallback&)>; | 34 using FlushRequestedCallback = std::function<void(const FlushCallback&)>; |
| 33 | 35 |
| 34 static std::shared_ptr<MojoConsumer> Create() { | 36 static std::shared_ptr<MojoPacketConsumer> Create() { |
| 35 return std::shared_ptr<MojoConsumer>(new MojoConsumer()); | 37 return std::shared_ptr<MojoPacketConsumer>(new MojoPacketConsumer()); |
| 36 } | 38 } |
| 37 | 39 |
| 38 ~MojoConsumer() override; | 40 ~MojoPacketConsumer() override; |
| 39 | 41 |
| 40 // Adds a binding. | 42 // Adds a binding. |
| 41 void AddBinding(InterfaceRequest<MediaConsumer> consumer); | 43 void AddBinding(InterfaceRequest<MediaPacketConsumer> consumer); |
| 42 | 44 |
| 43 // Sets a callback signalling that a prime has been requested from the | 45 // Sets a callback signalling that a prime has been requested from the |
| 44 // MediaConsumer client. | 46 // MediaPacketConsumer client. |
| 45 void SetPrimeRequestedCallback(const PrimeRequestedCallback& callback); | 47 void SetPrimeRequestedCallback(const PrimeRequestedCallback& callback); |
| 46 | 48 |
| 47 // Sets a callback signalling that a flush has been requested from the | 49 // Sets a callback signalling that a flush has been requested from the |
| 48 // MediaConsumer client. | 50 // MediaPacketConsumer client. |
| 49 void SetFlushRequestedCallback(const FlushRequestedCallback& callback); | 51 void SetFlushRequestedCallback(const FlushRequestedCallback& callback); |
| 50 | 52 |
| 51 // MediaConsumer implementation. | 53 // MediaPacketConsumer implementation. |
| 52 void SetBuffer(ScopedSharedBufferHandle buffer, | 54 void SetBuffer(ScopedSharedBufferHandle buffer, |
| 53 const SetBufferCallback& callback) override; | 55 const SetBufferCallback& callback) override; |
| 54 | 56 |
| 55 void SendPacket(MediaPacketPtr packet, | 57 void SendPacket(MediaPacketPtr packet, |
| 56 const SendPacketCallback& callback) override; | 58 const SendPacketCallback& callback) override; |
| 57 | 59 |
| 58 void Prime(const PrimeCallback& callback) override; | 60 void Prime(const PrimeCallback& callback) override; |
| 59 | 61 |
| 60 void MediaConsumerFlush(const FlushCallback& callback) override; | 62 void MediaPacketConsumerFlush(const FlushCallback& callback) override; |
| 61 | 63 |
| 62 // ActiveSource implementation. | 64 // ActiveSource implementation. |
| 63 bool can_accept_allocator() const override; | 65 bool can_accept_allocator() const override; |
| 64 | 66 |
| 65 void set_allocator(PayloadAllocator* allocator) override; | 67 void set_allocator(PayloadAllocator* allocator) override; |
| 66 | 68 |
| 67 void SetSupplyCallback(const SupplyCallback& supply_callback) override; | 69 void SetSupplyCallback(const SupplyCallback& supply_callback) override; |
| 68 | 70 |
| 69 void SetDownstreamDemand(Demand demand) override; | 71 void SetDownstreamDemand(Demand demand) override; |
| 70 | 72 |
| 71 private: | 73 private: |
| 72 MojoConsumer(); | 74 MojoPacketConsumer(); |
| 73 | 75 |
| 74 // Specialized packet implementation. | 76 // Specialized packet implementation. |
| 75 class PacketImpl : public Packet { | 77 class PacketImpl : public Packet { |
| 76 public: | 78 public: |
| 77 static PacketPtr Create( | 79 static PacketPtr Create( |
| 78 MediaPacketPtr media_packet, | 80 MediaPacketPtr media_packet, |
| 79 const SendPacketCallback& callback, | 81 const SendPacketCallback& callback, |
| 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 82 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 81 const MappedSharedBuffer& buffer) { | 83 const MappedSharedBuffer& buffer) { |
| 82 return PacketPtr( | 84 return PacketPtr( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 | 96 |
| 95 ~PacketImpl() override; | 97 ~PacketImpl() override; |
| 96 | 98 |
| 97 static void RunCallback(const SendPacketCallback& callback); | 99 static void RunCallback(const SendPacketCallback& callback); |
| 98 | 100 |
| 99 MediaPacketPtr media_packet_; | 101 MediaPacketPtr media_packet_; |
| 100 const SendPacketCallback callback_; | 102 const SendPacketCallback callback_; |
| 101 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 103 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 BindingSet<MediaConsumer> bindings_; | 106 BindingSet<MediaPacketConsumer> bindings_; |
| 105 PrimeRequestedCallback prime_requested_callback_; | 107 PrimeRequestedCallback prime_requested_callback_; |
| 106 FlushRequestedCallback flush_requested_callback_; | 108 FlushRequestedCallback flush_requested_callback_; |
| 107 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 109 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 108 MappedSharedBuffer buffer_; | 110 MappedSharedBuffer buffer_; |
| 109 SupplyCallback supply_callback_; | 111 SupplyCallback supply_callback_; |
| 110 }; | 112 }; |
| 111 | 113 |
| 112 } // namespace media | 114 } // namespace media |
| 113 } // namespace mojo | 115 } // namespace mojo |
| 114 | 116 |
| 115 #endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_ | 117 #endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_PACKET_CONSUMER_H_ |
| OLD | NEW |