| 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 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "services/media/framework_mojo/mojo_producer.h" | 9 #include "services/media/framework_mojo/mojo_producer.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 void MojoProducer::AddBinding(InterfaceRequest<MediaProducer> producer) { | 23 void MojoProducer::AddBinding(InterfaceRequest<MediaProducer> producer) { |
| 24 bindings_.AddBinding(this, producer.Pass()); | 24 bindings_.AddBinding(this, producer.Pass()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void MojoProducer::PrimeConnection(const PrimeConnectionCallback& callback) { | 27 void MojoProducer::PrimeConnection(const PrimeConnectionCallback& callback) { |
| 28 Demand demand; | 28 Demand demand; |
| 29 | 29 |
| 30 if (consumer_.is_bound()) { | 30 if (consumer_.is_bound()) { |
| 31 base::AutoLock lock(lock_); | 31 base::AutoLock lock(lock_); |
| 32 max_pushes_outstanding_ = 3; // TODO(dalesat): Made up! | 32 max_pushes_outstanding_ = 4; // TODO(dalesat): Made up! |
| 33 demand = current_pushes_outstanding_ < max_pushes_outstanding_ | 33 demand = current_pushes_outstanding_ < max_pushes_outstanding_ |
| 34 ? Demand::kPositive | 34 ? Demand::kPositive |
| 35 : Demand::kNegative; | 35 : Demand::kNegative; |
| 36 } else { | 36 } else { |
| 37 demand = Demand::kNeutral; | 37 demand = Demand::kNeutral; |
| 38 if (!mojo_allocator_.initialized()) { | 38 if (!mojo_allocator_.initialized()) { |
| 39 mojo_allocator_.InitNew(2048 * 1024); // TODO(dalesat): Made up! | 39 mojo_allocator_.InitNew(4096 * 1024); // TODO(dalesat): Made up! |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 DCHECK(demand_callback_); | 43 DCHECK(demand_callback_); |
| 44 demand_callback_(demand); | 44 demand_callback_(demand); |
| 45 | 45 |
| 46 if (consumer_.is_bound()) { | 46 if (consumer_.is_bound()) { |
| 47 consumer_->Prime([this, callback]() { callback.Run(); }); | 47 consumer_->Prime([this, callback]() { callback.Run(); }); |
| 48 } else { | 48 } else { |
| 49 callback.Run(); | 49 callback.Run(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return demand; | 109 return demand; |
| 110 } | 110 } |
| 111 | 111 |
| 112 void MojoProducer::Connect(InterfaceHandle<MediaConsumer> consumer, | 112 void MojoProducer::Connect(InterfaceHandle<MediaConsumer> consumer, |
| 113 const ConnectCallback& callback) { | 113 const ConnectCallback& callback) { |
| 114 DCHECK(consumer); | 114 DCHECK(consumer); |
| 115 | 115 |
| 116 consumer_ = MediaConsumerPtr::Create(std::move(consumer)); | 116 consumer_ = MediaConsumerPtr::Create(std::move(consumer)); |
| 117 | 117 |
| 118 if (!mojo_allocator_.initialized()) { | 118 if (!mojo_allocator_.initialized()) { |
| 119 mojo_allocator_.InitNew(2048 * 1024); // TODO(dalesat): Made up! | 119 mojo_allocator_.InitNew(4096 * 1024); // TODO(dalesat): Made up! |
| 120 } | 120 } |
| 121 | 121 |
| 122 consumer_->SetBuffer(mojo_allocator_.GetDuplicateHandle(), | 122 consumer_->SetBuffer(mojo_allocator_.GetDuplicateHandle(), |
| 123 [callback]() { callback.Run(); }); | 123 [callback]() { callback.Run(); }); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void MojoProducer::Disconnect() { | 126 void MojoProducer::Disconnect() { |
| 127 DCHECK(demand_callback_); | 127 DCHECK(demand_callback_); |
| 128 demand_callback_(Demand::kNegative); | 128 demand_callback_(Demand::kNegative); |
| 129 consumer_.reset(); | 129 consumer_.reset(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 MediaPacketPtr media_packet = MediaPacket::New(); | 161 MediaPacketPtr media_packet = MediaPacket::New(); |
| 162 media_packet->pts = packet->pts(); | 162 media_packet->pts = packet->pts(); |
| 163 media_packet->end_of_stream = packet->end_of_stream(); | 163 media_packet->end_of_stream = packet->end_of_stream(); |
| 164 media_packet->payload = region.Pass(); | 164 media_packet->payload = region.Pass(); |
| 165 | 165 |
| 166 return media_packet.Pass(); | 166 return media_packet.Pass(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace media | 169 } // namespace media |
| 170 } // namespace mojo | 170 } // namespace mojo |
| OLD | NEW |