2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
17 #define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
19 #include <android/hardware/broadcastradio/1.1/types.h>
26 namespace broadcastradio {
28 namespace implementation {
32 * Checks, if {@code pointer} tunes to {@channel}.
34 * For example, having a channel {AMFM_FREQUENCY = 103.3}:
35 * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 0} can tune to this channel;
36 * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 1} can't.
38 * @param pointer selector we're trying to match against channel.
39 * @param channel existing channel.
41 bool tunesTo(const ProgramSelector& pointer, const ProgramSelector& channel);
43 ProgramType getType(const ProgramSelector& sel);
44 bool isAmFm(const ProgramType type);
46 bool hasId(const ProgramSelector& sel, const IdentifierType type);
49 * Returns ID (either primary or secondary) for a given program selector.
51 * If the selector does not contain given type, returns 0 and emits a warning.
53 uint64_t getId(const ProgramSelector& sel, const IdentifierType type);
56 * Returns ID (either primary or secondary) for a given program selector.
58 * If the selector does not contain given type, returns default value.
60 uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t defval);
62 ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);
64 bool getLegacyChannel(const ProgramSelector& sel, uint32_t& channelOut, uint32_t& subChannelOut);
66 bool isDigital(const ProgramSelector& sel);
69 } // namespace implementation
71 } // namespace broadcastradio
72 } // namespace hardware
73 } // namespace android
75 #endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H