Index: media/mojo/services/mojo_demuxer_stream_adapter.h |
diff --git a/media/mojo/services/mojo_demuxer_stream_adapter.h b/media/mojo/services/mojo_demuxer_stream_adapter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..acfc1ede538ef969326f5e5556e9f2133f7ab9a7 |
--- /dev/null |
+++ b/media/mojo/services/mojo_demuxer_stream_adapter.h |
@@ -0,0 +1,76 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |
+#define MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |
+ |
+#include <queue> |
+ |
+#include "base/memory/weak_ptr.h" |
+#include "media/base/audio_decoder_config.h" |
+#include "media/base/demuxer_stream.h" |
+#include "media/base/video_decoder_config.h" |
+#include "media/mojo/interfaces/demuxer_stream.mojom.h" |
+ |
+namespace media { |
+ |
+// This class acts as a MojoRendererService-side stub for a real |
+// media::DemuxerStream that is part of a media::Pipeline in a remote |
+// application. Roughly speaking, it takes a mojo::DemuxerStreamPtr and exposes |
+// it as a media::DemuxerStream for use by media components. |
+class MojoDemuxerStreamAdapter : public media::DemuxerStream, |
+ public mojo::DemuxerStreamClient { |
+ public: |
+ // |stream| is connected to the mojo::DemuxerStream that |this| will become |
+ // the client of. |
+ // |stream_ready| will be invoked when |stream| has fully initialized |
+ // and |this| is ready for use. |
+ // NOTE: It is illegal to call any methods until |stream_ready| is invoked. |
+ MojoDemuxerStreamAdapter(mojo::DemuxerStreamPtr stream, |
xhwang
2014/09/10 00:00:52
nit: s/stream/demuxer_stream
tim (not reviewing)
2014/09/10 23:08:29
Done.
|
+ const base::Closure& stream_ready); |
xhwang
2014/09/10 00:00:52
nit: s/stream_ready/stream_ready_cb/
tim (not reviewing)
2014/09/10 23:08:29
Done.
|
+ virtual ~MojoDemuxerStreamAdapter(); |
+ |
+ // media::DemuxerStream implementation |
scherkus (not reviewing)
2014/09/09 20:35:32
comments end w/ periods
tim (not reviewing)
2014/09/10 23:08:29
Done.
|
+ virtual void Read(const ReadCB& read_cb) OVERRIDE; |
+ virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; |
+ virtual VideoDecoderConfig video_decoder_config() OVERRIDE; |
+ virtual Type type() OVERRIDE; |
+ virtual void EnableBitstreamConverter() OVERRIDE; |
+ virtual bool SupportsConfigChanges() OVERRIDE; |
+ virtual VideoRotation video_rotation() OVERRIDE; |
+ |
+ // mojo::DemuxerStreamClient implementation. |
+ virtual void OnStreamReady( |
+ mojo::ScopedDataPipeConsumerHandle pipe) OVERRIDE; |
+ virtual void OnAudioDecoderConfigChanged( |
+ mojo::AudioDecoderConfigPtr config) OVERRIDE; |
+ |
+ private: |
+ // The callback from |demuxer_stream_| that a read operation has completed. |
+ // |read_cb| is a callback from the client who invoked Read() on |this|. |
+ void OnBufferReady(const ReadCB& read_cb, |
+ mojo::DemuxerStream::Status status, |
+ mojo::MediaDecoderBufferPtr buffer); |
+ |
+ // See constructor for descriptions. |
+ mojo::DemuxerStreamPtr demuxer_stream_; |
+ base::Closure stream_ready_callback_; |
xhwang
2014/09/10 00:00:52
nit: s/stream_ready_callback_/stream_ready_cb_/
tim (not reviewing)
2014/09/10 23:08:29
Done.
|
+ |
+ // Used to store the results of OnBufferReady() in the event it is called |
+ // with DemuxerStream::Status::kConfigChanged and we don't have an up to |
+ // date AudioDecoderConfig yet. In that case we can't forward the results |
+ // on to the caller of Read() until OnAudioDecoderConfigChanged is observed. |
+ base::Closure on_config_change_cb_; |
+ |
+ // The front of the queue is the current config. We pop when we observe |
+ // DemuxerStatus::CONFIG_CHANGED. |
+ std::queue<media::AudioDecoderConfig> config_queue_; |
+ |
+ base::WeakPtrFactory<MojoDemuxerStreamAdapter> weak_factory_; |
+ DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamAdapter); |
+}; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |