86cbb9692ed82389ef2ca5f3be935fba85a3ebf3
[melted] / src / framework / mlt_service.h
1 /**
2 * \file mlt_service.h
3 * \brief interface declaration for all service classes
4 *
5 * Copyright (C) 2003-2008 Ushodaya Enterprises Limited
6 * \author Charles Yates <charles.yates@pandora.be>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23 #ifndef _MLT_SERVICE_H_
24 #define _MLT_SERVICE_H_
25
26 #include "mlt_properties.h"
27 #include "mlt_profile.h"
28
29 /** \brief Service abstract base class
30 *
31 * \extends mlt_properties
32 * The service is the base class for all of the interesting classes and
33 * plugins for MLT. A service can have multiple inputs connections to
34 * other services called its "producers" but only a single output to another
35 * service called its "consumer." A service that has both producer and
36 * consumer connections is called a filter. Any service can have zero or more
37 * filters "attached" to it. We call any collection of services and their
38 * connections a "service network," which is similar to what DirectShow calls
39 * a filter graph or what gstreamer calls an element pipeline.
40 *
41 * \event \em service-changed
42 * \event \em property-changed
43 * \properties \em mlt_type identifies the subclass
44 * \properties \em resource is either the stream identifier or grandchild-class
45 * \properties \em in when to start, what is started is service-specific
46 * \properties \em out when to stop
47 * \properties \em _filter_private Set this on a service to ensure that attached filters are handled privately.
48 * See modules/core/filter_region.c and modules/core/filter_watermark.c for examples.
49 * \properties \em disable Set this on a filter to disable it while keeping it in the object model.
50 * \properties \em _profile stores the mlt_profile for a service
51 */
52
53 struct mlt_service_s
54 {
55 struct mlt_properties_s parent; /**< \private */
56
57 /** Get a frame of data (virtual function).
58 *
59 * \param mlt_producer a producer
60 * \param mlt_frame_ptr a frame pointer by reference
61 * \param int an index
62 * \return true if there was an error
63 */
64 int ( *get_frame )( mlt_service self, mlt_frame_ptr frame, int index );
65
66 /** the destructor virtual function */
67 mlt_destructor close;
68 void *close_object; /**< the object supplied to the close virtual function */
69
70 void *local; /**< \private instance object */
71 void *child; /**< \private the object of a subclass */
72 };
73
74 #define MLT_SERVICE_PROPERTIES( service ) ( &( service )->parent )
75
76 extern int mlt_service_init( mlt_service self, void *child );
77 extern void mlt_service_lock( mlt_service self );
78 extern void mlt_service_unlock( mlt_service self );
79 extern mlt_service_type mlt_service_identify( mlt_service self );
80 extern int mlt_service_connect_producer( mlt_service self, mlt_service producer, int index );
81 extern mlt_service mlt_service_get_producer( mlt_service self );
82 extern int mlt_service_get_frame( mlt_service self, mlt_frame_ptr frame, int index );
83 extern mlt_properties mlt_service_properties( mlt_service self );
84 extern mlt_service mlt_service_consumer( mlt_service self );
85 extern mlt_service mlt_service_producer( mlt_service self );
86 extern int mlt_service_attach( mlt_service self, mlt_filter filter );
87 extern int mlt_service_detach( mlt_service self, mlt_filter filter );
88 extern void mlt_service_apply_filters( mlt_service self, mlt_frame frame, int index );
89 extern mlt_filter mlt_service_filter( mlt_service self, int index );
90 extern mlt_profile mlt_service_profile( mlt_service self );
91 extern void mlt_service_close( mlt_service self );
92
93 #endif
94