libdvbpsi  1.3.0
sis.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * sis.h
00003  * Copyright (c) 2010-2011 VideoLAN
00004  * $Id$
00005  *
00006  * Authors: Jean-Paul Saman <jpsaman@videolan.org>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  *
00022  *****************************************************************************/
00023 
00033 #ifndef _DVBPSI_SIS_H_
00034 #define _DVBPSI_SIS_H_
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 /*****************************************************************************
00041  * dvbpsi_sis_t
00042  *****************************************************************************/
00054 typedef struct dvbpsi_sis_s
00055 {
00056   /* section */
00057   uint8_t                   i_table_id;         
00058   uint16_t                  i_extension;        
00060   uint16_t                  i_ts_id;            
00061   uint8_t                   i_version;          
00062   uint8_t                   i_protocol_version; 
00064   bool                      b_current_next;     
00066   /* encryption */
00067   bool                      b_encrypted_packet;     
00069   uint8_t                   i_encryption_algorithm; 
00072   uint64_t                  i_pts_adjustment;       
00073   uint8_t                   cw_index;               
00075   /* splice command */
00076   uint16_t                  i_splice_command_length;
00077   uint8_t                   i_splice_command_type;  
00079   /* Splice Command:
00080    * splice_command_type     splice_info_section
00081    *    0x00                    splice_null()
00082    *    0x01                    reserved
00083    *    0x02                    reserved
00084    *    0x03                    reserved
00085    *    0x04                    splice_schedule()
00086    *    0x05                    splice_insert()
00087    *    0x06                    time_signal()
00088    *    0x07                    bandwidth_reservation()
00089    *    0x08 - 0xff             reserved
00090    */
00091   void                      *p_splice_command;      
00094   /* descriptors */
00095   uint16_t                  i_descriptors_length;   
00097   dvbpsi_descriptor_t       *p_first_descriptor;     
00100   /* FIXME: alignment stuffing */
00101   uint32_t i_ecrc; 
00103 } __attribute__((packed)) dvbpsi_sis_t;
00104 
00105 /*****************************************************************************
00106  * Splice Commands
00107  *****************************************************************************/
00120 typedef struct dvbpsi_sis_cmd_splice_null_s
00121 {
00122     /* nothing */
00123 } dvbpsi_sis_cmd_splice_null_t;
00124 
00133 typedef struct dvbpsi_sis_break_duration_s
00134 {
00135     bool        b_auto_return;  
00139     uint64_t    i_duration;     
00143 } dvbpsi_sis_break_duration_t;
00144 
00149 typedef struct dvbpsi_sis_component_utc_splice_time_s dvbpsi_sis_component_utc_splice_time_t;
00154 struct dvbpsi_sis_component_utc_splice_time_s
00155 {
00156     uint8_t     component_tag;      
00159     uint32_t    i_utc_splice_time;  
00165     dvbpsi_sis_component_utc_splice_time_t *p_next; 
00166 };
00167 
00176 typedef struct dvbpsi_sis_splice_event_s dvbpsi_sis_splice_event_t;
00177 struct dvbpsi_sis_splice_event_s
00178 {
00179     uint32_t        i_splice_event_id;               
00180     bool            b_splice_event_cancel_indicator; 
00182     /* if (!b_splice_event_cancel_indicator) */
00183     bool            b_out_of_network_indicator; 
00184     bool            b_program_splice_flag;      
00185     bool            b_duration_flag;            
00186     /*      if (b_program_splice_flag) */
00187     uint32_t        i_utc_splice_time;          
00192     /*      if (!b_program_splice_flag) */
00193     uint8_t         i_component_count;          
00196     dvbpsi_sis_component_utc_splice_time_t  *p_data;
00200     /*      if (b_duration_flag) */
00201     dvbpsi_sis_break_duration_t *p_break_duration;     
00203     /* */
00204 
00205     uint16_t        i_unique_program_id; 
00207     uint8_t         i_avail_num;         
00209     uint8_t         i_avails_expected;   
00211     /* end */
00212 
00213     dvbpsi_sis_splice_event_t *p_next;   
00214 };
00215 
00224 typedef struct dvbpsi_sis_cmd_splice_schedule_s
00225 {
00226     uint8_t                     i_splice_count; 
00227     dvbpsi_sis_splice_event_t  *p_splice_event; 
00228 } dvbpsi_sis_cmd_splice_schedule_t;
00229 
00238 typedef struct dvbpsi_sis_splice_time_s dvbpsi_sis_splice_time_t;
00239 struct dvbpsi_sis_splice_time_s
00240 {
00241     bool        b_time_specified_flag; 
00242     /* if (b_time_specified_flag) */
00243     uint64_t    i_pts_time;        
00246     /* else reserved */
00247     /* end */
00248 
00249     dvbpsi_sis_splice_time_t *p_next; 
00250 };
00251 
00260 typedef struct dvbpsi_sis_component_splice_time_s dvbpsi_sis_component_splice_time_t;
00261 struct dvbpsi_sis_component_splice_time_s
00262 {
00263     uint8_t     i_component_tag;    
00266     /* if (splice_immediate_flag) */
00267     dvbpsi_sis_splice_time_t *p_splice_time; 
00268     /* */
00269 
00270     dvbpsi_sis_component_splice_time_t *p_next; 
00271 };
00272 
00281 typedef struct dvbpsi_sis_cmd_splice_insert_s
00282 {
00283     uint32_t        i_splice_event_id;               
00284     bool            b_splice_event_cancel_indicator; 
00286     /* if (!b_splice_event_cancel_indicator) */
00287     bool            b_out_of_network_indicator; 
00288     bool            b_program_splice_flag;      
00289     bool            b_duration_flag;            
00290     bool            b_splice_immediate_flag;    
00292     /*      if (b_program_splice_flag) && (!b_splice_immediate_flag) */
00293     dvbpsi_sis_splice_time_t *p_splice_time;    
00295     /*      if (!b_program_splice_flag) */
00296     uint8_t         i_component_count;           
00298     dvbpsi_sis_component_splice_time_t  *p_data; 
00301     /*      if (b_duration_flag) */
00302     dvbpsi_sis_break_duration_t *p_break_duration; 
00304     /* */
00305     uint16_t        i_unique_program_id;      
00306     uint8_t         i_avail_num;              
00308     uint8_t         i_avails_expected;        
00310     /* end */
00311 } dvbpsi_sis_cmd_splice_insert_t;
00312 
00321 typedef struct dvbpsi_sis_cmd_time_signal_s
00322 {
00323     dvbpsi_sis_splice_time_t *p_splice_time;       
00324 } dvbpsi_sis_cmd_time_signal_t;
00325 
00334 typedef struct dvbpsi_sis_cmd_bandwidth_reservation_s
00335 {
00336     /* nothing */
00337 } dvbpsi_sis_cmd_bandwidth_reservation_t;
00338 
00339 /*****************************************************************************
00340  * dvbpsi_sis_callback
00341  *****************************************************************************/
00347 typedef void (* dvbpsi_sis_callback)(void* p_cb_data, dvbpsi_sis_t* p_new_sis);
00348 
00349 /*****************************************************************************
00350  * dvbpsi_sis_attach
00351  *****************************************************************************/
00364 bool dvbpsi_sis_attach(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
00365                       dvbpsi_sis_callback pf_callback, void* p_cb_data);
00366 
00367 /*****************************************************************************
00368  * dvbpsi_sis_detach
00369  *****************************************************************************/
00379 void dvbpsi_sis_detach(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension);
00380 
00381 /*****************************************************************************
00382  * dvbpsi_sis_init/dvbpsi_sis_new
00383  *****************************************************************************/
00396 void dvbpsi_sis_init(dvbpsi_sis_t *p_sis, uint8_t i_table_id, uint16_t i_extension,
00397                      uint8_t i_version, bool b_current_next, uint8_t i_protocol_version);
00398 
00410 dvbpsi_sis_t* dvbpsi_sis_new(uint8_t i_table_id, uint16_t i_extension, uint8_t i_version,
00411                              bool b_current_next, uint8_t i_protocol_version);
00412 
00413 /*****************************************************************************
00414  * dvbpsi_sis_empty/dvbpsi_sis_delete
00415  *****************************************************************************/
00422 void dvbpsi_sis_empty(dvbpsi_sis_t *p_sis);
00423 
00430 void dvbpsi_sis_delete(dvbpsi_sis_t *p_sis);
00431 
00432 /*****************************************************************************
00433  * dvbpsi_sis_descriptor_add
00434  *****************************************************************************/
00446 dvbpsi_descriptor_t *dvbpsi_sis_descriptor_add(dvbpsi_sis_t *p_sis,
00447                                              uint8_t i_tag, uint8_t i_length,
00448                                              uint8_t *p_data);
00449 
00450 /*****************************************************************************
00451  * dvbpsi_sis_sections_generate
00452  *****************************************************************************
00453  * Generate SIS sections based on the dvbpsi_sis_t structure.
00454  *****************************************************************************/
00464 dvbpsi_psi_section_t *dvbpsi_sis_sections_generate(dvbpsi_t *p_dvbpsi, dvbpsi_sis_t * p_sis);
00465 
00466 #ifdef __cplusplus
00467 };
00468 #endif
00469 
00470 #else
00471 #error "Multiple inclusions of sis.h"
00472 #endif
00473