OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "media/mojo/services/media_resource_shim.h" | 5 #include "media/mojo/services/media_resource_shim.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 for (auto& s : streams) { | 24 for (auto& s : streams) { |
25 streams_.emplace_back(new MojoDemuxerStreamAdapter( | 25 streams_.emplace_back(new MojoDemuxerStreamAdapter( |
26 std::move(s), base::Bind(&MediaResourceShim::OnStreamReady, | 26 std::move(s), base::Bind(&MediaResourceShim::OnStreamReady, |
27 weak_factory_.GetWeakPtr()))); | 27 weak_factory_.GetWeakPtr()))); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 MediaResourceShim::~MediaResourceShim() {} | 31 MediaResourceShim::~MediaResourceShim() {} |
32 | 32 |
33 // This function returns only the first stream of the given |type| for now. | 33 std::vector<DemuxerStream*> MediaResourceShim::GetStreams() { |
34 // TODO(servolk): Make this work with multiple streams. | |
35 DemuxerStream* MediaResourceShim::GetStream(DemuxerStream::Type type) { | |
36 DCHECK(demuxer_ready_cb_.is_null()); | 34 DCHECK(demuxer_ready_cb_.is_null()); |
37 for (auto& stream : streams_) { | 35 std::vector<DemuxerStream*> result; |
38 if (stream->type() == type) | 36 for (auto& stream : streams_) |
39 return stream.get(); | 37 result.push_back(stream.get()); |
40 } | 38 return result; |
| 39 } |
41 | 40 |
42 return nullptr; | 41 void MediaResourceShim::SetStreamStatusChangeCB( |
| 42 const StreamStatusChangeCB& cb) { |
| 43 NOTIMPLEMENTED(); |
43 } | 44 } |
44 | 45 |
45 void MediaResourceShim::OnStreamReady() { | 46 void MediaResourceShim::OnStreamReady() { |
46 if (++streams_ready_ == streams_.size()) | 47 if (++streams_ready_ == streams_.size()) |
47 base::ResetAndReturn(&demuxer_ready_cb_).Run(); | 48 base::ResetAndReturn(&demuxer_ready_cb_).Run(); |
48 } | 49 } |
49 | 50 |
50 } // namespace media | 51 } // namespace media |
OLD | NEW |