Browse Source

Added KDE3 version of MLT++

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/mlt++@1095629 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
tags/v3.5.13
tpearson 10 years ago
commit
f807055abb
76 changed files with 6462 additions and 0 deletions
  1. +8
    -0
      AUTHORS
  2. +381
    -0
      CUSTOMISING
  3. +473
    -0
      HOWTO
  4. +165
    -0
      LGPL
  5. +10
    -0
      Makefile
  6. +135
    -0
      README
  7. +8
    -0
      config.mak
  8. +21
    -0
      mlt++.sln
  9. +265
    -0
      mlt++.vcproj
  10. +61
    -0
      src/Makefile
  11. +50
    -0
      src/Mlt.h
  12. +129
    -0
      src/MltConsumer.cpp
  13. +56
    -0
      src/MltConsumer.h
  14. +68
    -0
      src/MltDeque.cpp
  15. +47
    -0
      src/MltDeque.h
  16. +61
    -0
      src/MltEvent.cpp
  17. +46
    -0
      src/MltEvent.h
  18. +75
    -0
      src/MltFactory.cpp
  19. +57
    -0
      src/MltFactory.h
  20. +63
    -0
      src/MltField.cpp
  21. +52
    -0
      src/MltField.h
  22. +111
    -0
      src/MltFilter.cpp
  23. +54
    -0
      src/MltFilter.h
  24. +118
    -0
      src/MltFilteredConsumer.cpp
  25. +52
    -0
      src/MltFilteredConsumer.h
  26. +86
    -0
      src/MltFilteredProducer.cpp
  27. +49
    -0
      src/MltFilteredProducer.h
  28. +89
    -0
      src/MltFrame.cpp
  29. +52
    -0
      src/MltFrame.h
  30. +100
    -0
      src/MltGeometry.cpp
  31. +80
    -0
      src/MltGeometry.h
  32. +157
    -0
      src/MltMiracle.cpp
  33. +58
    -0
      src/MltMiracle.h
  34. +85
    -0
      src/MltMultitrack.cpp
  35. +55
    -0
      src/MltMultitrack.h
  36. +284
    -0
      src/MltParser.cpp
  37. +68
    -0
      src/MltParser.h
  38. +314
    -0
      src/MltPlaylist.cpp
  39. +108
    -0
      src/MltPlaylist.h
  40. +191
    -0
      src/MltProducer.cpp
  41. +72
    -0
      src/MltProducer.h
  42. +261
    -0
      src/MltProperties.cpp
  43. +88
    -0
      src/MltProperties.h
  44. +146
    -0
      src/MltPushConsumer.cpp
  45. +50
    -0
      src/MltPushConsumer.h
  46. +72
    -0
      src/MltResponse.cpp
  47. +45
    -0
      src/MltResponse.h
  48. +115
    -0
      src/MltService.cpp
  49. +61
    -0
      src/MltService.h
  50. +56
    -0
      src/MltTokeniser.cpp
  51. +45
    -0
      src/MltTokeniser.h
  52. +158
    -0
      src/MltTractor.cpp
  53. +66
    -0
      src/MltTractor.h
  54. +90
    -0
      src/MltTransition.cpp
  55. +49
    -0
      src/MltTransition.h
  56. +34
    -0
      src/config.h
  57. +10
    -0
      swig/Makefile
  58. +42
    -0
      swig/configure
  59. +51
    -0
      swig/java/Play.java
  60. +2
    -0
      swig/java/Play.sh
  61. +34
    -0
      swig/java/build
  62. +142
    -0
      swig/mltpp.i
  63. +16
    -0
      swig/perl/Makefile.PL
  64. +3
    -0
      swig/perl/build
  65. +43
    -0
      swig/perl/play.pl
  66. +25
    -0
      swig/python/build
  67. +33
    -0
      swig/python/play.py
  68. +8
    -0
      swig/ruby/build
  69. +17
    -0
      swig/ruby/miracle.rb
  70. +38
    -0
      swig/ruby/play.rb
  71. +38
    -0
      swig/ruby/thumbs.rb
  72. +21
    -0
      swig/tcl/build
  73. +17
    -0
      swig/tcl/play.tcl
  74. +25
    -0
      test/Makefile
  75. +14
    -0
      test/play.cpp
  76. +133
    -0
      test/server.cpp

+ 8
- 0
AUTHORS View File

@@ -0,0 +1,8 @@
MLT was developed by:

Charles Yates <charles.yates@pandora.be>
Dan Dennedy <dan@dennedy.org>

MLT++ was developed by

Charles Yates <charles.yates@pandora.be>

+ 381
- 0
CUSTOMISING View File

@@ -0,0 +1,381 @@
Server Customisation

Copyright (C) 2005 Ushodaya Enterprises Limited
Authors: Charles Yates <charles.yates@pandora.be>
Last Revision: 2005-03-16


INTRODUCTION

This document describes how miracle can be customised. The emphasis is on
showing simple examples of various aspects of the servers capabilities
rather than on focussing on the MLT++ API.


THE BASIC CUSTOM SERVER

The most basic custom server exposes the entire DVCP protocol and is roughly
equivalent to the miracle server iteself, but in this case, it lacks the
initialisation from /etc/miracle.conf and the port is hardcoded to 5290:

#include <iostream.h>
using namespace std;

#include <MltMiracle.h>
using namespace Mlt;
int main( int argc, char **argv )
{
Miracle server( "miracle++", 5290 );
if ( server.start( ) )
{
server.execute( "uadd sdl" );
server.execute( "play u0" );
server.wait_for_shutdown( );
}
else
{
cerr << "Failed to start server" << endl;
}
return 0;
}

Note that after the server is started, this example submits the hard coded
commands specified - further units and property settings can of course be
specified via the DVCP protocol.

To specify initial DVCP commands from /etc/miracle.conf, it is sufficient to
specify an additional argument in the server constructor.

The wait_for_shutdown call is not required if the server is integrated in
a user interface application.


CUSTOMISATION

This document focusses on the following areas of customisation:

* the Miracle server class
* extending the command set
* accessing the units
* the Response object
* handling pushed westley documents
* accessiving events


THE MIRACLE SERVER CLASS

The full public interface of the server is as follows:

class Miracle : public Properties
{
public:
Miracle( char *name, int port = 5290, char *config = NULL );
virtual ~Miracle( );
mlt_properties get_properties( );
bool start( );
bool is_running( );
virtual Response *execute( char *command );
virtual Response *received( char *command, char *doc );
virtual Response *push( char *command, Service *service );
void wait_for_shutdown( );
static void log_level( int );
Properties *unit( int );
};

The focus of this document is on the 3 virtual methods (execute, received and
push). Some further information is provided about the unit properties method
and the types of functionality that it provides.


EXTENDING THE COMMAND SET

The simplest customisation is carried out by overriding the the 'execute'
method - the following shows a simple example:

#include <iostream.h>
#include <string>
#include <sstring>
using namespace std;

#include <MltMiracle.h>
#include <MltResponse.h>
using namespace Mlt;

class Custom :
public Miracle
{
public:
Custom( char *name = "Custom", int port = 5290, char *config = NULL ) :
Miracle( name, port, config )
{
}

Response *execute( char *command )
{
cerr << "command = " << command << endl;
return Miracle::execute( command );
}
};
int main( int argc, char **argv )
{
Custom server( "miracle++", 5290 );
if ( server.start( ) )
{
server.execute( "uadd sdl" );
server.execute( "play u0" );
server.wait_for_shutdown( );
}
else
{
cerr << "Failed to start server" << endl;
}
return 0;
}

All this does is output each command and pass control over to the original
implementation.

When you execute this, you will see the following output:

(5) Starting server on 5290.
command = uadd sdl
(5) miracle++ version 0.0.1 listening on port 5290
command = play u0
(7) Received signal 2 - shutting down.

Note that all commands except the PUSH are passed through this method before
they are executed and this includes those coming from the main function itself.


ACCESSING UNIT PROPERTIES

A unit consists of two objects - a playlist and a consumer. Your custom
server can access these by obtaining the Properties object associated to a unit
via the 'unit' method.
As a simple example we can replace our execute method above with the following:

Response *execute( char *command )
{
if ( !strcmp( command, "debug" ) )
{
int i = 0;
while( unit( i ) != NULL )
unit( i ++ )->debug( );
return new Response( 200, "Diagnostics output" );
}
return Miracle::execute( command );
}

When this runs and you send a 'debug' command via DVCP, the server will output
some information on stderr, like:

(5) Starting server on 5290.
(5) Server version 0.0.1 listening on port 5290
(5) Connection established with localhost (7)
Object: [ ref=3, unit=0, generation=0, constructor=sdl, id=sdl, arg=(nil),
consumer=0x80716a0, playlist=0x807f8a8, root=/, notifier=0x8087c28 ]
(6) localhost "debug" 100

You can extract the objects using:

Playlist playlist( ( mlt_playlist )( unit( i )->get_data( "playlist" ) ) );
Consumer consumer( ( mlt_consumer )( unit( i )->get_data( "consumer" ) ) );
and use the standard MLT++ wrapping methods to interact with them or you can
bypass these and using the C API directly.

Obviously, this opens a lot of possibilities for the types of editing operations
than can be carried out over the DVCP protocol - for example, you can attach filters
apply mixes/transitions between neighbouring cuts or carry out specific operations
on cuts.


THE RESPONSE OBJECT

The example above doesn't do anything particularly useful - in order to extend
things in more interesting ways, we should be able to carry information back to
the client. In the code above, we introduced the Response object to carry an
error code and a description - it can also be used to carry arbitrary large
blocks of data.

Response *execute( char *command )
{
Response *response = NULL;
if ( !strcmp( command, "debug" ) )
{
response = new Response( 200, "Diagnostics output" );
for( int i = 0; unit( i ) != NULL; i ++ )
{
Properties *properties = unit( i );
stringstream output;
output << string( "Unit " ) << i << endl;
for ( int j = 0; j < properties->count( ); j ++ )
output << properties->get_name( j ) << " = " << properties->get( j ) << endl;
response->write( output.str( ).c_str( ) );
}
}
return response == NULL ? Miracle::execute( command ) : response;
}

Now when you connect to the server via a telnet session, you can access the
'debug' command as follows:

$ telnet localhost 5290
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
100 VTR Ready
debug
201 OK
Unit 0
unit = 0
generation = 0
constructor = sdl
id = sdl
arg =

Note that the '200' return code specified is automatically promoted to a 201
because of the multiple lines.

Alternatively, you can invoke response->write as many times as you like - each
string submitted is simply appended to the object in a similar way to writing
to a file or socket. Note that the client doesn't receive anything until the
response is returned from this method (ie: there's currently no support to
stream results back to the client).

HANDLING PUSHED DOCUMENTS

The custom class receives PUSH'd westley either via the received or push
method.

The default handling is to simply append a pushed document on to the end of
first unit 0.

You can test this in the server defined above from the command line, for
example:

$ inigo noise: -consumer valerie:localhost:5290

By default, the 'push' method is used - this means that the xml document
received is automatically deserialised by the server itself and then offered
to the push method for handling - an example of this would be:

Response *push( char *command, Service *service )
{
Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
Producer producer( *service );
if ( producer.is_valid( ) && playlist.is_valid( ) )
{
playlist.lock( );
playlist.clear( );
playlist.append( producer );
playlist.unlock( );
return new Response( 200, "OK" );
}
return new Response( 400, "Invalid" );
}

With this method, each service pushed into the server will automatically
replace whatever is currently playing.

Note that the 'received' method is not invoked by default - if you wish to
receive the XML document and carry out any additional processing prior to
processing, you should set the 'push-parser-off' property on the server to 1.
This can be done by placing the following line in your classes constructor:

set( "push-parser-off", 1 );

When this property is set, the received method is used instead of the push -
in this scenario, your implementation is responsible for all handling
of the document.

To simulate this, you can try the following method:

Response *received( char *command, char *document )
{
cerr << document;
Producer producer( "westley-xml", document );
return push( command, &producer );
}

When you push your videos in to the server via the inigo command above (or
from other tools, such as those in the shotcut suite), you will see the xml
in the servers stderr output. If you need to carry out some operations on the
xml document (such as replacing low quality videos used in the editing process
with their original) the received mechanism is the one that you would want to
use.


OTHER MANIPULATIONS

What you do with the received MLT Service is largely up to you. As shown above,
you have flexibility in how the item is scheduled and you can carry out
manipulations on either the xml document and/or the deserialised producer.

Typically, shotcut and inigo produce 'tractor' objects - these can be easily
manipulated in the push method - for example, to remove a track from the
output, we could do something like:

Response *push( char *command, Service *service )
{
Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
Tractor *tractor( *service );
if ( tractor.is_valid( ) && playlist.is_valid( ) )
{
// Remove track 2 (NB: tracks are indexed from 0 like everything else)
Producer *producer = tractor.track( 2 );
Playlist track( producer );

// If we have a valid track then hide video and audio
// This is a bit pattern - 1 is video, 2 is audio
if ( track.is_valid( ) )
track.set( "hide", 3 );

// You need to delete the reference to the playlist producer here
delete producer;

// Play it
playlist.lock( );
playlist.clear( );
playlist.append( producer );
playlist.unlock( );
return new Response( 200, "OK" );
}
return new Response( 400, "Invalid" );
}


EVENT HANDLING

The MLT framework generates events which your custom server can use to do
various runtime manipulations. For the purpose of this document, I'll focus
on 'consumer-frame-render' - this event is fired immediately before a frame
is rendered.

See example in test/server.cpp


DISABLING DVCP

In some cases, it is desirable to fully disable the entire DVCP command set
and handle the PUSH in an application specific way (for example, the shotcut
applications all do this). The simplest way of doing this is to generate a
response that signifies the rejection of the command. In this example, the
'shutdown' command is also handled:

Response *execute( char *command )
{
if ( !strcmp( command, "shutdown" ) )
exit( 0 );
return new Response( 400, "Invalid Command" );
}
If you use this method in the code above, your server does nothing - no units
are defined, so even a PUSH will be rejected.




+ 473
- 0
HOWTO View File

@@ -0,0 +1,473 @@
INTRODUCTION
------------

This document provides a brief tutorial on the use of the mlt++ wrapper
and bindings.


Hello World
-----------

The mlt++ wrapper is a c++ wrapper for the mlt C library. As such, it
provides clean C++ access to the underlying library.

An example of use is as follows:

#include <mlt++/Mlt.h>
using namespace Mlt;

int main( void )
{
Factory::init( );
Producer p( "pango:", "Hello World" );
Consumer c( "sdl" );
c.connect( p );
c.run( );
return 0;
}

This is a fairly typical example of mlt++ usage - create a 'producer' (an
object which produces 'frames'), create a 'consumer' (an object which consumes
frames), connect them together, start the consumer and wait until done (here
we just wait for the user to close the window).

In this case, we construct a window as a consumer using the 'sdl' consumer
(SDL is a standard portable library which provides platform independent
access to accelerated video display and audio) and use the 'pango'
producer to generate frames with the words 'Hello World' (pango is a
library from the gtk toolkit).

The main point of this example is to show that mlt uses existing libraries
to provide its functionality - this keeps the framework itself very small.

Note that mlt is designed to be housed in GUI or server type applications -
typically, applications don't wait around for the consumer to be stopped in
the manner shown.

So far, we've introduced the Producer and Consumer mlt classes. We'll cover
each of these in more detail later in the tutorial, but for now, we'll
briefly cover the remaining classes.


Playlists
---------

Another simple class is the Playlist - this is direct extension of Producer
and it allows you to maintain a list of producer objects.

As a simple example of the Playlist in action, we'll convert the example
above into an application which plays multiple video or audio files.

#include <mlt++/Mlt.h>
using namespace Mlt;

int main( int argc, char **argv )
{
Factory::init( );
Playlist list;
for ( int i = 1; i < argc; i ++ )
{
Producer p( argv[i] );
if ( p.is_valid( ) )
list.append( p );
}
Consumer c( "sdl" );
c.connect( list );
c.run( );
return 0;
}

Now you can run the program as:

./player *.avi *.mp3 *.jpg etc

In this case, we construct a playlist by simply appending producers to it.
Notice that although the scope of the Producer is limited to the inner
for loop, we can safely add it to the playlist - this is due to the fact
that all mlt objects maintain reference counts and no object is really
destroyed until all the references are gone. In this case, when the list
object goes out of scope, all the producers we created will automatically
be destroyed.


Filters
-------

So far, we've shown how you can load and play media. We've given a brief
intro to the Playlist container, now it's time to start manipulating
things...

For the next example, I'll add a 'watermark' to the video - a watermark
is used by broadcasters to brand the channel and normally consists of a
logo of some sort. We'll just use some black text on a partially
transparent red background.

#include <mlt++/Mlt.h>
using namespace Mlt;

int main( int argc, char **argv )
{
Factory::init( );
Playlist list;
for ( int i = 1; i < argc; i ++ )
{
Producer p( argv[i] );
if ( p.is_valid( ) )
list.append( p );
}
Filter f( "watermark", "pango:" );
f.set( "producer.text", "MLT++" );
f.set( "producer.fgcolour", "0x000000ff" );
f.set( "producer.bgcolour", "0xff000080" );
list.attach( f );
Consumer c( "sdl" );
c.connect( list );
c.run( );
return 0;
}

Notice that the watermark filter reuses the 'pango' producer we showed in the
first example. In fact, you could use any producer here - if you wanted to
use a graphic or a video, you would just construct the filter with a full path
to that as the second argument.

We manipulate the filter using the set method - this method was also shown
in the first example.

Finally, we attach the filter to the playlist. This ensure that all frames
that are obtained from the playlist are watermarked.


Cuts
----

When you add a clip to a playlist, the a cut object is created - this is merely a
wrapper for the producer, spanning the specified in and out points.

Whenever you retrieve a clip from a playlist, you will always get a cut object.
This allows you to attach filters to a specific part of a producer and should
the position of the cut in the playlist change, then the filter will remain
correctly associated to it.

A producer and a cut are generally identical in behaviour, but should you need to
distinguish between them, you can use:

if ( producer.is_cut( ) )

and to retrieve the parent of a cut, you can use:

Producer parent = producer.parent_cut( );

Filters that are attached directly to a parent are executed before any filters
attached to the cut.


Tractor
-------

A tractor is an object that allows the manipulation of multiple video and audio
tracks.

Stepping away from the player example we've been tinkering with for a minute,
let's assume we want to do something like dub a video with some audio. This
a very trivial thing to do:

Tractor *dub( char *video_file, char *audio_file )
{
Tractor *tractor = new Tractor( );
Producer video( video_file );
Producer audio( audio_file );
tractor->set_track( video, 0 );
tractor->set_track( audio, 1 );
return tractor;
}

That's all that needs to be done - you can now connect the returned object to a
consumer, or add it to a playlist, or even apply it as a track to another tractor.


Transition
----------

Let's now assume we want to mix the audio between two tracks - to do this, we
need to introduce the concept of a transition. A transition in mlt is a service
which combines frames from two producers to produce a new frame.

Tractor *mix( char *video_file, char *audio_file )
{
Tractor *tractor = new Tractor( );
Transition mix( "mix" );
Producer video( video_file );
Producer audio( audio_file );
tractor.set_track( video, 0 );
tractor.set_track( audio, 1 );
tractor.field.plant_transition( mix, 0, 1 );
return tractor;
}

The tractor returned will now mix the audio from the original video and the
audio.


Mix
---

There is a convenience function which simplifies the process of applying
transitions betwee adjacent cuts on a playlist. This is often preferable
to use over the constuction of your own tractor and transition set up.

To apply a 25 frame luma transition between the first and second cut on
the playlist, you could use:

Transition luma;
playlist.mix( 0, 25, luma );


Events
------

Typically, applications need to be informed when changes occur in an mlt++ object.
This facilitates application services such as undo/redo management, or project
rendering in a timeline type widget and many other types of operations which an
application needs.

As an example, consider the following:

class Westley
{
private:
Consumer consumer;
Tractor &tractor;
public:
Westley( MltTractor &tractor ) :
tractor( tractor ),
consumer( "westley" )
{
consumer.connect( tractor );
tractor.listen( tractor, "producer-changed",
( mlt_listener )Westley::listener );
}
static void listener( Properties *tractor, Westley *object )
{
object->activate( );
}
void activate( )
{
consumer.start( );
}
};

Now, each time the tractor is changed, the westley representation is output to
stderr.


Servers and Westley Docs
------------------------

One of the key features of MLT is its server capabilities. This feature
allows you to pass westley documents seamlessly from one process to
another and even to different computers on your network.

The miracle playout server is one such example of an application which
uses this functionality - you can build your own servers into your own
processes with ease.

A server process would be running as follows:

#include <mlt++/Miracle>
using namespace Mlt;
int main( void )
{
Miracle miracle( "miracle", 5250 );
miracle.start( );
miracle.execute( "uadd sdl" );
miracle.execute( "play u0" );
miracle.wait_for_shutdown( );
return 0;
}

Typically, when you have an MLT object such as a producer or a playlist,
you can send a westley representation of this to a running server with:

Conumser valerie( "valerie", "localhost:5250" );
valerie.connect( producer );
valerie.start( );

The effect of the push will be to append the producer on to the first
unit (u0).

You can completely customise the miracle server - an example of this
is shown below.


That's All Folks...
-------------------

And that, believe it or not, is a fairly complete summary of the classes you'll
typically be interfacing with in mlt++. Obviously, there's a little more to it
than this - a couple of intrisinc classes have been glossed over (notably, the
Properties and Service base classes). The next section will cover all of the
above, but in much more detail...


DIGGING DEEPER
--------------

The previous section was designed to give you a whistle stop tour through the major
framework classes. This section will take you through the scenic route.


Introducing Base Classes
------------------------

Services in mlt are the collective noun for Producers, Filters, Transitions and
Consumer. A Service is also the base class from which all of these classes
extend. It provides the basic connectivity which has been shown throughout the
examples in the previous section.

Properties are the main way in which we communicate with the Services -
essentially, it provides get/set methods for named values. All services extend
Properties.


Properties
----------

Properties provide the general mechanism for communicating with Services -
through the Properties interface, we are able to manipulate and serialise
a services state.

For example, to dump all the properties to stdout, you can use something
like:

void dump( Properties &properties )
{
for ( int i = 0; i < properties.count( ); i ++ )
cout << Properties.get_name( i ) << " = " << Properties.get( i ) << endl;
}

Note that the properties object handles type conversion, so the following
is acceptable:

properties.set( "hello", "10.5" );
int hello_int = properties.get_int( "hello" );
double hello_double = properties.get_double( "hello" );

A couple of convenience methods are provide to examine or serialise property
objects.

For example:

properties.debug( );

will report all serialisable properties on stderr, in the form:

Object: [ ref=1, in=0, out=0, track=0, u=75, v=150, _unique_id=15,
mlt_type=filter, mlt_service=sepia ]


Services
--------

Typically, all the services are constructed via the specific classes
constructor. Often, you will receive Service objects rather than their
specific type. In order to access the extended classes interface,
you will need to create a reference.

For example, given an arbitrary Service object, you can determine its
type by using the type method - this will return a 'service_type' which
has values of producer_type, filter_type etc. Alternatively, you can
create a wrapping object and check on its validity.

bool do_we_have_a_producer( Service &service )
{
Producer producer( service );
return producer.is_valid( );
}


Events
------


Servers and Westley Docs
------------------------

For various reasons, you might want to serialise a producer to a string.
To do this, you just need to specify a property to write to:

Consumer westley( "westley", "buffer" );
westley.connect( producer );
westley.start( );
buffer = westley.get( "buffer" );

You can use any name you want, and you can change it using the "resource"
property. Any name with a '.' in it is considered to be a file. Hence, you
can use a westley consumer to store multiple instances of the same MLT
object - useful if you want to provide undo/redo capabilities in an
editing application.

Should you receive an xml document as a string, and you want to send it
on to a server, you can use:

Conumser valerie( "valerie", "localhost:5250" );
valerie.set( "westley", buffer );
valerie.start( );

If you need to obtain an MLT object from a string:

Producer producer( "westley-xml", buffer );
The following shows a working example of an extended server:

class ShotcutServer : public Miracle
{
public:
ShotcutServer( char *id, int port ) :
Miracle( id, port )
{
}
void set_receive_doc( bool doc )
{
set( "push-parser-off", doc );
}

// Reject all commands other than push/receive
Response *execute( char *command )
{
valerie_response response = valerie_response_init( );
valerie_response_set_error( response, 400, "Not OK" );
return new Response( response );
}
// Push document handler
Response *received( char *command, char *doc )
{
valerie_response response = valerie_response_init( );
// Use doc in some way and assign Response
if ( doc != NULL )
valerie_response_set_error( response, 200, "OK" );
return new Response( response );
}

// Push service handler
Response *push( char *command, Service *service )
{
valerie_response response = valerie_response_init( );
// Use service in some way and assign Response
if ( service != NULL )
valerie_response_set_error( response, 200, "OK" );
return new Response( response );
}
};

NB: Should you be incorporating this into a GUI application, remember that the
execute, received and push methods are invoked from a thread - make sure that
you honour the locking requirements of your GUI toolkit before interacting with
the UI.



+ 165
- 0
LGPL View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

+ 10
- 0
Makefile View File

@@ -0,0 +1,10 @@
include config.mak

all clean distclean install uninstall:
$(MAKE) DESTDIR=$(DESTDIR) -C src $@
$(MAKE) -C test $@

dist:
[ -d "mlt++-$(version)" ] && rm -rf "mlt++-$(version)" || echo -n
svn export . "mlt++-$(version)"
tar -cvzf "mlt++-$(version).tar.gz" "mlt++-$(version)"

+ 135
- 0
README View File

@@ -0,0 +1,135 @@
MLT++
-----

This mlt sub-project provides a C++ wrapping for the MLT library.

INSTALLATION
------------

./configure [ --prefix=path ]
make
make install

USAGE
-----

Use the following definitions in a Makefile to compile and link with mlt++:

CXXFLAGS=`mlt-config -Wall`
LDFLAGS=-lmlt++

Include files for the classes can either be explicitly included, ie:

#include <mlt++/MltProducer.h>
etc

Or you can include all using:

#include <mlt++/Mlt.h>

All definitions are placed in an Mlt namespace, and adhere closely to the C
naming convention. Mappings always follow the pattern:

Factory methods:

mlt_factory_init ==> Mlt::Factory::init
mlt_factory_producer ==> Mlt::Factory::producer
mlt_factory_filter ==> Mlt::Factory::filter
mlt_factory_transition ==> Mlt::Factory::transition
mlt_factory_consumer ==> Mlt::Factory::consumer
mlt_factory_close ==> Mlt::Factory::close

NB: Factory usage for service construction is optional.

Types:

mlt_properties ==> Mlt::Properties
mlt_frame ==> Mlt::Frame
mlt_service ==> Mlt::Service
mlt_producer ==> Mlt::Producer
mlt_filter ==> Mlt::Filter
mlt_transition ==> Mlt::Transition
mlt_consumer ==> Mlt::Consumer

Methods:

mlt_type_method ==> Mlt::Type.method
ie: mlt_playlist_append ==> Mlt::Playlist.append

Parent methods are available directly on children.

Additionally, you can specify:

using namespace Mlt;

To avoid the enforced use of the Mlt:: prefix.

Enumerators and macros are reused directly from the C library.

CLASS HIERARCHY
---------------

The currently mapped objects are shown in the following hierarchy:

Factory
Properties
Frame
Service
Consumer
Field
Filter
Multitrack
Producer
Playlist
Tractor
Transition

An additional set of classes allow apps to behave as, and communicate with,
client/server components - these components provide MLT with unique
possibilties for process to process or system to system communications.
Miracle
Response

SPECIAL CASES
-------------

Care should be taken with wrapper objects.

Taking, as an example, the C function that returns the immediate consumer of
a service:

mlt_service mlt_service_consumer( mlt_service );

This maps to:

Mlt::Service *Mlt::Service.consumer( );

Note that you get an object back - it is never the original c++ object, but
a wrapping object. This is done to keep consistency with the C api which may
instantiate C instances - therefore it cannot be assumed that a C++ object
exists for all mlt service instances.

As such, it is mandatory that you delete these objects. The original will
not be affected. However, all other modifications (to properties or its
state of connection) will be reflected in the original object.

This approach excludes the use of RTTI to determine the real type of the
object - this can only be done by parsing the objects properties.

Objects may be invalid - always use the is_valid method to check validity
before use.

LIMITATIONS
-----------

The mechanisms for the definition of new services are deliberately
excluded from the C++ wrappings - this is done to ensure that service
networks constructed can be serialised and used by existing applications
which are based on the C API (such as miracle).

SWIG
----

Experimental swig bindings based on mlt++ are provided.


+ 8
- 0
config.mak View File

@@ -0,0 +1,8 @@
version=0.2.5
prefix=/usr
libdir=/usr/lib
targetos=Linux
LIBSUF=.so
CXXFLAGS+=-pthread -Wall -fPIC -I/usr/include -I/usr/include/mlt -D_REENTRANT
LIBFLAGS=-shared
LDFLAGS+=-L/usr/lib -lmlt -L/usr/lib -lmiracle

+ 21
- 0
mlt++.sln View File

@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mlt++", "mlt++.vcproj", "{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Debug.ActiveCfg = Debug|Win32
{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Debug.Build.0 = Debug|Win32
{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Release.ActiveCfg = Release|Win32
{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

+ 265
- 0
mlt++.vcproj View File

@@ -0,0 +1,265 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="mlt++"
ProjectGUID="{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Program Files\mlt\include\mlt&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MLTPP_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libmlt.0.2.1.lib"
OutputFile="$(OutDir)/mlt++.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;C:\Program Files\mlt\lib&quot;"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/mlt++.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/mlt++.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Program Files\mlt\include\mlt&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MLTPP_EXPORTS"
RuntimeLibrary="0"
TreatWChar_tAsBuiltInType="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libmlt.0.2.1.lib"
OutputFile="$(OutDir)/mlt++.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;C:\Program Files\mlt\lib&quot;"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/mlt++.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\src\config.h">
</File>
<File
RelativePath=".\src\Mlt.h">
</File>
<File
RelativePath=".\src\MltConsumer.cpp">
</File>
<File
RelativePath=".\src\MltConsumer.h">
</File>
<File
RelativePath=".\src\MltDeque.cpp">
</File>
<File
RelativePath=".\src\MltDeque.h">
</File>
<File
RelativePath=".\src\MltEvent.cpp">
</File>
<File
RelativePath=".\src\MltEvent.h">
</File>
<File
RelativePath=".\src\MltFactory.cpp">
</File>
<File
RelativePath=".\src\MltFactory.h">
</File>
<File
RelativePath=".\src\MltField.cpp">
</File>
<File
RelativePath=".\src\MltField.h">
</File>
<File
RelativePath=".\src\MltFilter.cpp">
</File>
<File
RelativePath=".\src\MltFilter.h">
</File>
<File
RelativePath=".\src\MltFilteredConsumer.cpp">
</File>
<File
RelativePath=".\src\MltFilteredConsumer.h">
</File>
<File
RelativePath=".\src\MltFilteredProducer.cpp">
</File>
<File
RelativePath=".\src\MltFilteredProducer.h">
</File>
<File
RelativePath=".\src\MltFrame.cpp">
</File>
<File
RelativePath=".\src\MltFrame.h">
</File>
<File
RelativePath=".\src\MltGeometry.cpp">
</File>
<File
RelativePath=".\src\MltGeometry.h">
</File>
<File
RelativePath=".\src\MltMultitrack.cpp">
</File>
<File
RelativePath=".\src\MltMultitrack.h">
</File>
<File
RelativePath=".\src\MltParser.cpp">
</File>
<File
RelativePath=".\src\MltParser.h">
</File>
<File
RelativePath=".\src\MltPlaylist.cpp">
</File>
<File
RelativePath=".\src\MltPlaylist.h">
</File>
<File
RelativePath=".\src\MltProducer.cpp">
</File>
<File
RelativePath=".\src\MltProducer.h">
</File>
<File
RelativePath=".\src\MltProperties.cpp">
</File>
<File
RelativePath=".\src\MltProperties.h">
</File>
<File
RelativePath=".\src\MltPushConsumer.cpp">
</File>
<File
RelativePath=".\src\MltPushConsumer.h">
</File>
<File
RelativePath=".\src\MltService.cpp">
</File>
<File
RelativePath=".\src\MltService.h">
</File>
<File
RelativePath=".\src\MltTokeniser.cpp">
</File>
<File
RelativePath=".\src\MltTokeniser.h">
</File>
<File
RelativePath=".\src\MltTractor.cpp">
</File>
<File
RelativePath=".\src\MltTractor.h">
</File>
<File
RelativePath=".\src\MltTransition.cpp">
</File>
<File
RelativePath=".\src\MltTransition.h">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

+ 61
- 0
src/Makefile View File

@@ -0,0 +1,61 @@
include ../config.mak
INSTALL = install

ifneq ($(targetos), Darwin)
NAME = libmlt++$(LIBSUF)
TARGET = $(NAME).$(version)
LIBFLAGS += -Wl,-soname,$(TARGET)
else
NAME = libmlt++$(LIBSUF)
TARGET = libmlt++.$(version)$(LIBSUF)
LIBFLAGS += -install_name $(libdir)/$(TARGET)
endif

OBJS = MltConsumer.o \
MltDeque.o \
MltEvent.o \
MltFactory.o \
MltField.o \
MltFilter.o \
MltFilteredConsumer.o \
MltFrame.o \
MltGeometry.o \
MltMiracle.o \
MltMultitrack.o \
MltParser.o \
MltPlaylist.o \
MltProducer.o \
MltProperties.o \
MltPushConsumer.o \
MltResponse.o \
MltService.o \
MltTokeniser.o \
MltTractor.o \
MltTransition.o

SRCS = $(OBJS:.o=.cpp)
HEADERS = config.h Mlt.h $(OBJS:.o=.h)

all: $(TARGET)

$(TARGET): $(OBJS)
$(CXX) $(LIBFLAGS) -o $@ $(OBJS) $(LDFLAGS) -L/usr/kde3/lib
ln -sf $(TARGET) $(NAME)

clean:
$(RM) $(OBJS) $(TARGET) $(NAME)

distclean: clean

install:
$(INSTALL) -d "$(DESTDIR)$(libdir)"
$(INSTALL) -m 755 $(TARGET) $(DESTDIR)$(libdir)
ln -sf $(TARGET) $(DESTDIR)$(libdir)/$(NAME)
$(INSTALL) -d "$(DESTDIR)$(prefix)/include/mlt++"
$(INSTALL) -m 644 $(HEADERS) "$(DESTDIR)$(prefix)/include/mlt++"
/sbin/ldconfig || true

uninstall:
rm -f "$(DESTDIR)$(libdir)/$(TARGET)"
rm -f "$(DESTDIR)$(libdir)/$(NAME)"
rm -rf "$(DESTDIR)$(prefix)/include/mlt++"

+ 50
- 0
src/Mlt.h View File

@@ -0,0 +1,50 @@
/**
* Mlt.h - Convenience header file for all mlt++ objects
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _MLTPP_H_
#define _MLTPP_H_

#include "MltConsumer.h"
#include "MltDeque.h"
#include "MltEvent.h"
#include "MltFactory.h"
#include "MltField.h"
#include "MltFilter.h"
#include "MltFilteredConsumer.h"
#include "MltFrame.h"
#include "MltGeometry.h"
#ifndef WIN32
#include "MltMiracle.h"
#endif
#include "MltMultitrack.h"
#include "MltParser.h"
#include "MltPlaylist.h"
#include "MltProducer.h"
#include "MltProperties.h"
#include "MltPushConsumer.h"
#ifndef WIN32
#include "MltResponse.h"
#endif
#include "MltService.h"
#include "MltTokeniser.h"
#include "MltTractor.h"
#include "MltTransition.h"

#endif

+ 129
- 0
src/MltConsumer.cpp View File

@@ -0,0 +1,129 @@
/**
* MltConsumer.cpp - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <stdlib.h>
#include <string.h>
#include "MltConsumer.h"
#include "MltEvent.h"
using namespace Mlt;

Consumer::Consumer( ) :
instance( NULL )
{
instance = mlt_factory_consumer( NULL, NULL );
}

Consumer::Consumer( char *id, char *arg ) :
instance( NULL )
{
if ( id == NULL || arg != NULL )
{
instance = mlt_factory_consumer( id, arg );
}
else
{
if ( strchr( id, ':' ) )
{
char *temp = strdup( id );
char *arg = strchr( temp, ':' ) + 1;
*( arg - 1 ) = '\0';
instance = mlt_factory_consumer( temp, arg );
free( temp );
}
else
{
instance = mlt_factory_consumer( id, NULL );
}
}
}

Consumer::Consumer( Service &consumer ) :
instance( NULL )
{
if ( consumer.type( ) == consumer_type )
{
instance = ( mlt_consumer )consumer.get_service( );
inc_ref( );
}
}

Consumer::Consumer( Consumer &consumer ) :
instance( consumer.get_consumer( ) )
{
inc_ref( );
}

Consumer::Consumer( mlt_consumer consumer ) :
instance( consumer )
{
inc_ref( );
}

Consumer::~Consumer( )
{
mlt_consumer_close( instance );
}

mlt_consumer Consumer::get_consumer( )
{
return instance;
}

mlt_service Consumer::get_service( )
{
return mlt_consumer_service( get_consumer( ) );
}

int Consumer::connect( Service &service )
{
return connect_producer( service );
}

int Consumer::start( )
{
return mlt_consumer_start( get_consumer( ) );
}

void Consumer::purge( )
{
mlt_consumer_purge( get_consumer( ) );
}

int Consumer::stop( )
{
return mlt_consumer_stop( get_consumer( ) );
}

bool Consumer::is_stopped( )
{
return mlt_consumer_is_stopped( get_consumer( ) ) != 0;
}

int Consumer::run( )
{
int ret = start( );
if ( !is_stopped( ) )
{
Event *e = setup_wait_for( "consumer-stopped" );
wait_for( e );
delete e;
}
return ret;
}

+ 56
- 0
src/MltConsumer.h View File

@@ -0,0 +1,56 @@
/**
* MltConsumer.h - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _MLTPP_CONSUMER_H_
#define _MLTPP_CONSUMER_H_

#include "config.h"

#include <framework/mlt.h>

#include "MltService.h"

namespace Mlt
{
class Service;

class MLTPP_DECLSPEC Consumer : public Service
{
private:
mlt_consumer instance;
public:
Consumer( );
Consumer( char *id , char *service = NULL );
Consumer( Service &consumer );
Consumer( Consumer &consumer );
Consumer( mlt_consumer consumer );
virtual ~Consumer( );
virtual mlt_consumer get_consumer( );
mlt_service get_service( );
virtual int connect( Service &service );
int run( );
int start( );
void purge( );
int stop( );
bool is_stopped( );
};
}

#endif

+ 68
- 0
src/MltDeque.cpp View File

@@ -0,0 +1,68 @@
/**
* MltDeque.cpp - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "MltDeque.h"
using namespace Mlt;

Deque::Deque( )
{
deque = mlt_deque_init( );
}

Deque::~Deque( )
{
mlt_deque_close( deque );
}

int Deque::count( )
{
return mlt_deque_count( deque );
}

int Deque::push_back( void *item )
{
return mlt_deque_push_back( deque, item );
}

void *Deque::pop_back( )
{
return mlt_deque_pop_back( deque );
}

int Deque::push_front( void *item )
{
return mlt_deque_push_front( deque, item );
}

void *Deque::pop_front( )
{
return mlt_deque_pop_front( deque );
}

void *Deque::peek_back( )
{
return mlt_deque_peek_back( deque );
}

void *Deque::peek_front( )
{
return mlt_deque_peek_front( deque );
}


+ 47
- 0
src/MltDeque.h View File

@@ -0,0 +1,47 @@
/**
* MltDeque.h - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _MLTPP_DEQUE_H
#define _MLTPP_DEQUE_H

#include "config.h"

#include <framework/mlt.h>

namespace Mlt
{
class MLTPP_DECLSPEC Deque
{
private:
mlt_deque deque;
public:
Deque( );
~Deque( );
int count( );
int push_back( void *item );
void *pop_back( );
int push_front( void *item );
void *pop_front( );
void *peek_back( );
void *peek_front( );
};
}

#endif

+ 61
- 0
src/MltEvent.cpp View File

@@ -0,0 +1,61 @@
/**
* MltEvent.cpp - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "MltEvent.h"
using namespace Mlt;


Event::Event( mlt_event event ) :
instance( event )
{
mlt_event_inc_ref( instance );
}

Event::Event( Event &event ) :
instance( event.get_event( ) )
{
mlt_event_inc_ref( instance );
}

Event::~Event( )
{
mlt_event_close( instance );
}

mlt_event Event::get_event( )
{
return instance;
}

bool Event::is_valid( )
{
return instance != NULL;
}

void Event::block( )
{
mlt_event_block( get_event( ) );
}

void Event::unblock( )
{
mlt_event_unblock( get_event( ) );
}


+ 46
- 0
src/MltEvent.h View File

@@ -0,0 +1,46 @@
/**
* MltEvent.h - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _MLTPP_EVENT_H_
#define _MLTPP_EVENT_H_

#include "config.h"

#include <framework/mlt.h>

namespace Mlt
{
class MLTPP_DECLSPEC Event
{
private:
mlt_event instance;
public:
Event( mlt_event );
Event( Event & );
~Event( );
mlt_event get_event( );
bool is_valid( );
void block( );
void unblock( );
};
}

#endif


+ 75
- 0
src/MltFactory.cpp View File

@@ -0,0 +1,75 @@
/**
* MltFactory.cpp - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "MltFactory.h"
#include "MltProducer.h"
#include "MltFilter.h"
#include "MltTransition.h"
#include "MltConsumer.h"
using namespace Mlt;

int Factory::init( char *arg )
{
return mlt_factory_init( arg );
}

Properties *Factory::event_object( )
{
return new Properties( mlt_factory_event_object( ) );
}

Producer *Factory::producer( char *id, char *arg )
{
return new Producer( id, arg );
}

Filter *Factory::filter( char *id, char *arg )
{
return new Filter( id, arg );
}

Transition *Factory::transition( char *id, char *arg )
{
return new Transition( id, arg );
}

Consumer *Factory::consumer( char *id, char *arg )
{
return new Consumer( id, arg );
}

#ifdef WIN32
char *Factory::getenv( const char *name )
{
return mlt_getenv( name );
}

int Factory::setenv( const char *name, const char *value )
{
return mlt_setenv( name, value );
}
#endif

void Factory::close( )
{
mlt_factory_close( );
}



+ 57
- 0
src/MltFactory.h View File

@@ -0,0 +1,57 @@
/**
* MltFactory.h - MLT Wrapper
* Copyright (C) 2004-2005 Charles Yates
* Author: Charles Yates <charles.yates@pandora.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of