| OLD | NEW |
| 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_MOJO_DEMUXER_STREAM_ADAPTER_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // |demuxer_stream| is connected to the mojo::DemuxerStream that |this| will | 25 // |demuxer_stream| is connected to the mojo::DemuxerStream that |this| will |
| 26 // become the client of. | 26 // become the client of. |
| 27 // |stream_ready_cb| will be invoked when |stream| has fully initialized | 27 // |stream_ready_cb| will be invoked when |stream| has fully initialized |
| 28 // and |this| is ready for use. | 28 // and |this| is ready for use. |
| 29 // NOTE: Illegal to call any methods until |stream_ready_cb| is invoked. | 29 // NOTE: Illegal to call any methods until |stream_ready_cb| is invoked. |
| 30 MojoDemuxerStreamAdapter(mojo::DemuxerStreamPtr demuxer_stream, | 30 MojoDemuxerStreamAdapter(mojo::DemuxerStreamPtr demuxer_stream, |
| 31 const base::Closure& stream_ready_cb); | 31 const base::Closure& stream_ready_cb); |
| 32 virtual ~MojoDemuxerStreamAdapter(); | 32 virtual ~MojoDemuxerStreamAdapter(); |
| 33 | 33 |
| 34 // media::DemuxerStream implementation. | 34 // media::DemuxerStream implementation. |
| 35 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 35 virtual void Read(const ReadCB& read_cb) override; |
| 36 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE; | 36 virtual AudioDecoderConfig audio_decoder_config() override; |
| 37 virtual VideoDecoderConfig video_decoder_config() OVERRIDE; | 37 virtual VideoDecoderConfig video_decoder_config() override; |
| 38 virtual Type type() OVERRIDE; | 38 virtual Type type() override; |
| 39 virtual void EnableBitstreamConverter() OVERRIDE; | 39 virtual void EnableBitstreamConverter() override; |
| 40 virtual bool SupportsConfigChanges() OVERRIDE; | 40 virtual bool SupportsConfigChanges() override; |
| 41 virtual VideoRotation video_rotation() OVERRIDE; | 41 virtual VideoRotation video_rotation() override; |
| 42 | 42 |
| 43 // mojo::DemuxerStreamClient implementation. | 43 // mojo::DemuxerStreamClient implementation. |
| 44 virtual void OnStreamReady(mojo::ScopedDataPipeConsumerHandle pipe) OVERRIDE; | 44 virtual void OnStreamReady(mojo::ScopedDataPipeConsumerHandle pipe) override; |
| 45 virtual void OnAudioDecoderConfigChanged( | 45 virtual void OnAudioDecoderConfigChanged( |
| 46 mojo::AudioDecoderConfigPtr config) OVERRIDE; | 46 mojo::AudioDecoderConfigPtr config) override; |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // The callback from |demuxer_stream_| that a read operation has completed. | 49 // The callback from |demuxer_stream_| that a read operation has completed. |
| 50 // |read_cb| is a callback from the client who invoked Read() on |this|. | 50 // |read_cb| is a callback from the client who invoked Read() on |this|. |
| 51 void OnBufferReady(mojo::DemuxerStream::Status status, | 51 void OnBufferReady(mojo::DemuxerStream::Status status, |
| 52 mojo::MediaDecoderBufferPtr buffer); | 52 mojo::MediaDecoderBufferPtr buffer); |
| 53 | 53 |
| 54 // See constructor for descriptions. | 54 // See constructor for descriptions. |
| 55 mojo::DemuxerStreamPtr demuxer_stream_; | 55 mojo::DemuxerStreamPtr demuxer_stream_; |
| 56 base::Closure stream_ready_cb_; | 56 base::Closure stream_ready_cb_; |
| 57 | 57 |
| 58 // The last ReadCB received through a call to Read(). | 58 // The last ReadCB received through a call to Read(). |
| 59 // Used to store the results of OnBufferReady() in the event it is called | 59 // Used to store the results of OnBufferReady() in the event it is called |
| 60 // with DemuxerStream::Status::kConfigChanged and we don't have an up to | 60 // with DemuxerStream::Status::kConfigChanged and we don't have an up to |
| 61 // date AudioDecoderConfig yet. In that case we can't forward the results | 61 // date AudioDecoderConfig yet. In that case we can't forward the results |
| 62 // on to the caller of Read() until OnAudioDecoderConfigChanged is observed. | 62 // on to the caller of Read() until OnAudioDecoderConfigChanged is observed. |
| 63 DemuxerStream::ReadCB read_cb_; | 63 DemuxerStream::ReadCB read_cb_; |
| 64 | 64 |
| 65 // The front of the queue is the current config. We pop when we observe | 65 // The front of the queue is the current config. We pop when we observe |
| 66 // DemuxerStatus::CONFIG_CHANGED. | 66 // DemuxerStatus::CONFIG_CHANGED. |
| 67 std::queue<media::AudioDecoderConfig> config_queue_; | 67 std::queue<media::AudioDecoderConfig> config_queue_; |
| 68 | 68 |
| 69 base::WeakPtrFactory<MojoDemuxerStreamAdapter> weak_factory_; | 69 base::WeakPtrFactory<MojoDemuxerStreamAdapter> weak_factory_; |
| 70 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamAdapter); | 70 DISALLOW_COPY_AND_ASSIGN(MojoDemuxerStreamAdapter); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace media | 73 } // namespace media |
| 74 | 74 |
| 75 #endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ | 75 #endif // MEDIA_MOJO_SERVICES_MOJO_DEMUXER_STREAM_ADAPTER_H_ |
| OLD | NEW |