From: ddennedy Date: Thu, 12 Feb 2004 01:50:09 +0000 (+0000) Subject: remove child mlt dir X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=ecbe55c1ab5a3f4d9801b29f36041ce1b2384b96;p=melted remove child mlt dir git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@142 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/mlt/ChangeLog b/mlt/ChangeLog deleted file mode 100644 index e69de29..0000000 diff --git a/mlt/Makefile b/mlt/Makefile deleted file mode 100644 index 36c1f12..0000000 --- a/mlt/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -SUBDIRS = src/framework \ - src/modules \ - src/inigo \ - src/valerie \ - src/miracle \ - src/humperdink \ - src/albino - -all clean dist-clean depend install: - list='$(SUBDIRS)'; \ - for subdir in $$list; do \ - $(MAKE) -C $$subdir $@; \ - done - diff --git a/mlt/README b/mlt/README deleted file mode 100644 index 902bb32..0000000 --- a/mlt/README +++ /dev/null @@ -1,135 +0,0 @@ -README ------- - - This document provides a description of the MLT project organisation. - - It provides *CRITICAL* architecture information, so please read carefully - if you plan to extend or use the MLT code base. - -Directories ------------ - - The directory heirarchy is defined as follows: - - + docs - Location of all text and source format - documentation - + src - All project source is provided here - + framework - The media framework - + modules - All components are defined here - + core - Non-dependent MLT service - + dv - libdv services - + ffmpeg - ffmpeg dependent modules and test code - + sdl - SDL dependent modules and test code - + bluefish - Bluefish dependent modules and test code (*) - + mainconcept - mainconcept dependent modules and test code (*) - + inigo - A media playing test application - + valerie - Client API to access the server - + miracle - The server implementation - + humperdink - The evil demo - + albino - The simple but nice demo - + tests - Reserved for regression and unit tests - - Additional subdirectories may be nested below those shown and should be - documented in their parent. - - (*) Not posted to CVS due to licensing issues. - -Configuration -------------- - - Configuration is triggered from the top level directory via a - ./configure script. - - Each source bearing subdirectory shown above have their own configure - script which are called automatically from the top level. - - Typically, new modules can be introduced without modification to the - configure script and arguments are accepted and passed through to all - subdirectories. - - Top level usage is: - - ./configure --help - report all configure options - ./configure --prefix=[dir] - target install directory (default: /usr/local) - ./configure --disable-[mod] - do not compile specified module(s) - ./configure --[other] - pass through to children - - NB: This script must be run to register new services after a CVS checkout - or subsequent update. - -Compilation ------------ - - Makefiles are generated during configuration and these are based on - a per directory template which must be provided by the developer. - -Testing -------- - - To execute the mlt tools without installation, or to test a new version - on a system with an already installed mlt version, you should run: - - . setenv - - NB: This applies to your current shell only. - -Installation ------------- - - * NOT IMPLEMENTED YET * - - The install is triggered by running make install or make install-strip - from the top level directory. - - The framework produces a single shared object which is installed in - $prefix/lib/ and public header files which are installed in - $prefix/include/mlt/framework. - - The client produces a single shared object which is installed in - $prefix/lib/ and public header which are installed in - $prefix/include/mlt/client. - - The server produces a single exectuable which is installed in - $prefix/bin/. This is linked against the framework shared object and - posix libs but not against any of the modules. - - The modules produce a shared object per module and update text files - containing a list of modules provided by this build. These are installed - in $prefix/share/mlt/. It is at the discretion of the module to install - additional support files. - - To allow the development of external components, mlt-client-config and - mlt-framework-config scripts are generated and installed in $prefix/bin. - - After install, only those modules listed are usable by the server. No - module is loaded unless explicitly requested via server configuration - or usage. - - External modules are also placed in this $prefix/share/mlt, and the - installation of those must modify the text file accordingly before they - will be considered at runtime. - -Development ------------ - - All compilation in the project has {top-level-dir}/src on the include path. - All headers are included as: - - #include - - All external modules have {prefix}/include/mlt on the include path. All - headers should also be included as: - - #include - - This allows migration of source between external and internal modules. - The configuration and Makefile template requirements will require - attention though. - -Summary -------- - - 1. The server will interact with public interfaces from the framework only; - 2. The modules must expose public framework interfaces only; - 3. All modules are dynamically loaded at runtime. - diff --git a/mlt/configure b/mlt/configure deleted file mode 100755 index 4b39bfc..0000000 --- a/mlt/configure +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -function show_help -{ - cat << EOF -Funky non-autotool config script for MLT. - - Options are: - - --help - this information - --prefix=directory - install prefix for path (default: $prefix) -EOF - - for i in src/modules/* - do - [ -d $i ] && echo " --disable-`basename $i`" - done - - echo -} - -# Debug mode -set +x - -# Define build directory for scripts called -export build_dir=`dirname $0` -export prefix=/usr/local -export help=0 - -# Iterate through arguments -for i in $* -do - case $i in - --help ) help=1 ;; - --prefix=* ) prefix="${i#--prefix=}" ;; - esac -done - -# Show help if requested -[ $help = 1 ] && show_help - -# Iterate through each of the components -for i in framework modules inigo valerie miracle humperdink -do - if [ -x src/$i/configure ] - then - echo "Configuring `basename $i`:" - pushd src/$i > /dev/null - ./configure $@ - [ $? != 0 ] && exit 1 - popd > /dev/null - fi -done - diff --git a/mlt/docs/dvcp.txt b/mlt/docs/dvcp.txt deleted file mode 100644 index 6da16db..0000000 --- a/mlt/docs/dvcp.txt +++ /dev/null @@ -1,336 +0,0 @@ - -dv1394d Control Protocol (DVCP) Reference Documentation - -Copyright (C) 2003 Ushodaya Enterprised Limited -Author: Dan Dennedy -Last Revision: 2003-01-13 - -General Format --------------- - DVCP is an ASCII-based request/response TCP protocol much like FTP and - inspired by the SGI MVCP (Multiport Video Computer Protocol). Each - command is three to eight characters long followed by zero or more - arguments. Every item (command or argument) in the request is delimited - by a space and terminated with a new line. Arguments that contain spaces - must be surrounded by double quotation marks. The new line must contain - a line feed optionally preceeded by a carriage return. There are no - request header lines or body. - - -Response Codes --------------- - Responses consist of a numeric result code followed by a space folowed - by a brief textual description of the result. No quoting is applied to - descriptions regardless if it contains spaces. The result codes are - grouped by the hundreds into general categories of responses. Anything - in the 200-299 range is considered a success and anything 300 and above - is an error or exception. Most responses do not contain a body except - some of the success results that report information and sometimes the - 500 Server Error returns specific information. - A 200 result code contains no body. - A 201 result code contains one or more lines in the body, and a empty - line terminates the response. - A 202 result code contains only a single response line in the body. - - Errors in the 400 range indicate a normally handled error where the - command could not perform its action due to protocol syntax errors or - problems with validation of one or more of the arguments. This usually - indicates that the client is responsible for performing an illegal - request. - - Errors in the 500 range indicate a server error or exception. - - The following is a list of response codes and their descriptions: - 200 OK - 201 OK - 202 OK - 400 Unknown command - 401 Operation timed out - 402 Argument missing - 403 Unit not found - 404 Failed to locate or open clip - 405 Argument value out of range - 500 Server Error - - -Establishing a Connection -------------------------- - One can connect to the miracle server using telnet or a custom client, - preferrably one developed using the valerie client API. The default port - is 5250. Connections can be broken at will or use the BYE command to - request the server to terminate the connection. - - -General Command Information ---------------------------- - - All commands are case insensitive. Arguments may or may not be case - sensitive. There are two categories of commands: global and unit. Global - commands operate at the server level. Unit commands address a specific - unit. miracle is a multi-unit system. Units are named as U? where ? - is the unit number, for example, U0. As units are added to the server, - the unit number increases; the first unit is U0. - - The command HELP lists all commands known to the server with a brief - description of their purpose and arguments. Most commands take zero or - one argument outside of the unit name. Sometimes an argument is - optional, and an optional argument always follows required arguments. - All units command required a unit name argument. - - {} = required argument - [] = optional argument - () = one of a set of pre-defined values - - -Global Commands ---------------- - -HELP - List the commands and their brief description. - -BYE - Close the connection. - -SHUTDOWN - Shutdown the server and all client connections. - -SET {key=value} - Set a global server configuration property. - Currently, the only planned key is "root" to set the base directory - path for the CLS and LOAD commands. The default root value is /. - -GET {key} - Get the current value of a configuration property. - The value is returned by itself in the body of the response. - -CLS {path} - List the clips and subdirectories at {path} on the server. - Only subdirectories, non-hidden regular files, symbolic links, and NFS - shares are supported. - The response body contains one line per item. - The name of the subdirectory/file is always surrounded by double - quotation marks in case it contains spaces. - Subdirectories are listed before files and have a trailing / in their - name. - File entries have a size value in bytes in the second column position. - -RUN {file} - Process the commands in a file located on the server. - Commands are executed one after the other with no delay until the end - of file is reached or a command returns a response code not in the 200 - range. - The response body contains each command sent along with its arguments, - followed by each command's response status code and response body. - - -STATUS - Responds with the output of USTA for each unit and accepts no further - input. Each time the state of the unit changes, a new row is returned by - the server containing the state of the unit. - -Unit Management - - The following global commands manage the DV units within the server. - Currently there is a maximum of four units, and units can not be - removed. Each unit may be in an online or offline state. Offline units - can not be used, and any unit commands issued against an offline unit - results in a 403 response. - -NLS - * NOT IMPLEMENTED IN MIRACLE YET * - - -UADD mlt-consumer[:argument] - Add a unit based upon the mlt-consumer id and optional constructor - argument. - If the consumer is not found, then it still added but in an - offline manner. Later, by adding the device to the bus, the unit will - automatically become online. - The response body contains the name of the new unit: U0, U1, U2, or U3. - Channel is an optional setting. - -ULS - List the units. - The response body contains a space-delimited row for each unit in the - server containing the following columns: - - unit name (one of U0, U1, U2, or U3) - - mlt-consumer[:argument] from uadd - - 1394 node GUID (defunt - always 0 with miracle for now) - - online flag (1 = online, 0 = offline) - -SHUTDOWN - Shutdown the server. - - -Unit Commands -------------- - - The first argument of any unit command is the unit name (U0 - U3). A - unit must be loaded with a file before it can play anything. A "clip" - refers to the presence of a file loaded into the unit. A clip can - contain an in and out point to set the playback region. The default in - point is 0, and the default out point is the number of frames in the - file minus one. Therefore, all frame positions are zero-based. - -USET {unit} {key=value} - Set a unit's configuration property. - Key is one of the following: eof, points. - - Property "eof" determines what the playback engine does when it reaches - the end of a clip. The eof property takes one of the following values: - stop, loop, continue or pause. The default is pause. - - Property "points" determines whether the playback engine restricts the - playback region to the in and out points. It takes one of the following - values: use, ignore. - -UGET {unit} {key} - Get a unit's configuration property. - Key is one of the following: eof, points. - The response body contains only the key's value. See USET for information - about each property. - -LIST {unit} - List the clips associated to the unit. - The response body consists of two sections - the first section is a single row - containing the generation number of the playlist associated to the unit (an - integer starting from 0 which is incremented on each action which changes the - playlist). The second sections contais a space-delimited row for each clip in the - units playlistcontaining the following columns: - - clip index (starts from 0) - - file name - - in point - - out point - - real length of the files - - calculated length of file - When USET points=use is specified (default), the calculated size is (out-in)+1. - When points are ignored, the real length of the file is returned. - -LOAD {unit} {filename} [in out] - Load a clip into the unit. - Optionally set the in and out points to the specified absolute frame numbers. - Sets the current position to the first frame in the clip. - Preface the filename with '!' to tell the disk reader thread to remove only - duplicate frames from the tail of its buffer queue (from a previously loaded - and playing clip). Otherwise, miracle flushes all of its buffers upon LOAD - to make the effect of LOAD instantaneous. The LOAD !, USET eof=pause, and - extended USTA information can be used for client-side playlists (see the - demo programs). - -APND {unit} {filename} [in out] - Append a clip onto the unit's playlist. - Optionally set the in and out points to the specified absolute frame numbers. - -INSERT {unit} {filename} [ [+|-]clip [ in out ] ] - Insert a clip into the units playlist at the specified clip index or relative - to the currently playing clip index. - -REMOVE {unit} [ [+|-]clip ] - Removes a clip from the specified clip index or position relative to the - currently playing clip index. - -CLEAN {unit} - Removes all by the playing clip. - -MOVE {unit} [+|-]clip [ [+|-]clip ] - Move a clip in the playlist to position specified or position relative to the - currently playing clip. - -PLAY {unit} [speed] - Commence unit playback from the current position. - The default speed is 100% if not specified. - Speed is represented as a percentage value multiplied by 10. Therefore - the default playback speed is 1000 (1X or 100%), 2X is 2000. - Negative speed values play in reverse. - -STOP {unit} - Terminate the unit playback resulting in no video being sent. - -PAUSE {unit} - Pause the unit playback causing the current frame position to he held - indefinitely. - -REW {unit} - Rewind the unit. - If the unit it playing, then REW sets the playback speed to 2000 - (200%). - If the unit is stopped, then the frame position is reset to the first - frame. First frame depends upon the "points" unit configuration property - and whether an in point has been established for the clip using the SIN - command. - Set the currently loaded clip's in point. - Frame is zero-based and absolute. It is not dependent upon the clip's - current in point. - A frame-number of -1, resets the in point to 0. - -FF {unit} - Fast forward the unit. - If the unit it playing, then FF sets the playback speed to -2000 (200% - in reverse). - If the unit is stopped, then the frame position is reset to the first - frame. First frame depends upon the "points" unit configuration property - and whether an in point has been established for the clip using the SIN - command. - -STEP {unit} {number-of-frames} - Adjust the current frame position by the number of frames specified. - Number-of-frames can accept positive or negative values. - -GOTO {unit} {frame-number} [ [+|-]clip ] - Set the current frame position to frame-number. - Frame-number is zero-based and absolute within the clip, which means it is - relative to the file beginning and not the clip in point. - It does not alter the playback status of the unit. - -SIN {unit} {frame-number} [ [+|-]clip ] - Set the currently loaded clip's in point. - The in point is the logical starting frame of the clip. - Frame is zero-based and absolute. It is not dependent upon the clip's - current in point. - A frame-number of -1, resets the in point to 0. - -SOUT {unit} {frame-number} [ [+|-]clip ] - Set the currently loaded clip's out point. - The out point is the logical last frame of the clip. - Frame is zero-based and absolute. It is not dependent upon the clip's - current out point. - A frame-number of -1, resets the out point to the number of frames in - the file minus 1. - -USTA {unit} - Get the unit status report. - The response body contains the following fields delimited by spaces: - - unit number: U0, U1, U2, or U3 without the "U" prefix - - mode: (offline|not_loaded|playing|stopped|paused|disconnected|unknown) - "unknown" means the unit has not been added - "disconnected" means the server has closed a connection to a client running - STATUS. - - current clip name: filename - - current position: in absolute frame number units - - speed: playback rate in (percent * 10) - - fps: frames-per-second of loaded clip - - current in-point: starting frame number - - current out-point: ending frame number - - length of the clip - - buffer tail clip name: filename - - buffer tail position: in absolute frame number units - - buffer tail in-point: starting frame number - - buffer tail out-point: ending frame number - - buffer tail length: length of clip in buffer tail - - seekable flag: indicates if the current clip is seekable (relates to head) - - playlist generation number - - current clip index (relates to head) - - The status contains information based not only on the current frame being - output (current above) but also based upon the most recent frame read by - the disk reader thread and added to the tail of the input buffer queue - (buffer tail above). - -XFER {unit} {target-unit} - Transfer the unit's clip to the target unit. - The clip inherently includes the in- and out-point information. - The target unit's "points" configuration property is set to "use." - - - - diff --git a/mlt/docs/inigo.txt b/mlt/docs/inigo.txt deleted file mode 100644 index 9fa53e1..0000000 --- a/mlt/docs/inigo.txt +++ /dev/null @@ -1,286 +0,0 @@ -INIGO ------ - -Preamble: - - inigo was developed as a test tool for the MLT framework. It can - be thought of as a powerful, if somewhat obscure, multitrack - command line oriented video editor. - - The following details the usage of the tool and as a result, - provides a lot of insight into the workings of the MLT framework. - - -Usage: - - inigo [ -group [ name=value ]* ] - [ -consumer id[:arg] [ name=value ]* ] - [ -filter id[:arg] [ name=value ] * ] - [ -transition id[:arg] [ name=value ] * ] - [ -blank frames ] - [ -track ] - [ producer [ name=value ] * ]+ - [ -serialise file.inigo ] - - -General rules: - - 1. Order is incredibly important; - - 2. Error checking on command line parsing is weak; - - 3. Please refer to services.txt for details on services - available; - - 4. The MLT framework, from which inigo has inherited its - naming convention - is very ego-centric. Producers produce - MLT frame objects and consumers consume MLT frame objects. - The distinction is important - a DV producer does not produce - DV and a DV consumer does not consume DV. - - -Terminoligy: - - 'Producers' typically refer to files but may also indicate - devices (such as dv1394 input or video4linux). Hence, the more - generic term is used [yes, the more generic usage is out of - scope for now...]. - - 'Filters' are frame modifiers - they always guarantee that for - every frame they receive, they output *precisely* one frame. - Never more, never less, ever. - - 'Transitions' collect frames from two tracks (a and b) and - output 1 modified frame on their 'a track', and 1 unmodified - frame on their 'b track'. Never more, never less, ever. - - 'Consumers' collect frames from a producer, do something with - them and destroy them. - - Collectively, these are known as 'services'. - - All services have 'properties' associated to them. These are - typically defaulted or evaluated and may be overriden on a case - by case basis. - - All services except consumers obey in and out properties. - - Consumers have no say in the flow of frames [though they may - give the illusion that they do]. They get frames from a - connected producer, use them, destroy them and get more. - - -Basics: - - To play a file with the default SDL PAL consumer, usage is: - - $ inigo file - - Note that 'file' can be anything that inigo has a known - 'producer' mapping for (so this can be anything from .dv to - .txt). - - -Properties: - - Properties can be assigned to the producer by adding additional - name=value pairs after the producer: - - $ inigo file in=50 out=100 something="something else" - - Note that while some properties have meaning to all producers - (for example: in, out and length are guaranteed to be valid for - all, though typically, length is determined automatically), the - validity of others are dependent on the producer - however, - properties will always be assigned, but it doesn't mean they - will be used. - - -Multiple Files: - - Multiple files of different types can be used: - - $ inigo a.dv b.mpg c.png - - Properties can be assigned to each file: - - $ inigo a.dv in=50 out=100 b.mpg out=500 c.png out=500 - - -Filters: - - The Multiple Files examples above will logically playout one - after the other. - - However, inigo doesn't care too much about changes in frame - dimensions or audio specification, so you may need to add - additional normalising filters to that, ie: - - $ inigo a.dv b.mpg c.png -filter resize -filter resample - - These filters are designed to guarantee that the consumer gets - what it asks for. - - It should also be stressed that filters are applied in the order - in which they're specified. - - -Filter Properties: - - As with producers, properties may be specified on filters too. - - Again, in and out properties are common to all, so to apply a - filter to a range of frames, you would use something like: - - $ inigo a.dv -filter greyscale in=0 out=50 - - Again, filters have their own set of rules about properties and - will silently ignore properties that do not apply. - - -Groups: - - The -group switch is provided to force default properties on the - following 'services'. For example: - - $ inigo -group in=0 out=49 clip* - - would play the first 50 frames of all clips that match the wild - card pattern. - - Note that the last -group settings also apply to the following - filters, transitions and consumers, so: - - $ inigo -group in=0 out=49 clip* -filter greyscale - - is *probably not* what you want (ie: the greyscale filter would - only be applied to the first 50 frames). - - To shed the group properties, you can use any empty group: - - $ inigo -group in=0 out=49 clip* -group -filter greyscale - - -Introducing Tracks and Blanks: - - So far, all of the examples have shown the definition of a - single playlist, or more accurately, track. - - When multiple tracks exist, the consumer will receive a frame - from the 'lowest numbered' track that is generating a non-blank - frame. - - It is best to visualise a track arrangement, so we'll start with - an example: - - $ inigo a.dv out=49 -track b.dv - - This can be visualised as follows: - - +-------+ - |a | - +-------+----------+ - |b | - +------------------+ - - Playout will show the first 50 frames of a and the 51st frame - shown will be the 51st frame of b. - - To have the 51st frame be the first frame of b, we can use the - -blank switch: - - $ inigo a.dv out=49 -track -blank 49 b.dv - - Which we can visualise as: - - +-------+ - |a | - +-------+-------------------+ - |b | - +-------------------+ - - Now playout will continue as though a and b clips are on the - same track (which is about as useful as reversing the process of - slicing bread). - - -Transitions: - - Where tracks become useful is in the placing of transitions. - - Here we need tracks to overlap, so a useful multitrack - definition could be given as: - - $ inigo a.dv out=49 -transition luma in=25 out=49 \ - -track \ - -blank 24 b.dv - - Now we're cooking - our visualisation would be something like: - - +-------+ - |a | - +---+---+--------------+ - |b | - +------------------+ - - Playout will now show the first 25 frames of a and then a fade - transition for 25 frames between a and b, and will finally - playout the remainder of b. - - -Reversing a Transition: - - When we visualise a track definition, we also see situtations - like: - - +-------+ +----------+ - |a1 | |a2 | - +---+---+--------------+----+-----+ - |b | - +-----------------------+ - - In this case, we have two transitions, a1 to b and b to a2. - - In this scenario, we define a command line as follows: - - $ inigo a.dv out=49 -blank 49 a2.dv \ - -transition luma in=25 out=49 \ - -transition luma in=100 out=124 reverse=1 \ - -track \ - -blank 24 b.dv out=99 - - -Filters and Tracks: - - A filter applies to a [specified region of a] single track, so - normalisation filters need to be applied to each track when - applicable. - - This user specification is a necessary evil (you do not want to - resize a text or png overlay to be the size of the frame that - the consumer is requesting, and you may not want to unecessarily - resize a video track if you will be later rescaling it for - composition). - - -Serialisation: - - Inigo has a built in serialisation mechanism - you can build up - your command, test it via any consumer and then add a -serialise - file.inigo switch to save it. - - The saved file can be subsequently used as a clip by either - miracle or inigo. Take care though - paths to files are saved as - provided on the command line.... - - -Missing Features: - - Some filters/transitions should be applied on the output frame - regardless of which track it comes from - for example, you might - have a 3rd text track or a watermark which you want composited - on every frame, and of course, there's the obscure feature.... - - A -post switch will be added to provided this feature at some - point soon. - diff --git a/mlt/docs/services.txt b/mlt/docs/services.txt deleted file mode 100644 index 50f3cad..0000000 --- a/mlt/docs/services.txt +++ /dev/null @@ -1,664 +0,0 @@ -Producers ---------- - - ffmpeg - - Description - - Test case pipe based producer for video and audio. - - Constructor Argument - - 'file' - produce a/v from file - v4l - produce a/v from video4linux and dsp device - - Initialisation Properties - - string video_type - "file" or "v4l" - string video_file - file or v4l device - string video_size - WxH of video to produce (default: "") - int video_loop - loop video until audio exhausted (default: 0) - string audio_type - "file" or "dsp" - string audio_file - file or dsp device - int audio_rate - audio frequency (default: 48000) - int audio_channels - audio channels (default: 2) - int audio_track - audio track to use (default: 0) - int audio_loop - loop audio until video exhausted (default: 0) - intint in - in point - int out - out point - double fps - output frames per second (default: 25) - double aspect_ratio - aspect ratio of video - - Read Only Properties - - string resource - file or "v4l" - int end_of_clip - holds 1 when input is exhausted - - Dependencies - - ffmpeg executable. - - Known Bugs - - in point setting is broken. - - Implementation does not allow fast random access. - - libdv - - Description - - libdv based decoder for video and audio. - - Constructor Argument - - 'file' - produce a/v from file - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - string resource - file location - double fps - output frames per second - double aspect_ratio - aspect ratio of video] - int length - duration of resource (in frames) - - Dependencies - - libdv. - - Known Bugs - - None. - - mcdv - - Description - - Mainconcept based dv decoder for video and audio. - - Constructor Argument - - 'file' - produce a/v from file - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - string resource - file location - double fps - output frames per second - double aspect_ratio - aspect ratio of video - int length - duration of resource (in frames) - - Dependencies - - mainconcept dv sdk and libdv. - "dv_sdk" installed parallel to mlt. - - Known Bugs - - Can be problematic with source NTSC DV files? really? yes - try - playing pond.dv... - - mcmpeg - - Description - - Mainconcept based mpeg decoder for video and audio. - - Constructor Argument - - 'file' - produce a/v from file - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - string resource - file location - double fps - output frames per second - double aspect_ratio - aspect ratio of video - - Dependencies - - mainconcept mpeg sdk. - "mpeg_sdk_demo" installed parallel to mlt. - - Known Bugs - - None. - - pango - - Description - - A title generator that uses the Pango international text layout - and Freetype2 font renderer. - - Constructor Argument - - string file - a text file containing Pango markup, see: - http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html - - requires xml-like encoding special chars: <, >, & to <, >, & - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - int video_standard - enum mlt_video_standard from mlt_frame.h - PAL = 0, NTSC = 1 - this determines proper pixel aspect ratio - - string markup - a string containing Pango markup see: - http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html - - requires xml-like encoding special chars: <, >, & to <, >, & - - int fgcolor - an rgba color specification of the text (i.e. 0xrrggbbaa) - int bgcolor - an rgba color of the background rectangle - int align - paragraph alignment: 0 = left, 1 = center, 2 = right - int pad - the number of pixels to pad the background rectangle beyond edges of text - default 0 - string markup - see constructor argument - string text - non-markup text (can contain markup chars un-encoded) - string font - the default typeface to use when not using markup - default "Sans 48" - int x - the horizontal position of the title on the frame - default 0 - int y - the vertical position of the title on the frame - default 0 - double mix - the overall opacity control of the generated title - default 1.0 - - Read Only Properties - - string resource - the text/markup file or "pango" if no file - - Dependencies - - libpango-1.0, libpangoft2-1.0, libfreetype, libgdk_pixbuf-2.0, libglib-2.0, - libgobject-2.0, libgmodule-2.0, libfontconfig - - Known Bugs - - no frame-alignment functionality - - pixbuf - - Description - - A graphics overlay generator using gdk-pixbuf - - Constructor Argument - - 'file' - The name of a graphics file loadable by - a gdk-pixbuf loader. see /usr/lib/gdk-pixbuf/loaders - definitely png, jpeg, tiff, pnm, and xpm - - If "%" in filename, the filename is used with sprintf - generate a filename from a counter for multi-file/flipbook animation. - The file sequence ends when numeric discontinuity >100. - - If filename contains "/.all.", suffix with an extension to load - all pictures with matching extension from a directory - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - int video_standard - enum mlt_video_standard from mlt_frame.h - PAL = 0, NTSC = 1 - this determines proper pixel aspect ratio - double ttl - how long (seconds) to repeat each picture in file sequences - int x - the horizontal offset from the left edge of the frame - int y - the vertical offset from the top edge of the frame - double mix - the opacity factor to apply to the second frame - (used in addition to alpha channel). - - - Read Only Properties - - string resource - file location - - Dependencies - - libgdk_pixbuf-2.0, libglib-2.0, libgobject-2.0, libgmodule-2.0 - - Known Bugs - - in/out settings are incorrectly handled. - - ppm - - Description - - Reads a stream of contiguous PPM images. - - Constructor Argument - - command - a shell command to run something that produces ppm - streams on stdout. - - Initialisation Properties - - none - - Read Only Properties - - string resource - the command - - Dependencies - - none - - Known Bugs - - Since it uses pipes, it is not compatible with bluefish. - - -Filters -------- - - deinterlace - - Description - - Deinterlace a frame consisting of two fields by linearly blending. - - Constructor Argument - - none - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - Not a bug, but it only provides fair quality at a fair performance; - i.e., it excels at neither. - - ffmpeg_dub - - Description - - Use ffmpeg executable to substitute audio stream. - - Constructor Argument - - file - filename of a WAV, Ogg Vorbis (--enable-vorbis), - MP3 (--enable-mp3lame), or AC-3 (--enable-a52) audio file. - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - string resource - file - - Dependencies - - ffmpeg plus for ffmpeg: - libogg and libvorbis for Ogg Vorbis, libmp3lame for MP3, liba52 for AC-3. - - Known Bugs - - Uses pipes and is therefore not compatible with bluefish. - - gamma - - Description - - Adjust image luma using a non-linear power-law curve - - Constructor Argument - - gamma - a floating point value - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - double gamma - the exponential factor of the power-law curve - - Dependencies - - none - - Known Bugs - - none - - greyscale - - Description - - Convert color image to greyscale - - Constructor Argument - - none - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - none - - resize - - Description - - Image scaling and padding - - Constructor Argument - - scale - "affine" to use affine transform scaling, otherwise - center and pad. - - Initialisation Properties - - int in - in point - int out - out point - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - none - - volume - - Description - - Adjust an audio stream's volume level - - Constructor Argument - - volume - a floating point value of the factor - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - double volume - the factor applied to each sample - - Dependencies - - none - - Known Bugs - - none - - resample - - Description - - Adjust an audio stream's sampling rate - - Constructor Argument - - frequency - a numeric value for the new sample rate - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - int frequency - the target sample rate - - Dependencies - - libresample - - Known Bugs - - none - -Transitions ------------ - - composite - - Description - - An alpha-channel based compositor for two frames. - - Constructor Argument - - mix - see below - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - int x - the horizontal offset from the left edge of the frame - int y - the vertical offset from the top edge of the frame - double mix - the opacity factor to apply to the second frame - (used in addition to alpha channel). - - any negative value causes an automatic dissolve - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - Need to add field-based rendering. - - luma - - Description - - A generic dissolve and wipe transition processor. It gets its name - from how it uses a grayscale "map" file. As the luma value varies - over time, a threshold filter is applied to the map to determine - what parts of frame A vs. frame B to show. It only reads PGM - files, but it does handle 16 bit PGM. This performs field-based - rendering. - - Constructor Argument - - string file - the luma map file name. If not supplied, a dissolve. - - Initialisation Properties - - int in - in point - int out - out point - - Mutable Properties - - string filename - same as above - double softness - only when using a luma map, how soft to make the - edges between A and B. 0.0 = no softness. 1.0 = - too soft. - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - The luma map must be the same size as the B frame. - The PGM parser does not handle comments. - - mix - - Description - - An two stream audio mixer. - - Constructor Argument - - mix - see below - - Initalisation Properties - - int in - in point - int out - out point - - Mutable Properties - - double mix - the mix level to apply to the second frame. - - any negative value causes an automatic crossfade. - - Read Only Properties - - none - - Dependencies - - none - - Known Bugs - - Samples from the longer of the two frames are discarded. - -Consumers ---------- - - bluefish - - Description - - BlueFish444 audio and video output module. - - Constructor Argument - - string video_standard - "PAL" (default) or "NTSC" - - Initialisation Properties - - int video_standard - 0 = PAL, 1 = NTSC - - Read Only Properties - - none - - Dependencies - - BlueVelvet SDK installed parallel to mlt in "bluefish." - - Known Bugs - - Does not work with any service that uses pipes! - - If mlt crashes, you must reload the BlueDriver kernel module - due to unreleased DMA buffers. - - Needs an argument or property for multi-card address. - - ffmpeg - - Description - Constructor Argument - Initialisation Properties - Read Only Properties - Dependencies - Known Bugs - - libdv - - Description - - libdv dv producer. - - Constructor Argument - - string video_standard - "PAL" (default) or "NTSC" - - Initialisation Properties - Read Only Properties - Dependencies - Known Bugs - - sdl - - Description - - Simple DirectMedia Layer audio and video output module. - - Constructor Argument - - string video_standard - "PAL" (default), "NTSC", or "WxH" - - Mutable Properties - - double volume - audio level factor - int video_off - if 1, disable video output - int audio_off - if 1, disable audio output - int scale_overlay - if 1, resample video from source pixel aspect - ratio to square pixels. - - Read Only Properties - - none - - Dependencies - - libSDL-1.2, libasound, libaudio, libXt, libX11, libXext, libSM, libICE - - Known Bugs - - NTSC handling needs tightening up - sdl:NTSC is the only valid - constructor for NTSC playback at the moment. - diff --git a/mlt/docs/testing-20040110.txt b/mlt/docs/testing-20040110.txt deleted file mode 100644 index a8ec933..0000000 --- a/mlt/docs/testing-20040110.txt +++ /dev/null @@ -1,38 +0,0 @@ -On 1/10/2004, Dan Dennedy ran the dv1394d/docs/testing.txt against -mlt albino and miracle. - - -NOTE: Discrepancies cited here may have impact on related functionality. - - -General ------------------------------------------------------------------------------- -Server side error checks and related response error codes are not stringently enforced. - - -Not Implemented ------------------------------------------------------------------------------- -NLS -USET points=ignore -USET eof=terminate -XFER - - -Incorrect Behaviour ------------------------------------------------------------------------------- -killall miracle does not work. requires killall -HUP -USTA when stopped reports "paused" -CLEAN removes all clips (as opposed to leaving the currently playing one) -USET eof=pause is partially supported - - -Different Intentional Behaviour ------------------------------------------------------------------------------- - - -MLT Bugs ------------------------------------------------------------------------------- -Please check the services.txt doc for known bugs related to MLT components. - - - diff --git a/mlt/docs/testing.txt b/mlt/docs/testing.txt deleted file mode 100644 index 8d57a60..0000000 --- a/mlt/docs/testing.txt +++ /dev/null @@ -1,612 +0,0 @@ - -MLT Miracle Test Procedure - -Copyright (C) 2003 Ushodaya Enterprised Limited -Author: Dan Dennedy -Last Revision: 2003-01-17 - -NOTE: THIS DOCUMENT REQUIRES REVISION TO NEW, EXPECTED BEHAVIOR FROM MIRACLE. - -Tests are divided into 9 sections: - - 1. Command Line Usage - 2. Unit Management - 3. Server Configuration - 4. Simple Playback - 5. Multi-unit Playback - 6. Unit Configuration - 7. Advanced Playback - 8. Bus Reset - 9. Server Side Queuing - -Each section contains many tests which I've divided into a minimum of two lines: - -n.m action to carry out ---> expected result - -Further lines may appear to show the actual results when they deviate from what -I expected or if there are special cases to consider. - -Sequential tests are indicated as: - -n.m.o action to carry out ---> expected result - -It is suggested that you run top during the testing and note cpu hikes -or any excessive memory usage related to an operation. - - -0. Introduction ---------------- - -The tests following are by no means exhaustive, but they should cover typical -use cases - creativity is encouraged with more cases being added where necessary. -This document should also be maintained to dictate actual state, especially with -regard to a final release. Unit test cases are encouraged, but are excluded from -this document. - -It is important to carry out the full test cycle when preparing a final release. -In this situation, please resist the temptation to bug fix a given test case and -resume the tests from that point onward - it is better to repeat from the -beginning (but you can of course employ common sense in this situation). - -Before starting the final tests, please delete/backup your current -/etc/dv139d.conf file. This (more or less) ensures that tests are carried out -for a virgin install. - - -1. Command Line Usage ---------------------- - -Run these from the top level project directory - -1.1.0 Start miracle in interactive mode: src/miracle/miracle -test ---> miracle starts interactively and reports: -(5) Starting server on 5250. -(5) miracle version 0.0.1 listening on port 5250 - -1.1.1 Stop the server by pressing Ctrl-C ---> miracle returns the following and returns control to the console: -(5) miracle version 0.0.1 server terminated. - -1.2.2 Start miracle as a daemon: src/miracle/miracle ---> control returns to the console - -1.2.3 Verify miracle is running: ps ax ---> several miracle processes are running - -1.2.4 Verify successful miracle startup using syslog: sudo tail /var/log/syslog ---> miracle: miracle version 0.0.1 listening on port 5250 - -1.2.5 Verify connectivity on port 5250: telnet localhost 5250 ---> 100 VTR Ready - -1.2.6 Test clean disconnect: BYE ---> Connection closed by foreign host. - -1.2.7 Stop the daemon: killall miracle ---> no errors - -1.2.8 Verify a clean server shutdown: sudo tail /var/log/syslog ---> miracle: shutdown complete. - -1.3.0 Start miracle on a different port: src/miracle/miracle -port 5260 - -1.3.1 Verify successful miracle startup using syslog: sudo tail /var/log/syslog ---> miracle: miracle version 0.0.1 listening on port 5260 - -1.3.2 Verify connectivity on port 5260: telnet localhost 5260 ---> 100 VTR Ready - -1.3.3 Test clean disconnect: BYE ---> Connection closed by foreign host. - -1.3.4 Stop the daemon: killall miracle ---> no errors - - -2. Unit Management ------------------- - -Start the miracle server and connect to it with telnet or a protocol- -level client (albino). - -2.1 List the AV/C devices on the bus: NLS ---> 201 OK ---> one or more lines listing devices with GUID in second column - -2.2 Add a device as a miracle unit: UADD {sdl, bluefish}:{NTSC, PAL} ---> 201 OK ---> U0 - -2.3 List the units: ULS ---> 201 OK ---> U0 ?? {sdl, bluefish} 1 ---> It is important that the last column is '1' to indicate it is online. - -2.4 Add an offline unit by using some bogus GUID value: UADD foo ---> 201 OK ---> U1 - -2.3 List the units: ULS ---> 201 OK ---> U0 ?? {GUID} 1 ---> U1 00 0000000f00055c1 0 ---> It is important that the last column of the last row is '0' to - indicate offline. - -2.4 Attempt unit commands for a unit that does not exist: LOAD U6 foo ---> 403 Unit not found - -2.5 Attempt unit commands without specifying a unit: PLAY ---> 402 Argument missing - -2.6 Attempt unit commands for a unit that is offline: PLAY U1 ---> 403 Unit not found - -2.7.0 Load a clip into an offline unit: LOAD U1 test.dv ---> 200 OK - -2.7.1 Verify the status of the offline unit: USTA U1 ---> 202 OK ---> 1 offline "test.dv" 0 1000 25.00 0 ... ---> only the first 3 columns are relevant in this test - -2.9 Set the property of an online unit: USET U0 points=use ---> 200 OK - -2.8 Set the property of an offline unit: USET U1 points=ignore ---> 200 OK - - -3. Server Configuration ------------------------ - -Start miracle if not already started from a previous test. - -3.1 Get the hard-coded default root property value: GET root ---> 202 OK ---> / - -3.2 List the files and subdirectories at the root: CLS / ---> 201 OK ---> "bin/" ---> ... - -3.3 Change the server root to a place where clips are stored: e.g., - SET root=/tmp ---> 200 OK - -3.4 Get the new value of the root property value: GET root ---> 202 OK ---> /tmp/ ---> Notice that if you did not use a trailing slash in step 2.3, one is - added for you and appears in this step. This is normal and correct. - -3.5 List the files and subdirectories at the root: CLS / ---> 201 OK ---> zero or more lines listing subdirectories followed by files. - -3.6 Try to set a property that does not exist: SET foo=bar ---> 405 Argument value out of range - -3.7 Try to set no property or value: SET ---> 402 Argument missing - -3.8 Attempt a bogus command: FOO ---> 400 Unknown command - -XXX 3.9 Attempt the incorrect case for a command: get root -XXX --> 400 Unknown command - -3.10 Attempt case insensitivity of property key: GET Root ---> 202 OK ---> /tmp/ - - -4. Simple Playback -------------------- - -Start miracle or restart if already started. -Add an online unit. -Set the server root property if desired. - -4.1.0 Load a clip into the unit: LOAD U0 test.dv ---> 200 OK - -4.1.1 Check the unit status: USTA U0 ---> 202 OK ---> 0 stopped "test.dv" 0 1000 25.00 0 ... ---> Only the first 3 columns are relevant in this test. ---> The remaining columns are only relevant to the tester. - -4.2.0 Play the clip: PLAY U0 ---> 200 OK ---> Verify audio and video output - -4.2.1 Check the unit status: USTA U0 ---> 202 OK ---> 0 playing "test.dv" 1739 1000 25.00 0 ... ---> Only the first 3 columns are relevant in this test. ---> The remaining columns are only relevant to the tester. - -4.3.0 Pause playback: PAUSE U0 ---> 200 OK ---> Verify video continues, but audio is muted. - -4.3.1 Check the unit status: USTA U0 ---> 202 OK ---> 0 paused "test.dv" 1739 0 25.00 0 ... ---> The fifth column --------^ should be 0; it indicates speed. - -4.3.2 Stop playback: STOP U0 ---> 200 OK ---> The analog video output stops - -4.3.3 Pause playback: PAUSE U0 ---> 200 OK ---> Analog video starts again, but it is held on the same frame - paused in 4.3.0. - -4.3.4 Stop playback: STOP U0 ---> 200 OK ---> The analog video signal ceases. - -4.3.5 Rewind the unit: REW U0 ---> 200 OK - -4.3.6 Play the unit: PLAY U0 ---> 200 OK ---> Analog audio and video are produced from the beginning of the file. - -4.4 Stop the server during playback and ensure clean shutdown. - - -5. Multi-unit Playback ------------------------ - -Start miracle or restart if already started. -Add *2* online units. -Set the server root property if desired. - -5.1.0 Load a clip into one unit: LOAD U0 test.dv ---> 200 OK - -5.1.1 Load a clip into the other unit: LOAD U1 test.dv ---> 200 OK - -5.1.2 Start playing one unit: PLAY U0 ---> 200 OK ---> Verify audio and video output - -5.1.3 Start playing the other unit: PLAY U1 ---> 200 OK ---> Verify audio and video output of both units - -5.2 Verify independence of units by pausing one of them: PAUSE U0 ---> 200 OK ---> Verify video continues, but audio is muted on the first unit only. - -5.3 Stop the server during multi-unit playback and ensure clean shutdown. - - -6. Advanced Playback --------------------- - -Start miracle or restart if already started. -Add *2* online units. -Set the server root property if desired. - -Trick play modes: - -6.1.0 Load a clip: LOAD U0 test.dv ---> 200 OK - -6.1.1 Start playback by pausing on the first frame: PAUSE U0 ---> 200 OK ---> analog video starts, but audio is muted. - -6.1.2 Play fast forward: FF U0 ---> 200 OK ---> verify video is playing fast in the forward direction. - -6.1.3 Get unit status: USTA U0 ---> 202 OK ---> 0 playing "test.dv" 219 2000 25.00 0 ... ---> The important column is --^, indicates speed - -6.1.4 Play fast reverse: REW U0 ---> 200 OK ---> verify analog video output is fast in the reverse direction. - -6.1.5 Get unit status: USTA U0 ---> 202 OK ---> 0 playing "test.dv" 4621 -2000 25.00 0 ... ---> The important column is ---^, negative mean reverse - -6.1.6 Play slow forward: PLAY U0 500 ---> 200 OK ---> Verify the analog video output is slow in the forward direction. - -6.1.7 Play reverse normal speed: PLAY U0 -1000 ---> 200 OK ---> Verify the analog video output is at a normal speed in the reverse direction. ---> Audio output is reverse, but not the field order of video - -Loading while playing: - -6.2.0 Stop the unit (might be playing): STOP U0 ---> 200 OK - -6.2.1 Rewing the unit: REW U0 ---> 200 OK - -6.2.2 Start playing: PLAY U0 ---> 200 OK ---> verify analog audio and video output - -6.2.3 Load another clip: LOAD test002.dv ---> 200 OK ---> playback seamlessly switches to the new clip ---> verify the analog appearance of the video makes a clean switch - -6.2.4 Load another clip, this time with in and out points: - LOAD test.dv 100 500 (whatever works for your test footage) ---> 200 OK ---> verify the analog appearance of the video makes a clean switch - -6.2.5 Get unit status: USTA U0 ---> 202 OK ---> 0 playing "test.dv" 403 1000 25.00 100 ... ---> verify position -----^ is beyond --^ in point, last column is the out - point specified in the previous step. - -Edit points: - -6.3.0 Load a clip: LOAD U0 test.dv ---> 200 OK - -6.3.1 Pause the playback unit: PAUSE U0 ---> 200 OK - -6.3.2 Set the in point: SIN U0 100 ---> 200 OK ---> verify the frame displayed in analog video out changes - -6.3.4 Get the unit status: USTA U0 ---> 202 OK ---> 0 paused "test.dv" 100 0 25.00 100 ... ---> verify position ---^ and in ---^ - -6.3.5 Change the mode of the unit to not restrict playback to the edit - region: USET U0 points=ignore ---> 200 OK - -6.3.6 Jump to a frame before the in frame: GOTO U0 50 ---> 200 OK - -6.3.7 Get the unit status: USTA U0 ---> 202 OK ---> 0 paused "test.dv" 50 0 25.00 100 ... ---> position ----------^ preceeds -^ (in) - -6.3.8 Set the unit mode to restrict playback to the edit region: USET U0 points=use ---> 200 OK ---> verify frame on analog video output changes - -6.3.9 Get the unit status: USTA U0 ---> 202 OK ---> 0 paused "test.dv" 100 0 25.00 100 ... ---> verify position ---^ and in ---^ - -6.3.10 Clear the in point: SIN U0 -1 ---> 200 OK - -6.3.11 Get the unit status: USTA U0 ---> 202 OK ---> 0 paused "test.dv" 100 0 25.00 0 ... ---> verify the in point is reset --^ - -The above sequence should be repeated in a similar manner for the out point -using the SOUT command. - -Transfer: - -6.4.0 Load a clip into the first unit: LOAD U0 test.dv ---> 200 OK - -6.4.1 Load a clip into the second unit: LOAD U1 test002.dv ---> 200 OK - -6.4.2 Start playing the first unit: PLAY U0 ---> 200 OK ---> verify audio and video analog output - -6.4.3 Set an in point on the clip in the second unit: SIN U1 100 ---> 200 OK - -6.4.4 Play the second unit: PLAY U1 ---> 200 OK ---> note the beginning footage - -6.4.5 Transfer the clip from the second to the first unit: XFER U1 U0 ---> 200 OK ---> verify a clean switch on the analog audio and video output of the first unit. ---> upon transfer it should play the same footage previewed in step 6.4.4 - -6.4.5 Get the first unit's status: USTA U0 ---> 202 OK ---> 0 playing "test002.dv" 963 1000 29.97 100 2502 ---> note the in point set from U1 ---------^ - - -7. Unit Configuration ---------------------- - -Start miracle or restart if already started. -Add an online unit. -Set the server root property if desired. - -7.1.0 Load a short clip: LOAD U0 test.dv ---> 200 OK - -7.1.1 Play a clip: PLAY U0 ---> 200 OK ---> Wait until it gets to the end, and it should pause on the last frame. - -7.1.2 Make the clip start looping: USET U0 eof=loop ---> 200 OK ---> verify the clip starts playing from the beginning and loops - -7.2.0 Set the in point: SIN U0 10 ---> 200 OK ---> playback pauses at in point (verify with USTA U0) - -7.2.1 Set the out point: SOUT U0 200 ---> 200 OK ---> playback pauses at in point (verify with USTA U0) - -7.2.2 Start playing again: PLAY U0 ---> 200 OK ---> verify playback loops between in and out points - -7.3 Tell the unit to ignore the edit points: USET U0 points=ignore ---> 200 OK ---> verify playback loops over entire video file - -7.4 Get the current value of the points property: UGET U0 points ---> 202 OK ---> ignore - - -9. Server Side Queuing ----------------------- - -Only one unit is used for these test cases, and -users are encouraged to test with multiple units online. It is assumed that a -number of dv files are available for use in the servers ROOT directory - this -document assumes that they are named test001.dv and up. - -9.1.0 Start miracle in interactive mode and add a unit (all tests will assume U0) ---> server started with unit 0 available - -9.1.1 Obtain a miracle shell (via telnet or albino). ---> 100 VTR (if reported by the client) - -9.1.2 Load a clip with LOAD U0 test001.dv and PAUSE U0 ---> 200 OK - -9.1.3 List the clips with LIST U0 ---> 201 OK ---> 1 ---> 0 "test001.dv" 0 6999 7000 7000 25.00 ---> The 1 on the second line denotes the number of times the list has been changed - via user commands (known as the 'generation' number). ---> The third line and beyond reports the clip index (from 0 to n), file loaded, in point, - out point, real size of the file and the calculated size (out - in + 1 ). - -9.1.4 Check the unit status with USTA U0 ---> 202 OK ---> 0 paused "test001.dv" 0 0 25.00 0 6999 7000 "test001.dv" 0 0 6999 7000 1 1 0 ---> The last two fields indicate the generation number and current clip resp. - -9.1.5 Append a clip with APND U0 test002.dv followed by LIST U0 ---> 201 OK ---> 2 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 2 and current clip of 0 - -9.1.6 Move clip 1 to clip 0 with MOVE U0 1 0 followed by LIST U0 ---> 201 OK ---> 3 ---> 0 "test002.dv" 0 6999 7000 7000 ---> 1 "test001.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 3 and current clip of 1 - -9.1.7 Move clip 0 to clip 1 with MOVE U0 0 1 followed by LIST U0 ---> 201 OK ---> 4 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 4 and current clip of 0 ---> Note that the order in which you run 9.1.6 and 9.1.7 shouldn't matter as the - result will be identical - -9.1.8 Change the position to the next clip with GOTO U0 0 +1 ---> 200 OK ---> Check that USTA U0 reports a generation of 4 and current clip of 1 - -9.1.9 Remove all but the playing clip with CLEAN U0 followed by LIST U0 ---> 201 OK ---> 5 ---> 0 "test002.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 5 and current clip of 0 - -9.1.10 Insert test001.dv back into the list using INSERT U0 test001.dv and run LIST U0 ---> 201 OK ---> 6 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 6 and current clip of 1 - -9.1.11 Insert test003.dv at position 2 using INSERT U0 test001.dv 3 and run LIST U0 ---> 201 OK ---> 7 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 0 6999 7000 7000 ---> 2 "test003.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 7 and current clip of 1 - -9.1.12 Change the in point of the current clip using SIN U0 5000 and run LIST U0 ---> 201 OK ---> 8 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 2000 ---> 2 "test003.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 8 and current clip of 1 - -9.1.13 Change the out point of the following clip using SOUT U0 5000 +1 and run LIST U0 ---> 201 OK ---> 9 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 2000 ---> 2 "test003.dv" 0 5000 7000 5001 ---> Check that USTA U0 reports a generation of 9 and current clip of 2 - -9.1.14 Change the in point of the current clip to 1000 using SIN U0 1000 and run LIST U0 ---> 201 OK ---> 10 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 2000 ---> 2 "test003.dv" 1000 5000 7000 4001 ---> Check that USTA U0 reports a generation of 10 and current clip of 2 - -9.1.15 Ignore the in/out points by running USET U0 points=ignore and run LIST U0 ---> 201 OK ---> 11 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 7000 ---> 2 "test003.dv" 1000 5000 7000 7000 ---> Check that USTA U0 reports a generation of 11 and current clip of 2 - -9.1.16 Turn the in/out points on again by running USET U0 points=use and run LIST U0 ---> 201 OK ---> 12 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 2000 ---> 2 "test003.dv" 1000 5000 7000 4001 ---> Check that USTA U0 reports a generation of 12 and current clip of 2 - -9.1.17 Remove the current clip using REMOVE U0 and run LIST U0 ---> 201 OK ---> 13 ---> 0 "test001.dv" 0 6999 7000 7000 ---> 1 "test002.dv" 5000 6999 7000 2000 ---> Check that USTA U0 reports a generation of 13 and current clip of 0 - -9.1.17 Remove the next clip using REMOVE U0 +1 and run LIST U0 ---> 201 OK ---> 14 ---> 0 "test001.dv" 0 6999 7000 7000 ---> Check that USTA U0 reports a generation of 14 and current clip of 0 diff --git a/mlt/docs/valerie.txt b/mlt/docs/valerie.txt deleted file mode 100644 index a5abcce..0000000 --- a/mlt/docs/valerie.txt +++ /dev/null @@ -1,861 +0,0 @@ -VALERIE API Documentation - -Copyright (C) 2003 Ushodaya Enterprised Limited -Author: Charles Yates -Last Revision: 2004-01-11 - - -TABLE OF CONTENTS ------------------ - - 0. Overview - 0.1. Intended Audience - 0.2. Terminology - 1. Definition of a Parser - 1.1. Construction of a Local Parser - 1.2. Construction of a Remote Parser - 1.3. Using the Parser - 1.4. Closing the Parser - 2. The High Level Parser Wrapper - 2.1. Connecting - 2.2. valerie_error_code - 2.3. Using the High Level Wrapper - 2.4. Obtaining Directory Contents - 2.5. Obtaining the Node List - 2.6. Obtaining the Unit List - 2.7. Unit Status Information - 2.8. Server Side Queuing APIs - 2.9. Accessing the Low Level Parser Directly - 2.10. Cleaning up - 2.11. Examples - 3. The Low Level Parser API - 3.1. Executing a Command - 3.2. Interpreting valerie_response - 3.3. Accessing Unit Status - APPENDIX A - COMPILATION AND LINKING - APPENDIX B - COMPLETE HIGH LEVEL PARSER WRAPPER API LISTING - APPENDIX C - COMPLETE LOW LEVEL PARSER API LISTING - APPENDIX D - REFERENCES - - -0. Overview ------------ - - This document details how applications interface to DVCP functionality. - - -0.1. Intended Audience ----------------------- - - This document draws heavily upon the DVCP design (1) and assumes a basic - knowledge of the functionality provided by the DVCP core. - - It is aimed at developers who wish to use or maintain the API. - - -0.2. Terminology ----------------- - - The API is designed to allow client applications the ability to communicate - to a standalone miracle server or entirely embed the DVCP core in an - instance of a client application. - - The distinction between the two is defined by the construction of the - 'parser'. - - This 'parser' can be used to issue DVCP commands and receive responses and - a 'high level parser wrapper' is provided to simplify the usage and - decouple the application from the DVCP command set. - - -1. Definition of a Parser -------------------------- - - The parser provides a low level API which allows text DVCP commands to be - executed with responses being returned to the caller. Commands and - responses are ASCII formatted text. - - Two parsers are provided - local and remote. - - The local parser is the physical implementation which takes commands and - executes them. - - The remote parser is a network abstraction that forwards commands to a - miracle instance that hosts a local parser. - - -1.1. Construction of a Local Parser ------------------------------------ - - To construct a local parser you must have: - - #include - - and code to initialise the parser is as follows: - - valerie_parser parser = miracle_parser_init_local( ); - - See Appendix A for compilation and linking details. - - -1.2. Construction of a Remote Parser ------------------------------------- - - To construct a remote parser you must have: - - #include - - and code to initialise the parser is as follows: - - valerie_parser parser = valerie_parser_init_remote( "server", port ); - - See Appendix A for compilation and linking details. - - -1.3. Using the Parser ---------------------- - - Although the parser can be used directly to send commands and receive - responses, this low level usage puts the onus on the developer to parse the - responses in a meaningful way. - - Although this usage is not strictly forbidden by applications, it is - discouraged as construction of commands and meaningful parsing of responses - leads to the clients being unnecessarily dependent on the servers input and - output. - - As a result, a higher level Parser Wrapper API is provided - this API - encapsulates the command construction and response parsing. - - The following 2 sections provide details on these modes of access. - - -1.4. Closing the Parser ------------------------ - - Regardless of use, it is the constructors responsibility to close the - parser before it goes out of scope. This is done via: - - valerie_parser_close( parser ); - - -2. The High Level Parser Wrapper --------------------------------- - - The recommended way to access the parser, is via the valerie API. To use - this API, you must have: - - #include - - and code to construct the wrapper is: - - valerie dv = valerie_init( parser ); - - Note that either remote or local parsers can be used here and there is no - difference in usage, though some error returns will not be applicable to - both. - - It is recommended that applications honour and deal with the error returns - of both as this allows applications to interchange parsers. - - Also note that valerie is not threadsafe, so you should not use the same - structure in multiple threads. The correct solution to this is to create a - valerie per thread - you may safely use the same parser for each thread ie: - - /* valerie for the application */ - valerie dv = valerie_init( parser ); - /* valerie for the status handling thread. */ - valerie dv_status = valerie_init( parser ); - - For the purposes of simplification, the remainder of this section assumes - that a remote parser is in use. - - -2.1. Connecting ---------------- - - Once constructed, the next thing to do is 'connect': - - valerie_error_code error = valerie_connect( dv ); - - This function call initialises the parser (ie: if it's remote, it - establishes a connection to the server, or if it's local, it initialises - the state of the units and supporting objects). - - Note that if you have multiple valerie instances on the same parser you - should only connect one of the instances. - - -2.2. valerie_error_code ----------------------- - - All but a couple of the functions that make up the valerie API return a - valerie_error_code. - - These are defined as follows: - - valerie_ok = 0, - valerie_malloc_failed, - valerie_unknown_error, - valerie_no_response, - valerie_invalid_command, - valerie_server_timeout, - valerie_missing_argument, - valerie_server_unavailable, - valerie_unit_creation_failed, - valerie_unit_unavailable, - valerie_invalid_file, - valerie_invalid_position - - In most cases, it is sufficient to check on a return of valerie_ok. - - To obtain a textual description of a particular error, you can use: - - char *valerie_error_description( valerie_error_code ); - - -2.3. Using the High Level Wrapper ---------------------------------- - - The following code snippet assumes that dv is an initialised and connected - valerie structure: - - valerie_error_code error = valerie_unit_play( dv, 0 ); - if ( error == valerie_ok ) - fprintf( stderr, "Unit 0 is now playing\n" ); - else - fprintf( stderr, "Play on unit 0 failed: %s\n", - valerie_error_description( error ) ); - - The complete interface to valerie is listed in Appendix B of this document. - - -2.4. Obtaining Directory Contents --------------------------------- - - To obtain a list of files and subdirectories in a given directory relative - to the ROOT property of the server, DVCP provides the CLS command. - - A valid execution of CLS would be something like: - - CLS "/Stuff" - - would provide a response formatted as follows: - - 201 OK - "More Stuff/" - "file0001.dv" 15552000 - "file0002.dv" 15552000 - - with a trailing empty line. - - The first line indicates the error value, the second line shows an example - of a subdirectory and the 3rd and 4th line lists two files that happen to - exist in the directory. - - valerie provides a high level view on this which automatically parses the - response from the server correctly via the valerie_dir structures and - related functions. - - An example of use is as follows: - - valerie_dir dir = valerie_dir_init( dv, "/Stuff" ); - valerie_error_code error = valerie_dir_get_error_code( dir ); - if ( error == valerie_ok ) - { - if ( valerie_dir_count( dir ) > 0 ) - { - valerie_dir_entry_t entry; - int index = 0; - for ( index = 0; index < valerie_dir_count( dir ); index ++ ) - { - valerie_dir_get( dir, index, &entry ); - if ( entry.dir ) - printf( "<%s>\n", entry.name ); - else - printf( "%30s %8d", entry.name, entry.size ); - } - } - else - { - fprintf( stderr, "Directory is empty\n" ); - } - } - else - { - fprintf( stderr, "Directory listing failed: %s\n", - valerie_error_description( error ) ); - } - valerie_dir_close( dir ); - - Note that entry.name provides the name of the file or directory without the - directory prefix. As a convenience, entry.full provides the prefixed name, - so you could subsequently use: - - error = valerie_unit_load( dv, 0, entry.full ); - - to load unit 0 with an entry. - - -2.5. Obtaining the Node List ----------------------------- - - Currently not defined by miracle. - -2.6. Obtaining the Unit List ----------------------------- - - To obtain a list of defined units, DVCP provides the ULS command. - - A valid execution of ULS would be: - - ULS - - and would provide a response formatted as follows: - - 201 OK - U0 00 sdl:360x288 1 - - with a trailing empty line. - - The fields of each record in the response dictate unit, node, mlt consumer and - online status respectively. - - valerie provides a high level view on this which automatically parses the - response from the server correctly via the valerie_units structures and - related functions. - - An example of use is as follows: - - valerie_units units = valerie_units_init( dv ); - valerie_error_code error = valerie_units_get_error_code( units ); - if ( error == valerie_ok ) - { - if ( valerie_units_count( units ) > 0 ) - { - valerie_unit_entry_t entry; - int index = 0; - for ( index = 0; index < valerie_units_count( units ); index ++ ) - { - valerie_units_get( units, index, &entry ); - printf( "U%d %02d %s %s\n", - entry.unit, - entry.node, - entry.guid, - entry.online ? "online" : "offline" ); - } - } - else - { - fprintf( stderr, "Unit list is empty\n" ); - } - } - else - { - fprintf( stderr, "Unit listing failed: %s\n", - valerie_error_description( error ) ); - } - valerie_units_close( units ); - - -2.7. Unit Status Information ----------------------------- - - There are two methods for a client to obtain unit status information. - - The first is via the DVCP USTA command, which would normally be accessed - via: - - USTA U0 - - and would provide a response formated as follows: - - 202 OK - 0 playing "a.dv" 58 1000 25.00 0 6999 7000 "a.dv" 157 0 6999 7000 1 4 0 - - with no trailing empty line. - - The entries in the record are: - - * Unit - * State (undefined, offline, not_loaded, stopped, playing, - paused, disconnected [when server dies]) - * Name of Clip - * Position in clip - * Speed * 1000 - * Frames per second - * Start of clip (in point) - * End of clip (out point) - * Length of clip - * Read ahead clip - * Read ahead position - * Read ahead clip in - * Read ahead clip out - * Read ahead clip length - * Seekable flag - * Playlist generation - * Clip index - - Again, valerie provides a high level means for obtaining this via the - valerie_unit_status function and valerie_status structures: - - valerie_status_t status; - valerie_error_code error = valerie_unit_status( dv, 0, &status ); - if ( error == valerie_ok ) - { - switch( status.status ) - { - case unit_offline: - printf( "offline " ); - break; - case unit_undefined: - printf( "undefined " ); - break; - case unit_not_loaded: - printf( "unloaded " ); - break; - case unit_stopped: - printf( "stopped " ); - break; - case unit_playing: - printf( "playing " ); - break; - default: - printf( "unknown " ); - break; - } - - printf( "%06lld %06lld %06lld %s\n", status.in, - status.position, - status.out, - status.clip ); - } - else - { - fprintf( stderr, "Unit status failed: %s\n", - valerie_error_description( error ) ); - } - - The second approach for obtaining a units status is via automatic - notification. - - This is done via the valerie_notifier API. To obtain the notifier from the - high level API, you can use: - - valerie_notifier notifier = valerie_get_notifier( dv ); - - To obtain the last status associated to a unit, you can use: - - int unit = 1; - valerie_status_t status; - valerie_notifier_get( notifier, &status, unit ); - - To wait for the next status from any unit, you can use: - - valerie_notifier_wait( notifier, &status ); - - If you wish to trigger the action associated to your applications wait - handling of a particular unit, you can use: - - valerie_notifier_get( notifier, &status, unit ); - valerie_notifier_put( notifier, &status ); - - See Examples below for details on this. - - The complete list of fields in the status structure are: - - int unit; - unit_status status; - char clip[ 2048 ]; - int64_t position; - int speed; - double fps; - int64_t in; - int64_t out; - int64_t length; - char tail_clip[ 2048 ]; - int64_t tail_position; - int64_t tail_in; - int64_t tail_out; - int64_t tail_length; - int seekable; - int generation; - int clip_index; - - You will always receive a status record for every frame output. - - The read ahead information is provided for client side queuing. Client side - queuing assumes that uset eof=pause is applied to the unit. A client can - detect when the previously scheduled clip is played out by using the read - ahead information and schedule the next clip. While this mode of operation - is still supported, it is recommended that new clients use the server side - queuing mechanism which is described in the following section. - - -2.8. Server Side Queueing APIs ------------------------------- - - This section describes the APIs available to provide server side queueing. - - The concept is that each unit maintains its own playlist, containing multiple - clips. Associated to the playlist is a generation number which is incremented - on each modification to the playlist. The current playlist generation is - provided in the status record in order for a client to know when to refresh - its presentation of the list. The status record also indicates which clip is - currently active. - - Actions that can be carried out on the playlist are summarised as: - - * list - list all the clips and associated in/out points and size - * loading a clip - a load will wipe the current list and replace it with the - specified clip - * appending a clip - append will always place the specified clip at the end - of the playlist - * inserting a clip - insert will place a new clip at the specified position - in the playlist - * moving a clip - move will allow clips can be moved in the playlist - * removing a clip - remove will remove the specified clip from the playlist - * clean - clean will remove all but the playing clip from the playlist - - Additionally, the following existing actions are clip aware: - - * goto allows you to move the current play position to a specific clip position - * set in/out points allows you to modify clip in and out points - - Backward compatability has been maintained by the addition of a clip-aware - family of APIs which have the naming convention of valerie_unit_clip_*. - - These are listed in Appendix B. - - The following shows an example of obtaining the clips queued on unit 0: - - valerie_list list = valerie_list_init( dv, 0 ); - valerie_list_entry_t entry; - int index; - - printf( "Generation = %d\n", list->generation ); - for ( index = 0; index < valerie_list_count( list ); index ++ ) - { - valerie_list_get( list, index, &entry ); - printf( "%d %s %d %d %d %d\n", - entry.clip, - entry.full, - entry.in, - entry.out, - entry.max, - entry.size ); - } - valerie_list_close( list ); - - To load a clip on unit 0: - - valerie_unit_load( dv, 0, "/path/clip.dv" ); - - To append a clip on unit 0: - - valerie_unit_append( dv, 0, "/path/clip.dv", -1, -1 ); - - Note that the last two arguments specify the in and out points of the clip - with -1 denoting dfaults of the entirety of the file. - - To insert a clip at position 0 on unit 0, we can use the following: - - valerie_unit_clip_insert( dv, 0, clip_absolute, 0, "/path/clip.dv", -1, -1 ); - - The 3rd and 4th arguments here are common to all the valerie_unit_clip functions. - They take the form of either [clip_absolute, n] to indicate an absolute clip - index, or [clip_relative, n] to indicate a clip index relative to the - currently playing clip. - - So, to insert a clip immediately before the currently playing clip, we can - use: - - valerie_unit_clip_insert( dv, 0, clip_relative, -1, "/path/clip.dv", -1, -1 ); - - To move the current clip to the next position in the list: - - valerie_unit_clip_move( dv, 0, clip_relative, 0, clip_relative, 1 ); - - To remove a specific clip: - - valerie_unit_clip_remove( dv, 0, clip_absolute, index ); - - To remove all but the currently playing clip: - - valerie_unit_clean( dv, 0 ); - - To goto the first frame in the first clip, you can use: - - valerie_unit_clip_goto( dv, 0, clip_absolute, 0, 0 ); - - To set the in and out points on the current clip: - - valerie_unit_clip_set_in( dv, 0, clip_relative, 0, 0 ); - valerie_unit_clip_set_out( dv, 0, clip_relative, 0, 1000 ); - - A more complete example of use of the server side can queuing can be found - at: - - http://users.pandora.be/acp/gdv1394 - - The demo client provided with valerie is used for retaining backward - compatability with the client side queuing API. - - -2.9. Accessing the Low Level Parser Directly --------------------------------------------- - - The low level parser and its associated structures can be accessed directly - from the high level API, but is very occasionally actually needed. - - The methods are provided via a pair of high level methods: - - valerie_error_code error = valerie_execute( dv, 1024, "USTA U%d", unit ); - valerie_response response = valerie_get_last_response( dv ); - int index = 0; - for ( index = 0; index < valerie_response_count( response ); index ++ ) - printf( "%d: %s\n", index, valerie_response_get_line( response,index ) ); - - More details on the valerie_response structure can be found in section 3 of this - document. - - -2.10. Cleaning up ------------------ - - Before the valerie and parser go out of scope, you need to run: - - valerie_close( dv ); - valerie_parser_close( parser ); - - Note that you should close all valerie instances before closing the parser. - - -2.11. Examples --------------- - - Please refer to albino and humperdink source for examples provided with - the project. Additional examples can be found via google with gdv1394 and - poldo. - - -3. The Low Level Parser API ---------------------------- - - The low level parser API provides a very simple mechanism for constructing - commands and receiving responses. - - As described in section 2, a parser is constructed as local or remote and - this is sufficient for constructing the low level parser. - - -3.1. Executing a Command ------------------------- - - All commands can be executed via the single variable argument function - valerie_parser_executef and this function returns a valerie_response, ie: - - valerie_response response = valerie_parser_executef( parser, "CLS \"%s\"", dir ); - - Note that no carriage return/line feed is required (adding this is - erroneous). - - It is the receiver of the response who is responsible for closing it. - - valerie_response_close( response ); - - -3.2. Interpreting valerie_response ------------------------------ - - The response received can be NULL, but it is safe to call: - - int error = valerie_response_get_error_code( response ); - - which will return: - - * -1 if response is NULL, - * -2 if there is no content to the response, - * 0 if the responses first line does not correspond to a valid DVCP response - * or the DVCP protocol error code returned on the first line of the response - - A simple use of a valerie_response structure is as follows: - - valerie_response response = valerie_parser_executef( parser, "CLS \"%s\"", dir ); - int error = valerie_response_get_error_code( response ); - if ( error >= 0 ) - { - int index = 0; - for ( index = 0; index < valerie_response_count( response ); index ++ ) - printf( "%3d: %s\n", index, valerie_response_get_line( response, index ) ); - } - else - { - /* interpret error */ - } - valerie_response_close( response ); - - Note that it is safe to call valerie_response_close regardless of the error - condition indicated. - - -3.3. Accessing Unit Status --------------------------- - - As with the high level parser, there are two alternatives to obtain unit - status information - either via the USTA DVCP command or via the - valerie1394_notifier. - - The latter is the recommended way for any applications which wish to extract - meaningful information from the status while avoiding the requirement to - duplicate the parsing process in a specific client. - - The notifier can be obtained by: - - valerie_notifier notifier = valerie_parser_get_notifier( parser ); - - The use of the notifier with the low level parser is identical to that - dictated in Section 2 - to obtain the last status associated to a unit, - you can use: - - int unit = 1; - valerie_status_t status; - valerie_notifier_get( notifier, &status, unit ); - - To wait for the next status from any unit, you can use: - - valerie_notifier_wait( notifier, &status ); - - -APPENDIX A - COMPILATION AND LINKING ------------------------------------- - - Compilation flags are: - - -I /include - - where prefix defaults to /usr/local. - - Linking flags for a client are: - - -L /lib/ -lvalerie - - Or for a local parser: - - -L /lib/ -lmiracle - - Note that you never need both libs. - - -APPENDIX B - COMPLETE HIGH LEVEL PARSER WRAPPER API LISTING ------------------------------------------------------------ - - valerie valerie_init( valerie_parser ); - - valerie_error_code valerie_connect( valerie ); - - valerie_error_code valerie_set( valerie, char *, char * ); - valerie_error_code valerie_get( valerie, char *, char *, int ); - - valerie_error_code valerie_unit_add( valerie, char * ); - valerie_error_code valerie_unit_load( valerie, int, char * ); - valerie_error_code valerie_unit_load_clipped( valerie,int,char *,long,long ); - valerie_error_code valerie_unit_load_back( valerie, int, char * ); - valerie_error_code valerie_unit_load_back_clipped(valerie,int,char *,long,long) - valerie_error_code valerie_unit_play( valerie, int ); - valerie_error_code valerie_unit_play_at_speed( valerie, int, int ); - valerie_error_code valerie_unit_stop( valerie, int ); - valerie_error_code valerie_unit_pause( valerie, int ); - valerie_error_code valerie_unit_rewind( valerie, int ); - valerie_error_code valerie_unit_fast_forward( valerie, int ); - valerie_error_code valerie_unit_step( valerie, int, int ); - valerie_error_code valerie_unit_goto( valerie, int, int ); - valerie_error_code valerie_unit_set_in( valerie, int, int ); - valerie_error_code valerie_unit_set_out( valerie, int, int ); - valerie_error_code valerie_unit_clear_in( valerie, int ); - valerie_error_code valerie_unit_clear_out( valerie, int ); - valerie_error_code valerie_unit_clear_in_out( valerie, int ); - valerie_error_code valerie_unit_set( valerie, int, char *, char * ); - valerie_error_code valerie_unit_get( valerie, int, char * ); - - valerie_error_code valerie_unit_status( valerie, int, valerie_status ); - valerie_notifier valerie_get_notifier( valerie ); - - valerie_dir valerie_dir_init( valerie, char * ); - valerie_error_code valerie_dir_get( valerie_dir, int, valerie_dir_entry ); - int valerie_dir_count( valerie_dir ); - void valerie_dir_close( valerie_dir ); - - valerie_nodes valerie_nodes_init( valerie ); - valerie_error_code valerie_nodes_get(valerie_nodes,int,valerie_node_entry); - int valerie_nodes_count( valerie_nodes ); - void valerie_nodes_close( valerie_nodes ); - - valerie_units valerie_units_init( valerie ); - valerie_error_code valerie_units_get(valerie_units,int,valerie_unit_entry); - int valerie_units_count( valerie_units ); - void valerie_units_close( valerie_units ); - - valerie_response valerie_get_last_response( valerie ); - - valerie_error_code valerie_execute( valerie, size_t, char *, ... ); - - void valerie_close( valerie ); - - Notifier Functions - ------------------ - - void valerie_notifier_get( valerie_notifier, valerie_status, int ); - void valerie_notifier_put( valerie_notifier, valerie_status ); - int valerie_notifier_wait( valerie_notifier, valerie_status ); - void valerie_notifier_close( valerie_notifier ); - - Server Side Queuing - ------------------- - - valerie_list valerie_list_init( valerie, int ) - valerie_error_code valerie_list_get_error_code( valerie_list ) - valerie_error_code valerie_list_get( valerie_list, int, valerie_list_entry ) - int valerie_list_count( valerie_list ) - void valerie_list_close( valerie_list ) - - valerie_error_code valerie_unit_clean( valerie dv, int unit ) - valerie_error_code valerie_unit_append( valerie dv, int unit, char *file, int in, int out ) - valerie_error_code valerie_unit_remove_current_clip( valerie dv, int unit ) - - valerie_error_code valerie_unit_clip_goto( valerie dv, int unit, valerie_clip_offset offset, int clip, int position ) - valerie_error_code valerie_unit_clip_set_in( valerie dv, int unit, valerie_clip_offset offset, int clip, int in ) - valerie_error_code valerie_unit_clip_set_out( valerie dv, int unit, valerie_clip_offset offset, int clip, int in ) - valerie_error_code valerie_unit_clip_move( valerie dv, int unit, valerie_clip_offset offset, int src, valerie_clip_offset offset, int dest ) - valerie_error_code valerie_unit_clip_remove( valerie dv, int unit, valerie_clip_offset offset, int clip ) - valerie_error_code valerie_unit_clip_insert( valerie dv, int unit, valerie_clip_offset offset, int clip, char *file, int in, int out ) - - - -APPENDIX C - COMPLETE LOW LEVEL PARSER API LISTING --------------------------------------------------- - - valerie_response valerie_parser_connect( valerie_parser ); - valerie_response valerie_parser_execute( valerie_parser, char * ); - valerie_response valerie_parser_executef( valerie_parser, char *, ... ); - valerie_response valerie_parser_run( valerie_parser, char * ); - valerie_notifier valerie_parser_get_notifier( valerie_parser ); - void valerie_parser_close( valerie_parser ); - - valerie_response valerie_response_init( ); - valerie_response valerie_response_clone( valerie_response ); - int valerie_response_get_error_code( valerie_response ); - char *valerie_response_get_error_string( valerie_response ); - char *valerie_response_get_line( valerie_response, int ); - int valerie_response_count( valerie_response ); - void valerie_response_set_error( valerie_response, int, char * ); - int valerie_response_printf( valerie_response, size_t, char *, ... ); - int valerie_response_write( valerie_response, char *, int ); - void valerie_response_close( valerie_response ); - - -APPENDIX D - REFERENCES ------------------------ - - (1) doc/dvcp.txt - DVCP protocol - (2) doc/testing.txt - Test procedures diff --git a/mlt/setenv b/mlt/setenv deleted file mode 100644 index 809cb1c..0000000 --- a/mlt/setenv +++ /dev/null @@ -1,21 +0,0 @@ - -# Environment variable settings to allow execution without install - -export MLT_REPOSITORY=`pwd`/src/modules - -export LD_LIBRARY_PATH=\ -`pwd`/src/framework:\ -`pwd`/src/valerie:\ -`pwd`/src/miracle:\ -`pwd`/src/modules/bluefish:\ -`pwd`/../bluefish/lib:\ -`pwd`/../mpeg_sdk_demo/bin:\ -`pwd`/../dv_sdk - -export PATH=\ -`pwd`/src/albino:\ -`pwd`/src/inigo:\ -`pwd`/src/humperdink:\ -`pwd`/src/miracle:\ -$PATH - diff --git a/mlt/src/albino/Makefile b/mlt/src/albino/Makefile deleted file mode 100644 index 051c5fe..0000000 --- a/mlt/src/albino/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -TARGET = albino - -OBJS = albino.o - -CFLAGS = -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic - -LDFLAGS = -L ../valerie -L ../miracle -L ../framework -lmiracle -lmlt -lvalerie - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/albino/albino.c b/mlt/src/albino/albino.c deleted file mode 100644 index 28dc6f5..0000000 --- a/mlt/src/albino/albino.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * albino.c -- Local dv1394d Test Util - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include -#include - -/* Application header files */ -#include -#include -#include - -char *prompt( char *command, int length ) -{ - printf( "> " ); - return fgets( command, length, stdin ); -} - -void report( valerie_response response ) -{ - int index = 0; - if ( response != NULL ) - for ( index = 0; index < valerie_response_count( response ); index ++ ) - printf( "%4d: %s\n", index, valerie_response_get_line( response, index ) ); -} - -int main( int argc, char **argv ) -{ - valerie_parser parser = NULL; - valerie_response response = NULL; - char temp[ 1024 ]; - int index = 1; - - if ( argc > 2 && !strcmp( argv[ 1 ], "-s" ) ) - { - printf( "DV1394D Client Instance\n" ); - parser = valerie_parser_init_remote( argv[ 2 ], 5250 ); - response = valerie_parser_connect( parser ); - index = 3; - } - else - { - printf( "DV1394D Standalone Instance\n" ); - parser = miracle_parser_init_local( ); - response = valerie_parser_connect( parser ); - } - - if ( response != NULL ) - { - /* process files on command lines before going into console mode */ - for ( ; index < argc; index ++ ) - { - valerie_response_close( response ); - response = valerie_parser_run( parser, argv[ index ] ); - report( response ); - } - - while ( response != NULL && prompt( temp, 1024 ) ) - { - valerie_util_trim( valerie_util_chomp( temp ) ); - if ( !strcasecmp( temp, "BYE" ) ) - { - break; - } - else if ( strcmp( temp, "" ) ) - { - valerie_response_close( response ); - response = valerie_parser_execute( parser, temp ); - report( response ); - } - } - } - else - { - fprintf( stderr, "Unable to connect to a dv1394 instance.\n" ); - } - - printf( "\n" ); - valerie_parser_close( parser ); - - return 0; -} diff --git a/mlt/src/framework/Makefile b/mlt/src/framework/Makefile deleted file mode 100644 index 6d80401..0000000 --- a/mlt/src/framework/Makefile +++ /dev/null @@ -1,41 +0,0 @@ - -TARGET = libmlt.so - -OBJS = mlt_frame.o \ - mlt_property.o \ - mlt_properties.o \ - mlt_service.o \ - mlt_producer.o \ - mlt_multitrack.o \ - mlt_playlist.o \ - mlt_consumer.o \ - mlt_filter.o \ - mlt_transition.o \ - mlt_field.o \ - mlt_tractor.o \ - mlt_factory.o \ - mlt_repository.o - -SRCS := $(OBJS:.o=.c) - -CFLAGS = -g -Wall -D_FILE_OFFSET_BITS=64 -pthread - -LDFLAGS = -lm -ldl -lpthread - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/framework/config.h b/mlt/src/framework/config.h deleted file mode 100644 index fec9861..0000000 --- a/mlt/src/framework/config.h +++ /dev/null @@ -1,10 +0,0 @@ -/** GENERATED FILE - DON'T EDIT */ - -#ifndef _MLT_CONFIG_H_ -#define _MLT_CONFIG_H_ - -#define PREFIX "/usr/local" -#define PREFIX_DATA PREFIX "/share" - -#endif - diff --git a/mlt/src/framework/configure b/mlt/src/framework/configure deleted file mode 100755 index a9bf588..0000000 --- a/mlt/src/framework/configure +++ /dev/null @@ -1 +0,0 @@ -#!/bin/bash diff --git a/mlt/src/framework/mlt.h b/mlt/src/framework/mlt.h deleted file mode 100644 index 3ad47a0..0000000 --- a/mlt/src/framework/mlt.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * mlt.h -- header file for lazy client and implementation code :-) - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_H_ -#define _MLT_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "mlt_factory.h" -#include "mlt_frame.h" -#include "mlt_multitrack.h" -#include "mlt_producer.h" -#include "mlt_transition.h" -#include "mlt_consumer.h" -#include "mlt_filter.h" -#include "mlt_manager.h" -#include "mlt_playlist.h" -#include "mlt_properties.h" -#include "mlt_field.h" -#include "mlt_tractor.h" - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/mlt/src/framework/mlt_consumer.c b/mlt/src/framework/mlt_consumer.c deleted file mode 100644 index 6c751aa..0000000 --- a/mlt/src/framework/mlt_consumer.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * mlt_consumer.c -- abstraction for all consumer services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt_consumer.h" -#include -#include -#include - -/** Public final methods -*/ - -int mlt_consumer_init( mlt_consumer this, void *child ) -{ - memset( this, 0, sizeof( struct mlt_consumer_s ) ); - this->child = child; - return mlt_service_init( &this->parent, this ); -} - -/** Get the parent service object. -*/ - -mlt_service mlt_consumer_service( mlt_consumer this ) -{ - return &this->parent; -} - -/** Get the consumer properties. -*/ - -mlt_properties mlt_consumer_properties( mlt_consumer this ) -{ - return mlt_service_properties( &this->parent ); -} - -/** Connect the consumer to the producer. -*/ - -int mlt_consumer_connect( mlt_consumer this, mlt_service producer ) -{ - return mlt_service_connect_producer( &this->parent, producer, 0 ); -} - -/** Start the consumer. -*/ - -int mlt_consumer_start( mlt_consumer this ) -{ - if ( this->start != NULL ) - return this->start( this ); - return 0; -} - -/** Stop the consumer. -*/ - -int mlt_consumer_stop( mlt_consumer this ) -{ - if ( this->stop != NULL ) - return this->stop( this ); - return 0; -} - -/** Determine if the consumer is stopped. -*/ - -int mlt_consumer_is_stopped( mlt_consumer this ) -{ - if ( this->is_stopped != NULL ) - return this->is_stopped( this ); - return 0; -} - -/** Close the consumer. -*/ - -void mlt_consumer_close( mlt_consumer this ) -{ - // Get the childs close function - void ( *consumer_close )( ) = this->close; - - // Make sure it only gets called once - this->close = NULL; - - // Call the childs close if available - if ( consumer_close != NULL ) - consumer_close( this ); - else - mlt_service_close( &this->parent ); -} - diff --git a/mlt/src/framework/mlt_consumer.h b/mlt/src/framework/mlt_consumer.h deleted file mode 100644 index 6c4164b..0000000 --- a/mlt/src/framework/mlt_consumer.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * mlt_consumer.h -- abstraction for all consumer services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_CONSUMER_H_ -#define _MLT_CONSUMER_H_ - -#include "mlt_service.h" - -/** The interface definition for all consumers. -*/ - -struct mlt_consumer_s -{ - // We're implementing service here - struct mlt_service_s parent; - - // public virtual - int ( *start )( mlt_consumer ); - int ( *stop )( mlt_consumer ); - int ( *is_stopped )( mlt_consumer ); - void ( *close )( mlt_consumer ); - - // Private data - void *private; - void *child; -}; - -/** Public final methods -*/ - -extern int mlt_consumer_init( mlt_consumer this, void *child ); -extern mlt_service mlt_consumer_service( mlt_consumer this ); -extern mlt_properties mlt_consumer_properties( mlt_consumer this ); -extern int mlt_consumer_connect( mlt_consumer this, mlt_service producer ); -extern int mlt_consumer_start( mlt_consumer this ); -extern int mlt_consumer_stop( mlt_consumer this ); -extern int mlt_consumer_is_stopped( mlt_consumer this ); -extern void mlt_consumer_close( mlt_consumer ); - -#endif diff --git a/mlt/src/framework/mlt_factory.c b/mlt/src/framework/mlt_factory.c deleted file mode 100644 index 9223178..0000000 --- a/mlt/src/framework/mlt_factory.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * mlt_factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt.h" -#include "mlt_repository.h" - -#include -#include - -/** Singleton repositories -*/ - -static char *mlt_prefix = NULL; -static mlt_properties object_list = NULL; -static mlt_repository producers = NULL; -static mlt_repository filters = NULL; -static mlt_repository transitions = NULL; -static mlt_repository consumers = NULL; - -/** Construct the factories. -*/ - -int mlt_factory_init( char *prefix ) -{ - // Only initialise once - if ( mlt_prefix == NULL ) - { - // If no directory is specified, default to install directory - if ( prefix == NULL ) - prefix = PREFIX_DATA; - - // Store the prefix for later retrieval - mlt_prefix = strdup( prefix ); - - // Create the object list. - object_list = calloc( sizeof( struct mlt_properties_s ), 1 ); - mlt_properties_init( object_list, NULL ); - - // Create a repository for each service type - producers = mlt_repository_init( object_list, prefix, "producers.dat", "mlt_create_producer" ); - filters = mlt_repository_init( object_list, prefix, "filters.dat", "mlt_create_filter" ); - transitions = mlt_repository_init( object_list, prefix, "transitions.dat", "mlt_create_transition" ); - consumers = mlt_repository_init( object_list, prefix, "consumers.dat", "mlt_create_consumer" ); - } - - return 0; -} - -/** Fetch the prefix used in this instance. -*/ - -const char *mlt_factory_prefix( ) -{ - return mlt_prefix; -} - -/** Fetch a producer from the repository. -*/ - -mlt_producer mlt_factory_producer( char *service, void *input ) -{ - mlt_producer obj = mlt_repository_fetch( producers, service, input ); - if ( obj != NULL ) - { - mlt_properties properties = mlt_producer_properties( obj ); - mlt_properties_set( properties, "mlt_type", "producer" ); - mlt_properties_set( properties, "mlt_service", service ); - } - return obj; -} - -/** Fetch a filter from the repository. -*/ - -mlt_filter mlt_factory_filter( char *service, void *input ) -{ - mlt_filter obj = mlt_repository_fetch( filters, service, input ); - if ( obj != NULL ) - { - mlt_properties properties = mlt_filter_properties( obj ); - mlt_properties_set( properties, "mlt_type", "filter" ); - mlt_properties_set( properties, "mlt_service", service ); - } - return obj; -} - -/** Fetch a transition from the repository. -*/ - -mlt_transition mlt_factory_transition( char *service, void *input ) -{ - mlt_transition obj = mlt_repository_fetch( transitions, service, input ); - if ( obj != NULL ) - { - mlt_properties properties = mlt_transition_properties( obj ); - mlt_properties_set( properties, "mlt_type", "transition" ); - mlt_properties_set( properties, "mlt_service", service ); - } - return obj; -} - -/** Fetch a consumer from the repository -*/ - -mlt_consumer mlt_factory_consumer( char *service, void *input ) -{ - mlt_consumer obj = mlt_repository_fetch( consumers, service, input ); - if ( obj != NULL ) - { - mlt_properties properties = mlt_consumer_properties( obj ); - mlt_properties_set( properties, "mlt_type", "consumer" ); - mlt_properties_set( properties, "mlt_service", service ); - } - return obj; -} - -/** Close the factory. -*/ - -void mlt_factory_close( ) -{ - if ( mlt_prefix != NULL ) - { - mlt_repository_close( producers ); - mlt_repository_close( filters ); - mlt_repository_close( transitions ); - mlt_repository_close( consumers ); - mlt_properties_close( object_list ); - free( mlt_prefix ); - free( object_list ); - mlt_prefix = NULL; - } -} - diff --git a/mlt/src/framework/mlt_factory.h b/mlt/src/framework/mlt_factory.h deleted file mode 100644 index d0b9160..0000000 --- a/mlt/src/framework/mlt_factory.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * mlt_factory.h -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_FACTORY_H -#define _MLT_FACTORY_H - -#include "mlt_types.h" - -extern int mlt_factory_init( char *prefix ); -extern const char *mlt_factory_prefix( ); -extern mlt_producer mlt_factory_producer( char *name, void *input ); -extern mlt_filter mlt_factory_filter( char *name, void *input ); -extern mlt_transition mlt_factory_transition( char *name, void *input ); -extern mlt_consumer mlt_factory_consumer( char *name, void *input ); -extern void mlt_factory_close( ); - -#endif diff --git a/mlt/src/framework/mlt_field.c b/mlt/src/framework/mlt_field.c deleted file mode 100644 index 8a7f51f..0000000 --- a/mlt/src/framework/mlt_field.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * mlt_field.c -- A field for planting multiple transitions and filters - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "mlt_field.h" -#include "mlt_service.h" -#include "mlt_filter.h" -#include "mlt_transition.h" -#include "mlt_multitrack.h" -#include "mlt_tractor.h" - -#include -#include - -/** Private structures. -*/ - -struct mlt_field_s -{ - // This is the producer we're connected to - mlt_service producer; - - // Multitrack - mlt_multitrack multitrack; - - // Tractor - mlt_tractor tractor; -}; - -/** Constructor. - - We construct a multitrack and a tractor here. -*/ - -mlt_field mlt_field_init( ) -{ - // Initialise the field - mlt_field this = calloc( sizeof( struct mlt_field_s ), 1 ); - - // Initialise it - if ( this != NULL ) - { - // Construct a multitrack - this->multitrack = mlt_multitrack_init( ); - - // Construct a tractor - this->tractor = mlt_tractor_init( ); - - // The first plant will be connected to the mulitrack - this->producer = mlt_multitrack_service( this->multitrack ); - - // Connect the tractor to the multitrack - mlt_tractor_connect( this->tractor, this->producer ); - } - - // Return this - return this; -} - -/** Get the service associated to this field. -*/ - -mlt_service mlt_field_service( mlt_field this ) -{ - return mlt_tractor_service( this->tractor ); -} - -/** Get the multi track. -*/ - -mlt_multitrack mlt_field_multitrack( mlt_field this ) -{ - return this->multitrack; -} - -/** Get the tractor. -*/ - -mlt_tractor mlt_field_tractor( mlt_field this ) -{ - return this->tractor; -} - -/** Get the properties associated to this field. -*/ - -mlt_properties mlt_field_properties( mlt_field this ) -{ - return mlt_service_properties( mlt_field_service( this ) ); -} - -/** Plant a filter. -*/ - -int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ) -{ - // Connect the filter to the last producer - int result = mlt_filter_connect( that, this->producer, track ); - - // If sucessful, then we'll use this for connecting in the future - if ( result == 0 ) - { - // This is now the new producer - this->producer = mlt_filter_service( that ); - - // Reconnect tractor to new producer - mlt_tractor_connect( this->tractor, this->producer ); - } - - return result; -} - -/** Plant a transition. -*/ - -int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track, int b_track ) -{ - // Connect the transition to the last producer - int result = mlt_transition_connect( that, this->producer, a_track, b_track ); - - // If sucessful, then we'll use this for connecting in the future - if ( result == 0 ) - { - // This is now the new producer - this->producer = mlt_transition_service( that ); - - // Reconnect tractor to new producer - mlt_tractor_connect( this->tractor, this->producer ); - } - - return 0; -} - -/** Close the field. -*/ - -void mlt_field_close( mlt_field this ) -{ - mlt_tractor_close( this->tractor ); - mlt_multitrack_close( this->multitrack ); - free( this ); -} - diff --git a/mlt/src/framework/mlt_field.h b/mlt/src/framework/mlt_field.h deleted file mode 100644 index d84d0cc..0000000 --- a/mlt/src/framework/mlt_field.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * mlt_field.h -- A field for planting multiple transitions and services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_FIELD_H_ -#define _MLT_FIELD_H_ - -#include "mlt_types.h" - -extern mlt_field mlt_field_init( ); -extern mlt_service mlt_field_service( mlt_field this ); -extern mlt_tractor mlt_field_tractor( mlt_field this ); -extern mlt_multitrack mlt_field_multitrack( mlt_field this ); -extern mlt_properties mlt_field_properties( mlt_field this ); -extern int mlt_field_plant_filter( mlt_field this, mlt_filter that, int track ); -extern int mlt_field_plant_transition( mlt_field this, mlt_transition that, int a_track, int b_track ); -extern void mlt_field_close( mlt_field this ); - -#endif - diff --git a/mlt/src/framework/mlt_filter.c b/mlt/src/framework/mlt_filter.c deleted file mode 100644 index 6e39e79..0000000 --- a/mlt/src/framework/mlt_filter.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * mlt_filter.c -- abstraction for all filter services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_filter.h" -#include "mlt_frame.h" - -#include -#include -#include - -static int filter_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); - -/** Constructor method. -*/ - -int mlt_filter_init( mlt_filter this, void *child ) -{ - mlt_service service = &this->parent; - memset( this, 0, sizeof( struct mlt_filter_s ) ); - this->child = child; - if ( mlt_service_init( service, this ) == 0 ) - { - mlt_properties properties = mlt_service_properties( service ); - - // Override the get_frame method - service->get_frame = filter_get_frame; - - // Default in, out, track properties - mlt_properties_set_position( properties, "in", 0 ); - mlt_properties_set_position( properties, "out", 0 ); - mlt_properties_set_int( properties, "track", 0 ); - - return 0; - } - return 1; -} - -/** Get the service associated to this filter -*/ - -mlt_service mlt_filter_service( mlt_filter this ) -{ - return &this->parent; -} - -mlt_properties mlt_filter_properties( mlt_filter this ) -{ - return mlt_service_properties( mlt_filter_service( this ) ); -} - -/** Connect this filter to a producers track. Note that a filter only operates - on a single track, and by default it operates on the entirety of that track. -*/ - -int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ) -{ - int ret = mlt_service_connect_producer( &this->parent, producer, index ); - - // If the connection was successful, grab the producer, track and reset in/out - if ( ret == 0 ) - { - mlt_properties properties = mlt_service_properties( &this->parent ); - this->producer = producer; - mlt_properties_set_position( properties, "in", 0 ); - mlt_properties_set_position( properties, "out", 0 ); - mlt_properties_set_int( properties, "track", index ); - } - - return ret; -} - -/** Tune the in/out points. -*/ - -void mlt_filter_set_in_and_out( mlt_filter this, mlt_position in, mlt_position out ) -{ - mlt_properties properties = mlt_service_properties( &this->parent ); - mlt_properties_set_position( properties, "in", in ); - mlt_properties_set_position( properties, "out", out ); -} - -/** Return the track that this filter is operating on. -*/ - -int mlt_filter_get_track( mlt_filter this ) -{ - mlt_properties properties = mlt_service_properties( &this->parent ); - return mlt_properties_get_int( properties, "track" ); -} - -/** Get the in point. -*/ - -mlt_position mlt_filter_get_in( mlt_filter this ) -{ - mlt_properties properties = mlt_service_properties( &this->parent ); - return mlt_properties_get_position( properties, "in" ); -} - -/** Get the out point. -*/ - -mlt_position mlt_filter_get_out( mlt_filter this ) -{ - mlt_properties properties = mlt_service_properties( &this->parent ); - return mlt_properties_get_position( properties, "out" ); -} - -/** Process the frame. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - if ( this->process == NULL ) - return frame; - else - return this->process( this, frame ); -} - -/** Get a frame from this filter. -*/ - -static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) -{ - mlt_filter this = service->child; - - // Get coords in/out/track - int track = mlt_filter_get_track( this ); - int in = mlt_filter_get_in( this ); - int out = mlt_filter_get_out( this ); - - // If the frame request is for this filters track, we need to process it - if ( index == track ) - { - int ret = mlt_service_get_frame( this->producer, frame, index ); - if ( ret == 0 ) - { - if ( !mlt_frame_is_test_card( *frame ) ) - { - mlt_position position = mlt_frame_get_position( *frame ); - if ( position >= in && ( out == 0 || position < out ) ) - *frame = filter_process( this, *frame ); - } - return 0; - } - else - { - *frame = mlt_frame_init( ); - return 0; - } - } - else - { - return mlt_service_get_frame( this->producer, frame, index ); - } -} - -/** Close the filter. -*/ - -void mlt_filter_close( mlt_filter this ) -{ - if ( this->close != NULL ) - this->close( this ); - else - mlt_service_close( &this->parent ); -} - diff --git a/mlt/src/framework/mlt_filter.h b/mlt/src/framework/mlt_filter.h deleted file mode 100644 index edaf6f6..0000000 --- a/mlt/src/framework/mlt_filter.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * mlt_filter.h -- abstraction for all filter services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_FILTER_H_ -#define _MLT_FILTER_H_ - -#include "mlt_service.h" - -/** The interface definition for all filters. -*/ - -struct mlt_filter_s -{ - // We're implementing service here - struct mlt_service_s parent; - - // public virtual - void ( *close )( mlt_filter ); - - // protected filter method - mlt_frame ( *process )( mlt_filter, mlt_frame ); - - // track and in/out points - mlt_service producer; - - // Protected - void *child; -}; - -/** Public final methods -*/ - -extern int mlt_filter_init( mlt_filter this, void *child ); -extern mlt_service mlt_filter_service( mlt_filter this ); -extern mlt_properties mlt_filter_properties( mlt_filter this ); -extern int mlt_filter_connect( mlt_filter this, mlt_service producer, int index ); -extern void mlt_filter_set_in_and_out( mlt_filter this, mlt_position in, mlt_position out ); -extern int mlt_filter_get_track( mlt_filter this ); -extern mlt_position mlt_filter_get_in( mlt_filter this ); -extern mlt_position mlt_filter_get_out( mlt_filter this ); -extern void mlt_filter_close( mlt_filter ); - -#endif diff --git a/mlt/src/framework/mlt_frame.c b/mlt/src/framework/mlt_frame.c deleted file mode 100644 index 3f583d9..0000000 --- a/mlt/src/framework/mlt_frame.c +++ /dev/null @@ -1,869 +0,0 @@ -/* - * mlt_frame.c -- interface for all frame classes - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt_frame.h" -#include -#include -#include - -typedef struct -{ - mlt_image_format vfmt; - int width; - int height; - uint8_t *image; - uint8_t *alpha; - mlt_audio_format afmt; - int16_t *audio; -} -frame_test; - -static frame_test test_card = { mlt_image_none, 0, 0, NULL, NULL, mlt_audio_none, NULL }; - -/** Constructor for a frame. -*/ - -mlt_frame mlt_frame_init( ) -{ - // Allocate a frame - mlt_frame this = calloc( sizeof( struct mlt_frame_s ), 1 ); - - if ( this != NULL ) - { - // Initialise the properties - mlt_properties properties = &this->parent; - mlt_properties_init( properties, this ); - - // Set default properties on the frame - mlt_properties_set_position( properties, "position", 0.0 ); - mlt_properties_set_data( properties, "image", NULL, 0, NULL, NULL ); - mlt_properties_set_int( properties, "width", 720 ); - mlt_properties_set_int( properties, "height", 576 ); - mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 ); - mlt_properties_set_data( properties, "audio", NULL, 0, NULL, NULL ); - mlt_properties_set_data( properties, "alpha", NULL, 0, NULL, NULL ); - } - return this; -} - -/** Fetch the frames properties. -*/ - -mlt_properties mlt_frame_properties( mlt_frame this ) -{ - return &this->parent; -} - -/** Check if we have a way to derive something other than a test card. -*/ - -int mlt_frame_is_test_card( mlt_frame this ) -{ - return ( this->stack_get_image_size == 0 && mlt_properties_get_data( mlt_frame_properties( this ), "image", NULL ) == NULL ); -} - -/** Check if we have a way to derive something than test audio. -*/ - -int mlt_frame_is_test_audio( mlt_frame this ) -{ - return this->get_audio == NULL; -} - -/** Get the aspect ratio of the frame. -*/ - -double mlt_frame_get_aspect_ratio( mlt_frame this ) -{ - return mlt_properties_get_double( mlt_frame_properties( this ), "aspect_ratio" ); -} - -/** Set the aspect ratio of the frame. -*/ - -int mlt_frame_set_aspect_ratio( mlt_frame this, double value ) -{ - return mlt_properties_set_double( mlt_frame_properties( this ), "aspect_ratio", value ); -} - -/** Get the position of this frame. -*/ - -mlt_position mlt_frame_get_position( mlt_frame this ) -{ - return mlt_properties_get_position( mlt_frame_properties( this ), "position" ); -} - -/** Set the position of this frame. -*/ - -int mlt_frame_set_position( mlt_frame this, mlt_position value ) -{ - return mlt_properties_set_position( mlt_frame_properties( this ), "position", value ); -} - -/** Stack a get_image callback. -*/ - -int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image ) -{ - int ret = this->stack_get_image_size >= 10; - if ( ret == 0 ) - this->stack_get_image[ this->stack_get_image_size ++ ] = get_image; - return ret; -} - -/** Pop a get_image callback. -*/ - -mlt_get_image mlt_frame_pop_get_image( mlt_frame this ) -{ - mlt_get_image result = NULL; - if ( this->stack_get_image_size > 0 ) - result = this->stack_get_image[ -- this->stack_get_image_size ]; - return result; -} - -/** Push a frame. -*/ - -int mlt_frame_push_frame( mlt_frame this, mlt_frame that ) -{ - int ret = this->stack_frame_size >= 10; - if ( ret == 0 ) - this->stack_frame[ this->stack_frame_size ++ ] = that; - return ret; -} - -/** Pop a frame. -*/ - -mlt_frame mlt_frame_pop_frame( mlt_frame this ) -{ - mlt_frame result = NULL; - if ( this->stack_frame_size > 0 ) - result = this->stack_frame[ -- this->stack_frame_size ]; - return result; -} - -int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - mlt_properties properties = mlt_frame_properties( this ); - mlt_get_image get_image = mlt_frame_pop_get_image( this ); - - if ( get_image != NULL ) - { - return get_image( this, buffer, format, width, height, writable ); - } - else if ( mlt_properties_get_data( properties, "image", NULL ) != NULL ) - { - *format = mlt_image_yuv422; - *buffer = mlt_properties_get_data( properties, "image", NULL ); - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - } - else - { - if ( test_card.vfmt != *format ) - { - uint8_t *p; - uint8_t *q; - - test_card.vfmt = *format; - test_card.width = *width == 0 ? 720 : *width; - test_card.height = *height == 0 ? 576 : *height; - - switch( *format ) - { - case mlt_image_none: - break; - case mlt_image_rgb24: - test_card.image = realloc( test_card.image, test_card.width * test_card.height * 3 ); - memset( test_card.image, 255, test_card.width * test_card.height * 3 ); - break; - case mlt_image_rgb24a: - test_card.image = realloc( test_card.image, test_card.width * test_card.height * 4 ); - memset( test_card.image, 255, test_card.width * test_card.height * 4 ); - break; - case mlt_image_yuv422: - test_card.image = realloc( test_card.image, test_card.width * test_card.height * 2 ); - p = test_card.image; - q = test_card.image + test_card.width * test_card.height * 2; - while ( p != q ) - { - *p ++ = 255; - *p ++ = 128; - } - break; - case mlt_image_yuv420p: - test_card.image = realloc( test_card.image, test_card.width * test_card.height * 3 / 2 ); - memset( test_card.image, 255, test_card.width * test_card.height * 3 / 2 ); - break; - } - } - - *width = test_card.width; - *height = test_card.height; - *buffer = test_card.image; - } - - return 0; -} - -uint8_t *mlt_frame_get_alpha_mask( mlt_frame this ) -{ - if ( this->get_alpha_mask != NULL ) - return this->get_alpha_mask( this ); - return test_card.alpha; -} - -int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - if ( this->get_audio != NULL ) - { - return this->get_audio( this, buffer, format, frequency, channels, samples ); - } - else - { - if ( *samples <= 0 ) - *samples = 1920; - if ( *channels <= 0 ) - *channels = 2; - if ( *frequency <= 0 ) - *frequency = 48000; - if ( test_card.audio == NULL || test_card.afmt != *format ) - { - test_card.afmt = *format; - test_card.audio = realloc( test_card.audio, *samples * *channels * sizeof( int16_t ) ); - memset( test_card.audio, 0, *samples * *channels * sizeof( int16_t ) ); - } - - *buffer = test_card.audio; - } - return 0; -} - -void mlt_frame_close( mlt_frame this ) -{ - mlt_properties_close( &this->parent ); - free( this ); -} - -/***** convenience functions *****/ -#define RGB2YUV(r, g, b, y, u, v)\ - y = (306*r + 601*g + 117*b) >> 10;\ - u = ((-172*r - 340*g + 512*b) >> 10) + 128;\ - v = ((512*r - 429*g - 83*b) >> 10) + 128;\ - y = y < 0 ? 0 : y;\ - u = u < 0 ? 0 : u;\ - v = v < 0 ? 0 : v;\ - y = y > 255 ? 255 : y;\ - u = u > 255 ? 255 : u;\ - v = v > 255 ? 255 : v - -int mlt_convert_rgb24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha ) -{ - int ret = 0; - register int y0, y1, u0, u1, v0, v1; - register int r, g, b; - register uint8_t *d = yuv; - register int i, j; - - for ( i = 0; i < height; i++ ) - { - register uint8_t *s = rgba + ( stride * i ); - for ( j = 0; j < ( width / 2 ); j++ ) - { - r = *s++; - g = *s++; - b = *s++; - *alpha++ = *s++; - RGB2YUV (r, g, b, y0, u0 , v0); - r = *s++; - g = *s++; - b = *s++; - *alpha++ = *s++; - RGB2YUV (r, g, b, y1, u1 , v1); - *d++ = y0; - *d++ = (u0+u1) >> 1; - *d++ = y1; - *d++ = (v0+v1) >> 1; - } - if ( width % 2 ) - { - r = *s++; - g = *s++; - b = *s++; - *alpha++ = *s++; - RGB2YUV (r, g, b, y0, u0 , v0); - *d++ = y0; - *d++ = u0; - } - } - return ret; -} - -int mlt_convert_rgb24_to_yuv422( uint8_t *rgb, int width, int height, int stride, uint8_t *yuv ) -{ - int ret = 0; - register int y0, y1, u0, u1, v0, v1; - register int r, g, b; - register uint8_t *d = yuv; - register int i, j; - - for ( i = 0; i < height; i++ ) - { - register uint8_t *s = rgb + ( stride * i ); - for ( j = 0; j < ( width / 2 ); j++ ) - { - r = *s++; - g = *s++; - b = *s++; - RGB2YUV (r, g, b, y0, u0 , v0); - r = *s++; - g = *s++; - b = *s++; - RGB2YUV (r, g, b, y1, u1 , v1); - *d++ = y0; - *d++ = (u0+u1) >> 1; - *d++ = y1; - *d++ = (v0+v1) >> 1; - } - if ( width % 2 ) - { - r = *s++; - g = *s++; - b = *s++; - RGB2YUV (r, g, b, y0, u0 , v0); - *d++ = y0; - *d++ = u0; - } - } - return ret; -} - -int mlt_convert_yuv420p_to_yuv422( uint8_t *yuv420p, int width, int height, int stride, uint8_t *yuv ) -{ - int ret = 0; - register int i, j; - - int half = width >> 1; - - uint8_t *Y = yuv420p; - uint8_t *U = Y + width * height; - uint8_t *V = U + width * height / 4; - - register uint8_t *d = yuv; - - for ( i = 0; i < height; i++ ) - { - register uint8_t *u = U + ( i / 2 ) * ( half ); - register uint8_t *v = V + ( i / 2 ) * ( half ); - - for ( j = 0; j < half; j++ ) - { - *d ++ = *Y ++; - *d ++ = *u ++; - *d ++ = *Y ++; - *d ++ = *v ++; - } - } - return ret; -} - -int mlt_frame_composite_yuv( mlt_frame this, mlt_frame that, int x, int y, float weight ) -{ - int ret = 0; - int width_src = 0, height_src = 0; - int width_dest = 0, height_dest = 0; - mlt_image_format format_src = mlt_image_yuv422, format_dest = mlt_image_yuv422; - uint8_t *p_src, *p_dest; - int i, j; - int stride_src; - int stride_dest; - int x_src = 0, y_src = 0; - - // optimization point - no work to do - if ( ( x < 0 && -x >= width_src ) || ( y < 0 && -y >= height_src ) ) - return ret; - - format_src = mlt_image_yuv422; - format_dest = mlt_image_yuv422; - - //fprintf( stderr, "call get_image on frame a\n"), fflush( stderr ); - mlt_frame_get_image( this, &p_dest, &format_dest, &width_dest, &height_dest, 1 /* writable */ ); - //fprintf( stderr, "call get_image on frame b\n"), fflush( stderr ); - mlt_frame_get_image( that, &p_src, &format_src, &width_src, &height_src, 0 /* writable */ ); - - //fprintf( stderr, "mlt_frame_composite_yuv %dx%d -> %dx%d\n", width_src, height_src, width_dest, height_dest ); - //fflush(stderr); - //return ret; - stride_src = width_src * 2; - stride_dest = width_dest * 2; - - // crop overlay off the left edge of frame - if ( x < 0 ) - { - x_src = -x; - width_src -= x_src; - x = 0; - } - - // crop overlay beyond right edge of frame - else if ( x + width_src > width_dest ) - width_src = width_dest - x; - - // crop overlay off the top edge of the frame - if ( y < 0 ) - { - y_src = -y; - height_src -= y_src; - } - // crop overlay below bottom edge of frame - else if ( y + height_src > height_dest ) - height_src = height_dest - y; - - // offset pointer into overlay buffer based on cropping - p_src += x_src * 2 + y_src * stride_src; - - // offset pointer into frame buffer based upon positive, even coordinates only! -// if ( interlaced && y % 2 ) -// ++y; - p_dest += ( x < 0 ? 0 : x ) * 2 + ( y < 0 ? 0 : y ) * stride_dest; - - // Get the alpha channel of the overlay - uint8_t *p_alpha = mlt_frame_get_alpha_mask( that ); - - // offset pointer into alpha channel based upon cropping - if ( p_alpha ) - p_alpha += x_src + y_src * stride_src / 2; - - uint8_t *p = p_src; - uint8_t *q = p_dest; - uint8_t *o = p_dest; - uint8_t *z = p_alpha; - - uint8_t Y; - uint8_t UV; - uint8_t a; - float value; - - // now do the compositing only to cropped extents - for ( i = 0; i < height_src; i++ ) - { - p = p_src; - q = p_dest; - o = p_dest; - z = p_alpha; - - for ( j = 0; j < width_src; j ++ ) - { - Y = *p ++; - UV = *p ++; - a = ( z == NULL ) ? 255 : *z ++; - value = ( weight * ( float ) a / 255.0 ); - *o ++ = (uint8_t)( Y * value + *q++ * ( 1 - value ) ); - *o ++ = (uint8_t)( UV * value + *q++ * ( 1 - value ) ); - } - - p_src += stride_src; - p_dest += stride_dest; - if ( p_alpha ) - p_alpha += stride_src / 2; - } - - return ret; -} - -void *memfill( void *dst, void *src, int l, int elements ) -{ - int i = 0; - if ( l == 2 ) - { - uint8_t *p = dst; - uint8_t *src1 = src; - uint8_t *src2 = src + 1; - for ( i = 0; i < elements; i ++ ) - { - *p ++ = *src1; - *p ++ = *src2; - } - dst = p; - } - else - { - for ( i = 0; i < elements; i ++ ) - dst = memcpy( dst, src, l ) + l; - } - return dst; -} - -void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input, int iwidth, int iheight ) -{ - // Calculate strides - int istride = iwidth * 2; - int ostride = owidth * 2; - - iwidth = iwidth - ( iwidth % 4 ); - owidth = owidth - ( owidth % 4 ); - iheight = iheight - ( iheight % 2 ); - oheight = oheight - ( oheight % 2 ); - - // Coordinates (0,0 is middle of output) - int y; - - // Calculate ranges - int out_x_range = owidth / 2; - int out_y_range = oheight / 2; - int in_x_range = iwidth / 2 < out_x_range ? iwidth / 2 : out_x_range; - int in_y_range = iheight / 2 < out_y_range ? iheight / 2 : out_y_range; - - // Output pointers - uint8_t *out_line = output; - uint8_t *out_ptr = out_line; - - // Calculate a middle and possibly invalid pointer in the input - uint8_t *in_middle = input + istride * ( iheight / 2 ) + ( iwidth / 2 ) * 2; - int in_line = - in_y_range * istride - in_x_range * 2; - - uint8_t black[ 2 ] = { 16, 128 }; - - // Loop for the entirety of our output height. - for ( y = - out_y_range; y < out_y_range ; y ++ ) - { - // Start at the beginning of the line - out_ptr = out_line; - - if ( abs( y ) < iheight / 2 ) - { - // Fill the outer part with black - out_ptr = memfill( out_ptr, black, 2, out_x_range - in_x_range ); - - // We're in the input range for this row. - memcpy( out_ptr, in_middle + in_line, 2 * iwidth ); - out_ptr += 2 * iwidth; - - // Fill the outer part with black - out_ptr = memfill( out_ptr, black, 2, out_x_range - in_x_range ); - - // Move to next input line - in_line += istride; - } - else - { - // Fill whole line with black - out_ptr = memfill( out_ptr, black, 2, owidth ); - } - - // Move to next output line - out_line += ostride; - } -} - -/** A resizing function for yuv422 frames - this does not rescale, but simply - resizes. It assumes yuv422 images available on the frame so use with care. -*/ - -uint8_t *mlt_frame_resize_yuv422( mlt_frame this, int owidth, int oheight ) -{ - // Get properties - mlt_properties properties = mlt_frame_properties( this ); - - // Get the input image, width and height - uint8_t *input = mlt_properties_get_data( properties, "image", NULL ); - int iwidth = mlt_properties_get_int( properties, "width" ); - int iheight = mlt_properties_get_int( properties, "height" ); - - // If width and height are correct, don't do anything - if ( iwidth != owidth || iheight != oheight ) - { - // Create the output image - uint8_t *output = malloc( owidth * oheight * 2 ); - - // Call the generic resize - mlt_resize_yuv422( output, owidth, oheight, input, iwidth, iheight ); - - // Now update the frame - mlt_properties_set_data( properties, "image", output, owidth * oheight * 2, free, NULL ); - mlt_properties_set_int( properties, "width", owidth ); - mlt_properties_set_int( properties, "height", oheight ); - - // Return the output - return output; - } - - // No change, return input - return input; -} - -/** A rescaling function for yuv422 frames - low quality, and provided for testing - only. It assumes yuv422 images available on the frame so use with care. -*/ - -uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight ) -{ - // Get properties - mlt_properties properties = mlt_frame_properties( this ); - - // Get the input image, width and height - uint8_t *input = mlt_properties_get_data( properties, "image", NULL ); - int iwidth = mlt_properties_get_int( properties, "width" ); - int iheight = mlt_properties_get_int( properties, "height" ); - - // If width and height are correct, don't do anything - if ( iwidth != owidth || iheight != oheight ) - { - // Create the output image - uint8_t *output = malloc( owidth * oheight * 2 ); - - // Calculate strides - int istride = iwidth * 2; - int ostride = owidth * 2; - - iwidth = iwidth - ( iwidth % 4 ); - - // Coordinates (0,0 is middle of output) - int y, x; - - // Derived coordinates - int dy, dx; - - // Calculate ranges - int out_x_range = owidth / 2; - int out_y_range = oheight / 2; - int in_x_range = iwidth / 2; - int in_y_range = iheight / 2; - - // Output pointers - uint8_t *out_line = output; - uint8_t *out_ptr; - - // Calculate a middle pointer - uint8_t *in_middle = input + istride * in_y_range + in_x_range * 2; - uint8_t *in_line; - uint8_t *in_ptr; - - // Generate the affine transform scaling values - float scale_width = ( float )iwidth / ( float )owidth; - float scale_height = ( float )iheight / ( float )oheight; - - // Loop for the entirety of our output height. - for ( y = - out_y_range; y < out_y_range ; y ++ ) - { - // Calculate the derived y value - dy = scale_height * y; - - // Start at the beginning of the line - out_ptr = out_line; - - // Pointer to the middle of the input line - in_line = in_middle + dy * istride; - - // Loop for the entirety of our output row. - for ( x = - out_x_range; x < out_x_range; x += 1 ) - { - // Calculated the derived x - dx = scale_width * x; - - // Check if x and y are in the valid input range. - if ( abs( dx ) < in_x_range && abs( dy ) < in_y_range ) - { - // We're in the input range for this row. - in_ptr = in_line + ( dx >> 1 ) * 4 + 2 * ( x & 1 ); - *out_ptr ++ = *in_ptr ++; - *out_ptr ++ = *in_ptr ++; - } - else - { - // We're not in the input range for this row. - *out_ptr ++ = 16; - *out_ptr ++ = 128; - } - } - - // Move to next output line - out_line += ostride; - } - - // Now update the frame - mlt_properties_set_data( properties, "image", output, owidth * oheight * 2, free, NULL ); - mlt_properties_set_int( properties, "width", owidth ); - mlt_properties_set_int( properties, "height", oheight ); - - // Return the output - return output; - } - - // No change, return input - return input; -} - -int mlt_frame_mix_audio( mlt_frame this, mlt_frame that, float weight, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - int ret = 0; - int16_t *p_src, *p_dest; - int16_t *src, *dest; - //static int16_t *extra_src = NULL, *extra_dest = NULL; - static int extra_src_samples = 0, extra_dest_samples = 0; - int frequency_src = 0, frequency_dest = 0; - int channels_src = 0, channels_dest = 0; - int samples_src = 0, samples_dest = 0; - int i, j; - - mlt_frame_get_audio( this, &p_dest, format, &frequency_dest, &channels_dest, &samples_dest ); - //fprintf( stderr, "frame dest samples %d channels %d position %f\n", samples_dest, channels_dest, mlt_properties_get_position( mlt_frame_properties( this ), "position" ) ); - mlt_frame_get_audio( that, &p_src, format, &frequency_src, &channels_src, &samples_src ); - //fprintf( stderr, "frame src samples %d channels %d\n", samples_src, channels_src ); - if ( channels_src > 6 ) - channels_src = 0; - if ( channels_dest > 6 ) - channels_dest = 0; - if ( samples_src > 4000 ) - samples_src = 0; - if ( samples_dest > 4000 ) - samples_dest = 0; - -#if 0 - // Append new samples to leftovers - if ( extra_dest_samples > 0 ) - { - fprintf( stderr, "prepending %d samples to dest\n", extra_dest_samples ); - dest = realloc( extra_dest, ( samples_dest + extra_dest_samples ) * 2 * channels_dest ); - memcpy( &extra_dest[ extra_dest_samples * channels_dest ], p_dest, samples_dest * 2 * channels_dest ); - } - else - dest = p_dest; - if ( extra_src_samples > 0 ) - { - fprintf( stderr, "prepending %d samples to src\n", extra_src_samples ); - src = realloc( extra_src, ( samples_src + extra_src_samples ) * 2 * channels_src ); - memcpy( &extra_src[ extra_src_samples * channels_src ], p_src, samples_src * 2 * channels_src ); - } - else - src = p_src; -#else - src = p_src; - dest = p_dest; -#endif - - // determine number of samples to process - if ( samples_src + extra_src_samples < samples_dest + extra_dest_samples ) - *samples = samples_src + extra_src_samples; - else if ( samples_dest + extra_dest_samples < samples_src + extra_src_samples ) - *samples = samples_dest + extra_dest_samples; - - *channels = channels_src < channels_dest ? channels_src : channels_dest; - *buffer = p_dest; - - // Mixdown - for ( i = 0; i < *samples; i++ ) - { - for ( j = 0; j < *channels; j++ ) - { - double d = (double) dest[ i * channels_dest + j ]; - double s = (double) src[ i * channels_src + j ]; - dest[ i * channels_dest + j ] = s * weight + d * ( 1.0 - weight ); - } - } - - // We have to copy --sigh - if ( dest != p_dest ) - memcpy( p_dest, dest, *samples * 2 * *channels ); - -#if 0 - // Store the leftovers - if ( samples_src + extra_src_samples < samples_dest + extra_dest_samples ) - { - extra_dest_samples = ( samples_dest + extra_dest_samples ) - ( samples_src + extra_src_samples ); - size_t size = extra_dest_samples * 2 * channels_dest; - fprintf( stderr, "storing %d samples from dest\n", extra_dest_samples ); - if ( extra_dest ) - free( extra_dest ); - extra_dest = malloc( size ); - if ( extra_dest ) - memcpy( extra_dest, &p_dest[ ( samples_dest - extra_dest_samples - 1 ) * channels_dest ], size ); - else - extra_dest_samples = 0; - } - else if ( samples_dest + extra_dest_samples < samples_src + extra_src_samples ) - { - extra_src_samples = ( samples_src + extra_src_samples ) - ( samples_dest + extra_dest_samples ); - size_t size = extra_src_samples * 2 * channels_src; - fprintf( stderr, "storing %d samples from src\n", extra_dest_samples ); - if ( extra_src ) - free( extra_src ); - extra_src = malloc( size ); - if ( extra_src ) - memcpy( extra_src, &p_src[ ( samples_src - extra_src_samples - 1 ) * channels_src ], size ); - else - extra_src_samples = 0; - } -#endif - - return ret; -} - -int mlt_sample_calculator( float fps, int frequency, int64_t position ) -{ - int samples = 0; - - if ( fps > 29 && fps <= 30 ) - { - samples = frequency / 30; - - switch ( frequency ) - { - case 48000: - if ( position % 5 != 0 ) - samples += 2; - break; - case 44100: - if ( position % 300 == 0 ) - samples = 1471; - else if ( position % 30 == 0 ) - samples = 1470; - else if ( position % 2 == 0 ) - samples = 1472; - else - samples = 1471; - break; - case 32000: - if ( position % 30 == 0 ) - samples = 1068; - else if ( position % 29 == 0 ) - samples = 1067; - else if ( position % 4 == 2 ) - samples = 1067; - else - samples = 1068; - break; - default: - samples = 0; - } - } - else if ( fps != 0 ) - { - samples = frequency / fps; - } - - return samples; -} - diff --git a/mlt/src/framework/mlt_frame.h b/mlt/src/framework/mlt_frame.h deleted file mode 100644 index 5ece49c..0000000 --- a/mlt/src/framework/mlt_frame.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * mlt_frame.h -- interface for all frame classes - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_FRAME_H_ -#define _MLT_FRAME_H_ - -#include "mlt_properties.h" - -typedef enum -{ - mlt_image_none = 0, - mlt_image_rgb24, - mlt_image_rgb24a, - mlt_image_yuv422, - mlt_image_yuv420p -} -mlt_image_format; - -typedef enum -{ - mlt_video_standard_pal = 0, - mlt_video_standard_ntsc -} -mlt_video_standard; - -typedef enum -{ - mlt_audio_none = 0, - mlt_audio_pcm -} -mlt_audio_format; - -typedef int ( *mlt_get_image )( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ); - -struct mlt_frame_s -{ - // We're extending properties here - struct mlt_properties_s parent; - - // Virtual methods - int ( *get_audio )( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ); - uint8_t * ( *get_alpha_mask )( mlt_frame this ); - - // Private properties - mlt_get_image stack_get_image[ 10 ]; - int stack_get_image_size; - mlt_frame stack_frame[ 10 ]; - int stack_frame_size; -}; - -extern mlt_frame mlt_frame_init( ); -extern mlt_properties mlt_frame_properties( mlt_frame this ); -extern int mlt_frame_is_test_card( mlt_frame this ); -extern int mlt_frame_is_test_audio( mlt_frame this ); -extern double mlt_frame_get_aspect_ratio( mlt_frame this ); -extern int mlt_frame_set_aspect_ratio( mlt_frame this, double value ); -extern mlt_position mlt_frame_get_position( mlt_frame this ); -extern int mlt_frame_set_position( mlt_frame this, mlt_position value ); - -extern int mlt_frame_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ); -extern uint8_t *mlt_frame_get_alpha_mask( mlt_frame this ); -extern int mlt_frame_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ); - -extern int mlt_frame_push_get_image( mlt_frame this, mlt_get_image get_image ); -extern mlt_get_image mlt_frame_pop_get_image( mlt_frame this ); -extern int mlt_frame_push_frame( mlt_frame this, mlt_frame that ); -extern mlt_frame mlt_frame_pop_frame( mlt_frame this ); -extern void mlt_frame_close( mlt_frame this ); - -/* convenience functions */ -extern int mlt_convert_rgb24a_to_yuv422( uint8_t *rgba, int width, int height, int stride, uint8_t *yuv, uint8_t *alpha ); -extern int mlt_convert_rgb24_to_yuv422( uint8_t *rgb, int width, int height, int stride, uint8_t *yuv ); -extern int mlt_convert_yuv420p_to_yuv422( uint8_t *yuv420p, int width, int height, int stride, uint8_t *yuv ); -extern int mlt_frame_composite_yuv( mlt_frame this, mlt_frame that, int x, int y, float weight ); -extern uint8_t *mlt_frame_resize_yuv422( mlt_frame this, int owidth, int oheight ); -extern uint8_t *mlt_frame_rescale_yuv422( mlt_frame this, int owidth, int oheight ); -extern void mlt_resize_yuv422( uint8_t *output, int owidth, int oheight, uint8_t *input, int iwidth, int iheight ); -extern int mlt_frame_mix_audio( mlt_frame this, mlt_frame that, float weight, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ); -extern int mlt_sample_calculator( float fps, int frequency, int64_t position ); - -#endif - diff --git a/mlt/src/framework/mlt_manager.h b/mlt/src/framework/mlt_manager.h deleted file mode 100644 index 1567e64..0000000 --- a/mlt/src/framework/mlt_manager.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * mlt_manager.h -- manager service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_MANAGER_H_ -#define _MLT_MANAGER_H_ - -mlt_producer mlt_manager_init( char **config ); - -#endif diff --git a/mlt/src/framework/mlt_multitrack.c b/mlt/src/framework/mlt_multitrack.c deleted file mode 100644 index 2faaf69..0000000 --- a/mlt/src/framework/mlt_multitrack.c +++ /dev/null @@ -1,376 +0,0 @@ -/* - * mlt_multitrack.c -- multitrack service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_multitrack.h" -#include "mlt_playlist.h" -#include "mlt_frame.h" - -#include -#include - -/** Private definition. -*/ - -struct mlt_multitrack_s -{ - // We're extending producer here - struct mlt_producer_s parent; - mlt_producer *list; - int size; - int count; -}; - -/** Forward reference. -*/ - -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); - -/** Constructor. -*/ - -mlt_multitrack mlt_multitrack_init( ) -{ - // Allocate the multitrack object - mlt_multitrack this = calloc( sizeof( struct mlt_multitrack_s ), 1 ); - - if ( this != NULL ) - { - mlt_producer producer = &this->parent; - if ( mlt_producer_init( producer, this ) == 0 ) - { - mlt_properties properties = mlt_multitrack_properties( this ); - producer->get_frame = producer_get_frame; - mlt_properties_set_data( properties, "multitrack", this, 0, NULL, NULL ); - mlt_properties_set( properties, "log_id", "multitrack" ); - mlt_properties_set( properties, "resource", "" ); - } - else - { - free( this ); - this = NULL; - } - } - - return this; -} - -/** Get the producer associated to this multitrack. -*/ - -mlt_producer mlt_multitrack_producer( mlt_multitrack this ) -{ - return &this->parent; -} - -/** Get the service associated this multitrack. -*/ - -mlt_service mlt_multitrack_service( mlt_multitrack this ) -{ - return mlt_producer_service( mlt_multitrack_producer( this ) ); -} - -/** Get the properties associated this multitrack. -*/ - -mlt_properties mlt_multitrack_properties( mlt_multitrack this ) -{ - return mlt_service_properties( mlt_multitrack_service( this ) ); -} - -/** Initialise position related information. -*/ - -void mlt_multitrack_refresh( mlt_multitrack this ) -{ - int i = 0; - - // Obtain the properties of this multitrack - mlt_properties properties = mlt_multitrack_properties( this ); - - // We need to ensure that the multitrack reports the longest track as its length - mlt_position length = 0; - - // We need to ensure that fps are the same on all services - double fps = 0; - - // Obtain stats on all connected services - for ( i = 0; i < this->count; i ++ ) - { - // Get the producer from this index - mlt_producer producer = this->list[ i ]; - - // If it's allocated then, update our stats - if ( producer != NULL ) - { - // If we have more than 1 track, we must be in continue mode - if ( this->count > 1 ) - mlt_properties_set( mlt_producer_properties( producer ), "eof", "continue" ); - - // Determine the longest length - length = mlt_producer_get_playtime( producer ) > length ? mlt_producer_get_playtime( producer ) : length; - - // Handle fps - if ( fps == 0 ) - { - // This is the first producer, so it controls the fps - fps = mlt_producer_get_fps( producer ); - } - else if ( fps != mlt_producer_get_fps( producer ) ) - { - // Generate a warning for now - the following attempt to fix may fail - fprintf( stderr, "Warning: fps mismatch on track %d\n", i ); - - // It should be safe to impose fps on an image producer, but not necessarily safe for video - mlt_properties_set_double( mlt_producer_properties( producer ), "fps", fps ); - } - } - } - - // Update multitrack properties now - we'll not destroy the in point here - mlt_properties_set_position( properties, "length", length ); - mlt_properties_set_position( properties, "out", length - 1 ); - mlt_properties_set_double( properties, "fps", fps ); -} - -/** Connect a producer to a given track. - - Note that any producer can be connected here, but see special case treatment - of playlist in clip point determination below. -*/ - -int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ) -{ - // Connect to the producer to ourselves at the specified track - int result = mlt_service_connect_producer( mlt_multitrack_service( this ), mlt_producer_service( producer ), track ); - - if ( result == 0 ) - { - // Resize the producer list if need be - if ( track >= this->size ) - { - int i; - this->list = realloc( this->list, ( track + 10 ) * sizeof( mlt_producer ) ); - for ( i = this->size; i < track + 10; i ++ ) - this->list[ i ] = NULL; - this->size = track + 10; - } - - // Assign the track in our list here - this->list[ track ] = producer; - - // Increment the track count if need be - if ( track >= this->count ) - this->count = track + 1; - - // Refresh our stats - mlt_multitrack_refresh( this ); - } - - return result; -} - -/** Get the number of tracks. -*/ - -int mlt_multitrack_count( mlt_multitrack this ) -{ - return this->count; -} - -/** Get an individual track as a producer. -*/ - -mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ) -{ - mlt_producer producer = NULL; - - if ( this->list != NULL && track < this->count ) - producer = this->list[ track ]; - - return producer; -} - - -/** Determine the clip point. - - Special case here: a 'producer' has no concept of multiple clips - only the - playlist and multitrack producers have clip functionality. Further to that a - multitrack determines clip information from any connected tracks that happen - to be playlists. - - Additionally, it must locate clips in the correct order, for example, consider - the following track arrangement: - - playlist1 |0.0 |b0.0 |0.1 |0.1 |0.2 | - playlist2 |b1.0 |1.0 |b1.1 |1.1 | - - Note - b clips represent blanks. They are also reported as clip positions. - - When extracting clip positions from these playlists, we should get a sequence of: - - 0.0, 1.0, b0.0, 0.1, b1.1, 1.1, 0.1, 0.2, [out of playlist2], [out of playlist1] -*/ - -mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ) -{ - int first = 1; - mlt_position position = 0; - int i = 0; - - // Loop through each of the tracks - for ( i = 0; i < this->count; i ++ ) - { - // Get the producer for this track - mlt_producer producer = this->list[ i ]; - - // If it's assigned... - if ( producer != NULL ) - { - // Get the properties of this producer - mlt_properties properties = mlt_producer_properties( producer ); - - // Determine if it's a playlist - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - - // We only consider playlists - if ( playlist != NULL ) - { - // Locate the smallest position - if ( first ) - { - // First position found - position = mlt_playlist_clip( playlist, whence, index ); - - // We're no longer first - first = 0; - } - else - { - // Obtain the clip position in this playlist - //mlt_position position2 = mlt_playlist_clip( playlist, whence, index ); - - // If this position is prior to the first, then use it - //if ( position2 < position ) - //position = position2; - } - } - else - { - fprintf( stderr, "track %d isn't a playlist\n", index ); - } - } - } - - return position; -} - -/** Get frame method. - - Special case here: The multitrack must be used in a conjunction with a downstream - tractor-type service, ie: - - Producer1 \ - Producer2 - multitrack - { filters/transitions } - tractor - consumer - Producer3 / - - The get_frame of a tractor pulls frames from it's connected service on all tracks and - will terminate as soon as it receives a test card with a last_track property. The - important case here is that the mulitrack does not move to the next frame until all - tracks have been pulled. - - Reasoning: In order to seek on a network such as above, the multitrack needs to ensure - that all producers are positioned on the same frame. It uses the 'last track' logic - to determine when to move to the next frame. - - Flaw: if a transition is configured to read from a b-track which happens to trigger - the last frame logic (ie: it's configured incorrectly), then things are going to go - out of sync. - - See playlist logic too. -*/ - -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ) -{ - // Get the mutiltrack object - mlt_multitrack this = parent->child; - - // Check if we have a track for this index - if ( index < this->count && this->list[ index ] != NULL ) - { - // Get the producer for this track - mlt_producer producer = this->list[ index ]; - - // Obtain the current position - mlt_position position = mlt_producer_frame( parent ); - - // Make sure we're at the same point - mlt_producer_seek( producer, position ); - - // Get the frame from the producer - mlt_service_get_frame( mlt_producer_service( producer ), frame, 0 ); - - // Indicate speed of this producer - mlt_properties producer_properties = mlt_producer_properties( parent ); - double speed = mlt_properties_get_double( producer_properties, "speed" ); - mlt_properties properties = mlt_frame_properties( *frame ); - mlt_properties_set_double( properties, "speed", speed ); - } - else - { - // Generate a test frame - *frame = mlt_frame_init( ); - - // Update position on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( parent ) ); - - // Move on to the next frame - if ( index >= this->count ) - { - // Let tractor know if we've reached the end - mlt_properties_set_int( mlt_frame_properties( *frame ), "last_track", 1 ); - - // Move to the next frame - mlt_producer_prepare_next( parent ); - } - - // Refresh our stats - mlt_multitrack_refresh( this ); - } - - return 0; -} - -/** Close this instance. -*/ - -void mlt_multitrack_close( mlt_multitrack this ) -{ - // Close the producer - mlt_producer_close( &this->parent ); - - // Free the list - free( this->list ); - - // Free the object - free( this ); -} diff --git a/mlt/src/framework/mlt_multitrack.h b/mlt/src/framework/mlt_multitrack.h deleted file mode 100644 index c409752..0000000 --- a/mlt/src/framework/mlt_multitrack.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * mlt_multitrack.h -- multitrack service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_MULITRACK_H_ -#define _MLT_MULITRACK_H_ - -#include "mlt_producer.h" - -/** Public final methods -*/ - -extern mlt_multitrack mlt_multitrack_init( ); -extern mlt_producer mlt_multitrack_producer( mlt_multitrack this ); -extern mlt_service mlt_multitrack_service( mlt_multitrack this ); -extern mlt_properties mlt_multitrack_properties( mlt_multitrack this ); -extern int mlt_multitrack_connect( mlt_multitrack this, mlt_producer producer, int track ); -extern mlt_position mlt_multitrack_clip( mlt_multitrack this, mlt_whence whence, int index ); -extern void mlt_multitrack_close( mlt_multitrack this ); -extern int mlt_multitrack_count( mlt_multitrack this ); -extern mlt_producer mlt_multitrack_track( mlt_multitrack this, int track ); - -#endif - diff --git a/mlt/src/framework/mlt_playlist.c b/mlt/src/framework/mlt_playlist.c deleted file mode 100644 index 7399d51..0000000 --- a/mlt/src/framework/mlt_playlist.c +++ /dev/null @@ -1,646 +0,0 @@ -/* - * mlt_playlist.c -- playlist service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_playlist.h" -#include "mlt_frame.h" - -#include -#include -#include - -/** Virtual playlist entry. -*/ - -typedef struct -{ - mlt_producer producer; - mlt_position frame_in; - mlt_position frame_out; - mlt_position frame_count; -} -playlist_entry; - -/** Private definition. -*/ - -struct mlt_playlist_s -{ - struct mlt_producer_s parent; - struct mlt_producer_s blank; - - int size; - int count; - playlist_entry **list; -}; - -/** Forward declarations -*/ - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ); - -/** Constructor. -*/ - -mlt_playlist mlt_playlist_init( ) -{ - mlt_playlist this = calloc( sizeof( struct mlt_playlist_s ), 1 ); - if ( this != NULL ) - { - mlt_producer producer = &this->parent; - - // Construct the producer - mlt_producer_init( producer, this ); - - // Override the producer get_frame - producer->get_frame = producer_get_frame; - - // Initialise blank - mlt_producer_init( &this->blank, NULL ); - mlt_properties_set( mlt_producer_properties( &this->blank ), "mlt_service", "blank" ); - mlt_properties_set( mlt_producer_properties( &this->blank ), "resource", "blank" ); - - // Indicate that this producer is a playlist - mlt_properties_set_data( mlt_playlist_properties( this ), "playlist", this, 0, NULL, NULL ); - - // Specify the eof condition - mlt_properties_set( mlt_playlist_properties( this ), "eof", "pause" ); - mlt_properties_set( mlt_playlist_properties( this ), "resource", "" ); - } - - return this; -} - -/** Get the producer associated to this playlist. -*/ - -mlt_producer mlt_playlist_producer( mlt_playlist this ) -{ - return &this->parent; -} - -/** Get the service associated to this playlist. -*/ - -mlt_service mlt_playlist_service( mlt_playlist this ) -{ - return mlt_producer_service( &this->parent ); -} - -/** Get the propertues associated to this playlist. -*/ - -mlt_properties mlt_playlist_properties( mlt_playlist this ) -{ - return mlt_producer_properties( &this->parent ); -} - -/** Refresh the playlist after a clip has been changed. -*/ - -static int mlt_playlist_virtual_refresh( mlt_playlist this ) -{ - int i = 0; - - // Get the fps of the first producer - double fps = mlt_properties_get_double( mlt_playlist_properties( this ), "first_fps" ); - mlt_position frame_count = 0; - - for ( i = 0; i < this->count; i ++ ) - { - // Get the producer - mlt_producer producer = this->list[ i ]->producer; - - // If fps is 0 - if ( fps == 0 ) - { - // Inherit it from the producer - fps = mlt_producer_get_fps( producer ); - } - else if ( fps != mlt_properties_get_double( mlt_producer_properties( producer ), "fps" ) ) - { - // Generate a warning for now - the following attempt to fix may fail - fprintf( stderr, "Warning: fps mismatch on playlist producer %d\n", this->count ); - - // It should be safe to impose fps on an image producer, but not necessarily safe for video - mlt_properties_set_double( mlt_producer_properties( producer ), "fps", fps ); - } - - // Update the frame_count for this clip - frame_count += this->list[ i ]->frame_count; - } - - // Refresh all properties - mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", fps ); - mlt_properties_set_double( mlt_playlist_properties( this ), "fps", fps == 0 ? 25 : fps ); - mlt_properties_set_position( mlt_playlist_properties( this ), "length", frame_count ); - mlt_properties_set_position( mlt_playlist_properties( this ), "out", frame_count - 1 ); - - return 0; -} - -/** Append to the virtual playlist. -*/ - -static int mlt_playlist_virtual_append( mlt_playlist this, mlt_producer producer, mlt_position in, mlt_position out ) -{ - // Check that we have room - if ( this->count >= this->size ) - { - int i; - this->list = realloc( this->list, ( this->size + 10 ) * sizeof( playlist_entry * ) ); - for ( i = this->size; i < this->size + 10; i ++ ) - this->list[ i ] = NULL; - this->size += 10; - } - - this->list[ this->count ] = calloc( sizeof( playlist_entry ), 1 ); - this->list[ this->count ]->producer = producer; - this->list[ this->count ]->frame_in = in; - this->list[ this->count ]->frame_out = out; - this->list[ this->count ]->frame_count = out - in + 1; - - mlt_properties_set( mlt_producer_properties( producer ), "eof", "continue" ); - - mlt_producer_set_speed( producer, 0 ); - - this->count ++; - - return mlt_playlist_virtual_refresh( this ); -} - -/** Seek in the virtual playlist. -*/ - -static mlt_producer mlt_playlist_virtual_seek( mlt_playlist this ) -{ - // Default producer to blank - mlt_producer producer = NULL; - - // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); - - // Total number of frames - int64_t total = 0; - - // Get the properties - mlt_properties properties = mlt_playlist_properties( this ); - - // Get the eof handling - char *eof = mlt_properties_get( properties, "eof" ); - - // Index for the main loop - int i = 0; - - // Loop for each producer until found - for ( i = 0; i < this->count; i ++ ) - { - // Increment the total - total += this->list[ i ]->frame_count; - - // Check if the position indicates that we have found the clip - if ( position < this->list[ i ]->frame_count ) - { - // Found it, now break - producer = this->list[ i ]->producer; - break; - } - else - { - // Decrement position by length of this entry - position -= this->list[ i ]->frame_count; - } - } - - // Seek in real producer to relative position - if ( producer != NULL ) - { - position += this->list[ i ]->frame_in; - mlt_producer_seek( producer, position ); - } - else if ( !strcmp( eof, "pause" ) && total > 0 ) - { - playlist_entry *entry = this->list[ this->count - 1 ]; - mlt_producer this_producer = mlt_playlist_producer( this ); - mlt_producer_seek( this_producer, total - 1 - mlt_producer_get_in( this_producer ) ); - producer = entry->producer; - mlt_producer_seek( producer, entry->frame_out ); - mlt_producer_set_speed( this_producer, 0 ); - } - else if ( !strcmp( eof, "loop" ) && total > 0 ) - { - playlist_entry *entry = this->list[ 0 ]; - mlt_producer this_producer = mlt_playlist_producer( this ); - mlt_producer_seek( this_producer, 0 ); - producer = entry->producer; - mlt_producer_seek( producer, entry->frame_in ); - } - else - { - producer = &this->blank; - } - - return producer; -} - -/** Invoked when a producer indicates that it has prematurely reached its end. -*/ - -static mlt_producer mlt_playlist_virtual_set_out( mlt_playlist this ) -{ - // Default producer to blank - mlt_producer producer = &this->blank; - - // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); - - // Loop through the virtual playlist - int i = 0; - - for ( i = 0; i < this->count; i ++ ) - { - if ( position < this->list[ i ]->frame_count ) - { - // Found it, now break - producer = this->list[ i ]->producer; - break; - } - else - { - // Decrement position by length of this entry - position -= this->list[ i ]->frame_count; - } - } - - // Seek in real producer to relative position - if ( i < this->count ) - { - // Update the frame_count for the changed clip (hmmm) - this->list[ i ]->frame_out = position; - this->list[ i ]->frame_count = this->list[ i ]->frame_out - this->list[ i ]->frame_in + 1; - - // Refresh the playlist - mlt_playlist_virtual_refresh( this ); - } - - return producer; -} - -/** Obtain the current clips index. -*/ - -int mlt_playlist_current_clip( mlt_playlist this ) -{ - // Map playlist position to real producer in virtual playlist - mlt_position position = mlt_producer_frame( &this->parent ); - - // Loop through the virtual playlist - int i = 0; - - for ( i = 0; i < this->count; i ++ ) - { - if ( position < this->list[ i ]->frame_count ) - { - // Found it, now break - break; - } - else - { - // Decrement position by length of this entry - position -= this->list[ i ]->frame_count; - } - } - - return i; -} - -/** Obtain the current clips producer. -*/ - -mlt_producer mlt_playlist_current( mlt_playlist this ) -{ - int i = mlt_playlist_current_clip( this ); - if ( i < this->count ) - return this->list[ i ]->producer; - else - return &this->blank; -} - -/** Get the position which corresponds to the start of the next clip. -*/ - -mlt_position mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index ) -{ - mlt_position position = 0; - int absolute_clip = index; - int i = 0; - - // Determine the absolute clip - switch ( whence ) - { - case mlt_whence_relative_start: - absolute_clip = index; - break; - - case mlt_whence_relative_current: - absolute_clip = mlt_playlist_current_clip( this ) + index; - break; - - case mlt_whence_relative_end: - absolute_clip = this->count - index; - break; - } - - // Check that we're in a valid range - if ( absolute_clip < 0 ) - absolute_clip = 0; - else if ( absolute_clip > this->count ) - absolute_clip = this->count; - - // Now determine the position - for ( i = 0; i < absolute_clip; i ++ ) - position += this->list[ i ]->frame_count; - - return position; -} - -/** Get all the info about the clip specified. -*/ - -int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, int index ) -{ - int error = index < 0 || index >= this->count; - memset( info, 0, sizeof( mlt_playlist_clip_info ) ); - if ( !error ) - { - mlt_producer producer = this->list[ index ]->producer; - mlt_properties properties = mlt_producer_properties( producer ); - info->clip = index; - info->producer = producer; - info->start = mlt_playlist_clip( this, mlt_whence_relative_start, index ); - info->resource = mlt_properties_get( properties, "resource" ); - info->frame_in = this->list[ index ]->frame_in; - info->frame_out = this->list[ index ]->frame_out; - info->frame_count = this->list[ index ]->frame_count; - info->length = mlt_producer_get_length( producer ); - info->fps = mlt_producer_get_fps( producer ); - } - return error; -} - -/** Get number of clips in the playlist. -*/ - -int mlt_playlist_count( mlt_playlist this ) -{ - return this->count; -} - -/** Clear the playlist. -*/ - -int mlt_playlist_clear( mlt_playlist this ) -{ - this->count = 0; - mlt_properties_set_double( mlt_playlist_properties( this ), "first_fps", 0 ); - return mlt_playlist_virtual_refresh( this ); -} - -/** Append a producer to the playlist. -*/ - -int mlt_playlist_append( mlt_playlist this, mlt_producer producer ) -{ - // Append to virtual list - return mlt_playlist_virtual_append( this, producer, 0, mlt_producer_get_playtime( producer ) - 1 ); -} - -/** Append a producer to the playlist with in/out points. -*/ - -int mlt_playlist_append_io( mlt_playlist this, mlt_producer producer, mlt_position in, mlt_position out ) -{ - // Append to virtual list - if ( in != -1 && out != -1 ) - return mlt_playlist_virtual_append( this, producer, in, out ); - else - return mlt_playlist_append( this, producer ); -} - -/** Append a blank to the playlist of a given length. -*/ - -int mlt_playlist_blank( mlt_playlist this, mlt_position length ) -{ - // Append to the virtual list - return mlt_playlist_virtual_append( this, &this->blank, 0, length ); -} - -/** Insert a producer into the playlist. -*/ - -int mlt_playlist_insert( mlt_playlist this, mlt_producer producer, int where, mlt_position in, mlt_position out ) -{ - // Append to end - mlt_playlist_append_io( this, producer, in, out ); - - // Move to the position specified - return mlt_playlist_move( this, this->count - 1, where ); -} - -/** Remove an entry in the playlist. -*/ - -int mlt_playlist_remove( mlt_playlist this, int where ) -{ - if ( this->count > 0 ) - { - // We need to know the current clip and the position within the playlist - int current = mlt_playlist_current_clip( this ); - mlt_position position = mlt_producer_position( mlt_playlist_producer( this ) ); - - // We need all the details about the clip we're removing - mlt_playlist_clip_info where_info; - - // Loop variable - int i = 0; - - // Make sure the clip to be removed is valid and correct if necessary - if ( where < 0 ) - where = 0; - if ( where >= this->count ) - where = this->count - 1; - - // Get the clip info of the clip to be removed - mlt_playlist_get_clip_info( this, &where_info, where ); - - // Reorganise the list - for ( i = where + 1; i < this->count; i ++ ) - this->list[ i - 1 ] = this->list[ i ]; - this->count --; - - // Correct position - if ( where == current ) - mlt_producer_seek( mlt_playlist_producer( this ), where_info.start ); - else if ( where < current && this->count > 0 ) - mlt_producer_seek( mlt_playlist_producer( this ), position - where_info.frame_count ); - else if ( this->count == 0 ) - mlt_producer_seek( mlt_playlist_producer( this ), 0 ); - } - - return 0; -} - -/** Move an entry in the playlist. -*/ - -int mlt_playlist_move( mlt_playlist this, int src, int dest ) -{ - int i; - - /* We need to ensure that the requested indexes are valid and correct it as necessary */ - if ( src < 0 ) - src = 0; - if ( src >= this->count ) - src = this->count - 1; - - if ( dest < 0 ) - dest = 0; - if ( dest >= this->count ) - dest = this->count - 1; - - if ( src != dest && this->count > 1 ) - { - int current = mlt_playlist_current_clip( this ); - mlt_position position = mlt_producer_position( mlt_playlist_producer( this ) ); - playlist_entry *src_entry = NULL; - - // We need all the details about the current clip - mlt_playlist_clip_info current_info; - - mlt_playlist_get_clip_info( this, ¤t_info, current ); - position -= current_info.start; - - if ( current == src ) - current = dest; - else if ( current > src && current < dest ) - current ++; - else if ( current == dest ) - current = src; - - if ( src > dest ) - { - int t = dest; - dest = src; - src = t; - } - - src_entry = this->list[ src ]; - - for ( i = src + 1; i <= dest; i ++ ) - this->list[ i - 1 ] = this->list[ i ]; - - this->list[ dest ] = src_entry; - - mlt_playlist_get_clip_info( this, ¤t_info, current ); - mlt_producer_seek( mlt_playlist_producer( this ), current_info.start + position ); - } - - return 0; -} - -/** Resize the current clip. -*/ - -int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_position out ) -{ - int error = clip < 0 || clip >= this->count; - if ( error == 0 ) - { - playlist_entry *entry = this->list[ clip ]; - mlt_producer producer = entry->producer; - - if ( in <= -1 ) - in = 0; - if ( out <= -1 || out >= mlt_producer_get_playtime( producer ) ) - out = mlt_producer_get_playtime( producer ) - 1; - - if ( out < in ) - { - mlt_position t = in; - in = out; - out = t; - } - - entry->frame_in = in; - entry->frame_out = out; - entry->frame_count = out - in + 1; - mlt_playlist_virtual_refresh( this ); - } - return error; -} - -/** Get the current frame. -*/ - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - // Get this mlt_playlist - mlt_playlist this = producer->child; - - // Get the real producer - mlt_producer real = mlt_playlist_virtual_seek( this ); - - // Get the frame - mlt_service_get_frame( mlt_producer_service( real ), frame, index ); - - // Check if we're at the end of the clip - mlt_properties properties = mlt_frame_properties( *frame ); - if ( mlt_properties_get_int( properties, "end_of_clip" ) ) - mlt_playlist_virtual_set_out( this ); - - // Check for notifier and call with appropriate argument - mlt_properties playlist_properties = mlt_producer_properties( producer ); - void ( *notifier )( void * ) = mlt_properties_get_data( playlist_properties, "notifier", NULL ); - if ( notifier != NULL ) - { - void *argument = mlt_properties_get_data( playlist_properties, "notifier_arg", NULL ); - notifier( argument ); - } - - // Update position on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_frame( producer ) ); - - // Position ourselves on the next frame - mlt_producer_prepare_next( producer ); - - return 0; -} - -/** Close the playlist. -*/ - -void mlt_playlist_close( mlt_playlist this ) -{ - mlt_producer_close( &this->parent ); - mlt_producer_close( &this->blank ); - free( this ); -} diff --git a/mlt/src/framework/mlt_playlist.h b/mlt/src/framework/mlt_playlist.h deleted file mode 100644 index 7bad6db..0000000 --- a/mlt/src/framework/mlt_playlist.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * mlt_playlist.h -- playlist service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_PLAYLIST_H_ -#define _MLT_PLAYLIST_H_ - -#include "mlt_producer.h" - -/** Structure for returning clip information. -*/ - -typedef struct -{ - int clip; - mlt_producer producer; - mlt_position start; - char *resource; - mlt_position frame_in; - mlt_position frame_out; - mlt_position frame_count; - mlt_position length; - float fps; -} -mlt_playlist_clip_info; - -/** Public final methods -*/ - -extern mlt_playlist mlt_playlist_init( ); -extern mlt_producer mlt_playlist_producer( mlt_playlist this ); -extern mlt_service mlt_playlist_service( mlt_playlist this ); -extern mlt_properties mlt_playlist_properties( mlt_playlist this ); -extern int mlt_playlist_count( mlt_playlist this ); -extern int mlt_playlist_clear( mlt_playlist this ); -extern int mlt_playlist_append( mlt_playlist this, mlt_producer producer ); -extern int mlt_playlist_append_io( mlt_playlist this, mlt_producer producer, mlt_position in, mlt_position out ); -extern int mlt_playlist_blank( mlt_playlist this, mlt_position length ); -extern mlt_position mlt_playlist_clip( mlt_playlist this, mlt_whence whence, int index ); -extern int mlt_playlist_current_clip( mlt_playlist this ); -extern mlt_producer mlt_playlist_current( mlt_playlist this ); -extern int mlt_playlist_get_clip_info( mlt_playlist this, mlt_playlist_clip_info *info, int index ); -extern int mlt_playlist_insert( mlt_playlist this, mlt_producer producer, int where, mlt_position in, mlt_position out ); -extern int mlt_playlist_remove( mlt_playlist this, int where ); -extern int mlt_playlist_move( mlt_playlist this, int from, int to ); -extern int mlt_playlist_resize_clip( mlt_playlist this, int clip, mlt_position in, mlt_position out ); -extern void mlt_playlist_close( mlt_playlist this ); - -#endif - diff --git a/mlt/src/framework/mlt_producer.c b/mlt/src/framework/mlt_producer.c deleted file mode 100644 index 21f5277..0000000 --- a/mlt/src/framework/mlt_producer.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * mlt_producer.c -- abstraction for all producer services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt_producer.h" -#include "mlt_frame.h" -#include -#include -#include -#include - -/** Forward references. -*/ - -static int producer_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); - -/** Constructor -*/ - -int mlt_producer_init( mlt_producer this, void *child ) -{ - // Initialise the producer - memset( this, 0, sizeof( struct mlt_producer_s ) ); - - // Associate with the child - this->child = child; - - // Initialise the service - if ( mlt_service_init( &this->parent, this ) == 0 ) - { - // The parent is the service - mlt_service parent = &this->parent; - - // Get the properties of the parent - mlt_properties properties = mlt_service_properties( parent ); - - // Set the default properties - mlt_properties_set( properties, "mlt_type", "mlt_producer" ); - mlt_properties_set_position( properties, "position", 0.0 ); - mlt_properties_set_double( properties, "frame", 0 ); - mlt_properties_set_double( properties, "fps", 25.0 ); - mlt_properties_set_double( properties, "speed", 1.0 ); - mlt_properties_set_position( properties, "in", 0 ); - mlt_properties_set_position( properties, "out", 1799999 ); - mlt_properties_set_position( properties, "length", 1800000 ); - mlt_properties_set_double( properties, "aspect_ratio", 4.0 / 3.0 ); - mlt_properties_set( properties, "eof", "pause" ); - mlt_properties_set( properties, "resource", "" ); - - // Override service get_frame - parent->get_frame = producer_get_frame; - } - - return 0; -} - -/** Get the parent service object. -*/ - -mlt_service mlt_producer_service( mlt_producer this ) -{ - return &this->parent; -} - -/** Get the producer properties. -*/ - -mlt_properties mlt_producer_properties( mlt_producer this ) -{ - return mlt_service_properties( &this->parent ); -} - -/** Seek to a specified position. -*/ - -int mlt_producer_seek( mlt_producer this, mlt_position position ) -{ - // Determine eof handling - char *eof = mlt_properties_get( mlt_producer_properties( this ), "eof" ); - - // Check bounds - if ( position < 0 ) - position = 0; - else if ( !strcmp( eof, "pause" ) && position >= mlt_producer_get_playtime( this ) ) - position = mlt_producer_get_playtime( this ) - 1; - - // Set the position - mlt_properties_set_position( mlt_producer_properties( this ), "position", position ); - - // Calculate the absolute frame - mlt_properties_set_position( mlt_producer_properties( this ), "frame", mlt_producer_get_in( this ) + position ); - - return 0; -} - -/** Get the current position (relative to in point). -*/ - -mlt_position mlt_producer_position( mlt_producer this ) -{ - return mlt_properties_get_position( mlt_producer_properties( this ), "position" ); -} - -/** Get the current position (relative to start of producer). -*/ - -mlt_position mlt_producer_frame( mlt_producer this ) -{ - return mlt_properties_get_position( mlt_producer_properties( this ), "frame" ); -} - -/** Set the playing speed. -*/ - -int mlt_producer_set_speed( mlt_producer this, double speed ) -{ - return mlt_properties_set_double( mlt_producer_properties( this ), "speed", speed ); -} - -/** Get the playing speed. -*/ - -double mlt_producer_get_speed( mlt_producer this ) -{ - return mlt_properties_get_double( mlt_producer_properties( this ), "speed" ); -} - -/** Get the frames per second. -*/ - -double mlt_producer_get_fps( mlt_producer this ) -{ - return mlt_properties_get_double( mlt_producer_properties( this ), "fps" ); -} - -/** Set the in and out points. -*/ - -int mlt_producer_set_in_and_out( mlt_producer this, mlt_position in, mlt_position out ) -{ - // Correct ins and outs if necessary - if ( in < 0 ) - in = 0; - else if ( in > mlt_producer_get_length( this ) ) - in = mlt_producer_get_length( this ); - - if ( out < 0 ) - out = 0; - else if ( out > mlt_producer_get_length( this ) ) - out = mlt_producer_get_length( this ); - - // Swap ins and outs if wrong - if ( out < in ) - { - mlt_position t = in; - in = out; - out = t; - } - - // Set the values - mlt_properties_set_position( mlt_producer_properties( this ), "in", in ); - mlt_properties_set_position( mlt_producer_properties( this ), "out", out ); - - return 0; -} - -/** Get the in point. -*/ - -mlt_position mlt_producer_get_in( mlt_producer this ) -{ - return mlt_properties_get_position( mlt_producer_properties( this ), "in" ); -} - -/** Get the out point. -*/ - -mlt_position mlt_producer_get_out( mlt_producer this ) -{ - return mlt_properties_get_position( mlt_producer_properties( this ), "out" ); -} - -/** Get the total play time. -*/ - -mlt_position mlt_producer_get_playtime( mlt_producer this ) -{ - return mlt_producer_get_out( this ) - mlt_producer_get_in( this ) + 1; -} - -/** Get the total length of the producer. -*/ - -mlt_position mlt_producer_get_length( mlt_producer this ) -{ - return mlt_properties_get_position( mlt_producer_properties( this ), "length" ); -} - -/** Prepare for next frame. -*/ - -void mlt_producer_prepare_next( mlt_producer this ) -{ - mlt_producer_seek( this, mlt_producer_position( this ) + mlt_producer_get_speed( this ) ); -} - -/** Get a frame. -*/ - -static int producer_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) -{ - int result = 1; - mlt_producer this = service->child; - - // Determine eof handling - char *eof = mlt_properties_get( mlt_producer_properties( this ), "eof" ); - - // A properly instatiated producer will have a get_frame method... - if ( this->get_frame == NULL || ( !strcmp( eof, "continue" ) && mlt_producer_position( this ) > mlt_producer_get_out( this ) ) ) - { - // Generate a test frame - *frame = mlt_frame_init( ); - - // Set the position - result = mlt_frame_set_position( *frame, mlt_producer_position( this ) ); - - // Calculate the next position - mlt_producer_prepare_next( this ); - } - else - { - // Get the frame from the implementation - result = this->get_frame( this, frame, index ); - } - - // Copy the fps and speed of the producer onto the frame - mlt_properties properties = mlt_frame_properties( *frame ); - mlt_properties_set_double( properties, "fps", mlt_producer_get_fps( this ) ); - double speed = mlt_producer_get_speed( this ); - mlt_properties_set_double( properties, "speed", speed ); - - return 0; -} - -/** Close the producer. -*/ - -void mlt_producer_close( mlt_producer this ) -{ - if ( this->close != NULL ) - this->close( this ); - else - mlt_service_close( &this->parent ); -} diff --git a/mlt/src/framework/mlt_producer.h b/mlt/src/framework/mlt_producer.h deleted file mode 100644 index 7e748c0..0000000 --- a/mlt/src/framework/mlt_producer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * mlt_producer.h -- abstraction for all producer services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_PRODUCER_H_ -#define _MLT_PRODUCER_H_ - -#include "mlt_service.h" - -/** The interface definition for all producers. -*/ - -struct mlt_producer_s -{ - // We're implementing service here - struct mlt_service_s parent; - - // Public virtual methods - int ( *get_frame )( mlt_producer, mlt_frame_ptr, int ); - void ( *close )( mlt_producer ); - - // Private data - void *private; - void *child; -}; - -/** Public final methods -*/ - -//extern double mlt_producer_convert_position_to_time( mlt_producer this, int64_t frame ); -//extern mlt_position mlt_producer_convert_time_to_position( mlt_producer this, double time ); - -extern int mlt_producer_init( mlt_producer this, void *child ); -extern mlt_service mlt_producer_service( mlt_producer this ); -extern mlt_properties mlt_producer_properties( mlt_producer this ); -extern int mlt_producer_seek( mlt_producer this, mlt_position position ); -extern mlt_position mlt_producer_position( mlt_producer this ); -extern mlt_position mlt_producer_frame( mlt_producer this ); -extern int mlt_producer_set_speed( mlt_producer this, double speed ); -extern double mlt_producer_get_speed( mlt_producer this ); -extern double mlt_producer_get_fps( mlt_producer this ); -extern int mlt_producer_set_in_and_out( mlt_producer this, mlt_position in, mlt_position out ); -extern mlt_position mlt_producer_get_in( mlt_producer this ); -extern mlt_position mlt_producer_get_out( mlt_producer this ); -extern mlt_position mlt_producer_get_playtime( mlt_producer this ); -extern mlt_position mlt_producer_get_length( mlt_producer this ); -extern void mlt_producer_prepare_next( mlt_producer this ); -extern void mlt_producer_close( mlt_producer this ); - -#endif diff --git a/mlt/src/framework/mlt_properties.c b/mlt/src/framework/mlt_properties.c deleted file mode 100644 index a0f39f2..0000000 --- a/mlt/src/framework/mlt_properties.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * mlt_properties.c -- base properties class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt_properties.h" -#include "mlt_property.h" - -#include -#include -#include - -/* ---------------- // Private Implementation // ---------------- */ - -/** Private implementation of the property list. -*/ - -typedef struct -{ - char **name; - mlt_property *value; - int count; - int size; -} -property_list; - -/** Basic implementation. -*/ - -int mlt_properties_init( mlt_properties this, void *child ) -{ - // NULL all methods - memset( this, 0, sizeof( struct mlt_properties_s ) ); - - // Assign the child of the object - this->child = child; - - // Allocate the private structure - this->private = calloc( sizeof( property_list ), 1 ); - - return this->private == NULL; -} - -/** Constructor for stand alone object. -*/ - -mlt_properties mlt_properties_new( ) -{ - // Construct a standalone properties object - mlt_properties this = calloc( sizeof( struct mlt_properties_s ), 1 ); - - // Initialise this - mlt_properties_init( this, NULL ); - - // Return the pointer - return this; -} - -/** Inherit all serialisable properties from that into this. -*/ - -int mlt_properties_inherit( mlt_properties this, mlt_properties that ) -{ - int count = mlt_properties_count( that ); - while ( count -- ) - { - char *value = mlt_properties_get_value( that, count ); - if ( value != NULL ) - { - char *name = mlt_properties_get_name( that, count ); - mlt_properties_set( this, name, value ); - } - } - return 0; -} - -/** Locate a property by name -*/ - -static mlt_property mlt_properties_find( mlt_properties this, char *name ) -{ - mlt_property value = NULL; - property_list *list = this->private; - int i = 0; - - // Locate the item - for ( i = 0; value == NULL && i < list->count; i ++ ) - if ( !strcmp( list->name[ i ], name ) ) - value = list->value[ i ]; - - return value; -} - -/** Add a new property. -*/ - -static mlt_property mlt_properties_add( mlt_properties this, char *name ) -{ - property_list *list = this->private; - - // Check that we have space and resize if necessary - if ( list->count == list->size ) - { - list->size += 10; - list->name = realloc( list->name, list->size * sizeof( char * ) ); - list->value = realloc( list->value, list->size * sizeof( mlt_property ) ); - } - - // Assign name/value pair - list->name[ list->count ] = strdup( name ); - list->value[ list->count ] = mlt_property_init( ); - - // Return and increment count accordingly - return list->value[ list->count ++ ]; -} - -/** Fetch a property by name - this includes add if not found. -*/ - -static mlt_property mlt_properties_fetch( mlt_properties this, char *name ) -{ - // Try to find an existing property first - mlt_property property = mlt_properties_find( this, name ); - - // If it wasn't found, create one - if ( property == NULL ) - property = mlt_properties_add( this, name ); - - // Return the property - return property; -} - -/** Set the property. -*/ - -int mlt_properties_set( mlt_properties this, char *name, char *value ) -{ - int error = 1; - - // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); - - // Set it if not NULL - if ( property != NULL ) - error = mlt_property_set_string( property, value ); - - return error; -} - -/** Get a string value by name. -*/ - -char *mlt_properties_get( mlt_properties this, char *name ) -{ - mlt_property value = mlt_properties_find( this, name ); - return value == NULL ? NULL : mlt_property_get_string( value ); -} - -/** Get a name by index. -*/ - -char *mlt_properties_get_name( mlt_properties this, int index ) -{ - property_list *list = this->private; - if ( index >= 0 && index < list->count ) - return list->name[ index ]; - return NULL; -} - -/** Get a string value by index. -*/ - -char *mlt_properties_get_value( mlt_properties this, int index ) -{ - property_list *list = this->private; - if ( index >= 0 && index < list->count ) - return mlt_property_get_string( list->value[ index ] ); - return NULL; -} - -/** Return the number of items in the list. -*/ - -int mlt_properties_count( mlt_properties this ) -{ - property_list *list = this->private; - return list->count; -} - -/** Set a value by parsing a name=value string -*/ - -int mlt_properties_parse( mlt_properties this, char *namevalue ) -{ - char *name = strdup( namevalue ); - char *value = strdup( namevalue ); - int error = 0; - - if ( strchr( name, '=' ) ) - { - *( strchr( name, '=' ) ) = '\0'; - strcpy( value, strchr( value, '=' ) + 1 ); - } - else - { - strcpy( value, "" ); - } - - error = mlt_properties_set( this, name, value ); - - free( name ); - free( value ); - - return error; -} - -/** Get a value associated to the name. -*/ - -int mlt_properties_get_int( mlt_properties this, char *name ) -{ - mlt_property value = mlt_properties_find( this, name ); - return value == NULL ? 0 : mlt_property_get_int( value ); -} - -/** Set a value associated to the name. -*/ - -int mlt_properties_set_int( mlt_properties this, char *name, int value ) -{ - int error = 1; - - // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); - - // Set it if not NULL - if ( property != NULL ) - error = mlt_property_set_int( property, value ); - - return error; -} - -/** Get a value associated to the name. -*/ - -double mlt_properties_get_double( mlt_properties this, char *name ) -{ - mlt_property value = mlt_properties_find( this, name ); - return value == NULL ? 0 : mlt_property_get_double( value ); -} - -/** Set a value associated to the name. -*/ - -int mlt_properties_set_double( mlt_properties this, char *name, double value ) -{ - int error = 1; - - // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); - - // Set it if not NULL - if ( property != NULL ) - error = mlt_property_set_double( property, value ); - - return error; -} - -/** Get a value associated to the name. -*/ - -mlt_position mlt_properties_get_position( mlt_properties this, char *name ) -{ - mlt_property value = mlt_properties_find( this, name ); - return value == NULL ? 0 : mlt_property_get_position( value ); -} - -/** Set a value associated to the name. -*/ - -int mlt_properties_set_position( mlt_properties this, char *name, mlt_position value ) -{ - int error = 1; - - // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); - - // Set it if not NULL - if ( property != NULL ) - error = mlt_property_set_position( property, value ); - - return error; -} - -/** Get a value associated to the name. -*/ - -void *mlt_properties_get_data( mlt_properties this, char *name, int *length ) -{ - mlt_property value = mlt_properties_find( this, name ); - return value == NULL ? NULL : mlt_property_get_data( value, length ); -} - -/** Set a value associated to the name. -*/ - -int mlt_properties_set_data( mlt_properties this, char *name, void *value, int length, mlt_destructor destroy, mlt_serialiser serialise ) -{ - int error = 1; - - // Fetch the property to work with - mlt_property property = mlt_properties_fetch( this, name ); - - // Set it if not NULL - if ( property != NULL ) - error = mlt_property_set_data( property, value, length, destroy, serialise ); - - return error; -} - -/** Close the list. -*/ - -void mlt_properties_close( mlt_properties this ) -{ - property_list *list = this->private; - int index = 0; - - // Clean up names and values - for ( index = 0; index < list->count; index ++ ) - { - free( list->name[ index ] ); - mlt_property_close( list->value[ index ] ); - } - - // Clear up the list - free( list->name ); - free( list->value ); - free( list ); - - // Free this now if this has no child - if ( this->child == NULL ) - free( this ); -} - diff --git a/mlt/src/framework/mlt_properties.h b/mlt/src/framework/mlt_properties.h deleted file mode 100644 index 2cacc9f..0000000 --- a/mlt/src/framework/mlt_properties.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * mlt_properties.h -- base properties class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_PROPERTIES_H_ -#define _MLT_PROPERTIES_H_ - -#include "mlt_types.h" - -/** The properties base class defines the basic property propagation and - handling. -*/ - -struct mlt_properties_s -{ - void *child; - void *private; -}; - -/** Public interface. -*/ - -extern int mlt_properties_init( mlt_properties, void *child ); -extern mlt_properties mlt_properties_new( ); -extern int mlt_properties_inherit( mlt_properties this, mlt_properties that ); -extern int mlt_properties_set( mlt_properties this, char *name, char *value ); -extern int mlt_properties_parse( mlt_properties this, char *namevalue ); -extern char *mlt_properties_get( mlt_properties this, char *name ); -extern char *mlt_properties_get_name( mlt_properties this, int index ); -extern char *mlt_properties_get_value( mlt_properties this, int index ); -extern int mlt_properties_get_int( mlt_properties this, char *name ); -extern int mlt_properties_set_int( mlt_properties this, char *name, int value ); -extern double mlt_properties_get_double( mlt_properties this, char *name ); -extern int mlt_properties_set_double( mlt_properties this, char *name, double value ); -extern mlt_position mlt_properties_get_position( mlt_properties this, char *name ); -extern int mlt_properties_set_position( mlt_properties this, char *name, mlt_position value ); -extern int mlt_properties_set_data( mlt_properties this, char *name, void *value, int length, mlt_destructor, mlt_serialiser ); -extern void *mlt_properties_get_data( mlt_properties this, char *name, int *length ); -extern int mlt_properties_count( mlt_properties this ); -extern void mlt_properties_close( mlt_properties this ); - -#endif diff --git a/mlt/src/framework/mlt_property.c b/mlt/src/framework/mlt_property.c deleted file mode 100644 index 0a47529..0000000 --- a/mlt/src/framework/mlt_property.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * mlt_property.c -- property class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_property.h" - -#include -#include -#include - -/** Construct and uninitialised property. -*/ - -mlt_property mlt_property_init( ) -{ - return calloc( sizeof( struct mlt_property_s ), 1 ); -} - -/** Clear a property. -*/ - -void mlt_property_clear( mlt_property this ) -{ - // Special case data handling - if ( this->types & mlt_prop_data && this->destructor != NULL ) - this->destructor( this->data ); - - // Special case string handling - if ( this->types & mlt_prop_string ) - free( this->prop_string ); - - // We can wipe it now. - memset( this, 0, sizeof( struct mlt_property_s ) ); -} - -/** Set an int on this property. -*/ - -int mlt_property_set_int( mlt_property this, int value ) -{ - mlt_property_clear( this ); - this->types = mlt_prop_int; - this->prop_int = value; - return 0; -} - -/** Set a double on this property. -*/ - -int mlt_property_set_double( mlt_property this, double value ) -{ - mlt_property_clear( this ); - this->types = mlt_prop_double; - this->prop_double = value; - return 0; -} - -/** Set a position on this property. -*/ - -int mlt_property_set_position( mlt_property this, mlt_position value ) -{ - mlt_property_clear( this ); - this->types = mlt_prop_position; - this->prop_position = value; - return 0; -} - -/** Set a string on this property. -*/ - -int mlt_property_set_string( mlt_property this, char *value ) -{ - mlt_property_clear( this ); - this->types = mlt_prop_string; - if ( value != NULL ) - this->prop_string = strdup( value ); - return this->prop_string != NULL; -} - -/** Set an int64 on this property. -*/ - -int mlt_property_set_int64( mlt_property this, int64_t value ) -{ - mlt_property_clear( this ); - this->types = mlt_prop_int64; - this->prop_int64 = value; - return 0; -} - -/** Set a data on this property. -*/ - -int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ) -{ - if ( this->data == value ) - this->destructor = NULL; - mlt_property_clear( this ); - this->types = mlt_prop_data; - this->data = value; - this->length = length; - this->destructor = destructor; - this->serialiser = serialiser; - return 0; -} - -/** Get an int from this property. -*/ - -int mlt_property_get_int( mlt_property this ) -{ - if ( this->types & mlt_prop_int ) - return this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( int )this->prop_double; - else if ( this->types & mlt_prop_position ) - return ( int )this->prop_position; - else if ( this->types & mlt_prop_int64 ) - return ( int )this->prop_int64; - else if ( this->types & mlt_prop_string ) - return atoi( this->prop_string ); - return 0; -} - -/** Get a double from this property. -*/ - -double mlt_property_get_double( mlt_property this ) -{ - if ( this->types & mlt_prop_double ) - return this->prop_double; - else if ( this->types & mlt_prop_int ) - return ( double )this->prop_int; - else if ( this->types & mlt_prop_position ) - return ( double )this->prop_position; - else if ( this->types & mlt_prop_int64 ) - return ( double )this->prop_int64; - else if ( this->types & mlt_prop_string ) - return atof( this->prop_string ); - return 0; -} - -/** Get a position from this property. -*/ - -mlt_position mlt_property_get_position( mlt_property this ) -{ - if ( this->types & mlt_prop_position ) - return this->prop_position; - else if ( this->types & mlt_prop_int ) - return ( mlt_position )this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( mlt_position )this->prop_double; - else if ( this->types & mlt_prop_int64 ) - return ( mlt_position )this->prop_int64; - else if ( this->types & mlt_prop_string ) - return ( mlt_position )atol( this->prop_string ); - return 0; -} - -/** Get an int64 from this property. -*/ - -int64_t mlt_property_get_int64( mlt_property this ) -{ - if ( this->types & mlt_prop_int64 ) - return this->prop_int64; - else if ( this->types & mlt_prop_int ) - return ( int64_t )this->prop_int; - else if ( this->types & mlt_prop_double ) - return ( int64_t )this->prop_double; - else if ( this->types & mlt_prop_position ) - return ( int64_t )this->prop_position; - else if ( this->types & mlt_prop_string ) - return ( int64_t )atol( this->prop_string ); - return 0; -} - -/** Get a string from this property. -*/ - -char *mlt_property_get_string( mlt_property this ) -{ - // Construct a string if need be - if ( ! ( this->types & mlt_prop_string ) ) - { - if ( this->types & mlt_prop_int ) - { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%d", this->prop_int ); - } - else if ( this->types & mlt_prop_double ) - { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%e", this->prop_double ); - } - else if ( this->types & mlt_prop_position ) - { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%lld", this->prop_position ); - } - else if ( this->types & mlt_prop_int64 ) - { - this->types |= mlt_prop_string; - this->prop_string = malloc( 32 ); - sprintf( this->prop_string, "%lld", this->prop_int64 ); - } - else if ( this->types & mlt_prop_data && this->serialiser != NULL ) - { - this->types |= mlt_prop_string; - this->prop_string = this->serialiser( this->data, this->length ); - } - } - - // Return the string (may be NULL) - return this->prop_string; -} - -/** Get a data and associated length. -*/ - -void *mlt_property_get_data( mlt_property this, int *length ) -{ - // Assign length if not NULL - if ( length != NULL ) - *length = this->length; - - // Return the data (note: there is no conversion here) - return this->data; -} - -/** Close this property. -*/ - -void mlt_property_close( mlt_property this ) -{ - mlt_property_clear( this ); - free( this ); -} - - diff --git a/mlt/src/framework/mlt_property.h b/mlt/src/framework/mlt_property.h deleted file mode 100644 index 3f59ad2..0000000 --- a/mlt/src/framework/mlt_property.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * mlt_property.h -- property class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_PROPERTY_H_ -#define _MLT_PROPERTY_H_ - -#include "mlt_types.h" - -/** Bit pattern for properties. -*/ - -typedef enum -{ - mlt_prop_none = 0, - mlt_prop_int = 1, - mlt_prop_string = 2, - mlt_prop_position = 4, - mlt_prop_double = 8, - mlt_prop_data = 16, - mlt_prop_int64 = 32 -} -mlt_property_type; - -/** Property structure. -*/ - -typedef struct mlt_property_s -{ - // Stores a bit pattern of types available for this property - mlt_property_type types; - - // Atomic type handling - int prop_int; - mlt_position prop_position; - double prop_double; - int64_t prop_int64; - - // String handling - char *prop_string; - - // Generic type handling - void *data; - int length; - mlt_destructor destructor; - mlt_serialiser serialiser; -} -*mlt_property; - -/** API -*/ - -extern mlt_property mlt_property_init( ); -extern void mlt_property_clear( mlt_property this ); -extern int mlt_property_set_int( mlt_property this, int value ); -extern int mlt_property_set_double( mlt_property this, double value ); -extern int mlt_property_set_position( mlt_property this, mlt_position value ); -extern int mlt_property_set_uint64( mlt_property this, uint64_t value ); -extern int mlt_property_set_string( mlt_property this, char *value ); -extern int mlt_property_set_data( mlt_property this, void *value, int length, mlt_destructor destructor, mlt_serialiser serialiser ); -extern int mlt_property_get_int( mlt_property this ); -extern double mlt_property_get_double( mlt_property this ); -extern mlt_position mlt_property_get_position( mlt_property this ); -extern int64_t mlt_property_get_int64( mlt_property this ); -extern char *mlt_property_get_string( mlt_property this ); -extern void *mlt_property_get_data( mlt_property this, int *length ); -extern void mlt_property_close( mlt_property this ); - -#endif - diff --git a/mlt/src/framework/mlt_repository.c b/mlt/src/framework/mlt_repository.c deleted file mode 100644 index 9c25b21..0000000 --- a/mlt/src/framework/mlt_repository.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - * repository.c -- provides a map between service and shared objects - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "mlt_repository.h" -#include "mlt_properties.h" - -#include -#include -#include -#include - -struct mlt_repository_s -{ - struct mlt_properties_s parent; - mlt_properties object_list; -}; - -static char *construct_full_file( char *output, char *prefix, char *file ) -{ - strcpy( output, prefix ); - if ( prefix[ strlen( prefix ) - 1 ] != '/' ) - strcat( output, "/" ); - strcat( output, file ); - return output; -} - -static char *chomp( char *input ) -{ - if ( input[ strlen( input ) - 1 ] == '\n' ) - input[ strlen( input ) - 1 ] = '\0'; - return input; -} - -static mlt_properties construct_object( char *prefix, char *id ) -{ - mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 ); - mlt_properties_init( output, NULL ); - mlt_properties_set( output, "prefix", prefix ); - mlt_properties_set( output, "id", id ); - return output; -} - -static mlt_properties construct_service( mlt_properties object, char *id ) -{ - mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 ); - mlt_properties_init( output, NULL ); - mlt_properties_set_data( output, "object", object, 0, NULL, NULL ); - mlt_properties_set( output, "id", id ); - return output; -} - -static void *construct_instance( mlt_properties service_properties, char *symbol, void *input ) -{ - // Extract the service - char *service = mlt_properties_get( service_properties, "id" ); - - // Get the object properties - void *object_properties = mlt_properties_get_data( service_properties, "object", NULL ); - - // Get the dlopen'd object - void *object = mlt_properties_get_data( object_properties, "dlopen", NULL ); - - // Get the dlsym'd symbol - void *( *symbol_ptr )( char *, void * ) = mlt_properties_get_data( object_properties, symbol, NULL ); - - // Check that we have object and open if we don't - if ( object == NULL ) - { - char full_file[ 512 ]; - - // Get the prefix and id of the shared object - char *prefix = mlt_properties_get( object_properties, "prefix" ); - char *file = mlt_properties_get( object_properties, "id" ); - - // Construct the full file - construct_full_file( full_file, prefix, file ); - - // Open the shared object - object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL ); - if ( object == NULL ) - fprintf( stderr, "Failed to load plugin: %s\n", dlerror() ); - - // Set it on the properties - mlt_properties_set_data( object_properties, "dlopen", object, 0, ( void (*)( void * ) )dlclose, NULL ); - } - - // Now check if we have this symbol pointer - if ( object != NULL && symbol_ptr == NULL ) - { - // Construct it now - symbol_ptr = dlsym( object, symbol ); - - // Set it on the properties - mlt_properties_set_data( object_properties, "dlsym", symbol_ptr, 0, NULL, NULL ); - } - - // Construct the service - return symbol_ptr != NULL ? symbol_ptr( service, input ) : NULL; -} - -void destroy_properties( void *arg ) -{ - mlt_properties_close( arg ); - free( arg ); -} - -mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *data, char *symbol ) -{ - char full_file[ 512 ]; - FILE *file; - - // Construct the repository - mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 ); - mlt_properties_init( &this->parent, this ); - - // Add the symbol to THIS repository properties. - mlt_properties_set( &this->parent, "_symbol", symbol ); - - // Asociate the repository to the global object_list - this->object_list = object_list; - - // Construct full file - construct_full_file( full_file, prefix, data ); - - // Open the file - file = fopen( full_file, "r" ); - - // Parse the contents - if ( file != NULL ) - { - char full[ 512 ]; - char service[ 256 ]; - char object[ 256 ]; - - while( fgets( full, 512, file ) ) - { - chomp( full ); - - if ( full[ 0 ] != '#' && full[ 0 ] != '\0' && sscanf( full, "%s %s", service, object ) == 2 ) - { - // Get the object properties first - mlt_properties object_properties = mlt_properties_get_data( object_list, object, NULL ); - - // If their are no properties, create them now - if ( object_properties == NULL ) - { - // Construct the object - object_properties = construct_object( prefix, object ); - - // Add it to the object list - mlt_properties_set_data( object_list, object, object_properties, 0, destroy_properties, NULL ); - } - - // Now construct a property for the service - mlt_properties service_properties = construct_service( object_properties, service ); - - // Add it to the repository - mlt_properties_set_data( &this->parent, service, service_properties, 0, destroy_properties, NULL ); - } - } - - // Close the file - fclose( file ); - } - - return this; -} - -void *mlt_repository_fetch( mlt_repository this, char *service, void *input ) -{ - // Get the service properties - mlt_properties service_properties = mlt_properties_get_data( &this->parent, service, NULL ); - - // If the service exists - if ( service_properties != NULL ) - { - // Get the symbol that is used to generate this service - char *symbol = mlt_properties_get( &this->parent, "_symbol" ); - - // Now get an instance of the service - return construct_instance( service_properties, symbol, input ); - } - - return NULL; -} - -void mlt_repository_close( mlt_repository this ) -{ - mlt_properties_close( &this->parent ); - free( this ); -} - - diff --git a/mlt/src/framework/mlt_repository.h b/mlt/src/framework/mlt_repository.h deleted file mode 100644 index f00ad5b..0000000 --- a/mlt/src/framework/mlt_repository.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * repository.h -- provides a map between service and shared objects - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_REPOSITORY_H_ -#define _MLT_REPOSITORY_H_ - -#include "mlt_types.h" - -/** Repository structure forward reference. -*/ - -typedef struct mlt_repository_s *mlt_repository; - -/** Public functions. -*/ - -extern mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *file, char *symbol ); -extern void *mlt_repository_fetch( mlt_repository this, char *service, void *input ); -extern void mlt_repository_close( mlt_repository this ); - -#endif - diff --git a/mlt/src/framework/mlt_service.c b/mlt/src/framework/mlt_service.c deleted file mode 100644 index f432aae..0000000 --- a/mlt/src/framework/mlt_service.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * mlt_service.c -- interface for all service classes - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" -#include "mlt_service.h" -#include "mlt_frame.h" -#include -#include -#include - -/** IMPORTANT NOTES - - The base service implements a null frame producing service - as such, - it is functional without extension and will produce test cards frames - and PAL sized audio frames. - - PLEASE DO NOT CHANGE THIS BEHAVIOUR!!! OVERRIDE THE METHODS THAT - CONTROL THIS IN EXTENDING CLASSES. -*/ - -/** Private service definition. -*/ - -typedef struct -{ - int size; - int count; - mlt_service *in; - mlt_service out; -} -mlt_service_base; - -/** Friends? -*/ - -static void mlt_service_disconnect( mlt_service this ); -static void mlt_service_connect( mlt_service this, mlt_service that ); -static int service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); - -/** Constructor -*/ - -int mlt_service_init( mlt_service this, void *child ) -{ - // Initialise everything to NULL - memset( this, 0, sizeof( struct mlt_service_s ) ); - - // Assign the child - this->child = child; - - // Generate private space - this->private = calloc( sizeof( mlt_service_base ), 1 ); - - // Associate the methods - this->get_frame = service_get_frame; - - // Initialise the properties - return mlt_properties_init( &this->parent, this ); -} - -/** Return the properties object. -*/ - -mlt_properties mlt_service_properties( mlt_service this ) -{ - return &this->parent; -} - -/** Connect a producer service. - Returns: > 0 warning, == 0 success, < 0 serious error - 1 = this service does not accept input - 2 = the producer is invalid - 3 = the producer is already registered with this consumer -*/ - -int mlt_service_connect_producer( mlt_service this, mlt_service producer, int index ) -{ - int i = 0; - - // Get the service base - mlt_service_base *base = this->private; - - // Does this service accept input? - if ( mlt_service_accepts_input( this ) == 0 ) - return 1; - - // Does the producer service accept output connections? - if ( mlt_service_accepts_output( producer ) == 0 ) - return 2; - - // Check if the producer is already registered with this service - for ( i = 0; i < base->count; i ++ ) - if ( base->in[ i ] == producer ) - return 3; - - // Allocate space - if ( index >= base->size ) - { - int new_size = base->size + index + 10; - base->in = realloc( base->in, new_size * sizeof( mlt_service ) ); - if ( base->in != NULL ) - { - for ( i = base->size; i < new_size; i ++ ) - base->in[ i ] = NULL; - base->size = new_size; - } - } - - // If we have space, assign the input - if ( base->in != NULL && index >= 0 && index < base->size ) - { - // Now we disconnect the producer service from its consumer - mlt_service_disconnect( producer ); - - // Add the service to index specified - base->in[ index ] = producer; - - // Determine the number of active tracks - if ( index >= base->count ) - base->count = index + 1; - - // Now we connect the producer to its connected consumer - mlt_service_connect( producer, this ); - - // Inform caller that all went well - return 0; - } - else - { - return -1; - } -} - -/** Disconnect this service from its consumer. -*/ - -void mlt_service_disconnect( mlt_service this ) -{ - // Get the service base - mlt_service_base *base = this->private; - - // There's a bit more required here... - base->out = NULL; -} - -/** Associate this service to the its consumer. -*/ - -void mlt_service_connect( mlt_service this, mlt_service that ) -{ - // Get the service base - mlt_service_base *base = this->private; - - // There's a bit more required here... - base->out = that; -} - - -/** Get the first connected producer service. -*/ - -mlt_service mlt_service_get_producer( mlt_service this ) -{ - mlt_service producer = NULL; - - // Get the service base - mlt_service_base *base = this->private; - - if ( base->in != NULL ) - producer = base->in[ 0 ]; - - return producer; -} - - -/** Get the service state. -*/ - -mlt_service_state mlt_service_get_state( mlt_service this ) -{ - mlt_service_state state = mlt_state_unknown; - if ( mlt_service_has_input( this ) ) - state |= mlt_state_providing; - if ( mlt_service_has_output( this ) ) - state |= mlt_state_connected; - if ( state != ( mlt_state_providing | mlt_state_connected ) ) - state |= mlt_state_dormant; - return state; -} - -/** Get the maximum number of inputs accepted. - Returns: -1 for many, 0 for none or n for fixed. -*/ - -int mlt_service_accepts_input( mlt_service this ) -{ - if ( this->accepts_input == NULL ) - return -1; - else - return this->accepts_input( this ); -} - -/** Get the maximum number of outputs accepted. -*/ - -int mlt_service_accepts_output( mlt_service this ) -{ - if ( this->accepts_output == NULL ) - return 1; - else - return this->accepts_output( this ); -} - -/** Determines if this service has input -*/ - -int mlt_service_has_input( mlt_service this ) -{ - if ( this->has_input == NULL ) - return 1; - else - return this->has_input( this ); -} - -/** Determine if this service has output -*/ - -int mlt_service_has_output( mlt_service this ) -{ - mlt_service_base *base = this->private; - if ( this->has_output == NULL ) - return base->out != NULL; - else - return this->has_output( this ); -} - -/** Check if the service is active. -*/ - -int mlt_service_is_active( mlt_service this ) -{ - return !( mlt_service_get_state( this ) & mlt_state_dormant ); -} - -/** Obtain a frame to pass on. -*/ - -static int service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) -{ - mlt_service_base *base = this->private; - if ( index < base->count ) - { - mlt_service producer = base->in[ index ]; - if ( producer != NULL ) - return mlt_service_get_frame( producer, frame, index ); - } - *frame = mlt_frame_init( ); - return 0; -} - -int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ) -{ - return this->get_frame( this, frame, index ); -} - -/** Close the service. -*/ - -void mlt_service_close( mlt_service this ) -{ - mlt_service_base *base = this->private; - free( base->in ); - free( base ); - mlt_properties_close( &this->parent ); -} - diff --git a/mlt/src/framework/mlt_service.h b/mlt/src/framework/mlt_service.h deleted file mode 100644 index 8ad43a8..0000000 --- a/mlt/src/framework/mlt_service.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * mlt_service.h -- interface for all service classes - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_SERVICE_H_ -#define _MLT_SERVICE_H_ - -#include "mlt_properties.h" - -/** State of a service. - - Note that a service may be dormant even though it's fully connected, - providing or consuming. -*/ - -typedef enum -{ - mlt_state_unknown = 0, - mlt_state_dormant = 1, - mlt_state_connected = 2, - mlt_state_providing = 4, - mlt_state_consuming = 8 -} -mlt_service_state; - -/** The interface definition for all services. -*/ - -struct mlt_service_s -{ - // We're extending properties here - struct mlt_properties_s parent; - - // Protected virtual - int ( *accepts_input )( mlt_service this ); - int ( *accepts_output )( mlt_service this ); - int ( *has_input )( mlt_service this ); - int ( *has_output )( mlt_service this ); - int ( *get_frame )( mlt_service this, mlt_frame_ptr frame, int index ); - - // Private data - void *private; - void *child; -}; - -/** The public API. -*/ - -extern int mlt_service_init( mlt_service this, void *child ); -extern mlt_properties mlt_service_properties( mlt_service this ); -extern int mlt_service_connect_producer( mlt_service this, mlt_service producer, int index ); -extern mlt_service_state mlt_service_get_state( mlt_service this ); -extern void mlt_service_close( mlt_service this ); - -extern int mlt_service_accepts_input( mlt_service this ); -extern int mlt_service_accepts_output( mlt_service this ); -extern int mlt_service_has_input( mlt_service this ); -extern int mlt_service_has_output( mlt_service this ); -extern int mlt_service_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); -extern int mlt_service_is_active( mlt_service this ); -extern mlt_service mlt_service_get_producer( mlt_service this ); - -#endif - diff --git a/mlt/src/framework/mlt_tractor.c b/mlt/src/framework/mlt_tractor.c deleted file mode 100644 index f68079a..0000000 --- a/mlt/src/framework/mlt_tractor.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * mlt_tractor.c -- tractor service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_tractor.h" -#include "mlt_frame.h" -#include "mlt_multitrack.h" - -#include -#include -#include - -/** Private structure. -*/ - -struct mlt_tractor_s -{ - struct mlt_producer_s parent; - mlt_service producer; -}; - -/** Forward references to static methods. -*/ - -static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int track ); - -/** Constructor for the tractor. - - TODO: thread this service... -*/ - -mlt_tractor mlt_tractor_init( ) -{ - mlt_tractor this = calloc( sizeof( struct mlt_tractor_s ), 1 ); - if ( this != NULL ) - { - mlt_producer producer = &this->parent; - if ( mlt_producer_init( producer, this ) == 0 ) - { - producer->get_frame = producer_get_frame; - mlt_properties_set( mlt_producer_properties( producer ), "resource", "" ); - mlt_properties_set( mlt_producer_properties( producer ), "mlt_type", "mlt_producer" ); - mlt_properties_set( mlt_producer_properties( producer ), "mlt_service", "tractor" ); - } - else - { - free( this ); - this = NULL; - } - } - return this; -} - -/** Get the service object associated to the tractor. -*/ - -mlt_service mlt_tractor_service( mlt_tractor this ) -{ - return mlt_producer_service( &this->parent ); -} - -/** Get the producer object associated to the tractor. -*/ - -mlt_producer mlt_tractor_producer( mlt_tractor this ) -{ - return &this->parent; -} - -/** Get the properties object associated to the tractor. -*/ - -mlt_properties mlt_tractor_properties( mlt_tractor this ) -{ - return mlt_producer_properties( &this->parent ); -} - -/** Connect the tractor. -*/ - -int mlt_tractor_connect( mlt_tractor this, mlt_service producer ) -{ - int ret = mlt_service_connect_producer( mlt_tractor_service( this ), producer, 0 ); - - // This is the producer we're going to connect to - if ( ret == 0 ) - this->producer = producer; - - return ret; -} - -/** Get the next frame. - - TODO: This should be reading a pump being populated by the thread... -*/ - -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int track ) -{ - mlt_tractor this = parent->child; - - // We only respond to the first track requests - if ( track == 0 && this->producer != NULL ) - { - int i = 0; - int looking = 1; - int done = 0; - mlt_frame temp = NULL; - mlt_frame store[ 10 ]; - int count = 0; - - // Get the properties of the parent producer - mlt_properties properties = mlt_producer_properties( parent ); - - // Try to obtain the multitrack associated to the tractor - mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL ); - - // If we don't have one, we're in trouble... - if ( multitrack != NULL ) - { - mlt_producer target = mlt_multitrack_producer( multitrack ); - mlt_producer_seek( target, mlt_producer_frame( parent ) ); - mlt_producer_set_speed( target, mlt_producer_get_speed( parent ) ); - } - else - { - fprintf( stderr, "tractor without a multitrack!!\n" ); - } - - // Loop through each of the tracks we're harvesting - for ( i = 0; !done; i ++ ) - { - // Get a frame from the producer - mlt_service_get_frame( this->producer, &temp, i ); - - // Check for last track - done = mlt_properties_get_int( mlt_frame_properties( temp ), "last_track" ); - - // Handle the frame - if ( done && looking ) - { - // Use this as output if we don't have one already - *frame = temp; - } - else if ( ( !mlt_frame_is_test_card( temp ) || !mlt_frame_is_test_audio( temp ) ) && looking && - mlt_producer_frame( parent ) == mlt_frame_get_position( temp ) ) - { - *frame = temp; - looking = 0; - } - else - { - // We store all other frames for now - store[ count ++ ] = temp; - } - } - - // Now place all the unused frames on to the properties (will be destroyed automatically) - while ( count -- ) - { - mlt_properties frame_properties = mlt_frame_properties( *frame ); - char label[ 30 ]; - sprintf( label, "tractor_%d", count ); - while ( mlt_properties_get_data( frame_properties, label, NULL ) != NULL ) - strcat( label, "+" ); - mlt_properties_set_data( frame_properties, label, store[ count ], 0, ( mlt_destructor )mlt_frame_close, NULL ); - } - - // Prepare the next frame - mlt_producer_prepare_next( parent ); - - // Indicate our found status - return 0; - } - else - { - // Generate a test card - *frame = mlt_frame_init( ); - return 0; - } -} - -/** Close the tractor. -*/ - -void mlt_tractor_close( mlt_tractor this ) -{ - mlt_producer_close( &this->parent ); - free( this ); -} - diff --git a/mlt/src/framework/mlt_tractor.h b/mlt/src/framework/mlt_tractor.h deleted file mode 100644 index b6576ec..0000000 --- a/mlt/src/framework/mlt_tractor.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * mlt_tractor.h -- tractor service class - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_TRACTOR_H_ -#define _MLT_TRACTOR_H_ - -#include "mlt_producer.h" - -extern mlt_tractor mlt_tractor_init( ); -extern mlt_service mlt_tractor_service( mlt_tractor this ); -extern mlt_producer mlt_tractor_producer( mlt_tractor this ); -extern mlt_properties mlt_tractor_properties( mlt_tractor this ); -extern int mlt_tractor_connect( mlt_tractor this, mlt_service service ); -extern void mlt_tractor_close( mlt_tractor this ); - -#endif diff --git a/mlt/src/framework/mlt_transition.c b/mlt/src/framework/mlt_transition.c deleted file mode 100644 index b4024fb..0000000 --- a/mlt/src/framework/mlt_transition.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * mlt_transition.c -- abstraction for all transition services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include "mlt_transition.h" -#include "mlt_frame.h" - -#include -#include -#include - -/** Forward references. -*/ - -static int transition_get_frame( mlt_service this, mlt_frame_ptr frame, int index ); - -/** Constructor. -*/ - -int mlt_transition_init( mlt_transition this, void *child ) -{ - mlt_service service = &this->parent; - memset( this, 0, sizeof( struct mlt_transition_s ) ); - this->child = child; - if ( mlt_service_init( service, this ) == 0 ) - { - mlt_properties properties = mlt_transition_properties( this ); - - service->get_frame = transition_get_frame; - - mlt_properties_set_position( properties, "in", 0 ); - mlt_properties_set_position( properties, "out", 0 ); - mlt_properties_set_int( properties, "a_track", 0 ); - mlt_properties_set_int( properties, "b_track", 1 ); - - return 0; - } - return 1; -} - -/** Get the service associated to the transition. -*/ - -mlt_service mlt_transition_service( mlt_transition this ) -{ - return &this->parent; -} - -/** Get the properties interface. -*/ - -mlt_properties mlt_transition_properties( mlt_transition this ) -{ - return mlt_service_properties( mlt_transition_service( this ) ); -} - -/** Connect this transition with a producers a and b tracks. -*/ - -int mlt_transition_connect( mlt_transition this, mlt_service producer, int a_track, int b_track ) -{ - int ret = mlt_service_connect_producer( &this->parent, producer, a_track ); - if ( ret == 0 ) - { - mlt_properties properties = mlt_transition_properties( this ); - this->producer = producer; - mlt_properties_set_int( properties, "a_track", a_track ); - mlt_properties_set_int( properties, "b_track", b_track ); - } - return ret; -} - -/** Set the in and out points. -*/ - -void mlt_transition_set_in_and_out( mlt_transition this, mlt_position in, mlt_position out ) -{ - mlt_properties properties = mlt_transition_properties( this ); - mlt_properties_set_position( properties, "in", in ); - mlt_properties_set_position( properties, "out", out ); -} - -/** Get the index of the a track. -*/ - -int mlt_transition_get_a_track( mlt_transition this ) -{ - return mlt_properties_get_int( mlt_transition_properties( this ), "a_track" ); -} - -/** Get the index of the b track. -*/ - -int mlt_transition_get_b_track( mlt_transition this ) -{ - return mlt_properties_get_int( mlt_transition_properties( this ), "b_track" ); -} - -/** Get the in point. -*/ - -mlt_position mlt_transition_get_in( mlt_transition this ) -{ - return mlt_properties_get_position( mlt_transition_properties( this ), "in" ); -} - -/** Get the out point. -*/ - -mlt_position mlt_transition_get_out( mlt_transition this ) -{ - return mlt_properties_get_position( mlt_transition_properties( this ), "out" ); -} - -/** Process the frame. - - If we have no process method (unlikely), we simply return the a_frame unmolested. -*/ - -static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame ) -{ - if ( this->process == NULL ) - return a_frame; - else - return this->process( this, a_frame, b_frame ); -} - -/** Get a frame from this filter. - - The logic is complex here. A transition is applied to frames on the a and b tracks - specified in the connect method above. Since all frames are obtained via this - method for all tracks, we have to take special care that we only obtain the a and - b frames once - we do this on the first call to get a frame from either a or b. - - After that, we have 2 cases to resolve: - - 1) if the track is the a_track and we're in the time zone, then we need to call the - process method to do the effect on the frame and remember we've passed it on - otherwise, we pass on the a_frame unmolested; - 2) For all other tracks, we get the frames on demand. -*/ - -static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int index ) -{ - mlt_transition this = service->child; - - mlt_properties properties = mlt_transition_properties( this ); - - int a_track = mlt_properties_get_int( properties, "a_track" ); - int b_track = mlt_properties_get_int( properties, "b_track" ); - mlt_position in = mlt_properties_get_position( properties, "in" ); - mlt_position out = mlt_properties_get_position( properties, "out" ); - - // Fetch a and b frames together... - if ( ( index == a_track || index == b_track ) && !( this->a_held || this->b_held ) ) - { - mlt_service_get_frame( this->producer, &this->a_frame, a_track ); - mlt_service_get_frame( this->producer, &this->b_frame, b_track ); - this->a_held = 1; - this->b_held = 1; - } - - // Special case track processing - if ( index == a_track ) - { - // Determine if we're in the right time zone - mlt_position position = mlt_frame_get_position( this->a_frame ); - if ( position >= in && position <= out ) - { - // Process the transition - *frame = transition_process( this, this->a_frame, this->b_frame ); - this->a_held = 0; - } - else - { - // Pass on the 'a frame' and remember that we've done it - *frame = this->a_frame; - this->a_held = 0; - } - return 0; - } - if ( index == b_track ) - { - // Pass on the 'b frame' and remember that we've done it - *frame = this->b_frame; - this->b_held = 0; - return 0; - } - else - { - // Pass through - return mlt_service_get_frame( this->producer, frame, index ); - } -} - -/** Close the transition. -*/ - -void mlt_transition_close( mlt_transition this ) -{ - if ( this->close != NULL ) - this->close( this ); - else - mlt_service_close( &this->parent ); -} diff --git a/mlt/src/framework/mlt_transition.h b/mlt/src/framework/mlt_transition.h deleted file mode 100644 index 1dad6c1..0000000 --- a/mlt/src/framework/mlt_transition.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * mlt_transition.h -- abstraction for all transition services - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_TRANSITION_H_ -#define _MLT_TRANSITION_H_ - -#include "mlt_service.h" - -/** The interface definition for all transitions. -*/ - -struct mlt_transition_s -{ - // We're implementing service here - struct mlt_service_s parent; - - // public virtual - void ( *close )( mlt_transition ); - - // protected transition method - mlt_frame ( *process )( mlt_transition, mlt_frame, mlt_frame ); - - // Protected - void *child; - - // track and in/out points - mlt_service producer; - - // Private - mlt_frame a_frame; - mlt_frame b_frame; - int a_held; - int b_held; -}; - -/** Public final methods -*/ - -extern int mlt_transition_init( mlt_transition this, void *child ); -extern mlt_service mlt_transition_service( mlt_transition this ); -extern mlt_properties mlt_transition_properties( mlt_transition this ); -extern int mlt_transition_connect( mlt_transition this, mlt_service producer, int a_track, int b_track ); -extern void mlt_transition_set_in_and_out( mlt_transition this, mlt_position in, mlt_position out ); -extern int mlt_transition_get_a_track( mlt_transition this ); -extern int mlt_transition_get_b_track( mlt_transition this ); -extern mlt_position mlt_transition_get_in( mlt_transition this ); -extern mlt_position mlt_transition_get_out( mlt_transition this ); -extern void mlt_transition_close( mlt_transition this ); - -#endif diff --git a/mlt/src/framework/mlt_types.h b/mlt/src/framework/mlt_types.h deleted file mode 100644 index 26bae3d..0000000 --- a/mlt/src/framework/mlt_types.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * mlt_types.h -- provides forward definitions of all public types - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MLT_TYPES_H_ -#define _MLT_TYPES_H_ - -#include - -typedef enum -{ - mlt_whence_relative_start, - mlt_whence_relative_current, - mlt_whence_relative_end -} -mlt_whence; - -typedef int64_t mlt_position; -typedef struct mlt_frame_s *mlt_frame, **mlt_frame_ptr; -typedef struct mlt_properties_s *mlt_properties; -typedef struct mlt_service_s *mlt_service; -typedef struct mlt_producer_s *mlt_producer; -typedef struct mlt_manager_s *mlt_manager; -typedef struct mlt_playlist_s *mlt_playlist; -typedef struct mlt_multitrack_s *mlt_multitrack; -typedef struct mlt_filter_s *mlt_filter; -typedef struct mlt_transition_s *mlt_transition; -typedef struct mlt_tractor_s *mlt_tractor; -typedef struct mlt_field_s *mlt_field; -typedef struct mlt_consumer_s *mlt_consumer; - -typedef void ( *mlt_destructor )( void * ); -typedef char *( *mlt_serialiser )( void *, int length ); - -#define MLT_SERVICE(x) ( ( mlt_service )( x ) ) -#define MLT_PRODUCER(x) ( ( mlt_producer )( x ) ) -#define MLT_MULTITRACK(x) ( ( mlt_multitrack )( x ) ) -#define MLT_PLAYLIST(x) ( ( mlt_playlist )( x ) ) -#define MLT_TRACTOR(x) ( ( mlt_tractor )( x ) ) -#define MLT_FILTER(x) ( ( mlt_filter )( x ) ) -#define MLT_TRANSITION(x) ( ( mlt_transition )( x ) ) - -#endif diff --git a/mlt/src/humperdink/Makefile b/mlt/src/humperdink/Makefile deleted file mode 100644 index 53f2f96..0000000 --- a/mlt/src/humperdink/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -TARGET = humperdink - -OBJS = client.o \ - io.o \ - remote.o - -CFLAGS = -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic - -LDFLAGS = -L ../valerie -lvalerie - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/humperdink/client.c b/mlt/src/humperdink/client.c deleted file mode 100644 index 0705c14..0000000 --- a/mlt/src/humperdink/client.c +++ /dev/null @@ -1,1026 +0,0 @@ -/* - * client.c -- dv1394d client demo - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include -#include - -/* Application header files */ -#include "client.h" -#include "io.h" - -/** Clip navigation enumeration. -*/ - -typedef enum -{ - absolute, - relative -} -dv_demo_whence; - -/** Function prototype for menu handling. -*/ - -typedef valerie_error_code (*demo_function)( dv_demo ); - -/** The menu structure. -*/ - -typedef struct -{ - char *description; - struct menu_item - { - char *option; - demo_function function; - } - array[ 50 ]; -} -*dv_demo_menu, dv_demo_menu_t; - -/** Forward reference to menu runner. -*/ - -extern valerie_error_code dv_demo_run_menu( dv_demo, dv_demo_menu ); - -/** Foward references. -*/ - -extern valerie_error_code dv_demo_list_nodes( dv_demo ); -extern valerie_error_code dv_demo_add_unit( dv_demo ); -extern valerie_error_code dv_demo_select_unit( dv_demo ); -extern valerie_error_code dv_demo_execute( dv_demo ); -extern valerie_error_code dv_demo_load( dv_demo ); -extern valerie_error_code dv_demo_transport( dv_demo ); -static void *dv_demo_status_thread( void * ); - -/** Connected menu definition. -*/ - -dv_demo_menu_t connected_menu = -{ - "Connected Menu", - { - { "Add Unit", dv_demo_add_unit }, - { "Select Unit", dv_demo_select_unit }, - { "Command Shell", dv_demo_execute }, - { NULL, NULL } - } -}; - -/** Initialise the demo structure. -*/ - -dv_demo dv_demo_init( valerie_parser parser ) -{ - dv_demo this = malloc( sizeof( dv_demo_t ) ); - if ( this != NULL ) - { - int index = 0; - memset( this, 0, sizeof( dv_demo_t ) ); - strcpy( this->last_directory, "/" ); - for ( index = 0; index < 4; index ++ ) - { - this->queues[ index ].unit = index; - this->queues[ index ].position = -1; - } - this->parser = parser; - } - return this; -} - -/** Display a status record. -*/ - -void dv_demo_show_status( dv_demo demo, valerie_status status ) -{ - if ( status->unit == demo->selected_unit && demo->showing ) - { - char temp[ 1024 ] = ""; - - sprintf( temp, "U%d ", demo->selected_unit ); - - switch( status->status ) - { - case unit_offline: - strcat( temp, "offline " ); - break; - case unit_undefined: - strcat( temp, "undefined " ); - break; - case unit_not_loaded: - strcat( temp, "unloaded " ); - break; - case unit_stopped: - strcat( temp, "stopped " ); - break; - case unit_playing: - strcat( temp, "playing " ); - break; - case unit_paused: - strcat( temp, "paused " ); - break; - case unit_disconnected: - strcat( temp, "disconnect" ); - break; - default: - strcat( temp, "unknown " ); - break; - } - - sprintf( temp + strlen( temp ), " %9lld %9lld %9lld ", status->in, status->position, status->out ); - strcat( temp, status->clip ); - - printf( "%-80.80s\r", temp ); - fflush( stdout ); - } -} - -/** Determine action to carry out as dictated by the client unit queue. -*/ - -void dv_demo_queue_action( dv_demo demo, valerie_status status ) -{ - dv_demo_queue queue = &demo->queues[ status->unit ]; - - /* SPECIAL CASE STATUS NOTIFICATIONS TO IGNORE */ - - /* When we've issued a LOAD on the previous notification, then ignore this one. */ - if ( queue->ignore ) - { - queue->ignore --; - return; - } - - if ( queue->mode && status->status != unit_offline && queue->head != queue->tail ) - { - if ( ( status->position >= status->out && status->speed > 0 ) || status->status == unit_not_loaded ) - { - queue->position = ( queue->position + 1 ) % 50; - if ( queue->position == queue->tail ) - queue->position = queue->head; - valerie_unit_load( demo->dv_status, status->unit, queue->list[ queue->position ] ); - if ( status->status == unit_not_loaded ) - valerie_unit_play( demo->dv, queue->unit ); - queue->ignore = 1; - } - else if ( ( status->position <= status->in && status->speed < 0 ) || status->status == unit_not_loaded ) - { - if ( queue->position == -1 ) - queue->position = queue->head; - valerie_unit_load( demo->dv_status, status->unit, queue->list[ queue->position ] ); - if ( status->status == unit_not_loaded ) - valerie_unit_play( demo->dv, queue->unit ); - queue->position = ( queue->position - 1 ) % 50; - queue->ignore = 1; - } - } -} - -/** Status thread. -*/ - -static void *dv_demo_status_thread( void *arg ) -{ - dv_demo demo = arg; - valerie_status_t status; - valerie_notifier notifier = valerie_get_notifier( demo->dv_status ); - - while ( !demo->terminated ) - { - if ( valerie_notifier_wait( notifier, &status ) != -1 ) - { - dv_demo_queue_action( demo, &status ); - dv_demo_show_status( demo, &status ); - if ( status.status == unit_disconnected ) - demo->disconnected = 1; - } - } - - return NULL; -} - -/** Turn on/off status display. -*/ - -void dv_demo_change_status( dv_demo demo, int flag ) -{ - if ( demo->disconnected && flag ) - { - valerie_error_code error = valerie_connect( demo->dv ); - if ( error == valerie_ok ) - demo->disconnected = 0; - else - beep(); - } - - if ( flag ) - { - valerie_status_t status; - valerie_notifier notifier = valerie_get_notifier( demo->dv ); - valerie_notifier_get( notifier, &status, demo->selected_unit ); - demo->showing = 1; - dv_demo_show_status( demo, &status ); - } - else - { - demo->showing = 0; - printf( "%-80.80s\r", " " ); - fflush( stdout ); - } -} - -/** Add a unit. -*/ - -valerie_error_code dv_demo_add_unit( dv_demo demo ) -{ - valerie_error_code error = valerie_ok; - valerie_nodes nodes = valerie_nodes_init( demo->dv ); - valerie_units units = valerie_units_init( demo->dv ); - - if ( valerie_nodes_count( nodes ) != -1 && valerie_units_count( units ) != -1 ) - { - char pressed; - valerie_node_entry_t node; - valerie_unit_entry_t unit; - int node_index = 0; - int unit_index = 0; - - printf( "Select a Node\n\n" ); - - for ( node_index = 0; node_index < valerie_nodes_count( nodes ); node_index ++ ) - { - valerie_nodes_get( nodes, node_index, &node ); - printf( "%d: %s - %s ", node_index + 1, node.guid, node.name ); - for ( unit_index = 0; unit_index < valerie_units_count( units ); unit_index ++ ) - { - valerie_units_get( units, unit_index, &unit ); - if ( !strcmp( unit.guid, node.guid ) ) - printf( "[U%d] ", unit.unit ); - } - printf( "\n" ); - } - - printf( "0. Exit\n\n" ); - - printf( "Node: " ); - - while ( ( pressed = get_keypress( ) ) != '0' ) - { - node_index = pressed - '1'; - if ( node_index >= 0 && node_index < valerie_nodes_count( nodes ) ) - { - int unit; - printf( "%c\n\n", pressed ); - valerie_nodes_get( nodes, node_index, &node ); - if ( valerie_unit_add( demo->dv, node.guid, &unit ) == valerie_ok ) - { - printf( "Unit added as U%d\n", unit ); - demo->selected_unit = unit; - } - else - { - int index = 0; - valerie_response response = valerie_get_last_response( demo->dv ); - printf( "Failed to add unit:\n\n" ); - for( index = 1; index < valerie_response_count( response ) - 1; index ++ ) - printf( "%s\n", valerie_response_get_line( response, index ) ); - } - printf( "\n" ); - wait_for_any_key( NULL ); - break; - } - else - { - beep( ); - } - } - } - else - { - printf( "Invalid response from the server.\n\n" ); - wait_for_any_key( NULL ); - } - - valerie_nodes_close( nodes ); - valerie_units_close( units ); - - return error; -} - -/** Select a unit. -*/ - -valerie_error_code dv_demo_select_unit( dv_demo demo ) -{ - int terminated = 0; - int refresh = 1; - - while ( !terminated ) - { - valerie_units units = valerie_units_init( demo->dv ); - - if ( valerie_units_count( units ) > 0 ) - { - valerie_unit_entry_t unit; - int index = 0; - char key = '\0'; - - if ( refresh ) - { - printf( "Select a Unit\n\n" ); - - for ( index = 0; index < valerie_units_count( units ); index ++ ) - { - valerie_units_get( units, index, &unit ); - printf( "%d: U%d - %s [%s]\n", index + 1, - unit.unit, - unit.guid, - unit.online ? "online" : "offline" ); - } - printf( "0: Exit\n\n" ); - - printf( "Unit [%d]: ", demo->selected_unit + 1 ); - refresh = 0; - } - - key = get_keypress( ); - - if ( key == '\r' ) - key = demo->selected_unit + '1'; - - if ( key != '0' ) - { - if ( key >= '1' && key < '1' + valerie_units_count( units ) ) - { - demo->selected_unit = key - '1'; - printf( "%c\n\n", key ); - dv_demo_load( demo ); - refresh = 1; - } - else - { - beep( ); - } - } - else - { - printf( "0\n\n" ); - terminated = 1; - } - } - else if ( valerie_units_count( units ) == 0 ) - { - printf( "No units added - add a unit first\n\n" ); - dv_demo_add_unit( demo ); - } - else - { - printf( "Unable to obtain Unit List.\n" ); - terminated = 1; - } - - valerie_units_close( units ); - } - - return valerie_ok; -} - -/** Execute an arbitrary command. -*/ - -valerie_error_code dv_demo_execute( dv_demo demo ) -{ - valerie_error_code error = valerie_ok; - char command[ 10240 ]; - int terminated = 0; - - printf( "DV1394D Shell\n" ); - printf( "Enter an empty command to exit.\n\n" ); - - while ( !terminated ) - { - terminated = 1; - printf( "Command> " ); - - if ( chomp( get_string( command, 10240, "" ) ) != NULL ) - { - if ( strcmp( command, "" ) ) - { - int index = 0; - valerie_response response = NULL; - error = valerie_execute( demo->dv, 10240, command ); - printf( "\n" ); - response = valerie_get_last_response( demo->dv ); - for ( index = 0; index < valerie_response_count( response ); index ++ ) - { - char *line = valerie_response_get_line( response, index ); - printf( "%4d: %s\n", index, line ); - } - printf( "\n" ); - terminated = 0; - } - } - } - - printf( "\n" ); - - return error; -} - -/** Add a file to the queue. -*/ - -valerie_error_code dv_demo_queue_add( dv_demo demo, dv_demo_queue queue, char *file ) -{ - valerie_status_t status; - valerie_notifier notifier = valerie_get_notifier( demo->dv ); - - if ( ( queue->tail + 1 ) % 50 == queue->head ) - queue->head = ( queue->head + 1 ) % 50; - strcpy( queue->list[ queue->tail ], file ); - queue->tail = ( queue->tail + 1 ) % 50; - - valerie_notifier_get( notifier, &status, queue->unit ); - valerie_notifier_put( notifier, &status ); - - return valerie_ok; -} - -/** Basic queue maintenance and status reports. -*/ - -valerie_error_code dv_demo_queue_maintenance( dv_demo demo, dv_demo_queue queue ) -{ - printf( "Queue Maintenance for Unit %d\n\n", queue->unit ); - - if ( !queue->mode ) - { - char ch; - printf( "Activate queueing? [Y] " ); - ch = get_keypress( ); - if ( ch == 'y' || ch == 'Y' || ch == '\r' ) - queue->mode = 1; - printf( "\n\n" ); - } - - if ( queue->mode ) - { - int terminated = 0; - int last_position = -2; - - term_init( ); - - while ( !terminated ) - { - int first = ( queue->position + 1 ) % 50; - int index = first; - - if ( first == queue->tail ) - index = first = queue->head; - - if ( queue->head == queue->tail ) - { - if ( last_position == -2 ) - { - printf( "Queue is empty\n" ); - printf( "\n" ); - printf( "0 = exit, t = turn off queueing\n\n" ); - last_position = -1; - } - } - else if ( last_position != queue->position ) - { - printf( "Order of play\n\n" ); - - do - { - printf( "%c%02d: %s\n", index == first ? '*' : ' ', index, queue->list[ index ] + 1 ); - index = ( index + 1 ) % 50; - if ( index == queue->tail ) - index = queue->head; - } - while( index != first ); - - printf( "\n" ); - printf( "0 = exit, t = turn off queueing, c = clear queue\n\n" ); - last_position = queue->position; - } - - dv_demo_change_status( demo, 1 ); - - switch( term_read( ) ) - { - case -1: - break; - case '0': - terminated = 1; - break; - case 't': - terminated = 1; - queue->mode = 0; - break; - case 'c': - queue->head = queue->tail = 0; - queue->position = -1; - last_position = -2; - break; - } - - dv_demo_change_status( demo, 0 ); - } - - term_exit( ); - } - - return valerie_ok; -} - -/** Load a file to the selected unit. Horrible function - sorry :-/. Not a good - demo.... -*/ - -valerie_error_code dv_demo_load( dv_demo demo ) -{ - valerie_error_code error = valerie_ok; - int terminated = 0; - int refresh = 1; - int start = 0; - - strcpy( demo->current_directory, demo->last_directory ); - - term_init( ); - - while ( !terminated ) - { - valerie_dir dir = valerie_dir_init( demo->dv, demo->current_directory ); - - if ( valerie_dir_count( dir ) == -1 ) - { - printf( "Invalid directory - retrying %s\n", demo->last_directory ); - valerie_dir_close( dir ); - dir = valerie_dir_init( demo->dv, demo->last_directory ); - if ( valerie_dir_count( dir ) == -1 ) - { - printf( "Invalid directory - going back to /\n" ); - valerie_dir_close( dir ); - dir = valerie_dir_init( demo->dv, "/" ); - strcpy( demo->current_directory, "/" ); - } - else - { - strcpy( demo->current_directory, demo->last_directory ); - } - } - - terminated = valerie_dir_count( dir ) == -1; - - if ( !terminated ) - { - int index = 0; - int selected = 0; - int max = 9; - int end = 0; - - end = valerie_dir_count( dir ); - - strcpy( demo->last_directory, demo->current_directory ); - - while ( !selected && !terminated ) - { - valerie_dir_entry_t entry; - int pressed; - - if ( refresh ) - { - char *action = "Load & Play"; - if ( demo->queues[ demo->selected_unit ].mode ) - action = "Queue"; - printf( "%s from %s\n\n", action, demo->current_directory ); - if ( strcmp( demo->current_directory, "/" ) ) - printf( "-: Parent directory\n" ); - for ( index = start; index < end && ( index - start ) < max; index ++ ) - { - valerie_dir_get( dir, index, &entry ); - printf( "%d: %s\n", index - start + 1, entry.name ); - } - while ( ( index ++ % 9 ) != 0 ) - printf( "\n" ); - printf( "\n" ); - if ( start + max < end ) - printf( "space = more files" ); - else if ( end > max ) - printf( "space = return to start of list" ); - if ( start > 0 ) - printf( ", b = previous files" ); - printf( "\n" ); - printf( "0 = abort, t = transport, x = execute command, q = queue maintenance\n\n" ); - refresh = 0; - } - - dv_demo_change_status( demo, 1 ); - - pressed = term_read( ); - switch( pressed ) - { - case -1: - break; - case '0': - terminated = 1; - break; - case 'b': - refresh = start - max >= 0; - if ( refresh ) - start = start - max; - break; - case ' ': - refresh = start + max < end; - if ( refresh ) - { - start = start + max; - } - else if ( end > max ) - { - start = 0; - refresh = 1; - } - break; - case '-': - if ( strcmp( demo->current_directory, "/" ) ) - { - selected = 1; - ( *strrchr( demo->current_directory, '/' ) ) = '\0'; - ( *( strrchr( demo->current_directory, '/' ) + 1 ) ) = '\0'; - } - break; - case 't': - dv_demo_change_status( demo, 0 ); - term_exit( ); - dv_demo_transport( demo ); - term_init( ); - selected = 1; - break; - case 'x': - dv_demo_change_status( demo, 0 ); - term_exit( ); - dv_demo_execute( demo ); - term_init( ); - selected = 1; - break; - case 'q': - dv_demo_change_status( demo, 0 ); - term_exit( ); - dv_demo_queue_maintenance( demo, &demo->queues[ demo->selected_unit ] ); - term_init( ); - selected = 1; - break; - default: - if ( pressed >= '1' && pressed <= '9' ) - { - if ( ( start + pressed - '1' ) < end ) - { - valerie_dir_get( dir, start + pressed - '1', &entry ); - selected = 1; - strcat( demo->current_directory, entry.name ); - } - } - break; - } - - dv_demo_change_status( demo, 0 ); - } - - valerie_dir_close( dir ); - } - - if ( !terminated && demo->current_directory[ strlen( demo->current_directory ) - 1 ] != '/' ) - { - if ( demo->queues[ demo->selected_unit ].mode == 0 ) - { - error = valerie_unit_load( demo->dv, demo->selected_unit, demo->current_directory ); - valerie_unit_play( demo->dv, demo->selected_unit ); - } - else - { - dv_demo_queue_add( demo, &demo->queues[ demo->selected_unit ], demo->current_directory ); - printf( "File %s added to queue.\n", demo->current_directory ); - } - strcpy( demo->current_directory, demo->last_directory ); - refresh = 0; - } - else - { - refresh = 1; - start = 0; - } - } - - term_exit( ); - - return error; -} - -/** Set the in point of the clip on the select unit. -*/ - -valerie_error_code dv_demo_set_in( dv_demo demo ) -{ - int position = 0; - valerie_status_t status; - valerie_notifier notifier = valerie_parser_get_notifier( demo->parser ); - valerie_notifier_get( notifier, &status, demo->selected_unit ); - position = status.position; - return valerie_unit_set_in( demo->dv, demo->selected_unit, position ); -} - -/** Set the out point of the clip on the selected unit. -*/ - -valerie_error_code dv_demo_set_out( dv_demo demo ) -{ - int position = 0; - valerie_status_t status; - valerie_notifier notifier = valerie_parser_get_notifier( demo->parser ); - valerie_notifier_get( notifier, &status, demo->selected_unit ); - position = status.position; - return valerie_unit_set_out( demo->dv, demo->selected_unit, position ); -} - -/** Clear the in and out points on the selected unit. -*/ - -valerie_error_code dv_demo_clear_in_out( dv_demo demo ) -{ - return valerie_unit_clear_in_out( demo->dv, demo->selected_unit ); -} - -/** Goto a user specified frame on the selected unit. -*/ - -valerie_error_code dv_demo_goto( dv_demo demo ) -{ - int frame = 0; - printf( "Frame: " ); - if ( get_int( &frame, 0 ) ) - return valerie_unit_goto( demo->dv, demo->selected_unit, frame ); - return valerie_ok; -} - -/** Manipulate playback on the selected unit. -*/ - -valerie_error_code dv_demo_transport( dv_demo demo ) -{ - valerie_error_code error = valerie_ok; - int refresh = 1; - int terminated = 0; - valerie_status_t status; - valerie_notifier notifier = valerie_get_notifier( demo->dv ); - - while ( !terminated ) - { - if ( refresh ) - { - printf( " +----+ +------+ +----+ +------+ +---+ +-----+ +------+ +-----+ +---+ \n" ); - printf( " |1=-5| |2=-2.5| |3=-1| |4=-0.5| |5=1| |6=0.5| |7=1.25| |8=2.5| |9=5| \n" ); - printf( " +----+ +------+ +----+ +------+ +---+ +-----+ +------+ +-----+ +---+ \n" ); - printf( "\n" ); - printf( "+----------------------------------------------------------------------+\n" ); - printf( "| 0 = quit, x = eXecute, 'space' = pause |\n" ); - printf( "| g = goto a frame, q = queue maintenance |\n" ); - printf( "| h = step -1, j = end of clip, k = start of clip, l = step 1 |\n" ); - printf( "| eof handling: p = pause, r = repeat, t = terminate |\n" ); - printf( "| i = set in point, o = set out point, c = clear in/out |\n" ); - printf( "| u = use point settings, d = don't use point settings |\n" ); - printf( "+----------------------------------------------------------------------+\n" ); - printf( "\n" ); - term_init( ); - refresh = 0; - } - - dv_demo_change_status( demo, 1 ); - - switch( term_read( ) ) - { - case '0': - terminated = 1; - break; - case -1: - break; - case ' ': - error = valerie_unit_pause( demo->dv, demo->selected_unit ); - break; - case '1': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, -5000 ); - break; - case '2': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, -2500 ); - break; - case '3': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, -1000 ); - break; - case '4': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, -500 ); - break; - case '5': - error = valerie_unit_play( demo->dv, demo->selected_unit ); - break; - case '6': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, 500 ); - break; - case '7': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, 1250 ); - break; - case '8': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, 2500 ); - break; - case '9': - error = valerie_unit_play_at_speed( demo->dv, demo->selected_unit, 5000 ); - break; - case 's': - error = valerie_unit_goto( demo->dv, demo->selected_unit, 0 ); - break; - case 'h': - error = valerie_unit_step( demo->dv, demo->selected_unit, -1 ); - break; - case 'j': - valerie_notifier_get( notifier, &status, demo->selected_unit ); - error = valerie_unit_goto( demo->dv, demo->selected_unit, status.tail_out ); - break; - case 'k': - valerie_notifier_get( notifier, &status, demo->selected_unit ); - error = valerie_unit_goto( demo->dv, demo->selected_unit, status.in ); - break; - case 'l': - error = valerie_unit_step( demo->dv, demo->selected_unit, 1 ); - break; - case 'p': - error = valerie_unit_set( demo->dv, demo->selected_unit, "eof", "pause" ); - break; - case 'r': - error = valerie_unit_set( demo->dv, demo->selected_unit, "eof", "loop" ); - break; - case 't': - error = valerie_unit_set( demo->dv, demo->selected_unit, "eof", "stop" ); - break; - case 'i': - error = dv_demo_set_in( demo ); - break; - case 'o': - error = dv_demo_set_out( demo ); - break; - case 'g': - dv_demo_change_status( demo, 0 ); - term_exit( ); - error = dv_demo_goto( demo ); - refresh = 1; - break; - case 'c': - error = dv_demo_clear_in_out( demo ); - break; - case 'u': - error = valerie_unit_set( demo->dv, demo->selected_unit, "points", "use" ); - break; - case 'd': - error = valerie_unit_set( demo->dv, demo->selected_unit, "points", "ignore" ); - break; - case 'x': - dv_demo_change_status( demo, 0 ); - term_exit( ); - dv_demo_execute( demo ); - refresh = 1; - break; - case 'q': - dv_demo_change_status( demo, 0 ); - term_exit( ); - dv_demo_queue_maintenance( demo, &demo->queues[ demo->selected_unit ] ); - refresh = 1; - break; - } - - dv_demo_change_status( demo, 0 ); - } - - term_exit( ); - - return error; -} - -/** Recursive menu execution. -*/ - -valerie_error_code dv_demo_run_menu( dv_demo demo, dv_demo_menu menu ) -{ - char *items = "123456789abcdefghijklmnopqrstuvwxyz"; - int refresh_menu = 1; - int terminated = 0; - int item_count = 0; - int item_selected = 0; - int index = 0; - char key; - - while( !terminated ) - { - - if ( refresh_menu ) - { - printf( "%s\n\n", menu->description ); - for ( index = 0; menu->array[ index ].option != NULL; index ++ ) - printf( "%c: %s\n", items[ index ], menu->array[ index ].option ); - printf( "0: Exit\n\n" ); - printf( "Select Option: " ); - refresh_menu = 0; - item_count = index; - } - - key = get_keypress( ); - - if ( demo->disconnected && key != '0' ) - { - valerie_error_code error = valerie_connect( demo->dv ); - if ( error == valerie_ok ) - demo->disconnected = 0; - else - beep(); - } - - if ( !demo->disconnected || key == '0' ) - { - item_selected = strchr( items, key ) - items; - - if ( key == '0' ) - { - printf( "%c\n\n", key ); - terminated = 1; - } - else if ( item_selected >= 0 && item_selected < item_count ) - { - printf( "%c\n\n", key ); - menu->array[ item_selected ].function( demo ); - refresh_menu = 1; - } - else - { - beep( ); - } - } - } - - return valerie_ok; -} - -/** Entry point for main menu. -*/ - -void dv_demo_run( dv_demo this ) -{ - this->dv = valerie_init( this->parser ); - this->dv_status = valerie_init( this->parser ); - if ( valerie_connect( this->dv ) == valerie_ok ) - { - pthread_create( &this->thread, NULL, dv_demo_status_thread, this ); - dv_demo_run_menu( this, &connected_menu ); - this->terminated = 1; - pthread_join( this->thread, NULL ); - this->terminated = 0; - } - else - { - printf( "Unable to connect." ); - wait_for_any_key( "" ); - } - - valerie_close( this->dv_status ); - valerie_close( this->dv ); - - printf( "Demo Exit.\n" ); -} - -/** Close the demo structure. -*/ - -void dv_demo_close( dv_demo demo ) -{ - free( demo ); -} - diff --git a/mlt/src/humperdink/client.h b/mlt/src/humperdink/client.h deleted file mode 100644 index 9490360..0000000 --- a/mlt/src/humperdink/client.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * client.h -- dv1394d client demo - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DEMO_CLIENT_H_ -#define _DEMO_CLIENT_H_ - -#include -#include -#include - -/** Queue for unit playback -*/ - -typedef struct -{ - int mode; - int unit; - int position; - int head; - int tail; - char list[ 50 ][ PATH_MAX + NAME_MAX ]; - int ignore; -} -*dv_demo_queue, dv_demo_queue_t; - -/** Structure for storing app state. -*/ - -typedef struct -{ - int disconnected; - valerie_parser parser; - valerie dv; - valerie dv_status; - int selected_unit; - char current_directory[ 512 ]; - char last_directory[ 512 ]; - int showing; - int terminated; - pthread_t thread; - dv_demo_queue_t queues[ MAX_UNITS ]; -} -*dv_demo, dv_demo_t; - -extern dv_demo dv_demo_init( valerie_parser ); -extern void dv_demo_run( dv_demo ); -extern void dv_demo_close( dv_demo ); - -#endif diff --git a/mlt/src/humperdink/io.c b/mlt/src/humperdink/io.c deleted file mode 100644 index b9e92f2..0000000 --- a/mlt/src/humperdink/io.c +++ /dev/null @@ -1,204 +0,0 @@ -/* - * io.c -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include -#include -#include -#include -#include - -/* Application header files */ -#include "io.h" - -char *chomp( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - if ( length && input[ length - 1 ] == '\n' ) - input[ length - 1 ] = '\0'; - if ( length > 1 && input[ length - 2 ] == '\r' ) - input[ length - 2 ] = '\0'; - } - return input; -} - -char *trim( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - int first = 0; - while( first < length && isspace( input[ first ] ) ) - first ++; - memmove( input, input + first, length - first + 1 ); - length = length - first; - while ( length > 0 && isspace( input[ length - 1 ] ) ) - input[ -- length ] = '\0'; - } - return input; -} - -char *strip_quotes( char *input ) -{ - if ( input != NULL ) - { - char *ptr = strrchr( input, '\"' ); - if ( ptr != NULL ) - *ptr = '\0'; - if ( input[ 0 ] == '\"' ) - strcpy( input, input + 1 ); - } - return input; -} - -char *get_string( char *output, int maxlength, char *use ) -{ - char *value = NULL; - strcpy( output, use ); - if ( trim( chomp( fgets( output, maxlength, stdin ) ) ) != NULL ) - { - if ( !strcmp( output, "" ) ) - strcpy( output, use ); - value = output; - } - return value; -} - -int *get_int( int *output, int use ) -{ - int *value = NULL; - char temp[ 132 ]; - *output = use; - if ( trim( chomp( fgets( temp, 132, stdin ) ) ) != NULL ) - { - if ( strcmp( temp, "" ) ) - *output = atoi( temp ); - value = output; - } - return value; -} - -/** This stores the previous settings -*/ - -static struct termios oldtty; -static int mode = 0; - -/** This is called automatically on application exit to restore the - previous tty settings. -*/ - -void term_exit(void) -{ - if ( mode == 1 ) - { - tcsetattr( 0, TCSANOW, &oldtty ); - mode = 0; - } -} - -/** Init terminal so that we can grab keys without blocking. -*/ - -void term_init( ) -{ - struct termios tty; - - tcgetattr( 0, &tty ); - oldtty = tty; - - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - tty.c_oflag |= OPOST; - tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); - tty.c_cflag &= ~(CSIZE|PARENB); - tty.c_cflag |= CS8; - tty.c_cc[ VMIN ] = 1; - tty.c_cc[ VTIME ] = 0; - - tcsetattr( 0, TCSANOW, &tty ); - - mode = 1; - - atexit( term_exit ); -} - -/** Check for a keypress without blocking infinitely. - Returns: ASCII value of keypress or -1 if no keypress detected. -*/ - -int term_read( ) -{ - int n = 1; - unsigned char ch; - struct timeval tv; - fd_set rfds; - - FD_ZERO( &rfds ); - FD_SET( 0, &rfds ); - tv.tv_sec = 1; - tv.tv_usec = 0; - n = select( 1, &rfds, NULL, NULL, &tv ); - if (n > 0) - { - n = read( 0, &ch, 1 ); - tcflush( 0, TCIFLUSH ); - if (n == 1) - return ch; - return n; - } - return -1; -} - -char get_keypress( ) -{ - char value = '\0'; - int pressed = 0; - - fflush( stdout ); - - term_init( ); - while ( ( pressed = term_read( ) ) == -1 ) ; - term_exit( ); - - value = (char)pressed; - - return value; -} - -void wait_for_any_key( char *message ) -{ - if ( message == NULL ) - printf( "Press any key to continue: " ); - else - printf( "%s", message ); - - get_keypress( ); - - printf( "\n\n" ); -} - -void beep( ) -{ - printf( "%c", 7 ); - fflush( stdout ); -} diff --git a/mlt/src/humperdink/io.h b/mlt/src/humperdink/io.h deleted file mode 100644 index 6c4b609..0000000 --- a/mlt/src/humperdink/io.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * io.h -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DEMO_IO_H_ -#define _DEMO_IO_H_ - -extern char *chomp( char * ); -extern char *trim( char * ); -extern char *strip_quotes( char * ); -extern char *get_string( char *, int, char * ); -extern int *get_int( int *, int ); -extern void term_init( ); -extern int term_read( ); -extern void term_exit( ); -extern char get_keypress( ); -extern void wait_for_any_key( char * ); -extern void beep( ); - -#endif diff --git a/mlt/src/humperdink/remote.c b/mlt/src/humperdink/remote.c deleted file mode 100644 index 9306b21..0000000 --- a/mlt/src/humperdink/remote.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * remote.c -- Remote dv1394d client demo - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include - -/* dv1394d header files */ -#include - -/* Application header files */ -#include "client.h" -#include "io.h" - -/** Connect to a remote server. -*/ - -static valerie_parser create_parser( ) -{ - char server[ 132 ]; - int port; - valerie_parser parser = NULL; - - printf( "Connecting to a Server\n\n" ); - - printf( "Server [localhost]: " ); - - if ( get_string( server, sizeof( server ), "localhost" ) != NULL ) - { - printf( "Port [5250]: " ); - - if ( get_int( &port, 5250 ) != NULL ) - parser = valerie_parser_init_remote( server, port ); - } - - printf( "\n" ); - - return parser; -} - -/** Main function. -*/ - -int main( int argc, char **argv ) -{ - valerie_parser parser = create_parser( ); - - if ( parser != NULL ) - { - dv_demo demo = dv_demo_init( parser ); - dv_demo_run( demo ); - dv_demo_close( demo ); - valerie_parser_close( parser ); - } - - return 0; -} diff --git a/mlt/src/inigo/Makefile b/mlt/src/inigo/Makefile deleted file mode 100644 index 78e7cfa..0000000 --- a/mlt/src/inigo/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TARGET = inigo - -OBJS = inigo.o \ - io.o - -CFLAGS = -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic - -LDFLAGS = -L ../framework -lmlt - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/inigo/configure b/mlt/src/inigo/configure deleted file mode 100755 index e69de29..0000000 diff --git a/mlt/src/inigo/inigo.c b/mlt/src/inigo/inigo.c deleted file mode 100644 index cfef4fd..0000000 --- a/mlt/src/inigo/inigo.c +++ /dev/null @@ -1,282 +0,0 @@ -#include -#include -#include - -#include - -#include "io.h" - -static void transport_action( mlt_producer producer, char *value ) -{ - mlt_properties properties = mlt_producer_properties( producer ); - mlt_multitrack multitrack = mlt_properties_get_data( properties, "multitrack", NULL ); - - if ( strlen( value ) == 1 ) - { - switch( value[ 0 ] ) - { - case 'q': - mlt_properties_set_int( properties, "done", 1 ); - break; - case '0': - mlt_producer_set_speed( producer, 1 ); - mlt_producer_seek( producer, 0 ); - break; - case '1': - mlt_producer_set_speed( producer, -10 ); - break; - case '2': - mlt_producer_set_speed( producer, -5 ); - break; - case '3': - mlt_producer_set_speed( producer, -2 ); - break; - case '4': - mlt_producer_set_speed( producer, -1 ); - break; - case '5': - mlt_producer_set_speed( producer, 0 ); - break; - case '6': - case ' ': - mlt_producer_set_speed( producer, 1 ); - break; - case '7': - mlt_producer_set_speed( producer, 2 ); - break; - case '8': - mlt_producer_set_speed( producer, 5 ); - break; - case '9': - mlt_producer_set_speed( producer, 10 ); - break; - case 'd': - if ( multitrack != NULL ) - { - int i = 0; - mlt_position last = -1; - for ( i = 0; 1; i ++ ) - { - mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_start, i ); - if ( time == last ) - break; - last = time; - fprintf( stderr, "%d: %lld\n", i, time ); - } - fprintf( stderr, "Current Position: %lld\n", mlt_producer_position( producer ) ); - } - break; - - case 'g': - if ( multitrack != NULL ) - { - mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 0 ); - mlt_producer_seek( producer, time ); - } - break; - case 'H': - if ( producer != NULL ) - { - mlt_position position = mlt_producer_position( producer ); - mlt_producer_seek( producer, position - ( mlt_producer_get_fps( producer ) * 60 ) ); - } - break; - case 'h': - if ( producer != NULL ) - { - mlt_position position = mlt_producer_position( producer ); - mlt_producer_set_speed( producer, 0 ); - mlt_producer_seek( producer, position - 1 ); - } - break; - case 'j': - if ( multitrack != NULL ) - { - mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, 1 ); - mlt_producer_seek( producer, time ); - } - break; - case 'k': - if ( multitrack != NULL ) - { - mlt_position time = mlt_multitrack_clip( multitrack, mlt_whence_relative_current, -1 ); - mlt_producer_seek( producer, time ); - } - break; - case 'l': - if ( producer != NULL ) - { - mlt_position position = mlt_producer_position( producer ); - mlt_producer_set_speed( producer, 0 ); - mlt_producer_seek( producer, position + 1 ); - } - break; - case 'L': - if ( producer != NULL ) - { - mlt_position position = mlt_producer_position( producer ); - mlt_producer_seek( producer, position + ( mlt_producer_get_fps( producer ) * 60 ) ); - } - break; - } - } -} - -static mlt_consumer create_consumer( char *id, mlt_producer producer ) -{ - char *arg = strchr( id, ':' ); - if ( arg != NULL ) - *arg ++ = '\0'; - mlt_consumer consumer = mlt_factory_consumer( id, arg ); - if ( consumer != NULL ) - { - mlt_properties properties = mlt_consumer_properties( consumer ); - mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL ); - mlt_properties_set_data( properties, "transport_producer", producer, 0, NULL, NULL ); - } - return consumer; -} - -static void transport( mlt_producer producer ) -{ - mlt_properties properties = mlt_producer_properties( producer ); - - term_init( ); - - fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); - fprintf( stderr, "|1=-10| |2= -5| |3= -2| |4= -1| |5= 0| |6= 1| |7= 2| |8= 5| |9= 10|\n" ); - fprintf( stderr, "+-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ +-----+\n" ); - - fprintf( stderr, "+---------------------------------------------------------------------+\n" ); - fprintf( stderr, "| H = back 1 minute, L = forward 1 minute |\n" ); - fprintf( stderr, "| h = previous frame, l = next frame |\n" ); - fprintf( stderr, "| g = start of clip, j = next clip, k = previous clip |\n" ); - fprintf( stderr, "| 0 = restart, q = quit, space = play |\n" ); - fprintf( stderr, "+---------------------------------------------------------------------+\n" ); - - while( mlt_properties_get_int( properties, "done" ) == 0 ) - { - int value = term_read( ); - if ( value != -1 ) - transport_action( producer, ( char * )&value ); - } -} - -int main( int argc, char **argv ) -{ - int i; - mlt_consumer consumer = NULL; - mlt_producer inigo = NULL; - FILE *store = NULL; - char *name = NULL; - - // Construct the factory - mlt_factory_init( getenv( "MLT_REPOSITORY" ) ); - - for ( i = 1; i < argc; i ++ ) - { - if ( !strcmp( argv[ i ], "-serialise" ) ) - { - name = argv[ ++ i ]; - if ( strstr( name, ".inigo" ) ) - store = fopen( name, "w" ); - } - } - - // Get inigo producer - inigo = mlt_factory_producer( "inigo", &argv[ 1 ] ); - - if ( argc > 1 && inigo != NULL && mlt_producer_get_length( inigo ) > 0 ) - { - // Get inigo's properties - mlt_properties inigo_props = mlt_producer_properties( inigo ); - - // Get the field service from inigo - mlt_field field = mlt_properties_get_data( inigo_props, "field", 0 ); - - // Get the last group - mlt_properties group = mlt_properties_get_data( inigo_props, "group", 0 ); - - // Parse the arguments - for ( i = 1; i < argc; i ++ ) - { - if ( !strcmp( argv[ i ], "-consumer" ) ) - { - consumer = create_consumer( argv[ ++ i ], inigo ); - while ( argv[ i + 1 ] != NULL && strstr( argv[ i + 1 ], "=" ) ) - mlt_properties_parse( group, argv[ ++ i ] ); - } - else if ( !strcmp( argv[ i ], "-serialise" ) ) - { - i ++; - } - else - { - if ( store != NULL ) - fprintf( store, "%s\n", argv[ i ] ); - - i ++; - - while ( argv[ i ] != NULL && argv[ i ][ 0 ] != '-' ) - { - if ( store != NULL ) - fprintf( store, "%s\n", argv[ i ] ); - i += 1; - } - - i --; - } - } - - // If we have no consumer, default to sdl - if ( store == NULL && consumer == NULL ) - consumer = create_consumer( "sdl", inigo ); - - if ( consumer != NULL && store == NULL ) - { - // Apply group settings - mlt_properties properties = mlt_consumer_properties( consumer ); - mlt_properties_inherit( properties, group ); - - // Connect consumer to tractor - mlt_consumer_connect( consumer, mlt_field_service( field ) ); - - // Start the consumer - mlt_consumer_start( consumer ); - - // Transport functionality - transport( inigo ); - - // Stop the consumer - mlt_consumer_stop( consumer ); - } - else if ( store != NULL ) - { - fprintf( stderr, "Project saved as %s.\n", name ); - fclose( store ); - } - } - else - { - fprintf( stderr, "Usage: inigo [ -group [ name=value ]* ]\n" - " [ -consumer id[:arg] [ name=value ]* ]\n" - " [ -filter id[:arg] [ name=value ] * ]\n" - " [ -transition id[:arg] [ name=value ] * ]\n" - " [ -blank frames ]\n" - " [ -track ]\n" - " [ producer [ name=value ] * ]+\n" ); - } - - // Close the consumer - if ( consumer != NULL ) - mlt_consumer_close( consumer ); - - // Close the producer - if ( inigo != NULL ) - mlt_producer_close( inigo ); - - // Close the factory - mlt_factory_close( ); - - return 0; -} diff --git a/mlt/src/inigo/io.c b/mlt/src/inigo/io.c deleted file mode 100644 index 431003d..0000000 --- a/mlt/src/inigo/io.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * io.c -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include -#include -#include -#include - -/* Application header files */ -#include "io.h" - -char *chomp( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - if ( length && input[ length - 1 ] == '\n' ) - input[ length - 1 ] = '\0'; - if ( length > 1 && input[ length - 2 ] == '\r' ) - input[ length - 2 ] = '\0'; - } - return input; -} - -char *trim( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - int first = 0; - while( first < length && isspace( input[ first ] ) ) - first ++; - memmove( input, input + first, length - first + 1 ); - length = length - first; - while ( length > 0 && isspace( input[ length - 1 ] ) ) - input[ -- length ] = '\0'; - } - return input; -} - -char *strip_quotes( char *input ) -{ - if ( input != NULL ) - { - char *ptr = strrchr( input, '\"' ); - if ( ptr != NULL ) - *ptr = '\0'; - if ( input[ 0 ] == '\"' ) - strcpy( input, input + 1 ); - } - return input; -} - -char *get_string( char *output, int maxlength, char *use ) -{ - char *value = NULL; - strcpy( output, use ); - if ( trim( chomp( fgets( output, maxlength, stdin ) ) ) != NULL ) - { - if ( !strcmp( output, "" ) ) - strcpy( output, use ); - value = output; - } - return value; -} - -int *get_int( int *output, int use ) -{ - int *value = NULL; - char temp[ 132 ]; - *output = use; - if ( trim( chomp( fgets( temp, 132, stdin ) ) ) != NULL ) - { - if ( strcmp( temp, "" ) ) - *output = atoi( temp ); - value = output; - } - return value; -} - -/** This stores the previous settings -*/ - -static struct termios oldtty; -static int mode = 0; - -/** This is called automatically on application exit to restore the - previous tty settings. -*/ - -void term_exit(void) -{ - if ( mode == 1 ) - { - tcsetattr( 0, TCSANOW, &oldtty ); - mode = 0; - } -} - -/** Init terminal so that we can grab keys without blocking. -*/ - -void term_init( ) -{ - struct termios tty; - - tcgetattr( 0, &tty ); - oldtty = tty; - - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - tty.c_oflag |= OPOST; - tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); - tty.c_cflag &= ~(CSIZE|PARENB); - tty.c_cflag |= CS8; - tty.c_cc[ VMIN ] = 1; - tty.c_cc[ VTIME ] = 0; - - tcsetattr( 0, TCSANOW, &tty ); - - mode = 1; - - atexit( term_exit ); -} - -/** Check for a keypress without blocking infinitely. - Returns: ASCII value of keypress or -1 if no keypress detected. -*/ - -int term_read( ) -{ - int n = 1; - unsigned char ch; - struct timeval tv; - fd_set rfds; - - FD_ZERO( &rfds ); - FD_SET( 0, &rfds ); - tv.tv_sec = 0; - tv.tv_usec = 250; - n = select( 1, &rfds, NULL, NULL, &tv ); - if (n > 0) - { - n = read( 0, &ch, 1 ); - tcflush( 0, TCIFLUSH ); - if (n == 1) - return ch; - return n; - } - return -1; -} - -char get_keypress( ) -{ - char value = '\0'; - int pressed = 0; - - fflush( stdout ); - - term_init( ); - while ( ( pressed = term_read( ) ) == -1 ) ; - term_exit( ); - - value = (char)pressed; - - return value; -} - -void wait_for_any_key( char *message ) -{ - if ( message == NULL ) - printf( "Press any key to continue: " ); - else - printf( "%s", message ); - - get_keypress( ); - - printf( "\n\n" ); -} - -void beep( ) -{ - printf( "%c", 7 ); - fflush( stdout ); -} diff --git a/mlt/src/inigo/io.h b/mlt/src/inigo/io.h deleted file mode 100644 index f97e69e..0000000 --- a/mlt/src/inigo/io.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * io.h -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DEMO_IO_H_ -#define _DEMO_IO_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern char *chomp( char * ); -extern char *trim( char * ); -extern char *strip_quotes( char * ); -extern char *get_string( char *, int, char * ); -extern int *get_int( int *, int ); -extern void term_init( ); -extern int term_read( ); -extern void term_exit( ); -extern char get_keypress( ); -extern void wait_for_any_key( char * ); -extern void beep( ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/Makefile b/mlt/src/miracle/Makefile deleted file mode 100644 index 3bda183..0000000 --- a/mlt/src/miracle/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -TARGET = miracle - -APP_OBJS = miracle.o - -LIB_OBJS = miracle_log.o \ - miracle_server.o \ - miracle_connection.o \ - miracle_local.o \ - miracle_unit.o \ - miracle_commands.o \ - miracle_unit_commands.o - -OBJS = $(APP_OBJS) $(LIB_OBJS) - -CFLAGS = -I .. -Wall -g -D_FILE_OFFSET_BITS=64 -pthread -rdynamic - -LDFLAGS = -L ../valerie -lvalerie -L ../framework -lmlt - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(APP_OBJS) libmiracle.so - $(CC) -o $@ $(APP_OBJS) -L. -lmiracle $(LDFLAGS) - -libmiracle.so: $(LIB_OBJS) - $(CC) -shared -o $@ $(LIB_OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) libmiracle.so - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/miracle/configure b/mlt/src/miracle/configure deleted file mode 100755 index 1a24852..0000000 --- a/mlt/src/miracle/configure +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/mlt/src/miracle/miracle.c b/mlt/src/miracle/miracle.c deleted file mode 100644 index e3d26f4..0000000 --- a/mlt/src/miracle/miracle.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * miracle.c -- A DV over IEEE 1394 TCP Server - * - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Authors: - * Dan Dennedy - * Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include -#include -#include -#include -#include - -#include - -/* Application header files */ -#include "miracle_server.h" -#include "miracle_log.h" - -/** Our dv server. -*/ - -static miracle_server server = NULL; - -/** atexit shutdown handler for the server. -*/ - -static void main_cleanup( ) -{ - miracle_server_shutdown( server ); -} - -/** Report usage and exit. -*/ - -void usage( char *app ) -{ - fprintf( stderr, "Usage: %s [-test] [-port NNNN]\n", app ); - exit( 0 ); -} - -/** The main function. -*/ - -int main( int argc, char **argv ) -{ - int error = 0; - int index = 0; - int background = 1; - struct timespec tm = { 5, 0 }; - - server = miracle_server_init( argv[ 0 ] ); - - for ( index = 1; index < argc; index ++ ) - { - if ( !strcmp( argv[ index ], "-port" ) ) - miracle_server_set_port( server, atoi( argv[ ++ index ] ) ); - else if ( !strcmp( argv[ index ], "-proxy" ) ) - miracle_server_set_proxy( server, argv[ ++ index ] ); - else if ( !strcmp( argv[ index ], "-test" ) ) - background = 0; - else - usage( argv[ 0 ] ); - } - - /* Optionally detatch ourselves from the controlling tty */ - - if ( background ) - { - if ( fork() ) - return 0; - setsid(); - miracle_log_init( log_syslog, LOG_INFO ); - } - else - { - miracle_log_init( log_stderr, LOG_DEBUG ); - } - - atexit( main_cleanup ); - - /* Execute the server */ - error = miracle_server_execute( server ); - - /* We need to wait until we're exited.. */ - while ( !server->shutdown ) - nanosleep( &tm, NULL ); - - return error; -} diff --git a/mlt/src/miracle/miracle_commands.c b/mlt/src/miracle/miracle_commands.c deleted file mode 100644 index 3a5db91..0000000 --- a/mlt/src/miracle/miracle_commands.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * global_commands.c - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "miracle_unit.h" -#include "miracle_commands.h" -#include "miracle_log.h" - -static miracle_unit g_units[MAX_UNITS]; - - -/** Return the miracle_unit given a numeric index. -*/ - -miracle_unit miracle_get_unit( int n ) -{ - if (n < MAX_UNITS) - return g_units[n]; - else - return NULL; -} - -/** Destroy the miracle_unit given its numeric index. -*/ - -void miracle_delete_unit( int n ) -{ - if (n < MAX_UNITS) - { - miracle_unit unit = miracle_get_unit(n); - if (unit != NULL) - { - miracle_unit_close( unit ); - g_units[ n ] = NULL; - miracle_log( LOG_NOTICE, "Deleted unit U%d.", n ); - } - } -} - -/** Destroy all allocated units on the server. -*/ - -void miracle_delete_all_units( void ) -{ - int i; - for (i = 0; i < MAX_UNITS; i++) - { - if ( miracle_get_unit(i) != NULL ) - { - miracle_unit_close( miracle_get_unit(i) ); - miracle_log( LOG_NOTICE, "Deleted unit U%d.", i ); - } - } -} - -/** Add a DV virtual vtr to the server. -*/ -response_codes miracle_add_unit( command_argument cmd_arg ) -{ - int i = 0; - for ( i = 0; i < MAX_UNITS; i ++ ) - if ( g_units[ i ] == NULL ) - break; - - if ( i < MAX_UNITS ) - { - char *arg = cmd_arg->argument; - g_units[ i ] = miracle_unit_init( i, arg ); - if ( g_units[ i ] != NULL ) - miracle_unit_set_notifier( g_units[ i ], valerie_parser_get_notifier( cmd_arg->parser ), cmd_arg->root_dir ); - return g_units[ i ] != NULL ? RESPONSE_SUCCESS : RESPONSE_ERROR; - } - - return RESPONSE_ERROR; -} - - -/** List all AV/C nodes on the bus. -*/ -response_codes miracle_list_nodes( command_argument cmd_arg ) -{ - response_codes error = RESPONSE_SUCCESS_N; - return error; -} - - -/** List units already added to server. -*/ -response_codes miracle_list_units( command_argument cmd_arg ) -{ - response_codes error = RESPONSE_SUCCESS_N; - int i = 0; - - for ( i = 0; i < MAX_UNITS; i ++ ) - { - miracle_unit unit = miracle_get_unit( i ); - if ( unit != NULL ) - { - mlt_properties properties = unit->properties; - char *constructor = mlt_properties_get( properties, "constructor" ); - int node = mlt_properties_get_int( properties, "node" ); - int online = !mlt_properties_get_int( properties, "offline" ); - valerie_response_printf( cmd_arg->response, 1024, "U%d %02d %s %d\n", i, node, constructor, online ); - } - } - - return error; -} - -static int filter_files( const struct dirent *de ) -{ - return de->d_name[ 0 ] != '.'; -} - -/** List clips in a directory. -*/ -response_codes miracle_list_clips( command_argument cmd_arg ) -{ - response_codes error = RESPONSE_BAD_FILE; - const char *dir_name = (const char*) cmd_arg->argument; - DIR *dir; - char fullname[1024]; - struct dirent **de = NULL; - int i, n; - - snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, dir_name ); - dir = opendir( fullname ); - if (dir != NULL) - { - struct stat info; - error = RESPONSE_SUCCESS_N; - n = scandir( fullname, &de, filter_files, alphasort ); - for (i = 0; i < n; i++ ) - { - snprintf( fullname, 1023, "%s%s/%s", cmd_arg->root_dir, dir_name, de[i]->d_name ); - if ( stat( fullname, &info ) == 0 && S_ISDIR( info.st_mode ) ) - valerie_response_printf( cmd_arg->response, 1024, "\"%s/\"\n", de[i]->d_name ); - } - for (i = 0; i < n; i++ ) - { - snprintf( fullname, 1023, "%s%s/%s", cmd_arg->root_dir, dir_name, de[i]->d_name ); - if ( lstat( fullname, &info ) == 0 && - ( S_ISREG( info.st_mode ) || S_ISLNK( info.st_mode ) || ( strstr( fullname, ".clip" ) && info.st_mode | S_IXUSR ) ) ) - valerie_response_printf( cmd_arg->response, 1024, "\"%s\" %llu\n", de[i]->d_name, (unsigned long long) info.st_size ); - free( de[ i ] ); - } - free( de ); - closedir( dir ); - valerie_response_write( cmd_arg->response, "\n", 1 ); - } - - return error; -} - -/** Set a server configuration property. -*/ - -response_codes miracle_set_global_property( command_argument cmd_arg ) -{ - char *key = (char*) cmd_arg->argument; - char *value = NULL; - - value = strchr( key, '=' ); - if (value == NULL) - return RESPONSE_OUT_OF_RANGE; - *value = 0; - value++; - miracle_log( LOG_DEBUG, "SET %s = %s", key, value ); - - if ( strncasecmp( key, "root", 1024) == 0 ) - { - int len = strlen(value); - int i; - - /* stop all units and unload clips */ - for (i = 0; i < MAX_UNITS; i++) - { - if (g_units[i] != NULL) - miracle_unit_terminate( g_units[i] ); - } - - /* set the property */ - strncpy( cmd_arg->root_dir, value, 1023 ); - - /* add a trailing slash if needed */ - if ( cmd_arg->root_dir[ len - 1 ] != '/') - { - cmd_arg->root_dir[ len ] = '/'; - cmd_arg->root_dir[ len + 1 ] = '\0'; - } - } - else - return RESPONSE_OUT_OF_RANGE; - - return RESPONSE_SUCCESS; -} - -/** Get a server configuration property. -*/ - -response_codes miracle_get_global_property( command_argument cmd_arg ) -{ - char *key = (char*) cmd_arg->argument; - - if ( strncasecmp( key, "root", 1024) == 0 ) - { - valerie_response_write( cmd_arg->response, cmd_arg->root_dir, strlen(cmd_arg->root_dir) ); - return RESPONSE_SUCCESS_1; - } - else - return RESPONSE_OUT_OF_RANGE; - - return RESPONSE_SUCCESS; -} - - diff --git a/mlt/src/miracle/miracle_commands.h b/mlt/src/miracle/miracle_commands.h deleted file mode 100644 index 9d79683..0000000 --- a/mlt/src/miracle/miracle_commands.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * global_commands.h - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -#ifndef _GLOBAL_COMMANDS_H_ -#define _GLOBAL_COMMANDS_H_ - -#include -#include "miracle_unit.h" -#include "miracle_connection.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern miracle_unit miracle_get_unit( int ); -extern void miracle_delete_unit( int ); -extern void miracle_delete_all_units( void ); -extern int miracle_unit_status( int n, valerie_status status, int root_offset ); -//extern void raw1394_start_service_threads( void ); -//extern void raw1394_stop_service_threads( void ); - -extern response_codes miracle_add_unit( command_argument ); -extern response_codes miracle_list_nodes( command_argument ); -extern response_codes miracle_list_units( command_argument ); -extern response_codes miracle_list_clips( command_argument ); -extern response_codes miracle_set_global_property( command_argument ); -extern response_codes miracle_get_global_property( command_argument ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_connection.c b/mlt/src/miracle/miracle_connection.c deleted file mode 100644 index 82a5b59..0000000 --- a/mlt/src/miracle/miracle_connection.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - * miracle_connection.c -- DV Connection Handler - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* Application header files */ -#include "miracle_commands.h" -#include "miracle_connection.h" -#include "miracle_server.h" -#include "miracle_log.h" - -/** This is a generic replacement for fgets which operates on a file - descriptor. Unlike fgets, we can also specify a line terminator. Maximum - of (max - 1) chars can be read into buf from fd. If we reach the - end-of-file, *eof_chk is set to 1. -*/ - -int fdgetline( int fd, char *buf, int max, char line_terminator, int *eof_chk ) -{ - int count = 0; - char tmp [1]; - *eof_chk = 0; - - if (fd) - while (count < max - 1) { - if (read (fd, tmp, 1) > 0) { - if (tmp [0] != line_terminator) - buf [count++] = tmp [0]; - else - break; - -/* Is it an EOF character (ctrl-D, i.e. ascii 4)? If so we definitely want - to break. */ - - if (tmp [0] == 4) { - *eof_chk = 1; - break; - } - } else { - *eof_chk = 1; - break; - } - } - - buf [count] = '\0'; - - return count; -} - -static int connection_initiate( int ); -static int connection_send( int, valerie_response ); -static int connection_read( int, char *, int ); -static void connection_close( int ); - -static int connection_initiate( int fd ) -{ - int error = 0; - valerie_response response = valerie_response_init( ); - valerie_response_set_error( response, 100, "VTR Ready" ); - error = connection_send( fd, response ); - valerie_response_close( response ); - return error; -} - -static int connection_send( int fd, valerie_response response ) -{ - int error = 0; - int index = 0; - int code = valerie_response_get_error_code( response ); - - if ( code != -1 ) - { - int items = valerie_response_count( response ); - - if ( items == 0 ) - valerie_response_set_error( response, 500, "Unknown error" ); - - if ( code == 200 && items > 2 ) - valerie_response_set_error( response, 201, "OK" ); - else if ( code == 200 && items > 1 ) - valerie_response_set_error( response, 202, "OK" ); - - code = valerie_response_get_error_code( response ); - items = valerie_response_count( response ); - - for ( index = 0; !error && index < items; index ++ ) - { - char *line = valerie_response_get_line( response, index ); - int length = strlen( line ); - if ( length == 0 && index != valerie_response_count( response ) - 1 && write( fd, " ", 1 ) != 1 ) - error = -1; - else if ( length > 0 && write( fd, line, length ) != length ) - error = -1; - if ( write( fd, "\r\n", 2 ) != 2 ) - error = -1; - } - - if ( ( code == 201 || code == 500 ) && strcmp( valerie_response_get_line( response, items - 1 ), "" ) ) - write( fd, "\r\n", 2 ); - } - else - { - char *message = "500 Empty Response\r\n\r\n"; - write( fd, message, strlen( message ) ); - } - - return error; -} - -static int connection_read( int fd, char *command, int length ) -{ - int eof_chk; - int nchars = fdgetline( fd, command, length, '\n', &eof_chk ); - char *cr = strchr( command, '\r'); - if ( cr != NULL ) - cr[0] = '\0'; - if ( eof_chk || strncasecmp( command, "BYE", 3 ) == 0 ) - nchars = 0; - return nchars; -} - -int connection_status( int fd, valerie_notifier notifier ) -{ - int error = 0; - int index = 0; - valerie_status_t status; - char text[ 10240 ]; - valerie_socket socket = valerie_socket_init_fd( fd ); - - for ( index = 0; !error && index < MAX_UNITS; index ++ ) - { - valerie_notifier_get( notifier, &status, index ); - valerie_status_serialise( &status, text, sizeof( text ) ); - error = valerie_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); - } - - while ( !error ) - { - if ( valerie_notifier_wait( notifier, &status ) == 0 ) - { - valerie_status_serialise( &status, text, sizeof( text ) ); - error = valerie_socket_write_data( socket, text, strlen( text ) ) != strlen( text ); - } - else - { - struct timeval tv = { 0, 0 }; - fd_set rfds; - - FD_ZERO( &rfds ); - FD_SET( fd, &rfds ); - - if ( select( socket->fd + 1, &rfds, NULL, NULL, &tv ) ) - error = 1; - } - } - - valerie_socket_close( socket ); - - return error; -} - -static void connection_close( int fd ) -{ - close( fd ); -} - -void *parser_thread( void *arg ) -{ - struct hostent *he; - connection_t *connection = arg; - char address[ 512 ]; - char command[ 1024 ]; - int fd = connection->fd; - valerie_parser parser = connection->parser; - valerie_response response = NULL; - - /* Get the connecting clients ip information */ - he = gethostbyaddr( (char *) &( connection->sin.sin_addr.s_addr ), sizeof(u_int32_t), AF_INET); - if ( he != NULL ) - strcpy( address, he->h_name ); - else - inet_ntop( AF_INET, &( connection->sin.sin_addr.s_addr), address, 32 ); - - miracle_log( LOG_NOTICE, "Connection established with %s (%d)", address, fd ); - - /* Execute the commands received. */ - if ( connection_initiate( fd ) == 0 ) - { - int error = 0; - - while( !error && connection_read( fd, command, 1024 ) ) - { - if ( strncmp( command, "STATUS", 6 ) ) - { - response = valerie_parser_execute( parser, command ); - miracle_log( LOG_INFO, "%s \"%s\" %d", address, command, valerie_response_get_error_code( response ) ); - error = connection_send( fd, response ); - valerie_response_close( response ); - } - else - { - error = connection_status( fd, valerie_parser_get_notifier( parser ) ); - } - } - } - - /* Free the resources associated with this connection. */ - connection_close( fd ); - - miracle_log( LOG_NOTICE, "Connection with %s (%d) closed", address, fd ); - - free( connection ); - - return NULL; -} diff --git a/mlt/src/miracle/miracle_connection.h b/mlt/src/miracle/miracle_connection.h deleted file mode 100644 index ce19115..0000000 --- a/mlt/src/miracle/miracle_connection.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * miracle_connection.h -- DV Connection Handler - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DV_CONNECTION_H_ -#define _DV_CONNECTION_H_ - -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Connection structure -*/ - -typedef struct -{ - int fd; - struct sockaddr_in sin; - valerie_parser parser; -} -connection_t; - -/** Enumeration for responses. -*/ - -typedef enum -{ - RESPONSE_SUCCESS = 200, - RESPONSE_SUCCESS_N = 201, - RESPONSE_SUCCESS_1 = 202, - RESPONSE_UNKNOWN_COMMAND = 400, - RESPONSE_TIMEOUT = 401, - RESPONSE_MISSING_ARG = 402, - RESPONSE_INVALID_UNIT = 403, - RESPONSE_BAD_FILE = 404, - RESPONSE_OUT_OF_RANGE = 405, - RESPONSE_TOO_MANY_FILES = 406, - RESPONSE_ERROR = 500 -} -response_codes; - -/* the following struct is passed as the single argument - to all command callback functions */ - -typedef struct -{ - valerie_parser parser; - valerie_response response; - valerie_tokeniser tokeniser; - char *command; - int unit; - void *argument; - char *root_dir; -} -command_argument_t, *command_argument; - -/* A handler is defined as follows. */ -typedef int (*command_handler_t) ( command_argument ); - - -extern void *parser_thread( void *arg ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_local.c b/mlt/src/miracle/miracle_local.c deleted file mode 100644 index 501487a..0000000 --- a/mlt/src/miracle/miracle_local.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * miracle_local.c -- Local Miracle Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include - -/* Valerie header files */ -#include - -/* MLT header files. */ -#include - -/* Application header files */ -#include "miracle_local.h" -#include "miracle_connection.h" -#include "miracle_commands.h" -#include "miracle_unit_commands.h" -#include "miracle_log.h" - -/** Private miracle_local structure. -*/ - -typedef struct -{ - valerie_parser parser; - char root_dir[1024]; -} -*miracle_local, miracle_local_t; - -/** Forward declarations. -*/ - -static valerie_response miracle_local_connect( miracle_local ); -static valerie_response miracle_local_execute( miracle_local, char * ); -static void miracle_local_close( miracle_local ); -response_codes miracle_help( command_argument arg ); -response_codes miracle_run( command_argument arg ); -response_codes miracle_shutdown( command_argument arg ); - -/** DV Parser constructor. -*/ - -valerie_parser miracle_parser_init_local( ) -{ - valerie_parser parser = malloc( sizeof( valerie_parser_t ) ); - miracle_local local = malloc( sizeof( miracle_local_t ) ); - - if ( parser != NULL ) - { - memset( parser, 0, sizeof( valerie_parser_t ) ); - - parser->connect = (parser_connect)miracle_local_connect; - parser->execute = (parser_execute)miracle_local_execute; - parser->close = (parser_close)miracle_local_close; - parser->real = local; - - if ( local != NULL ) - { - memset( local, 0, sizeof( miracle_local_t ) ); - local->parser = parser; - local->root_dir[0] = '/'; - } - - // Construct the factory - mlt_factory_init( getenv( "MLT_REPOSITORY" ) ); - } - return parser; -} - -/** response status code/message pair -*/ - -typedef struct -{ - int code; - char *message; -} -responses_t; - -/** response messages -*/ - -static responses_t responses [] = -{ - {RESPONSE_SUCCESS, "OK"}, - {RESPONSE_SUCCESS_N, "OK"}, - {RESPONSE_SUCCESS_1, "OK"}, - {RESPONSE_UNKNOWN_COMMAND, "Unknown command"}, - {RESPONSE_TIMEOUT, "Operation timed out"}, - {RESPONSE_MISSING_ARG, "Argument missing"}, - {RESPONSE_INVALID_UNIT, "Unit not found"}, - {RESPONSE_BAD_FILE, "Failed to locate or open clip"}, - {RESPONSE_OUT_OF_RANGE, "Argument value out of range"}, - {RESPONSE_TOO_MANY_FILES, "Too many files open"}, - {RESPONSE_ERROR, "Server Error"} -}; - -/** Argument types. -*/ - -typedef enum -{ - ATYPE_NONE, - ATYPE_FLOAT, - ATYPE_STRING, - ATYPE_INT -} -arguments_types; - -/** A command definition. -*/ - -typedef struct -{ -/* The command string corresponding to this operation (e.g. "play") */ - char *command; -/* The function associated with it */ - response_codes (*operation) ( command_argument ); -/* a boolean to indicate if this is a unit or global command - unit commands require a unit identifier as first argument */ - int is_unit; -/* What type is the argument (RTTI :-) ATYPE_whatever */ - int type; -/* online help information */ - char *help; -} -command_t; - -/* The following define the queue of commands available to the user. The - first entry is the name of the command (the string which must be typed), - the second command is the function associated with it, the third argument - is for the type of the argument, and the last argument specifies whether - this is something which should be handled immediately or whether it - should be queued (only robot motion commands need to be queued). */ - -static command_t vocabulary[] = -{ - {"BYE", NULL, 0, ATYPE_NONE, "Terminates the session. Units are not removed and task queue is not flushed."}, - {"HELP", miracle_help, 0, ATYPE_NONE, "Display this information!"}, - {"NLS", miracle_list_nodes, 0, ATYPE_NONE, "List the AV/C nodes on the 1394 bus."}, - {"UADD", miracle_add_unit, 0, ATYPE_STRING, "Create a new DV unit (virtual VTR) to transmit to receiver specified in GUID argument."}, - {"ULS", miracle_list_units, 0, ATYPE_NONE, "Lists the units that have already been added to the server."}, - {"CLS", miracle_list_clips, 0, ATYPE_STRING, "Lists the clips at directory name argument."}, - {"SET", miracle_set_global_property, 0, ATYPE_STRING, "Set a server configuration property."}, - {"GET", miracle_get_global_property, 0, ATYPE_STRING, "Get a server configuration property."}, - {"RUN", miracle_run, 0, ATYPE_STRING, "Run a batch file." }, - {"LIST", miracle_list, 1, ATYPE_NONE, "List the playlist associated to a unit."}, - {"LOAD", miracle_load, 1, ATYPE_STRING, "Load clip specified in absolute filename argument."}, - {"INSERT", miracle_insert, 1, ATYPE_STRING, "Insert a clip at the given clip index."}, - {"REMOVE", miracle_remove, 1, ATYPE_NONE, "Remove a clip at the given clip index."}, - {"CLEAN", miracle_clean, 1, ATYPE_NONE, "Clean a unit by removing all but the currently playing clip."}, - {"MOVE", miracle_move, 1, ATYPE_INT, "Move a clip to another clip index."}, - {"APND", miracle_append, 1, ATYPE_STRING, "Append a clip specified in absolute filename argument."}, - {"PLAY", miracle_play, 1, ATYPE_NONE, "Play a loaded clip at speed -2000 to 2000 where 1000 = normal forward speed."}, - {"STOP", miracle_stop, 1, ATYPE_NONE, "Stop a loaded and playing clip."}, - {"PAUSE", miracle_pause, 1, ATYPE_NONE, "Pause a playing clip."}, - {"REW", miracle_rewind, 1, ATYPE_NONE, "Rewind a unit. If stopped, seek to beginning of clip. If playing, play fast backwards."}, - {"FF", miracle_ff, 1, ATYPE_NONE, "Fast forward a unit. If stopped, seek to beginning of clip. If playing, play fast forwards."}, - {"STEP", miracle_step, 1, ATYPE_INT, "Step argument number of frames forward or backward."}, - {"GOTO", miracle_goto, 1, ATYPE_INT, "Jump to frame number supplied as argument."}, - {"SIN", miracle_set_in_point, 1, ATYPE_INT, "Set the IN point of the loaded clip to frame number argument. -1 = reset in point to 0"}, - {"SOUT", miracle_set_out_point, 1, ATYPE_INT, "Set the OUT point of the loaded clip to frame number argument. -1 = reset out point to maximum."}, - {"USTA", miracle_get_unit_status, 1, ATYPE_NONE, "Report information about the unit."}, - {"USET", miracle_set_unit_property, 1, ATYPE_STRING, "Set a unit configuration property."}, - {"UGET", miracle_get_unit_property, 1, ATYPE_STRING, "Get a unit configuration property."}, - {"XFER", miracle_transfer, 1, ATYPE_STRING, "Transfer the unit's clip to another unit specified as argument."}, - {"SHUTDOWN", miracle_shutdown, 0, ATYPE_NONE, "Shutdown the server."}, - {NULL, NULL, 0, ATYPE_NONE, NULL} -}; - -/** Usage message -*/ - -static char helpstr [] = - "Miracle -- A Multimedia Playout Server\n" - " Copyright (C) 2002-2003 Ushodaya Enterprises Limited\n" - " Authors:\n" - " Dan Dennedy \n" - " Charles Yates \n" - "Available commands:\n"; - -/** Lookup the response message for a status code. -*/ - -inline char *get_response_msg( int code ) -{ - int i = 0; - for ( i = 0; responses[ i ].message != NULL && code != responses[ i ].code; i ++ ) ; - return responses[ i ].message; -} - -/** Tell the user the miracle command set -*/ - -response_codes miracle_help( command_argument cmd_arg ) -{ - int i = 0; - - valerie_response_printf( cmd_arg->response, 10240, "%s", helpstr ); - - for ( i = 0; vocabulary[ i ].command != NULL; i ++ ) - valerie_response_printf( cmd_arg->response, 1024, - "%-10.10s%s\n", - vocabulary[ i ].command, - vocabulary[ i ].help ); - - valerie_response_printf( cmd_arg->response, 2, "\n" ); - - return RESPONSE_SUCCESS_N; -} - -/** Execute a batch file. -*/ - -response_codes miracle_run( command_argument cmd_arg ) -{ - valerie_response temp = valerie_parser_run( cmd_arg->parser, (char *)cmd_arg->argument ); - - if ( temp != NULL ) - { - int index = 0; - - valerie_response_set_error( cmd_arg->response, - valerie_response_get_error_code( temp ), - valerie_response_get_error_string( temp ) ); - - for ( index = 1; index < valerie_response_count( temp ); index ++ ) - valerie_response_printf( cmd_arg->response, 10240, "%s\n", valerie_response_get_line( temp, index ) ); - - valerie_response_close( temp ); - } - - return valerie_response_get_error_code( cmd_arg->response ); -} - -response_codes miracle_shutdown( command_argument cmd_arg ) -{ - exit( 0 ); - return RESPONSE_SUCCESS; -} - -/** Processes 'thread' id -*/ - -static pthread_t self; - -/* Signal handler to deal with various shutdown signals. Basically this - should clean up and power down the motor. Note that the death of any - child thread will kill all thrads. */ - -void signal_handler( int sig ) -{ - if ( pthread_equal( self, pthread_self( ) ) ) - { - -#ifdef _GNU_SOURCE - miracle_log( LOG_DEBUG, "Received %s - shutting down.", strsignal(sig) ); -#else - miracle_log( LOG_DEBUG, "Received signal %i - shutting down.", sig ); -#endif - - exit(EXIT_SUCCESS); - } -} - -/** Local 'connect' function. -*/ - -static valerie_response miracle_local_connect( miracle_local local ) -{ - valerie_response response = valerie_response_init( ); - - self = pthread_self( ); - - valerie_response_set_error( response, 100, "VTR Ready" ); - - signal( SIGHUP, signal_handler ); - signal( SIGINT, signal_handler ); - signal( SIGTERM, SIG_DFL ); - signal( SIGSTOP, signal_handler ); - signal( SIGPIPE, signal_handler ); - signal( SIGALRM, signal_handler ); - signal( SIGCHLD, SIG_IGN ); - - return response; -} - -/** Set the error and determine the message associated to this command. -*/ - -void miracle_command_set_error( command_argument cmd, response_codes code ) -{ - valerie_response_set_error( cmd->response, code, get_response_msg( code ) ); -} - -/** Parse the unit argument. -*/ - -int miracle_command_parse_unit( command_argument cmd, int argument ) -{ - int unit = -1; - char *string = valerie_tokeniser_get_string( cmd->tokeniser, argument ); - if ( string != NULL && ( string[ 0 ] == 'U' || string[ 0 ] == 'u' ) && strlen( string ) > 1 ) - unit = atoi( string + 1 ); - return unit; -} - -/** Parse a normal argument. -*/ - -void *miracle_command_parse_argument( command_argument cmd, int argument, arguments_types type ) -{ - void *ret = NULL; - char *value = valerie_tokeniser_get_string( cmd->tokeniser, argument ); - - if ( value != NULL ) - { - switch( type ) - { - case ATYPE_NONE: - break; - - case ATYPE_FLOAT: - ret = malloc( sizeof( float ) ); - if ( ret != NULL ) - *( float * )ret = atof( value ); - break; - - case ATYPE_STRING: - ret = strdup( value ); - break; - - case ATYPE_INT: - ret = malloc( sizeof( int ) ); - if ( ret != NULL ) - *( int * )ret = atoi( value ); - break; - } - } - - return ret; -} - -/** Get the error code - note that we simply the success return. -*/ - -response_codes miracle_command_get_error( command_argument cmd ) -{ - response_codes ret = valerie_response_get_error_code( cmd->response ); - if ( ret == RESPONSE_SUCCESS_N || ret == RESPONSE_SUCCESS_1 ) - ret = RESPONSE_SUCCESS; - return ret; -} - -/** Execute the command. -*/ - -static valerie_response miracle_local_execute( miracle_local local, char *command ) -{ - command_argument_t cmd; - cmd.parser = local->parser; - cmd.response = valerie_response_init( ); - cmd.tokeniser = valerie_tokeniser_init( ); - cmd.command = command; - cmd.unit = -1; - cmd.argument = NULL; - cmd.root_dir = local->root_dir; - - /* Set the default error */ - miracle_command_set_error( &cmd, RESPONSE_UNKNOWN_COMMAND ); - - /* Parse the command */ - if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 ) - { - int index = 0; - char *value = valerie_tokeniser_get_string( cmd.tokeniser, 0 ); - int found = 0; - - /* Strip quotes from all tokens */ - for ( index = 0; index < valerie_tokeniser_count( cmd.tokeniser ); index ++ ) - valerie_util_strip( valerie_tokeniser_get_string( cmd.tokeniser, index ), '\"' ); - - /* Search the vocabulary array for value */ - for ( index = 1; !found && vocabulary[ index ].command != NULL; index ++ ) - if ( ( found = !strcasecmp( vocabulary[ index ].command, value ) ) ) - break; - - /* If we found something, the handle the args and call the handler. */ - if ( found ) - { - int position = 1; - - miracle_command_set_error( &cmd, RESPONSE_SUCCESS ); - - if ( vocabulary[ index ].is_unit ) - { - cmd.unit = miracle_command_parse_unit( &cmd, position ); - if ( cmd.unit == -1 ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); - position ++; - } - - if ( miracle_command_get_error( &cmd ) == RESPONSE_SUCCESS ) - { - cmd.argument = miracle_command_parse_argument( &cmd, position, vocabulary[ index ].type ); - if ( cmd.argument == NULL && vocabulary[ index ].type != ATYPE_NONE ) - miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG ); - position ++; - } - - if ( miracle_command_get_error( &cmd ) == RESPONSE_SUCCESS ) - { - response_codes error = vocabulary[ index ].operation( &cmd ); - miracle_command_set_error( &cmd, error ); - } - - free( cmd.argument ); - } - } - - valerie_tokeniser_close( cmd.tokeniser ); - - return cmd.response; -} - -/** Close the parser. -*/ - -static void miracle_local_close( miracle_local local ) -{ - miracle_delete_all_units(); - pthread_kill_other_threads_np(); - miracle_log( LOG_DEBUG, "Clean shutdown." ); - free( local ); - //mlt_factory_close( ); -} diff --git a/mlt/src/miracle/miracle_local.h b/mlt/src/miracle/miracle_local.h deleted file mode 100644 index 6baf035..0000000 --- a/mlt/src/miracle/miracle_local.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * miracle_local.h -- Local dv1394d Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _MIRACLE_LOCAL_H_ -#define _MIRACLE_LOCAL_H_ - -/* Application header files */ -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Local parser API. -*/ - -extern valerie_parser miracle_parser_init_local( ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_log.c b/mlt/src/miracle/miracle_log.c deleted file mode 100644 index f5f7e1a..0000000 --- a/mlt/src/miracle/miracle_log.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * miracle_log.c -- logging facility implementation - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "miracle_log.h" - -static int log_output = log_stderr; -static int threshold = LOG_DEBUG; - -void miracle_log_init( enum log_output method, int new_threshold ) -{ - log_output = method; - threshold = new_threshold; - if (method == log_syslog) - openlog( "miracle", LOG_CONS, LOG_DAEMON ); - -} - -void miracle_log( int priority, char *format, ... ) -{ - va_list list; - va_start( list, format ); - if ( LOG_PRI(priority) <= threshold ) - { - if ( log_output == log_syslog ) - { - vsyslog( priority, format, list ); - } - else - { - char line[1024]; - if ( snprintf( line, 1024, "(%d) %s\n", priority, format ) != 0 ) - vfprintf( stderr, line, list ); - } - } - va_end( list ); -} diff --git a/mlt/src/miracle/miracle_log.h b/mlt/src/miracle/miracle_log.h deleted file mode 100644 index 3788ee5..0000000 --- a/mlt/src/miracle/miracle_log.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * miracle_log.h -- logging facility header - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _LOG_H_ -#define _LOG_H_ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -enum log_output { - log_stderr, - log_syslog -}; - -void miracle_log_init( enum log_output method, int threshold ); -void miracle_log( int priority, char *format, ... ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_server.c b/mlt/src/miracle/miracle_server.c deleted file mode 100644 index 3c82c33..0000000 --- a/mlt/src/miracle/miracle_server.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * miracle_server.c -- DV Server - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* System header files */ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/* Application header files */ -#include "miracle_server.h" -#include "miracle_connection.h" -#include "miracle_local.h" -#include "miracle_log.h" -#include -#include - -#define VERSION "0.0.1" - -/** Initialise a server structure. -*/ - -miracle_server miracle_server_init( char *id ) -{ - miracle_server server = malloc( sizeof( miracle_server_t ) ); - if ( server != NULL ) - { - memset( server, 0, sizeof( miracle_server_t ) ); - server->id = id; - server->port = DEFAULT_TCP_PORT; - server->socket = -1; - } - return server; -} - -/** Set the port of the server. -*/ - -void miracle_server_set_port( miracle_server server, int port ) -{ - server->port = port; -} - -void miracle_server_set_proxy( miracle_server server, char *proxy ) -{ - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - server->proxy = 1; - server->remote_port = DEFAULT_TCP_PORT; - valerie_tokeniser_parse_new( tokeniser, proxy, ":" ); - strcpy( server->remote_server, valerie_tokeniser_get_string( tokeniser, 0 ) ); - if ( valerie_tokeniser_count( tokeniser ) == 2 ) - server->remote_port = atoi( valerie_tokeniser_get_string( tokeniser, 1 ) ); - valerie_tokeniser_close( tokeniser ); -} - -/** Wait for a connection. -*/ - -static int miracle_server_wait_for_connect( miracle_server server ) -{ - struct timeval tv; - fd_set rfds; - - /* Wait for a 1 second. */ - tv.tv_sec = 1; - tv.tv_usec = 0; - - FD_ZERO( &rfds ); - FD_SET( server->socket, &rfds ); - - return select( server->socket + 1, &rfds, NULL, NULL, &tv); -} - -/** Run the server thread. -*/ - -static void *miracle_server_run( void *arg ) -{ - miracle_server server = arg; - pthread_t cmd_parse_info; - connection_t *tmp = NULL; - pthread_attr_t thread_attributes; - int socksize; - - socksize = sizeof( struct sockaddr ); - - miracle_log( LOG_NOTICE, "%s version %s listening on port %i", server->id, VERSION, server->port ); - - /* Create the initial thread. We want all threads to be created detached so - their resources get freed automatically. (CY: ... hmmph...) */ - pthread_attr_init( &thread_attributes ); - pthread_attr_setdetachstate( &thread_attributes, PTHREAD_CREATE_DETACHED ); - pthread_attr_init( &thread_attributes ); - pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED ); - /* pthread_attr_setschedpolicy( &thread_attributes, SCHED_RR ); */ - - while ( !server->shutdown ) - { - /* Wait for a new connection. */ - if ( miracle_server_wait_for_connect( server ) ) - { - /* Create a new block of data to hold a copy of the incoming connection for - our server thread. The thread should free this when it terminates. */ - - tmp = (connection_t*) malloc( sizeof(connection_t) ); - tmp->parser = server->parser; - tmp->fd = accept( server->socket, (struct sockaddr*) &(tmp->sin), &socksize ); - - /* Pass the connection to a parser thread :-/ */ - if ( tmp->fd != -1 ) - pthread_create( &cmd_parse_info, &thread_attributes, parser_thread, tmp ); - } - } - - miracle_log( LOG_NOTICE, "%s version %s server terminated.", server->id, VERSION ); - - return NULL; -} - -/** Execute the server thread. -*/ - -int miracle_server_execute( miracle_server server ) -{ - int error = 0; - valerie_response response = NULL; - int index = 0; - struct sockaddr_in ServerAddr; - int flag = 1; - - ServerAddr.sin_family = AF_INET; - ServerAddr.sin_port = htons( server->port ); - ServerAddr.sin_addr.s_addr = INADDR_ANY; - - /* Create socket, and bind to port. Listen there. Backlog = 5 - should be sufficient for listen (). */ - server->socket = socket( AF_INET, SOCK_STREAM, 0 ); - - if ( server->socket == -1 ) - { - server->shutdown = 1; - perror( "socket" ); - miracle_log( LOG_ERR, "%s unable to create socket.", server->id ); - return -1; - } - - setsockopt( server->socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof( int ) ); - - if ( bind( server->socket, (struct sockaddr *) &ServerAddr, sizeof (ServerAddr) ) != 0 ) - { - server->shutdown = 1; - perror( "bind" ); - miracle_log( LOG_ERR, "%s unable to bind to port %d.", server->id, server->port ); - return -1; - } - - if ( listen( server->socket, 5 ) != 0 ) - { - server->shutdown = 1; - perror( "listen" ); - miracle_log( LOG_ERR, "%s unable to listen on port %d.", server->id, server->port ); - return -1; - } - - fcntl( server->socket, F_SETFL, O_NONBLOCK ); - - if ( !server->proxy ) - { - miracle_log( LOG_NOTICE, "Starting server on %d.", server->port ); - server->parser = miracle_parser_init_local( ); - } - else - { - miracle_log( LOG_NOTICE, "Starting proxy for %s:%d on %d.", server->remote_server, server->remote_port, server->port ); - server->parser = valerie_parser_init_remote( server->remote_server, server->remote_port ); - } - - response = valerie_parser_connect( server->parser ); - - if ( response != NULL && valerie_response_get_error_code( response ) == 100 ) - { - /* read configuration file */ - if ( response != NULL && !server->proxy ) - { - valerie_response_close( response ); - response = valerie_parser_run( server->parser, "/etc/miracle.conf" ); - - if ( valerie_response_count( response ) > 1 ) - { - if ( valerie_response_get_error_code( response ) > 299 ) - miracle_log( LOG_ERR, "Error evaluating server configuration. Processing stopped." ); - for ( index = 0; index < valerie_response_count( response ); index ++ ) - miracle_log( LOG_DEBUG, "%4d: %s", index, valerie_response_get_line( response, index ) ); - } - } - - if ( response != NULL ) - { - pthread_attr_t attr; - int result; - pthread_attr_init( &attr ); - pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_JOINABLE ); - pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); - pthread_attr_setschedpolicy( &attr, SCHED_FIFO ); - pthread_attr_setscope( &attr, PTHREAD_SCOPE_SYSTEM ); - valerie_response_close( response ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); - if ( result ) - { - miracle_log( LOG_WARNING, "Failed to schedule realtime (%s)", strerror(errno) ); - pthread_attr_setschedpolicy( &attr, SCHED_OTHER ); - result = pthread_create( &server->thread, &attr, miracle_server_run, server ); - if ( result ) - { - miracle_log( LOG_CRIT, "Failed to launch TCP listener thread" ); - error = -1; - } - } - } - } - else - { - miracle_log( LOG_ERR, "Error connecting to parser. Processing stopped." ); - server->shutdown = 1; - error = -1; - } - - return error; -} - -/** Shutdown the server. -*/ - -void miracle_server_shutdown( miracle_server server ) -{ - if ( server != NULL && !server->shutdown ) - { - server->shutdown = 1; - pthread_join( server->thread, NULL ); - valerie_parser_close( server->parser ); - close( server->socket ); - } -} diff --git a/mlt/src/miracle/miracle_server.h b/mlt/src/miracle/miracle_server.h deleted file mode 100644 index 95dfb52..0000000 --- a/mlt/src/miracle/miracle_server.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * miracle_server.h -- DV Server - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _MIRACLE_SERVER_H_ -#define _MIRACLE_SERVER_H_ - -/* System header files */ -#include - -/* Application header files */ -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Servers default port -*/ - -#define DEFAULT_TCP_PORT 5250 - -/** Structure for the server -*/ - -typedef struct -{ - char *id; - int port; - int socket; - valerie_parser parser; - pthread_t thread; - int shutdown; - int proxy; - char remote_server[ 50 ]; - int remote_port; -} -*miracle_server, miracle_server_t; - -/** API for the server -*/ - -extern miracle_server miracle_server_init( char * ); -extern void miracle_server_set_port( miracle_server, int ); -extern void miracle_server_set_proxy( miracle_server, char * ); -extern int miracle_server_execute( miracle_server ); -extern void miracle_server_shutdown( miracle_server ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_unit.c b/mlt/src/miracle/miracle_unit.c deleted file mode 100644 index f7023d0..0000000 --- a/mlt/src/miracle/miracle_unit.c +++ /dev/null @@ -1,645 +0,0 @@ -/* - * miracle_unit.c -- DV Transmission Unit Implementation - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "miracle_unit.h" -#include "miracle_log.h" -#include "miracle_local.h" - -#include - -/* Forward references */ -static void miracle_unit_status_communicate( miracle_unit ); - -/** Allocate a new DV transmission unit. - - \return A new miracle_unit handle. -*/ - -miracle_unit miracle_unit_init( int index, char *constructor ) -{ - miracle_unit this = NULL; - mlt_consumer consumer = NULL; - - char *id = strdup( constructor ); - char *arg = strchr( id, ':' ); - - if ( arg != NULL ) - *arg ++ = '\0'; - - consumer = mlt_factory_consumer( id, arg ); - - if ( consumer != NULL ) - { - mlt_playlist playlist = mlt_playlist_init( ); - this = calloc( sizeof( miracle_unit_t ), 1 ); - this->properties = mlt_properties_new( ); - this->producers = mlt_properties_new( ); - mlt_properties_init( this->properties, this ); - mlt_properties_set_int( this->properties, "unit", index ); - mlt_properties_set_int( this->properties, "generation", 0 ); - mlt_properties_set( this->properties, "constructor", constructor ); - mlt_properties_set( this->properties, "id", id ); - mlt_properties_set( this->properties, "arg", arg ); - mlt_properties_set_data( this->properties, "consumer", consumer, 0, ( mlt_destructor )mlt_consumer_close, NULL ); - mlt_properties_set_data( this->properties, "playlist", playlist, 0, ( mlt_destructor )mlt_playlist_close, NULL ); - mlt_consumer_connect( consumer, mlt_playlist_service( playlist ) ); - } - - return this; -} - -/** Communicate the current status to all threads waiting on the notifier. -*/ - -static void miracle_unit_status_communicate( miracle_unit unit ) -{ - if ( unit != NULL ) - { - mlt_properties properties = unit->properties; - char *root_dir = mlt_properties_get( properties, "root" ); - valerie_notifier notifier = mlt_properties_get_data( properties, "notifier", NULL ); - valerie_status_t status; - - if ( root_dir != NULL && notifier != NULL ) - { - if ( miracle_unit_get_status( unit, &status ) == 0 ) - /* if ( !( ( status.status == unit_playing || status.status == unit_paused ) && - strcmp( status.clip, "" ) && - !strcmp( status.tail_clip, "" ) && - status.position == 0 && - status.in == 0 && - status.out == 0 ) ) */ - valerie_notifier_put( notifier, &status ); - } - } -} - -/** Set the notifier info -*/ - -void miracle_unit_set_notifier( miracle_unit this, valerie_notifier notifier, char *root_dir ) -{ - mlt_properties properties = this->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_properties playlist_properties = mlt_playlist_properties( playlist ); - - mlt_properties_set( properties, "root", root_dir ); - mlt_properties_set_data( properties, "notifier", notifier, 0, NULL, NULL ); - mlt_properties_set_data( playlist_properties, "notifier_arg", this, 0, NULL, NULL ); - mlt_properties_set_data( playlist_properties, "notifier", miracle_unit_status_communicate, 0, NULL, NULL ); - - miracle_unit_status_communicate( this ); -} - -/** Create or locate a producer for the file specified. -*/ - -static mlt_producer create_producer( miracle_unit unit, char *file ) -{ - // Get the unit properties - mlt_properties properties = unit->producers; - - // Check if we already have loaded this file - mlt_producer result = mlt_properties_get_data( properties, file, NULL ); - - if ( result == NULL ) - { - // 1st Line preferences - if ( strstr( file, ".inigo" ) ) - { - char *args[ 2 ] = { file, NULL }; - result = mlt_factory_producer( "inigo", args ); - } - else if ( strstr( file, ".mpg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".mpeg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".jpg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".JPG" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".jpeg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".png" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".tga" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".txt" ) ) - result = mlt_factory_producer( "pango", file ); - - // 2nd Line fallbacks - if ( result == NULL && strstr( file, ".dv" ) ) - result = mlt_factory_producer( "libdv", file ); - else if ( result == NULL && strstr( file, ".dif" ) ) - result = mlt_factory_producer( "libdv", file ); - - // 3rd line fallbacks - if ( result == NULL ) - result = mlt_factory_producer( "ffmpeg", file ); - - // Now store the result - mlt_properties_set_data( properties, file, result, 0, ( mlt_destructor )mlt_producer_close, NULL ); - } - - return result; -} - -/** Update the generation count. -*/ - -static void update_generation( miracle_unit unit ) -{ - mlt_properties properties = unit->properties; - int generation = mlt_properties_get_int( properties, "generation" ); - mlt_properties_set_int( properties, "generation", ++ generation ); -} - -/** Wipe all clips on the playlist for this unit. -*/ - -static void clear_unit( miracle_unit unit ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_producer producer = mlt_playlist_producer( playlist ); - - mlt_playlist_clear( playlist ); - mlt_producer_seek( producer, 0 ); - - if ( unit->old_producers != NULL ) - mlt_properties_close( unit->old_producers ); - unit->old_producers = unit->producers; - unit->producers = mlt_properties_new( ); - - update_generation( unit ); -} - -/** Generate a report on all loaded clips. -*/ - -void miracle_unit_report_list( miracle_unit unit, valerie_response response ) -{ - int i; - mlt_properties properties = unit->properties; - int generation = mlt_properties_get_int( properties, "generation" ); - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - - valerie_response_printf( response, 1024, "%d\n", generation ); - - for ( i = 0; i < mlt_playlist_count( playlist ); i ++ ) - { - mlt_playlist_clip_info info; - mlt_playlist_get_clip_info( playlist , &info, i ); - valerie_response_printf( response, 10240, "%d \"%s\" %lld %lld %lld %lld %.2f\n", - i, info.resource, - info.frame_in, - info.frame_out, - info.frame_count, - info.length, - info.fps ); - } -} - -/** Load a clip into the unit clearing existing play list. - - \todo error handling - \param unit A miracle_unit handle. - \param clip The absolute file name of the clip to load. - \param in The starting frame (-1 for 0) - \param out The ending frame (-1 for maximum) -*/ - -valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ) -{ - // Have to clear the unit first - clear_unit( unit ); - - // Now try to create an producer - mlt_producer instance = create_producer( unit, clip ); - - if ( instance != NULL ) - { - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); - miracle_log( LOG_DEBUG, "loaded clip %s", clip ); - miracle_unit_status_communicate( unit ); - return valerie_ok; - } - - return valerie_invalid_file; -} - -valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ) -{ - mlt_producer instance = create_producer( unit, clip ); - - if ( instance != NULL ) - { - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_insert( playlist, instance, index, in, out ); - miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index ); - update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; - } - - return valerie_invalid_file; -} - -valerie_error_code miracle_unit_remove( miracle_unit unit, int index ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_remove( playlist, index ); - miracle_log( LOG_DEBUG, "removed clip at %d", index ); - update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; -} - -valerie_error_code miracle_unit_clean( miracle_unit unit ) -{ - clear_unit( unit ); - miracle_log( LOG_DEBUG, "Cleaned playlist" ); - miracle_unit_status_communicate( unit ); - return valerie_ok; -} - -valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_move( playlist, src, dest ); - miracle_log( LOG_DEBUG, "moved clip %d to %d", src, dest ); - update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; -} - -/** Add a clip to the unit play list. - - \todo error handling - \param unit A miracle_unit handle. - \param clip The absolute file name of the clip to load. - \param in The starting frame (-1 for 0) - \param out The ending frame (-1 for maximum) -*/ - -valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ) -{ - mlt_producer instance = create_producer( unit, clip ); - - if ( instance != NULL ) - { - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_append_io( playlist, instance, in, out ); - miracle_log( LOG_DEBUG, "appended clip %s", clip ); - update_generation( unit ); - miracle_unit_status_communicate( unit ); - return valerie_ok; - } - - return valerie_invalid_file; -} - -/** Start playing the unit. - - \todo error handling - \param unit A miracle_unit handle. - \param speed An integer that specifies the playback rate as a - percentage multiplied by 100. -*/ - -void miracle_unit_play( miracle_unit_t *unit, int speed ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_producer producer = mlt_playlist_producer( playlist ); - mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); - mlt_producer_set_speed( producer, ( double )speed / 1000 ); - mlt_consumer_start( consumer ); - miracle_unit_status_communicate( unit ); -} - -/** Stop playback. - - Terminates the dv_pump and halts dv1394 transmission. - - \param unit A miracle_unit handle. -*/ - -void miracle_unit_terminate( miracle_unit unit ) -{ - mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); - mlt_consumer_stop( consumer ); - miracle_unit_status_communicate( unit ); -} - -/** Query the status of unit playback. - - \param unit A miracle_unit handle. - \return 1 if the unit is not playing, 0 if playing. -*/ - -int miracle_unit_has_terminated( miracle_unit unit ) -{ - mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL ); - return mlt_consumer_is_stopped( consumer ); -} - -/** Transfer the currently loaded clip to another unit -*/ - -int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ) -{ - return 0; -} - -/** Determine if unit is offline. -*/ - -int miracle_unit_is_offline( miracle_unit unit ) -{ - return 0; -} - -/** Obtain the status for a given unit -*/ - -int miracle_unit_get_status( miracle_unit unit, valerie_status status ) -{ - int error = unit == NULL; - - memset( status, 0, sizeof( valerie_status_t ) ); - - if ( !error ) - { - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_producer producer = mlt_playlist_producer( playlist ); - mlt_producer clip = mlt_playlist_current( playlist ); - - mlt_playlist_clip_info info; - int clip_index = mlt_playlist_current_clip( playlist ); - mlt_playlist_get_clip_info( playlist, &info, clip_index ); - - if ( info.resource != NULL && strcmp( info.resource, "" ) ) - { - strncpy( status->clip, info.resource, sizeof( status->clip ) ); - status->speed = (int)( mlt_producer_get_speed( producer ) * 1000.0 ); - status->fps = mlt_producer_get_fps( producer ); - status->in = info.frame_in; - status->out = info.frame_out; - status->position = mlt_producer_position( clip ); - status->length = mlt_producer_get_length( clip ); - strncpy( status->tail_clip, info.resource, sizeof( status->tail_clip ) ); - status->tail_in = info.frame_in; - status->tail_out = info.frame_out; - status->tail_position = mlt_producer_position( clip ); - status->tail_length = mlt_producer_get_length( clip ); - status->clip_index = mlt_playlist_current_clip( playlist ); - status->seek_flag = 1; - } - - status->generation = mlt_properties_get_int( properties, "generation" ); - - if ( miracle_unit_has_terminated( unit ) ) - status->status = unit_stopped; - else if ( !strcmp( status->clip, "" ) ) - status->status = unit_not_loaded; - else if ( status->speed == 0 ) - status->status = unit_paused; - else - status->status = unit_playing; - } - else - { - status->status = unit_undefined; - } - - status->unit = mlt_properties_get_int( unit->properties, "unit" ); - - return error; -} - -/** Change position in the playlist. -*/ - -void miracle_unit_change_position( miracle_unit unit, int clip, int64_t position ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_producer producer = mlt_playlist_producer( playlist ); - mlt_playlist_clip_info info; - - if ( clip < 0 ) - { - clip = 0; - position = 0; - } - else if ( clip >= mlt_playlist_count( playlist ) ) - { - clip = mlt_playlist_count( playlist ) - 1; - position = LONG_MAX; - } - - if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 ) - { - int64_t frame_start = info.start; - int64_t frame_offset = position; - - if ( frame_offset < 0 ) - frame_offset = info.frame_out; - if ( frame_offset < info.frame_in ) - frame_offset = info.frame_in; - if ( frame_offset >= info.frame_out ) - frame_offset = info.frame_out; - - mlt_producer_seek( producer, frame_start + frame_offset - info.frame_in ); - } - - miracle_unit_status_communicate( unit ); -} - -/** Get the index of the current clip. -*/ - -int miracle_unit_get_current_clip( miracle_unit unit ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - int clip_index = mlt_playlist_current_clip( playlist ); - return clip_index; -} - -/** Set a clip's in point -*/ - -int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_clip_info info; - int error = mlt_playlist_get_clip_info( playlist, &info, index ); - - if ( error == 0 ) - { - miracle_unit_play( unit, 0 ); - error = mlt_playlist_resize_clip( playlist, index, position, info.frame_out ); - update_generation( unit ); - miracle_unit_change_position( unit, index, 0 ); - } - - return error; -} - -/** Set a clip's out point. -*/ - -int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_playlist_clip_info info; - int error = mlt_playlist_get_clip_info( playlist, &info, index ); - - if ( error == 0 ) - { - miracle_unit_play( unit, 0 ); - error = mlt_playlist_resize_clip( playlist, index, info.frame_in, position ); - update_generation( unit ); - miracle_unit_status_communicate( unit ); - miracle_unit_change_position( unit, index, -1 ); - } - - return error; -} - -/** Step by specified position. -*/ - -void miracle_unit_step( miracle_unit unit, int64_t offset ) -{ - mlt_properties properties = unit->properties; - mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL ); - mlt_producer producer = mlt_playlist_producer( playlist ); - mlt_position position = mlt_producer_frame( producer ); - mlt_producer_seek( producer, position + offset ); -} - -/** Set the unit's clip mode regarding in and out points. -*/ - -//void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ) -//{ - //dv_player player = miracle_unit_get_dv_player( unit ); - //if ( player != NULL ) - //dv_player_set_clip_mode( player, mode ); - //miracle_unit_status_communicate( unit ); -//} - -/** Get the unit's clip mode regarding in and out points. -*/ - -//dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ) -//{ - //dv_player player = miracle_unit_get_dv_player( unit ); - //return dv_player_get_clip_mode( player ); -//} - -/** Set the unit's clip mode regarding eof handling. -*/ - -//void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action action ) -//{ - //dv_player player = miracle_unit_get_dv_player( unit ); - //dv_player_set_eof_action( player, action ); - //miracle_unit_status_communicate( unit ); -//} - -/** Get the unit's clip mode regarding eof handling. -*/ - -//dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ) -//{ - //dv_player player = miracle_unit_get_dv_player( unit ); - //return dv_player_get_eof_action( player ); -//} - -int miracle_unit_set( miracle_unit unit, char *name_value ) -{ - mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL ); - mlt_properties properties = mlt_playlist_properties( playlist ); - return mlt_properties_parse( properties, name_value ); -} - -char *miracle_unit_get( miracle_unit unit, char *name ) -{ - mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL ); - mlt_properties properties = mlt_playlist_properties( playlist ); - return mlt_properties_get( properties, name ); -} - -/** Release the unit - - \todo error handling - \param unit A miracle_unit handle. -*/ - -void miracle_unit_close( miracle_unit unit ) -{ - if ( unit != NULL ) - { - miracle_log( LOG_DEBUG, "closing unit..." ); - if ( unit->old_producers != NULL ) - mlt_properties_close( unit->old_producers ); - mlt_properties_close( unit->properties ); - mlt_properties_close( unit->producers ); - free( unit ); - miracle_log( LOG_DEBUG, "... unit closed." ); - } -} - diff --git a/mlt/src/miracle/miracle_unit.h b/mlt/src/miracle/miracle_unit.h deleted file mode 100644 index 9cf2663..0000000 --- a/mlt/src/miracle/miracle_unit.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * dvunit.h -- DV Transmission Unit Header - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DV_UNIT_H_ -#define _DV_UNIT_H_ - -#include - -#include -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -typedef struct -{ - mlt_properties properties; - mlt_properties producers; - mlt_properties old_producers; -} -miracle_unit_t, *miracle_unit; - -extern miracle_unit miracle_unit_init( int index, char *arg ); -extern void miracle_unit_report_list( miracle_unit unit, valerie_response response ); -extern void miracle_unit_allow_stdin( miracle_unit unit, int flag ); -extern valerie_error_code miracle_unit_load( miracle_unit unit, char *clip, int64_t in, int64_t out, int flush ); -extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int64_t in, int64_t out ); -extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int64_t in, int64_t out ); -extern valerie_error_code miracle_unit_remove( miracle_unit unit, int index ); -extern valerie_error_code miracle_unit_clean( miracle_unit unit ); -extern valerie_error_code miracle_unit_move( miracle_unit unit, int src, int dest ); -extern int miracle_unit_transfer( miracle_unit dest_unit, miracle_unit src_unit ); -extern void miracle_unit_play( miracle_unit_t *unit, int speed ); -extern void miracle_unit_terminate( miracle_unit ); -extern int miracle_unit_has_terminated( miracle_unit ); -extern int miracle_unit_get_nodeid( miracle_unit unit ); -extern int miracle_unit_get_channel( miracle_unit unit ); -extern int miracle_unit_is_offline( miracle_unit unit ); -extern void miracle_unit_set_notifier( miracle_unit, valerie_notifier, char * ); -extern int miracle_unit_get_status( miracle_unit, valerie_status ); -extern void miracle_unit_change_position( miracle_unit, int, int64_t position ); -extern void miracle_unit_change_speed( miracle_unit unit, int speed ); -extern int miracle_unit_set_clip_in( miracle_unit unit, int index, int64_t position ); -extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int64_t position ); -//extern void miracle_unit_set_mode( miracle_unit unit, dv_player_clip_mode mode ); -//extern dv_player_clip_mode miracle_unit_get_mode( miracle_unit unit ); -//extern void miracle_unit_set_eof_action( miracle_unit unit, dv_player_eof_action mode ); -//extern dv_player_eof_action miracle_unit_get_eof_action( miracle_unit unit ); -extern void miracle_unit_step( miracle_unit unit, int64_t offset ); -extern void miracle_unit_close( miracle_unit unit ); -extern void miracle_unit_suspend( miracle_unit ); -extern void miracle_unit_restore( miracle_unit ); -extern int miracle_unit_set( miracle_unit, char *name_value ); -extern char * miracle_unit_get( miracle_unit, char *name ); -extern int miracle_unit_get_current_clip( miracle_unit ); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/miracle/miracle_unit_commands.c b/mlt/src/miracle/miracle_unit_commands.c deleted file mode 100644 index f38ff3a..0000000 --- a/mlt/src/miracle/miracle_unit_commands.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * unit_commands.c - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#include "miracle_unit.h" -#include "miracle_commands.h" -#include "miracle_log.h" - -int miracle_load( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - char *filename = (char*) cmd_arg->argument; - char fullname[1024]; - int flush = 1; - - if ( filename[0] == '!' ) - { - flush = 0; - filename ++; - } - - if ( filename[0] == '/' ) - filename++; - - snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename ); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - int64_t in = -1, out = -1; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) - { - in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); - } - if ( miracle_unit_load( unit, fullname, in, out, flush ) != valerie_ok ) - return RESPONSE_BAD_FILE; - } - return RESPONSE_SUCCESS; -} - -int miracle_list( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit( cmd_arg->unit ); - - if ( unit != NULL ) - { - miracle_unit_report_list( unit, cmd_arg->response ); - return RESPONSE_SUCCESS; - } - - return RESPONSE_INVALID_UNIT; -} - -static int parse_clip( command_argument cmd_arg, int arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - int clip = miracle_unit_get_current_clip( unit ); - - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) > arg ) - { - char *token = valerie_tokeniser_get_string( cmd_arg->tokeniser, arg ); - if ( token[ 0 ] == '+' ) - clip += atoi( token + 1 ); - else if ( token[ 0 ] == '-' ) - clip -= atoi( token + 1 ); - else - clip = atoi( token ); - } - - return clip; -} - -int miracle_insert( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - char *filename = (char*) cmd_arg->argument; - char fullname[1024]; - - if ( filename[0] == '/' ) - filename++; - - snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename ); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - long in = -1, out = -1; - int index = parse_clip( cmd_arg, 3 ); - - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 6 ) - { - in = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); - out = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 5 ) ); - } - - switch( miracle_unit_insert( unit, fullname, index, in, out ) ) - { - case valerie_ok: - return RESPONSE_SUCCESS; - default: - return RESPONSE_BAD_FILE; - } - } - return RESPONSE_SUCCESS; -} - -int miracle_remove( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - int index = parse_clip( cmd_arg, 2 ); - - if ( miracle_unit_remove( unit, index ) != valerie_ok ) - return RESPONSE_BAD_FILE; - } - return RESPONSE_SUCCESS; -} - -int miracle_clean( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - if ( miracle_unit_clean( unit ) != valerie_ok ) - return RESPONSE_BAD_FILE; - } - return RESPONSE_SUCCESS; -} - -int miracle_move( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - - if ( unit != NULL ) - { - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) > 2 ) - { - int src = parse_clip( cmd_arg, 2 ); - int dest = parse_clip( cmd_arg, 3 ); - - if ( miracle_unit_move( unit, src, dest ) != valerie_ok ) - return RESPONSE_BAD_FILE; - } - else - { - return RESPONSE_MISSING_ARG; - } - } - else - { - return RESPONSE_INVALID_UNIT; - } - - return RESPONSE_SUCCESS; -} - -int miracle_append( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - char *filename = (char*) cmd_arg->argument; - char fullname[1024]; - - if ( filename[0] == '/' ) - filename++; - - snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename ); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - int64_t in = -1, out = -1; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 5 ) - { - in = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 3 ) ); - out = atol( valerie_tokeniser_get_string( cmd_arg->tokeniser, 4 ) ); - } - switch ( miracle_unit_append( unit, fullname, in, out ) ) - { - case valerie_ok: - return RESPONSE_SUCCESS; - default: - return RESPONSE_BAD_FILE; - } - } - return RESPONSE_SUCCESS; -} - -int miracle_play( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - - if ( unit == NULL ) - { - return RESPONSE_INVALID_UNIT; - } - else - { - int speed = 1000; - if ( valerie_tokeniser_count( cmd_arg->tokeniser ) == 3 ) - speed = atoi( valerie_tokeniser_get_string( cmd_arg->tokeniser, 2 ) ); - miracle_unit_play( unit, speed ); - } - - return RESPONSE_SUCCESS; -} - -int miracle_stop( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - { - miracle_unit_play( unit, 0 ); - miracle_unit_terminate( unit ); - } - return RESPONSE_SUCCESS; -} - -int miracle_pause( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - miracle_unit_play( unit, 0 ); - return RESPONSE_SUCCESS; -} - -int miracle_rewind( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - miracle_unit_play( unit, -2000 ); - return RESPONSE_SUCCESS; -} - -int miracle_step( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - { - miracle_unit_play( unit, 0 ); - miracle_unit_step( unit, *(int*) cmd_arg->argument ); - } - return RESPONSE_SUCCESS; -} - -int miracle_goto( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - int clip = parse_clip( cmd_arg, 3 ); - - if (unit == NULL || miracle_unit_is_offline(unit)) - return RESPONSE_INVALID_UNIT; - else - miracle_unit_change_position( unit, clip, *(int*) cmd_arg->argument ); - return RESPONSE_SUCCESS; -} - -int miracle_ff( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - miracle_unit_play( unit, 2000 ); - return RESPONSE_SUCCESS; -} - -int miracle_set_in_point( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - int clip = parse_clip( cmd_arg, 3 ); - - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - { - int position = *(int *) cmd_arg->argument; - - switch( miracle_unit_set_clip_in( unit, clip, position ) ) - { - case -1: - return RESPONSE_BAD_FILE; - case -2: - return RESPONSE_OUT_OF_RANGE; - } - } - return RESPONSE_SUCCESS; -} - -int miracle_set_out_point( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - int clip = parse_clip( cmd_arg, 3 ); - - if ( unit == NULL ) - return RESPONSE_INVALID_UNIT; - else - { - int position = *(int *) cmd_arg->argument; - - switch( miracle_unit_set_clip_out( unit, clip, position ) ) - { - case -1: - return RESPONSE_BAD_FILE; - case -2: - return RESPONSE_OUT_OF_RANGE; - } - } - - return RESPONSE_SUCCESS; -} - -int miracle_get_unit_status( command_argument cmd_arg ) -{ - valerie_status_t status; - int error = miracle_unit_get_status( miracle_get_unit( cmd_arg->unit ), &status ); - - if ( error == -1 ) - return RESPONSE_INVALID_UNIT; - else - { - char text[ 10240 ]; - valerie_response_printf( cmd_arg->response, sizeof( text ), valerie_status_serialise( &status, text, sizeof( text ) ) ); - return RESPONSE_SUCCESS_1; - } - return 0; -} - - -int miracle_set_unit_property( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - char *name_value = (char*) cmd_arg->argument; - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else - miracle_unit_set( unit, name_value ); - return RESPONSE_SUCCESS; -} - -int miracle_get_unit_property( command_argument cmd_arg ) -{ - miracle_unit unit = miracle_get_unit(cmd_arg->unit); - char *name = (char*) cmd_arg->argument; - char *value = miracle_unit_get( unit, name ); - if (unit == NULL) - return RESPONSE_INVALID_UNIT; - else if ( value != NULL ) - valerie_response_printf( cmd_arg->response, 1024, "%s\n", value ); - return RESPONSE_SUCCESS; -} - - -int miracle_transfer( command_argument cmd_arg ) -{ - /* - dv_unit src_unit = miracle_get_unit(cmd_arg->unit); - int dest_unit_id = -1; - char *string = (char*) cmd_arg->argument; - if ( string != NULL && ( string[ 0 ] == 'U' || string[ 0 ] == 'u' ) && strlen( string ) > 1 ) - dest_unit_id = atoi( string + 1 ); - - if ( src_unit != NULL && dest_unit_id != -1 ) - { - dv_unit dest_unit = miracle_get_unit( dest_unit_id ); - if ( dest_unit != NULL && !dv_unit_is_offline(dest_unit) && dest_unit != src_unit ) - { - dv_unit_transfer( dest_unit, src_unit ); - return RESPONSE_SUCCESS; - } - } - */ - return RESPONSE_INVALID_UNIT; -} diff --git a/mlt/src/miracle/miracle_unit_commands.h b/mlt/src/miracle/miracle_unit_commands.h deleted file mode 100644 index 575ff1b..0000000 --- a/mlt/src/miracle/miracle_unit_commands.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * unit_commands.h - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - - -#ifndef _UNIT_COMMANDS_H_ -#define _UNIT_COMMANDS_H_ - -#include "miracle_connection.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern response_codes miracle_list( command_argument ); -extern response_codes miracle_load( command_argument ); -extern response_codes miracle_insert( command_argument ); -extern response_codes miracle_remove( command_argument ); -extern response_codes miracle_clean( command_argument ); -extern response_codes miracle_move( command_argument ); -extern response_codes miracle_append( command_argument ); -extern response_codes miracle_play( command_argument ); -extern response_codes miracle_stop( command_argument ); -extern response_codes miracle_pause( command_argument ); -extern response_codes miracle_rewind( command_argument ); -extern response_codes miracle_step( command_argument ); -extern response_codes miracle_goto( command_argument ); -extern response_codes miracle_ff( command_argument ); -extern response_codes miracle_set_in_point( command_argument ); -extern response_codes miracle_set_out_point( command_argument ); -extern response_codes miracle_get_unit_status( command_argument ); -extern response_codes miracle_set_unit_property( command_argument ); -extern response_codes miracle_get_unit_property( command_argument ); -extern response_codes miracle_transfer( command_argument ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/modules/Makefile b/mlt/src/modules/Makefile deleted file mode 100644 index 45f7a31..0000000 --- a/mlt/src/modules/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -SUBDIRS = core gtk2 dv sdl mainconcept bluefish ffmpeg resample inigo westley - -all clean depend install: - list='$(SUBDIRS)'; \ - for subdir in $$list; do \ - if [ -f $$subdir/Makefile ] ; \ - then [ ! -f disable-$$subdir ] && $(MAKE) -C $$subdir $@; \ - fi \ - done - -dist-clean: - rm -f consumers.dat filters.dat producers.dat transitions.dat; \ - list='$(SUBDIRS)'; \ - for subdir in $$list; do \ - if [ -f $$subdir/Makefile ] ; \ - then [ ! -f disable-$$subdir ] && $(MAKE) -C $$subdir $@; \ - fi \ - done - diff --git a/mlt/src/modules/configure b/mlt/src/modules/configure deleted file mode 100755 index b33bc37..0000000 --- a/mlt/src/modules/configure +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Clean up disables if not in help mode -[ "$help" != "1" ] && rm -f disable-* producers.dat filters.dat transitions.dat consumers.dat - -# Iterate through arguments -for i in $* -do - case $i in - --disable-* ) touch disable-${i#--disable-} ;; - esac -done - -# Iterate through each of the components -for i in * -do - if [ -x $i/configure -a \( "$help" = "1" -o ! -f disable-$i \) ] - then - echo "Configuring modules/$i:" - pushd $i > /dev/null - ./configure $@ - [ $? != 0 ] && exit 1 - popd > /dev/null - fi -done - diff --git a/mlt/src/modules/core/Makefile b/mlt/src/modules/core/Makefile deleted file mode 100644 index 4c458d1..0000000 --- a/mlt/src/modules/core/Makefile +++ /dev/null @@ -1,35 +0,0 @@ - -TARGET = ../libmltcore.so - -OBJS = factory.o \ - producer_ppm.o \ - filter_deinterlace.o \ - filter_greyscale.o \ - filter_gamma.o \ - filter_resize.o \ - transition_composite.o \ - transition_luma.o \ - transition_mix.o \ - filter_volume.o - -CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/core/configure b/mlt/src/modules/core/configure deleted file mode 100755 index baedbae..0000000 --- a/mlt/src/modules/core/configure +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -ppm libmltcore.so -EOF - -cat << EOF >> ../filters.dat -deinterlace libmltcore.so -gamma libmltcore.so -greyscale libmltcore.so -resize libmltcore.so -volume libmltcore.so -EOF - -cat << EOF >> ../transitions.dat -composite libmltcore.so -luma libmltcore.so -mix libmltcore.so -EOF - -fi - diff --git a/mlt/src/modules/core/factory.c b/mlt/src/modules/core/factory.c deleted file mode 100644 index 5353ac2..0000000 --- a/mlt/src/modules/core/factory.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "producer_ppm.h" -#include "filter_deinterlace.h" -#include "filter_greyscale.h" -#include "filter_resize.h" -#include "filter_gamma.h" -#include "transition_composite.h" -#include "transition_luma.h" -#include "transition_mix.h" -#include "filter_volume.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "ppm" ) ) - return producer_ppm_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - if ( !strcmp( id, "deinterlace" ) ) - return filter_deinterlace_init( arg ); - if ( !strcmp( id, "gamma" ) ) - return filter_gamma_init( arg ); - if ( !strcmp( id, "greyscale" ) ) - return filter_greyscale_init( arg ); - if ( !strcmp( id, "resize" ) ) - return filter_resize_init( arg ); - if ( !strcmp( id, "volume" ) ) - return filter_volume_init( arg ); - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - if ( !strcmp( id, "composite" ) ) - return transition_composite_init( arg ); - if ( !strcmp( id, "luma" ) ) - return transition_luma_init( arg ); - if ( !strcmp( id, "mix" ) ) - return transition_mix_init( arg ); - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - return NULL; -} - diff --git a/mlt/src/modules/core/filter_deinterlace.c b/mlt/src/modules/core/filter_deinterlace.c deleted file mode 100644 index 7fc04b6..0000000 --- a/mlt/src/modules/core/filter_deinterlace.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * filter_deinterlace.c -- deinterlace filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_deinterlace.h" - -#include - -#include -#include - -/** Deinterlace class. -*/ - -typedef struct -{ - struct mlt_filter_s parent; -} -filter_deinterlace; - -/* Linear Blend filter - C version contributed by Rogerio Brito. - This algorithm has the same interface as the other functions. - - The destination "screen" (pdst) is constructed from the source - screen (psrc[0]) line by line. - - The i-th line of the destination screen is the average of 3 lines - from the source screen: the (i-1)-th, i-th and (i+1)-th lines, with - the i-th line having weight 2 in the computation. - - Remarks: - * each line on pdst doesn't depend on previous lines; - * due to the way the algorithm is defined, the first & last lines of the - screen aren't deinterlaced. - -*/ -static void deinterlace_yuv( uint8_t *pdst, uint8_t *psrc, int width, int height ) -{ - register int x, y; - register uint8_t *l0, *l1, *l2, *l3; - - l0 = pdst; /* target line */ - l1 = psrc; /* 1st source line */ - l2 = l1 + width; /* 2nd source line = line that follows l1 */ - l3 = l2 + width; /* 3rd source line = line that follows l2 */ - - /* Copy the first line */ - memcpy(l0, l1, width); - l0 += width; - - for (y = 1; y < height-1; ++y) - { - /* computes avg of: l1 + 2*l2 + l3 */ - for (x = 0; x < width; ++x) - l0[x] = (l1[x] + (l2[x]<<1) + l3[x]) >> 2; - - /* updates the line pointers */ - l1 = l2; l2 = l3; l3 += width; - l0 += width; - } - - /* Copy the last line */ - memcpy(l0, l1, width); -} - -/** Do it :-). -*/ - -static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - mlt_frame_get_image( this, image, format, width, height, 1 ); - deinterlace_yuv( *image, *image, *width * 2, *height ); - return 0; -} - -/** Deinterlace filter processing - this should be lazy evaluation here... -*/ - -static mlt_frame deinterlace_process( mlt_filter this, mlt_frame frame ) -{ - mlt_frame_push_get_image( frame, filter_get_image ); - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_deinterlace_init( void *arg ) -{ - filter_deinterlace *this = calloc( sizeof( filter_deinterlace ), 1 ); - if ( this != NULL ) - { - mlt_filter filter = &this->parent; - mlt_filter_init( filter, this ); - filter->process = deinterlace_process; - return &this->parent; - } - return NULL; -} - diff --git a/mlt/src/modules/core/filter_deinterlace.h b/mlt/src/modules/core/filter_deinterlace.h deleted file mode 100644 index cfcd2fc..0000000 --- a/mlt/src/modules/core/filter_deinterlace.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_deinterlace.h -- deinterlace filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_DEINTERLACE_H_ -#define _FILTER_DEINTERLACE_H_ - -#include - -extern mlt_filter filter_deinterlace_init( void *arg ); - -#endif diff --git a/mlt/src/modules/core/filter_gamma.c b/mlt/src/modules/core/filter_gamma.c deleted file mode 100644 index 3387561..0000000 --- a/mlt/src/modules/core/filter_gamma.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * filter_gamma.c -- gamma filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_gamma.h" - -#include - -#include -#include -#include - -/** Do it :-). -*/ - -static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - mlt_frame_get_image( this, image, format, width, height, 1 ); - uint8_t *p = *image; - uint8_t *q = *image + *width * *height * 2; - - // Get the gamma value - double gamma = mlt_properties_get_double( mlt_frame_properties( this ), "gamma" ); - - // Calculate the look up table - double exp = 1 / gamma; - uint8_t lookup[ 256 ]; - int i; - - for( i = 0; i < 256; i ++ ) - lookup[ i ] = ( uint8_t )( pow( ( double )i / 255.0, exp ) * 255 ); - - while ( p != q ) - { - *p = lookup[ *p ]; - p += 2; - } - - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - double gamma = mlt_properties_get_double( mlt_filter_properties( this ), "gamma" ); - gamma = gamma <= 0 ? 2 : gamma; - mlt_frame_push_get_image( frame, filter_get_image ); - mlt_properties_set_double( mlt_frame_properties( frame ), "gamma", gamma ); - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_gamma_init( char *arg ) -{ - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); - if ( this != NULL ) - { - mlt_filter_init( this, NULL ); - this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_filter_properties( this ), "gamma", atof( arg ) ); - } - return this; -} - diff --git a/mlt/src/modules/core/filter_gamma.h b/mlt/src/modules/core/filter_gamma.h deleted file mode 100644 index a969b8a..0000000 --- a/mlt/src/modules/core/filter_gamma.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_gamma.h -- gamma filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_GAMMA_H_ -#define _FILTER_GAMMA_H_ - -#include - -extern mlt_filter filter_gamma_init( char *arg ); - -#endif diff --git a/mlt/src/modules/core/filter_greyscale.c b/mlt/src/modules/core/filter_greyscale.c deleted file mode 100644 index 170ff4f..0000000 --- a/mlt/src/modules/core/filter_greyscale.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * filter_greyscale.c -- greyscale filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_greyscale.h" - -#include - -#include -#include - -/** Greyscale class. -*/ - -typedef struct -{ - struct mlt_filter_s parent; -} -filter_greyscale; - -/** Do it :-). -*/ - -static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - mlt_frame_get_image( this, image, format, width, height, 1 ); - uint8_t *p = *image; - uint8_t *q = *image + *width * *height * 2; - while ( p ++ != q ) - *p ++ = 128; - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - mlt_frame_push_get_image( frame, filter_get_image ); - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_greyscale_init( void *arg ) -{ - filter_greyscale *this = calloc( sizeof( filter_greyscale ), 1 ); - if ( this != NULL ) - { - mlt_filter filter = &this->parent; - mlt_filter_init( filter, this ); - filter->process = filter_process; - } - return ( mlt_filter )this; -} - diff --git a/mlt/src/modules/core/filter_greyscale.h b/mlt/src/modules/core/filter_greyscale.h deleted file mode 100644 index 30515f5..0000000 --- a/mlt/src/modules/core/filter_greyscale.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_greyscale.h -- greyscale filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_GREYSCALE_H_ -#define _FILTER_GREYSCALE_H_ - -#include - -extern mlt_filter filter_greyscale_init( void *arg ); - -#endif diff --git a/mlt/src/modules/core/filter_resize.c b/mlt/src/modules/core/filter_resize.c deleted file mode 100644 index 537ce50..0000000 --- a/mlt/src/modules/core/filter_resize.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * filter_resize.c -- resizing filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_resize.h" - -#include - -#include -#include -#include - -/** Do it :-). -*/ - -static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - int owidth = *width; - int oheight = *height; - mlt_frame_get_image( this, image, format, &owidth, &oheight, 0 ); - if ( *width == 0 ) - *width = 720; - if ( *height == 0 ) - *height = 576; - if ( !strcmp( mlt_properties_get( mlt_frame_properties( this ), "resize.scale" ), "affine" ) ) - *image = mlt_frame_rescale_yuv422( this, *width, *height ); - else - *image = mlt_frame_resize_yuv422( this, *width, *height ); - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - mlt_frame_push_get_image( frame, filter_get_image ); - mlt_properties_set( mlt_frame_properties( frame ), "resize.scale", mlt_properties_get( mlt_filter_properties( this ), "scale" ) ); - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_resize_init( char *arg ) -{ - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); - if ( mlt_filter_init( this, this ) == 0 ) - { - this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set( mlt_filter_properties( this ), "scale", arg ); - else - mlt_properties_set( mlt_filter_properties( this ), "scale", "off" ); - } - return this; -} - diff --git a/mlt/src/modules/core/filter_resize.h b/mlt/src/modules/core/filter_resize.h deleted file mode 100644 index 17c9c19..0000000 --- a/mlt/src/modules/core/filter_resize.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_resize.h -- resizing filter - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_RESIZE_H_ -#define _FILTER_RESIZE_H_ - -#include - -extern mlt_filter filter_resize_init( char *arg ); - -#endif diff --git a/mlt/src/modules/core/filter_volume.c b/mlt/src/modules/core/filter_volume.c deleted file mode 100644 index c0ad4dd..0000000 --- a/mlt/src/modules/core/filter_volume.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * filter_volume.c -- adjust audio volume - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_volume.h" - -#include - -#include -#include - -/** Get the audio. -*/ - -static int filter_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Get the properties of the a frame - mlt_properties properties = mlt_frame_properties( frame ); - double volume = mlt_properties_get_double( properties, "volume" ); - - // Restore the original get_audio - frame->get_audio = mlt_properties_get_data( properties, "volume.get_audio", NULL ); - - // Get the producer's audio - mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); - - // Apply the volume - int i; - for ( i = 0; i < ( *channels * *samples ); i++ ) - (*buffer)[i] *= volume; - - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - mlt_properties properties = mlt_frame_properties( frame ); - - // Propogate the level property - if ( mlt_properties_get( mlt_filter_properties( this ), "volume" ) != NULL ) - mlt_properties_set_double( properties, "volume", - mlt_properties_get_double( mlt_filter_properties( this ), "volume" ) ); - - // Backup the original get_audio (it's still needed) - mlt_properties_set_data( properties, "volume.get_audio", frame->get_audio, 0, NULL, NULL ); - - // Override the get_audio method - frame->get_audio = filter_get_audio; - - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_volume_init( char *arg ) -{ - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); - if ( this != NULL && mlt_filter_init( this, NULL ) == 0 ) - { - this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_filter_properties( this ), "volume", atof( arg ) ); - } - return this; -} - diff --git a/mlt/src/modules/core/filter_volume.h b/mlt/src/modules/core/filter_volume.h deleted file mode 100644 index d5fb569..0000000 --- a/mlt/src/modules/core/filter_volume.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_volume.h -- adjust audio volume - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_VOLUME_H_ -#define _FILTER_VOLUME_H_ - -#include - -extern mlt_filter filter_volume_init( char *arg ); - -#endif diff --git a/mlt/src/modules/core/producer_ppm.c b/mlt/src/modules/core/producer_ppm.c deleted file mode 100644 index c929d25..0000000 --- a/mlt/src/modules/core/producer_ppm.c +++ /dev/null @@ -1,272 +0,0 @@ -/* - * producer_ppm.c -- simple ppm test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_ppm.h" -#include -#include -#include - -typedef struct producer_ppm_s *producer_ppm; - -struct producer_ppm_s -{ - struct mlt_producer_s parent; - char *command; - FILE *video; - FILE *audio; - uint64_t expected; -}; - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ); -static void producer_close( mlt_producer parent ); - -mlt_producer producer_ppm_init( void *command ) -{ - producer_ppm this = calloc( sizeof( struct producer_ppm_s ), 1 ); - if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) - { - mlt_producer producer = &this->parent; - mlt_properties properties = mlt_producer_properties( producer ); - - producer->get_frame = producer_get_frame; - producer->close = producer_close; - - if ( command != NULL ) - { - mlt_properties_set( properties, "resource", command ); - this->command = strdup( command ); - } - else - { - mlt_properties_set( properties, "resource", "ppm test" ); - } - - return producer; - } - free( this ); - return NULL; -} - -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - if ( mlt_properties_get_int( properties, "has_image" ) ) - { - // Get the RGB image - uint8_t *rgb = mlt_properties_get_data( properties, "image", NULL ); - - // Get width and height - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - - // Convert to requested format - if ( *format == mlt_image_yuv422 ) - { - uint8_t *image = malloc( *width * *height * 2 ); - mlt_convert_rgb24_to_yuv422( rgb, *width, *height, *width * 3, image ); - mlt_properties_set_data( properties, "image", image, *width * *height * 2, free, NULL ); - *buffer = image; - } - else if ( *format == mlt_image_rgb24 ) - { - *buffer = rgb; - } - } - else - { - mlt_frame_get_image( this, buffer, format, width, height, writable ); - } - - return 0; -} - -FILE *producer_ppm_run_video( producer_ppm this ) -{ - if ( this->video == NULL ) - { - if ( this->command == NULL ) - { - this->video = popen( "image2raw -k -r 25 -ppm /usr/share/pixmaps/*.png", "r" ); - } - else - { - char command[ 1024 ]; - float fps = mlt_producer_get_fps( &this->parent ); - float position = mlt_producer_position( &this->parent ); - sprintf( command, "ffmpeg -i \"%s\" -ss %f -f imagepipe -r %f -img ppm - 2>/dev/null", this->command, position, fps ); - this->video = popen( command, "r" ); - } - } - return this->video; -} - -FILE *producer_ppm_run_audio( producer_ppm this ) -{ - if ( this->audio == NULL ) - { - if ( this->command != NULL ) - { - char command[ 1024 ]; - float position = mlt_producer_position( &this->parent ); - sprintf( command, "ffmpeg -i \"%s\" -ss %f -f s16le -ar 48000 -ac 2 - 2>/dev/null", this->command, position ); - this->audio = popen( command, "r" ); - } - } - return this->audio; -} - -static void producer_ppm_position( producer_ppm this, uint64_t requested ) -{ - if ( requested != this->expected ) - { - if ( this->video != NULL ) - pclose( this->video ); - this->video = NULL; - if ( this->audio != NULL ) - pclose( this->audio ); - this->audio = NULL; - } - - // This is the next frame we expect - this->expected = mlt_producer_frame( &this->parent ) + 1; - - // Open the pipe - this->video = producer_ppm_run_video( this ); - - // Open the audio pipe - this->audio = producer_ppm_run_audio( this ); - -} - -static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - FILE *pipe = mlt_properties_get_data( properties, "audio.pipe", NULL ); - - *frequency = 48000; - *channels = 2; - *samples = 1920; - - // Size - int size = *samples * *channels * 2; - - // Allocate an image - *buffer = malloc( size ); - - // Read it - if ( pipe != NULL ) - fread( *buffer, size, 1, pipe ); - else - memset( *buffer, 0, size ); - - // Pass the data on the frame properties - mlt_properties_set_data( properties, "audio", *buffer, size, free, NULL ); - - return 0; -} - -static int read_ppm_header( FILE *video, int *width, int *height ) -{ - int count = 0; - { - char temp[ 132 ]; - fgets( temp, 132, video ); - fgets( temp, 132, video ); - count += sscanf( temp, "%d %d", width, height ); - fgets( temp, 132, video ); - } - return count; -} - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - producer_ppm this = producer->child; - int width; - int height; - - // Construct a test frame - *frame = mlt_frame_init( ); - - // Are we at the position expected? - producer_ppm_position( this, mlt_producer_frame( producer ) ); - - // Get the frames properties - mlt_properties properties = mlt_frame_properties( *frame ); - - FILE *video = this->video; - FILE *audio = this->audio; - - // Read the video - if ( video != NULL && read_ppm_header( video, &width, &height ) == 2 ) - { - - // Allocate an image - uint8_t *image = malloc( width * height * 3 ); - - // Read it - fread( image, width * height * 3, 1, video ); - - // Pass the data on the frame properties - mlt_properties_set_data( properties, "image", image, width * height * 3, free, NULL ); - mlt_properties_set_int( properties, "width", width ); - mlt_properties_set_int( properties, "height", height ); - mlt_properties_set_int( properties, "has_image", 1 ); - - // Push the image callback - mlt_frame_push_get_image( *frame, producer_get_image ); - } - else - { - // Push the image callback - mlt_frame_push_get_image( *frame, producer_get_image ); - } - - // Set the audio pipe - mlt_properties_set_data( properties, "audio.pipe", audio, 0, NULL, NULL ); - - // Hmm - register audio callback - ( *frame )->get_audio = producer_get_audio; - - // Update timecode on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); - - // Calculate the next timecode - mlt_producer_prepare_next( producer ); - - return 0; -} - -static void producer_close( mlt_producer parent ) -{ - producer_ppm this = parent->child; - if ( this->video ) - pclose( this->video ); - if ( this->audio ) - pclose( this->audio ); - free( this->command ); - parent->close = NULL; - mlt_producer_close( parent ); - free( this ); -} - diff --git a/mlt/src/modules/core/producer_ppm.h b/mlt/src/modules/core/producer_ppm.h deleted file mode 100644 index 205d546..0000000 --- a/mlt/src/modules/core/producer_ppm.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * producer_ppm.h -- simple ppm test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_PPM_H_ -#define _PRODUCER_PPM_H_ - -#include -#include - -extern mlt_producer producer_ppm_init( void *command ); - -#endif diff --git a/mlt/src/modules/core/transition_composite.c b/mlt/src/modules/core/transition_composite.c deleted file mode 100644 index 7a32dd5..0000000 --- a/mlt/src/modules/core/transition_composite.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * transition_composite.c -- compose one image over another using alpha channel - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "transition_composite.h" -#include - -#include -#include - -/** Get the image. -*/ - -static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Get the properties of the a frame - mlt_properties a_props = mlt_frame_properties( this ); - - // Get the b frame from the stack - mlt_frame b_frame = mlt_frame_pop_frame( this ); - - if ( b_frame != NULL ) - { - // Get the properties of the b frame - mlt_properties b_props = mlt_frame_properties( b_frame ); - - // Arbitrary composite defaults - int x = 0; - int y = 0; - double mix = 1.0; - - // Override from b frame properties if provided - if ( mlt_properties_get( b_props, "x" ) != NULL ) - x = mlt_properties_get_int( b_props, "x" ); - if ( mlt_properties_get( b_props, "y" ) != NULL ) - y = mlt_properties_get_int( b_props, "y" ); - if ( mlt_properties_get( b_props, "image.mix" ) != NULL ) - mix = mlt_properties_get_double( b_props, "image.mix" ); - - // Composite the b_frame on the a_frame - mlt_frame_composite_yuv( this, b_frame, x, y, mix ); - - // Extract the a_frame image info - *width = mlt_properties_get_int( a_props, "width" ); - *height = mlt_properties_get_int( a_props, "height" ); - *image = mlt_properties_get_data( a_props, "image", NULL ); - } - else if ( a_props != NULL ) - { - // Extract the a_frame image info - *width = mlt_properties_get_int( a_props, "width" ); - *height = mlt_properties_get_int( a_props, "height" ); - *image = mlt_properties_get_data( a_props, "image", NULL ); - } - - return 0; -} - -/** Composition transition processing. -*/ - -static mlt_frame composite_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame ) -{ - // Propogate the transition properties to the b frame - mlt_properties properties = mlt_transition_properties( this ); - mlt_properties b_props = mlt_frame_properties( b_frame ); - - if ( mlt_properties_get( properties, "x" ) != NULL ) - mlt_properties_set_int( b_props, "x", mlt_properties_get_int( properties, "x" ) ); - if ( mlt_properties_get( properties, "y" ) != NULL ) - mlt_properties_set_int( b_props, "y", mlt_properties_get_int( properties, "y" ) ); - - // Only if mix is specified, otherwise a producer may set the mix - if ( mlt_properties_get( properties, "mix" ) != NULL ) - { - // A negative means dissolve - if ( mlt_properties_get_double( properties, "mix" ) < 0 ) - { - // Determine the time position of this frame in the transition duration - mlt_position in = mlt_transition_get_in( this ); - mlt_position out = mlt_transition_get_out( this ); - mlt_position time = mlt_frame_get_position( b_frame ); - double mix = ( double )( time - in ) / ( double )( out - in + 1 ); - mlt_properties_set_double( b_props, "image.mix", mix ); - } - else - mlt_properties_set_double( b_props, "image.mix", mlt_properties_get_double( properties, "mix" ) ); - } - - mlt_frame_push_get_image( a_frame, transition_get_image ); - mlt_frame_push_frame( a_frame, b_frame ); - - return a_frame; -} - -/** Constructor for the filter. -*/ - -mlt_transition transition_composite_init( char *arg ) -{ - mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 ); - if ( this != NULL && mlt_transition_init( this, NULL ) == 0 ) - { - this->process = composite_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) ); - } - return this; -} - diff --git a/mlt/src/modules/core/transition_composite.h b/mlt/src/modules/core/transition_composite.h deleted file mode 100644 index 769ddfd..0000000 --- a/mlt/src/modules/core/transition_composite.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * transition_composite.h -- compose one image over another using alpha channel - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _TRANSITION_COMPOSITE_H_ -#define _TRANSITION_COMPOSITE_H_ - -#include - -extern mlt_transition transition_composite_init( char *arg ); - -#endif diff --git a/mlt/src/modules/core/transition_luma.c b/mlt/src/modules/core/transition_luma.c deleted file mode 100644 index 1aabc94..0000000 --- a/mlt/src/modules/core/transition_luma.c +++ /dev/null @@ -1,358 +0,0 @@ -/* - * transition_luma.c -- a generic dissolve/wipe processor - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "transition_luma.h" -#include - -#include -#include -#include -#include - -/** Luma class. -*/ - -typedef struct -{ - struct mlt_transition_s parent; - char *filename; - int width; - int height; - float *bitmap; -} -transition_luma; - - -// forward declarations -static void transition_close( mlt_transition parent ); - - -// image processing functions - -static inline float smoothstep( float edge1, float edge2, float a ) -{ - if ( a < edge1 ) - return 0.0; - - if ( a >= edge2 ) - return 1.0; - - a = ( a - edge1 ) / ( edge2 - edge1 ); - - return ( a * a * ( 3 - 2 * a ) ); -} - -/** powerful stuff - - \param field_order -1 = progressive, 0 = lower field first, 1 = top field first -*/ -static void luma_composite( mlt_frame this, mlt_frame b_frame, int luma_width, int luma_height, - float *luma_bitmap, float pos, float frame_delta, float softness, int field_order ) -{ - int width_src, height_src; - int width_dest, height_dest; - mlt_image_format format_src, format_dest; - uint8_t *p_src, *p_dest; - int i, j; - int stride_src; - int stride_dest; - float weight = 0; - int field; - - format_src = mlt_image_yuv422; - format_dest = mlt_image_yuv422; - - mlt_frame_get_image( this, &p_dest, &format_dest, &width_dest, &height_dest, 1 /* writable */ ); - mlt_frame_get_image( b_frame, &p_src, &format_src, &width_src, &height_src, 0 /* writable */ ); - - stride_src = width_src * 2; - stride_dest = width_dest * 2; - - // Offset the position based on which field we're looking at ... - float field_pos[ 2 ]; - field_pos[ 0 ] = pos + ( ( field_order == 0 ? 1 : 0 ) * frame_delta * 0.5 ); - field_pos[ 1 ] = pos + ( ( field_order == 0 ? 0 : 1 ) * frame_delta * 0.5 ); - - // adjust the position for the softness level - field_pos[ 0 ] *= ( 1.0 + softness ); - field_pos[ 1 ] *= ( 1.0 + softness ); - - uint8_t *p; - uint8_t *q; - uint8_t *o; - float *l; - - uint8_t y; - uint8_t uv; - float value; - - // composite using luma map - for ( field = 0; field < ( field_order < 0 ? 1 : 2 ); ++field ) - { - for ( i = field; i < height_src; i += ( field_order < 0 ? 1 : 2 ) ) - { - p = &p_src[ i * stride_src ]; - q = &p_dest[ i * stride_dest ]; - o = &p_dest[ i * stride_dest ]; - l = &luma_bitmap[ i * luma_width ]; - - for ( j = 0; j < width_src; j ++ ) - { - y = *p ++; - uv = *p ++; - weight = *l ++; - value = smoothstep( weight, weight + softness, field_pos[ field ] ); - - *o ++ = (uint8_t)( y * value + *q++ * ( 1 - value ) ); - *o ++ = (uint8_t)( uv * value + *q++ * ( 1 - value ) ); - } - } - } -} - -/** Get the image. -*/ - -static int transition_get_image( mlt_frame this, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Get the properties of the a frame - mlt_properties a_props = mlt_frame_properties( this ); - - // Get the b frame from the stack - mlt_frame b_frame = mlt_frame_pop_frame( this ); - - // Get the properties of the b frame - mlt_properties b_props = mlt_frame_properties( b_frame ); - - // Arbitrary composite defaults - float frame_delta = 1 / mlt_properties_get_double( b_props, "fps" ); - float mix = mlt_properties_get_double( b_props, "image.mix" ); - int luma_width = mlt_properties_get_int( b_props, "luma.width" ); - int luma_height = mlt_properties_get_int( b_props, "luma.height" ); - float *luma_bitmap = mlt_properties_get_data( b_props, "luma.bitmap", NULL ); - float luma_softness = mlt_properties_get_double( b_props, "luma.softness" ); - int progressive = mlt_properties_get_int( b_props, "progressive" ); - int top_field_first = mlt_properties_get_int( b_props, "top_field_first" ); - int reverse = mlt_properties_get_int( b_props, "luma.reverse" ); - - // Honour the reverse here - mix = reverse ? 1 - mix : mix; - - if ( luma_width > 0 && luma_height > 0 && luma_bitmap != NULL ) - // Composite the frames using a luma map - luma_composite( this, b_frame, luma_width, luma_height, luma_bitmap, mix, frame_delta, - luma_softness, progressive > 0 ? -1 : top_field_first ); - else - // Dissolve the frames using the time offset for mix value - mlt_frame_composite_yuv( this, b_frame, 0, 0, mix ); - - // Extract the a_frame image info - *width = mlt_properties_get_int( a_props, "width" ); - *height = mlt_properties_get_int( a_props, "height" ); - *image = mlt_properties_get_data( a_props, "image", NULL ); - - return 0; -} - -/** Load the luma map from PGM stream. -*/ - -static void luma_read_pgm( FILE *f, float **map, int *width, int *height ) -{ - uint8_t *data = NULL; - while (1) - { - char line[128]; - int i = 2; - int maxval; - int bpp; - float *p; - - line[127] = '\0'; - - // get the magic code - if ( fgets( line, 127, f ) == NULL ) - break; - if ( line[0] != 'P' || line[1] != '5' ) - break; - - // skip white space and see if a new line must be fetched - for ( i = 2; i < 127 && line[i] != '\0' && isspace( line[i] ); i++ ); - if ( line[i] == '\0' && fgets( line, 127, f ) == NULL ) - break; - - // get the dimensions - if ( line[0] == 'P' ) - i = sscanf( line, "P5 %d %d %d", width, height, &maxval ); - else - i = sscanf( line, "%d %d %d", width, height, &maxval ); - - // get the height value, if not yet - if ( i < 2 ) - { - if ( fgets( line, 127, f ) == NULL ) - break; - i = sscanf( line, "%d", height ); - if ( i == 0 ) - break; - else - i = 2; - } - - // get the maximum gray value, if not yet - if ( i < 3 ) - { - if ( fgets( line, 127, f ) == NULL ) - break; - i = sscanf( line, "%d", &maxval ); - if ( i == 0 ) - break; - } - - // determine if this is one or two bytes per pixel - bpp = maxval > 255 ? 2 : 1; - // allocate temporary storage for the raw data - data = malloc( *width * *height * bpp ); - if ( data == NULL ) - break; - - // read the raw data - if ( fread( data, *width * *height * bpp, 1, f ) != 1 ) - break; - - // allocate the luma bitmap - *map = p = (float*) malloc( *width * *height * sizeof( float ) ); - if ( *map == NULL ) - break; - - // proces the raw data into the luma bitmap - for ( i = 0; i < *width * *height * bpp; i += bpp ) - { - if ( bpp == 1 ) - *p++ = (float) data[ i ] / (float) maxval; - else - *p++ = (float) ( ( data[ i ] << 8 ) + data[ i+1 ] ) / (float) maxval; - } - - break; - } - - if ( data != NULL ) - free( data ); -} - - -/** Luma transition processing. -*/ - -static mlt_frame transition_process( mlt_transition transition, mlt_frame a_frame, mlt_frame b_frame ) -{ - transition_luma *this = (transition_luma*) transition->child; - - // Get the properties of the transition - mlt_properties properties = mlt_transition_properties( transition ); - - // Get the properties of the b frame - mlt_properties b_props = mlt_frame_properties( b_frame ); - - // If the filename property changed, reload the map - char *luma_file = mlt_properties_get( properties, "filename" ); - if ( luma_file != NULL && ( this->filename == NULL || ( this->filename && strcmp( luma_file, this->filename ) ) ) ) - { - int width = mlt_properties_get_int( b_props, "width" ); - int height = mlt_properties_get_int( b_props, "height" ); - char command[ 512 ]; - FILE *pipe; - - command[ 511 ] = '\0'; - if ( this->filename ) - free( this->filename ); - this->filename = strdup( luma_file ); - snprintf( command, 511, "anytopnm %s | pnmscale -width %d -height %d", luma_file, width, height ); - //pipe = popen( command, "r" ); - pipe = fopen( luma_file, "r" ); - if ( pipe != NULL ) - { - if ( this->bitmap ) - free( this->bitmap ); - luma_read_pgm( pipe, &this->bitmap, &this->width, &this->height ); - //pclose( pipe ); - fclose( pipe ); - } - - } - - // Determine the time position of this frame in the transition duration - mlt_position in = mlt_transition_get_in( transition ); - mlt_position out = mlt_transition_get_out( transition ); - mlt_position time = mlt_frame_get_position( b_frame ); - float pos = ( float )( time - in ) / ( float )( out - in + 1 ); - - // Set the b frame properties - mlt_properties_set_double( b_props, "image.mix", pos ); - mlt_properties_set_int( b_props, "luma.width", this->width ); - mlt_properties_set_int( b_props, "luma.height", this->height ); - mlt_properties_set_data( b_props, "luma.bitmap", this->bitmap, 0, NULL, NULL ); - mlt_properties_set_int( b_props, "luma.reverse", mlt_properties_get_int( properties, "reverse" ) ); - mlt_properties_set_double( b_props, "luma.softness", mlt_properties_get_double( properties, "softness" ) ); - - mlt_frame_push_get_image( a_frame, transition_get_image ); - mlt_frame_push_frame( a_frame, b_frame ); - - return a_frame; -} - -/** Constructor for the filter. -*/ - -mlt_transition transition_luma_init( char *lumafile ) -{ - transition_luma *this = calloc( sizeof( transition_luma ), 1 ); - if ( this != NULL ) - { - mlt_transition transition = &this->parent; - mlt_transition_init( transition, this ); - transition->process = transition_process; - transition->close = transition_close; - - if ( lumafile != NULL ) - mlt_properties_set( mlt_transition_properties( transition ), "filename", lumafile ); - - return &this->parent; - } - return NULL; -} - -/** Close the transition. -*/ - -static void transition_close( mlt_transition parent ) -{ - transition_luma *this = (transition_luma*) parent->child; - - if ( this->bitmap ) - free( this->bitmap ); - - if ( this->filename ) - free( this->filename ); - - free( this ); -} - diff --git a/mlt/src/modules/core/transition_luma.h b/mlt/src/modules/core/transition_luma.h deleted file mode 100644 index 72f8283..0000000 --- a/mlt/src/modules/core/transition_luma.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * transition_luma.h -- a generic dissolve/wipe processor - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _TRANSITION_LUMA_H_ -#define _TRANSITION_LUMA_H_ - -#include - -extern mlt_transition transition_luma_init( char *lumafile ); - -#endif diff --git a/mlt/src/modules/core/transition_mix.c b/mlt/src/modules/core/transition_mix.c deleted file mode 100644 index 7b1521d..0000000 --- a/mlt/src/modules/core/transition_mix.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * transition_mix.c -- mix two audio streams - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "transition_mix.h" -#include - -#include -#include - - -/** Get the audio. -*/ - -static int transition_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Get the properties of the a frame - mlt_properties a_props = mlt_frame_properties( frame ); - - // Get the b frame from the stack - mlt_frame b_frame = mlt_frame_pop_frame( frame ); - - // Get the properties of the b frame - mlt_properties b_props = mlt_frame_properties( b_frame ); - - // Restore the original get_audio - frame->get_audio = mlt_properties_get_data( a_props, "mix.get_audio", NULL ); - - double mix = 0.5; - if ( mlt_properties_get( b_props, "audio.mix" ) != NULL ) - mix = mlt_properties_get_double( b_props, "audio.mix" ); - if ( mlt_properties_get_int( b_props, "audio.reverse" ) ) - mix = 1 - mix; - - mlt_frame_mix_audio( frame, b_frame, mix, buffer, format, frequency, channels, samples ); - - // Push the b_frame back on for get_image - mlt_frame_push_frame( frame, b_frame ); - - return 0; -} - - -/** Mix transition processing. -*/ - -static mlt_frame transition_process( mlt_transition this, mlt_frame a_frame, mlt_frame b_frame ) -{ - mlt_properties properties = mlt_transition_properties( this ); - mlt_properties b_props = mlt_frame_properties( b_frame ); - - // Only if mix is specified, otherwise a producer may set the mix - if ( mlt_properties_get( properties, "mix" ) != NULL ) - { - // A negative means crossfade - if ( mlt_properties_get_double( properties, "mix" ) < 0 ) - { - // Determine the time position of this frame in the transition duration - mlt_position in = mlt_transition_get_in( this ); - mlt_position out = mlt_transition_get_out( this ); - mlt_position time = mlt_frame_get_position( b_frame ); - double mix = ( double )( time - in ) / ( double )( out - in + 1 ); - mlt_properties_set_double( b_props, "audio.mix", mix ); - } - else - mlt_properties_set_double( b_props, "audio.mix", mlt_properties_get_double( properties, "mix" ) ); - mlt_properties_set_double( b_props, "audio.reverse", mlt_properties_get_double( properties, "reverse" ) ); - } - - // Backup the original get_audio (it's still needed) - mlt_properties_set_data( mlt_frame_properties( a_frame ), "mix.get_audio", a_frame->get_audio, 0, NULL, NULL ); - - // Override the get_audio method - a_frame->get_audio = transition_get_audio; - - mlt_frame_push_frame( a_frame, b_frame ); - - return a_frame; -} - -/** Constructor for the transition. -*/ - -mlt_transition transition_mix_init( char *arg ) -{ - mlt_transition this = calloc( sizeof( struct mlt_transition_s ), 1 ); - if ( this != NULL && mlt_transition_init( this, NULL ) == 0 ) - { - this->process = transition_process; - if ( arg != NULL ) - mlt_properties_set_double( mlt_transition_properties( this ), "mix", atof( arg ) ); - } - return this; -} - diff --git a/mlt/src/modules/core/transition_mix.h b/mlt/src/modules/core/transition_mix.h deleted file mode 100644 index 2ada6bc..0000000 --- a/mlt/src/modules/core/transition_mix.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * transition_mix.h -- mix two audio streams - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _TRANSITION_MIX_H_ -#define _TRANSITION_MIX_H_ - -#include - -extern mlt_transition transition_mix_init( char *arg ); - -#endif diff --git a/mlt/src/modules/dv/Makefile b/mlt/src/modules/dv/Makefile deleted file mode 100644 index f3aac3c..0000000 --- a/mlt/src/modules/dv/Makefile +++ /dev/null @@ -1,30 +0,0 @@ - -TARGET = ../libmltdv.so - -OBJS = factory.o \ - producer_libdv.o \ - consumer_libdv.o - -CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -LDFLAGS=-ldv -lpthread - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/dv/configure b/mlt/src/modules/dv/configure deleted file mode 100755 index 9453267..0000000 --- a/mlt/src/modules/dv/configure +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -libdv libmltdv.so -EOF - -cat << EOF >> ../consumers.dat -libdv libmltdv.so -EOF - -fi - diff --git a/mlt/src/modules/dv/consumer_libdv.c b/mlt/src/modules/dv/consumer_libdv.c deleted file mode 100644 index de64f46..0000000 --- a/mlt/src/modules/dv/consumer_libdv.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * producer_libdv.c -- a DV encoder based on libdv - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -// Local header files -#include "consumer_libdv.h" - -// mlt Header files -#include - -// System header files -#include -#include -#include -#include - -// libdv header files -#include - -// Forward references. -static int consumer_start( mlt_consumer this ); -static int consumer_stop( mlt_consumer this ); -static int consumer_is_stopped( mlt_consumer this ); -static int consumer_encode_video( mlt_consumer this, uint8_t *dv_frame, mlt_frame frame ); -static void consumer_encode_audio( mlt_consumer this, uint8_t *dv_frame, mlt_frame frame ); -static void consumer_output( mlt_consumer this, uint8_t *dv_frame, int size, mlt_frame frame ); -static void *consumer_thread( void *arg ); -static void consumer_close( mlt_consumer this ); - -/** Initialise the dv consumer. -*/ - -mlt_consumer consumer_libdv_init( char *arg ) -{ - // Allocate the consumer - mlt_consumer this = calloc( 1, sizeof( struct mlt_consumer_s ) ); - - // If memory allocated and initialises without error - if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 ) - { - // Get properties from the consumer - mlt_properties properties = mlt_consumer_properties( this ); - - // Assign close callback - this->close = consumer_close; - - // Interpret the constructor argument - if ( arg == NULL || !strcmp( arg, "PAL" ) ) - mlt_properties_set_double( properties, "fps", 25 ); - else - mlt_properties_set_double( properties, "fps", 29.97 ); - - // Set the encode and output handling method - mlt_properties_set_data( properties, "video", consumer_encode_video, 0, NULL, NULL ); - mlt_properties_set_data( properties, "audio", consumer_encode_audio, 0, NULL, NULL ); - mlt_properties_set_data( properties, "output", consumer_output, 0, NULL, NULL ); - - // Set up start/stop/terminated callbacks - this->start = consumer_start; - this->stop = consumer_stop; - this->is_stopped = consumer_is_stopped; - } - else - { - // Clean up in case of init failure - free( this ); - this = NULL; - } - - // Return this - return this; -} - -/** Start the consumer. -*/ - -static int consumer_start( mlt_consumer this ) -{ - // Get the properties - mlt_properties properties = mlt_consumer_properties( this ); - - // Check that we're not already running - if ( !mlt_properties_get_int( properties, "running" ) ) - { - // Allocate a thread - pthread_t *thread = calloc( 1, sizeof( pthread_t ) ); - - // Assign the thread to properties - mlt_properties_set_data( properties, "thread", thread, sizeof( pthread_t ), free, NULL ); - - // Set the running state - mlt_properties_set_int( properties, "running", 1 ); - - // Create the thread - pthread_create( thread, NULL, consumer_thread, this ); - } - return 0; -} - -/** Stop the consumer. -*/ - -static int consumer_stop( mlt_consumer this ) -{ - // Get the properties - mlt_properties properties = mlt_consumer_properties( this ); - - // Check that we're running - if ( mlt_properties_get_int( properties, "running" ) ) - { - // Get the thread - pthread_t *thread = mlt_properties_get_data( properties, "thread", NULL ); - - // Stop the thread - mlt_properties_set_int( properties, "running", 0 ); - - // Wait for termination - pthread_join( *thread, NULL ); - } - - return 0; -} - -/** Determine if the consumer is stopped. -*/ - -static int consumer_is_stopped( mlt_consumer this ) -{ - // Get the properties - mlt_properties properties = mlt_consumer_properties( this ); - return !mlt_properties_get_int( properties, "running" ); -} - -/** Get or create a new libdv encoder. -*/ - -static dv_encoder_t *libdv_get_encoder( mlt_consumer this, mlt_frame frame ) -{ - // Get the properties of the consumer - mlt_properties this_properties = mlt_consumer_properties( this ); - - // Obtain the dv_encoder - dv_encoder_t *encoder = mlt_properties_get_data( this_properties, "dv_encoder", NULL ); - - // Construct one if we don't have one - if ( encoder == NULL ) - { - // Get the fps of the consumer (for now - should be from frame) - double fps = mlt_properties_get_double( this_properties, "fps" ); - - // Create the encoder - encoder = dv_encoder_new( 0, 0, 0 ); - - // Encoder settings - encoder->isPAL = fps == 25; - encoder->is16x9 = 0; - encoder->vlc_encode_passes = 1; - encoder->static_qno = 0; - encoder->force_dct = DV_DCT_AUTO; - - // Store the encoder on the properties - mlt_properties_set_data( this_properties, "dv_encoder", encoder, 0, ( mlt_destructor )dv_encoder_free, NULL ); - - // Convenience for image dimensions - mlt_properties_set_int( this_properties, "width", 720 ); - mlt_properties_set_int( this_properties, "height", fps == 25 ? 576 : 480 ); - } - - // Return the encoder - return encoder; -} - - -/** The libdv encode video method. -*/ - -static int consumer_encode_video( mlt_consumer this, uint8_t *dv_frame, mlt_frame frame ) -{ - // Obtain the dv_encoder - dv_encoder_t *encoder = libdv_get_encoder( this, frame ); - - // Get the properties of the consumer - mlt_properties this_properties = mlt_consumer_properties( this ); - - // This will hold the size of the dv frame - int size = 0; - - // determine if this a test card - int is_test = mlt_frame_is_test_card( frame ); - - // If we get an encoder, then encode the image - if ( encoder != NULL ) - { - // Specify desired image properties - mlt_image_format fmt = mlt_image_yuv422; - int width = mlt_properties_get_int( this_properties, "width" ); - int height = mlt_properties_get_int( this_properties, "height" ); - uint8_t *image = NULL; - - // Get the image - mlt_frame_get_image( frame, &image, &fmt, &width, &height, 0 ); - - // Check that we get what we expected - if ( fmt != mlt_image_yuv422 || - width != mlt_properties_get_int( this_properties, "width" ) || - height != mlt_properties_get_int( this_properties, "height" ) || - image == NULL ) - { - // We should try to recover here - fprintf( stderr, "We have a problem houston...\n" ); - } - else - { - // Calculate the size of the dv frame - size = height == 576 ? frame_size_625_50 : frame_size_525_60; - } - - // Process the frame - if ( size != 0 && !( mlt_properties_get_int( this_properties, "was_test_card" ) && is_test ) ) - { - // Encode the image - dv_encode_full_frame( encoder, &image, e_dv_color_yuv, dv_frame ); - - // Note test card status - mlt_properties_set_int( this_properties, "was_test_card", is_test ); - } - } - - return size; -} - -/** The libdv encode audio method. -*/ - -static void consumer_encode_audio( mlt_consumer this, uint8_t *dv_frame, mlt_frame frame ) -{ - // Get the properties of the consumer - mlt_properties this_properties = mlt_consumer_properties( this ); - - // Obtain the dv_encoder - dv_encoder_t *encoder = libdv_get_encoder( this, frame ); - - // Only continue if we have an encoder - if ( encoder != NULL ) - { - // Get the frame count - int count = mlt_properties_get_int( this_properties, "count" ); - - // Default audio args - mlt_audio_format fmt = mlt_audio_pcm; - int channels = 2; - int frequency = 48000; - int samples = mlt_sample_calculator( mlt_properties_get_double( this_properties, "fps" ), frequency, count ); - int16_t *pcm = NULL; - - // Get the frame number - time_t start = time( NULL ); - int height = mlt_properties_get_int( this_properties, "height" ); - int is_pal = height == 576; - int is_wide = 0; - - // Temporary - audio buffer allocation - int16_t *audio_buffers[ 4 ]; - int i = 0; - int j = 0; - for ( i = 0 ; i < 4; i ++ ) - audio_buffers[ i ] = malloc( 2 * DV_AUDIO_MAX_SAMPLES ); - - // Get the audio - mlt_frame_get_audio( frame, &pcm, &fmt, &frequency, &channels, &samples ); - - // Inform the encoder of the number of audio samples - encoder->samples_this_frame = samples; - - // Fill the audio buffers correctly - for ( i = 0; i < samples; i ++ ) - for ( j = 0; j < channels; j++ ) - audio_buffers[ j ][ i ] = *pcm ++; - - // Encode audio on frame - dv_encode_full_audio( encoder, audio_buffers, channels, frequency, dv_frame ); - - // Specify meta data on the frame - dv_encode_metadata( dv_frame, is_pal, is_wide, &start, count ); - dv_encode_timecode( dv_frame, is_pal, count ); - - // Update properties - mlt_properties_set_int( this_properties, "count", ++ count ); - - // Temporary - free audio buffers - for ( i = 0 ; i < 4; i ++ ) - free( audio_buffers[ i ] ); - } -} - -/** The libdv output method. -*/ - -static void consumer_output( mlt_consumer this, uint8_t *dv_frame, int size, mlt_frame frame ) -{ - fwrite( dv_frame, size, 1, stdout ); - fflush( stdout ); -} - -/** The main thread - the argument is simply the consumer. -*/ - -static void *consumer_thread( void *arg ) -{ - // Map the argument to the object - mlt_consumer this = arg; - - // Get the properties - mlt_properties properties = mlt_consumer_properties( this ); - - // Get the handling methods - int ( *video )( mlt_consumer, uint8_t *, mlt_frame ) = mlt_properties_get_data( properties, "video", NULL ); - int ( *audio )( mlt_consumer, uint8_t *, mlt_frame ) = mlt_properties_get_data( properties, "audio", NULL ); - int ( *output )( mlt_consumer, uint8_t *, int, mlt_frame ) = mlt_properties_get_data( properties, "output", NULL ); - - // Allocate a single PAL frame for encoding - uint8_t *dv_frame = malloc( frame_size_625_50 ); - - // Get the service associated to the consumer - mlt_service service = mlt_consumer_service( this ); - - // Define a frame pointer - mlt_frame frame; - - // Loop while running - while( mlt_properties_get_int( properties, "running" ) ) - { - // Get the frame - if ( mlt_service_get_frame( service, &frame, 0 ) == 0 ) - { - // Obtain the dv_encoder - if ( libdv_get_encoder( this, frame ) != NULL ) - { - // Encode the image - int size = video( this, dv_frame, frame ); - - // Encode the audio - if ( size > 0 ) - audio( this, dv_frame, frame ); - - // Output the frame - output( this, dv_frame, size, frame ); - - // Close the frame - mlt_frame_close( frame ); - } - else - { - fprintf( stderr, "Unable to obtain dv encoder.\n" ); - } - } - } - - // Tidy up - free( dv_frame ); - - return NULL; -} - -/** Close the consumer. -*/ - -static void consumer_close( mlt_consumer this ) -{ - // Stop the consumer - mlt_consumer_stop( this ); - - // Close the parent - mlt_consumer_close( this ); - - // Free the memory - free( this ); -} - diff --git a/mlt/src/modules/dv/consumer_libdv.h b/mlt/src/modules/dv/consumer_libdv.h deleted file mode 100644 index de7311e..0000000 --- a/mlt/src/modules/dv/consumer_libdv.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * producer_libdv.h -- a DV encoder based on libdv - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _CONSUMER_LIBDV_H_ -#define _CONSUMER_LIBDV_H_ - -#include - -extern mlt_consumer consumer_libdv_init( char *filename ); - -#endif diff --git a/mlt/src/modules/dv/factory.c b/mlt/src/modules/dv/factory.c deleted file mode 100644 index 8d25f70..0000000 --- a/mlt/src/modules/dv/factory.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "producer_libdv.h" -#include "consumer_libdv.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "libdv" ) ) - return producer_libdv_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - if ( !strcmp( id, "libdv" ) ) - return consumer_libdv_init( arg ); - return NULL; -} - diff --git a/mlt/src/modules/dv/producer_libdv.c b/mlt/src/modules/dv/producer_libdv.c deleted file mode 100644 index b82a0e6..0000000 --- a/mlt/src/modules/dv/producer_libdv.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * producer_libdv.c -- simple libdv test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_libdv.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct producer_libdv_s *producer_libdv; - -struct producer_libdv_s -{ - struct mlt_producer_s parent; - int fd; - dv_decoder_t *dv_decoder; - int is_pal; - uint64_t file_size; - int frame_size; - long frames_in_file; -}; - -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); -static void producer_close( mlt_producer parent ); - -static int producer_collect_info( producer_libdv this ); - -mlt_producer producer_libdv_init( char *filename ) -{ - producer_libdv this = calloc( sizeof( struct producer_libdv_s ), 1 ); - - if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) - { - mlt_producer producer = &this->parent; - mlt_properties properties = mlt_producer_properties( producer ); - - // Register transport implementation with the producer - producer->close = producer_close; - - // Register our get_frame implementation with the producer - producer->get_frame = producer_get_frame; - - // Create the dv_decoder - this->dv_decoder = dv_decoder_new( FALSE, FALSE, FALSE ); - this->dv_decoder->quality = DV_QUALITY_BEST; - this->dv_decoder->audio->arg_audio_emphasis = 2; - dv_set_audio_correction( this->dv_decoder, DV_AUDIO_CORRECT_AVERAGE ); - - // Open the file if specified - this->fd = open( filename, O_RDONLY ); - producer_collect_info( this ); - - // Set the resource property (required for all producers) - mlt_properties_set( properties, "resource", filename ); - - // Return the producer - return producer; - } - free( this ); - return NULL; -} - -static int read_frame( int fd, uint8_t* frame_buf, int *isPAL ) -{ - int result = read( fd, frame_buf, frame_size_525_60 ) == frame_size_525_60; - if ( result ) - { - *isPAL = ( frame_buf[3] & 0x80 ); - - if ( *isPAL ) - { - int diff = frame_size_625_50 - frame_size_525_60; - result = read( fd, frame_buf + frame_size_525_60, diff ) == diff; - } - } - - return result; -} - -static int producer_collect_info( producer_libdv this ) -{ - int valid = 0; - uint8_t *dv_data = malloc( frame_size_625_50 ); - - if ( dv_data != NULL ) - { - // Read the first frame - valid = read_frame( this->fd, dv_data, &this->is_pal ); - - // If it looks like a valid frame, the get stats - if ( valid ) - { - // Get the properties - mlt_properties properties = mlt_producer_properties( &this->parent ); - - // Determine the file size - struct stat buf; - fstat( this->fd, &buf ); - - // Store the file size - this->file_size = buf.st_size; - - // Determine the frame size - this->frame_size = this->is_pal ? frame_size_625_50 : frame_size_525_60; - - // Determine the number of frames in the file - this->frames_in_file = this->file_size / this->frame_size; - - // Calculate default in/out points - double fps = this->is_pal ? 25 : 30000.0 / 1001.0; - mlt_properties_set_double( properties, "fps", fps ); - mlt_properties_set_position( properties, "length", this->frames_in_file ); - mlt_properties_set_position( properties, "in", 0 ); - mlt_properties_set_position( properties, "out", this->frames_in_file - 1 ); - - // Parse the header for meta info - dv_parse_header( this->dv_decoder, dv_data ); - mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); - - // Set the speed to normal - mlt_properties_set_double( properties, "speed", 1 ); - } - - free( dv_data ); - } - - return valid; -} - -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - int pitches[3] = { 0, 0, 0 }; - uint8_t *pixels[3] = { NULL, NULL, NULL }; - - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - // Get the dv decoder - dv_decoder_t *decoder = mlt_properties_get_data( properties, "dv_decoder", NULL ); - - // Get the dv data - uint8_t *dv_data = mlt_properties_get_data( properties, "dv_data", NULL ); - - // Parse the header for meta info - dv_parse_header( decoder, dv_data ); - - // Assign width and height from properties - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - - // Extract an image of the format requested - if ( *format == mlt_image_yuv422 ) - { - // Allocate an image - uint8_t *image = malloc( *width * *height * 2 ); - - // Pass to properties for clean up - mlt_properties_set_data( properties, "image", image, *width * *height * 2, free, NULL ); - - // Decode the image - pitches[ 0 ] = *width * 2; - pixels[ 0 ] = image; - dv_decode_full_frame( decoder, dv_data, e_dv_color_yuv, pixels, pitches ); - - // Assign result - *buffer = image; - } - else if ( *format == mlt_image_rgb24 ) - { - // Allocate an image - uint8_t *image = malloc( *width * *height * 3 ); - - // Pass to properties for clean up - mlt_properties_set_data( properties, "image", image, *width * *height * 3, free, NULL ); - - // Decode the frame - pitches[ 0 ] = 720 * 3; - pixels[ 0 ] = image; - dv_decode_full_frame( decoder, dv_data, e_dv_color_rgb, pixels, pitches ); - - // Assign result - *buffer = image; - } - - return 0; -} - -static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - int16_t *p; - int i, j; - int16_t *audio_channels[ 4 ]; - - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - // Get the dv decoder - dv_decoder_t *decoder = mlt_properties_get_data( properties, "dv_decoder", NULL ); - - // Get the dv data - uint8_t *dv_data = mlt_properties_get_data( properties, "dv_data", NULL ); - - // Parse the header for meta info - dv_parse_header( decoder, dv_data ); - - // Obtain required values - *frequency = decoder->audio->frequency; - *samples = decoder->audio->samples_this_frame; - *channels = decoder->audio->num_channels; - - // Create a temporary workspace - for ( i = 0; i < 4; i++ ) - audio_channels[ i ] = malloc( DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); - - // Create a workspace for the result - *buffer = malloc( *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ) ); - - // Pass the allocated audio buffer as a property - mlt_properties_set_data( properties, "audio", *buffer, *channels * DV_AUDIO_MAX_SAMPLES * sizeof( int16_t ), free, NULL ); - - // Decode the audio - dv_decode_full_audio( decoder, dv_data, audio_channels ); - - // Interleave the audio - p = *buffer; - for ( i = 0; i < *samples; i++ ) - for ( j = 0; j < *channels; j++ ) - *p++ = audio_channels[ j ][ i ]; - - // Free the temporary work space - for ( i = 0; i < 4; i++ ) - free( audio_channels[ i ] ); - - return 0; -} - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - producer_libdv this = producer->child; - uint8_t *data = malloc( frame_size_625_50 ); - - // Obtain the current frame number - uint64_t position = mlt_producer_frame( producer ); - - // Convert timecode to a file position (ensuring that we're on a frame boundary) - uint64_t offset = position * this->frame_size; - - // Create an empty frame - *frame = mlt_frame_init( ); - - // Seek and fetch - if ( this->fd != 0 && - lseek( this->fd, offset, SEEK_SET ) == offset && - read_frame( this->fd, data, &this->is_pal ) ) - { - // Get the frames properties - mlt_properties properties = mlt_frame_properties( *frame ); - - // Pass the dv decoder - mlt_properties_set_data( properties, "dv_decoder", this->dv_decoder, 0, NULL, NULL ); - - // Pass the dv data - mlt_properties_set_data( properties, "dv_data", data, frame_size_625_50, free, NULL ); - - // Update other info on the frame - mlt_properties_set_int( properties, "width", 720 ); - mlt_properties_set_int( properties, "height", this->is_pal ? 576 : 480 ); - mlt_properties_set_int( properties, "top_field_first", 0 ); - - // Parse the header for meta info - dv_parse_header( this->dv_decoder, data ); - mlt_properties_set_int( properties, "progressive", dv_is_progressive( this->dv_decoder ) ); - mlt_properties_set_double( properties, "aspect_ratio", dv_format_wide( this->dv_decoder ) ? 16.0/9.0 : 4.0/3.0 ); - - // Hmm - register audio callback - ( *frame )->get_audio = producer_get_audio; - - // Push the get_image method on to the stack - mlt_frame_push_get_image( *frame, producer_get_image ); - } - else - { - free( data ); - } - - // Update timecode on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); - - // Calculate the next timecode - mlt_producer_prepare_next( producer ); - - return 0; -} - -static void producer_close( mlt_producer parent ) -{ - // Obtain this - producer_libdv this = parent->child; - - // Free the dv deconder - //dv_decoder_free( this->dv_decoder ); - - // Close the file - if ( this->fd != 0 ) - close( this->fd ); - - // Close the parent - parent->close = NULL; - mlt_producer_close( parent ); - - // Free the memory - free( this ); -} - diff --git a/mlt/src/modules/dv/producer_libdv.h b/mlt/src/modules/dv/producer_libdv.h deleted file mode 100644 index c493eae..0000000 --- a/mlt/src/modules/dv/producer_libdv.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * producer_libdv.h -- a DV decoder based on libdv - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_LIBDV_H_ -#define _PRODUCER_LIBDV_H_ - -#include - -extern mlt_producer producer_libdv_init( char *filename ); - -#endif diff --git a/mlt/src/modules/ffmpeg/Makefile b/mlt/src/modules/ffmpeg/Makefile deleted file mode 100644 index 52c407b..0000000 --- a/mlt/src/modules/ffmpeg/Makefile +++ /dev/null @@ -1,29 +0,0 @@ - -TARGET = ../libmltffmpeg.so - -OBJS = factory.o \ - producer_ffmpeg.o \ - filter_ffmpeg_dub.o \ - consumer_ffmpeg.o - -CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/ffmpeg/audio.sh b/mlt/src/modules/ffmpeg/audio.sh deleted file mode 100755 index 2d6aeda..0000000 --- a/mlt/src/modules/ffmpeg/audio.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -trap exit - -audio_type="$1" -audio_file="$2" -audio_position=$3 -audio_frequency=$4 -audio_channels=$5 -audio_track=$5 - -if [ "$audio_type" == "dsp" ] -then ffmpeg -ad "$audio_file" -f s16le -ar $audio_frequency -ac $audio_channels - -else ffmpeg -i "$audio_file" -ss $audio_position -f s16le -ar $audio_frequency -ac $audio_channels - -fi - diff --git a/mlt/src/modules/ffmpeg/configure b/mlt/src/modules/ffmpeg/configure deleted file mode 100755 index 539ac5b..0000000 --- a/mlt/src/modules/ffmpeg/configure +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -ffmpeg libmltffmpeg.so -EOF - -cat << EOF >> ../filters.dat -ffmpeg_dub libmltffmpeg.so -EOF - -cat << EOF >> ../consumers.dat -ffmpeg libmltffmpeg.so -EOF - -fi - diff --git a/mlt/src/modules/ffmpeg/consumer_ffmpeg.c b/mlt/src/modules/ffmpeg/consumer_ffmpeg.c deleted file mode 100644 index 11f72b7..0000000 --- a/mlt/src/modules/ffmpeg/consumer_ffmpeg.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * consumer_ffmpeg.c -- an ffmpeg consumer - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "consumer_ffmpeg.h" -#include -#include -#include -#include -#include - -/** This classes definition. -*/ - -typedef struct consumer_ffmpeg_s *consumer_ffmpeg; - -struct consumer_ffmpeg_s -{ - struct mlt_consumer_s parent; - mlt_properties properties; - int format; - int video; - pthread_t thread; - int running; - uint8_t audio_buffer[ 4096 * 3 ]; - int audio_avail; - pthread_mutex_t audio_mutex; - pthread_cond_t audio_cond; - int window_width; - int window_height; - float aspect_ratio; - int width; - int height; - int playing; - mlt_frame *queue; - int size; - int count; - uint8_t *buffer; -}; - -/** Forward references to static functions. -*/ - -static void consumer_close( mlt_consumer parent ); -static void *consumer_thread( void * ); - -/** This is what will be called by the factory - anything can be passed in - via the argument, but keep it simple. -*/ - -mlt_consumer consumer_ffmpeg_init( char *arg ) -{ - // Create the consumer object - consumer_ffmpeg this = calloc( sizeof( struct consumer_ffmpeg_s ), 1 ); - - // If no malloc'd and consumer init ok - if ( this != NULL && mlt_consumer_init( &this->parent, this ) == 0 ) - { - // Get the parent consumer object - mlt_consumer parent = &this->parent; - - // We have stuff to clean up, so override the close method - parent->close = consumer_close; - - // get a handle on properties - mlt_service service = mlt_consumer_service( parent ); - this->properties = mlt_service_properties( service ); - - // This is the initialisation of the consumer - this->running = 1; - pthread_mutex_init( &this->audio_mutex, NULL ); - pthread_cond_init( &this->audio_cond, NULL); - - // process actual param - if ( arg == NULL || !strcmp( arg, "-" ) ) - { - mlt_properties_set( this->properties, "video_file", "-" ); - mlt_properties_set( this->properties, "video_format", "dv" ); - } - else - { - mlt_properties_set( this->properties, "video_file", arg ); - mlt_properties_set( this->properties, "video_format", "" ); - } - - // Create the the thread - pthread_create( &this->thread, NULL, consumer_thread, this ); - - // Return the consumer produced - return parent; - } - - // malloc or consumer init failed - free( this ); - - // Indicate failure - return NULL; -} - -static void sdl_fill_audio( void *udata, uint8_t *stream, int len ) -{ - consumer_ffmpeg this = udata; - - pthread_mutex_lock( &this->audio_mutex ); - - // Block until audio received - while ( this->running && len > this->audio_avail ) - pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); - - if ( this->audio_avail >= len ) - { - // Remove len from the audio available - this->audio_avail -= len; - - // Remove the samples - memmove( this->audio_buffer, this->audio_buffer + len, this->audio_avail ); - } - else - { - // Just to be safe, wipe the stream first - memset( stream, 0, len ); - - // Copy what we have into the stream - memcpy( stream, this->audio_buffer, this->audio_avail ); - - // No audio left - this->audio_avail = 0; - } - - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); -} - -static int consumer_play_audio( consumer_ffmpeg this, mlt_frame frame, int init_audio ) -{ - // Get the properties of this consumer - mlt_properties properties = this->properties; - mlt_audio_format afmt = mlt_audio_pcm; - int channels; - int samples; - int frequency; - int16_t *pcm; - int bytes; - - mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples ); - - if ( mlt_properties_get_int( properties, "audio_off" ) ) - return init_audio; - - if ( init_audio == 0 ) - { - bytes = ( samples * channels * 2 ); - pthread_mutex_lock( &this->audio_mutex ); - while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) ) - pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); - mlt_properties properties = mlt_frame_properties( frame ); - if ( mlt_properties_get_double( properties, "speed" ) == 1 ) - memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes ); - else - memset( &this->audio_buffer[ this->audio_avail ], 0, bytes ); - this->audio_avail += bytes; - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); - } - else - { - this->playing = 1; - } - - return init_audio; -} - -static int consumer_play_video( consumer_ffmpeg this, mlt_frame frame ) -{ - // Get the properties of this consumer - mlt_properties properties = this->properties; - - if ( mlt_properties_get_int( properties, "video_off" ) ) - { - mlt_frame_close( frame ); - return 0; - } - - if ( this->count == this->size ) - { - this->size += 25; - this->queue = realloc( this->queue, sizeof( mlt_frame ) * this->size ); - } - this->queue[ this->count ++ ] = frame; - - // We're working on the oldest frame now - frame = this->queue[ 0 ]; - - // Shunt the frames in the queue down - int i = 0; - for ( i = 1; i < this->count; i ++ ) - this->queue[ i - 1 ] = this->queue[ i ]; - this->count --; - - return 0; -} - -/** Threaded wrapper for pipe. -*/ - -static void *consumer_thread( void *arg ) -{ - // Identify the arg - consumer_ffmpeg this = arg; - - // Get the consumer - mlt_consumer consumer = &this->parent; - - // Get the service assoicated to the consumer - mlt_service service = mlt_consumer_service( consumer ); - - // Define a frame pointer - mlt_frame frame; - - // internal intialization - int init_audio = 1; - - // Loop until told not to - while( this->running ) - { - // Get a frame from the service (should never return anything other than 0) - if ( mlt_service_get_frame( service, &frame, 0 ) == 0 ) - { - init_audio = consumer_play_audio( this, frame, init_audio ); - consumer_play_video( this, frame ); - } - } - - return NULL; -} - -/** Callback to allow override of the close method. -*/ - -static void consumer_close( mlt_consumer parent ) -{ - // Get the actual object - consumer_ffmpeg this = parent->child; - - // Kill the thread and clean up - this->running = 0; - - pthread_mutex_lock( &this->audio_mutex ); - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); - - pthread_join( this->thread, NULL ); - pthread_mutex_destroy( &this->audio_mutex ); - pthread_cond_destroy( &this->audio_cond ); - - // Now clean up the rest (the close = NULL is a bit nasty but needed for now) - parent->close = NULL; - mlt_consumer_close( parent ); - - // Finally clean up this - free( this ); -} - diff --git a/mlt/src/modules/ffmpeg/consumer_ffmpeg.h b/mlt/src/modules/ffmpeg/consumer_ffmpeg.h deleted file mode 100644 index dc2fc79..0000000 --- a/mlt/src/modules/ffmpeg/consumer_ffmpeg.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * consumer_ffmpeg.h -- simple ffmpeg test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _CONSUMER_FFMPEG_H_ -#define _CONSUMER_FFMPEG_H_ - -#include - -extern mlt_consumer consumer_ffmpeg_init( char *file ); - -#endif diff --git a/mlt/src/modules/ffmpeg/factory.c b/mlt/src/modules/ffmpeg/factory.c deleted file mode 100644 index 7bf697a..0000000 --- a/mlt/src/modules/ffmpeg/factory.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "producer_ffmpeg.h" -#include "filter_ffmpeg_dub.h" -#include "consumer_ffmpeg.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "ffmpeg" ) ) - return producer_ffmpeg_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - if ( !strcmp( id, "ffmpeg_dub" ) ) - return filter_ffmpeg_dub_init( arg ); - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - if ( !strcmp( id, "ffmpeg" ) ) - return consumer_ffmpeg_init( arg ); - return NULL; -} - diff --git a/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.c b/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.c deleted file mode 100644 index 0d678af..0000000 --- a/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * filter_ffmpeg_dub.c -- simple ffmpeg dub test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_ffmpeg_dub.h" -#include -#include -#include - -/** Do it. -*/ - -static int filter_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Obtain the frame properties - mlt_properties frame_properties = mlt_frame_properties( frame ); - - // Get the producer used. - mlt_producer producer = mlt_properties_get_data( frame_properties, "producer", NULL ); - - // Get the producer properties - mlt_properties producer_properties = mlt_producer_properties( producer ); - - // Get the original get_audio - frame->get_audio = mlt_properties_get_data( frame_properties, "get_audio", NULL ); - - // Call the original get_audio - mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); - - // Now if our producer is still producing, override the audio - if ( !mlt_properties_get_int( producer_properties, "end_of_clip" ) ) - { - // Get the position - mlt_position position = mlt_properties_get_position( producer_properties, "dub_position" ); - - // We need a frame from the producer - mlt_frame producer_frame; - - // Set the FPS - mlt_properties_set_double( producer_properties, "fps", mlt_properties_get_double( frame_properties, "fps" ) ); - - // Seek to the position - mlt_producer_seek( producer, position ); - - // Get the next frame - producer->get_frame( producer, &producer_frame, 0 ); - - if ( !mlt_properties_get_int( producer_properties, "end_of_clip" ) ) - { - // Now get the audio from this frame - producer_frame->get_audio( producer_frame, buffer, format, frequency, channels, samples ); - - // This producer frame will be destroyed automatically when frame is destroyed - mlt_properties_set_data( frame_properties, "ffmpeg_dub_frame", producer_frame, 0, ( mlt_destructor )mlt_frame_close, NULL ); - - // Incrment the position - mlt_properties_set_position( producer_properties, "dub_position", position + 1 ); - } - } - - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - // Obtain the filter properties - mlt_properties filter_properties = mlt_filter_properties( this ); - - // Get the producer used. - mlt_producer producer = mlt_properties_get_data( filter_properties, "producer", NULL ); - - // Obtain the frame properties - mlt_properties frame_properties = mlt_frame_properties( frame ); - - // Get the producer properties - mlt_properties producer_properties = mlt_producer_properties( producer ); - - // Only do this if we have not reached end of clip and ffmpeg_dub has not already been done - if ( !mlt_properties_get_int( producer_properties, "end_of_clip" ) && - mlt_properties_get_data( frame_properties, "get_audio", NULL ) == NULL ) - { - // Backup the original get_audio (it's still needed) - mlt_properties_set_data( frame_properties, "get_audio", frame->get_audio, 0, NULL, NULL ); - - // Pass the producer on the frame - mlt_properties_set_data( frame_properties, "producer", producer, 0, NULL, NULL ); - - // Override the get_audio method - frame->get_audio = filter_get_audio; - } - - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_ffmpeg_dub_init( char *file ) -{ - // Create the filter object - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); - - // Initialise it - mlt_filter_init( this, NULL ); - - // Overide the filter process method - this->process = filter_process; - - // Obtain the properties - mlt_properties properties = mlt_filter_properties( this ); - - // Create an ffmpeg producer - mlt_producer producer = mlt_factory_producer( "ffmpeg", file ); - - // Pass the producer - mlt_properties_set_data( properties, "producer", producer, 0, ( mlt_destructor )mlt_producer_close, NULL ); - - // Initialise the audio frame position - mlt_properties_set_position( properties, "dub_position", 0 ); - - return this; -} - diff --git a/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.h b/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.h deleted file mode 100644 index 688d01b..0000000 --- a/mlt/src/modules/ffmpeg/filter_ffmpeg_dub.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_ffmpeg_dub.h -- simple ffmpeg dub test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_FFMPEG_DUB_H_ -#define _FILTER_FFMPEG_DUB_H_ - -#include - -extern mlt_filter filter_ffmpeg_dub_init( char *file ); - -#endif diff --git a/mlt/src/modules/ffmpeg/producer_ffmpeg.c b/mlt/src/modules/ffmpeg/producer_ffmpeg.c deleted file mode 100644 index 15b1c89..0000000 --- a/mlt/src/modules/ffmpeg/producer_ffmpeg.c +++ /dev/null @@ -1,555 +0,0 @@ -/* - * producer_ffmpeg.c -- simple ffmpeg test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_ffmpeg.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -typedef struct producer_ffmpeg_s *producer_ffmpeg; - -/** Bi-directional pipe structure. -*/ - -typedef struct rwpipe -{ - int pid; - FILE *reader; - FILE *writer; -} -rwpipe; - -/** Create a bidirectional pipe for the given command. -*/ - -rwpipe *rwpipe_open( char *command ) -{ - rwpipe *this = malloc( sizeof( rwpipe ) ); - - if ( this != NULL ) - { - int input[ 2 ]; - int output[ 2 ]; - - pipe( input ); - pipe( output ); - - this->pid = fork(); - - if ( this->pid == 0 ) - { - signal( SIGPIPE, SIG_DFL ); - signal( SIGHUP, SIG_DFL ); - signal( SIGINT, SIG_DFL ); - signal( SIGTERM, SIG_DFL ); - signal( SIGSTOP, SIG_DFL ); - signal( SIGCHLD, SIG_DFL ); - - dup2( output[ 0 ], STDIN_FILENO ); - dup2( input[ 1 ], STDOUT_FILENO ); - - close( input[ 0 ] ); - close( input[ 1 ] ); - close( output[ 0 ] ); - close( output[ 1 ] ); - - execl( "/bin/sh", "sh", "-c", command, NULL ); - exit( 255 ); - } - else - { - setpgid( this->pid, this->pid ); - - close( input[ 1 ] ); - close( output[ 0 ] ); - - this->reader = fdopen( input[ 0 ], "r" ); - this->writer = fdopen( output[ 1 ], "w" ); - } - } - - return this; -} - -/** Read data from the pipe. -*/ - -FILE *rwpipe_reader( rwpipe *this ) -{ - if ( this != NULL ) - return this->reader; - else - return NULL; -} - -/** Write data to the pipe. -*/ - -FILE *rwpipe_writer( rwpipe *this ) -{ - if ( this != NULL ) - return this->writer; - else - return NULL; -} - -/** Close the pipe and process. -*/ - -void rwpipe_close( rwpipe *this ) -{ - if ( this != NULL ) - { - fclose( this->reader ); - fclose( this->writer ); - kill( - this->pid, SIGKILL ); - waitpid( - this->pid, NULL, 0 ); - free( this ); - } -} - -struct producer_ffmpeg_s -{ - struct mlt_producer_s parent; - rwpipe *video_pipe; - rwpipe *audio_pipe; - FILE *video; - FILE *audio; - uint64_t expected; - uint8_t *buffer; - int open; - int width; - int height; - int end_of_video; - int end_of_audio; -}; - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ); -static void producer_close( mlt_producer parent ); - -/** Consutruct an ffmpeg producer. -*/ - -mlt_producer producer_ffmpeg_init( char *file ) -{ - producer_ffmpeg this = calloc( sizeof( struct producer_ffmpeg_s ), 1 ); - if ( file != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) - { - int usable = 1; - - // Get the producer - mlt_producer producer = &this->parent; - - // Get the properties of the producer - mlt_properties properties = mlt_producer_properties( producer ); - - // Override get_frame and close methods - producer->get_frame = producer_get_frame; - producer->close = producer_close; - - // Set the properties - mlt_properties_set( properties, "mlt_type", "producer_ffmpeg" ); - - if ( !strcmp( file, "v4l" ) ) - { - mlt_properties_set( properties, "video_type", "v4l" ); - mlt_properties_set( properties, "video_file", "/dev/video0" ); - mlt_properties_set( properties, "video_size", "640x480" ); - mlt_properties_set( properties, "audio_type", "dsp" ); - mlt_properties_set( properties, "audio_file", "/dev/dsp" ); - } - else - { - struct stat buf; - if ( stat( file, &buf ) != 0 || !S_ISREG( buf.st_mode ) ) - usable = 0; - mlt_properties_set( properties, "video_type", "file" ); - mlt_properties_set( properties, "video_file", file ); - mlt_properties_set( properties, "video_size", "" ); - mlt_properties_set( properties, "audio_type", "file" ); - mlt_properties_set( properties, "audio_file", file ); - } - - mlt_properties_set_int( properties, "audio_rate", 48000 ); - mlt_properties_set_int( properties, "audio_channels", 2 ); - mlt_properties_set_int( properties, "audio_track", 0 ); - - mlt_properties_set( properties, "log_id", file ); - mlt_properties_set( properties, "resource", file ); - mlt_properties_set_position( properties, "length", 36000 ); - mlt_properties_set_position( properties, "out", 36000 ); - - this->buffer = malloc( 1024 * 1024 * 2 ); - - if ( !usable ) - { - mlt_producer_close( &this->parent ); - producer = NULL; - } - - return producer; - } - free( this ); - return NULL; -} - -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - if ( mlt_properties_get_int( properties, "has_image" ) ) - { - // Get width and height - *format = mlt_image_yuv422; - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - - // Specify format and image - *buffer = mlt_properties_get_data( properties, "image", NULL ); - } - else - { - mlt_frame_get_image( this, buffer, format, width, height, writable ); - } - - return 0; -} - -FILE *producer_ffmpeg_run_video( producer_ffmpeg this, mlt_position position ) -{ - if ( this->video == NULL ) - { - // Get the producer - mlt_producer producer = &this->parent; - - // Get the properties of the producer - mlt_properties properties = mlt_producer_properties( producer ); - - // Get the video loop property - int video_loop = mlt_properties_get_int( properties, "video_loop" ); - - if ( !this->open || video_loop ) - { - const char *mlt_prefix = mlt_factory_prefix( ); - char *video_type = mlt_properties_get( properties, "video_type" ); - char *video_file = mlt_properties_get( properties, "video_file" ); - float video_rate = mlt_properties_get_double( properties, "fps" ); - char *video_size = mlt_properties_get( properties, "video_size" ); - char command[ 1024 ] = ""; - - sprintf( command, "%s/ffmpeg/video.sh \"%s\" \"%s\" \"%s\" %f %f 2>/dev/null", - mlt_prefix, - video_type, - video_file, - video_size, - video_rate, - ( float )position ); - - this->video_pipe = rwpipe_open( command ); - this->video = rwpipe_reader( this->video_pipe ); - } - } - return this->video; -} - -FILE *producer_ffmpeg_run_audio( producer_ffmpeg this, mlt_position position ) -{ - // Get the producer - mlt_producer producer = &this->parent; - - // Get the properties of the producer - mlt_properties properties = mlt_producer_properties( producer ); - - if ( this->audio == NULL ) - { - int audio_loop = mlt_properties_get_int( properties, "audio_loop" ); - - if ( !this->open || audio_loop ) - { - const char *mlt_prefix = mlt_factory_prefix( ); - char *audio_type = mlt_properties_get( properties, "audio_type" ); - char *audio_file = mlt_properties_get( properties, "audio_file" ); - int frequency = mlt_properties_get_int( properties, "audio_rate" ); - int channels = mlt_properties_get_int( properties, "audio_channels" ); - int track = mlt_properties_get_int( properties, "audio_track" ); - char command[ 1024 ] = ""; - - sprintf( command, "%s/ffmpeg/audio.sh \"%s\" \"%s\" %f %d %d %d 2>/dev/null", - mlt_prefix, - audio_type, - audio_file, - ( float )position, - frequency, - channels, - track ); - - this->audio_pipe = rwpipe_open( command ); - this->audio = rwpipe_reader( this->audio_pipe ); - } - } - return this->audio; -} - -static void producer_ffmpeg_position( producer_ffmpeg this, uint64_t requested, int *skip ) -{ - *skip = 0; - - if ( this->open && requested > this->expected ) - { - // Skip the following n frames - *skip = requested - this->expected; - } - else if ( requested != this->expected ) - { - // Close the video pipe - if ( this->video != NULL ) - rwpipe_close( this->video_pipe ); - this->video = NULL; - - // Close the audio pipe - if ( this->audio != NULL ) - rwpipe_close( this->audio_pipe ); - this->audio = NULL; - - // We should not be open now - this->open = 0; - this->end_of_video = 0; - this->end_of_audio = 0; - } - - // This is the next frame we expect - this->expected = requested + 1; - - // Open the pipe - this->video = producer_ffmpeg_run_video( this, 0 ); - - // Open the audio pipe - this->audio = producer_ffmpeg_run_audio( this, 0 ); - - // We should be open now - this->open = 1; -} - -static int producer_get_audio( mlt_frame this, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Get the frames properties - mlt_properties properties = mlt_frame_properties( this ); - - producer_ffmpeg producer = mlt_properties_get_data( properties, "producer_ffmpeg", NULL ); - mlt_properties producer_properties = mlt_producer_properties( &producer->parent ); - - int64_t target = mlt_properties_get_double( properties, "target" ); - int skip = mlt_properties_get_int( properties, "skip" ); - - float fps = mlt_properties_get_double( producer_properties, "fps" ); - *frequency = mlt_properties_get_int( producer_properties, "audio_rate" ); - *channels = mlt_properties_get_int( producer_properties, "audio_channels" ); - - // Maximum Size (?) - int size = ( *frequency / 25 ) * *channels * 2; - - // Allocate an image - *buffer = malloc( size ); - - // Read it - if ( producer->audio != NULL ) - { - do - { - *samples = mlt_sample_calculator( fps, *frequency, target - skip ); - if ( fread( *buffer, *samples * *channels * 2, 1, producer->audio ) != 1 ) - { - rwpipe_close( producer->audio_pipe ); - producer->audio = NULL; - producer->end_of_audio = 1; - } - } - while( producer->audio != NULL && skip -- ); - } - else - { - *samples = mlt_sample_calculator( fps, *frequency, target ); - memset( *buffer, 0, size ); - } - - // Pass the data on the frame properties - mlt_properties_set_data( properties, "audio", *buffer, size, free, NULL ); - - // Set the producer properties - mlt_properties_set_int( producer_properties, "end_of_clip", producer->end_of_video && producer->end_of_audio ); - - return 0; -} - -static int read_ffmpeg_header( producer_ffmpeg this, int *width, int *height ) -{ - int count = 0; - char temp[ 132 ]; - FILE *video = this->video; - - if ( fgets( temp, 132, video ) ) - { - if ( strncmp( temp, "FRAME", 5 ) ) - { - if ( strstr( temp, " W" ) != NULL ) - *width = atoi( strstr( temp, " W" ) + 2 ); - if ( strstr( temp, " H" ) != NULL ) - *height = atoi( strstr( temp, " H" ) + 2 ); - count = 2; - fgets( temp, 132, video ); - this->width = *width; - this->height = *height; - } - else - { - *width = this->width; - *height = this->height; - count = 2; - } - } - return count; -} - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - producer_ffmpeg this = producer->child; - int width; - int height; - int skip; - - // Construct a test frame - *frame = mlt_frame_init( ); - - // Are we at the position expected? - producer_ffmpeg_position( this, mlt_producer_frame( producer ), &skip ); - - // Get properties objects - mlt_properties producer_properties = mlt_producer_properties( &this->parent ); - - // Get the frames properties - mlt_properties properties = mlt_frame_properties( *frame ); - - FILE *video = this->video; - - mlt_properties_set_double( properties, "target", mlt_producer_frame( producer ) ); - mlt_properties_set_int( properties, "skip", skip ); - - // Read the video - if ( video != NULL && read_ffmpeg_header( this, &width, &height ) == 2 ) - { - // Allocate an image - uint8_t *image = malloc( width * height * 2 ); - - // Read it - while( skip -- ) - { - if ( fread( this->buffer, width * height * 3 / 2, 1, video ) == 1 ) - read_ffmpeg_header( this, &width, &height ); - else - skip = 0; - } - - fread( this->buffer, width * height * 3 / 2, 1, video ); - - // Convert it - mlt_convert_yuv420p_to_yuv422( this->buffer, width, height, width, image ); - - // Pass the data on the frame properties - mlt_properties_set_data( properties, "image", image, width * height * 2, free, NULL ); - mlt_properties_set_int( properties, "width", width ); - mlt_properties_set_int( properties, "height", height ); - mlt_properties_set_int( properties, "has_image", 1 ); - - // Push the image callback - mlt_frame_push_get_image( *frame, producer_get_image ); - } - else - { - // Clean up - if ( this->video != NULL ) - { - int video_loop = mlt_properties_get_int( producer_properties, "video_loop" ); - - // Inform caller that end of clip is reached - this->end_of_video = !video_loop; - rwpipe_close( this->video_pipe ); - this->video = NULL; - } - - // Push the image callback - if ( !this->end_of_video ) - mlt_frame_push_get_image( *frame, producer_get_image ); - } - - // Set the audio pipe - mlt_properties_set_data( properties, "producer_ffmpeg", this, 0, NULL, NULL ); - - // Hmm - register audio callback - if ( !this->end_of_audio ) - ( *frame )->get_audio = producer_get_audio; - - // Get the additional properties - double aspect_ratio = mlt_properties_get_double( producer_properties, "aspect_ratio" ); - double speed = mlt_properties_get_double( producer_properties, "speed" ); - - // Set them on the frame - mlt_properties_set_double( properties, "aspect_ratio", aspect_ratio ); - mlt_properties_set_double( properties, "speed", speed ); - - // Set the out point on the producer - if ( this->end_of_video && this->end_of_audio ) - { - mlt_properties_set_int( properties, "end_of_clip", 1 ); - mlt_properties_set_position( producer_properties, "length", mlt_producer_position( &this->parent ) ); - mlt_producer_set_in_and_out( &this->parent, mlt_producer_get_in( &this->parent ), mlt_producer_position( &this->parent ) ); - } - - // Update timecode on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); - - // Calculate the next timecode - mlt_producer_prepare_next( producer ); - - return 0; -} - -static void producer_close( mlt_producer parent ) -{ - producer_ffmpeg this = parent->child; - if ( this->video ) - rwpipe_close( this->video_pipe ); - if ( this->audio ) - rwpipe_close( this->audio_pipe ); - parent->close = NULL; - mlt_producer_close( parent ); - free( this->buffer ); - free( this ); -} - diff --git a/mlt/src/modules/ffmpeg/producer_ffmpeg.h b/mlt/src/modules/ffmpeg/producer_ffmpeg.h deleted file mode 100644 index b283850..0000000 --- a/mlt/src/modules/ffmpeg/producer_ffmpeg.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * producer_ffmpeg.h -- simple ffmpeg test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_FFMPEG_H_ -#define _PRODUCER_FFMPEG_H_ - -#include - -extern mlt_producer producer_ffmpeg_init( char *file ); - -#endif diff --git a/mlt/src/modules/ffmpeg/video.sh b/mlt/src/modules/ffmpeg/video.sh deleted file mode 100755 index f8689fe..0000000 --- a/mlt/src/modules/ffmpeg/video.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -trap exit - -video_type="$1" -video_file="$2" -video_size="$3" -video_fps=$4 -video_position=$5 - -[ "$video_size" != "" ] && video_size="-s "$video_size - -if [ "$video_type" == "v4l" ] -then ffmpeg -vd "$video_file" -r $video_fps $video_size -f imagepipe -f yuv4mpegpipe - -else ffmpeg -i "$video_file" -ss $video_position -f imagepipe -r $video_fps $video_size -f yuv4mpegpipe - -fi diff --git a/mlt/src/modules/gtk2/Makefile b/mlt/src/modules/gtk2/Makefile deleted file mode 100644 index 3130918..0000000 --- a/mlt/src/modules/gtk2/Makefile +++ /dev/null @@ -1,30 +0,0 @@ - -TARGET = ../libmltgtk2.so - -OBJS = factory.o \ - producer_pixbuf.o \ - producer_pango.o - -CFLAGS = `pkg-config gdk-pixbuf-2.0 --cflags` `pkg-config pangoft2 --cflags` -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -LDFLAGS = `pkg-config gdk-pixbuf-2.0 --libs` `pkg-config pangoft2 --libs` - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/gtk2/configure b/mlt/src/modules/gtk2/configure deleted file mode 100755 index 04a232a..0000000 --- a/mlt/src/modules/gtk2/configure +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -pixbuf libmltgtk2.so -pango libmltgtk2.so -EOF - -fi - diff --git a/mlt/src/modules/gtk2/factory.c b/mlt/src/modules/gtk2/factory.c deleted file mode 100644 index 38e1692..0000000 --- a/mlt/src/modules/gtk2/factory.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "producer_pixbuf.h" -#include "producer_pango.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "pixbuf" ) ) - return producer_pixbuf_init( arg ); - else if ( !strcmp( id, "pango" ) ) - return producer_pango_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - return NULL; -} - diff --git a/mlt/src/modules/gtk2/producer_pango.c b/mlt/src/modules/gtk2/producer_pango.c deleted file mode 100644 index f1952dc..0000000 --- a/mlt/src/modules/gtk2/producer_pango.c +++ /dev/null @@ -1,452 +0,0 @@ -/* - * producer_pango.c -- a pango-based titler - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_pango.h" -#include -#include -#include -#include -#include -#include - -struct producer_pango_s -{ - struct mlt_producer_s parent; - int width; - int height; - uint8_t *image; - uint8_t *alpha; - int fgcolor; - int bgcolor; - int align; - int pad; - char *markup; - char *text; - char *font; -}; - -// special color type used by internal pango routines -typedef struct -{ - uint8_t r, g, b, a; -} rgba_color; - -// Forward declarations -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); -static void producer_close( mlt_producer parent ); -static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg ); -static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, - rgba_color fg, rgba_color bg, int pad, int align ); - -mlt_producer producer_pango_init( const char *filename ) -{ - producer_pango this = calloc( sizeof( struct producer_pango_s ), 1 ); - if ( this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) - { - mlt_producer producer = &this->parent; - - producer->get_frame = producer_get_frame; - producer->close = producer_close; - - // This is required to initialise gdk-pixbuf - g_type_init(); - - // Get the properties interface - mlt_properties properties = mlt_producer_properties( &this->parent ); - - // Set the default properties - mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); - mlt_properties_set_int( properties, "fgcolor", 0xffffffff ); - mlt_properties_set_int( properties, "bgcolor", 0x00000000 ); - mlt_properties_set_int( properties, "align", pango_align_left ); - mlt_properties_set_int( properties, "pad", 0 ); - mlt_properties_set( properties, "text", "" ); - mlt_properties_set( properties, "font", "Sans 48" ); - mlt_properties_set_int( properties, "x", 0 ); - mlt_properties_set_int( properties, "y", 0 ); - mlt_properties_set_double( properties, "mix", 1.0 ); - - if ( filename == NULL ) - { - mlt_properties_set( properties, "resource", "pango" ); - mlt_properties_set( properties, "markup", "" ); - } - else - { - FILE *f = fopen( filename, "r" ); - if ( f != NULL ) - { - char line[81]; - char *markup = NULL; - size_t size = 0; - line[80] = '\0'; - - while ( fgets( line, 80, f ) ) - { - size += strlen( line ) + 1; - if ( markup ) - { - realloc( markup, size ); - strcat( markup, line ); - } - else - { - markup = strdup( line ); - } - } - fclose( f ); - mlt_properties_set( properties, "resource", ( char * ) filename ); - mlt_properties_set( properties, "markup", ( char * ) ( markup == NULL ? "" : markup ) ); - if ( markup ) - free( markup ); - } - else - { - mlt_properties_set( properties, "resource", "pango" ); - mlt_properties_set( properties, "markup", "" ); - } - } - - return producer; - } - free( this ); - return NULL; -} - -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( this ); - - // May need to know the size of the image to clone it - int size = 0; - - // Get the image - uint8_t *image = mlt_properties_get_data( properties, "image", &size ); - - // Get width and height - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - - // Clone if necessary - if ( writable ) - { - // Clone our image - uint8_t *copy = malloc( size ); - memcpy( copy, image, size ); - - // We're going to pass the copy on - image = copy; - - // Now update properties so we free the copy after - mlt_properties_set_data( properties, "image", copy, size, free, NULL ); - } - - // Pass on the image - *buffer = image; - - return 0; -} - -static uint8_t *producer_get_alpha_mask( mlt_frame this ) -{ - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( this ); - - // Return the alpha mask - return mlt_properties_get_data( properties, "alpha", NULL ); -} - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - producer_pango this = producer->child; - GdkPixbuf *pixbuf = NULL; - - // Generate a frame - *frame = mlt_frame_init( ); - - // Obtain properties of frame and producer - mlt_properties properties = mlt_frame_properties( *frame ); - mlt_properties producer_props = mlt_producer_properties( producer ); - - // Get producer properties - int fg = mlt_properties_get_int( producer_props, "fgcolor" ); - int bg = mlt_properties_get_int( producer_props, "bgcolor" ); - int align = mlt_properties_get_int( producer_props, "align" ); - int pad = mlt_properties_get_int( producer_props, "pad" ); - char *markup = mlt_properties_get( producer_props, "markup" ); - char *text = mlt_properties_get( producer_props, "text" ); - char *font = mlt_properties_get( producer_props, "font" ); - - // See if any properties changed - int property_changed = ( fg != this->fgcolor ); - property_changed = property_changed || ( bg != this->bgcolor ); - property_changed = property_changed || ( align != this->align ); - property_changed = property_changed || ( pad != this->pad ); - property_changed = property_changed || ( markup && this->markup && strcmp( markup, this->markup ) ); - property_changed = property_changed || ( text && this->text && strcmp( text, this->text ) ); - property_changed = property_changed || ( font && this->font && strcmp( font, this->font ) ); - - // Save the properties for next comparison - this->fgcolor = fg; - this->bgcolor = bg; - this->align = align; - this->pad = pad; - if ( markup != NULL ) - { - if ( this->markup != NULL ) - free( this->markup ); - this->markup = strdup( markup ); - } - if ( text != NULL ) - { - if ( this->text != NULL ) - free( this->text ); - this->text = strdup( text ); - } - if ( font != NULL ) - { - if ( this->font != NULL ) - free( this->font ); - this->font = strdup( font ); - } - - if ( property_changed ) - { - rgba_color fgcolor = - { - ( fg & 0xff000000 ) >> 24, - ( fg & 0x00ff0000 ) >> 16, - ( fg & 0x0000ff00 ) >> 8, - ( fg & 0x000000ff ) - }; - rgba_color bgcolor = - { - ( bg & 0xff000000 ) >> 24, - ( bg & 0x00ff0000 ) >> 16, - ( bg & 0x0000ff00 ) >> 8, - ( bg & 0x000000ff ) - }; - - // Render the title - pixbuf = pango_get_pixbuf( markup, text, font, fgcolor, bgcolor, pad, align ); - } - - // If we have a pixbuf - if ( pixbuf ) - { - // Scale to adjust for sample aspect ratio - if ( mlt_properties_get_int( properties, "video_standard" ) == mlt_video_standard_pal ) - { - GdkPixbuf *temp = pixbuf; - GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, - (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 54.0/59.0), - gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER ); - pixbuf = scaled; - g_object_unref( temp ); - } - else - { - GdkPixbuf *temp = pixbuf; - GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, - (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 11.0/10.0 ), - gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER ); - pixbuf = scaled; - g_object_unref( temp ); - } - - // Store width and height - this->width = gdk_pixbuf_get_width( pixbuf ); - this->height = gdk_pixbuf_get_height( pixbuf ); - - // Allocate/define image and alpha - uint8_t *image = malloc( this->width * this->height * 2 ); - uint8_t *alpha = NULL; - - // Extract YUV422 and alpha - if ( gdk_pixbuf_get_has_alpha( pixbuf ) ) - { - // Allocate the alpha mask - alpha = malloc( this->width * this->height ); - - // Convert the image - mlt_convert_rgb24a_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ), - this->width, this->height, - gdk_pixbuf_get_rowstride( pixbuf ), - image, alpha ); - } - else - { - // No alpha to extract - mlt_convert_rgb24_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ), - this->width, this->height, - gdk_pixbuf_get_rowstride( pixbuf ), - image ); - } - - // Finished with pixbuf now - g_object_unref( pixbuf ); - - // if single picture, reference the image and alpha in the producer - if ( this->image != NULL ) - free( this->image ); - this->image = image; - if ( this->alpha != NULL ) - free( this->alpha ); - this->alpha = alpha; - - } - - if ( this->image != NULL ) - { - // Set width/height - mlt_properties_set_int( properties, "width", this->width ); - mlt_properties_set_int( properties, "height", this->height ); - - // Set the compositing properties - if ( mlt_properties_get( producer_props, "x" ) != NULL ) - mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) ); - if ( mlt_properties_get( producer_props, "y" ) != NULL ) - mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) ); - if ( mlt_properties_get( producer_props, "mix" ) != NULL ) - mlt_properties_set_double( properties, "image.mix", mlt_properties_get_double( producer_props, "mix" ) ); - - // if picture sequence pass the image and alpha data without destructor - mlt_properties_set_data( properties, "image", this->image, this->width * this->height * 2, NULL, NULL ); - mlt_properties_set_data( properties, "alpha", this->alpha, this->width * this->height, NULL, NULL ); - - // Set alpha mask call back - ( *frame )->get_alpha_mask = producer_get_alpha_mask; - - // Stack the get image callback - mlt_frame_push_get_image( *frame, producer_get_image ); - } - - // Update timecode on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); - - // Calculate the next timecode - mlt_producer_prepare_next( producer ); - - return 0; -} - -static void producer_close( mlt_producer parent ) -{ - producer_pango this = parent->child; - if ( this->image != NULL ) - free( this->image ); - if ( this->alpha != NULL ) - free( this->alpha ); - if ( this->markup != NULL ) - free( this->markup ); - if ( this->text != NULL ) - free( this->text ); - if ( this->font != NULL ) - free( this->font ); - parent->close = NULL; - mlt_producer_close( parent ); - free( this ); -} - -static void pango_draw_background( GdkPixbuf *pixbuf, rgba_color bg ) -{ - int ww = gdk_pixbuf_get_width( pixbuf ); - int hh = gdk_pixbuf_get_height( pixbuf ); - uint8_t *p = gdk_pixbuf_get_pixels( pixbuf ); - int i, j; - - for ( j = 0; j < hh; j++ ) - { - for ( i = 0; i < ww; i++ ) - { - *p++ = bg.r; - *p++ = bg.g; - *p++ = bg.b; - *p++ = bg.a; - } - } -} - -static GdkPixbuf *pango_get_pixbuf( const char *markup, const char *text, const char *font, rgba_color fg, rgba_color bg, int pad, int align ) -{ - PangoFT2FontMap *fontmap = (PangoFT2FontMap*) pango_ft2_font_map_new(); - PangoContext *context = pango_ft2_font_map_create_context( fontmap ); - PangoLayout *layout = pango_layout_new( context ); - int w, h, x; - int i, j; - GdkPixbuf *pixbuf = NULL; - FT_Bitmap bitmap; - uint8_t *src = NULL; - uint8_t* dest = NULL; - int stride; - - pango_ft2_font_map_set_resolution( fontmap, 72, 72 ); - pango_layout_set_width( layout, -1 ); // set wrapping constraints - pango_layout_set_font_description( layout, pango_font_description_from_string( font ) ); -// pango_layout_set_spacing( layout, space ); - pango_layout_set_alignment( layout, ( PangoAlignment ) align ); - if ( markup != NULL && strcmp( markup, "" ) != 0 ) - pango_layout_set_markup( layout, markup, strlen( markup ) ); - else if ( text != NULL && strcmp( text, "" ) != 0 ) - pango_layout_set_text( layout, text, strlen( text ) ); - else - return NULL; - pango_layout_get_pixel_size( layout, &w, &h ); - - pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE /* has alpha */, 8, w + 2 * pad, h + 2 * pad ); - pango_draw_background( pixbuf, bg ); - - stride = gdk_pixbuf_get_rowstride( pixbuf ); - - bitmap.width = w; - bitmap.pitch = 32 * ( ( w + 31 ) / 31 ); - bitmap.rows = h; - bitmap.buffer = ( unsigned char * ) calloc( 1, h * bitmap.pitch ); - bitmap.num_grays = 256; - bitmap.pixel_mode = ft_pixel_mode_grays; - - pango_ft2_render_layout( &bitmap, layout, 0, 0 ); - - src = bitmap.buffer; - x = ( gdk_pixbuf_get_width( pixbuf ) - w - 2 * pad ) * align / 2 + pad; - dest = gdk_pixbuf_get_pixels( pixbuf ) + 4 * x + pad * stride; - for ( j = 0; j < h; j++ ) - { - uint8_t *d = dest; - for ( i = 0; i < w; i++ ) - { - float a = ( float ) bitmap.buffer[ j * bitmap.pitch + i ] / 255.0; - *d++ = ( int ) ( a * fg.r + ( 1 - a ) * bg.r ); - *d++ = ( int ) ( a * fg.g + ( 1 - a ) * bg.g ); - *d++ = ( int ) ( a * fg.b + ( 1 - a ) * bg.b ); - *d++ = ( int ) ( a * fg.a + ( 1 - a ) * bg.a ); - } - dest += stride; - } - free( bitmap.buffer ); - - g_object_unref( layout ); - g_object_unref( context ); - g_object_unref( fontmap ); - - return pixbuf; -} - diff --git a/mlt/src/modules/gtk2/producer_pango.h b/mlt/src/modules/gtk2/producer_pango.h deleted file mode 100644 index fbed05c..0000000 --- a/mlt/src/modules/gtk2/producer_pango.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * producer_pango.h -- a pango-based titler - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_PANGO_H_ -#define _PRODUCER_PANGO_H_ - -#include - -typedef struct producer_pango_s *producer_pango; - -typedef enum -{ - pango_align_left = 0, - pango_align_center, - pango_align_right -} pango_align; - -extern mlt_producer producer_pango_init( const char *filename ); - -#endif diff --git a/mlt/src/modules/gtk2/producer_pixbuf.c b/mlt/src/modules/gtk2/producer_pixbuf.c deleted file mode 100644 index 8a1d3a3..0000000 --- a/mlt/src/modules/gtk2/producer_pixbuf.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * producer_pixbuf.c -- raster image loader based upon gdk-pixbuf - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_pixbuf.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int index ); -static void producer_close( mlt_producer parent ); - -typedef enum -{ - SIGNAL_FORMAT_PAL, - SIGNAL_FORMAT_NTSC -} mlt_signal_format; - -static int filter_files( const struct dirent *de ) -{ - if ( de->d_name[ 0 ] != '.' ) - return 1; - else - return 0; -} - - -mlt_producer producer_pixbuf_init( char *filename ) -{ - producer_pixbuf this = calloc( sizeof( struct producer_pixbuf_s ), 1 ); - if ( filename != NULL && this != NULL && mlt_producer_init( &this->parent, this ) == 0 ) - { - mlt_producer producer = &this->parent; - - producer->get_frame = producer_get_frame; - producer->close = producer_close; - - // Get the properties interface - mlt_properties properties = mlt_producer_properties( &this->parent ); - - // Set the default properties - mlt_properties_set( properties, "resource", filename ); - mlt_properties_set_int( properties, "video_standard", mlt_video_standard_pal ); - mlt_properties_set_double( properties, "ttl", 5 ); - - // Obtain filenames - if ( strchr( filename, '%' ) != NULL ) - { - // handle picture sequences - int i = 0; - int gap = 0; - char full[1024]; - - while ( gap < 100 ) - { - struct stat buf; - snprintf( full, 1023, filename, i ++ ); - if ( stat( full, &buf ) == 0 ) - { - this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) ); - this->filenames[ this->count ++ ] = strdup( full ); - gap = 0; - } - else - { - gap ++; - } - } - mlt_properties_set_position( properties, "out", this->count * 25 ); - } - else if ( strstr( filename, "/.all." ) != NULL ) - { - char *dir_name = strdup( filename ); - char *extension = strrchr( filename, '.' ); - *( strstr( dir_name, "/.all." ) + 1 ) = '\0'; - char fullname[ 1024 ]; - strcpy( fullname, dir_name ); - struct dirent **de = NULL; - int n = scandir( fullname, &de, filter_files, alphasort ); - int i; - struct stat info; - - for (i = 0; i < n; i++ ) - { - snprintf( fullname, 1023, "%s%s", dir_name, de[i]->d_name ); - - if ( lstat( fullname, &info ) == 0 && - ( S_ISREG( info.st_mode ) || ( strstr( fullname, extension ) && info.st_mode | S_IXUSR ) ) ) - { - this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) ); - this->filenames[ this->count ++ ] = strdup( fullname ); - } - free( de[ i ] ); - } - - mlt_properties_set_position( properties, "out", this->count * 25 ); - free( de ); - free( dir_name ); - } - else - { - this->filenames = realloc( this->filenames, sizeof( char * ) * ( this->count + 1 ) ); - this->filenames[ this->count ++ ] = strdup( filename ); - mlt_properties_set_position( properties, "out", 25 ); - } - - // Initialise gobject types - g_type_init(); - - return producer; - } - free( this ); - return NULL; -} - -static int producer_get_image( mlt_frame this, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable ) -{ - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( this ); - - // May need to know the size of the image to clone it - int size = 0; - - // Get the image - uint8_t *image = mlt_properties_get_data( properties, "image", &size ); - - // Get width and height - *width = mlt_properties_get_int( properties, "width" ); - *height = mlt_properties_get_int( properties, "height" ); - - // Clone if necessary - // NB: Cloning is necessary with this producer (due to processing of images ahead of use) - // The fault is not in the design of mlt, but in the implementation of pixbuf... - //if ( writable ) - { - size = *width * *height * 2; - - // Clone our image - uint8_t *copy = malloc( size ); - memcpy( copy, image, size ); - - // We're going to pass the copy on - image = copy; - - // Now update properties so we free the copy after - mlt_properties_set_data( properties, "image", copy, size, free, NULL ); - } - - // Pass on the image - *buffer = image; - - return 0; -} - -static uint8_t *producer_get_alpha_mask( mlt_frame this ) -{ - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( this ); - - // Return the alpha mask - return mlt_properties_get_data( properties, "alpha", NULL ); -} - -static int producer_get_frame( mlt_producer producer, mlt_frame_ptr frame, int index ) -{ - producer_pixbuf this = producer->child; - GdkPixbuf *pixbuf = NULL; - GError *error = NULL; - - // Generate a frame - *frame = mlt_frame_init( ); - - // Obtain properties of frame - mlt_properties properties = mlt_frame_properties( *frame ); - - // Obtain properties of producer - mlt_properties producer_props = mlt_producer_properties( producer ); - - // Get the time to live for each frame - double ttl = mlt_properties_get_double( producer_props, "ttl" ); - - // Image index - int image_idx = ( int )floor( mlt_producer_position( producer ) / ttl ) % this->count; - - // Update timecode on the frame we're creating - mlt_frame_set_position( *frame, mlt_producer_position( producer ) ); - - // optimization for subsequent iterations on single picture - if ( this->image != NULL && image_idx == this->image_idx ) - { - // Set width/height - mlt_properties_set_int( properties, "width", this->width ); - mlt_properties_set_int( properties, "height", this->height ); - - // Set the compositing properties - if ( mlt_properties_get( producer_props, "x" ) != NULL ) - mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) ); - if ( mlt_properties_get( producer_props, "y" ) != NULL ) - mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) ); - if ( mlt_properties_get( producer_props, "mix" ) != NULL ) - mlt_properties_set_double( properties, "image.mix", mlt_properties_get_double( producer_props, "mix" ) ); - - // if picture sequence pass the image and alpha data without destructor - mlt_properties_set_data( properties, "image", this->image, 0, NULL, NULL ); - mlt_properties_set_data( properties, "alpha", this->alpha, 0, NULL, NULL ); - - // Set alpha mask call back - ( *frame )->get_alpha_mask = producer_get_alpha_mask; - - // Stack the get image callback - mlt_frame_push_get_image( *frame, producer_get_image ); - } - else - { - free( this->image ); - free( this->alpha ); - this->image_idx = image_idx; - pixbuf = gdk_pixbuf_new_from_file( this->filenames[ image_idx ], &error ); - } - - // If we have a pixbuf - if ( pixbuf ) - { - // Scale to adjust for sample aspect ratio - if ( mlt_properties_get_int( properties, "video_standard" ) == mlt_video_standard_pal ) - { - GdkPixbuf *temp = pixbuf; - GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, - (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 54.0/59.0), - gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER ); - pixbuf = scaled; - g_object_unref( temp ); - } - else - { - GdkPixbuf *temp = pixbuf; - GdkPixbuf *scaled = gdk_pixbuf_scale_simple( pixbuf, - (gint) ( (float) gdk_pixbuf_get_width( pixbuf ) * 11.0/10.0 ), - gdk_pixbuf_get_height( pixbuf ), GDK_INTERP_HYPER ); - pixbuf = scaled; - g_object_unref( temp ); - } - - // Store width and height - this->width = gdk_pixbuf_get_width( pixbuf ); - this->height = gdk_pixbuf_get_height( pixbuf ); - this->width -= this->width % 4; - this->height -= this->height % 2; - - // Allocate/define image and alpha - uint8_t *image = malloc( this->width * this->height * 2 ); - uint8_t *alpha = NULL; - - // Extract YUV422 and alpha - if ( gdk_pixbuf_get_has_alpha( pixbuf ) ) - { - // Allocate the alpha mask - alpha = malloc( this->width * this->height ); - - // Convert the image - mlt_convert_rgb24a_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ), - this->width, this->height, - gdk_pixbuf_get_rowstride( pixbuf ), - image, alpha ); - } - else - { - // No alpha to extract - mlt_convert_rgb24_to_yuv422( gdk_pixbuf_get_pixels( pixbuf ), - this->width, this->height, - gdk_pixbuf_get_rowstride( pixbuf ), - image ); - } - - // Finished with pixbuf now - g_object_unref( pixbuf ); - - // Set width/height of frame - mlt_properties_set_int( properties, "width", this->width ); - mlt_properties_set_int( properties, "height", this->height ); - - // Set the compositing properties - if ( mlt_properties_get( producer_props, "x" ) != NULL ) - mlt_properties_set_int( properties, "x", mlt_properties_get_int( producer_props, "x" ) ); - if ( mlt_properties_get( producer_props, "y" ) != NULL ) - mlt_properties_set_int( properties, "y", mlt_properties_get_int( producer_props, "y" ) ); - if ( mlt_properties_get( producer_props, "mix" ) != NULL ) - mlt_properties_set_double( properties, "mix", mlt_properties_get_double( producer_props, "mix" ) ); - - // Pass alpha and image on properties with or without destructor - this->image = image; - this->alpha = alpha; - - // pass the image and alpha data without destructor - mlt_properties_set_data( properties, "image", image, this->width * this->height * 2, NULL, NULL ); - mlt_properties_set_data( properties, "alpha", alpha, this->width * this->height, NULL, NULL ); - - // Set alpha call back - ( *frame )->get_alpha_mask = producer_get_alpha_mask; - - // Push the get_image method - mlt_frame_push_get_image( *frame, producer_get_image ); - } - - // Calculate the next timecode - mlt_producer_prepare_next( producer ); - - return 0; -} - -static void producer_close( mlt_producer parent ) -{ - producer_pixbuf this = parent->child; - if ( this->image ) - free( this->image ); - if ( this->alpha ) - free( this->alpha ); - parent->close = NULL; - mlt_producer_close( parent ); - free( this ); -} - diff --git a/mlt/src/modules/gtk2/producer_pixbuf.h b/mlt/src/modules/gtk2/producer_pixbuf.h deleted file mode 100644 index 74b8f7a..0000000 --- a/mlt/src/modules/gtk2/producer_pixbuf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * producer_pixbuf.h -- raster image loader based upon gdk-pixbuf - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_PIXBUF_H_ -#define _PRODUCER_PIXBUF_H_ - -#include - -typedef struct producer_pixbuf_s *producer_pixbuf; - -struct producer_pixbuf_s -{ - struct mlt_producer_s parent; - - // File name list - char **filenames; - int count; - int image_idx; - - int width; - int height; - uint8_t *image; - uint8_t *alpha; -}; - -extern mlt_producer producer_pixbuf_init( char *filename ); - -#endif diff --git a/mlt/src/modules/inigo/Makefile b/mlt/src/modules/inigo/Makefile deleted file mode 100644 index c52ae1d..0000000 --- a/mlt/src/modules/inigo/Makefile +++ /dev/null @@ -1,27 +0,0 @@ - -TARGET = ../libinigo.so - -OBJS = factory.o \ - producer_inigo.o - -CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/inigo/configure b/mlt/src/modules/inigo/configure deleted file mode 100755 index 617ee0a..0000000 --- a/mlt/src/modules/inigo/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -inigo libinigo.so -EOF - -fi - diff --git a/mlt/src/modules/inigo/factory.c b/mlt/src/modules/inigo/factory.c deleted file mode 100644 index 29320a8..0000000 --- a/mlt/src/modules/inigo/factory.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "producer_inigo.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "inigo" ) ) - return producer_inigo_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - return NULL; -} - diff --git a/mlt/src/modules/inigo/producer_inigo.c b/mlt/src/modules/inigo/producer_inigo.c deleted file mode 100644 index 3150ae6..0000000 --- a/mlt/src/modules/inigo/producer_inigo.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * producer_inigo.c -- simple inigo test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_inigo.h" - -#include -#include -#include - -#include - -static mlt_producer parse_inigo( char *file ) -{ - FILE *input = fopen( file, "r" ); - char **args = calloc( sizeof( char * ), 1000 ); - int count = 0; - char temp[ 2048 ]; - - if ( input != NULL ) - { - while( fgets( temp, 2048, input ) ) - { - temp[ strlen( temp ) - 1 ] = '\0'; - if ( strcmp( temp, "" ) ) - args[ count ++ ] = strdup( temp ); - } - } - - mlt_producer result = producer_inigo_init( args ); - - if ( result != NULL ) - { - mlt_properties properties = mlt_producer_properties( result ); - mlt_properties_set( properties, "resource", file ); - } - - while( count -- ) - free( args[ count ] ); - free( args ); - - return result; -} - -static mlt_producer create_producer( char *file ) -{ - mlt_producer result = NULL; - - // 1st Line preferences - if ( strstr( file, ".inigo" ) ) - result = parse_inigo( file ); - else if ( strstr( file, ".mpg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".mpeg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".jpg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".JPG" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".jpeg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".png" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".txt" ) ) - result = mlt_factory_producer( "pango", file ); - - // 2nd Line fallbacks - if ( result == NULL && strstr( file, ".dv" ) ) - result = mlt_factory_producer( "libdv", file ); - else if ( result == NULL && strstr( file, ".dif" ) ) - result = mlt_factory_producer( "libdv", file ); - - // 3rd line fallbacks - if ( result == NULL ) - result = mlt_factory_producer( "ffmpeg", file ); - - return result; -} - -static void track_service( mlt_field field, void *service, mlt_destructor destructor ) -{ - mlt_properties properties = mlt_field_properties( field ); - int registered = mlt_properties_get_int( properties, "registered" ); - char *key = mlt_properties_get( properties, "registered" ); - mlt_properties_set_data( properties, key, service, 0, destructor, NULL ); - mlt_properties_set_int( properties, "registered", ++ registered ); -} - -static mlt_filter create_filter( mlt_field field, char *id, int track ) -{ - char *arg = strchr( id, ':' ); - if ( arg != NULL ) - *arg ++ = '\0'; - mlt_filter filter = mlt_factory_filter( id, arg ); - if ( filter != NULL ) - { - mlt_field_plant_filter( field, filter, track ); - track_service( field, filter, ( mlt_destructor )mlt_filter_close ); - } - return filter; -} - -static mlt_transition create_transition( mlt_field field, char *id, int track ) -{ - char *arg = strchr( id, ':' ); - if ( arg != NULL ) - *arg ++ = '\0'; - mlt_transition transition = mlt_factory_transition( id, arg ); - if ( transition != NULL ) - { - mlt_field_plant_transition( field, transition, track, track + 1 ); - track_service( field, transition, ( mlt_destructor )mlt_transition_close ); - } - return transition; -} - -mlt_producer producer_inigo_init( char **argv ) -{ - int i; - int track = 0; - mlt_producer producer = NULL; - mlt_playlist playlist = mlt_playlist_init( ); - mlt_properties group = mlt_properties_new( ); - mlt_properties properties = group; - mlt_field field = mlt_field_init( ); - mlt_properties field_properties = mlt_field_properties( field ); - mlt_multitrack multitrack = mlt_field_multitrack( field ); - - // We need to track the number of registered filters - mlt_properties_set_int( field_properties, "registered", 0 ); - - // Parse the arguments - for ( i = 0; argv[ i ] != NULL; i ++ ) - { - if ( !strcmp( argv[ i ], "-group" ) ) - { - if ( mlt_properties_count( group ) != 0 ) - { - mlt_properties_close( group ); - group = mlt_properties_new( ); - } - if ( group != NULL ) - properties = group; - } - else if ( !strcmp( argv[ i ], "-filter" ) ) - { - mlt_filter filter = create_filter( field, argv[ ++ i ], track ); - if ( filter != NULL ) - { - properties = mlt_filter_properties( filter ); - mlt_properties_inherit( properties, group ); - } - } - else if ( !strcmp( argv[ i ], "-transition" ) ) - { - mlt_transition transition = create_transition( field, argv[ ++ i ], track ); - if ( transition != NULL ) - { - properties = mlt_transition_properties( transition ); - mlt_properties_inherit( properties, group ); - } - } - else if ( !strcmp( argv[ i ], "-blank" ) ) - { - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - producer = NULL; - mlt_playlist_blank( playlist, atof( argv[ ++ i ] ) ); - } - else if ( !strcmp( argv[ i ], "-track" ) ) - { - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - producer = NULL; - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ++ ); - playlist = mlt_playlist_init( ); - } - else if ( strstr( argv[ i ], "=" ) ) - { - mlt_properties_parse( properties, argv[ i ] ); - } - else if ( argv[ i ][ 0 ] != '-' ) - { - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - producer = create_producer( argv[ i ] ); - if ( producer != NULL ) - { - properties = mlt_producer_properties( producer ); - mlt_properties_inherit( properties, group ); - } - } - else - { - if ( !strcmp( argv[ i ], "-serialise" ) ) - i += 2; - else if ( !strcmp( argv[ i ], "-consumer" ) ) - i += 2; - - while ( argv[ i ] != NULL && strchr( argv[ i ], '=' ) ) - i ++; - - i --; - } - } - - // Connect producer to playlist - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - - // We must have a producer at this point - if ( mlt_playlist_count( playlist ) > 0 ) - { - // Connect multitrack to producer - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ); - } - - mlt_tractor tractor = mlt_field_tractor( field ); - mlt_producer prod = mlt_tractor_producer( tractor ); - mlt_properties props = mlt_tractor_properties( tractor ); - mlt_properties_set_data( props, "multitrack", multitrack, 0, NULL, NULL ); - mlt_properties_set_data( props, "field", field, 0, NULL, NULL ); - mlt_properties_set_data( props, "group", group, 0, NULL, NULL ); - mlt_properties_set_position( props, "length", mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) + 1 ); - mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) ); - mlt_properties_set_double( props, "fps", mlt_producer_get_fps( mlt_multitrack_producer( multitrack ) ) ); - - return mlt_tractor_producer( tractor ); -} - diff --git a/mlt/src/modules/inigo/producer_inigo.h b/mlt/src/modules/inigo/producer_inigo.h deleted file mode 100644 index be65692..0000000 --- a/mlt/src/modules/inigo/producer_inigo.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * producer_inigo.h -- simple inigo test case - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_INIGO_H_ -#define _PRODUCER_INIGO_H_ - -#include - -extern mlt_producer producer_inigo_init( char **args ); - -#endif diff --git a/mlt/src/modules/resample/Makefile b/mlt/src/modules/resample/Makefile deleted file mode 100644 index b8b7542..0000000 --- a/mlt/src/modules/resample/Makefile +++ /dev/null @@ -1,29 +0,0 @@ - -TARGET = ../libmltresample.so - -OBJS = factory.o \ - filter_resample.o - -CFLAGS = -I../../ -Wall -g - -LDFLAGS= -lsamplerate - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/resample/configure b/mlt/src/modules/resample/configure deleted file mode 100755 index 7e0f23a..0000000 --- a/mlt/src/modules/resample/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../filters.dat -resample libmltresample.so -EOF - -fi - diff --git a/mlt/src/modules/resample/factory.c b/mlt/src/modules/resample/factory.c deleted file mode 100644 index 42385a7..0000000 --- a/mlt/src/modules/resample/factory.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "filter_resample.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - if ( !strcmp( id, "resample" ) ) - return filter_resample_init( arg ); - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - return NULL; -} - diff --git a/mlt/src/modules/resample/filter_resample.c b/mlt/src/modules/resample/filter_resample.c deleted file mode 100644 index 402a278..0000000 --- a/mlt/src/modules/resample/filter_resample.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * filter_resample.c -- adjust audio sample frequency - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "filter_resample.h" - -#include - -#include -#include -#include -#define __USE_ISOC99 1 -#include - -#define BUFFER_LEN 20480 -#define RESAMPLE_TYPE SRC_SINC_FASTEST - -/** Get the audio. -*/ - -static int resample_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) -{ - // Get the properties of the a frame - mlt_properties properties = mlt_frame_properties( frame ); - int output_rate = mlt_properties_get_int( properties, "resample.frequency" ); - SRC_STATE *state = mlt_properties_get_data( properties, "resample.state", NULL ); - SRC_DATA data; - float *input_buffer = mlt_properties_get_data( properties, "resample.input_buffer", NULL ); - float *output_buffer = mlt_properties_get_data( properties, "resample.output_buffer", NULL ); - int i; - - // Restore the original get_audio - frame->get_audio = mlt_properties_get_data( properties, "resample.get_audio", NULL ); - - // Get the producer's audio - mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); - - // Convert to floating point - for ( i = 0; i < *samples * *channels; ++i ) - input_buffer[ i ] = ( float )( (*buffer)[ i ] ) / 32768; - - // Resample - data.data_in = input_buffer; - data.data_out = output_buffer; - data.src_ratio = ( float ) output_rate / ( float ) *frequency; - data.input_frames = *samples; - data.output_frames = BUFFER_LEN / *channels; - data.end_of_input = 0; - i = src_process( state, &data ); - if ( i == 0 ) - { - if ( data.output_frames_gen > *samples ) - { - *buffer = (int16_t*) malloc( data.output_frames_gen * *channels * 2 ); - mlt_properties_set_data( properties, "audio", *buffer, *channels * data.output_frames_gen * 2, free, NULL ); - } - *samples = data.output_frames_gen; - *frequency = output_rate; - - // Convert from floating back to signed 16bit - for ( i = 0; i < *samples * *channels; ++i ) - { - float sample = output_buffer[ i ]; - if ( sample > 1.0 ) - sample = 1.0; - if ( sample < -1.0 ) - sample = -1.0; - if ( sample >= 0 ) - (*buffer)[ i ] = lrint( 32767.0 * sample ); - else - (*buffer)[ i ] = lrint( 32768.0 * sample ); - } - } - else - fprintf( stderr, "resample_get_audio: %s\n", src_strerror( i ) ); - - return 0; -} - -/** Filter processing. -*/ - -static mlt_frame filter_process( mlt_filter this, mlt_frame frame ) -{ - mlt_properties properties = mlt_filter_properties( this ); - mlt_properties frame_props = mlt_frame_properties( frame ); - - // Propogate the frequency property if supplied - if ( mlt_properties_get( properties, "frequency" ) != NULL ) - mlt_properties_set_int( frame_props, "resample.frequency", mlt_properties_get_int( properties, "frequency" ) ); - - // Propogate the other properties - mlt_properties_set_int( frame_props, "resample.channels", mlt_properties_get_int( properties, "channels" ) ); - mlt_properties_set_data( frame_props, "resample.state", mlt_properties_get_data( properties, "state", NULL ), 0, NULL, NULL ); - mlt_properties_set_data( frame_props, "resample.input_buffer", mlt_properties_get_data( properties, "input_buffer", NULL ), 0, NULL, NULL ); - mlt_properties_set_data( frame_props, "resample.output_buffer", mlt_properties_get_data( properties, "output_buffer", NULL ), 0, NULL, NULL ); - - // Backup the original get_audio (it's still needed) - mlt_properties_set_data( frame_props, "resample.get_audio", frame->get_audio, 0, NULL, NULL ); - - // Override the get_audio method - frame->get_audio = resample_get_audio; - - return frame; -} - -/** Constructor for the filter. -*/ - -mlt_filter filter_resample_init( char *arg ) -{ - mlt_filter this = calloc( sizeof( struct mlt_filter_s ), 1 ); - if ( this != NULL && mlt_filter_init( this, NULL ) == 0 ) - { - int error; - SRC_STATE *state = src_new( RESAMPLE_TYPE, 2 /* channels */, &error ); - if ( error == 0 ) - { - this->process = filter_process; - if ( arg != NULL ) - mlt_properties_set_int( mlt_filter_properties( this ), "frequency", atoi( arg ) ); - mlt_properties_set_int( mlt_filter_properties( this ), "channels", 2 ); - mlt_properties_set_data( mlt_filter_properties( this ), "state", state, 0, (mlt_destructor)src_delete, NULL ); - mlt_properties_set_data( mlt_filter_properties( this ), "input_buffer", - malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL ); - mlt_properties_set_data( mlt_filter_properties( this ), "output_buffer", - malloc( BUFFER_LEN ), BUFFER_LEN, free, NULL ); - } - else - { - fprintf( stderr, "filter_resample_init: %s\n", src_strerror( error ) ); - } - } - return this; -} - diff --git a/mlt/src/modules/resample/filter_resample.h b/mlt/src/modules/resample/filter_resample.h deleted file mode 100644 index 6ce7eb4..0000000 --- a/mlt/src/modules/resample/filter_resample.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * filter_resample.h -- adjust audio sample frequency - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _FILTER_RESAMPLE_H_ -#define _FILTER_RESAMPLE_H_ - -#include - -extern mlt_filter filter_resample_init( char *arg ); - -#endif diff --git a/mlt/src/modules/sdl/Makefile b/mlt/src/modules/sdl/Makefile deleted file mode 100644 index b527594..0000000 --- a/mlt/src/modules/sdl/Makefile +++ /dev/null @@ -1,29 +0,0 @@ - -TARGET = ../libmltsdl.so - -OBJS = factory.o \ - consumer_sdl.o - -CFLAGS = -I../../ `sdl-config --cflags` -Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -LDFLAGS= `sdl-config --libs` - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/sdl/configure b/mlt/src/modules/sdl/configure deleted file mode 100755 index 1c40fac..0000000 --- a/mlt/src/modules/sdl/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../consumers.dat -sdl libmltsdl.so -EOF - -fi - diff --git a/mlt/src/modules/sdl/consumer_sdl.c b/mlt/src/modules/sdl/consumer_sdl.c deleted file mode 100644 index dbd4ff3..0000000 --- a/mlt/src/modules/sdl/consumer_sdl.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * consumer_sdl.c -- A Simple DirectMedia Layer consumer - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "consumer_sdl.h" -#include -#include -#include -#include -#include -#include -#include - -/** This classes definition. -*/ - -typedef struct consumer_sdl_s *consumer_sdl; - -struct consumer_sdl_s -{ - struct mlt_consumer_s parent; - mlt_properties properties; - int format; - int video; - pthread_t thread; - int running; - uint8_t audio_buffer[ 4096 * 3 ]; - int audio_avail; - pthread_mutex_t audio_mutex; - pthread_cond_t audio_cond; - int window_width; - int window_height; - float aspect_ratio; - int width; - int height; - int playing; - mlt_frame *queue; - int size; - int count; - int sdl_flags; - SDL_Surface *sdl_screen; - SDL_Overlay *sdl_overlay; - uint8_t *buffer; -}; - -/** Forward references to static functions. -*/ - -static int consumer_start( mlt_consumer parent ); -static int consumer_stop( mlt_consumer parent ); -static int consumer_is_stopped( mlt_consumer parent ); -static void consumer_close( mlt_consumer parent ); -static void *consumer_thread( void * ); -static int consumer_get_dimensions( int *width, int *height ); - -/** This is what will be called by the factory - anything can be passed in - via the argument, but keep it simple. -*/ - -mlt_consumer consumer_sdl_init( char *arg ) -{ - // Create the consumer object - consumer_sdl this = calloc( sizeof( struct consumer_sdl_s ), 1 ); - - // If no malloc'd and consumer init ok - if ( this != NULL && mlt_consumer_init( &this->parent, this ) == 0 ) - { - // Get the parent consumer object - mlt_consumer parent = &this->parent; - - // We have stuff to clean up, so override the close method - parent->close = consumer_close; - - // get a handle on properties - mlt_service service = mlt_consumer_service( parent ); - this->properties = mlt_service_properties( service ); - - // Set the default volume - mlt_properties_set_double( this->properties, "volume", 1.0 ); - - // This is the initialisation of the consumer - pthread_mutex_init( &this->audio_mutex, NULL ); - pthread_cond_init( &this->audio_cond, NULL); - - // Default fps - mlt_properties_set_double( this->properties, "fps", 25 ); - - // process actual param - if ( arg == NULL || !strcmp( arg, "PAL" ) ) - { - this->width = 720; - this->height = 576; - } - else if ( !strcmp( arg, "NTSC" ) ) - { - this->width = 720; - this->height = 480; - mlt_properties_set_double( this->properties, "fps", 29.97 ); - } - else if ( sscanf( arg, "%dx%d", &this->width, &this->height ) != 2 ) - { - this->width = 720; - this->height = 576; - } - - // Default window size and aspect ratio - this->aspect_ratio = 4.0 / 3.0; - this->window_width = (int)( (float)this->height * this->aspect_ratio ) + 1; - this->window_height = this->height; - - // Set the sdl flags - this->sdl_flags = SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_HWACCEL | SDL_RESIZABLE; - - // Allow thread to be started/stopped - parent->start = consumer_start; - parent->stop = consumer_stop; - parent->is_stopped = consumer_is_stopped; - - // Return the consumer produced - return parent; - } - - // malloc or consumer init failed - free( this ); - - // Indicate failure - return NULL; -} - -int consumer_start( mlt_consumer parent ) -{ - consumer_sdl this = parent->child; - - if ( !this->running ) - { - this->running = 1; - pthread_create( &this->thread, NULL, consumer_thread, this ); - } - - return 0; -} - -int consumer_stop( mlt_consumer parent ) -{ - // Get the actual object - consumer_sdl this = parent->child; - - if ( this->running ) - { - // Kill the thread and clean up - this->running = 0; - - pthread_mutex_lock( &this->audio_mutex ); - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); - - pthread_join( this->thread, NULL ); - } - - return 0; -} - -int consumer_is_stopped( mlt_consumer parent ) -{ - consumer_sdl this = parent->child; - return !this->running; -} - -static int sdl_lock_display( ) -{ - SDL_Surface *screen = SDL_GetVideoSurface( ); - return screen != NULL && ( !SDL_MUSTLOCK( screen ) || SDL_LockSurface( screen ) >= 0 ); -} - -static void sdl_unlock_display( ) -{ - SDL_Surface *screen = SDL_GetVideoSurface( ); - if ( screen != NULL && SDL_MUSTLOCK( screen ) ) - SDL_UnlockSurface( screen ); -} - -static void sdl_fill_audio( void *udata, uint8_t *stream, int len ) -{ - consumer_sdl this = udata; - - // Get the volume - float volume = mlt_properties_get_double( this->properties, "volume" ); - - pthread_mutex_lock( &this->audio_mutex ); - - // Block until audio received - while ( this->running && len > this->audio_avail ) - pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); - - if ( this->audio_avail >= len ) - { - // Place in the audio buffer - SDL_MixAudio( stream, this->audio_buffer, len, ( int )( ( float )SDL_MIX_MAXVOLUME * volume ) ); - - // Remove len from the audio available - this->audio_avail -= len; - - // Remove the samples - memmove( this->audio_buffer, this->audio_buffer + len, this->audio_avail ); - } - else - { - // Just to be safe, wipe the stream first - memset( stream, 0, len ); - - // Copy what we have into the stream - memcpy( stream, this->audio_buffer, this->audio_avail ); - - // Mix the audio - SDL_MixAudio( stream, stream, len, ( int )( ( float )SDL_MIX_MAXVOLUME * volume ) ); - - // No audio left - this->audio_avail = 0; - } - - // We're definitely playing now - this->playing = 1; - - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); -} - -static int consumer_play_audio( consumer_sdl this, mlt_frame frame, int init_audio ) -{ - // Get the properties of this consumer - mlt_properties properties = this->properties; - mlt_audio_format afmt = mlt_audio_pcm; - - // Set the preferred params of the test card signal - int channels = 2; - int frequency = 48000; - static int counter = 0; - int samples = mlt_sample_calculator( mlt_properties_get_double( this->properties, "fps" ), frequency, counter++ ); - - int16_t *pcm; - int bytes; - - mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples ); - - if ( mlt_properties_get_int( properties, "audio_off" ) ) - { - this->playing = 1; - return init_audio; - } - - if ( init_audio == 1 ) - { - SDL_AudioSpec request; - SDL_AudioSpec got; - - SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); - SDL_EnableUNICODE( 1 ); - - // specify audio format - memset( &request, 0, sizeof( SDL_AudioSpec ) ); - this->playing = 0; - request.freq = frequency; - request.format = AUDIO_S16; - request.channels = channels; - request.samples = 1024; - request.callback = sdl_fill_audio; - request.userdata = (void *)this; - if ( SDL_OpenAudio( &request, &got ) != 0 ) - { - fprintf( stderr, "SDL failed to open audio: %s\n", SDL_GetError() ); - init_audio = 2; - } - else if ( got.size != 0 ) - { - SDL_PauseAudio( 0 ); - init_audio = 0; - } - } - - if ( init_audio == 0 ) - { - bytes = ( samples * channels * 2 ); - pthread_mutex_lock( &this->audio_mutex ); - while ( bytes > ( sizeof( this->audio_buffer) - this->audio_avail ) ) - pthread_cond_wait( &this->audio_cond, &this->audio_mutex ); - mlt_properties properties = mlt_frame_properties( frame ); - if ( mlt_properties_get_double( properties, "speed" ) == 1 ) - memcpy( &this->audio_buffer[ this->audio_avail ], pcm, bytes ); - else - memset( &this->audio_buffer[ this->audio_avail ], 0, bytes ); - this->audio_avail += bytes; - pthread_cond_broadcast( &this->audio_cond ); - pthread_mutex_unlock( &this->audio_mutex ); - } - else - { - this->playing = 1; - } - - return init_audio; -} - -static int consumer_play_video( consumer_sdl this, mlt_frame frame ) -{ - // Get the properties of this consumer - mlt_properties properties = this->properties; - - mlt_image_format vfmt = mlt_image_yuv422; - int width = this->width, height = this->height; - uint8_t *image; - int changed = 0; - - if ( mlt_properties_get_int( properties, "video_off" ) ) - { - mlt_frame_close( frame ); - return 0; - } - - if ( this->count == this->size ) - { - this->size += 25; - this->queue = realloc( this->queue, sizeof( mlt_frame ) * this->size ); - } - this->queue[ this->count ++ ] = frame; - - if ( this->playing ) - { - // We're working on the oldest frame now - frame = this->queue[ 0 ]; - - // Shunt the frames in the queue down - int i = 0; - for ( i = 1; i < this->count; i ++ ) - this->queue[ i - 1 ] = this->queue[ i ]; - this->count --; - - // Get the image, width and height - mlt_frame_get_image( frame, &image, &vfmt, &width, &height, 0 ); - - if ( this->sdl_screen != NULL ) - { - SDL_Event event; - - changed = consumer_get_dimensions( &this->window_width, &this->window_height ); - - while ( SDL_PollEvent( &event ) ) - { - switch( event.type ) - { - case SDL_VIDEORESIZE: - this->window_width = event.resize.w; - this->window_height = event.resize.h; - changed = 1; - break; - case SDL_KEYDOWN: - { - mlt_producer producer = mlt_properties_get_data( properties, "transport_producer", NULL ); - char keyboard[ 2 ] = " "; - void (*callback)( mlt_producer, char * ) = mlt_properties_get_data( properties, "transport_callback", NULL ); - if ( callback != NULL && producer != NULL && event.key.keysym.unicode < 0x80 && event.key.keysym.unicode > 0 ) - { - keyboard[ 0 ] = ( char )event.key.keysym.unicode; - callback( producer, keyboard ); - } - } - break; - } - } - - } - - if ( width != this->width || height != this->height ) - { - this->width = width; - this->height = height; - changed = 1; - } - - if ( this->sdl_screen == NULL || changed ) - { - double aspect_ratio = mlt_frame_get_aspect_ratio( frame ); - float display_aspect_ratio = (float)width / (float)height; - SDL_Rect rect; - - if ( mlt_properties_get_double( properties, "aspect_ratio" ) ) - aspect_ratio = mlt_properties_get_double( properties, "aspect_ratio" ); - - if ( aspect_ratio == 1 ) - { - rect.w = this->window_width; - rect.h = this->window_height; - } - else if ( this->window_width < this->window_height * aspect_ratio ) - { - rect.w = this->window_width; - rect.h = this->window_width / aspect_ratio; - } - else - { - rect.w = this->window_height * aspect_ratio; - rect.h = this->window_height; - } - - if ( mlt_properties_get_int( properties, "scale_overlay" ) ) - { - if ( ( float )rect.w * display_aspect_ratio < this->window_width ) - rect.w = ( int )( ( float )rect.w * display_aspect_ratio ); - else if ( ( float )rect.h * display_aspect_ratio < this->window_height ) - rect.h = ( int )( ( float )rect.h * display_aspect_ratio ); - } - - rect.x = ( this->window_width - rect.w ) / 2; - rect.y = ( this->window_height - rect.h ) / 2; - - // Force an overlay recreation - if ( this->sdl_overlay != NULL ) - SDL_FreeYUVOverlay( this->sdl_overlay ); - - // open SDL window with video overlay, if possible - this->sdl_screen = SDL_SetVideoMode( this->window_width, this->window_height, 0, this->sdl_flags ); - - if ( this->sdl_screen != NULL ) - { - SDL_SetClipRect( this->sdl_screen, &rect ); - - sdl_lock_display(); - this->sdl_overlay = SDL_CreateYUVOverlay( this->width - (this->width % 4), this->height- (this->height % 2 ), SDL_YUY2_OVERLAY, this->sdl_screen ); - sdl_unlock_display(); - } - } - - if ( this->sdl_screen != NULL && this->sdl_overlay != NULL ) - { - this->buffer = this->sdl_overlay->pixels[ 0 ]; - if ( SDL_LockYUVOverlay( this->sdl_overlay ) >= 0 ) - { - mlt_resize_yuv422( this->buffer, this->width - (this->width % 4 ), this->height- (this->height % 2 ), image, width, height ); - SDL_UnlockYUVOverlay( this->sdl_overlay ); - SDL_DisplayYUVOverlay( this->sdl_overlay, &this->sdl_screen->clip_rect ); - } - } - } - else - { - frame = NULL; - } - - // Close the frame - if ( frame != NULL ) - mlt_frame_close( frame ); - - if ( this->count ) - mlt_frame_get_image( this->queue[ this->count - 1 ], &image, &vfmt, &width, &height, 0 ); - - return 0; -} - -/** Threaded wrapper for pipe. -*/ - -static void *consumer_thread( void *arg ) -{ - // Identify the arg - consumer_sdl this = arg; - - // Get the consumer - mlt_consumer consumer = &this->parent; - - // Get the service assoicated to the consumer - mlt_service service = mlt_consumer_service( consumer ); - - // Define a frame pointer - mlt_frame frame; - - // internal intialization - int init_audio = 1; - - if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE ) < 0 ) - { - fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() ); - return NULL; - } - - // Loop until told not to - while( this->running ) - { - // Get a frame from the service (should never return anything other than 0) - if ( mlt_service_get_frame( service, &frame, 0 ) == 0 ) - { - init_audio = consumer_play_audio( this, frame, init_audio ); - consumer_play_video( this, frame ); - } - } - - // internal cleanup - if ( init_audio == 0 ) - SDL_AudioQuit( ); - if ( this->sdl_overlay != NULL ) - SDL_FreeYUVOverlay( this->sdl_overlay ); - SDL_Quit( ); - - this->sdl_screen = NULL; - this->sdl_overlay = NULL; - this->audio_avail = 0; - - return NULL; -} - -static int consumer_get_dimensions( int *width, int *height ) -{ - int changed = 0; - - // SDL windows manager structure - SDL_SysWMinfo wm; - - // Specify the SDL Version - SDL_VERSION( &wm.version ); - - // Get the wm structure - if ( SDL_GetWMInfo( &wm ) == 1 ) - { - // Check that we have the X11 wm - if ( wm.subsystem == SDL_SYSWM_X11 ) - { - // Get the SDL window - Window window = wm.info.x11.window; - - // Get the display session - Display *display = wm.info.x11.display; - - // Get the window attributes - XWindowAttributes attr; - XGetWindowAttributes( display, window, &attr ); - - // Determine whether window has changed - changed = *width != attr.width || *height != attr.height; - - // Return width and height - *width = attr.width; - *height = attr.height; - } - } - - return changed; -} - -/** Callback to allow override of the close method. -*/ - -static void consumer_close( mlt_consumer parent ) -{ - // Get the actual object - consumer_sdl this = parent->child; - - // Stop the consumer - mlt_consumer_stop( parent ); - - // Destroy mutexes - pthread_mutex_destroy( &this->audio_mutex ); - pthread_cond_destroy( &this->audio_cond ); - - // Now clean up the rest - mlt_consumer_close( parent ); - - // Finally clean up this - free( this ); -} - diff --git a/mlt/src/modules/sdl/consumer_sdl.h b/mlt/src/modules/sdl/consumer_sdl.h deleted file mode 100644 index bf2fefd..0000000 --- a/mlt/src/modules/sdl/consumer_sdl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * consumer_sdl.h -- A Simple DirectMedia Layer consumer - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _CONSUMER_SDL_H_ -#define _CONSUMER_SDL_H_ - -#include - -extern mlt_consumer consumer_sdl_init( char * ); - -#endif diff --git a/mlt/src/modules/sdl/factory.c b/mlt/src/modules/sdl/factory.c deleted file mode 100644 index 9e5f56e..0000000 --- a/mlt/src/modules/sdl/factory.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "consumer_sdl.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - if ( !strcmp( id, "sdl" ) ) - return consumer_sdl_init( arg ); - return NULL; -} - diff --git a/mlt/src/modules/westley/Makefile b/mlt/src/modules/westley/Makefile deleted file mode 100644 index 576a6ea..0000000 --- a/mlt/src/modules/westley/Makefile +++ /dev/null @@ -1,30 +0,0 @@ - -TARGET = ../libmltwestley.so - -OBJS = factory.o \ - consumer_westley.o \ - producer_westley.o - -CFLAGS = -I../../ -Wall -g -D_FILE_OFFSET_BITS=64 -pthread `xml2-config --cflags` - -LDFLAGS = `xml2-config --libs` - -SRCS := $(OBJS:.o=.c) - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/modules/westley/configure b/mlt/src/modules/westley/configure deleted file mode 100755 index b971570..0000000 --- a/mlt/src/modules/westley/configure +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ "$help" != "1" ] -then - -cat << EOF >> ../producers.dat -westley libmltwestley.so -EOF - -cat << EOF >> ../consumers.dat -westley libmltwestley.so -EOF - -fi - diff --git a/mlt/src/modules/westley/consumer_westley.c b/mlt/src/modules/westley/consumer_westley.c deleted file mode 100644 index 3019351..0000000 --- a/mlt/src/modules/westley/consumer_westley.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * consumer_westley.c -- a libxml2 serialiser of mlt service networks - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "consumer_westley.h" -#include -#include -#include -#include -#include -#include - -/** Forward references to static functions. -*/ - -static int consumer_start( mlt_consumer parent ); - -/** This is what will be called by the factory - anything can be passed in - via the argument, but keep it simple. -*/ - -mlt_consumer consumer_westley_init( char *arg ) -{ - // Create the consumer object - mlt_consumer this = calloc( sizeof( struct mlt_consumer_s ), 1 ); - - // If no malloc'd and consumer init ok - if ( this != NULL && mlt_consumer_init( this, NULL ) == 0 ) - { - // We have stuff to clean up, so override the close method - //parent->close = consumer_close; - - // Allow thread to be started/stopped - this->start = consumer_start; - - // Return the consumer produced - return this; - } - - // malloc or consumer init failed - free( this ); - - // Indicate failure - return NULL; -} - - -// This maintains counters for adding ids to elements -struct serialise_context_s -{ - int producer_count; - int multitrack_count; - int playlist_count; - int tractor_count; - int filter_count; - int transition_count; -}; -typedef struct serialise_context_s* serialise_context; - - -static inline void serialise_properties( mlt_properties properties, xmlNode *node ) -{ - int i; - xmlNode *p; - - // Enumerate the properties - for ( i = 0; i < mlt_properties_count( properties ); i++ ) - { -#if 0 - p = xmlNewChild( node, NULL, "prop", NULL ); -#else - p = node; -#endif - xmlNewProp( p, mlt_properties_get_name( properties, i ), mlt_properties_get_value( properties, i ) ); - } -} - -static xmlNode* serialise_service( serialise_context context, mlt_service service, xmlNode *node ) -{ - int i; - xmlNode *child = node; - char id[ 31 ]; - id[ 30 ] = '\0'; - - // Iterate over consumer/producer connections - while ( service != NULL ) - { - mlt_properties properties = mlt_service_properties( service ); - char *mlt_type = mlt_properties_get( properties, "mlt_type" ); - - // Tell about the producer - if ( strcmp( mlt_type, "producer" ) == 0 ) - { - child = xmlNewChild( node, NULL, "producer", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( child, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "producer%d", context->producer_count++ ); - xmlNewProp( child, "id", id ); - } - - //xmlNewProp( child, "type", mlt_properties_get( properties, "mlt_service" ) ); - //xmlNewProp( child, "src", mlt_properties_get( properties, "resource" ) ); - serialise_properties( properties, child ); - } - - // Tell about the framework container producers - else if ( strcmp( mlt_type, "mlt_producer" ) == 0 ) - { - // Recurse on multitrack's tracks - if ( strcmp( mlt_properties_get( properties, "resource" ), "" ) == 0 ) - { - child = xmlNewChild( node, NULL, "multitrack", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( child, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "multitrack%d", context->multitrack_count++ ); - xmlNewProp( child, "id", id ); - } - - // Iterate over the tracks - for ( i = 0; i < mlt_multitrack_count( MLT_MULTITRACK( service ) ); i++ ) - { - xmlNode *track = xmlNewChild( child, NULL, "track", NULL ); - serialise_service( context, MLT_SERVICE( mlt_multitrack_track( MLT_MULTITRACK( service ), i ) ), track ); - } - break; - } - - // Recurse on playlist's clips - else if ( strcmp( mlt_properties_get( properties, "resource" ), "" ) == 0 ) - { - mlt_playlist_clip_info info; - child = xmlNewChild( node, NULL, "playlist", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( child, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "playlist%d", context->playlist_count++ ); - xmlNewProp( child, "id", id ); - } - - xmlNewProp( child, "in", mlt_properties_get( properties, "in" ) ); - xmlNewProp( child, "out", mlt_properties_get( properties, "out" ) ); - - // Iterate over the playlist entries - for ( i = 0; i < mlt_playlist_count( MLT_PLAYLIST( service ) ); i++ ) - { - if ( ! mlt_playlist_get_clip_info( MLT_PLAYLIST( service ), &info, i ) ) - { - if ( strcmp( mlt_properties_get( mlt_producer_properties( info.producer ), "mlt_service" ), "blank" ) == 0 ) - { - char length[ 20 ]; - length[ 19 ] = '\0'; - xmlNode *entry = xmlNewChild( child, NULL, "blank", NULL ); - snprintf( length, 19, "%lld", info.length ); - xmlNewProp( entry, "length", length ); - } - else - { - xmlNode *entry = xmlNewChild( child, NULL, "entry", NULL ); - serialise_service( context, MLT_SERVICE( info.producer ), entry ); - } - } - } - } - - // Recurse on tractor's producer - else if ( strcmp( mlt_properties_get( properties, "resource" ), "" ) == 0 ) - { - child = xmlNewChild( node, NULL, "tractor", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( child, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "tractor%d", context->tractor_count++ ); - xmlNewProp( child, "id", id ); - } - - // Recurse on connected producer - serialise_service( context, mlt_service_get_producer( service ), child ); - - break; - } - } - - // Tell about a filter - else if ( strcmp( mlt_type, "filter" ) == 0 ) - { - // Recurse on connected producer - child = serialise_service( context, MLT_SERVICE( MLT_FILTER( service )->producer ), node ); - - // sanity check - if ( child == NULL ) - break; - - node = xmlNewChild( child, NULL, "filter", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( node, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "filter%d", context->filter_count++ ); - xmlNewProp( node, "id", id ); - } - - //xmlNewProp( node, "type", mlt_properties_get( properties, "mlt_service" ) ); - - serialise_properties( properties, node ); - - break; - } - - // Tell about a transition - else if ( strcmp( mlt_type, "transition" ) == 0 ) - { - // Recurse on connected producer - child = serialise_service( context, MLT_SERVICE( MLT_TRANSITION( service )->producer ), node ); - - // sanity check - if ( child == NULL ) - break; - - node = xmlNewChild( child, NULL, "transition", NULL ); - - // Set the id - if ( mlt_properties_get( properties, "id" ) != NULL ) - xmlNewProp( node, "id", mlt_properties_get( properties, "mlt_service" ) ); - else - { - snprintf( id, 30, "transition%d", context->transition_count++ ); - xmlNewProp( node, "id", id ); - } - - //xmlNewProp( node, "type", mlt_properties_get( properties, "mlt_service" ) ); - - serialise_properties( properties, node ); - - break; - } - - // Get the next connected service - service = mlt_service_get_producer( service ); - } - return child; -} - -static int consumer_start( mlt_consumer this ) -{ - mlt_service inigo = NULL; - xmlDoc *doc = xmlNewDoc( "1.0" ); - xmlNode *root = xmlNewNode( NULL, "westley" ); - xmlDocSetRootElement( doc, root ); - - // Get the producer service - mlt_service service = mlt_service_get_producer( mlt_consumer_service( this ) ); - if ( service != NULL ) - { - struct serialise_context_s context; - memset( &context, 0, sizeof( struct serialise_context_s ) ); - - // Remember inigo - if ( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ) != NULL && - strcmp( mlt_properties_get( mlt_service_properties( service ), "mlt_service" ), "inigo" ) == 0 ) - { - inigo = service; - - // Turn inigo's producer into a framework producer - mlt_properties_set( mlt_service_properties( service ), "mlt_type", "mlt_producer" ); - } - - serialise_service( &context, service, root ); - xmlDocFormatDump( stderr, doc, 1 ); - } - - xmlFreeDoc( doc ); - mlt_consumer_stop( this ); - - // Tell inigo, enough already! - if ( inigo != NULL ) - mlt_properties_set_int( mlt_service_properties( inigo ), "done", 1 ); - - return 0; -} - diff --git a/mlt/src/modules/westley/consumer_westley.h b/mlt/src/modules/westley/consumer_westley.h deleted file mode 100644 index 8b94db4..0000000 --- a/mlt/src/modules/westley/consumer_westley.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * consumer_westley.h -- a libxml2 serialiser of mlt service networks - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _CONSUMER_WESTLEY_H_ -#define _CONSUMER_WESTLEY_H_ - -#include - -extern mlt_consumer consumer_westley_init( char * ); - -#endif diff --git a/mlt/src/modules/westley/factory.c b/mlt/src/modules/westley/factory.c deleted file mode 100644 index e60cd56..0000000 --- a/mlt/src/modules/westley/factory.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * factory.c -- the factory method interfaces - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include - -#include "consumer_westley.h" -#include "producer_westley.h" - -void *mlt_create_producer( char *id, void *arg ) -{ - if ( !strcmp( id, "westley" ) ) - return producer_westley_init( arg ); - return NULL; -} - -void *mlt_create_filter( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_transition( char *id, void *arg ) -{ - return NULL; -} - -void *mlt_create_consumer( char *id, void *arg ) -{ - if ( !strcmp( id, "westley" ) ) - return consumer_westley_init( arg ); - return NULL; -} - diff --git a/mlt/src/modules/westley/producer_westley.c b/mlt/src/modules/westley/producer_westley.c deleted file mode 100644 index 6616f3c..0000000 --- a/mlt/src/modules/westley/producer_westley.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * producer_libdv.c -- a libxml2 parser of mlt service networks - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "producer_westley.h" -#include -#include -#include -#include - -#include - -static mlt_producer parse_westley( char *file ) -{ - return NULL; -} - -mlt_producer producer_westley_init( char *filename ) -{ - int i; - int track = 0; - mlt_producer producer = NULL; - mlt_playlist playlist = mlt_playlist_init( ); - mlt_properties group = mlt_properties_new( ); - mlt_properties properties = group; - mlt_field field = mlt_field_init( ); - mlt_properties field_properties = mlt_field_properties( field ); - mlt_multitrack multitrack = mlt_field_multitrack( field ); - - // We need to track the number of registered filters - mlt_properties_set_int( field_properties, "registered", 0 ); - - // Parse - producer = parse_westley( filename ); - - // TODO - - // Connect producer to playlist - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - - // We must have a producer at this point - if ( mlt_playlist_count( playlist ) > 0 ) - { - // Connect multitrack to producer - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist ), track ); - } - - mlt_tractor tractor = mlt_field_tractor( field ); - mlt_producer prod = mlt_tractor_producer( tractor ); - mlt_properties props = mlt_tractor_properties( tractor ); - mlt_properties_set( mlt_producer_properties( prod ), "resource", filename ); - mlt_properties_set_data( props, "multitrack", multitrack, 0, NULL, NULL ); - mlt_properties_set_data( props, "field", field, 0, NULL, NULL ); - mlt_properties_set_data( props, "group", group, 0, NULL, NULL ); - mlt_properties_set_position( props, "length", mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) + 1 ); - mlt_producer_set_in_and_out( prod, 0, mlt_producer_get_out( mlt_multitrack_producer( multitrack ) ) ); - mlt_properties_set_double( props, "fps", mlt_producer_get_fps( mlt_multitrack_producer( multitrack ) ) ); - - return mlt_tractor_producer( tractor ); -} - diff --git a/mlt/src/modules/westley/producer_westley.h b/mlt/src/modules/westley/producer_westley.h deleted file mode 100644 index 979a0d7..0000000 --- a/mlt/src/modules/westley/producer_westley.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * producer_westley.h -- a libxml2 parser of mlt service networks - * Copyright (C) 2003-2004 Ushodaya Enterprises Limited - * Author: Dan Dennedy - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _PRODUCER_WESTLEY_H_ -#define _PRODUCER_WESTLEY_H_ - -#include - -extern mlt_producer producer_westley_init( char *filename ); - -#endif diff --git a/mlt/src/tests/Makefile b/mlt/src/tests/Makefile deleted file mode 100644 index 3c7dd78..0000000 --- a/mlt/src/tests/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -TARGET = dan charlie pango pixbuf dissolve luma - -CFLAGS = -I .. -Wall -rdynamic -pthread - -LDFLAGS = -L ../framework -lmlt - -all: $(TARGET) - -pango: pango.o - $(CC) pango.o -o $@ $(LDFLAGS) - -pixbuf: pixbuf.o - $(CC) pixbuf.o -o $@ $(LDFLAGS) - -dissolve: dissolve.o - $(CC) dissolve.o -o $@ $(LDFLAGS) - -luma: luma.o - $(CC) luma.o -o $@ $(LDFLAGS) - -dan: dan.o - $(CC) dan.o -o $@ $(LDFLAGS) - -charlie: charlie.o io.o - $(CC) charlie.o io.o -o $@ $(LDFLAGS) - -clean: - rm -f dan.o io.o charlie.o dan charlie - -depend: dan.c charlie.c io.c - $(CC) -MM $(CFLAGS) $^ 1>.depend - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/tests/charlie.c b/mlt/src/tests/charlie.c deleted file mode 100644 index f4086e4..0000000 --- a/mlt/src/tests/charlie.c +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include - -#include - -#include "io.h" - -mlt_producer create_producer( char *file ) -{ - mlt_producer result = NULL; - - // 1st Line preferences - if ( strstr( file, ".inigo" ) ) - { - char *args[ 2 ] = { file, NULL }; - result = mlt_factory_producer( "inigo", args ); - } - else if ( strstr( file, ".mpg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".mpeg" ) ) - result = mlt_factory_producer( "mcmpeg", file ); - else if ( strstr( file, ".dv" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".dif" ) ) - result = mlt_factory_producer( "mcdv", file ); - else if ( strstr( file, ".jpg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".JPG" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".jpeg" ) ) - result = mlt_factory_producer( "pixbuf", file ); - else if ( strstr( file, ".png" ) ) - result = mlt_factory_producer( "pixbuf", file ); - - // 2nd Line fallbacks - if ( result == NULL && strstr( file, ".dv" ) ) - result = mlt_factory_producer( "libdv", file ); - else if ( result == NULL && strstr( file, ".dif" ) ) - result = mlt_factory_producer( "libdv", file ); - - return result; -} - -void transport_action( mlt_producer producer, char *value ) -{ - mlt_properties properties = mlt_producer_properties( producer ); - - switch( value[ 0 ] ) - { - case 'q': - mlt_properties_set_int( properties, "done", 1 ); - break; - case '0': - mlt_producer_set_speed( producer, 1 ); - mlt_producer_seek( producer, 0 ); - break; - case '1': - mlt_producer_set_speed( producer, -5 ); - break; - case '2': - mlt_producer_set_speed( producer, -2.5 ); - break; - case '3': - mlt_producer_set_speed( producer, -1 ); - break; - case '4': - mlt_producer_set_speed( producer, -0.5 ); - break; - case '5': - mlt_producer_set_speed( producer, 0 ); - break; - case '6': - mlt_producer_set_speed( producer, 0.5 ); - break; - case '7': - mlt_producer_set_speed( producer, 1 ); - break; - case '8': - mlt_producer_set_speed( producer, 2.5 ); - break; - case '9': - mlt_producer_set_speed( producer, 5 ); - break; - } -} - -mlt_consumer create_consumer( char *id, mlt_producer producer ) -{ - char *arg = strchr( id, ':' ); - if ( arg != NULL ) - *arg ++ = '\0'; - mlt_consumer consumer = mlt_factory_consumer( id, arg ); - if ( consumer != NULL ) - { - mlt_properties properties = mlt_consumer_properties( consumer ); - mlt_properties_set_data( properties, "transport_callback", transport_action, 0, NULL, NULL ); - mlt_properties_set_data( properties, "transport_producer", producer, 0, NULL, NULL ); - } - return consumer; -} - -void track_service( mlt_field field, void *service, mlt_destructor destructor ) -{ - mlt_properties properties = mlt_field_properties( field ); - int registered = mlt_properties_get_int( properties, "registered" ); - char *key = mlt_properties_get( properties, "registered" ); - mlt_properties_set_data( properties, key, service, 0, destructor, NULL ); - mlt_properties_set_int( properties, "registered", ++ registered ); -} - -void set_properties( mlt_service service, char *namevalue ) -{ - mlt_properties properties = mlt_service_properties( service ); - mlt_properties_parse( properties, namevalue ); -} - -void transport( mlt_producer producer ) -{ - mlt_properties properties = mlt_producer_properties( producer ); - - term_init( ); - fprintf( stderr, "Press 'q' to continue\n" ); - while( mlt_properties_get_int( properties, "done" ) == 0 ) - { - int value = term_read( ); - if ( value != -1 ) - transport_action( producer, ( char * )&value ); - } -} - -int main( int argc, char **argv ) -{ - int i; - mlt_service service = NULL; - mlt_consumer consumer = NULL; - mlt_producer producer = NULL; - mlt_playlist playlist = NULL; - - // Construct the factory - mlt_factory_init( getenv( "MLT_REPOSITORY" ) ); - - // Set up containers - playlist = mlt_playlist_init( ); - - // Parse the arguments - for ( i = 1; i < argc; i ++ ) - { - if ( !strcmp( argv[ i ], "-consumer" ) ) - { - consumer = create_consumer( argv[ ++ i ], mlt_playlist_producer( playlist ) ); - if ( consumer != NULL ) - service = mlt_consumer_service( consumer ); - } - else if ( !strstr( argv[ i ], "=" ) ) - { - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - producer = create_producer( argv[ i ] ); - if ( producer != NULL ) - service = mlt_producer_service( producer ); - } - else - { - set_properties( service, argv[ i ] ); - } - } - - // If we have no consumer, default to sdl - if ( consumer == NULL ) - consumer = create_consumer( "sdl", mlt_playlist_producer( playlist ) ); - - // Connect producer to playlist - if ( producer != NULL ) - mlt_playlist_append( playlist, producer ); - - // Connect consumer to playlist - mlt_consumer_connect( consumer, mlt_playlist_service( playlist ) ); - - // Transport functionality - transport( mlt_playlist_producer( playlist ) ); - - // Close the services - mlt_consumer_close( consumer ); - mlt_playlist_close( playlist ); - - // Close the factory - mlt_factory_close( ); - - return 0; -} diff --git a/mlt/src/tests/clock16ntsc.pgm b/mlt/src/tests/clock16ntsc.pgm deleted file mode 100644 index 61e64ad..0000000 Binary files a/mlt/src/tests/clock16ntsc.pgm and /dev/null differ diff --git a/mlt/src/tests/clock16pal.pgm b/mlt/src/tests/clock16pal.pgm deleted file mode 100644 index 4d7b0fc..0000000 Binary files a/mlt/src/tests/clock16pal.pgm and /dev/null differ diff --git a/mlt/src/tests/dan.c b/mlt/src/tests/dan.c deleted file mode 100644 index d62abdf..0000000 --- a/mlt/src/tests/dan.c +++ /dev/null @@ -1,102 +0,0 @@ - -#include - -#include - -int main( int argc, char **argv ) -{ - char temp[ 132 ]; - char *file1 = NULL; - char *file2 = NULL; - - mlt_factory_init( "../modules" ); - - if ( argc >= 2 ) - file1 = argv[ 1 ]; - if ( argc >= 3 ) - file2 = argv[ 2 ]; - - // Start the consumer... - int vstd = mlt_video_standard_ntsc; - //mlt_consumer consumer = mlt_factory_consumer( "bluefish", &vstd ); - mlt_consumer consumer = mlt_factory_consumer( "westley", "PAL" ); - - // Create the producer(s) - mlt_producer dv1 = mlt_factory_producer( "libdv", file1 ); - mlt_producer_set_in_and_out( dv1, 0, 5 ); - - mlt_producer dv2 = mlt_factory_producer( "libdv", file2 ); - //mlt_producer_set_in_and_out( dv2, 10.0, 30.0 ); - -#if 0 - // Connect the consumer to the producer - mlt_consumer_connect( consumer, mlt_producer_service( dv2 ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - mlt_consumer_close( consumer ); - return 0; -#endif - - //mlt_producer dv1 = producer_pixbuf_init( file1 ); - //mlt_producer dv2 = producer_libdv_init( file2 ); - //mlt_producer dv2 = mlt_factory_producer( "pixbuf", file2 ); -#if 0 - mlt_producer title = mlt_factory_producer( "pango", NULL ); //"Mutton Lettuce Tomato" ); - mlt_properties_set_int( mlt_producer_properties( title ), "video_standard", mlt_video_standard_ntsc ); - mlt_properties_set( mlt_producer_properties( title ), "font", "Sans Bold 36" ); - mlt_properties_set( mlt_producer_properties( title ), "text", "Mutton Lettuce\nTomato" ); - mlt_properties_set_int( mlt_producer_properties( title ), "bgcolor", 0x0000007f ); - mlt_properties_set_int( mlt_producer_properties( title ), "pad", 8 ); - mlt_properties_set_int( mlt_producer_properties( title ), "align", 1 ); - mlt_properties_set_int( mlt_producer_properties( title ), "x", 20 ); - mlt_properties_set_int( mlt_producer_properties( title ), "y", 40 ); -#endif - - mlt_playlist playlist1 = mlt_playlist_init(); - mlt_playlist_append( playlist1, dv1 ); - mlt_playlist_blank( playlist1, 1.0 ); - - mlt_playlist playlist2 = mlt_playlist_init(); - mlt_playlist_blank( playlist2, 3.0 ); - mlt_playlist_append( playlist2, dv2 ); - - // Register producers(s) with a multitrack object - mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist1 ), 0 ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist2 ), 1 ); - - // Create a filter and associate it to track 0 - //mlt_filter filter = mlt_factory_filter( "deinterlace", NULL ); - //mlt_filter_connect( filter, mlt_multitrack_service( multitrack ), 0 ); - //mlt_filter_set_in_and_out( filter, 0, 1000 ); - - // Define a transition - mlt_transition transition = mlt_factory_transition( "luma", NULL ); - mlt_transition_connect( transition, mlt_multitrack_service( multitrack ), 0, 1 ); - mlt_transition_set_in_and_out( transition, 3.0, 5.0 ); - //mlt_properties_set( mlt_transition_properties( transition ), "filename", "clock.pgm" ); - mlt_properties_set_double( mlt_transition_properties( transition ), "softness", 0.1 ); - - // Buy a tractor and connect it to the filter - mlt_tractor tractor = mlt_tractor_init( ); - mlt_tractor_connect( tractor, mlt_transition_service( transition ) ); - - // Connect the tractor to the consumer - mlt_consumer_connect( consumer, mlt_tractor_service( tractor ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - - // Close everything... - mlt_consumer_close( consumer ); - mlt_tractor_close( tractor ); - mlt_transition_close( transition ); - mlt_multitrack_close( multitrack ); - mlt_producer_close( dv1 ); - mlt_producer_close( dv2 ); - - return 0; -} diff --git a/mlt/src/tests/dissolve.c b/mlt/src/tests/dissolve.c deleted file mode 100644 index d9ce2d7..0000000 --- a/mlt/src/tests/dissolve.c +++ /dev/null @@ -1,71 +0,0 @@ - -#include - -#include - -int main( int argc, char **argv ) -{ - char temp[ 132 ]; - char *file1 = NULL; - char *file2 = NULL; - - mlt_factory_init( "../modules" ); - - if ( argc < 3 ) - { - fprintf( stderr, "usage: dissolve file1.mpeg file2.mpeg\n" ); - return 1; - } - else - { - file1 = argv[ 1 ]; - file2 = argv[ 2 ]; - } - - // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" ); - - // Create the producer(s) - mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); - mlt_producer dv2 = mlt_factory_producer( "mcmpeg", file2 ); - - mlt_playlist playlist1 = mlt_playlist_init(); - mlt_playlist_append_io( playlist1, dv1, 0.0, 5.0 ); - - mlt_playlist playlist2 = mlt_playlist_init(); - mlt_playlist_blank( playlist2, 2.9 ); - mlt_playlist_append( playlist2, dv2 ); - - // Register producers(s) with a multitrack object - mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist1 ), 0 ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist2 ), 1 ); - - // Define a transition - mlt_transition transition = mlt_factory_transition( "luma", NULL ); - mlt_transition_connect( transition, mlt_multitrack_service( multitrack ), 0, 1 ); - mlt_transition_set_in_and_out( transition, 3.0, 5.0 ); - - // Buy a tractor and connect it to the filter - mlt_tractor tractor = mlt_tractor_init( ); - mlt_tractor_connect( tractor, mlt_transition_service( transition ) ); - - // Connect the tractor to the consumer - mlt_consumer_connect( consumer, mlt_tractor_service( tractor ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - - // Close everything... - mlt_consumer_close( consumer ); - mlt_tractor_close( tractor ); - mlt_transition_close( transition ); - mlt_multitrack_close( multitrack ); - mlt_playlist_close( playlist1 ); - mlt_playlist_close( playlist2 ); - mlt_producer_close( dv1 ); - mlt_producer_close( dv2 ); - - return 0; -} diff --git a/mlt/src/tests/io.c b/mlt/src/tests/io.c deleted file mode 100644 index 431003d..0000000 --- a/mlt/src/tests/io.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * io.c -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include -#include -#include -#include - -/* Application header files */ -#include "io.h" - -char *chomp( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - if ( length && input[ length - 1 ] == '\n' ) - input[ length - 1 ] = '\0'; - if ( length > 1 && input[ length - 2 ] == '\r' ) - input[ length - 2 ] = '\0'; - } - return input; -} - -char *trim( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - int first = 0; - while( first < length && isspace( input[ first ] ) ) - first ++; - memmove( input, input + first, length - first + 1 ); - length = length - first; - while ( length > 0 && isspace( input[ length - 1 ] ) ) - input[ -- length ] = '\0'; - } - return input; -} - -char *strip_quotes( char *input ) -{ - if ( input != NULL ) - { - char *ptr = strrchr( input, '\"' ); - if ( ptr != NULL ) - *ptr = '\0'; - if ( input[ 0 ] == '\"' ) - strcpy( input, input + 1 ); - } - return input; -} - -char *get_string( char *output, int maxlength, char *use ) -{ - char *value = NULL; - strcpy( output, use ); - if ( trim( chomp( fgets( output, maxlength, stdin ) ) ) != NULL ) - { - if ( !strcmp( output, "" ) ) - strcpy( output, use ); - value = output; - } - return value; -} - -int *get_int( int *output, int use ) -{ - int *value = NULL; - char temp[ 132 ]; - *output = use; - if ( trim( chomp( fgets( temp, 132, stdin ) ) ) != NULL ) - { - if ( strcmp( temp, "" ) ) - *output = atoi( temp ); - value = output; - } - return value; -} - -/** This stores the previous settings -*/ - -static struct termios oldtty; -static int mode = 0; - -/** This is called automatically on application exit to restore the - previous tty settings. -*/ - -void term_exit(void) -{ - if ( mode == 1 ) - { - tcsetattr( 0, TCSANOW, &oldtty ); - mode = 0; - } -} - -/** Init terminal so that we can grab keys without blocking. -*/ - -void term_init( ) -{ - struct termios tty; - - tcgetattr( 0, &tty ); - oldtty = tty; - - tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - tty.c_oflag |= OPOST; - tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); - tty.c_cflag &= ~(CSIZE|PARENB); - tty.c_cflag |= CS8; - tty.c_cc[ VMIN ] = 1; - tty.c_cc[ VTIME ] = 0; - - tcsetattr( 0, TCSANOW, &tty ); - - mode = 1; - - atexit( term_exit ); -} - -/** Check for a keypress without blocking infinitely. - Returns: ASCII value of keypress or -1 if no keypress detected. -*/ - -int term_read( ) -{ - int n = 1; - unsigned char ch; - struct timeval tv; - fd_set rfds; - - FD_ZERO( &rfds ); - FD_SET( 0, &rfds ); - tv.tv_sec = 0; - tv.tv_usec = 250; - n = select( 1, &rfds, NULL, NULL, &tv ); - if (n > 0) - { - n = read( 0, &ch, 1 ); - tcflush( 0, TCIFLUSH ); - if (n == 1) - return ch; - return n; - } - return -1; -} - -char get_keypress( ) -{ - char value = '\0'; - int pressed = 0; - - fflush( stdout ); - - term_init( ); - while ( ( pressed = term_read( ) ) == -1 ) ; - term_exit( ); - - value = (char)pressed; - - return value; -} - -void wait_for_any_key( char *message ) -{ - if ( message == NULL ) - printf( "Press any key to continue: " ); - else - printf( "%s", message ); - - get_keypress( ); - - printf( "\n\n" ); -} - -void beep( ) -{ - printf( "%c", 7 ); - fflush( stdout ); -} diff --git a/mlt/src/tests/io.h b/mlt/src/tests/io.h deleted file mode 100644 index f97e69e..0000000 --- a/mlt/src/tests/io.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * io.h -- dv1394d client demo input/output - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _DEMO_IO_H_ -#define _DEMO_IO_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern char *chomp( char * ); -extern char *trim( char * ); -extern char *strip_quotes( char * ); -extern char *get_string( char *, int, char * ); -extern int *get_int( int *, int ); -extern void term_init( ); -extern int term_read( ); -extern void term_exit( ); -extern char get_keypress( ); -extern void wait_for_any_key( char * ); -extern void beep( ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/tests/luma.c b/mlt/src/tests/luma.c deleted file mode 100644 index dabb878..0000000 --- a/mlt/src/tests/luma.c +++ /dev/null @@ -1,75 +0,0 @@ - -#include - -#include - -int main( int argc, char **argv ) -{ - char temp[ 132 ]; - char *file1 = NULL; - char *file2 = NULL; - char *wipe = NULL; - - mlt_factory_init( "../modules" ); - - if ( argc < 4 ) - { - fprintf( stderr, "usage: luma file1.mpeg file2.mpeg wipe.pgm\n" ); - return 1; - } - else - { - file1 = argv[ 1 ]; - file2 = argv[ 2 ]; - wipe = argv[ 3 ]; - } - - // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" ); - - // Create the producer(s) - mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); - mlt_producer dv2 = mlt_factory_producer( "mcmpeg", file2 ); - - mlt_playlist playlist1 = mlt_playlist_init(); - mlt_playlist_append_io( playlist1, dv1, 0.0, 5.0 ); - - mlt_playlist playlist2 = mlt_playlist_init(); - mlt_playlist_blank( playlist2, 2.9 ); - mlt_playlist_append( playlist2, dv2 ); - - // Register producers(s) with a multitrack object - mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist1 ), 0 ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( playlist2 ), 1 ); - - // Define a transition - mlt_transition transition = mlt_factory_transition( "luma", wipe ); - mlt_properties_set( mlt_transition_properties( transition ), "filename", wipe ); - mlt_properties_set_double( mlt_transition_properties( transition ), "softness", 0.1 ); - mlt_transition_connect( transition, mlt_multitrack_service( multitrack ), 0, 1 ); - mlt_transition_set_in_and_out( transition, 3.0, 5.0 ); - - // Buy a tractor and connect it to the filter - mlt_tractor tractor = mlt_tractor_init( ); - mlt_tractor_connect( tractor, mlt_transition_service( transition ) ); - - // Connect the tractor to the consumer - mlt_consumer_connect( consumer, mlt_tractor_service( tractor ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - - // Close everything... - mlt_consumer_close( consumer ); - mlt_tractor_close( tractor ); - mlt_transition_close( transition ); - mlt_multitrack_close( multitrack ); - mlt_playlist_close( playlist1 ); - mlt_playlist_close( playlist2 ); - mlt_producer_close( dv1 ); - mlt_producer_close( dv2 ); - - return 0; -} diff --git a/mlt/src/tests/pango.c b/mlt/src/tests/pango.c deleted file mode 100644 index fb56113..0000000 --- a/mlt/src/tests/pango.c +++ /dev/null @@ -1,78 +0,0 @@ - -#include - -#include - -int main( int argc, char **argv ) -{ - char temp[ 132 ]; - char *file1 = NULL; - char *text = NULL; - - mlt_factory_init( "../modules" ); - - if ( argc < 3 ) - { - fprintf( stderr, "usage: pango file.mpeg text_to_display\n" ); - return 1; - } - else - { - file1 = argv[ 1 ]; - text = argv[ 2 ]; - } - - // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "bluefish", "NTSC" ); - - // Create the producer(s) - mlt_playlist pl1 = mlt_playlist_init(); - mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); - mlt_playlist_append( pl1, dv1 ); - - mlt_playlist pl2 = mlt_playlist_init(); - mlt_producer title = mlt_factory_producer( "pango", NULL ); //"Mutton Lettuce Tomato" ); - mlt_playlist_append( pl2, title ); - mlt_properties_set_int( mlt_producer_properties( title ), "video_standard", mlt_video_standard_pal ); - mlt_properties_set( mlt_producer_properties( title ), "font", "Sans Bold 36" ); - mlt_properties_set( mlt_producer_properties( title ), "text", text ); - mlt_properties_set_int( mlt_producer_properties( title ), "bgcolor", 0x0000007f ); - mlt_properties_set_int( mlt_producer_properties( title ), "pad", 8 ); - mlt_properties_set_int( mlt_producer_properties( title ), "align", 1 ); - mlt_properties_set_int( mlt_producer_properties( title ), "x", 200 ); - mlt_properties_set_int( mlt_producer_properties( title ), "y", 40 ); - mlt_properties_set_double( mlt_producer_properties( title ), "mix", 0.8 ); - - // Register producers(s) with a multitrack object - mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( pl1 ), 0 ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( pl2 ), 1 ); - - // Define a transition - mlt_transition transition = mlt_factory_transition( "composite", NULL ); - mlt_transition_connect( transition, mlt_multitrack_service( multitrack ), 0, 1 ); - mlt_transition_set_in_and_out( transition, 0.0, 9999.0 ); - - // Buy a tractor and connect it to the filter - mlt_tractor tractor = mlt_tractor_init( ); - mlt_tractor_connect( tractor, mlt_transition_service( transition ) ); - - // Connect the tractor to the consumer - mlt_consumer_connect( consumer, mlt_tractor_service( tractor ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - - // Close everything... - mlt_consumer_close( consumer ); - mlt_tractor_close( tractor ); - mlt_transition_close( transition ); - mlt_multitrack_close( multitrack ); - mlt_playlist_close( pl1 ); - mlt_playlist_close( pl2 ); - mlt_producer_close( dv1 ); - mlt_producer_close( title ); - - return 0; -} diff --git a/mlt/src/tests/pixbuf.c b/mlt/src/tests/pixbuf.c deleted file mode 100644 index 64a23b7..0000000 --- a/mlt/src/tests/pixbuf.c +++ /dev/null @@ -1,73 +0,0 @@ - -#include - -#include - -int main( int argc, char **argv ) -{ - char temp[ 132 ]; - char *file1 = NULL; - char *file2 = NULL; - - mlt_factory_init( "../modules" ); - - if ( argc < 3 ) - { - fprintf( stderr, "usage: pixbuf file.mpeg file.{png,jpg,etc}\n" ); - return 1; - } - else - { - file1 = argv[ 1 ]; - file2 = argv[ 2 ]; - } - - // Start the consumer... - mlt_consumer consumer = mlt_factory_consumer( "sdl", "PAL" ); - - // Create the producer(s) - mlt_playlist pl1 = mlt_playlist_init(); - mlt_producer dv1 = mlt_factory_producer( "mcmpeg", file1 ); - mlt_playlist_append( pl1, dv1 ); - - mlt_playlist pl2 = mlt_playlist_init(); - mlt_producer overlay = mlt_factory_producer( "pixbuf", file2 ); - mlt_playlist_append( pl2, overlay ); - mlt_properties_set_int( mlt_producer_properties( overlay ), "video_standard", mlt_video_standard_pal ); - mlt_properties_set_int( mlt_producer_properties( overlay ), "x", 600 ); - mlt_properties_set_int( mlt_producer_properties( overlay ), "y", 460 ); - mlt_properties_set_double( mlt_producer_properties( overlay ), "mix", 0.8 ); - - // Register producers(s) with a multitrack object - mlt_multitrack multitrack = mlt_multitrack_init( ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( pl1 ), 0 ); - mlt_multitrack_connect( multitrack, mlt_playlist_producer( pl2 ), 1 ); - - // Define a transition - mlt_transition transition = mlt_factory_transition( "composite", NULL ); - mlt_transition_connect( transition, mlt_multitrack_service( multitrack ), 0, 1 ); - mlt_transition_set_in_and_out( transition, 0.0, 9999.0 ); - - // Buy a tractor and connect it to the filter - mlt_tractor tractor = mlt_tractor_init( ); - mlt_tractor_connect( tractor, mlt_transition_service( transition ) ); - - // Connect the tractor to the consumer - mlt_consumer_connect( consumer, mlt_tractor_service( tractor ) ); - - // Do stuff until we're told otherwise... - fprintf( stderr, "Press return to continue\n" ); - fgets( temp, 132, stdin ); - - // Close everything... - mlt_consumer_close( consumer ); - mlt_tractor_close( tractor ); - mlt_transition_close( transition ); - mlt_multitrack_close( multitrack ); - mlt_playlist_close( pl1 ); - mlt_playlist_close( pl2 ); - mlt_producer_close( dv1 ); - mlt_producer_close( overlay ); - - return 0; -} diff --git a/mlt/src/tests/setenv b/mlt/src/tests/setenv deleted file mode 100644 index 44cee49..0000000 --- a/mlt/src/tests/setenv +++ /dev/null @@ -1,7 +0,0 @@ -export MLT_REPOSITORY=`pwd`/../modules - -export LD_LIBRARY_PATH=`pwd`/../framework:\ -`pwd`/../modules/bluefish:\ -`pwd`/../../../bluefish/lib:\ -`pwd`/../../../mpeg_sdk_demo/bin:\ -`pwd`/../../../dv_sdk diff --git a/mlt/src/tests/test.png b/mlt/src/tests/test.png deleted file mode 100644 index b3fca64..0000000 Binary files a/mlt/src/tests/test.png and /dev/null differ diff --git a/mlt/src/valerie/Makefile b/mlt/src/valerie/Makefile deleted file mode 100644 index 6afae18..0000000 --- a/mlt/src/valerie/Makefile +++ /dev/null @@ -1,36 +0,0 @@ - -TARGET = libvalerie.so - -OBJS = valerie.o \ - valerie_notifier.o \ - valerie_parser.o \ - valerie_response.o \ - valerie_status.o \ - valerie_tokeniser.o \ - valerie_util.o \ - valerie_remote.o \ - valerie_socket.o - -SRCS := $(OBJS:.o=.c) - -CFLAGS=-Wall -g -D_FILE_OFFSET_BITS=64 -pthread - -LDFLAGS=-ldv -lpthread - -all: $(TARGET) - -$(TARGET): $(OBJS) - $(CC) -shared -o $@ $(OBJS) $(LDFLAGS) - -depend: $(SRCS) - $(CC) -MM $(CFLAGS) $^ 1>.depend - -dist-clean: clean - rm -f .depend - -clean: - rm -f $(OBJS) $(TARGET) - -ifneq ($(wildcard .depend),) -include .depend -endif diff --git a/mlt/src/valerie/configure b/mlt/src/valerie/configure deleted file mode 100755 index 1a24852..0000000 --- a/mlt/src/valerie/configure +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/mlt/src/valerie/valerie.c b/mlt/src/valerie/valerie.c deleted file mode 100644 index f273153..0000000 --- a/mlt/src/valerie/valerie.c +++ /dev/null @@ -1,875 +0,0 @@ -/* - * valerie.c -- High Level Client API for miracle - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include -#include -#include - -/* Application header files */ -#include "valerie.h" -#include "valerie_tokeniser.h" -#include "valerie_util.h" - -/** Initialise the valerie structure. -*/ - -valerie valerie_init( valerie_parser parser ) -{ - valerie this = malloc( sizeof( valerie_t ) ); - if ( this != NULL ) - { - memset( this, 0, sizeof( valerie_t ) ); - this->parser = parser; - } - return this; -} - -/** Set the response structure associated to the last command. -*/ - -static void valerie_set_last_response( valerie this, valerie_response response ) -{ - if ( this != NULL ) - { - if ( this->last_response != NULL ) - valerie_response_close( this->last_response ); - this->last_response = response; - } -} - -/** Connect to the parser. -*/ - -valerie_error_code valerie_connect( valerie this ) -{ - valerie_error_code error = valerie_server_unavailable; - valerie_response response = valerie_parser_connect( this->parser ); - if ( response != NULL ) - { - valerie_set_last_response( this, response ); - if ( valerie_response_get_error_code( response ) == 100 ) - error = valerie_ok; - } - return error; -} - -/** Interpret a non-context sensitive error code. -*/ - -static valerie_error_code valerie_get_error_code( valerie this, valerie_response response ) -{ - valerie_error_code error = valerie_server_unavailable; - switch( valerie_response_get_error_code( response ) ) - { - case -1: - error = valerie_server_unavailable; - break; - case -2: - error = valerie_no_response; - break; - case 200: - case 201: - case 202: - error = valerie_ok; - break; - case 400: - error = valerie_invalid_command; - break; - case 401: - error = valerie_server_timeout; - break; - case 402: - error = valerie_missing_argument; - break; - case 403: - error = valerie_unit_unavailable; - break; - case 404: - error = valerie_invalid_file; - break; - default: - case 500: - error = valerie_unknown_error; - break; - } - return error; -} - -/** Execute a command. -*/ - -valerie_error_code valerie_execute( valerie this, size_t size, char *format, ... ) -{ - valerie_error_code error = valerie_server_unavailable; - char *command = malloc( size ); - if ( this != NULL && command != NULL ) - { - va_list list; - va_start( list, format ); - if ( vsnprintf( command, size, format, list ) != 0 ) - { - valerie_response response = valerie_parser_execute( this->parser, command ); - valerie_set_last_response( this, response ); - error = valerie_get_error_code( this, response ); - } - else - { - error = valerie_invalid_command; - } - va_end( list ); - } - else - { - error = valerie_malloc_failed; - } - free( command ); - return error; -} - -/** Set a global property. -*/ - -valerie_error_code valerie_set( valerie this, char *property, char *value ) -{ - return valerie_execute( this, 1024, "SET %s=%s", property, value ); -} - -/** Get a global property. -*/ - -valerie_error_code valerie_get( valerie this, char *property, char *value, int length ) -{ - valerie_error_code error = valerie_execute( this, 1024, "GET %s", property ); - if ( error == valerie_ok ) - { - valerie_response response = valerie_get_last_response( this ); - strncpy( value, valerie_response_get_line( response, 1 ), length ); - } - return error; -} - -/** Run a script. -*/ - -valerie_error_code valerie_run( valerie this, char *file ) -{ - return valerie_execute( this, 10240, "RUN \"%s\"", file ); -} - -/** Add a unit. -*/ - -valerie_error_code valerie_unit_add( valerie this, char *guid, int *unit ) -{ - valerie_error_code error = valerie_execute( this, 1024, "UADD %s", guid ); - if ( error == valerie_ok ) - { - int length = valerie_response_count( this->last_response ); - char *line = valerie_response_get_line( this->last_response, length - 2 ); - if ( line == NULL || sscanf( line, "U%d", unit ) != 1 ) - error = valerie_unit_creation_failed; - } - else - { - if ( error == valerie_unknown_error ) - error = valerie_unit_creation_failed; - } - return error; -} - -/** Load a file on the specified unit. -*/ - -valerie_error_code valerie_unit_load( valerie this, int unit, char *file ) -{ - return valerie_execute( this, 10240, "LOAD U%d \"%s\"", unit, file ); -} - -static void valerie_interpret_clip_offset( char *output, valerie_clip_offset offset, int clip ) -{ - switch( offset ) - { - case valerie_absolute: - sprintf( output, "%d", clip ); - break; - case valerie_relative: - if ( clip < 0 ) - sprintf( output, "%d", clip ); - else - sprintf( output, "+%d", clip ); - break; - } -} - -/** Load a file on the specified unit with the specified in/out points. -*/ - -valerie_error_code valerie_unit_load_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) -{ - return valerie_execute( this, 10240, "LOAD U%d \"%s\" %lld %lld", unit, file, in, out ); -} - -/** Load a file on the specified unit at the end of the current pump. -*/ - -valerie_error_code valerie_unit_load_back( valerie this, int unit, char *file ) -{ - return valerie_execute( this, 10240, "LOAD U%d \"!%s\"", unit, file ); -} - -/** Load a file on the specified unit at the end of the pump with the specified in/out points. -*/ - -valerie_error_code valerie_unit_load_back_clipped( valerie this, int unit, char *file, int64_t in, int64_t out ) -{ - return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %lld %lld", unit, file, in, out ); -} - -/** Append a file on the specified unit. -*/ - -valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int64_t in, int64_t out ) -{ - return valerie_execute( this, 10240, "APND U%d \"%s\" %lld %lld", unit, file, in, out ); -} - -/** Clean the unit - this function removes all but the currently playing clip. -*/ - -valerie_error_code valerie_unit_clean( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "CLEAN U%d", unit ); -} - -/** Move clips on the units playlist. -*/ - -valerie_error_code valerie_unit_clip_move( valerie this, int unit, valerie_clip_offset src_offset, int src, valerie_clip_offset dest_offset, int dest ) -{ - char temp1[ 100 ]; - char temp2[ 100 ]; - valerie_interpret_clip_offset( temp1, src_offset, src ); - valerie_interpret_clip_offset( temp2, dest_offset, dest ); - return valerie_execute( this, 1024, "MOVE U%d %s %s", unit, temp1, temp2 ); -} - -/** Remove clip at the specified position. -*/ - -valerie_error_code valerie_unit_clip_remove( valerie this, int unit, valerie_clip_offset offset, int clip ) -{ - char temp[ 100 ]; - valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "REMOVE U%d %s", unit, temp ); -} - -/** Remove the currently playing clip. -*/ - -valerie_error_code valerie_unit_remove_current_clip( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "REMOVE U%d", unit ); -} - -/** Insert clip at the specified position. -*/ - -valerie_error_code valerie_unit_clip_insert( valerie this, int unit, valerie_clip_offset offset, int clip, char *file, int64_t in, int64_t out ) -{ - char temp[ 100 ]; - valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "INSERT U%d %s %s %lld %lld", unit, file, temp, in, out ); -} - -/** Play the unit at normal speed. -*/ - -valerie_error_code valerie_unit_play( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "PLAY U%d 1000", unit ); -} - -/** Play the unit at specified speed. -*/ - -valerie_error_code valerie_unit_play_at_speed( valerie this, int unit, int speed ) -{ - return valerie_execute( this, 10240, "PLAY U%d %d", unit, speed ); -} - -/** Stop playback on the specified unit. -*/ - -valerie_error_code valerie_unit_stop( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "STOP U%d", unit ); -} - -/** Pause playback on the specified unit. -*/ - -valerie_error_code valerie_unit_pause( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "PAUSE U%d", unit ); -} - -/** Rewind the specified unit. -*/ - -valerie_error_code valerie_unit_rewind( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "REW U%d", unit ); -} - -/** Fast forward the specified unit. -*/ - -valerie_error_code valerie_unit_fast_forward( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "FF U%d", unit ); -} - -/** Step by the number of frames on the specified unit. -*/ - -valerie_error_code valerie_unit_step( valerie this, int unit, int64_t step ) -{ - return valerie_execute( this, 1024, "STEP U%d %lld", unit, step ); -} - -/** Goto the specified frame on the specified unit. -*/ - -valerie_error_code valerie_unit_goto( valerie this, int unit, int64_t position ) -{ - return valerie_execute( this, 1024, "GOTO U%d %lld", unit, position ); -} - -/** Goto the specified frame in the clip on the specified unit. -*/ - -valerie_error_code valerie_unit_clip_goto( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t position ) -{ - char temp[ 100 ]; - valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "GOTO U%d %lld %s", unit, position, temp ); -} - -/** Set the in point of the loaded file on the specified unit. -*/ - -valerie_error_code valerie_unit_set_in( valerie this, int unit, int64_t in ) -{ - return valerie_execute( this, 1024, "SIN U%d %lld", unit, in ); -} - -/** Set the in point of the clip on the specified unit. -*/ - -valerie_error_code valerie_unit_clip_set_in( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) -{ - char temp[ 100 ]; - valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SIN U%d %lld %s", unit, in, temp ); -} - -/** Set the out point of the loaded file on the specified unit. -*/ - -valerie_error_code valerie_unit_set_out( valerie this, int unit, int64_t out ) -{ - return valerie_execute( this, 1024, "SOUT U%d %lld", unit, out ); -} - -/** Set the out point of the clip on the specified unit. -*/ - -valerie_error_code valerie_unit_clip_set_out( valerie this, int unit, valerie_clip_offset offset, int clip, int64_t in ) -{ - char temp[ 100 ]; - valerie_interpret_clip_offset( temp, offset, clip ); - return valerie_execute( this, 1024, "SOUT U%d %lld %s", unit, in, temp ); -} - -/** Clear the in point of the loaded file on the specified unit. -*/ - -valerie_error_code valerie_unit_clear_in( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "SIN U%d -1", unit ); -} - -/** Clear the out point of the loaded file on the specified unit. -*/ - -valerie_error_code valerie_unit_clear_out( valerie this, int unit ) -{ - return valerie_execute( this, 1024, "SOUT U%d -1", unit ); -} - -/** Clear the in and out points on the loaded file on the specified unit. -*/ - -valerie_error_code valerie_unit_clear_in_out( valerie this, int unit ) -{ - valerie_error_code error = valerie_unit_clear_out( this, unit ); - if ( error == valerie_ok ) - error = valerie_unit_clear_in( this, unit ); - return error; -} - -/** Set a unit configuration property. -*/ - -valerie_error_code valerie_unit_set( valerie this, int unit, char *name, char *value ) -{ - return valerie_execute( this, 1024, "USET U%d %s=%s", unit, name, value ); -} - -/** Get a unit configuration property. -*/ - -valerie_error_code valerie_unit_get( valerie this, int unit, char *name ) -{ - return valerie_execute( this, 1024, "UGET U%d %s", unit, name ); -} - -/** Get a units status. -*/ - -valerie_error_code valerie_unit_status( valerie this, int unit, valerie_status status ) -{ - valerie_error_code error = valerie_execute( this, 1024, "USTA U%d", unit ); - int error_code = valerie_response_get_error_code( this->last_response ); - - memset( status, 0, sizeof( valerie_status_t ) ); - status->unit = unit; - if ( error_code == 202 && valerie_response_count( this->last_response ) == 2 ) - valerie_status_parse( status, valerie_response_get_line( this->last_response, 1 ) ); - else if ( error_code == 403 ) - status->status = unit_undefined; - - return error; -} - -/** Transfer the current settings of unit src to unit dest. -*/ - -valerie_error_code valerie_unit_transfer( valerie this, int src, int dest ) -{ - return valerie_execute( this, 1024, "XFER U%d U%d", src, dest ); -} - -/** Obtain the parsers notifier. -*/ - -valerie_notifier valerie_get_notifier( valerie this ) -{ - if ( this != NULL ) - return valerie_parser_get_notifier( this->parser ); - else - return NULL; -} - -/** List the contents of the specified directory. -*/ - -valerie_dir valerie_dir_init( valerie this, char *directory ) -{ - valerie_dir dir = malloc( sizeof( valerie_dir_t ) ); - if ( dir != NULL ) - { - memset( dir, 0, sizeof( valerie_dir_t ) ); - dir->directory = strdup( directory ); - dir->response = valerie_parser_executef( this->parser, "CLS \"%s\"", directory ); - } - return dir; -} - -/** Return the error code associated to the dir. -*/ - -valerie_error_code valerie_dir_get_error_code( valerie_dir dir ) -{ - if ( dir != NULL ) - return valerie_get_error_code( NULL, dir->response ); - else - return valerie_malloc_failed; -} - -/** Get a particular file entry in the directory. -*/ - -valerie_error_code valerie_dir_get( valerie_dir dir, int index, valerie_dir_entry entry ) -{ - valerie_error_code error = valerie_ok; - memset( entry, 0, sizeof( valerie_dir_entry_t ) ); - if ( index < valerie_dir_count( dir ) ) - { - char *line = valerie_response_get_line( dir->response, index + 1 ); - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - valerie_tokeniser_parse_new( tokeniser, line, " " ); - - if ( valerie_tokeniser_count( tokeniser ) > 0 ) - { - valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 0 ), '\"' ); - strcpy( entry->full, dir->directory ); - if ( entry->full[ strlen( entry->full ) - 1 ] != '/' ) - strcat( entry->full, "/" ); - strcpy( entry->name, valerie_tokeniser_get_string( tokeniser, 0 ) ); - strcat( entry->full, entry->name ); - - switch ( valerie_tokeniser_count( tokeniser ) ) - { - case 1: - entry->dir = 1; - break; - case 2: - entry->size = strtoull( valerie_tokeniser_get_string( tokeniser, 1 ), NULL, 10 ); - break; - default: - error = valerie_invalid_file; - break; - } - } - valerie_tokeniser_close( tokeniser ); - } - return error; -} - -/** Get the number of entries in the directory -*/ - -int valerie_dir_count( valerie_dir dir ) -{ - if ( dir != NULL && valerie_response_count( dir->response ) >= 2 ) - return valerie_response_count( dir->response ) - 2; - else - return -1; -} - -/** Close the directory structure. -*/ - -void valerie_dir_close( valerie_dir dir ) -{ - if ( dir != NULL ) - { - free( dir->directory ); - valerie_response_close( dir->response ); - free( dir ); - } -} - -/** List the playlist of the specified unit. -*/ - -valerie_list valerie_list_init( valerie this, int unit ) -{ - valerie_list list = calloc( 1, sizeof( valerie_list_t ) ); - if ( list != NULL ) - { - list->response = valerie_parser_executef( this->parser, "LIST U%d", unit ); - if ( valerie_response_count( list->response ) >= 2 ) - list->generation = atoi( valerie_response_get_line( list->response, 1 ) ); - } - return list; -} - -/** Return the error code associated to the list. -*/ - -valerie_error_code valerie_list_get_error_code( valerie_list list ) -{ - if ( list != NULL ) - return valerie_get_error_code( NULL, list->response ); - else - return valerie_malloc_failed; -} - -/** Get a particular file entry in the list. -*/ - -valerie_error_code valerie_list_get( valerie_list list, int index, valerie_list_entry entry ) -{ - valerie_error_code error = valerie_ok; - memset( entry, 0, sizeof( valerie_list_entry_t ) ); - if ( index < valerie_list_count( list ) ) - { - char *line = valerie_response_get_line( list->response, index + 2 ); - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - valerie_tokeniser_parse_new( tokeniser, line, " " ); - - if ( valerie_tokeniser_count( tokeniser ) > 0 ) - { - entry->clip = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); - valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 1 ), '\"' ); - strcpy( entry->full, valerie_tokeniser_get_string( tokeniser, 1 ) ); - entry->in = atol( valerie_tokeniser_get_string( tokeniser, 2 ) ); - entry->out = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); - entry->max = atol( valerie_tokeniser_get_string( tokeniser, 4 ) ); - entry->size = atol( valerie_tokeniser_get_string( tokeniser, 5 ) ); - entry->fps = atof( valerie_tokeniser_get_string( tokeniser, 6 ) ); - } - valerie_tokeniser_close( tokeniser ); - } - return error; -} - -/** Get the number of entries in the list -*/ - -int valerie_list_count( valerie_list list ) -{ - if ( list != NULL && valerie_response_count( list->response ) >= 3 ) - return valerie_response_count( list->response ) - 3; - else - return -1; -} - -/** Close the list structure. -*/ - -void valerie_list_close( valerie_list list ) -{ - if ( list != NULL ) - { - valerie_response_close( list->response ); - free( list ); - } -} - -/** List the currently connected nodes. -*/ - -valerie_nodes valerie_nodes_init( valerie this ) -{ - valerie_nodes nodes = malloc( sizeof( valerie_nodes_t ) ); - if ( nodes != NULL ) - { - memset( nodes, 0, sizeof( valerie_nodes_t ) ); - nodes->response = valerie_parser_executef( this->parser, "NLS" ); - } - return nodes; -} - -/** Return the error code associated to the nodes list. -*/ - -valerie_error_code valerie_nodes_get_error_code( valerie_nodes nodes ) -{ - if ( nodes != NULL ) - return valerie_get_error_code( NULL, nodes->response ); - else - return valerie_malloc_failed; -} - -/** Get a particular node entry. -*/ - -valerie_error_code valerie_nodes_get( valerie_nodes nodes, int index, valerie_node_entry entry ) -{ - valerie_error_code error = valerie_ok; - memset( entry, 0, sizeof( valerie_node_entry_t ) ); - if ( index < valerie_nodes_count( nodes ) ) - { - char *line = valerie_response_get_line( nodes->response, index + 1 ); - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - valerie_tokeniser_parse_new( tokeniser, line, " " ); - - if ( valerie_tokeniser_count( tokeniser ) == 3 ) - { - entry->node = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); - strncpy( entry->guid, valerie_tokeniser_get_string( tokeniser, 1 ), sizeof( entry->guid ) ); - valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 2 ), '\"' ); - strncpy( entry->name, valerie_tokeniser_get_string( tokeniser, 2 ), sizeof( entry->name ) ); - } - - valerie_tokeniser_close( tokeniser ); - } - return error; -} - -/** Get the number of nodes -*/ - -int valerie_nodes_count( valerie_nodes nodes ) -{ - if ( nodes != NULL && valerie_response_count( nodes->response ) >= 2 ) - return valerie_response_count( nodes->response ) - 2; - else - return -1; -} - -/** Close the nodes structure. -*/ - -void valerie_nodes_close( valerie_nodes nodes ) -{ - if ( nodes != NULL ) - { - valerie_response_close( nodes->response ); - free( nodes ); - } -} - -/** List the currently defined units. -*/ - -valerie_units valerie_units_init( valerie this ) -{ - valerie_units units = malloc( sizeof( valerie_units_t ) ); - if ( units != NULL ) - { - memset( units, 0, sizeof( valerie_units_t ) ); - units->response = valerie_parser_executef( this->parser, "ULS" ); - } - return units; -} - -/** Return the error code associated to the nodes list. -*/ - -valerie_error_code valerie_units_get_error_code( valerie_units units ) -{ - if ( units != NULL ) - return valerie_get_error_code( NULL, units->response ); - else - return valerie_malloc_failed; -} - -/** Get a particular unit entry. -*/ - -valerie_error_code valerie_units_get( valerie_units units, int index, valerie_unit_entry entry ) -{ - valerie_error_code error = valerie_ok; - memset( entry, 0, sizeof( valerie_unit_entry_t ) ); - if ( index < valerie_units_count( units ) ) - { - char *line = valerie_response_get_line( units->response, index + 1 ); - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - valerie_tokeniser_parse_new( tokeniser, line, " " ); - - if ( valerie_tokeniser_count( tokeniser ) == 4 ) - { - entry->unit = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) + 1 ); - entry->node = atoi( valerie_tokeniser_get_string( tokeniser, 1 ) ); - strncpy( entry->guid, valerie_tokeniser_get_string( tokeniser, 2 ), sizeof( entry->guid ) ); - entry->online = atoi( valerie_tokeniser_get_string( tokeniser, 3 ) ); - } - - valerie_tokeniser_close( tokeniser ); - } - return error; -} - -/** Get the number of units -*/ - -int valerie_units_count( valerie_units units ) -{ - if ( units != NULL && valerie_response_count( units->response ) >= 2 ) - return valerie_response_count( units->response ) - 2; - else - return -1; -} - -/** Close the units structure. -*/ - -void valerie_units_close( valerie_units units ) -{ - if ( units != NULL ) - { - valerie_response_close( units->response ); - free( units ); - } -} - -/** Get the response of the last command executed. -*/ - -valerie_response valerie_get_last_response( valerie this ) -{ - return this->last_response; -} - -/** Obtain a printable message associated to the error code provided. -*/ - -char *valerie_error_description( valerie_error_code error ) -{ - char *msg = "Unrecognised error"; - switch( error ) - { - case valerie_ok: - msg = "OK"; - break; - case valerie_malloc_failed: - msg = "Memory allocation error"; - break; - case valerie_unknown_error: - msg = "Unknown error"; - break; - case valerie_no_response: - msg = "No response obtained"; - break; - case valerie_invalid_command: - msg = "Invalid command"; - break; - case valerie_server_timeout: - msg = "Communications with server timed out"; - break; - case valerie_missing_argument: - msg = "Missing argument"; - break; - case valerie_server_unavailable: - msg = "Unable to communicate with server"; - break; - case valerie_unit_creation_failed: - msg = "Unit creation failed"; - break; - case valerie_unit_unavailable: - msg = "Unit unavailable"; - break; - case valerie_invalid_file: - msg = "Invalid file"; - break; - case valerie_invalid_position: - msg = "Invalid position"; - break; - } - return msg; -} - -/** Close the valerie structure. -*/ - -void valerie_close( valerie this ) -{ - if ( this != NULL ) - { - valerie_set_last_response( this, NULL ); - free( this ); - } -} diff --git a/mlt/src/valerie/valerie.h b/mlt/src/valerie/valerie.h deleted file mode 100644 index 658ef9a..0000000 --- a/mlt/src/valerie/valerie.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * valerie.h -- High Level Client API for miracle - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _VALERIE_H_ -#define _VALERIE_H_ - -/* System header files */ -#include - -/* Application header files */ -#include "valerie_parser.h" -#include "valerie_status.h" -#include "valerie_notifier.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Client error conditions -*/ - -typedef enum -{ - valerie_ok = 0, - valerie_malloc_failed, - valerie_unknown_error, - valerie_no_response, - valerie_invalid_command, - valerie_server_timeout, - valerie_missing_argument, - valerie_server_unavailable, - valerie_unit_creation_failed, - valerie_unit_unavailable, - valerie_invalid_file, - valerie_invalid_position -} -valerie_error_code; - -/** Clip index specification. -*/ - -typedef enum -{ - valerie_absolute = 0, - valerie_relative -} -valerie_clip_offset; - -/** Client structure. -*/ - -typedef struct -{ - valerie_parser parser; - valerie_response last_response; -} -*valerie, valerie_t; - -/** Client API. -*/ - -extern valerie valerie_init( valerie_parser ); - -/* Connect to the valerie parser instance */ -extern valerie_error_code valerie_connect( valerie ); - -/* Global functions */ -extern valerie_error_code valerie_set( valerie, char *, char * ); -extern valerie_error_code valerie_get( valerie, char *, char *, int ); -extern valerie_error_code valerie_run( valerie, char * ); - -/* Unit functions */ -extern valerie_error_code valerie_unit_add( valerie, char *, int * ); -extern valerie_error_code valerie_unit_load( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_clipped( valerie, int, char *, int64_t, int64_t ); -extern valerie_error_code valerie_unit_load_back( valerie, int, char * ); -extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int64_t, int64_t ); -extern valerie_error_code valerie_unit_append( valerie, int, char *, int64_t, int64_t ); -extern valerie_error_code valerie_unit_clean( valerie, int ); -extern valerie_error_code valerie_unit_clip_move( valerie, int, valerie_clip_offset, int, valerie_clip_offset, int ); -extern valerie_error_code valerie_unit_clip_remove( valerie, int, valerie_clip_offset, int ); -extern valerie_error_code valerie_unit_remove_current_clip( valerie, int ); -extern valerie_error_code valerie_unit_clip_insert( valerie, int, valerie_clip_offset, int, char *, int64_t, int64_t ); -extern valerie_error_code valerie_unit_play( valerie, int ); -extern valerie_error_code valerie_unit_play_at_speed( valerie, int, int ); -extern valerie_error_code valerie_unit_stop( valerie, int ); -extern valerie_error_code valerie_unit_pause( valerie, int ); -extern valerie_error_code valerie_unit_rewind( valerie, int ); -extern valerie_error_code valerie_unit_fast_forward( valerie, int ); -extern valerie_error_code valerie_unit_step( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_goto( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int64_t ); -extern valerie_error_code valerie_unit_set_in( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_set_out( valerie, int, int64_t ); -extern valerie_error_code valerie_unit_clear_in( valerie, int ); -extern valerie_error_code valerie_unit_clear_out( valerie, int ); -extern valerie_error_code valerie_unit_clear_in_out( valerie, int ); -extern valerie_error_code valerie_unit_set( valerie, int, char *, char * ); -extern valerie_error_code valerie_unit_get( valerie, int, char * ); -extern valerie_error_code valerie_unit_status( valerie, int, valerie_status ); -extern valerie_error_code valerie_unit_transfer( valerie, int, int ); - -/* Notifier functionality. */ -extern valerie_notifier valerie_get_notifier( valerie ); - -/** Structure for the directory. -*/ - -typedef struct -{ - char *directory; - valerie_response response; -} -*valerie_dir, valerie_dir_t; - -/** Directory entry structure. -*/ - -typedef struct -{ - int dir; - char name[ NAME_MAX ]; - char full[ PATH_MAX + NAME_MAX ]; - unsigned long long size; -} -*valerie_dir_entry, valerie_dir_entry_t; - -/* Directory reading. */ -extern valerie_dir valerie_dir_init( valerie, char * ); -extern valerie_error_code valerie_dir_get_error_code( valerie_dir ); -extern valerie_error_code valerie_dir_get( valerie_dir, int, valerie_dir_entry ); -extern int valerie_dir_count( valerie_dir ); -extern void valerie_dir_close( valerie_dir ); - -/** Structure for the list. -*/ - -typedef struct -{ - int generation; - valerie_response response; -} -*valerie_list, valerie_list_t; - -/** List entry structure. -*/ - -typedef struct -{ - int clip; - char full[ PATH_MAX + NAME_MAX ]; - int64_t in; - int64_t out; - int64_t max; - int64_t size; - int64_t fps; -} -*valerie_list_entry, valerie_list_entry_t; - -/* List reading. */ -extern valerie_list valerie_list_init( valerie, int ); -extern valerie_error_code valerie_list_get_error_code( valerie_list ); -extern valerie_error_code valerie_list_get( valerie_list, int, valerie_list_entry ); -extern int valerie_list_count( valerie_list ); -extern void valerie_list_close( valerie_list ); - -/** Structure for nodes. -*/ - -typedef struct -{ - valerie_response response; -} -*valerie_nodes, valerie_nodes_t; - -/** Node entry structure. -*/ - -typedef struct -{ - int node; - char guid[ 17 ]; - char name[ 1024 ]; -} -*valerie_node_entry, valerie_node_entry_t; - -/* Node reading. */ -extern valerie_nodes valerie_nodes_init( valerie ); -extern valerie_error_code valerie_nodes_get_error_code( valerie_nodes ); -extern valerie_error_code valerie_nodes_get( valerie_nodes, int, valerie_node_entry ); -extern int valerie_nodes_count( valerie_nodes ); -extern void valerie_nodes_close( valerie_nodes ); - -/** Structure for units. -*/ - -typedef struct -{ - valerie_response response; -} -*valerie_units, valerie_units_t; - -/** Unit entry structure. -*/ - -typedef struct -{ - int unit; - int node; - char guid[ 512 ]; - int online; -} -*valerie_unit_entry, valerie_unit_entry_t; - -/* Unit reading. */ -extern valerie_units valerie_units_init( valerie ); -extern valerie_error_code valerie_units_get_error_code( valerie_units ); -extern valerie_error_code valerie_units_get( valerie_units, int, valerie_unit_entry ); -extern int valerie_units_count( valerie_units ); -extern void valerie_units_close( valerie_units ); - -/* Miscellaenous functions */ -extern valerie_response valerie_get_last_response( valerie ); -extern char *valerie_error_description( valerie_error_code ); - -/* Courtesy functions. */ -extern valerie_error_code valerie_execute( valerie, size_t, char *, ... ); - -/* Close function. */ -extern void valerie_close( valerie ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_notifier.c b/mlt/src/valerie/valerie_notifier.c deleted file mode 100644 index 5e374a8..0000000 --- a/mlt/src/valerie/valerie_notifier.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * valerie_notifier.c -- Unit Status Notifier Handling - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include -#include -#include - -/* Application header files */ -#include "valerie_notifier.h" - -/** Notifier initialisation. -*/ - -valerie_notifier valerie_notifier_init( ) -{ - valerie_notifier this = malloc( sizeof( valerie_notifier_t ) ); - if ( this != NULL ) - { - int index = 0; - memset( this, 0, sizeof( valerie_notifier_t ) ); - pthread_mutex_init( &this->mutex, NULL ); - pthread_cond_init( &this->cond, NULL ); - pthread_mutex_init( &this->cond_mutex, NULL ); - for ( index = 0; index < MAX_UNITS; index ++ ) - this->store[ index ].unit = index; - } - return this; -} - -/** Get a stored status for the specified unit. -*/ - -void valerie_notifier_get( valerie_notifier this, valerie_status status, int unit ) -{ - pthread_mutex_lock( &this->mutex ); - if ( unit >= 0 && unit < MAX_UNITS ) - { - valerie_status_copy( status, &this->store[ unit ] ); - } - else - { - memset( status, 0, sizeof( valerie_status_t ) ); - status->unit = unit; - } - status->dummy = time( NULL ); - pthread_mutex_unlock( &this->mutex ); -} - -/** Wait on a new status. -*/ - -int valerie_notifier_wait( valerie_notifier this, valerie_status status ) -{ - struct timeval now; - struct timespec timeout; - int error = 0; - - memset( status, 0, sizeof( valerie_status_t ) ); - - pthread_mutex_lock( &this->cond_mutex ); - gettimeofday( &now, NULL ); - timeout.tv_sec = now.tv_sec + 1; - timeout.tv_nsec = now.tv_usec * 1000; - if ( pthread_cond_timedwait( &this->cond, &this->cond_mutex, &timeout ) != ETIMEDOUT ) - { - pthread_mutex_lock( &this->mutex ); - valerie_status_copy( status, &this->last ); - pthread_mutex_unlock( &this->mutex ); - } - else - { - error = -1; - } - pthread_mutex_unlock( &this->cond_mutex ); - - return error; -} - -/** Put a new status. -*/ - -void valerie_notifier_put( valerie_notifier this, valerie_status status ) -{ - pthread_mutex_lock( &this->mutex ); - valerie_status_copy( &this->store[ status->unit ], status ); - valerie_status_copy( &this->last, status ); - pthread_mutex_unlock( &this->mutex ); - pthread_cond_broadcast( &this->cond ); -} - -/** Communicate a disconnected status for all units to all waiting. -*/ - -void valerie_notifier_disconnected( valerie_notifier notifier ) -{ - int unit = 0; - valerie_status_t status; - for ( unit = 0; unit < MAX_UNITS; unit ++ ) - { - valerie_notifier_get( notifier, &status, unit ); - status.status = unit_disconnected; - valerie_notifier_put( notifier, &status ); - } -} - -/** Close the notifier - note that all access must be stopped before we call this. -*/ - -void valerie_notifier_close( valerie_notifier this ) -{ - if ( this != NULL ) - { - pthread_mutex_destroy( &this->mutex ); - pthread_mutex_destroy( &this->cond_mutex ); - pthread_cond_destroy( &this->cond ); - free( this ); - } -} diff --git a/mlt/src/valerie/valerie_notifier.h b/mlt/src/valerie/valerie_notifier.h deleted file mode 100644 index bc123ed..0000000 --- a/mlt/src/valerie/valerie_notifier.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * valerie_notifier.h -- Unit Status Notifier Handling - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_NOTIFIER_H_ -#define _VALERIE_NOTIFIER_H_ - -/* System header files */ -#include - -/* Application header files */ -#include "valerie_status.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define MAX_UNITS 16 - -/** Status notifier definition. -*/ - -typedef struct -{ - pthread_mutex_t mutex; - pthread_mutex_t cond_mutex; - pthread_cond_t cond; - valerie_status_t last; - valerie_status_t store[ MAX_UNITS ]; -} -*valerie_notifier, valerie_notifier_t; - -extern valerie_notifier valerie_notifier_init( ); -extern void valerie_notifier_get( valerie_notifier, valerie_status, int ); -extern int valerie_notifier_wait( valerie_notifier, valerie_status ); -extern void valerie_notifier_put( valerie_notifier, valerie_status ); -extern void valerie_notifier_disconnected( valerie_notifier ); -extern void valerie_notifier_close( valerie_notifier ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_parser.c b/mlt/src/valerie/valerie_parser.c deleted file mode 100644 index 4ead1c0..0000000 --- a/mlt/src/valerie/valerie_parser.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * valerie_parser.c -- Valerie Parser for Miracle - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include -#include -#include - -/* Application header files */ -#include "valerie_parser.h" -#include "valerie_util.h" - -/** Connect to the parser. -*/ - -valerie_response valerie_parser_connect( valerie_parser parser ) -{ - return parser->connect( parser->real ); -} - -/** Execute a command via the parser. -*/ - -valerie_response valerie_parser_execute( valerie_parser parser, char *command ) -{ - return parser->execute( parser->real, command ); -} - -/** Execute a formatted command via the parser. -*/ - -valerie_response valerie_parser_executef( valerie_parser parser, char *format, ... ) -{ - char *command = malloc( 10240 ); - valerie_response response = NULL; - if ( command != NULL ) - { - va_list list; - va_start( list, format ); - if ( vsnprintf( command, 10240, format, list ) != 0 ) - response = valerie_parser_execute( parser, command ); - va_end( list ); - free( command ); - } - return response; -} - -/** Execute the contents of a file. Note the special case valerie_response returned. -*/ - -valerie_response valerie_parser_run( valerie_parser parser, char *filename ) -{ - valerie_response response = valerie_response_init( ); - if ( response != NULL ) - { - FILE *file = fopen( filename, "r" ); - if ( file != NULL ) - { - char command[ 1024 ]; - valerie_response_set_error( response, 201, "OK" ); - while ( valerie_response_get_error_code( response ) == 201 && fgets( command, 1024, file ) ) - { - valerie_util_trim( valerie_util_chomp( command ) ); - if ( strcmp( command, "" ) && command[ 0 ] != '#' ) - { - valerie_response temp = NULL; - valerie_response_printf( response, 1024, "%s\n", command ); - temp = valerie_parser_execute( parser, command ); - if ( temp != NULL ) - { - int index = 0; - for ( index = 0; index < valerie_response_count( temp ); index ++ ) - valerie_response_printf( response, 10240, "%s\n", valerie_response_get_line( temp, index ) ); - valerie_response_close( temp ); - } - else - { - valerie_response_set_error( response, 500, "Batch execution failed" ); - } - } - } - fclose( file ); - } - else - { - valerie_response_set_error( response, 404, "File not found." ); - } - } - return response; -} - -/** Get the notifier associated to the parser. -*/ - -valerie_notifier valerie_parser_get_notifier( valerie_parser parser ) -{ - if ( parser->notifier == NULL ) - parser->notifier = valerie_notifier_init( ); - return parser->notifier; -} - -/** Close the parser. -*/ - -void valerie_parser_close( valerie_parser parser ) -{ - if ( parser != NULL ) - { - parser->close( parser->real ); - valerie_notifier_close( parser->notifier ); - free( parser ); - } -} diff --git a/mlt/src/valerie/valerie_parser.h b/mlt/src/valerie/valerie_parser.h deleted file mode 100644 index 71446d9..0000000 --- a/mlt/src/valerie/valerie_parser.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * valerie_parser.h -- Valerie Parser for Miracle Server - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_PARSER_H_ -#define _VALERIE_PARSER_H_ - -/* Application header files */ -#include "valerie_response.h" -#include "valerie_notifier.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Callbacks to define the parser. -*/ - -typedef valerie_response (*parser_connect)( void * ); -typedef valerie_response (*parser_execute)( void *, char * ); -typedef void (*parser_close)( void * ); - -/** Structure for the valerie parser. -*/ - -typedef struct -{ - parser_connect connect; - parser_execute execute; - parser_close close; - void *real; - valerie_notifier notifier; -} -*valerie_parser, valerie_parser_t; - -/** API for the parser - note that no constructor is defined here. -*/ - -extern valerie_response valerie_parser_connect( valerie_parser ); -extern valerie_response valerie_parser_execute( valerie_parser, char * ); -extern valerie_response valerie_parser_executef( valerie_parser, char *, ... ); -extern valerie_response valerie_parser_run( valerie_parser, char * ); -extern valerie_notifier valerie_parser_get_notifier( valerie_parser ); -extern void valerie_parser_close( valerie_parser ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_remote.c b/mlt/src/valerie/valerie_remote.c deleted file mode 100644 index 4b5023e..0000000 --- a/mlt/src/valerie/valerie_remote.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * valerie_remote.c -- Remote Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include -#include -#include -#include -#include - -/* Application header files */ -#include "valerie_remote.h" -#include "valerie_socket.h" -#include "valerie_tokeniser.h" -#include "valerie_util.h" - -/** Private valerie_remote structure. -*/ - -typedef struct -{ - int terminated; - char *server; - int port; - valerie_socket socket; - valerie_socket status; - pthread_t thread; - valerie_parser parser; - pthread_mutex_t mutex; - int connected; -} -*valerie_remote, valerie_remote_t; - -/** Forward declarations. -*/ - -static valerie_response valerie_remote_connect( valerie_remote ); -static valerie_response valerie_remote_execute( valerie_remote, char * ); -static void valerie_remote_close( valerie_remote ); -static int valerie_remote_read_response( valerie_socket, valerie_response ); - -/** DV Parser constructor. -*/ - -valerie_parser valerie_parser_init_remote( char *server, int port ) -{ - valerie_parser parser = malloc( sizeof( valerie_parser_t ) ); - valerie_remote remote = malloc( sizeof( valerie_remote_t ) ); - - if ( parser != NULL ) - { - memset( parser, 0, sizeof( valerie_parser_t ) ); - - parser->connect = (parser_connect)valerie_remote_connect; - parser->execute = (parser_execute)valerie_remote_execute; - parser->close = (parser_close)valerie_remote_close; - parser->real = remote; - - if ( remote != NULL ) - { - memset( remote, 0, sizeof( valerie_remote_t ) ); - remote->parser = parser; - remote->server = strdup( server ); - remote->port = port; - pthread_mutex_init( &remote->mutex, NULL ); - } - } - return parser; -} - -/** Thread for receiving and distributing the status information. -*/ - -static void *valerie_remote_status_thread( void *arg ) -{ - valerie_remote remote = arg; - char temp[ 10240 ]; - int length = 0; - int offset = 0; - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - valerie_notifier notifier = valerie_parser_get_notifier( remote->parser ); - valerie_status_t status; - int index = 0; - - valerie_socket_write_data( remote->status, "STATUS\r\n", 8 ); - - while ( !remote->terminated && - ( length = valerie_socket_read_data( remote->status, temp + offset, sizeof( temp ) ) ) >= 0 ) - { - if ( strchr( temp, '\n' ) == NULL ) - { - offset = length; - continue; - } - offset = 0; - valerie_tokeniser_parse_new( tokeniser, temp, "\n" ); - for ( index = 0; index < valerie_tokeniser_count( tokeniser ); index ++ ) - { - char *line = valerie_tokeniser_get_string( tokeniser, index ); - if ( line[ strlen( line ) - 1 ] == '\r' ) - { - valerie_util_chomp( line ); - valerie_status_parse( &status, line ); - valerie_notifier_put( notifier, &status ); - } - else - { - strcpy( temp, line ); - offset = strlen( temp ); - } - } - } - - valerie_notifier_disconnected( notifier ); - valerie_tokeniser_close( tokeniser ); - remote->terminated = 1; - - return NULL; -} - -/** Forward reference. -*/ - -static void valerie_remote_disconnect( valerie_remote remote ); - -/** Connect to the server. -*/ - -static valerie_response valerie_remote_connect( valerie_remote remote ) -{ - valerie_response response = NULL; - - valerie_remote_disconnect( remote ); - - if ( !remote->connected ) - { - signal( SIGPIPE, SIG_IGN ); - - remote->socket = valerie_socket_init( remote->server, remote->port ); - remote->status = valerie_socket_init( remote->server, remote->port ); - - if ( valerie_socket_connect( remote->socket ) == 0 ) - { - response = valerie_response_init( ); - valerie_remote_read_response( remote->socket, response ); - } - - if ( response != NULL && valerie_socket_connect( remote->status ) == 0 ) - { - valerie_response status_response = valerie_response_init( ); - valerie_remote_read_response( remote->status, status_response ); - if ( valerie_response_get_error_code( status_response ) == 100 ) - pthread_create( &remote->thread, NULL, valerie_remote_status_thread, remote ); - valerie_response_close( status_response ); - remote->connected = 1; - } - } - - return response; -} - -/** Execute the command. -*/ - -static valerie_response valerie_remote_execute( valerie_remote remote, char *command ) -{ - valerie_response response = NULL; - pthread_mutex_lock( &remote->mutex ); - if ( valerie_socket_write_data( remote->socket, command, strlen( command ) ) == strlen( command ) ) - { - response = valerie_response_init( ); - valerie_socket_write_data( remote->socket, "\r\n", 2 ); - valerie_remote_read_response( remote->socket, response ); - } - pthread_mutex_unlock( &remote->mutex ); - return response; -} - -/** Disconnect. -*/ - -static void valerie_remote_disconnect( valerie_remote remote ) -{ - if ( remote != NULL && remote->terminated ) - { - pthread_join( remote->thread, NULL ); - valerie_socket_close( remote->status ); - valerie_socket_close( remote->socket ); - remote->connected = 0; - remote->terminated = 0; - } -} - -/** Close the parser. -*/ - -static void valerie_remote_close( valerie_remote remote ) -{ - if ( remote != NULL ) - { - remote->terminated = 1; - valerie_remote_disconnect( remote ); - pthread_mutex_destroy( &remote->mutex ); - free( remote->server ); - free( remote ); - } -} - -/** Read response. -*/ - -static int valerie_remote_read_response( valerie_socket socket, valerie_response response ) -{ - char temp[ 10240 ]; - int length; - int terminated = 0; - - while ( !terminated && ( length = valerie_socket_read_data( socket, temp, 10240 ) ) >= 0 ) - { - int position = 0; - temp[ length ] = '\0'; - valerie_response_write( response, temp, length ); - position = valerie_response_count( response ) - 1; - if ( position < 0 || temp[ strlen( temp ) - 1 ] != '\n' ) - continue; - switch( valerie_response_get_error_code( response ) ) - { - case 201: - case 500: - terminated = !strcmp( valerie_response_get_line( response, position ), "" ); - break; - case 202: - terminated = valerie_response_count( response ) >= 2; - break; - default: - terminated = 1; - break; - } - } - - return 0; -} diff --git a/mlt/src/valerie/valerie_remote.h b/mlt/src/valerie/valerie_remote.h deleted file mode 100644 index 291184a..0000000 --- a/mlt/src/valerie/valerie_remote.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * valerie_remote.h -- Remote Parser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_REMOTE_H_ -#define _VALERIE_REMOTE_H_ - -/* Application header files */ -#include "valerie_parser.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Remote parser API. -*/ - -extern valerie_parser valerie_parser_init_remote( char *, int ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_response.c b/mlt/src/valerie/valerie_response.c deleted file mode 100644 index 5b9491c..0000000 --- a/mlt/src/valerie/valerie_response.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * valerie_response.c -- Response - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include -#include -#include - -/* Application header files */ -#include "valerie_response.h" - -/** Construct a new dv response. -*/ - -valerie_response valerie_response_init( ) -{ - valerie_response response = malloc( sizeof( valerie_response_t ) ); - if ( response != NULL ) - memset( response, 0, sizeof( valerie_response_t ) ); - return response; -} - -/** Clone a dv response -*/ - -valerie_response valerie_response_clone( valerie_response response ) -{ - valerie_response clone = valerie_response_init( ); - if ( clone != NULL && response != NULL ) - { - int index = 0; - for ( index = 0; index < valerie_response_count( response ); index ++ ) - { - char *line = valerie_response_get_line( response, index ); - valerie_response_printf( clone, strlen( line ) + 2, "%s\n", line ); - } - } - return clone; -} - -/** Get the error code associated to the response. -*/ - -int valerie_response_get_error_code( valerie_response response ) -{ - int error_code = -1; - if ( response != NULL ) - { - if ( response->count > 0 ) - { - if ( sscanf( response->array[ 0 ], "%d", &error_code ) != 1 ) - error_code = 0; - } - else - { - error_code = -2; - } - } - return error_code; -} - -/** Get the error description associated to the response. -*/ - -char *valerie_response_get_error_string( valerie_response response ) -{ - char *error_string = "No message specified"; - if ( response->count > 0 ) - { - char *ptr = strchr( response->array[ 0 ], ' ' ) ; - if ( ptr != NULL ) - error_string = ptr + 1; - } - return error_string; -} - -/** Get a line of text at the given index. Note that the text itself is - terminated only with a NUL char and it is the responsibility of the - the user of the returned data to use a LF or CR/LF as appropriate. -*/ - -char *valerie_response_get_line( valerie_response response, int index ) -{ - if ( index < response->count ) - return response->array[ index ]; - else - return NULL; -} - -/** Return the number of lines of text in the response. -*/ - -int valerie_response_count( valerie_response response ) -{ - if ( response != NULL ) - return response->count; - else - return 0; -} - -/** Set the error and description associated to the response. -*/ - -void valerie_response_set_error( valerie_response response, int error_code, char *error_string ) -{ - if ( response->count == 0 ) - { - valerie_response_printf( response, 10240, "%d %s\n", error_code, error_string ); - } - else - { - char temp[ 10240 ]; - int length = sprintf( temp, "%d %s", error_code, error_string ); - response->array[ 0 ] = realloc( response->array[ 0 ], length + 1 ); - strcpy( response->array[ 0 ], temp ); - } -} - -/** Write formatted text to the response. -*/ - -int valerie_response_printf( valerie_response response, size_t size, char *format, ... ) -{ - int length = 0; - char *text = malloc( size ); - if ( text != NULL ) - { - va_list list; - va_start( list, format ); - length = vsnprintf( text, size, format, list ); - if ( length != 0 ) - valerie_response_write( response, text, length ); - va_end( list ); - free( text ); - } - return length; -} - -/** Write text to the reponse. -*/ - -int valerie_response_write( valerie_response response, char *text, int size ) -{ - int ret = 0; - char *ptr = text; - - while ( size > 0 ) - { - int index = response->count - 1; - char *lf = strchr( ptr, '\n' ); - int length_of_string = 0; - - /* Make sure we have space in the dynamic array. */ - if ( !response->append && response->count >= response->size - 1 ) - { - response->size += 50; - response->array = realloc( response->array, response->size * sizeof( char * ) ); - } - - /* Make sure the array is valid, or we're really in trouble */ - if ( response->array == NULL ) - { - ret = 0; - break; - } - - /* Now, if we're appending to the previous write (ie: if it wasn't - terminated by a LF), then use the index calculated above, otherwise - go to the next one and ensure it's NULLed. */ - - if ( !response->append ) - { - response->array[ ++ index ] = NULL; - response->count ++; - } - else - { - length_of_string = strlen( response->array[ index ] ); - } - - /* Now we need to know how to handle the current ptr with respect to lf. */ - /* TODO: tidy up and error check... sigh... tested for many, many 1000s of lines */ - - if ( lf == NULL ) - { - response->array[ index ] = realloc( response->array[ index ], length_of_string + size + 1 ); - memcpy( response->array[ index ] + length_of_string, ptr, size ); - response->array[ index ][ length_of_string + size ] = '\0'; - if ( ( length_of_string + size ) > 0 && response->array[ index ][ length_of_string + size - 1 ] == '\r' ) - response->array[ index ][ length_of_string + size - 1 ] = '\0'; - size = 0; - ret += size; - response->append = 1; - } - else - { - int chars = lf - ptr; - response->array[ index ] = realloc( response->array[ index ], length_of_string + chars + 1 ); - memcpy( response->array[ index ] + length_of_string, ptr, chars ); - response->array[ index ][ length_of_string + chars ] = '\0'; - if ( ( length_of_string + chars ) > 0 && response->array[ index ][ length_of_string + chars - 1 ] == '\r' ) - response->array[ index ][ length_of_string + chars - 1 ] = '\0'; - ptr = ptr + chars + 1; - size -= ( chars + 1 ); - response->append = 0; - ret += chars + 1; - } - } - - return ret; -} - -/** Close the response. -*/ - -void valerie_response_close( valerie_response response ) -{ - if ( response != NULL ) - { - int index = 0; - for ( index = 0; index < response->count; index ++ ) - free( response->array[ index ] ); - free( response->array ); - free( response ); - } -} diff --git a/mlt/src/valerie/valerie_response.h b/mlt/src/valerie/valerie_response.h deleted file mode 100644 index 1e8f1fa..0000000 --- a/mlt/src/valerie/valerie_response.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * valerie_response.h -- Response - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_RESPONSE_H_ -#define _VALERIE_RESPONSE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Structure for the response -*/ - -typedef struct -{ - char **array; - int size; - int count; - int append; -} -*valerie_response, valerie_response_t; - -/** API for accessing the response structure. -*/ - -extern valerie_response valerie_response_init( ); -extern valerie_response valerie_response_clone( valerie_response ); -extern int valerie_response_get_error_code( valerie_response ); -extern char *valerie_response_get_error_string( valerie_response ); -extern char *valerie_response_get_line( valerie_response, int ); -extern int valerie_response_count( valerie_response ); -extern void valerie_response_set_error( valerie_response, int, char * ); -extern int valerie_response_printf( valerie_response, size_t, char *, ... ); -extern int valerie_response_write( valerie_response, char *, int ); -extern void valerie_response_close( valerie_response ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_socket.c b/mlt/src/valerie/valerie_socket.c deleted file mode 100644 index 74e8483..0000000 --- a/mlt/src/valerie/valerie_socket.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * valerie_socket.c -- Client Socket - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* System header files */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Application header files */ -#include "valerie_socket.h" - -/** Initialise the socket. -*/ - -valerie_socket valerie_socket_init( char *server, int port ) -{ - valerie_socket socket = malloc( sizeof( valerie_socket_t ) ); - if ( socket != NULL ) - { - memset( socket, 0, sizeof( valerie_socket_t ) ); - socket->fd = -1; - socket->server = strdup( server ); - socket->port = port; - } - return socket; -} - -/** Connect to the server. -*/ - -int valerie_socket_connect( valerie_socket connection ) -{ - int ret = 0; - struct hostent *host; - struct sockaddr_in sock; - - if ( connection->server != NULL ) - { - host = gethostbyname( connection->server ); - - memset( &sock, 0, sizeof( struct sockaddr_in ) ); - memcpy( &sock.sin_addr, host->h_addr, host->h_length ); - sock.sin_family = host->h_addrtype; - sock.sin_port = htons( connection->port ); - - if ( ( connection->fd = socket( AF_INET, SOCK_STREAM, 0 ) ) != -1 ) - ret = connect( connection->fd, (const struct sockaddr *)&sock, sizeof( struct sockaddr_in ) ); - else - ret = -1; - } - - return ret; -} - -/** Convenience constructor for a connected file descriptor. -*/ - -valerie_socket valerie_socket_init_fd( int fd ) -{ - valerie_socket socket = malloc( sizeof( valerie_socket_t ) ); - if ( socket != NULL ) - { - memset( socket, 0, sizeof( valerie_socket_t ) ); - socket->fd = fd; - socket->no_close = 1; - } - return socket; -} - -/** Read an arbitrarily formatted block of data from the server. -*/ - -int valerie_socket_read_data( valerie_socket socket, char *data, int length ) -{ - struct timeval tv = { 1, 0 }; - fd_set rfds; - int used = 0; - - data[ 0 ] = '\0'; - - FD_ZERO( &rfds ); - FD_SET( socket->fd, &rfds ); - - if ( select( socket->fd + 1, &rfds, NULL, NULL, &tv ) ) - { - used = read( socket->fd, data, length - 1 ); - if ( used > 0 ) - data[ used ] = '\0'; - else - used = -1; - } - - return used; -} - -/** Write an arbitrarily formatted block of data to the server. -*/ - -int valerie_socket_write_data( valerie_socket socket, char *data, int length ) -{ - int used = 0; - - while ( used >=0 && used < length ) - { - struct timeval tv = { 1, 0 }; - fd_set rfds; - fd_set wfds; - fd_set efds; - - FD_ZERO( &rfds ); - FD_SET( socket->fd, &rfds ); - FD_ZERO( &wfds ); - FD_SET( socket->fd, &wfds ); - FD_ZERO( &efds ); - FD_SET( socket->fd, &efds ); - - errno = 0; - - if ( select( socket->fd + 1, &rfds, &wfds, &efds, &tv ) ) - { - if ( errno != 0 || FD_ISSET( socket->fd, &efds ) || FD_ISSET( socket->fd, &rfds ) ) - { - used = -1; - } - else if ( FD_ISSET( socket->fd, &wfds ) ) - { - int inc = write( socket->fd, data + used, length - used ); - if ( inc > 0 ) - used += inc; - else - used = -1; - } - } - } - - return used; -} - -/** Close the socket. -*/ - -void valerie_socket_close( valerie_socket socket ) -{ - if ( socket->fd > 0 && !socket->no_close ) - close( socket->fd ); - free( socket->server ); - free( socket ); -} diff --git a/mlt/src/valerie/valerie_socket.h b/mlt/src/valerie/valerie_socket.h deleted file mode 100644 index f016ca1..0000000 --- a/mlt/src/valerie/valerie_socket.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * valerie_socket.h -- Client Socket - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _VALERIE_SOCKET_H_ -#define _VALERIE_SOCKET_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Structure for socket. -*/ - -typedef struct -{ - char *server; - int port; - int fd; - int no_close; -} -*valerie_socket, valerie_socket_t; - -/** Remote parser API. -*/ - -extern valerie_socket valerie_socket_init( char *, int ); -extern int valerie_socket_connect( valerie_socket ); -extern valerie_socket valerie_socket_init_fd( int ); -extern int valerie_socket_read_data( valerie_socket, char *, int ); -extern int valerie_socket_write_data( valerie_socket, char *, int ); -extern void valerie_socket_close( valerie_socket ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_status.c b/mlt/src/valerie/valerie_status.c deleted file mode 100644 index 5e4cbd2..0000000 --- a/mlt/src/valerie/valerie_status.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * valerie_status.c -- Unit Status Handling - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include -#include - -/* Application header files */ -#include "valerie_status.h" -#include "valerie_tokeniser.h" -#include "valerie_util.h" - -/** Parse a unit status string. -*/ - -void valerie_status_parse( valerie_status status, char *text ) -{ - valerie_tokeniser tokeniser = valerie_tokeniser_init( ); - if ( valerie_tokeniser_parse_new( tokeniser, text, " " ) == 17 ) - { - status->unit = atoi( valerie_tokeniser_get_string( tokeniser, 0 ) ); - strncpy( status->clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 2 ), '\"' ), sizeof( status->clip ) ); - status->position = atol( valerie_tokeniser_get_string( tokeniser, 3 ) ); - status->speed = atoi( valerie_tokeniser_get_string( tokeniser, 4 ) ); - status->fps = atof( valerie_tokeniser_get_string( tokeniser, 5 ) ); - status->in = atol( valerie_tokeniser_get_string( tokeniser, 6 ) ); - status->out = atol( valerie_tokeniser_get_string( tokeniser, 7 ) ); - status->length = atol( valerie_tokeniser_get_string( tokeniser, 8 ) ); - - strncpy( status->tail_clip, valerie_util_strip( valerie_tokeniser_get_string( tokeniser, 9 ), '\"' ), sizeof( status->tail_clip ) ); - status->tail_position = atol( valerie_tokeniser_get_string( tokeniser, 10 ) ); - status->tail_in = atol( valerie_tokeniser_get_string( tokeniser, 11 ) ); - status->tail_out = atol( valerie_tokeniser_get_string( tokeniser, 12 ) ); - status->tail_length = atol( valerie_tokeniser_get_string( tokeniser, 13 ) ); - status->seek_flag = atoi( valerie_tokeniser_get_string( tokeniser, 14 ) ); - status->generation = atoi( valerie_tokeniser_get_string( tokeniser, 15 ) ); - status->clip_index = atoi( valerie_tokeniser_get_string( tokeniser, 16 ) ); - - if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "unknown" ) ) - status->status = unit_unknown; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "undefined" ) ) - status->status = unit_undefined; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "offline" ) ) - status->status = unit_offline; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "not_loaded" ) ) - status->status = unit_not_loaded; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "stopped" ) ) - status->status = unit_stopped; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "paused" ) ) - status->status = unit_paused; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "playing" ) ) - status->status = unit_playing; - else if ( !strcmp( valerie_tokeniser_get_string( tokeniser, 1 ), "disconnected" ) ) - status->status = unit_disconnected; - } - else - { - memset( status, 0, sizeof( valerie_status_t ) ); - fprintf( stderr, "Status thread changed?\n" ); - } - valerie_tokeniser_close( tokeniser ); -} - -/** Serialise a status into a string. -*/ - -char *valerie_status_serialise( valerie_status status, char *text, int length ) -{ - char *status_string = NULL; - - switch( status->status ) - { - case unit_undefined: - status_string = "undefined"; - break; - - case unit_offline: - status_string = "offline"; - break; - - case unit_not_loaded: - status_string = "not_loaded"; - break; - - case unit_stopped: - status_string = "stopped"; - break; - - case unit_playing: - status_string = "playing"; - break; - - case unit_unknown: - status_string = "unknown"; - break; - - case unit_paused: - status_string = "paused"; - break; - - case unit_disconnected: - status_string = "disconnected"; - break; - } - - snprintf( text, length, "%d %s \"%s\" %lld %d %.2f %lld %lld %lld \"%s\" %lld %lld %lld %lld %d %d %d\r\n", - status->unit, - status_string, - status->clip, - status->position, - status->speed, - status->fps, - status->in, - status->out, - status->length, - status->tail_clip, - status->tail_position, - status->tail_in, - status->tail_out, - status->tail_length, - status->seek_flag, - status->generation, - status->clip_index ); - - return text; -} - -/** Compare two status codes for changes. -*/ - -int valerie_status_compare( valerie_status status1, valerie_status status2 ) -{ - return memcmp( status1, status2, sizeof( valerie_status_t ) ); -} - -/** Copy status code info from dest to src. -*/ - -valerie_status valerie_status_copy( valerie_status dest, valerie_status src ) -{ - return memcpy( dest, src, sizeof( valerie_status_t ) ); -} diff --git a/mlt/src/valerie/valerie_status.h b/mlt/src/valerie/valerie_status.h deleted file mode 100644 index 5da7497..0000000 --- a/mlt/src/valerie/valerie_status.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * valerie_status.h -- Unit Status Handling - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_STATUS_H_ -#define _VALERIE_STATUS_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Status codes -*/ - -typedef enum -{ - unit_unknown = 0, - unit_undefined, - unit_offline, - unit_not_loaded, - unit_stopped, - unit_playing, - unit_paused, - unit_disconnected -} -unit_status; - -/** Status structure. -*/ - -typedef struct -{ - int unit; - unit_status status; - char clip[ 2048 ]; - int64_t position; - int speed; - double fps; - int64_t in; - int64_t out; - int64_t length; - char tail_clip[ 2048 ]; - int64_t tail_position; - int64_t tail_in; - int64_t tail_out; - int64_t tail_length; - int seek_flag; - int generation; - int clip_index; - int dummy; -} -*valerie_status, valerie_status_t; - -/** DV1394 Status API -*/ - -extern void valerie_status_parse( valerie_status, char * ); -extern char *valerie_status_serialise( valerie_status, char *, int ); -extern int valerie_status_compare( valerie_status, valerie_status ); -extern valerie_status valerie_status_copy( valerie_status, valerie_status ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_tokeniser.c b/mlt/src/valerie/valerie_tokeniser.c deleted file mode 100644 index 7acaf85..0000000 --- a/mlt/src/valerie/valerie_tokeniser.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * valerie_tokeniser.c -- String tokeniser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include - -/* Application header files */ -#include "valerie_tokeniser.h" - -/** Initialise a tokeniser. -*/ - -valerie_tokeniser valerie_tokeniser_init( ) -{ - valerie_tokeniser tokeniser = malloc( sizeof( valerie_tokeniser_t ) ); - if ( tokeniser != NULL ) - memset( tokeniser, 0, sizeof( valerie_tokeniser_t ) ); - return tokeniser; -} - -/** Clear the tokeniser. -*/ - -static void valerie_tokeniser_clear( valerie_tokeniser tokeniser ) -{ - int index = 0; - for ( index = 0; index < tokeniser->count; index ++ ) - free( tokeniser->tokens[ index ] ); - tokeniser->count = 0; - free( tokeniser->input ); - tokeniser->input = NULL; -} - -/** Append a string to the tokeniser. -*/ - -static int valerie_tokeniser_append( valerie_tokeniser tokeniser, char *token ) -{ - int error = 0; - - if ( tokeniser->count == tokeniser->size ) - { - tokeniser->size += 20; - tokeniser->tokens = realloc( tokeniser->tokens, tokeniser->size * sizeof( char * ) ); - } - - if ( tokeniser->tokens != NULL ) - { - tokeniser->tokens[ tokeniser->count ++ ] = strdup( token ); - } - else - { - tokeniser->count = 0; - error = -1; - } - return error; -} - -/** Parse a string by splitting on the delimiter provided. -*/ - -int valerie_tokeniser_parse_new( valerie_tokeniser tokeniser, char *string, char *delimiter ) -{ - int count = 0; - int length = strlen( string ); - int delimiter_size = strlen( delimiter ); - int index = 0; - char *token = strdup( string ); - - valerie_tokeniser_clear( tokeniser ); - tokeniser->input = strdup( string ); - strcpy( token, "" ); - - for ( index = 0; index < length; ) - { - char *start = string + index; - char *end = strstr( start, delimiter ); - - if ( end == NULL ) - { - strcat( token, start ); - valerie_tokeniser_append( tokeniser, token ); - index = length; - count ++; - } - else if ( start != end ) - { - strncat( token, start, end - start ); - index += end - start; - if ( token[ 0 ] != '\"' || ( token[ 0 ] == '\"' && token[ strlen( token ) - 1 ] == '\"' ) ) - { - valerie_tokeniser_append( tokeniser, token ); - strcpy( token, "" ); - count ++; - } - else while ( strncmp( string + index, delimiter, delimiter_size ) == 0 ) - { - strncat( token, delimiter, delimiter_size ); - index += delimiter_size; - } - } - else - { - index += strlen( delimiter ); - } - } - - /* Special case - malformed string condition */ - if ( !strcmp( token, "" ) ) - { - count = 0 - ( count - 1 ); - valerie_tokeniser_append( tokeniser, token ); - } - - free( token ); - return count; -} - -/** Get the original input. -*/ - -char *valerie_tokeniser_get_input( valerie_tokeniser tokeniser ) -{ - return tokeniser->input; -} - -/** Get the number of tokens. -*/ - -int valerie_tokeniser_count( valerie_tokeniser tokeniser ) -{ - return tokeniser->count; -} - -/** Get a token as a string. -*/ - -char *valerie_tokeniser_get_string( valerie_tokeniser tokeniser, int index ) -{ - if ( index < tokeniser->count ) - return tokeniser->tokens[ index ]; - else - return NULL; -} - -/** Close the tokeniser. -*/ - -void valerie_tokeniser_close( valerie_tokeniser tokeniser ) -{ - valerie_tokeniser_clear( tokeniser ); - free( tokeniser->tokens ); - free( tokeniser ); -} diff --git a/mlt/src/valerie/valerie_tokeniser.h b/mlt/src/valerie/valerie_tokeniser.h deleted file mode 100644 index 9d0838c..0000000 --- a/mlt/src/valerie/valerie_tokeniser.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * valerie_tokeniser.h -- String tokeniser - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_TOKENISER_H_ -#define _VALERIE_TOKENISER_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** Structure for tokeniser. -*/ - -typedef struct -{ - char *input; - char **tokens; - int count; - int size; -} -*valerie_tokeniser, valerie_tokeniser_t; - -/** Remote parser API. -*/ - -extern valerie_tokeniser valerie_tokeniser_init( ); -extern int valerie_tokeniser_parse_new( valerie_tokeniser, char *, char * ); -extern char *valerie_tokeniser_get_input( valerie_tokeniser ); -extern int valerie_tokeniser_count( valerie_tokeniser ); -extern char *valerie_tokeniser_get_string( valerie_tokeniser, int ); -extern void valerie_tokeniser_close( valerie_tokeniser ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/mlt/src/valerie/valerie_util.c b/mlt/src/valerie/valerie_util.c deleted file mode 100644 index 168f6a7..0000000 --- a/mlt/src/valerie/valerie_util.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * valerie_util.c -- General Purpose Client Utilities - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* System header files */ -#include -#include - -/* Application header files */ -#include "valerie_util.h" - -/** Remove LF or CR/LF terminations from the input string. -*/ - -char *valerie_util_chomp( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - if ( length && input[ length - 1 ] == '\n' ) - input[ length - 1 ] = '\0'; - if ( length > 1 && input[ length - 2 ] == '\r' ) - input[ length - 2 ] = '\0'; - } - return input; -} - -/** Remove leading and trailing spaces from the input string. -*/ - -char *valerie_util_trim( char *input ) -{ - if ( input != NULL ) - { - int length = strlen( input ); - int first = 0; - while( first < length && isspace( input[ first ] ) ) - first ++; - memmove( input, input + first, length - first + 1 ); - length = length - first; - while ( length > 0 && isspace( input[ length - 1 ] ) ) - input[ -- length ] = '\0'; - } - return input; -} - -/** Strip the specified string of leading and trailing 'value' (ie: "). -*/ - -char *valerie_util_strip( char *input, char value ) -{ - if ( input != NULL ) - { - char *ptr = strrchr( input, value ); - if ( ptr != NULL ) - *ptr = '\0'; - if ( input[ 0 ] == value ) - strcpy( input, input + 1 ); - } - return input; -} diff --git a/mlt/src/valerie/valerie_util.h b/mlt/src/valerie/valerie_util.h deleted file mode 100644 index 492eba0..0000000 --- a/mlt/src/valerie/valerie_util.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * valerie_util.h -- General Purpose Client Utilities - * Copyright (C) 2002-2003 Ushodaya Enterprises Limited - * Author: Charles Yates - * - * This library 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.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _VALERIE_UTIL_H_ -#define _VALERIE_UTIL_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern char *valerie_util_chomp( char * ); -extern char *valerie_util_trim( char * ); -extern char *valerie_util_strip( char *, char ); - -#ifdef __cplusplus -} -#endif - -#endif