| 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 CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ | 6 #define CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 13 #include "chromecast/media/cma/base/coded_frame_provider.h" | 14 #include "chromecast/media/cma/base/coded_frame_provider.h" |
| 14 #include "media/base/audio_decoder_config.h" | 15 #include "media/base/audio_decoder_config.h" |
| 15 #include "media/base/video_decoder_config.h" | 16 #include "media/base/video_decoder_config.h" |
| 16 | 17 |
| 17 namespace chromecast { | 18 namespace chromecast { |
| 18 namespace media { | 19 namespace media { |
| 19 class MediaMessageFifo; | 20 class MediaMessageFifo; |
| 20 | 21 |
| 21 // CodedFrameProviderHost is a frame provider that gets the frames | 22 // CodedFrameProviderHost is a frame provider that gets the frames |
| 22 // from a media message fifo. | 23 // from a media message fifo. |
| 23 class CodedFrameProviderHost : public CodedFrameProvider { | 24 class CodedFrameProviderHost : public CodedFrameProvider { |
| 24 public: | 25 public: |
| 25 // Note: if the media message fifo is located into shared memory, | 26 // Note: if the media message fifo is located into shared memory, |
| 26 // the caller must make sure the shared memory segment is valid | 27 // the caller must make sure the shared memory segment is valid |
| 27 // during the whole lifetime of this object. | 28 // during the whole lifetime of this object. |
| 28 explicit CodedFrameProviderHost( | 29 explicit CodedFrameProviderHost( |
| 29 scoped_ptr<MediaMessageFifo> media_message_fifo); | 30 std::unique_ptr<MediaMessageFifo> media_message_fifo); |
| 30 ~CodedFrameProviderHost() override; | 31 ~CodedFrameProviderHost() override; |
| 31 | 32 |
| 32 // CodedFrameProvider implementation. | 33 // CodedFrameProvider implementation. |
| 33 void Read(const ReadCB& read_cb) override; | 34 void Read(const ReadCB& read_cb) override; |
| 34 void Flush(const base::Closure& flush_cb) override; | 35 void Flush(const base::Closure& flush_cb) override; |
| 35 | 36 |
| 36 // Invoked when some data has been written into the fifo. | 37 // Invoked when some data has been written into the fifo. |
| 37 void OnFifoWriteEvent(); | 38 void OnFifoWriteEvent(); |
| 38 base::Closure GetFifoWriteEventCb(); | 39 base::Closure GetFifoWriteEventCb(); |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 void ReadMessages(); | 42 void ReadMessages(); |
| 42 | 43 |
| 43 base::ThreadChecker thread_checker_; | 44 base::ThreadChecker thread_checker_; |
| 44 | 45 |
| 45 // Fifo holding the frames. | 46 // Fifo holding the frames. |
| 46 scoped_ptr<MediaMessageFifo> fifo_; | 47 std::unique_ptr<MediaMessageFifo> fifo_; |
| 47 | 48 |
| 48 ReadCB read_cb_; | 49 ReadCB read_cb_; |
| 49 | 50 |
| 50 // Audio/video configuration for the next A/V buffer. | 51 // Audio/video configuration for the next A/V buffer. |
| 51 ::media::AudioDecoderConfig audio_config_; | 52 ::media::AudioDecoderConfig audio_config_; |
| 52 ::media::VideoDecoderConfig video_config_; | 53 ::media::VideoDecoderConfig video_config_; |
| 53 | 54 |
| 54 base::WeakPtr<CodedFrameProviderHost> weak_this_; | 55 base::WeakPtr<CodedFrameProviderHost> weak_this_; |
| 55 base::WeakPtrFactory<CodedFrameProviderHost> weak_factory_; | 56 base::WeakPtrFactory<CodedFrameProviderHost> weak_factory_; |
| 56 | 57 |
| 57 DISALLOW_COPY_AND_ASSIGN(CodedFrameProviderHost); | 58 DISALLOW_COPY_AND_ASSIGN(CodedFrameProviderHost); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 } // namespace media | 61 } // namespace media |
| 61 } // namespace chromecast | 62 } // namespace chromecast |
| 62 | 63 |
| 63 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ | 64 #endif // CHROMECAST_MEDIA_CMA_IPC_STREAMER_CODED_FRAME_PROVIDER_HOST_H_ |
| OLD | NEW |