| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ | 6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chromecast/media/cma/backend/alsa/post_processing_pipeline.h" | 13 #include "chromecast/media/cma/backend/alsa/post_processing_pipeline.h" |
| 14 #include "chromecast/media/cma/backend/alsa/post_processor_factory.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class ListValue; | 17 class ListValue; |
| 17 class ScopedNativeLibrary; | |
| 18 } // namespace base | 18 } // namespace base |
| 19 | 19 |
| 20 namespace chromecast { | 20 namespace chromecast { |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 class AudioPostProcessor; | 23 class AudioPostProcessor; |
| 24 | 24 |
| 25 // Creates and contains multiple AudioPostProcessors, as specified in ctor. | 25 // Creates and contains multiple AudioPostProcessors, as specified in ctor. |
| 26 // Provides convenience methods to access and use the AudioPostProcessors. | 26 // Provides convenience methods to access and use the AudioPostProcessors. |
| 27 class PostProcessingPipelineImpl : public PostProcessingPipeline { | 27 class PostProcessingPipelineImpl : public PostProcessingPipeline { |
| 28 public: | 28 public: |
| 29 PostProcessingPipelineImpl(const std::string& name, | 29 PostProcessingPipelineImpl(const std::string& name, |
| 30 const base::ListValue* filter_description_list, | 30 const base::ListValue* filter_description_list, |
| 31 int channels); | 31 int channels); |
| 32 ~PostProcessingPipelineImpl() override; | 32 ~PostProcessingPipelineImpl() override; |
| 33 | 33 |
| 34 int ProcessFrames(float* data, | 34 int ProcessFrames(float* data, |
| 35 int num_frames, | 35 int num_frames, |
| 36 float current_volume, | 36 float current_volume, |
| 37 bool is_silence) override; | 37 bool is_silence) override; |
| 38 | 38 |
| 39 bool SetSampleRate(int sample_rate) override; | 39 bool SetSampleRate(int sample_rate) override; |
| 40 bool IsRinging() override; | 40 bool IsRinging() override; |
| 41 | 41 |
| 42 // Send string |config| to post processor |name|. | 42 // Send string |config| to post processor |name|. |
| 43 void SetPostProcessorConfig(const std::string& name, | 43 void SetPostProcessorConfig(const std::string& name, |
| 44 const std::string& config) override; | 44 const std::string& config) override; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // Note: typedef is used to silence chromium-style mandatory constructor in |
| 48 // structs. |
| 49 typedef struct { |
| 50 std::unique_ptr<AudioPostProcessor> ptr; |
| 51 std::string name; |
| 52 } PostProcessorInfo; |
| 53 |
| 47 int GetRingingTimeInFrames(); | 54 int GetRingingTimeInFrames(); |
| 48 void UpdateCastVolume(float multiplier); | 55 void UpdateCastVolume(float multiplier); |
| 49 | 56 |
| 50 std::string name_; | 57 std::string name_; |
| 51 int sample_rate_; | 58 int sample_rate_; |
| 52 int ringing_time_in_frames_ = 0; | 59 int ringing_time_in_frames_ = 0; |
| 53 int silence_frames_processed_ = 0; | 60 int silence_frames_processed_ = 0; |
| 54 int total_delay_frames_ = 0; | 61 int total_delay_frames_ = 0; |
| 55 float current_multiplier_; | 62 float current_multiplier_; |
| 56 float cast_volume_; | 63 float cast_volume_; |
| 57 | 64 |
| 58 // Contains all libraries in use; | 65 // factory_ keeps shared libraries open, so it must outlive processors_. |
| 59 // Functions in shared objects cannot be used once library is closed. | 66 PostProcessorFactory factory_; |
| 60 std::vector<std::unique_ptr<base::ScopedNativeLibrary>> libraries_; | |
| 61 | |
| 62 // Must be after libraries_ | |
| 63 // Note: typedef is used to silence chromium-style mandatory constructor in | |
| 64 // structs. | |
| 65 typedef struct { | |
| 66 std::unique_ptr<AudioPostProcessor> ptr; | |
| 67 std::string name; | |
| 68 } PostProcessorInfo; | |
| 69 | 67 |
| 70 std::vector<PostProcessorInfo> processors_; | 68 std::vector<PostProcessorInfo> processors_; |
| 71 | 69 |
| 72 DISALLOW_COPY_AND_ASSIGN(PostProcessingPipelineImpl); | 70 DISALLOW_COPY_AND_ASSIGN(PostProcessingPipelineImpl); |
| 73 }; | 71 }; |
| 74 | 72 |
| 75 } // namespace media | 73 } // namespace media |
| 76 } // namespace chromecast | 74 } // namespace chromecast |
| 77 | 75 |
| 78 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ | 76 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_IMPL_H_ |
| OLD | NEW |