Fix up a few ignored return values
[melted] / src / framework / mlt_consumer.h
1 /**
2 * \file mlt_consumer.h
3 * \brief abstraction for all consumer services
4 * \see mlt_consumer_s
5 *
6 * Copyright (C) 2003-2009 Ushodaya Enterprises Limited
7 * \author Charles Yates <charles.yates@pandora.be>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library 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 GNU
17 * 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 _MLT_CONSUMER_H_
25 #define _MLT_CONSUMER_H_
26
27 #include "mlt_service.h"
28 #include "mlt_events.h"
29 #include <pthread.h>
30
31 /** \brief Consumer abstract service class
32 *
33 * A consumer is a service that pulls audio and video from the connected
34 * producers, filters, and transitions. Typically a consumer is used to
35 * output audio and/or video to a device, file, or socket.
36 *
37 * \extends mlt_service_s
38 * \properties \em rescale the scaling algorithm to pass on to all scaling
39 * filters, defaults to "bilinear"
40 * \properties \em buffer the number of frames to use in the asynchronous
41 * render thread, defaults to 25
42 * \properties \em frequency the audio sample rate to use in Hertz, defaults to 48000
43 * \properties \em channels the number of audio channels to use, defaults to 2
44 * \properties \em real_time the asynchronous behavior: 1 (default) for asynchronous
45 * with frame dropping, -1 for asynchronous without frame dropping, 0 to disable (synchronous)
46 * \properties \em test_card the name of a resource to use as the test card, defaults to
47 * environment variable MLT_TEST_CARD. If undefined, the hard-coded default test card is
48 * white silence. A test card is what appears when nothing is produced.
49 * \event \em consumer-frame-show Subclass implementations should fire this.
50 * \event \em consumer-frame-render The abstract class fires this.
51 * \event \em consumer-stopped
52 * \properties \em fps video frames per second as floating point (read only)
53 * \properties \em frame_rate_num the numerator of the video frame rate, overrides \p mlt_profile_s
54 * \properties \em frame_rate_den the denominator of the video frame rate, overrides \p mlt_profile_s
55 * \properties \em width the horizontal video resolution, overrides \p mlt_profile_s
56 * \properties \em height the vertical video resolution, overrides \p mlt_profile_s
57 * \properties \em progressive a flag that indicates if the video is interlaced
58 * or progressive, overrides \p mlt_profile_s
59 * \properties \em aspect_ratio the video sample (pixel) aspect ratio as floating point (read only)
60 * \properties \em sample_aspect_num the numerator of the sample aspect ratio, overrides \p mlt_profile_s
61 * \properties \em sample_aspect_den the denominator of the sample aspect ratio, overrides \p mlt_profile_s
62 * \properties \em display_ratio the video frame aspect ratio as floating point (read only)
63 * \properties \em display_aspect_num the numerator of the video frame aspect ratio, overrides \p mlt_profile_s
64 * \properties \em display_aspect_den the denominator of the video frame aspect ratio, overrides \p mlt_profile_s
65 *
66 */
67
68 struct mlt_consumer_s
69 {
70 /** A consumer is a service. */
71 struct mlt_service_s parent;
72
73 /** Start the consumer to pull frames (virtual function).
74 *
75 * \param mlt_consumer a consumer
76 * \return true if there was an error
77 */
78 int ( *start )( mlt_consumer );
79
80 /** Stop the consumer (virtual function).
81 *
82 * \param mlt_consumer a consumer
83 * \return true if there was an error
84 */
85 int ( *stop )( mlt_consumer );
86
87 /** Get whether the consumer is running or stopped (virtual function).
88 *
89 * \param mlt_consumer a consumer
90 * \return true if the consumer is stopped
91 */
92 int ( *is_stopped )( mlt_consumer );
93
94 /** The destructor virtual function
95 *
96 * \param mlt_consumer a consumer
97 */
98 void ( *close )( mlt_consumer );
99
100 void *local; /**< \private instance object */
101 void *child; /**< \private the object of a subclass */
102
103 int real_time;
104 int ahead;
105 mlt_image_format format;
106 mlt_deque queue;
107 pthread_t ahead_thread;
108 pthread_mutex_t mutex;
109 pthread_cond_t cond;
110 pthread_mutex_t put_mutex;
111 pthread_cond_t put_cond;
112 mlt_frame put;
113 int put_active;
114 mlt_event event_listener;
115 };
116
117 #define MLT_CONSUMER_SERVICE( consumer ) ( &( consumer )->parent )
118 #define MLT_CONSUMER_PROPERTIES( consumer ) MLT_SERVICE_PROPERTIES( MLT_CONSUMER_SERVICE( consumer ) )
119
120 extern int mlt_consumer_init( mlt_consumer self, void *child, mlt_profile profile );
121 extern mlt_consumer mlt_consumer_new( mlt_profile profile );
122 extern mlt_service mlt_consumer_service( mlt_consumer self );
123 extern mlt_properties mlt_consumer_properties( mlt_consumer self );
124 extern int mlt_consumer_connect( mlt_consumer self, mlt_service producer );
125 extern int mlt_consumer_start( mlt_consumer self );
126 extern void mlt_consumer_purge( mlt_consumer self );
127 extern int mlt_consumer_put_frame( mlt_consumer self, mlt_frame frame );
128 extern mlt_frame mlt_consumer_get_frame( mlt_consumer self );
129 extern mlt_frame mlt_consumer_rt_frame( mlt_consumer self );
130 extern int mlt_consumer_stop( mlt_consumer self );
131 extern int mlt_consumer_is_stopped( mlt_consumer self );
132 extern void mlt_consumer_stopped( mlt_consumer self );
133 extern void mlt_consumer_close( mlt_consumer );
134
135 #endif