Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Side by Side Diff: services/media/framework_mojo/mojo_consumer.h

Issue 2097953002: Motown: Rename MediaProducer/Consumer to MediaPacketProducer/Consumer (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fixed #ifndef guards Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/media/framework_mojo/BUILD.gn ('k') | services/media/framework_mojo/mojo_consumer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_
6 #define SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_
7
8 #include "base/single_thread_task_runner.h"
9 #include "base/task_runner.h"
10 #include "mojo/common/binding_set.h"
11 #include "mojo/services/media/common/cpp/mapped_shared_buffer.h"
12 #include "mojo/services/media/common/interfaces/media_transport.mojom.h"
13 #include "services/media/framework/models/active_source.h"
14
15 namespace mojo {
16 namespace media {
17
18 // Implements MediaConsumer::Flush on behalf of MediaConsumer to avoid name
19 // conflict with Part::Flush.
20 class MojoConsumerMediaConsumer : public MediaConsumer {
21 // MediaConsumer implementation.
22 void Flush(const FlushCallback& callback) override;
23
24 // Implements MediaConsumer::Flush.
25 virtual void MediaConsumerFlush(const FlushCallback& callback) = 0;
26 };
27
28 // Implements MediaConsumer to receive a stream from across mojo.
29 class MojoConsumer : public MojoConsumerMediaConsumer, public ActiveSource {
30 public:
31 using PrimeRequestedCallback = std::function<void(const PrimeCallback&)>;
32 using FlushRequestedCallback = std::function<void(const FlushCallback&)>;
33
34 static std::shared_ptr<MojoConsumer> Create() {
35 return std::shared_ptr<MojoConsumer>(new MojoConsumer());
36 }
37
38 ~MojoConsumer() override;
39
40 // Adds a binding.
41 void AddBinding(InterfaceRequest<MediaConsumer> consumer);
42
43 // Sets a callback signalling that a prime has been requested from the
44 // MediaConsumer client.
45 void SetPrimeRequestedCallback(const PrimeRequestedCallback& callback);
46
47 // Sets a callback signalling that a flush has been requested from the
48 // MediaConsumer client.
49 void SetFlushRequestedCallback(const FlushRequestedCallback& callback);
50
51 // MediaConsumer implementation.
52 void SetBuffer(ScopedSharedBufferHandle buffer,
53 const SetBufferCallback& callback) override;
54
55 void SendPacket(MediaPacketPtr packet,
56 const SendPacketCallback& callback) override;
57
58 void Prime(const PrimeCallback& callback) override;
59
60 void MediaConsumerFlush(const FlushCallback& callback) override;
61
62 // ActiveSource implementation.
63 bool can_accept_allocator() const override;
64
65 void set_allocator(PayloadAllocator* allocator) override;
66
67 void SetSupplyCallback(const SupplyCallback& supply_callback) override;
68
69 void SetDownstreamDemand(Demand demand) override;
70
71 private:
72 MojoConsumer();
73
74 // Specialized packet implementation.
75 class PacketImpl : public Packet {
76 public:
77 static PacketPtr Create(
78 MediaPacketPtr media_packet,
79 const SendPacketCallback& callback,
80 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
81 const MappedSharedBuffer& buffer) {
82 return PacketPtr(
83 new PacketImpl(media_packet.Pass(), callback, task_runner, buffer));
84 }
85
86 protected:
87 void Release() override;
88
89 private:
90 PacketImpl(MediaPacketPtr media_packet,
91 const SendPacketCallback& callback,
92 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
93 const MappedSharedBuffer& buffer);
94
95 ~PacketImpl() override;
96
97 static void RunCallback(const SendPacketCallback& callback);
98
99 MediaPacketPtr media_packet_;
100 const SendPacketCallback callback_;
101 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
102 };
103
104 BindingSet<MediaConsumer> bindings_;
105 PrimeRequestedCallback prime_requested_callback_;
106 FlushRequestedCallback flush_requested_callback_;
107 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
108 MappedSharedBuffer buffer_;
109 SupplyCallback supply_callback_;
110 };
111
112 } // namespace media
113 } // namespace mojo
114
115 #endif // SERVICES_MEDIA_FRAMEWORK_MOJO_MOJO_CONSUMER_H_
OLDNEW
« no previous file with comments | « services/media/framework_mojo/BUILD.gn ('k') | services/media/framework_mojo/mojo_consumer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698