xref: /linux/drivers/media/test-drivers/vidtv/vidtv_channel.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
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
5  * applications.
6  *
7  * This file contains the code for a 'channel' abstraction.
8  *
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
17  *
18  *
19  * Copyright (C) 2020 Daniel W. S. Almeida
20  */
21 
22 #ifndef VIDTV_CHANNEL_H
23 #define VIDTV_CHANNEL_H
24 
25 #include <linux/types.h>
26 
27 #include "vidtv_encoder.h"
28 #include "vidtv_mux.h"
29 #include "vidtv_psi.h"
30 
31 /**
32  * struct vidtv_channel - A 'channel' abstraction
33  *
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
41  *
42  * @name: name of the channel
43  * @transport_stream_id: a number to identify the TS, chosen at will.
44  * @service: A _single_ service. Will be concatenated into the SDT.
45  * @program_num: The link between PAT, PMT and SDT.
46  * @program: A _single_ program with one or more streams associated with it.
47  * Will be concatenated into the PAT.
48  * @streams: A stream loop used to populate the PMT section for 'program'
49  * @encoders: A encoder loop. There must be one encoder for each stream.
50  * @events: Optional event information. This will feed into the EIT.
51  * @next: Optionally chain this channel.
52  */
53 struct vidtv_channel {
54 	char *name;
55 	u16 transport_stream_id;
56 	struct vidtv_psi_table_sdt_service *service;
57 	u16 program_num;
58 	struct vidtv_psi_table_pat_program *program;
59 	struct vidtv_psi_table_pmt_stream *streams;
60 	struct vidtv_encoder *encoders;
61 	struct vidtv_psi_table_eit_event *events;
62 	struct vidtv_channel *next;
63 };
64 
65 /**
66  * vidtv_channel_si_init - Init the PSI tables from the channels in the mux
67  * @m: The mux containing the channels.
68  */
69 int vidtv_channel_si_init(struct vidtv_mux *m);
70 void vidtv_channel_si_destroy(struct vidtv_mux *m);
71 
72 /**
73  * vidtv_channels_init - Init hardcoded, fake 'channels'.
74  * @m: The mux to store the channels into.
75  */
76 int vidtv_channels_init(struct vidtv_mux *m);
77 struct vidtv_channel
78 *vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream_id);
79 void vidtv_channels_destroy(struct vidtv_mux *m);
80 
81 #endif //VIDTV_CHANNEL_H
82