blob: 176b1b2fb9dd193c58ae3e4018122b1d679932f9 [file] [log] [blame]
Tomasz Wasilczyk48377552017-06-22 10:45:33 -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 */
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080016#ifndef ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
17#define ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070018
19#include "VirtualProgram.h"
20
21#include <mutex>
22#include <vector>
23
24namespace android {
25namespace hardware {
26namespace broadcastradio {
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080027namespace V1_1 {
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070028namespace implementation {
29
Tomasz Wasilczykefadc192017-07-28 10:08:46 -070030/**
31 * A radio frequency space mock.
32 *
33 * This represents all broadcast waves in the air for a given radio technology,
34 * not a captured station list in the radio tuner memory.
35 *
36 * It's meant to abstract out radio content from default tuner implementation.
37 */
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070038class VirtualRadio {
39 public:
Tomasz Wasilczykba3e2542017-07-17 13:59:21 -070040 VirtualRadio(const std::vector<VirtualProgram> initialList);
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070041
42 std::vector<VirtualProgram> getProgramList();
Tomasz Wasilczykf679e8b2017-09-14 09:43:35 -070043 bool getProgram(const V1_1::ProgramSelector& selector, VirtualProgram& program);
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070044
45 private:
46 std::mutex mMut;
47 std::vector<VirtualProgram> mPrograms;
48};
49
Tomasz Wasilczykefadc192017-07-28 10:08:46 -070050/**
51 * Get virtual radio space for a given radio class.
52 *
53 * As a space, each virtual radio always exists. For example, DAB frequencies
54 * exists in US, but contains no programs.
55 *
56 * The lifetime of the virtual radio space is virtually infinite, but for the
57 * needs of default implementation, it's bound with the lifetime of default
58 * implementation process.
59 *
60 * Internally, it's a static object, so trying to access the reference during
61 * default implementation library unloading may result in segmentation fault.
62 * It's unlikely for testing purposes.
63 *
64 * @param classId A class of radio technology.
65 * @return A reference to virtual radio space for a given technology.
66 */
67VirtualRadio& getRadio(V1_0::Class classId);
68
69VirtualRadio& getAmRadio();
70VirtualRadio& getFmRadio();
71VirtualRadio& getSatRadio();
72VirtualRadio& getDigitalRadio();
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070073
74} // namespace implementation
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080075} // namespace V1_1
Tomasz Wasilczyk48377552017-06-22 10:45:33 -070076} // namespace broadcastradio
77} // namespace hardware
78} // namespace android
79
Tomasz Wasilczyk8c34c812018-02-08 13:42:31 -080080#endif // ANDROID_HARDWARE_BROADCASTRADIO_V1_1_VIRTUALRADIO_H