~ubuntu-branches/ubuntu/precise/me-tv/precise-proposed

« back to all changes in this revision

Viewing changes to src/libdvben50221/en50221_app_utils.h

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Kern
  • Date: 2008-07-23 14:03:56 UTC
  • mfrom: (1.1.3 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080723140356-m6ze7fbkydes42c7
Tags: 0.5.33-3
Fix xine-lib ffmpeg dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    en50221 encoder An implementation for libdvb
3
 
    an implementation for the en50221 transport layer
4
 
 
5
 
    Copyright (C) 2004, 2005 Manu Abraham <abraham.manu@gmail.com>
6
 
    Copyright (C) 2005 Julian Scheel (julian at jusst dot de)
7
 
    Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
8
 
 
9
 
    This library is free software; you can redistribute it and/or modify
10
 
    it under the terms of the GNU Lesser General Public License as
11
 
    published by the Free Software Foundation; either version 2.1 of
12
 
    the License, or (at your option) any later version.
13
 
 
14
 
    This program is distributed in the hope that it will be useful,
15
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
    GNU Lesser General Public License for more details.
18
 
 
19
 
    You should have received a copy of the GNU Lesser General Public
20
 
    License along with this library; if not, write to the Free Software
21
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22
 
*/
23
 
 
24
 
#ifndef __EN50221_APP_UTILS_H__
25
 
#define __EN50221_APP_UTILS_H__
26
 
 
27
 
#ifdef __cplusplus
28
 
extern "C" {
29
 
#endif
30
 
 
31
 
#include <stdlib.h>
32
 
#include <stdint.h>
33
 
#include <sys/uio.h>
34
 
 
35
 
/**
36
 
 * A decomposed public resource structure.
37
 
 *
38
 
 * we will ignore private resource (resource_id_type==3),
39
 
 * because they are not used by any modules at all and
40
 
 * would need special code for any private resource anyway.
41
 
 */
42
 
struct en50221_app_public_resource_id {
43
 
        uint16_t resource_class;
44
 
        uint16_t resource_type;
45
 
        uint8_t resource_version;
46
 
};
47
 
 
48
 
typedef int (*en50221_send_data) (void *arg,
49
 
                                  uint16_t session_number,
50
 
                                  uint8_t * data,
51
 
                                  uint16_t data_length);
52
 
typedef int (*en50221_send_datav) (void *arg,
53
 
                                   uint16_t session_number,
54
 
                                   struct iovec * vector,
55
 
                                   int iov_count);
56
 
 
57
 
/**
58
 
 * An abstraction away from hardcoded send functions so different layers may be
59
 
 * slotted in under the application layer.
60
 
 */
61
 
struct en50221_app_send_functions {
62
 
        /**
63
 
         * Argument to pass to these functions.
64
 
         */
65
 
        void *arg;
66
 
 
67
 
        /**
68
 
         * Send data.
69
 
         */
70
 
        en50221_send_data send_data;
71
 
 
72
 
        /**
73
 
         * Send vector data.
74
 
         */
75
 
        en50221_send_datav send_datav;
76
 
};
77
 
 
78
 
/**
79
 
 * Make a host-endian uint32_t formatted resource id.
80
 
 *
81
 
 * @param CLASS Class of resource.
82
 
 * @param TYPE Type of resource.
83
 
 * @param VERSION Version of resource.
84
 
 * @return Formatted resource id.
85
 
 */
86
 
#define MKRID(CLASS, TYPE, VERSION) ((((CLASS)&0xffff)<<16) | (((TYPE)&0x3ff)<<6) | ((VERSION)&0x3f))
87
 
 
88
 
/**
89
 
 * Decode a host-endian public resource_id into an en50221_app_public_resource_id structure.
90
 
 *
91
 
 * @param idf Structure to write decoded resource_id into.
92
 
 * @param resource_id ID to decode.
93
 
 * @return Pointer to idf on success, or NULL if this is not a public resource.
94
 
 */
95
 
struct en50221_app_public_resource_id *
96
 
        en50221_app_decode_public_resource_id(struct en50221_app_public_resource_id *idf,
97
 
                                              uint32_t resource_id);
98
 
 
99
 
/**
100
 
 * Encode an en50221_app_public_resource_id structure into a host-endian uint32_t.
101
 
 *
102
 
 * @param idf Structure to encode.
103
 
 * @return The encoded value
104
 
 */
105
 
static inline uint32_t en50221_app_encode_public_resource_id(struct en50221_app_public_resource_id *idf) {
106
 
        return MKRID(idf->resource_class, idf->resource_type, idf->resource_version);
107
 
}
108
 
 
109
 
#ifdef __cplusplus
110
 
}
111
 
#endif
112
 
#endif