/*
	A SI parser implementation for libdvb
	an implementation for the High Level Common Interface

	Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)

	This library is free software; you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as
	published by the Free Software Foundation; either version 2.1 of
	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public
	License along with this library; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
*/

#ifndef __DESCRIPTOR_H__
#define __DESCRIPTOR_H__

#include <stdlib.h>
#include <stdint.h>
#include "pmt.h"

#define MAX_DESCRIPTOR		20

// tag = 0x09
struct ca_descriptor {
	unsigned descriptor_tag: 8;
	unsigned descriptor_length: 8;
	unsigned ca_system_id: 16;
	unsigned reserved: 3;
	unsigned ca_pid: 13;

	uint8_t *p_private_data_byte;
};

struct descriptor_info {
	unsigned descriptor_tag: 8;
	unsigned descriptor_length: 8;
};


uint8_t parse_descriptor_info(struct descriptor_info *p_descr_info, uint8_t *buf, uint16_t pos);
uint16_t parse_ca_descriptor(struct ca_descriptor *p_descriptor, uint8_t *buf, uint16_t pos);
void *allocate_descriptor_storage(struct descriptor_info *p_descriptor_info);
uint16_t parse_descriptor(void *p_descr, struct descriptor_info *p_descriptor_info, uint8_t *buf, uint16_t pos);


#endif
