Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chromecast/media/cma/backend/alsa/post_processing_pipeline_parser.cc

Issue 2771143002: Implement runtime audio post-processing pipeline. See go/cast_audio.json (Closed)
Patch Set: Suffix governor with _1.0 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chromecast/media/cma/backend/alsa/post_processing_pipeline_parser.h"
6
7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h"
9 #include "base/logging.h"
10 #include "base/values.h"
11 #include "chromecast/base/serializers.h"
12 #include "chromecast/media/base/audio_device_ids.h"
13 #include "media/audio/audio_device_description.h"
14
15 namespace chromecast {
16 namespace media {
17
18 namespace {
19
20 const base::FilePath::CharType kPostProcessingPipelineFilePath[] =
21 FILE_PATH_LITERAL("/etc/cast_audio.json");
22
23 const char kCommunicationPipelineKey[] = "communication";
24 const char kAlarmPipelineKey[] = "alarm";
25 const char kTtsPipelineKey[] = "tts";
26 const char kMediaPipelineKey[] = "media";
27
28 // TODO(bshaya): Use AudioContentType instead.
29 std::string GetPipelineKey(const std::string& device_id) {
30 if (device_id == ::media::AudioDeviceDescription::kCommunicationsDeviceId) {
31 return kCommunicationPipelineKey;
32 }
33 if (device_id == kAlarmAudioDeviceId) {
34 return kAlarmPipelineKey;
35 }
36 if (device_id == kTtsAudioDeviceId) {
37 return kTtsPipelineKey;
38 }
39 if (device_id == ::media::AudioDeviceDescription::kDefaultDeviceId) {
40 return kMediaPipelineKey;
41 }
42 NOTREACHED() << "Invalid device_id: " << device_id;
43 return "";
44 }
45
46 } // namespace
47
48 PostProcessingPipelineParser::PostProcessingPipelineParser() = default;
49 PostProcessingPipelineParser::~PostProcessingPipelineParser() = default;
50
51 void PostProcessingPipelineParser::Initialize() {
52 if (!base::PathExists(base::FilePath(kPostProcessingPipelineFilePath))) {
53 LOG(WARNING) << "No post-processing config found in "
54 << kPostProcessingPipelineFilePath << ".";
55 return;
56 }
57
58 config_dict_ = base::DictionaryValue::From(
59 DeserializeJsonFromFile(base::FilePath(kPostProcessingPipelineFilePath)));
60 CHECK(config_dict_->GetDictionary("post_processing", &pipeline_dict_))
61 << "No \"post_processing\" object found in "
62 << kPostProcessingPipelineFilePath;
63 }
64
65 base::ListValue* PostProcessingPipelineParser::GetPipelineByDeviceId(
66 const std::string& device_id) {
67 if (!pipeline_dict_) {
68 return nullptr;
69 }
70
71 base::ListValue* out_list;
72 std::string key = GetPipelineKey(device_id);
73 if (!pipeline_dict_->GetList(key, &out_list)) {
74 LOG(WARNING) << "No post-processor description found for \"" << key
75 << "\" in " << kPostProcessingPipelineFilePath
76 << ". Using passthrough.";
77 return nullptr;
78 }
79 return out_list;
80 }
81
82 } // namepsace media
83 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698