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