| 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/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "services/media/factory_service/media_source_impl.h" | 8 #include "services/media/factory_service/media_source_impl.h" |
| 9 #include "services/media/framework/util/callback_joiner.h" | 9 #include "services/media/framework/util/callback_joiner.h" |
| 10 #include "services/media/framework/util/conversion_pipeline_builder.h" | 10 #include "services/media/framework/util/conversion_pipeline_builder.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 : MediaFactoryService::Product<MediaSource>(this, request.Pass(), owner), | 34 : MediaFactoryService::Product<MediaSource>(this, request.Pass(), owner), |
| 35 allowed_media_types_(allowed_media_types.Clone()) { | 35 allowed_media_types_(allowed_media_types.Clone()) { |
| 36 DCHECK(reader); | 36 DCHECK(reader); |
| 37 | 37 |
| 38 task_runner_ = base::MessageLoop::current()->task_runner(); | 38 task_runner_ = base::MessageLoop::current()->task_runner(); |
| 39 DCHECK(task_runner_); | 39 DCHECK(task_runner_); |
| 40 | 40 |
| 41 status_publisher_.SetCallbackRunner( | 41 status_publisher_.SetCallbackRunner( |
| 42 [this](const GetStatusCallback& callback, uint64_t version) { | 42 [this](const GetStatusCallback& callback, uint64_t version) { |
| 43 MediaSourceStatusPtr status = MediaSourceStatus::New(); | 43 MediaSourceStatusPtr status = MediaSourceStatus::New(); |
| 44 status->state = state_; | |
| 45 status->metadata = | 44 status->metadata = |
| 46 demux_ ? MediaMetadata::From(demux_->metadata()) : nullptr; | 45 demux_ ? MediaMetadata::From(demux_->metadata()) : nullptr; |
| 47 callback.Run(version, status.Pass()); | 46 callback.Run(version, status.Pass()); |
| 48 }); | 47 }); |
| 49 | 48 |
| 50 std::shared_ptr<Reader> reader_ptr = MojoReader::Create(reader.Pass()); | 49 std::shared_ptr<Reader> reader_ptr = MojoReader::Create(reader.Pass()); |
| 51 if (!reader_ptr) { | 50 if (!reader_ptr) { |
| 52 NOTREACHED() << "couldn't create reader"; | 51 LOG(ERROR) << "couldn't create reader"; |
| 53 state_ = MediaState::FAULT; | 52 // TODO(dalesat): Add problem reporting. |
| 54 return; | 53 return; |
| 55 } | 54 } |
| 56 | 55 |
| 57 demux_ = Demux::Create(reader_ptr); | 56 demux_ = Demux::Create(reader_ptr); |
| 58 if (!demux_) { | 57 if (!demux_) { |
| 59 NOTREACHED() << "couldn't create demux"; | 58 LOG(ERROR) << "couldn't create demux"; |
| 60 state_ = MediaState::FAULT; | 59 // TODO(dalesat): Add problem reporting. |
| 61 return; | 60 return; |
| 62 } | 61 } |
| 63 | 62 |
| 64 demux_->WhenInitialized([this](Result result) { | 63 demux_->WhenInitialized([this](Result result) { |
| 65 task_runner_->PostTask(FROM_HERE, | 64 task_runner_->PostTask(FROM_HERE, |
| 66 base::Bind(&MediaSourceImpl::OnDemuxInitialized, | 65 base::Bind(&MediaSourceImpl::OnDemuxInitialized, |
| 67 base::Unretained(this), result)); | 66 base::Unretained(this), result)); |
| 68 }); | 67 }); |
| 69 } | 68 } |
| 70 | 69 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 status_publisher_.Get(version_last_seen, callback); | 130 status_publisher_.Get(version_last_seen, callback); |
| 132 } | 131 } |
| 133 | 132 |
| 134 void MediaSourceImpl::Prepare(const PrepareCallback& callback) { | 133 void MediaSourceImpl::Prepare(const PrepareCallback& callback) { |
| 135 RCHECK(init_complete_.occurred()); | 134 RCHECK(init_complete_.occurred()); |
| 136 | 135 |
| 137 for (std::unique_ptr<Stream>& stream : streams_) { | 136 for (std::unique_ptr<Stream>& stream : streams_) { |
| 138 stream->EnsureSink(); | 137 stream->EnsureSink(); |
| 139 } | 138 } |
| 140 graph_.Prepare(); | 139 graph_.Prepare(); |
| 141 state_ = MediaState::PAUSED; | |
| 142 callback.Run(); | 140 callback.Run(); |
| 143 status_publisher_.SendUpdates(); | 141 status_publisher_.SendUpdates(); |
| 144 } | 142 } |
| 145 | 143 |
| 146 void MediaSourceImpl::Prime(const PrimeCallback& callback) { | 144 void MediaSourceImpl::Prime(const PrimeCallback& callback) { |
| 147 RCHECK(init_complete_.occurred()); | 145 RCHECK(init_complete_.occurred()); |
| 148 | 146 |
| 149 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); | 147 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); |
| 150 | 148 |
| 151 for (std::unique_ptr<Stream>& stream : streams_) { | 149 for (std::unique_ptr<Stream>& stream : streams_) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 const MojoProducer::FlushConnectionCallback callback) { | 265 const MojoProducer::FlushConnectionCallback callback) { |
| 268 if (producer_ != nullptr) { | 266 if (producer_ != nullptr) { |
| 269 producer_->FlushConnection(callback); | 267 producer_->FlushConnection(callback); |
| 270 } else { | 268 } else { |
| 271 callback.Run(); | 269 callback.Run(); |
| 272 } | 270 } |
| 273 } | 271 } |
| 274 | 272 |
| 275 } // namespace media | 273 } // namespace media |
| 276 } // namespace mojo | 274 } // namespace mojo |
| OLD | NEW |