1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | #ifndef VC_PACKETIZERS_PRIVATE_H |
28 | #define VC_PACKETIZERS_PRIVATE_H |
29 | |
30 | /** \file |
31 | * Private interface for packetizers |
32 | */ |
33 | |
34 | #include <stdarg.h> |
35 | #include "containers/packetizers.h" |
36 | #include "containers/core/containers_common.h" |
37 | #include "containers/core/containers_bytestream.h" |
38 | #include "containers/core/containers_time.h" |
39 | |
40 | /** \defgroup VcPacketizerModuleApi Packetizer Module API |
41 | * Private interface for modules implementing packetizers */ |
42 | /* @{ */ |
43 | |
44 | /** Context private to the packetizer instance. This private context is used to |
45 | * store data which shouldn't be exported by the public API. */ |
46 | typedef struct VC_PACKETIZER_PRIVATE_T |
47 | { |
48 | /** Pointer to the private data of the packetizer module in use */ |
49 | struct VC_PACKETIZER_MODULE_T *module; |
50 | |
51 | /** Bytestream abstraction layer */ |
52 | struct VC_CONTAINER_BYTESTREAM_T stream; |
53 | |
54 | /** Current stream time */ |
55 | VC_CONTAINER_TIME_T time; |
56 | |
57 | /** Packetize the bytestream. |
58 | * |
59 | * \param context Pointer to the context of the instance of the packetizer |
60 | * \param out Pointer to the output packet structure which needs to be filled |
61 | * \param flags Miscellaneous flags controlling the packetizing |
62 | * \return the status of the operation |
63 | */ |
64 | VC_CONTAINER_STATUS_T (*pf_packetize)( VC_PACKETIZER_T *context, |
65 | VC_CONTAINER_PACKET_T *out, VC_PACKETIZER_FLAGS_T flags ); |
66 | |
67 | /** Reset packetizer state. |
68 | * |
69 | * \param context Pointer to the context of the instance of the packetizer |
70 | * \return the status of the operation |
71 | */ |
72 | VC_CONTAINER_STATUS_T (*pf_reset)( VC_PACKETIZER_T *context ); |
73 | |
74 | /** Closes a packetizer module. |
75 | * |
76 | * \param context Pointer to the context of the instance to close |
77 | * \return the status of the operation |
78 | */ |
79 | VC_CONTAINER_STATUS_T (*pf_close)( struct VC_PACKETIZER_T *context ); |
80 | |
81 | /** Pointer to the packetizer module code and symbols*/ |
82 | void *module_handle; |
83 | |
84 | /** Temporary packet structure used when the caller does not provide one */ |
85 | VC_CONTAINER_PACKET_T packet; |
86 | |
87 | } VC_PACKETIZER_PRIVATE_T; |
88 | |
89 | /** Structure used by packetizers to register themselves with the core. */ |
90 | typedef struct VC_PACKETIZER_REGISTRY_ENTRY_T |
91 | { |
92 | struct VC_PACKETIZER_REGISTRY_ENTRY_T *next; /**< To link entries together */ |
93 | const char *name; /**< Name of the packetizer */ |
94 | VC_CONTAINER_STATUS_T (*open)( VC_PACKETIZER_T * ); /**< Called to open packetizer */ |
95 | } VC_PACKETIZER_REGISTRY_ENTRY_T; |
96 | |
97 | /** Register a packetizer with the core. |
98 | * |
99 | * \param entry Entry to register with the core |
100 | */ |
101 | void vc_packetizer_register(VC_PACKETIZER_REGISTRY_ENTRY_T *entry); |
102 | |
103 | /** Utility macro used to register a packetizer with the core */ |
104 | #define VC_PACKETIZER_REGISTER(func, name) \ |
105 | VC_CONTAINER_CONSTRUCTOR(func##_register); \ |
106 | static VC_PACKETIZER_REGISTRY_ENTRY_T registry_entry = {0, name, func}; \ |
107 | void func##_register(void) { vc_packetizer_register(®istry_entry); } |
108 | |
109 | /* @} */ |
110 | |
111 | #endif /* VC_PACKETIZERS_PRIVATE_H */ |
112 | |