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

Side by Side Diff: media/mojo/services/media_resource_shim.cc

Issue 2667283002: Refactor MediaResource to be multi-stream capable (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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
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
OLDNEW
« no previous file with comments | « media/mojo/services/media_resource_shim.h ('k') | media/mojo/services/mojo_demuxer_stream_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698