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

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

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 #ifndef MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_ 5 #ifndef MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_
6 #define MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_ 6 #define MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "media/base/media_resource.h" 13 #include "media/base/media_resource.h"
14 #include "media/mojo/services/mojo_demuxer_stream_adapter.h" 14 #include "media/mojo/services/mojo_demuxer_stream_adapter.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 // MediaResource shim for mojom::DemuxerStreams. 18 // MediaResource shim for mojom::DemuxerStreams.
19 class MediaResourceShim : public MediaResource { 19 class MediaResourceShim : public MediaResource {
20 public: 20 public:
21 // Constructs the shim; at least a single audio or video stream must be 21 // Constructs the shim; at least a single audio or video stream must be
22 // provided. |demuxer_ready_cb| will be called once the streams have been 22 // provided. |demuxer_ready_cb| will be called once the streams have been
23 // initialized. Calling any method before then is an error. 23 // initialized. Calling any method before then is an error.
24 MediaResourceShim(std::vector<mojom::DemuxerStreamPtr> streams, 24 MediaResourceShim(std::vector<mojom::DemuxerStreamPtr> streams,
25 const base::Closure& demuxer_ready_cb); 25 const base::Closure& demuxer_ready_cb);
26 ~MediaResourceShim() override; 26 ~MediaResourceShim() override;
27 27
28 // MediaResource interface. 28 // MediaResource interface.
29 DemuxerStream* GetStream(DemuxerStream::Type type) override; 29 std::vector<DemuxerStream*> GetStreams() override;
30 void SetStreamStatusChangeCB(const StreamStatusChangeCB& cb) override;
30 31
31 private: 32 private:
32 // Called as each mojom::DemuxerStream becomes ready. Once all streams 33 // Called as each mojom::DemuxerStream becomes ready. Once all streams
33 // are ready it will fire the |demuxer_ready_cb_| provided during 34 // are ready it will fire the |demuxer_ready_cb_| provided during
34 // construction. 35 // construction.
35 void OnStreamReady(); 36 void OnStreamReady();
36 37
37 // Stored copy the ready callback provided during construction; cleared once 38 // Stored copy the ready callback provided during construction; cleared once
38 // all streams are ready. 39 // all streams are ready.
39 base::Closure demuxer_ready_cb_; 40 base::Closure demuxer_ready_cb_;
40 41
41 // Container for demuxer stream adapters which interface with the mojo level 42 // Container for demuxer stream adapters which interface with the mojo level
42 // demuxer streams. |streams_ready_| tracks how many streams are ready and is 43 // demuxer streams. |streams_ready_| tracks how many streams are ready and is
43 // used by OnStreamReady() to know when |demuxer_ready_cb_| should be fired. 44 // used by OnStreamReady() to know when |demuxer_ready_cb_| should be fired.
44 std::vector<std::unique_ptr<MojoDemuxerStreamAdapter>> streams_; 45 std::vector<std::unique_ptr<MojoDemuxerStreamAdapter>> streams_;
45 size_t streams_ready_; 46 size_t streams_ready_;
46 47
47 // WeakPtrFactorys must always be the last member variable. 48 // WeakPtrFactorys must always be the last member variable.
48 base::WeakPtrFactory<MediaResourceShim> weak_factory_; 49 base::WeakPtrFactory<MediaResourceShim> weak_factory_;
49 50
50 DISALLOW_COPY_AND_ASSIGN(MediaResourceShim); 51 DISALLOW_COPY_AND_ASSIGN(MediaResourceShim);
51 }; 52 };
52 53
53 } // namespace media 54 } // namespace media
54 55
55 #endif // MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_ 56 #endif // MEDIA_MOJO_SERVICES_MEDIA_RESOURCE_SHIM_H_
OLDNEW
« no previous file with comments | « media/mojo/clients/mojo_renderer_unittest.cc ('k') | media/mojo/services/media_resource_shim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698