Fix up warnings about explicit base initializers in copy constructors
[melted] / mlt++ / src / MltConsumer.cpp
1 /**
2 * MltConsumer.cpp - MLT Wrapper
3 * Copyright (C) 2004-2005 Charles Yates
4 * Author: Charles Yates <charles.yates@pandora.be>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21 #include <stdlib.h>
22 #include <string.h>
23 #include "MltConsumer.h"
24 #include "MltEvent.h"
25 #include "MltProfile.h"
26 using namespace Mlt;
27
28 Consumer::Consumer( ) :
29 instance( NULL )
30 {
31 instance = mlt_factory_consumer( NULL, NULL, NULL );
32 }
33
34 Consumer::Consumer( Profile& profile ) :
35 instance( NULL )
36 {
37 instance = mlt_factory_consumer( profile.get_profile(), NULL, NULL );
38 }
39
40 Consumer::Consumer( Profile& profile, char *id, char *arg ) :
41 instance( NULL )
42 {
43 if ( id == NULL || arg != NULL )
44 {
45 instance = mlt_factory_consumer( profile.get_profile(), id, arg );
46 }
47 else
48 {
49 if ( strchr( id, ':' ) )
50 {
51 char *temp = strdup( id );
52 char *arg = strchr( temp, ':' ) + 1;
53 *( arg - 1 ) = '\0';
54 instance = mlt_factory_consumer( profile.get_profile(), temp, arg );
55 free( temp );
56 }
57 else
58 {
59 instance = mlt_factory_consumer( profile.get_profile(), id, NULL );
60 }
61 }
62 }
63
64 Consumer::Consumer( Service &consumer ) :
65 instance( NULL )
66 {
67 if ( consumer.type( ) == consumer_type )
68 {
69 instance = ( mlt_consumer )consumer.get_service( );
70 inc_ref( );
71 }
72 }
73
74 Consumer::Consumer( Consumer &consumer ) :
75 Mlt::Service( consumer ),
76 instance( consumer.get_consumer( ) )
77 {
78 inc_ref( );
79 }
80
81 Consumer::Consumer( mlt_consumer consumer ) :
82 instance( consumer )
83 {
84 inc_ref( );
85 }
86
87 Consumer::~Consumer( )
88 {
89 mlt_consumer_close( instance );
90 }
91
92 mlt_consumer Consumer::get_consumer( )
93 {
94 return instance;
95 }
96
97 mlt_service Consumer::get_service( )
98 {
99 return mlt_consumer_service( get_consumer( ) );
100 }
101
102 int Consumer::connect( Service &service )
103 {
104 return connect_producer( service );
105 }
106
107 int Consumer::start( )
108 {
109 return mlt_consumer_start( get_consumer( ) );
110 }
111
112 void Consumer::purge( )
113 {
114 mlt_consumer_purge( get_consumer( ) );
115 }
116
117 int Consumer::stop( )
118 {
119 return mlt_consumer_stop( get_consumer( ) );
120 }
121
122 bool Consumer::is_stopped( )
123 {
124 return mlt_consumer_is_stopped( get_consumer( ) ) != 0;
125 }
126
127 int Consumer::run( )
128 {
129 int ret = start( );
130 if ( !is_stopped( ) )
131 {
132 Event *e = setup_wait_for( "consumer-stopped" );
133 wait_for( e );
134 delete e;
135 }
136 return ret;
137 }