1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Vidtv serves as a reference DVB driver and helps validate the existing APIs
4 * in the media subsystem. It can also aid developers working on userspace
7 * This file contains the code for a 'channel' abstraction.
9 * When vidtv boots, it will create some hardcoded channels.
10 * Their services will be concatenated to populate the SDT.
11 * Their programs will be concatenated to populate the PAT
12 * Their events will be concatenated to populate the EIT
13 * For each program in the PAT, a PMT section will be created
14 * The PMT section for a channel will be assigned its streams.
15 * Every stream will have its corresponding encoder polled to produce TS packets
16 * These packets may be interleaved by the mux and then delivered to the bridge
19 * Copyright (C) 2020 Daniel W. S. Almeida
22 #ifndef VIDTV_CHANNEL_H
23 #define VIDTV_CHANNEL_H
25 #include <linux/types.h>
27 #include "vidtv_encoder.h"
28 #include "vidtv_mux.h"
29 #include "vidtv_psi.h"
32 * struct vidtv_channel - A 'channel' abstraction
34 * When vidtv boots, it will create some hardcoded channels.
35 * Their services will be concatenated to populate the SDT.
36 * Their programs will be concatenated to populate the PAT
37 * For each program in the PAT, a PMT section will be created
38 * The PMT section for a channel will be assigned its streams.
39 * Every stream will have its corresponding encoder polled to produce TS packets
40 * These packets may be interleaved by the mux and then delivered to the bridge
42 * @transport_stream_id: a number to identify the TS, chosen at will.
43 * @service: A _single_ service. Will be concatenated into the SDT.
44 * @program_num: The link between PAT, PMT and SDT.
45 * @program: A _single_ program with one or more streams associated with it.
46 * Will be concatenated into the PAT.
47 * @streams: A stream loop used to populate the PMT section for 'program'
48 * @encoders: A encoder loop. There must be one encoder for each stream.
49 * @events: Optional event information. This will feed into the EIT.
50 * @next: Optionally chain this channel.
52 struct vidtv_channel {
54 u16 transport_stream_id;
55 struct vidtv_psi_table_sdt_service *service;
57 struct vidtv_psi_table_pat_program *program;
58 struct vidtv_psi_table_pmt_stream *streams;
59 struct vidtv_encoder *encoders;
60 struct vidtv_psi_table_eit_event *events;
61 struct vidtv_channel *next;
65 * vidtv_channel_si_init - Init the PSI tables from the channels in the mux
66 * @m: The mux containing the channels.
68 int vidtv_channel_si_init(struct vidtv_mux *m);
69 void vidtv_channel_si_destroy(struct vidtv_mux *m);
72 * vidtv_channels_init - Init hardcoded, fake 'channels'.
73 * @m: The mux to store the channels into.
75 int vidtv_channels_init(struct vidtv_mux *m);
77 *vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream_id);
78 void vidtv_channels_destroy(struct vidtv_mux *m);
80 #endif //VIDTV_CHANNEL_H