multimedia: Add API to set active output volume

Add cras utils and multimedia server API to set active output volume.

BUG=chromium:463813
TEST=not used yet.

Change-Id: I9557a8fe0f6b24b5c112508994543d4379b954c4
Reviewed-on: https://chromium-review.googlesource.com/257291
Reviewed-by: Wai-Hong Tam <waihong@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/client/cros/audio/cras_utils.py b/client/cros/audio/cras_utils.py
index 33ca9b9..e53e11d 100644
--- a/client/cros/audio/cras_utils.py
+++ b/client/cros/audio/cras_utils.py
@@ -127,6 +127,16 @@
 
     return (output_match.group(1).strip(), input_match.group(1).strip())
 
+
+def set_selected_output_node_volume(volume):
+    """Sets the selected output node volume.
+
+    @param volume: the volume to be set (0-100).
+    """
+    selected_output_node_id, _ = get_selected_nodes()
+    set_node_volume(selected_output_node_id, volume)
+
+
 def get_active_stream_count():
     """Gets the number of active streams."""
     server_info = dump_server_info()
diff --git a/client/cros/multimedia/audio_facade_native.py b/client/cros/multimedia/audio_facade_native.py
index e6de161..3ac7094 100644
--- a/client/cros/multimedia/audio_facade_native.py
+++ b/client/cros/multimedia/audio_facade_native.py
@@ -119,6 +119,15 @@
         return True
 
 
+    def set_selected_output_volume(self, volume):
+        """Sets the selected output volume.
+
+        @param volume: the volume to be set(0-100).
+
+        """
+        cras_utils.set_selected_output_node_volume(volume)
+
+
 class RecorderError(Exception):
     """Error in Recorder."""
     pass
diff --git a/server/cros/multimedia/audio_facade_adapter.py b/server/cros/multimedia/audio_facade_adapter.py
index ef8b8e9..c9e00c3 100644
--- a/server/cros/multimedia/audio_facade_adapter.py
+++ b/server/cros/multimedia/audio_facade_adapter.py
@@ -113,3 +113,12 @@
         self._client.get_file(remote_path, file_path)
 
         return True
+
+
+    def set_selected_output_volume(self, volume):
+        """Sets the selected output volume on DUT.
+
+        @param volume: the volume to be set(0-100).
+
+        """
+        self._audio_proxy.set_selected_output_volume(volume)