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_BASE_VIDEO_PIPELINE_IMPL_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_BASE_VIDEO_PIPELINE_IMPL_H_ |
6 #define CHROMECAST_MEDIA_CMA_BASE_VIDEO_PIPELINE_IMPL_H_ | 6 #define CHROMECAST_MEDIA_CMA_BASE_VIDEO_PIPELINE_IMPL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
14 #include "chromecast/media/cma/pipeline/video_pipeline.h" | 14 #include "chromecast/media/cma/pipeline/video_pipeline.h" |
15 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" | 15 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" |
| 16 #include "chromecast/public/media/media_pipeline_backend.h" |
16 #include "chromecast/public/media/stream_id.h" | 17 #include "chromecast/public/media/stream_id.h" |
17 #include "chromecast/public/media/video_pipeline_device.h" | |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 class AudioDecoderConfig; | 20 class AudioDecoderConfig; |
21 class VideoDecoderConfig; | 21 class VideoDecoderConfig; |
22 } | 22 } |
23 | 23 |
24 namespace chromecast { | 24 namespace chromecast { |
25 struct Size; | 25 struct Size; |
26 namespace media { | 26 namespace media { |
27 class AvPipelineImpl; | 27 class AvPipelineImpl; |
28 class BrowserCdmCast; | 28 class BrowserCdmCast; |
29 class BufferingState; | 29 class BufferingState; |
30 class CodedFrameProvider; | 30 class CodedFrameProvider; |
31 class VideoPipelineDevice; | |
32 | 31 |
33 class VideoPipelineImpl : public VideoPipeline { | 32 class VideoPipelineImpl { |
34 public: | 33 public: |
35 // |buffering_controller| can be NULL. | 34 VideoPipelineImpl(MediaPipelineBackend::VideoDecoder* decoder, |
36 explicit VideoPipelineImpl(VideoPipelineDevice* video_device); | 35 const BrowserVideoPipelineClient& client); |
37 ~VideoPipelineImpl() override; | 36 ~VideoPipelineImpl(); |
38 | 37 |
39 // Input port of the pipeline. | 38 // Input port of the pipeline. |
40 void SetCodedFrameProvider(scoped_ptr<CodedFrameProvider> frame_provider); | 39 void SetCodedFrameProvider(scoped_ptr<CodedFrameProvider> frame_provider); |
41 | 40 |
42 // Provide the CDM to use to decrypt samples. | 41 // Provide the CDM to use to decrypt samples. |
43 void SetCdm(BrowserCdmCast* media_keys); | 42 void SetCdm(BrowserCdmCast* media_keys); |
44 | 43 |
45 // Functions to control the state of the audio pipeline. | 44 // Functions to control the state of the audio pipeline. |
46 void Initialize( | 45 void Initialize( |
47 const std::vector<::media::VideoDecoderConfig>& configs, | 46 const std::vector<::media::VideoDecoderConfig>& configs, |
48 scoped_ptr<CodedFrameProvider> frame_provider, | 47 scoped_ptr<CodedFrameProvider> frame_provider, |
49 const ::media::PipelineStatusCB& status_cb); | 48 const ::media::PipelineStatusCB& status_cb); |
50 bool StartPlayingFrom(base::TimeDelta time, | 49 bool StartPlayingFrom(base::TimeDelta time, |
51 const scoped_refptr<BufferingState>& buffering_state); | 50 const scoped_refptr<BufferingState>& buffering_state); |
52 void Flush(const ::media::PipelineStatusCB& status_cb); | 51 void Flush(const ::media::PipelineStatusCB& status_cb); |
53 void Stop(); | 52 void Stop(); |
54 | 53 |
55 // Update the playback statistics for this video stream. | 54 // Update the playback statistics for this video stream. |
56 void UpdateStatistics(); | 55 void UpdateStatistics(); |
57 | 56 |
58 // VideoPipeline implementation. | 57 void OnBufferPushed(MediaPipelineBackend::BufferStatus status); |
59 void SetClient(const VideoPipelineClient& client) override; | 58 void OnEndOfStream(); |
| 59 void OnError(); |
| 60 void OnNaturalSizeChanged(const Size& size); |
60 | 61 |
61 private: | 62 private: |
62 class DeviceClientImpl; | 63 class DeviceClientImpl; |
63 friend class DeviceClientImpl; | 64 friend class DeviceClientImpl; |
64 | 65 |
65 void OnFlushDone(const ::media::PipelineStatusCB& status_cb); | 66 void OnFlushDone(const ::media::PipelineStatusCB& status_cb); |
66 void OnUpdateConfig(StreamId id, | 67 void OnUpdateConfig(StreamId id, |
67 const ::media::AudioDecoderConfig& audio_config, | 68 const ::media::AudioDecoderConfig& audio_config, |
68 const ::media::VideoDecoderConfig& video_config); | 69 const ::media::VideoDecoderConfig& video_config); |
69 void OnNaturalSizeChanged(const Size& size); | |
70 | 70 |
71 VideoPipelineDevice* video_device_; | 71 MediaPipelineBackend::VideoDecoder* video_decoder_; |
72 | 72 |
73 scoped_ptr<AvPipelineImpl> av_pipeline_impl_; | 73 scoped_ptr<AvPipelineImpl> av_pipeline_impl_; |
74 VideoPipelineClient video_client_; | 74 BrowserVideoPipelineClient video_client_; |
75 | 75 |
76 ::media::PipelineStatistics previous_stats_; | 76 ::media::PipelineStatistics previous_stats_; |
77 | 77 |
78 base::WeakPtr<VideoPipelineImpl> weak_this_; | 78 base::WeakPtr<VideoPipelineImpl> weak_this_; |
79 base::WeakPtrFactory<VideoPipelineImpl> weak_factory_; | 79 base::WeakPtrFactory<VideoPipelineImpl> weak_factory_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(VideoPipelineImpl); | 81 DISALLOW_COPY_AND_ASSIGN(VideoPipelineImpl); |
82 }; | 82 }; |
83 | 83 |
84 } // namespace media | 84 } // namespace media |
85 } // namespace chromecast | 85 } // namespace chromecast |
86 | 86 |
87 #endif // CHROMECAST_MEDIA_CMA_BASE_VIDEO_PIPELINE_IMPL_H_ | 87 #endif // CHROMECAST_MEDIA_CMA_BASE_VIDEO_PIPELINE_IMPL_H_ |
OLD | NEW |