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_PARSER_H_ | 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_PARSER_H_ |
6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_PARSER_H_ | 6 #define CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_PARSER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
| 10 #include <unordered_set> |
| 11 #include <vector> |
10 | 12 |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 | 14 |
13 namespace base { | 15 namespace base { |
14 class DictionaryValue; | 16 class DictionaryValue; |
15 class ListValue; | 17 class ListValue; |
16 } // namespace base | 18 } // namespace base |
17 | 19 |
18 namespace chromecast { | 20 namespace chromecast { |
19 namespace media { | 21 namespace media { |
20 | 22 |
| 23 // Helper class to hold information about a stream pipeline. |
| 24 struct StreamPipelineDescriptor { |
| 25 // The format for pipeline is: |
| 26 // [ {"processor": "PATH_TO_SHARED_OBJECT", |
| 27 // "config": "CONFIGURATION_STRING"}, |
| 28 // {"processor": "PATH_TO_SHARED_OBJECT", |
| 29 // "config": "CONFIGURATION_STRING"}, |
| 30 // ... ] |
| 31 base::ListValue* pipeline; |
| 32 std::unordered_set<std::string> stream_types; |
| 33 |
| 34 StreamPipelineDescriptor( |
| 35 base::ListValue* pipeline_in, |
| 36 const std::unordered_set<std::string>& stream_types_in); |
| 37 ~StreamPipelineDescriptor(); |
| 38 StreamPipelineDescriptor(const StreamPipelineDescriptor& other); |
| 39 StreamPipelineDescriptor operator=(const StreamPipelineDescriptor& other) = |
| 40 delete; |
| 41 }; |
| 42 |
21 // Helper class to parse post-processing pipeline descriptor file. | 43 // Helper class to parse post-processing pipeline descriptor file. |
22 class PostProcessingPipelineParser { | 44 class PostProcessingPipelineParser { |
23 public: | 45 public: |
24 PostProcessingPipelineParser(); | 46 // |json|, if provided, is used instead of reading from file. |
| 47 // |json| should be provided in tests only. |
| 48 explicit PostProcessingPipelineParser(const std::string& json = ""); |
25 ~PostProcessingPipelineParser(); | 49 ~PostProcessingPipelineParser(); |
26 | 50 |
27 // Reads the pipeline descriptor file and does preliminary parsing. | 51 std::vector<StreamPipelineDescriptor> GetStreamPipelines(); |
28 // Crashes with fatal log if parsing fails. | |
29 void Initialize(); | |
30 | 52 |
31 // Gets the list of processors for a given stream type. | 53 // Gets the list of processors for the mix/linearize stages. |
32 // The format will be: | 54 // Same format as StreamPipelineDescriptor.pipeline |
33 // [ | 55 base::ListValue* GetMixPipeline(); |
34 // {"processor": "PATH_TO_SHARED_OBJECT", | 56 base::ListValue* GetLinearizePipeline(); |
35 // "config": "CONFIGURATION_STRING"}, | 57 |
36 // {"processor": "PATH_TO_SHARED_OBJECT", | 58 static std::string GetFilePath(); |
37 // "config": "CONFIGURATION_STRING"}, | |
38 // ... | |
39 // ] | |
40 base::ListValue* GetPipelineByDeviceId(const std::string& device_id); | |
41 | 59 |
42 private: | 60 private: |
| 61 base::ListValue* GetPipelineByKey(const std::string& key); |
| 62 |
43 std::unique_ptr<base::DictionaryValue> config_dict_; | 63 std::unique_ptr<base::DictionaryValue> config_dict_; |
44 base::DictionaryValue* pipeline_dict_ = nullptr; | |
45 | 64 |
46 DISALLOW_COPY_AND_ASSIGN(PostProcessingPipelineParser); | 65 DISALLOW_COPY_AND_ASSIGN(PostProcessingPipelineParser); |
47 }; | 66 }; |
48 | 67 |
49 } // namepsace media | 68 } // namepsace media |
50 } // namespace chromecast | 69 } // namespace chromecast |
51 | 70 |
52 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_PARSER_H_ | 71 #endif // CHROMECAST_MEDIA_CMA_BACKEND_ALSA_POST_PROCESSING_PIPELINE_PARSER_H_ |
OLD | NEW |