Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / mojo / services / demuxer_stream_provider_shim.h
blob9fdab66f90018324429eca3c7ff32e821e673425
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.
5 #ifndef MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_
6 #define MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/memory/weak_ptr.h"
11 #include "media/base/demuxer_stream_provider.h"
12 #include "media/mojo/services/mojo_demuxer_stream_adapter.h"
14 namespace media {
16 // DemuxerStreamProvider shim for interfaces::DemuxerStreams.
17 class DemuxerStreamProviderShim : public DemuxerStreamProvider {
18 public:
19 // Constructs the shim; at least a single audio or video stream must be
20 // provided. |demuxer_ready_cb| will be called once the streams have been
21 // initialized. Calling any method before then is an error.
22 DemuxerStreamProviderShim(interfaces::DemuxerStreamPtr audio,
23 interfaces::DemuxerStreamPtr video,
24 const base::Closure& demuxer_ready_cb);
25 ~DemuxerStreamProviderShim() override;
27 // DemuxerStreamProvider interface.
28 DemuxerStream* GetStream(DemuxerStream::Type type) override;
30 private:
31 // Called as each interfaces::DemuxerStream becomes ready. Once all streams
32 // are ready it will fire the |demuxer_ready_cb_| provided during
33 // construction.
34 void OnStreamReady();
36 // Stored copy the ready callback provided during construction; cleared once
37 // all streams are ready.
38 base::Closure demuxer_ready_cb_;
40 // Scoped container for demuxer stream adapters which interface with the
41 // mojo level demuxer streams. |streams_ready_| tracks how many streams are
42 // ready and is used by OnStreamReady() to know when |demuxer_ready_cb_|
43 // should be fired.
44 ScopedVector<MojoDemuxerStreamAdapter> streams_;
45 size_t streams_ready_;
47 // WeakPtrFactorys must always be the last member variable.
48 base::WeakPtrFactory<DemuxerStreamProviderShim> weak_factory_;
50 DISALLOW_COPY_AND_ASSIGN(DemuxerStreamProviderShim);
53 } // namespace media
55 #endif // MEDIA_MOJO_SERVICES_DEMUXER_STREAM_PROVIDER_SHIM_H_