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