18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Vidtv serves as a reference DVB driver and helps validate the existing APIs 48c2ecf20Sopenharmony_ci * in the media subsystem. It can also aid developers working on userspace 58c2ecf20Sopenharmony_ci * applications. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * This file contains the code for a 'channel' abstraction. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * When vidtv boots, it will create some hardcoded channels. 108c2ecf20Sopenharmony_ci * Their services will be concatenated to populate the SDT. 118c2ecf20Sopenharmony_ci * Their programs will be concatenated to populate the PAT 128c2ecf20Sopenharmony_ci * Their events will be concatenated to populate the EIT 138c2ecf20Sopenharmony_ci * For each program in the PAT, a PMT section will be created 148c2ecf20Sopenharmony_ci * The PMT section for a channel will be assigned its streams. 158c2ecf20Sopenharmony_ci * Every stream will have its corresponding encoder polled to produce TS packets 168c2ecf20Sopenharmony_ci * These packets may be interleaved by the mux and then delivered to the bridge 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * Copyright (C) 2020 Daniel W. S. Almeida 208c2ecf20Sopenharmony_ci */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#ifndef VIDTV_CHANNEL_H 238c2ecf20Sopenharmony_ci#define VIDTV_CHANNEL_H 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#include <linux/types.h> 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include "vidtv_encoder.h" 288c2ecf20Sopenharmony_ci#include "vidtv_mux.h" 298c2ecf20Sopenharmony_ci#include "vidtv_psi.h" 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/** 328c2ecf20Sopenharmony_ci * struct vidtv_channel - A 'channel' abstraction 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * When vidtv boots, it will create some hardcoded channels. 358c2ecf20Sopenharmony_ci * Their services will be concatenated to populate the SDT. 368c2ecf20Sopenharmony_ci * Their programs will be concatenated to populate the PAT 378c2ecf20Sopenharmony_ci * For each program in the PAT, a PMT section will be created 388c2ecf20Sopenharmony_ci * The PMT section for a channel will be assigned its streams. 398c2ecf20Sopenharmony_ci * Every stream will have its corresponding encoder polled to produce TS packets 408c2ecf20Sopenharmony_ci * These packets may be interleaved by the mux and then delivered to the bridge 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * @name: name of the channel 438c2ecf20Sopenharmony_ci * @transport_stream_id: a number to identify the TS, chosen at will. 448c2ecf20Sopenharmony_ci * @service: A _single_ service. Will be concatenated into the SDT. 458c2ecf20Sopenharmony_ci * @program_num: The link between PAT, PMT and SDT. 468c2ecf20Sopenharmony_ci * @program: A _single_ program with one or more streams associated with it. 478c2ecf20Sopenharmony_ci * Will be concatenated into the PAT. 488c2ecf20Sopenharmony_ci * @streams: A stream loop used to populate the PMT section for 'program' 498c2ecf20Sopenharmony_ci * @encoders: A encoder loop. There must be one encoder for each stream. 508c2ecf20Sopenharmony_ci * @events: Optional event information. This will feed into the EIT. 518c2ecf20Sopenharmony_ci * @next: Optionally chain this channel. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_cistruct vidtv_channel { 548c2ecf20Sopenharmony_ci char *name; 558c2ecf20Sopenharmony_ci u16 transport_stream_id; 568c2ecf20Sopenharmony_ci struct vidtv_psi_table_sdt_service *service; 578c2ecf20Sopenharmony_ci u16 program_num; 588c2ecf20Sopenharmony_ci struct vidtv_psi_table_pat_program *program; 598c2ecf20Sopenharmony_ci struct vidtv_psi_table_pmt_stream *streams; 608c2ecf20Sopenharmony_ci struct vidtv_encoder *encoders; 618c2ecf20Sopenharmony_ci struct vidtv_psi_table_eit_event *events; 628c2ecf20Sopenharmony_ci struct vidtv_channel *next; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/** 668c2ecf20Sopenharmony_ci * vidtv_channel_si_init - Init the PSI tables from the channels in the mux 678c2ecf20Sopenharmony_ci * @m: The mux containing the channels. 688c2ecf20Sopenharmony_ci */ 698c2ecf20Sopenharmony_ciint vidtv_channel_si_init(struct vidtv_mux *m); 708c2ecf20Sopenharmony_civoid vidtv_channel_si_destroy(struct vidtv_mux *m); 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/** 738c2ecf20Sopenharmony_ci * vidtv_channels_init - Init hardcoded, fake 'channels'. 748c2ecf20Sopenharmony_ci * @m: The mux to store the channels into. 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_ciint vidtv_channels_init(struct vidtv_mux *m); 778c2ecf20Sopenharmony_cistruct vidtv_channel 788c2ecf20Sopenharmony_ci*vidtv_channel_s302m_init(struct vidtv_channel *head, u16 transport_stream_id); 798c2ecf20Sopenharmony_civoid vidtv_channels_destroy(struct vidtv_mux *m); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#endif //VIDTV_CHANNEL_H 82