1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, 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
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON 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
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27#ifndef VC_CONTAINERS_FILTERS_H
28#define VC_CONTAINERS_FILTERS_H
29
30/** \file containers_filters.h
31 * Interface definition for the filter abstraction used by the container
32 * common layer */
33#include <stdarg.h>
34
35#include "containers/containers.h"
36
37/** \defgroup VcContainerFilterApi Container Filter API */
38/* @{ */
39
40/** Container Filter Context.
41 * This structure defines the context for a container filter instance */
42typedef struct VC_CONTAINER_FILTER_T
43{
44 /** Pointer to container instance */
45 struct VC_CONTAINER_T *container;
46 /** Pointer to information private to the container filter instance */
47 struct VC_CONTAINER_FILTER_PRIVATE_T *priv;
48 /** Pointer to information private to the container filter module */
49 struct VC_CONTAINER_FILTER_MODULE_T *module;
50
51 /** \note the following list of function pointers should not be used directly.
52 * They defines the interface for implementing container filter modules and are
53 * filled in by the container filter modules themselves. */
54
55 /** \private
56 * Function pointer to close and free all resources allocated by a
57 * container filter module */
58 VC_CONTAINER_STATUS_T (*pf_close)(struct VC_CONTAINER_FILTER_T *filter);
59
60 /** \private
61 * Function pointer to filter a data packet using a container filter module */
62 VC_CONTAINER_STATUS_T (*pf_process)(struct VC_CONTAINER_FILTER_T *filter, VC_CONTAINER_PACKET_T *p_packet);
63
64 /** \private
65 * Function pointer to control container filter module */
66 VC_CONTAINER_STATUS_T (*pf_control)( struct VC_CONTAINER_FILTER_T *filter, VC_CONTAINER_CONTROL_T operation, va_list args );
67
68} VC_CONTAINER_FILTER_T;
69
70/** Opens a container filter using a four character code describing the filter.
71 * This will create an instance of the container filter.
72 *
73 * \param filter Four Character Code describing the filter
74 * \param type Four Character Code describing the subtype - indicated whether filter is encrypt or decrypt
75 * \param container Pointer to the container instance
76 * \param status Returns the status of the operation
77 * \return If successful, this returns a pointer to the new instance
78 * of the container filter. Returns NULL on failure.
79 */
80VC_CONTAINER_FILTER_T *vc_container_filter_open(VC_CONTAINER_FOURCC_T filter,
81 VC_CONTAINER_FOURCC_T type,
82 VC_CONTAINER_T *container,
83 VC_CONTAINER_STATUS_T *status );
84
85/** Closes an instance of a container filter.
86 * \param context Pointer to the VC_CONTAINER_FILTER_T context of the instance to close
87 * \return VC_CONTAINER_SUCCESS on success.
88 */
89VC_CONTAINER_STATUS_T vc_container_filter_close( VC_CONTAINER_FILTER_T *context );
90
91/** Filter a data packet using a container filter module.
92 * \param context Pointer to the VC_CONTAINER_FILTER_T instance to use
93 * \param packet Pointer to the VC_CONTAINER_PACKET_T structure to process
94 * \return the status of the operation
95 */
96VC_CONTAINER_STATUS_T vc_container_filter_process(VC_CONTAINER_FILTER_T *context, VC_CONTAINER_PACKET_T *p_packet);
97
98/** Extensible control function for container filter modules.
99* This function takes a variable number of arguments which will depend on the specific operation.
100*
101* \param context Pointer to the VC_CONTAINER_FILTER_T instance to use
102* \param operation The requested operation
103* \param args Arguments for the operation
104* \return the status of the operation
105*/
106VC_CONTAINER_STATUS_T vc_container_filter_control(VC_CONTAINER_FILTER_T *context, VC_CONTAINER_CONTROL_T operation, ... );
107
108/* @} */
109
110#endif /* VC_CONTAINERS_FILTERS_H */
111