Stream.h revision d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4d
1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include "Element.h"
20#include "EngineDefinition.h"
21#include <RoutingStrategy.h>
22#include <map>
23
24namespace android
25{
26namespace audio_policy
27{
28/**
29 * @tparam routing_strategy: Applicable strategy for this stream.
30 */
31template <>
32class Element<audio_stream_type_t>
33{
34public:
35    Element(const std::string &name)
36        : mName(name),
37          mApplicableStrategy(STRATEGY_MEDIA)
38    {}
39    ~Element() {}
40
41    /**
42     * Returns identifier of this policy element
43     *
44     * @returns string representing the name of this policy element
45     */
46    const std::string &getName() const { return mName; }
47
48    /**
49    * Set the unique identifier for this policy element.
50    *
51    * @tparam Key type of the unique identifier.
52    * @param[in] identifier to be set.
53    *
54    * @return NO_ERROR if the identifier is valid and set correctly, error code otherwise.
55    */
56    status_t setIdentifier(audio_stream_type_t identifier);
57
58    /**
59     * @return the unique identifier of this policy element.
60     */
61    audio_stream_type_t getIdentifier() const { return mIdentifier; }
62
63    /**
64     * A Policy element may implement getter/setter function for a given property.
65     * Property may be routing_strategy, audio_stream_type_t, audio_usage_t, audio_source_t
66     * or a string.
67     */
68    template <typename Property>
69    Property get() const;
70
71    template <typename Property>
72    status_t set(Property property);
73
74private:
75    /* Copy facilities are put private to disable copy. */
76    Element(const Element &object);
77    Element &operator=(const Element &object);
78
79    std::string mName; /**< Unique literal Identifier of a policy base element*/
80    audio_stream_type_t mIdentifier; /**< Unique numerical Identifier of a policy base element*/
81
82    routing_strategy mApplicableStrategy; /**< Applicable strategy for this stream. */
83
84    audio_stream_type_t mVolumeProfile; /**< Volume Profile followed by this stream. */
85};
86
87typedef Element<audio_stream_type_t> Stream;
88
89} // namespace audio_policy
90} // namespace android
91
92
93