Chromium Code Reviews| 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_demux_impl.h" | 8 #include "services/media/factory_service/media_demux_impl.h" |
| 9 #include "services/media/framework/callback_joiner.h" | 9 #include "services/media/framework/callback_joiner.h" |
| 10 #include "services/media/framework/parts/reader_cache.h" | 10 #include "services/media/framework/parts/reader_cache.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 base::Bind(&MediaDemuxImpl::OnDemuxInitialized, | 64 base::Bind(&MediaDemuxImpl::OnDemuxInitialized, |
| 65 base::Unretained(this), result)); | 65 base::Unretained(this), result)); |
| 66 }); | 66 }); |
| 67 } | 67 } |
| 68 | 68 |
| 69 MediaDemuxImpl::~MediaDemuxImpl() {} | 69 MediaDemuxImpl::~MediaDemuxImpl() {} |
| 70 | 70 |
| 71 void MediaDemuxImpl::OnDemuxInitialized(Result result) { | 71 void MediaDemuxImpl::OnDemuxInitialized(Result result) { |
| 72 demux_part_ = graph_.Add(demux_); | 72 demux_part_ = graph_.Add(demux_); |
| 73 | 73 |
| 74 auto demux_streams = demux_->streams(); | 74 const std::vector<Demux::DemuxStream*>& demux_streams = demux_->streams(); |
|
kulakowski
2016/04/19 19:18:22
I'm curious why the move away from auto/auto&/auto
dalesat
2016/04/19 19:47:03
I like auto a lot, but previous reviewers have not
kulakowski
2016/04/20 17:42:37
Makes sense.
I would prefer to use it where it is
| |
| 75 for (auto demux_stream : demux_streams) { | 75 for (Demux::DemuxStream* demux_stream : demux_streams) { |
| 76 streams_.push_back(std::unique_ptr<Stream>( | 76 streams_.push_back(std::unique_ptr<Stream>( |
| 77 new Stream(demux_part_.output(demux_stream->index()), | 77 new Stream(demux_part_.output(demux_stream->index()), |
| 78 demux_stream->stream_type(), &graph_))); | 78 demux_stream->stream_type(), &graph_))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 graph_.Prepare(); | 81 graph_.Prepare(); |
| 82 | 82 |
| 83 metadata_publisher_.SendUpdates(); | 83 metadata_publisher_.SendUpdates(); |
| 84 | 84 |
| 85 init_complete_.Occur(); | 85 init_complete_.Occur(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void MediaDemuxImpl::Describe(const DescribeCallback& callback) { | 88 void MediaDemuxImpl::Describe(const DescribeCallback& callback) { |
| 89 init_complete_.When([this, callback]() { | 89 init_complete_.When([this, callback]() { |
| 90 auto result = Array<MediaTypePtr>::New(streams_.size()); | 90 Array<MediaTypePtr> result = Array<MediaTypePtr>::New(streams_.size()); |
| 91 for (size_t i = 0; i < streams_.size(); i++) { | 91 for (size_t i = 0; i < streams_.size(); i++) { |
| 92 MediaSourceStreamDescriptorPtr descriptor = | 92 MediaSourceStreamDescriptorPtr descriptor = |
| 93 MediaSourceStreamDescriptor::New(); | 93 MediaSourceStreamDescriptor::New(); |
| 94 result[i] = streams_[i]->media_type(); | 94 result[i] = streams_[i]->media_type(); |
| 95 } | 95 } |
| 96 | |
| 96 callback.Run(result.Pass()); | 97 callback.Run(result.Pass()); |
| 97 }); | 98 }); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void MediaDemuxImpl::GetProducer(uint32_t stream_index, | 101 void MediaDemuxImpl::GetProducer(uint32_t stream_index, |
| 101 InterfaceRequest<MediaProducer> producer) { | 102 InterfaceRequest<MediaProducer> producer) { |
| 102 DCHECK(init_complete_.occurred()); | 103 DCHECK(init_complete_.occurred()); |
| 103 | 104 |
| 104 if (stream_index >= streams_.size()) { | 105 if (stream_index >= streams_.size()) { |
| 105 return; | 106 return; |
| 106 } | 107 } |
| 107 | 108 |
| 108 streams_[stream_index]->GetProducer(producer.Pass()); | 109 streams_[stream_index]->GetProducer(producer.Pass()); |
| 109 } | 110 } |
| 110 | 111 |
| 111 void MediaDemuxImpl::GetMetadata(uint64_t version_last_seen, | 112 void MediaDemuxImpl::GetMetadata(uint64_t version_last_seen, |
| 112 const GetMetadataCallback& callback) { | 113 const GetMetadataCallback& callback) { |
| 113 metadata_publisher_.Get(version_last_seen, callback); | 114 metadata_publisher_.Get(version_last_seen, callback); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void MediaDemuxImpl::Prime(const PrimeCallback& callback) { | 117 void MediaDemuxImpl::Prime(const PrimeCallback& callback) { |
| 117 DCHECK(init_complete_.occurred()); | 118 DCHECK(init_complete_.occurred()); |
| 118 | 119 |
| 119 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); | 120 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); |
| 120 | 121 |
| 121 for (auto& stream : streams_) { | 122 for (std::unique_ptr<Stream>& stream : streams_) { |
| 122 stream->PrimeConnection(callback_joiner->NewCallback()); | 123 stream->PrimeConnection(callback_joiner->NewCallback()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 callback_joiner->WhenJoined(callback); | 126 callback_joiner->WhenJoined(callback); |
| 126 } | 127 } |
| 127 | 128 |
| 128 void MediaDemuxImpl::Flush(const FlushCallback& callback) { | 129 void MediaDemuxImpl::Flush(const FlushCallback& callback) { |
| 129 DCHECK(init_complete_.occurred()); | 130 DCHECK(init_complete_.occurred()); |
| 130 | 131 |
| 131 graph_.FlushAllOutputs(demux_part_); | 132 graph_.FlushAllOutputs(demux_part_); |
| 132 | 133 |
| 133 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); | 134 std::shared_ptr<CallbackJoiner> callback_joiner = CallbackJoiner::Create(); |
| 134 | 135 |
| 135 for (auto& stream : streams_) { | 136 for (std::unique_ptr<Stream>& stream : streams_) { |
| 136 stream->FlushConnection(callback_joiner->NewCallback()); | 137 stream->FlushConnection(callback_joiner->NewCallback()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 callback_joiner->WhenJoined(callback); | 140 callback_joiner->WhenJoined(callback); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void MediaDemuxImpl::Seek(int64_t position, const SeekCallback& callback) { | 143 void MediaDemuxImpl::Seek(int64_t position, const SeekCallback& callback) { |
| 143 DCHECK(init_complete_.occurred()); | 144 DCHECK(init_complete_.occurred()); |
| 144 | 145 |
| 145 demux_->Seek(position, [this, callback]() { | 146 demux_->Seek(position, [this, callback]() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 } | 183 } |
| 183 | 184 |
| 184 void MediaDemuxImpl::Stream::FlushConnection( | 185 void MediaDemuxImpl::Stream::FlushConnection( |
| 185 const MojoProducer::FlushConnectionCallback callback) { | 186 const MojoProducer::FlushConnectionCallback callback) { |
| 186 DCHECK(producer_); | 187 DCHECK(producer_); |
| 187 producer_->FlushConnection(callback); | 188 producer_->FlushConnection(callback); |
| 188 } | 189 } |
| 189 | 190 |
| 190 } // namespace media | 191 } // namespace media |
| 191 } // namespace mojo | 192 } // namespace mojo |
| OLD | NEW |