| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_ | |
| 6 #define MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "media/base/demuxer_stream_provider.h" | |
| 14 #include "media/mojo/services/mojo_demuxer_stream_adapter.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 // DemuxerStreamProvider shim for mojom::DemuxerStreams. | |
| 19 class DemuxerStreamProviderShim : public DemuxerStreamProvider { | |
| 20 public: | |
| 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 | |
| 23 // initialized. Calling any method before then is an error. | |
| 24 DemuxerStreamProviderShim(std::vector<mojom::DemuxerStreamPtr> streams, | |
| 25 const base::Closure& demuxer_ready_cb); | |
| 26 ~DemuxerStreamProviderShim() override; | |
| 27 | |
| 28 // DemuxerStreamProvider interface. | |
| 29 DemuxerStream* GetStream(DemuxerStream::Type type) override; | |
| 30 | |
| 31 private: | |
| 32 // Called as each mojom::DemuxerStream becomes ready. Once all streams | |
| 33 // are ready it will fire the |demuxer_ready_cb_| provided during | |
| 34 // construction. | |
| 35 void OnStreamReady(); | |
| 36 | |
| 37 // Stored copy the ready callback provided during construction; cleared once | |
| 38 // all streams are ready. | |
| 39 base::Closure demuxer_ready_cb_; | |
| 40 | |
| 41 // 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 // used by OnStreamReady() to know when |demuxer_ready_cb_| should be fired. | |
| 44 std::vector<std::unique_ptr<MojoDemuxerStreamAdapter>> streams_; | |
| 45 size_t streams_ready_; | |
| 46 | |
| 47 // WeakPtrFactorys must always be the last member variable. | |
| 48 base::WeakPtrFactory<DemuxerStreamProviderShim> weak_factory_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(DemuxerStreamProviderShim); | |
| 51 }; | |
| 52 | |
| 53 } // namespace media | |
| 54 | |
| 55 #endif // MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_ | |
| OLD | NEW |