blob: cd86ffaadc451a98bb60de46ab4fde5b8d19d244 [file] [log] [blame]
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -07001/*
2 * Copyright (C) 2017 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#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
17#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H
18
19#include <android/hardware/broadcastradio/1.1/types.h>
20#include <chrono>
21#include <queue>
22#include <thread>
23
24namespace android {
25namespace hardware {
26namespace broadcastradio {
27namespace V1_1 {
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070028namespace utils {
29
30/**
31 * Checks, if {@code pointer} tunes to {@channel}.
32 *
33 * For example, having a channel {AMFM_FREQUENCY = 103.3}:
34 * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 0} can tune to this channel;
35 * - selector {AMFM_FREQUENCY = 103.3, HD_SUBCHANNEL = 1} can't.
36 *
37 * @param pointer selector we're trying to match against channel.
38 * @param channel existing channel.
39 */
40bool tunesTo(const ProgramSelector& pointer, const ProgramSelector& channel);
41
42ProgramType getType(const ProgramSelector& sel);
43bool isAmFm(const ProgramType type);
44
45bool hasId(const ProgramSelector& sel, const IdentifierType type);
46
47/**
48 * Returns ID (either primary or secondary) for a given program selector.
49 *
50 * If the selector does not contain given type, returns 0 and emits a warning.
51 */
52uint64_t getId(const ProgramSelector& sel, const IdentifierType type);
53
54/**
55 * Returns ID (either primary or secondary) for a given program selector.
56 *
57 * If the selector does not contain given type, returns default value.
58 */
59uint64_t getId(const ProgramSelector& sel, const IdentifierType type, uint64_t defval);
60
61ProgramSelector make_selector(V1_0::Band band, uint32_t channel, uint32_t subChannel = 0);
62
Tomasz Wasilczyk2834b952017-07-12 14:17:09 -070063bool getLegacyChannel(const ProgramSelector& sel, uint32_t* channelOut, uint32_t* subChannelOut);
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070064
65bool isDigital(const ProgramSelector& sel);
66
67} // namespace utils
Tomasz Wasilczyka02b6ef2017-07-05 11:23:30 -070068} // namespace V1_1
69} // namespace broadcastradio
70} // namespace hardware
71} // namespace android
72
73#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_UTILS_H