+++ /dev/null
-Miracle Control Protocol (DVCP) Reference Documentation
-
-Copyright (C) 2004 Ushodaya Enterprised Limited
-Author: Dan Dennedy <dan@dennedy.org>
-Last Revision: 2004-03-20
-
-
-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 an 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.
-
-WIPE {unit}
- Removes all clips before 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 the connection to the client.
- - 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."
-
-
-
-
+++ /dev/null
-On 1/10/2004, Dan Dennedy ran the 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
-
-
-Incorrect Behaviour
-------------------------------------------------------------------------------
-
-
-Different Intentional Behaviour
-------------------------------------------------------------------------------
-
-Different forced Behaviour
-------------------------------------------------------------------------------
-killall miracle does not work when the SDL consumer is in use. requires killall -HUP
-
-MLT Bugs
-------------------------------------------------------------------------------
-Please check the services.txt doc for known bugs related to MLT components.
-
-
-
+++ /dev/null
-Miracle Test Procedure
-
-Copyright (C) 2003 Ushodaya Enterprised Limited
-Author: Dan Dennedy <dan@dennedy.org>
-Last Revision: 2004-03-20
-
-
-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}
---> 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 List the units: ULS
---> 201 OK
---> U0 ?? {sdl, bluefish} 1
-
-2.5 Attempt unit commands for a unit that does not exist: LOAD U6 foo
---> 403 Unit not found
-
-2.6 Attempt unit commands without specifying a unit: PLAY
---> 402 Argument missing
-
-2.7 Attempt unit commands for a unit: PLAY U0
---> 200 OK
-
-2.8.0 Load a clip into an unit: LOAD U0 test.dv
---> 200 OK
-
-2.7.1 Verify the status of the unit: USTA U0
---> 202 OK
---> 0 online "test.dv" 0 1000 25.00 0 ...
---> only the first 3 columns are relevant in this test
-
-
-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
+++ /dev/null
-Valerie API Documentation
-
-Copyright (C) 2004 Ushodaya Enterprised Limited
-Author: Charles Yates <charles.yates@pandora.be>
-Last Revision: 2004-03-20
-
-
-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 <miracle/miracle_local.h>
-
- 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 <valerie/valerie_remote.h>
-
- 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 <valerie/valerie.h>
-
- 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/rugen
-
- 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 <prefix>/include
-
- where prefix defaults to /usr/local.
-
- Linking flags for a client are:
-
- -L <prefix>/lib/ -lvalerie
-
- Or for a local parser:
-
- -L <prefix>/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
+++ /dev/null
-MLT++ was developed by:
-Charles Yates <charles.yates@pandora.be>
-
-MLT++ is maintained by:
-Dan Dennedy <dan@dennedy.org>
+++ /dev/null
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-\f
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-\f
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-\f
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-\f
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-\f
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-\f
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-\f
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-\f
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-\f
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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 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
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
+++ /dev/null
-Server Customisation
-
-Copyright (C) 2005 Ushodaya Enterprises Limited
-Authors: Charles Yates <charles.yates@pandora.be>
-Last Revision: 2005-03-16
-
-
-INTRODUCTION
-
- This document describes how miracle can be customised. The emphasis is on
- showing simple examples of various aspects of the servers capabilities
- rather than on focussing on the MLT++ API.
-
-
-THE BASIC CUSTOM SERVER
-
- The most basic custom server exposes the entire DVCP protocol and is roughly
- equivalent to the miracle server iteself, but in this case, it lacks the
- initialisation from /etc/miracle.conf and the port is hardcoded to 5290:
-
- #include <iostream.h>
- using namespace std;
-
- #include <MltMiracle.h>
- using namespace Mlt;
-
- int main( int argc, char **argv )
- {
- Miracle server( "miracle++", 5290 );
- if ( server.start( ) )
- {
- server.execute( "uadd sdl" );
- server.execute( "play u0" );
- server.wait_for_shutdown( );
- }
- else
- {
- cerr << "Failed to start server" << endl;
- }
- return 0;
- }
-
- Note that after the server is started, this example submits the hard coded
- commands specified - further units and property settings can of course be
- specified via the DVCP protocol.
-
- To specify initial DVCP commands from /etc/miracle.conf, it is sufficient to
- specify an additional argument in the server constructor.
-
- The wait_for_shutdown call is not required if the server is integrated in
- a user interface application.
-
-
-CUSTOMISATION
-
- This document focusses on the following areas of customisation:
-
- * the Miracle server class
- * extending the command set
- * accessing the units
- * the Response object
- * handling pushed westley documents
- * accessiving events
-
-
-THE MIRACLE SERVER CLASS
-
- The full public interface of the server is as follows:
-
- class Miracle : public Properties
- {
- public:
- Miracle( char *name, int port = 5290, char *config = NULL );
- virtual ~Miracle( );
- mlt_properties get_properties( );
- bool start( );
- bool is_running( );
- virtual Response *execute( char *command );
- virtual Response *received( char *command, char *doc );
- virtual Response *push( char *command, Service *service );
- void wait_for_shutdown( );
- static void log_level( int );
- Properties *unit( int );
- };
-
- The focus of this document is on the 3 virtual methods (execute, received and
- push). Some further information is provided about the unit properties method
- and the types of functionality that it provides.
-
-
-EXTENDING THE COMMAND SET
-
- The simplest customisation is carried out by overriding the the 'execute'
- method - the following shows a simple example:
-
- #include <iostream.h>
- #include <string>
- #include <sstring>
- using namespace std;
-
- #include <MltMiracle.h>
- #include <MltResponse.h>
- using namespace Mlt;
-
- class Custom :
- public Miracle
- {
- public:
- Custom( char *name = "Custom", int port = 5290, char *config = NULL ) :
- Miracle( name, port, config )
- {
- }
-
- Response *execute( char *command )
- {
- cerr << "command = " << command << endl;
- return Miracle::execute( command );
- }
- };
-
- int main( int argc, char **argv )
- {
- Custom server( "miracle++", 5290 );
- if ( server.start( ) )
- {
- server.execute( "uadd sdl" );
- server.execute( "play u0" );
- server.wait_for_shutdown( );
- }
- else
- {
- cerr << "Failed to start server" << endl;
- }
- return 0;
- }
-
- All this does is output each command and pass control over to the original
- implementation.
-
- When you execute this, you will see the following output:
-
- (5) Starting server on 5290.
- command = uadd sdl
- (5) miracle++ version 0.0.1 listening on port 5290
- command = play u0
- (7) Received signal 2 - shutting down.
-
- Note that all commands except the PUSH are passed through this method before
- they are executed and this includes those coming from the main function itself.
-
-
-ACCESSING UNIT PROPERTIES
-
- A unit consists of two objects - a playlist and a consumer. Your custom
- server can access these by obtaining the Properties object associated to a unit
- via the 'unit' method.
-
- As a simple example we can replace our execute method above with the following:
-
- Response *execute( char *command )
- {
- if ( !strcmp( command, "debug" ) )
- {
- int i = 0;
- while( unit( i ) != NULL )
- unit( i ++ )->debug( );
- return new Response( 200, "Diagnostics output" );
- }
- return Miracle::execute( command );
- }
-
- When this runs and you send a 'debug' command via DVCP, the server will output
- some information on stderr, like:
-
- (5) Starting server on 5290.
- (5) Server version 0.0.1 listening on port 5290
- (5) Connection established with localhost (7)
- Object: [ ref=3, unit=0, generation=0, constructor=sdl, id=sdl, arg=(nil),
- consumer=0x80716a0, playlist=0x807f8a8, root=/, notifier=0x8087c28 ]
- (6) localhost "debug" 100
-
- You can extract the objects using:
-
- Playlist playlist( ( mlt_playlist )( unit( i )->get_data( "playlist" ) ) );
- Consumer consumer( ( mlt_consumer )( unit( i )->get_data( "consumer" ) ) );
-
- and use the standard MLT++ wrapping methods to interact with them or you can
- bypass these and using the C API directly.
-
- Obviously, this opens a lot of possibilities for the types of editing operations
- than can be carried out over the DVCP protocol - for example, you can attach filters
- apply mixes/transitions between neighbouring cuts or carry out specific operations
- on cuts.
-
-
-THE RESPONSE OBJECT
-
- The example above doesn't do anything particularly useful - in order to extend
- things in more interesting ways, we should be able to carry information back to
- the client. In the code above, we introduced the Response object to carry an
- error code and a description - it can also be used to carry arbitrary large
- blocks of data.
-
- Response *execute( char *command )
- {
- Response *response = NULL;
- if ( !strcmp( command, "debug" ) )
- {
- response = new Response( 200, "Diagnostics output" );
- for( int i = 0; unit( i ) != NULL; i ++ )
- {
- Properties *properties = unit( i );
- stringstream output;
- output << string( "Unit " ) << i << endl;
- for ( int j = 0; j < properties->count( ); j ++ )
- output << properties->get_name( j ) << " = " << properties->get( j ) << endl;
- response->write( output.str( ).c_str( ) );
- }
- }
- return response == NULL ? Miracle::execute( command ) : response;
- }
-
- Now when you connect to the server via a telnet session, you can access the
- 'debug' command as follows:
-
- $ telnet localhost 5290
- Trying 127.0.0.1...
- Connected to localhost (127.0.0.1).
- Escape character is '^]'.
- 100 VTR Ready
- debug
- 201 OK
- Unit 0
- unit = 0
- generation = 0
- constructor = sdl
- id = sdl
- arg =
-
- Note that the '200' return code specified is automatically promoted to a 201
- because of the multiple lines.
-
- Alternatively, you can invoke response->write as many times as you like - each
- string submitted is simply appended to the object in a similar way to writing
- to a file or socket. Note that the client doesn't receive anything until the
- response is returned from this method (ie: there's currently no support to
- stream results back to the client).
-
-
-HANDLING PUSHED DOCUMENTS
-
- The custom class receives PUSH'd westley either via the received or push
- method.
-
- The default handling is to simply append a pushed document on to the end of
- first unit 0.
-
- You can test this in the server defined above from the command line, for
- example:
-
- $ inigo noise: -consumer valerie:localhost:5290
-
- By default, the 'push' method is used - this means that the xml document
- received is automatically deserialised by the server itself and then offered
- to the push method for handling - an example of this would be:
-
- Response *push( char *command, Service *service )
- {
- Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
- Producer producer( *service );
- if ( producer.is_valid( ) && playlist.is_valid( ) )
- {
- playlist.lock( );
- playlist.clear( );
- playlist.append( producer );
- playlist.unlock( );
- return new Response( 200, "OK" );
- }
- return new Response( 400, "Invalid" );
- }
-
- With this method, each service pushed into the server will automatically
- replace whatever is currently playing.
-
- Note that the 'received' method is not invoked by default - if you wish to
- receive the XML document and carry out any additional processing prior to
- processing, you should set the 'push-parser-off' property on the server to 1.
- This can be done by placing the following line in your classes constructor:
-
- set( "push-parser-off", 1 );
-
- When this property is set, the received method is used instead of the push -
- in this scenario, your implementation is responsible for all handling
- of the document.
-
- To simulate this, you can try the following method:
-
- Response *received( char *command, char *document )
- {
- cerr << document;
- Producer producer( "westley-xml", document );
- return push( command, &producer );
- }
-
- When you push your videos in to the server via the inigo command above (or
- from other tools, such as those in the shotcut suite), you will see the xml
- in the servers stderr output. If you need to carry out some operations on the
- xml document (such as replacing low quality videos used in the editing process
- with their original) the received mechanism is the one that you would want to
- use.
-
-
-OTHER MANIPULATIONS
-
- What you do with the received MLT Service is largely up to you. As shown above,
- you have flexibility in how the item is scheduled and you can carry out
- manipulations on either the xml document and/or the deserialised producer.
-
- Typically, shotcut and inigo produce 'tractor' objects - these can be easily
- manipulated in the push method - for example, to remove a track from the
- output, we could do something like:
-
- Response *push( char *command, Service *service )
- {
- Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
- Tractor *tractor( *service );
- if ( tractor.is_valid( ) && playlist.is_valid( ) )
- {
- // Remove track 2 (NB: tracks are indexed from 0 like everything else)
- Producer *producer = tractor.track( 2 );
- Playlist track( producer );
-
- // If we have a valid track then hide video and audio
- // This is a bit pattern - 1 is video, 2 is audio
- if ( track.is_valid( ) )
- track.set( "hide", 3 );
-
- // You need to delete the reference to the playlist producer here
- delete producer;
-
- // Play it
- playlist.lock( );
- playlist.clear( );
- playlist.append( producer );
- playlist.unlock( );
- return new Response( 200, "OK" );
- }
- return new Response( 400, "Invalid" );
- }
-
-
-EVENT HANDLING
-
- The MLT framework generates events which your custom server can use to do
- various runtime manipulations. For the purpose of this document, I'll focus
- on 'consumer-frame-render' - this event is fired immediately before a frame
- is rendered.
-
- See example in test/server.cpp
-
-
-DISABLING DVCP
-
- In some cases, it is desirable to fully disable the entire DVCP command set
- and handle the PUSH in an application specific way (for example, the shotcut
- applications all do this). The simplest way of doing this is to generate a
- response that signifies the rejection of the command. In this example, the
- 'shutdown' command is also handled:
-
- Response *execute( char *command )
- {
- if ( !strcmp( command, "shutdown" ) )
- exit( 0 );
- return new Response( 400, "Invalid Command" );
- }
-
- If you use this method in the code above, your server does nothing - no units
- are defined, so even a PUSH will be rejected.
-
-
-
+++ /dev/null
-2009-04-10 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * test/play.cpp, test/server.cpp: cleanup some warnings
-
- * src/MltResponse.cpp, src/MltResponse.h: const update for MltResponse
-
- * src/MltResponse.cpp, src/MltResponse.h: Constness changes
-
- * src/MltTransition.cpp, src/MltTransition.h: Constness changes
-
- * src/MltProducer.cpp, src/MltProducer.h: Constness changes
-
- * src/MltProperties.cpp, src/MltProperties.h: Constness changes
-
- * src/MltConsumer.cpp, src/MltConsumer.h: Constness changes
-
- * src/MltProperties.cpp, src/MltResponse.cpp: Constness changes
-
- * src/MltProperties.cpp, src/MltPushConsumer.cpp: Constness changes
-
- * src/MltFilter.cpp, src/MltFilter.h, src/MltProperties.cpp,
- src/MltProperties.h: Constness changes
-
- * src/MltConsumer.cpp, src/MltField.cpp, src/MltFilter.cpp, src/MltFrame.cpp,
- src/MltMultitrack.cpp, src/MltPlaylist.cpp, src/MltProducer.cpp,
- src/MltTractor.cpp, src/MltTransition.cpp: Fix up warnings about explicit
- base initializers in copy constructors
-
- * configure: Add more warnings
-
- * .gitignore: Add a .gitignore file
-
-2009-04-02 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/ruby/thumbs.rb: thumbs.rb: fix setting size property for avformat
- consumer
-
-2009-02-04 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * debian/changelog, debian/control, debian/copyright, debian/rules: remove
- debian package subdirectory (they provide their own)
-
-2009-01-26 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/configure, swig/php/build, swig/php/play.php: swig/configure,
- swig/php/*: add php bindings
-
-2008-12-28 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/java/build, swig/python/build, swig/python/play.py, swig/tcl/build:
- swig/{java,python,tcl}/build: fix linking error __stack_chk_fail_local.
- swig/python/play.py: fix syntax error reported by Jonathon Thomas.
-
-2008-12-27 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/configure: swig/configure: use pkg-config mlt-framework instead of
- deprecated mlt-config.
-
-2008-12-04 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * README: README: update instructions to use pkg-config instead of mlt-config
-
- * swig/java/build, swig/perl/Makefile.PL, swig/python/build, swig/ruby/build,
- swig/tcl/build, test/Makefile: test/Makefile, swig/*/build: replace more
- mlt-config with pkg-config
-
-2008-11-06 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile: src/Makefile: suppress warning on ldconfig failure
-
-2008-10-25 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure: configure: apply patch from Alberto Villa to fix build on
- FreeBSD
-
-2008-10-20 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure: configure: convert to use pkg-config; mlt-config is deprecated
-
-2008-08-06 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * AUTHORS: update mlt++ AUTHORS
-
- * Makefile: fix make dist target
-
- * configure: bump versions for 0.3.0 release
-
- * Makefile: improve make dist target
-
- * swig/java/Play.java, swig/java/Play.sh, swig/java/build: swig/java: fixup
- the java bindings build script and example (bug 1523941)
-
-2008-06-26 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProducer.cpp, src/MltProducer.h, swig/mltpp.i: MltProducer.{h,cpp},
- mltpp.i: remove Producer::get_frame that is unncessary and introduced a
- memory leak.
-
-2008-06-24 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp: MltPlaylist.cpp: return null on clip_info method if
- mlt_playlist_get_clip_info fails.
-
-2008-06-08 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp: MltPlaylist.cpp: prevent strdup from crashing on a
- null pointer.
-
-2008-04-23 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProducer.cpp, src/MltProducer.h, swig/mltpp.i: MltProducer.{h,cpp},
- swig/mltpp.i: add method Producer::get_frame.
-
-2008-04-12 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * test/server.cpp: test/server.cpp: bugfix (1940389) compilation on gcc 4.3
-
-2008-02-27 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltRepository.cpp, src/MltRepository.h: MltRepository.{h,cpp}: update
- to latest mlt_repository.h change - finalization of callback declarations and
- metadata handling
-
-2008-02-16 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/python/build: swig/python/build: add -fPIC
-
- * src/MltRepository.cpp, src/MltRepository.h, swig/mltpp.i:
- MltRepository.{h,cpp}, swig/mltpp.i: added consumers, filters, producers,
- transitions, register_metadata, and metadata methods to Repository class
-
-2008-02-12 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * Makefile: do not make tests automatically
-
-2008-02-07 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure, src/Makefile: configure: add soversion variable src/Makefile:
- improve library versioning by linking on interface version (soversion)
-
- * swig/ruby/thumbs.rb: thumbs.rb: fix error on Playlist.append due to args
- not int
-
- * src/Makefile, src/Mlt.h, src/MltFactory.cpp, src/MltFactory.h,
- src/MltRepository.cpp, src/MltRepository.h, swig/mltpp.i: Mlt.h,
- MltFactory.{h,cpp}, MltRepository.{h,cpp}, swig/mltpp.i: update to deal with
- changes and new capabilities in mlt_factory and mlt_repository.
-
-2008-02-04 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * COPYING: add COPYING to disclose license
-
-2008-02-02 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltConsumer.cpp, src/MltConsumer.h,
- src/MltFactory.cpp, src/MltFactory.h, src/MltFilter.cpp, src/MltFilter.h,
- src/MltFilteredConsumer.cpp, src/MltFilteredConsumer.h,
- src/MltFilteredProducer.cpp, src/MltFilteredProducer.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProfile.cpp, src/MltProfile.h,
- src/MltPushConsumer.cpp, src/MltPushConsumer.h, src/MltService.cpp,
- src/MltService.h, src/MltTractor.cpp, src/MltTractor.h,
- src/MltTransition.cpp, src/MltTransition.h, swig/mltpp.i, swig/perl/play.pl,
- swig/python/play.py, swig/ruby/miracle.rb, swig/ruby/play.rb,
- swig/ruby/thumbs.rb, swig/tcl/play.tcl, test/play.cpp, test/server.cpp: add
- MltProfile and update examples
-
-2007-06-12 ddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * Makefile: added dist make targets
-
- * Makefile, src/Makefile, test/Makefile: added uninstall make targets
-
-2006-03-20 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltFactory.h: + Fix for swig parsing
-
-2006-02-23 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile: + Install of config.h for linux and os/x usage
-
- * src/config.h: + Added the config.h for win32
-
- * mlt++.sln, mlt++.vcproj, src/Mlt.h, src/MltConsumer.h, src/MltDeque.h,
- src/MltEvent.h, src/MltFactory.cpp, src/MltFactory.h, src/MltField.h,
- src/MltFilter.h, src/MltFilteredConsumer.h, src/MltFilteredProducer.h,
- src/MltFrame.cpp, src/MltFrame.h, src/MltGeometry.h, src/MltMultitrack.h,
- src/MltParser.h, src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltProperties.h,
- src/MltPushConsumer.h, src/MltService.h, src/MltTokeniser.h,
- src/MltTractor.h, src/MltTransition.h: + Win32 port - dev studio is required
- to avoid issues with C++ ABI compatibility + Fix for image render in NTSC
- NB: mlt patch to follow (this one isn't much use without it :-)) - mlt build
- is purely mingw32 of course
-
-2005-12-05 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure, src/Makefile: + Fix for Darwin and soname logic
-
- * debian/changelog, debian/control, debian/copyright, debian/rules: +
- Functional debian build rules
-
- * Makefile, configure, src/Makefile, test/Makefile: + MLT++ updates for 0.2.1
- - distclean corrected, soname usage in linking
-
-2005-11-29 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * Makefile, configure: + Correction to a typo
-
- * swig/perl/Makefile.PL: + Perl compilation patch submitted by Torsten
- Spindler
-
- * configure, src/Makefile: + Added a --libdir switch to the configure and
- build and fixed test case compilation
-
-2005-11-22 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure: + Allow LDFLAGS to be inherited from the environment
-
-2005-11-21 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile: + Creates the lib directory on an install
-
-2005-11-10 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * Makefile, src/Makefile: + DESTDIR patch from Anthony Green (green at redhat
- dot com) - many thanks :-)
-
-2005-10-03 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProperties.cpp, src/MltProperties.h: OS/X gcc/g++ 4.x fix
-
- * configure, src/Makefile, src/MltProperties.cpp, src/MltProperties.h,
- test/Makefile: + Whoops - had forgotten these OS/X patches...
-
-2005-09-29 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPushConsumer.cpp: + Oops - fix for memory leak
-
-2005-09-28 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltPushConsumer.cpp, src/MltPushConsumer.h: +
- Added a push based consumer wrapper
-
-2005-07-26 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/Makefile, swig/configure, swig/perl/Makefile.PL, swig/python/build,
- swig/tcl/build: + Cleaned up swig build so it doesn't require an mlt++
- install first - Temporarily disabled java
-
-2005-06-27 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * CUSTOMISING, test/server.cpp: CUSTOMISING + Replaced TBD for frame
- rendering notification event test/server.cpp + Added an example frame
- rendering callback that removes all shotcut related fx
-
-2005-06-26 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * CUSTOMISING, swig/ruby/thumbs.rb: CUSTOMISING + Added an example of how to
- hide a track on reception swig/ruby/thumbs.rb + Changed generator to run,
- rather than sleep and poll
-
-2005-04-12 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * CUSTOMISING: Minor doc updates
-
-2005-03-16 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * CUSTOMISING, src/MltProperties.cpp, src/MltProperties.h,
- src/MltResponse.cpp, src/MltResponse.h, test/server.cpp: Server customisation
-
-
-2005-02-12 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltService.cpp: Minor correction
-
-2005-01-14 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProperties.cpp, src/MltProperties.h: Const string usage in
- properties
-
-2005-01-03 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltGeometry.cpp, src/MltGeometry.h: Next/Prev key extraction
-
- * src/MltMiracle.cpp, src/MltMiracle.h, swig/mltpp.i: Fetch unit from miracle
- server
-
-2004-12-31 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltGeometry.h: Update for geometry
-
-2004-12-24 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltGeometry.cpp, src/MltGeometry.h,
- swig/mltpp.i: Geometry
-
-2004-12-12 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h: blank_at method added
-
-2004-12-11 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h: split_at method added
-
-2004-12-09 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltTractor.cpp, src/MltTractor.h: Tractor constructor modifications
-
-2004-11-25 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/Makefile: Install makefile for swig
-
- * src/Makefile, src/Mlt.h, src/MltDeque.cpp, src/MltDeque.h,
- src/MltFactory.cpp, src/MltFactory.h, src/MltProducer.cpp, src/MltProducer.h,
- src/MltTransition.cpp, src/MltTransition.h: Deque added; simplified producer
- parent access; transition in and out
-
-2004-11-22 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltService.cpp,
- src/MltService.h, test/Makefile: More playlist modifications; service locking
-
-
-2004-11-17 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProperties.cpp, src/MltProperties.h, src/MltTractor.cpp,
- src/MltTractor.h: Ref count and event firing method on properties; locate_cut
- on tractor
-
-2004-11-11 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltProperties.h,
- src/MltTractor.cpp, src/MltTractor.h: Playlist reorganisation
-
-2004-11-07 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltTractor.cpp,
- src/MltTractor.h: Simplified playlist and track access
-
-2004-11-05 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProducer.cpp, src/MltProducer.h: Added cut related methods
-
-2004-10-31 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltTokeniser.cpp, src/MltTokeniser.h,
- test/server.cpp: Added courtesy tokenising class
-
-2004-10-27 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * configure, swig/configure, swig/ruby/build, swig/ruby/miracle.rb: Config
- changes
-
-2004-10-17 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltMiracle.cpp, src/MltMiracle.h: id and log level for server
-
- * src/MltMiracle.cpp: Server shutdown state
-
-2004-10-14 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltConsumer.cpp, src/MltConsumer.h, test/play.cpp: buffer fix and
- tractor handling
-
- * HOWTO: Doc updates
-
- * src/MltMiracle.cpp, src/MltMiracle.h: Improved push capabilities
-
-2004-10-08 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProducer.cpp, src/MltProducer.h: Same and following clip
- identification
-
-2004-10-05 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltFrame.cpp, src/MltFrame.h,
- src/MltParser.cpp, src/MltParser.h, src/MltService.cpp, src/MltService.h,
- swig/mltpp.i: Added the parser object and moved type identity into mlt
-
-2004-09-29 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, swig/mltpp.i: new mix related
- methods
-
-2004-09-26 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * README, src/MltPlaylist.cpp, src/MltPlaylist.h: Playlist repeat clip
- functionality
-
-2004-09-24 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltProducer.cpp, src/MltProducer.h, swig/mltpp.i: Cut management part 1
-
-
-2004-09-23 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltService.cpp, swig/mltpp.i: get_frame and ruby listen fix
-
-2004-09-22 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltFrame.cpp, src/MltProperties.cpp, src/MltProperties.h, swig/mltpp.i:
- Event and frame handling
-
- * configure, src/MltMiracle.cpp: Server shutdown
-
-2004-09-19 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltMiracle.cpp, src/MltMiracle.h,
- src/MltResponse.cpp, src/MltResponse.h, swig/mltpp.i: Added the response
- object
-
- * HOWTO, src/Makefile, src/Mlt.h, src/MltMiracle.cpp, src/MltMiracle.h,
- swig/mltpp.i, swig/ruby/miracle.rb, test/Makefile, test/play.cpp,
- test/server.cpp: Adding miracle
-
-2004-09-09 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h: Adding the mix part 1
-
-2004-09-06 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltFilteredConsumer.cpp, src/MltFilteredConsumer.h,
- src/MltProducer.cpp, src/MltProducer.h, src/MltService.cpp, src/MltService.h,
- swig/mltpp.i: Service attach filters
-
-2004-09-03 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * HOWTO, src/MltProperties.cpp, src/MltProperties.h, swig/mltpp.i,
- swig/perl/play.pl: More event stuff
-
-2004-09-02 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltEvent.cpp, src/MltEvent.h,
- src/MltProperties.cpp, src/MltProperties.h, swig/mltpp.i, swig/ruby/play.rb,
- test/play.cpp: Event modifications
-
-2004-08-31 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * HOWTO, src/Makefile, src/MltConsumer.cpp, src/MltConsumer.h,
- src/MltFilter.cpp, src/MltFilter.h, src/MltFrame.cpp, src/MltFrame.h,
- src/MltMultitrack.cpp, src/MltMultitrack.h, src/MltPlaylist.cpp,
- src/MltPlaylist.h, src/MltProducer.cpp, src/MltProducer.h,
- src/MltService.cpp, src/MltService.h, src/MltTractor.cpp, src/MltTractor.h,
- src/MltTransition.cpp, src/MltTransition.h: Run time type identification
-
-2004-08-28 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * README, src/MltMultitrack.cpp, src/MltMultitrack.h, src/MltTractor.cpp,
- src/MltTractor.h, swig/mltpp.i: Tractor enhancements
-
- * src/Makefile, src/Mlt.h, src/MltField.cpp, src/MltField.h,
- src/MltMultitrack.cpp, src/MltMultitrack.h, src/MltTractor.cpp,
- src/MltTractor.h, swig/mltpp.i: Multitrack classes added
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, swig/mltpp.i: Producer filter extraction method
-
-2004-08-27 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/Mlt.h, src/MltFilteredProducer.cpp,
- src/MltFilteredProducer.h, src/MltProducer.cpp, src/MltProducer.h,
- src/MltService.cpp, src/MltService.h, swig/mltpp.i: Removed FilteredProducer
-
-2004-08-26 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * Makefile, test/Makefile, test/play.cpp: Build modifications
-
- * src/MltConsumer.cpp, src/MltConsumer.h, src/MltFilter.cpp, src/MltFilter.h,
- src/MltFilteredConsumer.cpp, src/MltFilteredConsumer.h, src/MltFrame.cpp,
- src/MltFrame.h, src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltProperties.h,
- src/MltService.cpp, src/MltService.h, src/MltTransition.cpp,
- src/MltTransition.h, swig/perl/play.pl: Mlt Ref Counts and Playlist
- split/join
-
-2004-08-23 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/perl/play.pl: Added play.pl
-
- * src/Makefile, swig/mltpp.i: Workaround for perl
-
-2004-08-21 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltConsumer.cpp, src/MltFilter.cpp, src/MltProperties.cpp,
- src/MltProperties.h, src/MltTransition.cpp: Constructor clean up
-
- * src/MltConsumer.cpp, src/MltConsumer.h: consumer purge
-
-2004-08-20 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltFilter.cpp, src/MltFilter.h, src/MltPlaylist.cpp, src/MltPlaylist.h,
- swig/configure, swig/java/build, swig/ruby/build, swig/ruby/thumbs.rb:
- mlt_position, /usr/bin/env and Instance fix
-
-2004-08-18 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/MltFrame.cpp, src/MltFrame.h, src/MltProducer.cpp, src/MltProducer.h,
- src/MltService.cpp, swig/mltpp.i, swig/ruby/play.rb: image handling
-
-2004-08-17 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/java/Play.java, swig/ruby/play.rb, swig/ruby/thumbs.rb: Fixes for mods
- to api
-
- * src/Makefile, src/Mlt.h, src/MltConsumer.cpp, src/MltConsumer.h,
- src/MltFilteredConsumer.cpp, src/MltFilteredConsumer.h,
- src/MltFilteredProducer.cpp, src/MltFilteredProducer.h, src/MltService.cpp,
- src/MltService.h, swig/mltpp.i: Filtered producers and consumers
-
- * test/play.cpp: oops
-
-2004-08-16 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * swig/configure, swig/java/Play.java, swig/java/Play.sh, swig/java/build,
- swig/mltpp.i, swig/perl/Makefile.PL, swig/perl/build, swig/python/build,
- swig/python/play.py, swig/ruby/build, swig/ruby/play.rb, swig/ruby/thumbs.rb,
- swig/tcl/build, swig/tcl/play.tcl: Experimental swig bindings
-
- * README, src/MltFactory.cpp, src/MltFactory.h, src/MltFilter.cpp,
- src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProperties.cpp, src/MltProperties.h, src/MltService.cpp,
- src/MltService.h, src/MltTransition.cpp, test/Makefile: More cleanups
-
- * README, src/MltConsumer.cpp, src/MltConsumer.h, src/MltFactory.cpp,
- src/MltFactory.h, src/MltFilter.cpp, src/MltFilter.h, src/MltFrame.cpp,
- src/MltFrame.h, src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltProperties.h,
- src/MltService.cpp, src/MltService.h, src/MltTransition.cpp,
- src/MltTransition.h, test/play.cpp: Class rework and simplification
-
- * src/Makefile, src/Mlt.h: Added Mlt.h convenience header
-
- * src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProperties.cpp,
- src/MltProperties.h, src/MltService.cpp: Complete methods for properties and
- playlist; reversed NULL handling on service class
-
- * README, src/MltProperties.cpp, src/MltProperties.h, test/play.cpp: Object
- validity checks
-
- * AUTHORS, Makefile, README, configure, src/Makefile, src/MltService.cpp,
- test/play.cpp: Build and docs modifications
-
-2004-08-15 lilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
-
- * src/Makefile, src/MltConsumer.cpp, src/MltConsumer.h, src/MltFactory.cpp,
- src/MltFactory.h, src/MltFilter.cpp, src/MltFilter.h, src/MltFrame.cpp,
- src/MltFrame.h, src/MltPlaylist.cpp, src/MltPlaylist.h, src/MltProducer.cpp,
- src/MltProducer.h, src/MltProperties.cpp, src/MltProperties.h,
- src/MltService.cpp, src/MltService.h, src/MltTransition.cpp,
- src/MltTransition.h, test/Makefile, test/play.cpp: Initial revision
+++ /dev/null
-Microsoft Visual Studio Solution File, Format Version 8.00\r
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mlt++", "mlt++.vcproj", "{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}"\r
- ProjectSection(ProjectDependencies) = postProject\r
- EndProjectSection\r
-EndProject\r
-Global\r
- GlobalSection(SolutionConfiguration) = preSolution\r
- Debug = Debug\r
- Release = Release\r
- EndGlobalSection\r
- GlobalSection(ProjectConfiguration) = postSolution\r
- {31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Debug.ActiveCfg = Debug|Win32\r
- {31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Debug.Build.0 = Debug|Win32\r
- {31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Release.ActiveCfg = Release|Win32\r
- {31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}.Release.Build.0 = Release|Win32\r
- EndGlobalSection\r
- GlobalSection(ExtensibilityGlobals) = postSolution\r
- EndGlobalSection\r
- GlobalSection(ExtensibilityAddIns) = postSolution\r
- EndGlobalSection\r
-EndGlobal\r
+++ /dev/null
-<?xml version="1.0" encoding="Windows-1252"?>\r
-<VisualStudioProject\r
- ProjectType="Visual C++"\r
- Version="7.10"\r
- Name="mlt++"\r
- ProjectGUID="{31B6CBDB-6A84-4BC7-AACF-A1BCE02444FD}"\r
- Keyword="Win32Proj">\r
- <Platforms>\r
- <Platform\r
- Name="Win32"/>\r
- </Platforms>\r
- <Configurations>\r
- <Configuration\r
- Name="Debug|Win32"\r
- OutputDirectory="Debug"\r
- IntermediateDirectory="Debug"\r
- ConfigurationType="2"\r
- CharacterSet="2">\r
- <Tool\r
- Name="VCCLCompilerTool"\r
- Optimization="0"\r
- AdditionalIncludeDirectories=""C:\Program Files\mlt\include\mlt""\r
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MLTPP_EXPORTS"\r
- MinimalRebuild="TRUE"\r
- BasicRuntimeChecks="3"\r
- RuntimeLibrary="3"\r
- TreatWChar_tAsBuiltInType="TRUE"\r
- UsePrecompiledHeader="0"\r
- WarningLevel="3"\r
- Detect64BitPortabilityProblems="TRUE"\r
- DebugInformationFormat="4"/>\r
- <Tool\r
- Name="VCCustomBuildTool"/>\r
- <Tool\r
- Name="VCLinkerTool"\r
- AdditionalDependencies="libmlt.0.2.1.lib"\r
- OutputFile="$(OutDir)/mlt++.dll"\r
- LinkIncremental="2"\r
- AdditionalLibraryDirectories=""C:\Program Files\mlt\lib""\r
- GenerateDebugInformation="TRUE"\r
- ProgramDatabaseFile="$(OutDir)/mlt++.pdb"\r
- SubSystem="2"\r
- ImportLibrary="$(OutDir)/mlt++.lib"\r
- TargetMachine="1"/>\r
- <Tool\r
- Name="VCMIDLTool"/>\r
- <Tool\r
- Name="VCPostBuildEventTool"/>\r
- <Tool\r
- Name="VCPreBuildEventTool"/>\r
- <Tool\r
- Name="VCPreLinkEventTool"/>\r
- <Tool\r
- Name="VCResourceCompilerTool"/>\r
- <Tool\r
- Name="VCWebServiceProxyGeneratorTool"/>\r
- <Tool\r
- Name="VCXMLDataGeneratorTool"/>\r
- <Tool\r
- Name="VCWebDeploymentTool"/>\r
- <Tool\r
- Name="VCManagedWrapperGeneratorTool"/>\r
- <Tool\r
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
- </Configuration>\r
- <Configuration\r
- Name="Release|Win32"\r
- OutputDirectory="Release"\r
- IntermediateDirectory="Release"\r
- ConfigurationType="2"\r
- CharacterSet="2">\r
- <Tool\r
- Name="VCCLCompilerTool"\r
- AdditionalIncludeDirectories=""C:\Program Files\mlt\include\mlt""\r
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MLTPP_EXPORTS"\r
- RuntimeLibrary="0"\r
- TreatWChar_tAsBuiltInType="TRUE"\r
- UsePrecompiledHeader="0"\r
- WarningLevel="3"\r
- Detect64BitPortabilityProblems="TRUE"\r
- DebugInformationFormat="3"/>\r
- <Tool\r
- Name="VCCustomBuildTool"/>\r
- <Tool\r
- Name="VCLinkerTool"\r
- AdditionalDependencies="libmlt.0.2.1.lib"\r
- OutputFile="$(OutDir)/mlt++.dll"\r
- LinkIncremental="1"\r
- AdditionalLibraryDirectories=""C:\Program Files\mlt\lib""\r
- GenerateDebugInformation="TRUE"\r
- SubSystem="2"\r
- OptimizeReferences="2"\r
- EnableCOMDATFolding="2"\r
- ImportLibrary="$(OutDir)/mlt++.lib"\r
- TargetMachine="1"/>\r
- <Tool\r
- Name="VCMIDLTool"/>\r
- <Tool\r
- Name="VCPostBuildEventTool"/>\r
- <Tool\r
- Name="VCPreBuildEventTool"/>\r
- <Tool\r
- Name="VCPreLinkEventTool"/>\r
- <Tool\r
- Name="VCResourceCompilerTool"/>\r
- <Tool\r
- Name="VCWebServiceProxyGeneratorTool"/>\r
- <Tool\r
- Name="VCXMLDataGeneratorTool"/>\r
- <Tool\r
- Name="VCWebDeploymentTool"/>\r
- <Tool\r
- Name="VCManagedWrapperGeneratorTool"/>\r
- <Tool\r
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>\r
- </Configuration>\r
- </Configurations>\r
- <References>\r
- </References>\r
- <Files>\r
- <Filter\r
- Name="Source Files"\r
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">\r
- <File\r
- RelativePath=".\src\config.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\Mlt.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltConsumer.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltConsumer.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltDeque.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltDeque.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltEvent.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltEvent.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFactory.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFactory.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltField.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltField.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilter.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilter.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilteredConsumer.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilteredConsumer.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilteredProducer.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFilteredProducer.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFrame.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltFrame.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltGeometry.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltGeometry.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltMultitrack.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltMultitrack.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltParser.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltParser.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltPlaylist.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltPlaylist.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltProducer.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltProducer.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltProperties.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltProperties.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltPushConsumer.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltPushConsumer.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltService.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltService.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTokeniser.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTokeniser.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTractor.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTractor.h">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTransition.cpp">\r
- </File>\r
- <File\r
- RelativePath=".\src\MltTransition.h">\r
- </File>\r
- </Filter>\r
- <Filter\r
- Name="Header Files"\r
- Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">\r
- </Filter>\r
- <Filter\r
- Name="Resource Files"\r
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"\r
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">\r
- </Filter>\r
- </Files>\r
- <Globals>\r
- </Globals>\r
-</VisualStudioProject>\r
+++ /dev/null
-/**
- * MltMiracle.cpp - MLT Wrapper
- * Copyright (C) 2004-2005 Charles Yates
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "MltMiracle.h"
-#include "MltService.h"
-#include "MltResponse.h"
-using namespace Mlt;
-
-#include <time.h>
-
-static valerie_response mlt_miracle_execute( void *arg, char *command )
-{
- Miracle *miracle = ( Miracle * )arg;
- if ( miracle != NULL )
- {
- Response *response = miracle->execute( command );
- valerie_response real = valerie_response_clone( response->get_response( ) );
- delete response;
- return real;
- }
- else
- {
- valerie_response response = valerie_response_init( );
- valerie_response_set_error( response, 500, "Invalid server" );
- return response;
- }
-}
-
-static valerie_response mlt_miracle_received( void *arg, char *command, char *doc )
-{
- Miracle *miracle = ( Miracle * )arg;
- if ( miracle != NULL )
- {
- Response *response = miracle->received( command, doc );
- if ( response != NULL )
- {
- valerie_response real = valerie_response_clone( response->get_response( ) );
- delete response;
- return real;
- }
- return NULL;
- }
- else
- {
- valerie_response response = valerie_response_init( );
- valerie_response_set_error( response, 500, "Invalid server" );
- return response;
- }
-}
-
-static valerie_response mlt_miracle_push( void *arg, char *command, mlt_service service )
-{
- Miracle *miracle = ( Miracle * )arg;
- if ( miracle != NULL )
- {
- Service input( service );
- Response *response = miracle->push( command, &input );
- valerie_response real = valerie_response_clone( response->get_response( ) );
- delete response;
- return real;
- }
- else
- {
- valerie_response response = valerie_response_init( );
- valerie_response_set_error( response, 500, "Invalid server" );
- return response;
- }
-}
-
-Miracle::Miracle( char *name, int port, char *config ) :
- Properties( false )
-{
- server = miracle_server_init( name );
- miracle_server_set_port( server, port );
- miracle_server_set_config( server, config );
-}
-
-Miracle::~Miracle( )
-{
- miracle_server_close( server );
-}
-
-mlt_properties Miracle::get_properties( )
-{
- return &server->parent;
-}
-
-bool Miracle::start( )
-{
- if ( miracle_server_execute( server ) == 0 )
- {
- _real = server->parser->real;
- _execute = server->parser->execute;
- _received = server->parser->received;
- _push = server->parser->push;
- server->parser->real = this;
- server->parser->execute = mlt_miracle_execute;
- server->parser->received = mlt_miracle_received;
- server->parser->push = mlt_miracle_push;
- }
- return server->shutdown == 0;
-}
-
-bool Miracle::is_running( )
-{
- return server->shutdown == 0;
-}
-
-Response *Miracle::execute( char *command )
-{
- return new Response( _execute( _real, command ) );
-}
-
-Response *Miracle::received( char *command, char *doc )
-{
- return new Response( _received( _real, command, doc ) );
-}
-
-Response *Miracle::push( char *command, Service *service )
-{
- return new Response( _push( _real, command, service->get_service( ) ) );
-}
-
-void Miracle::wait_for_shutdown( )
-{
- struct timespec tm = { 1, 0 };
- while ( !server->shutdown )
- nanosleep( &tm, NULL );
-}
-
-void Miracle::log_level( int threshold )
-{
- miracle_log_init( log_stderr, threshold );
-}
-
-Properties *Miracle::unit( int index )
-{
- mlt_properties properties = miracle_server_fetch_unit( server, index );
- return properties != NULL ? new Properties( properties ) : NULL;
-}
+++ /dev/null
-/**
- * MltMiracle.h - MLT Wrapper
- * Copyright (C) 2004-2005 Charles Yates
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _MLTPP_MIRACLE_H_
-#define _MLTPP_MIRACLE_H_
-
-#include <miracle/miracle_server.h>
-#include <miracle/miracle_log.h>
-#include "MltService.h"
-
-namespace Mlt
-{
- class Properties;
- class Service;
- class Response;
-
- class Miracle : public Properties
- {
- private:
- miracle_server server;
- void *_real;
- parser_execute _execute;
- parser_received _received;
- parser_push _push;
- public:
- Miracle( char *name, int port = 5250, char *config = NULL );
- virtual ~Miracle( );
- mlt_properties get_properties( );
- bool start( );
- bool is_running( );
- virtual Response *execute( char *command );
- virtual Response *received( char *command, char *doc );
- virtual Response *push( char *command, Service *service );
- void wait_for_shutdown( );
- static void log_level( int );
- Properties *unit( int );
- };
-}
-
-#endif
-
+++ /dev/null
-/**
- * MltResponse.cpp - MLT Wrapper
- * Copyright (C) 2004-2005 Charles Yates
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <string.h>
-#include "MltResponse.h"
-using namespace Mlt;
-
-Response::Response( valerie_response response ) :
- _response( response )
-{
-}
-
-Response::Response( int error, const char *message ) :
- _response( NULL )
-{
- _response = valerie_response_init( );
- if ( _response != NULL )
- valerie_response_set_error( _response, error, message );
-}
-
-Response::~Response( )
-{
- valerie_response_close( _response );
-}
-
-valerie_response Response::get_response( )
-{
- return _response;
-}
-
-int Response::error_code( )
-{
- return valerie_response_get_error_code( get_response( ) );
-}
-
-const char *Response::error_string( )
-{
- return valerie_response_get_error_string( get_response( ) );
-}
-
-char *Response::get( int index )
-{
- return valerie_response_get_line( get_response( ), index );
-}
-
-int Response::count( )
-{
- return valerie_response_count( get_response( ) );
-}
-
-int Response::write( const char *data )
-{
- return valerie_response_write( get_response( ), data, strlen( data ) );
-}
-
+++ /dev/null
-/**
- * MltResponse.h - MLT Wrapper
- * Copyright (C) 2004-2005 Charles Yates
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _MLTPP_RESPONSE_H_
-#define _MLTPP_RESPONSE_H_
-
-#include <valerie/valerie_response.h>
-
-namespace Mlt
-{
- class Response
- {
- private:
- valerie_response _response;
- public:
- Response( valerie_response response );
- Response( int error, const char *message );
- ~Response( );
- valerie_response get_response( );
- int error_code( );
- const char *error_string( );
- char *get( int );
- int count( );
- int write( const char *data );
- };
-}
-
-#endif
+++ /dev/null
-#!/usr/bin/env ruby
-
-require 'mltpp'
-
-def command
- puts "command"
-end
-
-def push
- puts "push"
-end
-
-miracle = Mltpp::Miracle.new( "miracle-ruby", 5260 )
-miracle.start
-miracle.execute( "uadd sdl" )
-listener = Mltpp::Listener.new( miracle, "command-received", method( :command ) )
-listener = Mltpp::Listener.new( miracle, "push-received", method( :push ) )
-miracle.wait_for_shutdown
-
+++ /dev/null
-#include <iostream>
-#include <string>
-#include <cstring>
-#include <sstream>
-using namespace std;
-
-#include <Mlt.h>
-using namespace Mlt;
-
-class Custom : public Miracle
-{
- private:
- Event *event;
- Profile profile;
-
- public:
- Custom( char *name = "Custom", int port = 5290, char *config = NULL ) :
- Miracle( name, port, config ),
- event( NULL )
- {
- // Ensure that we receive the westley document before it's deserialised
- set( "push-parser-off", 1 );
- }
-
- virtual ~Custom( )
- {
- delete event;
- }
-
- // Optional step - receive the westley document and do something with it
- Response *received( char *command, char *document )
- {
- cerr << document << endl;
- Producer producer( profile, "westley-xml", document );
- return push( command, &producer );
- }
-
- // Push handling - clear the playlist, append, seek to beginning and play
- Response *push( char*, Service *service )
- {
- Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
- Producer producer( *service );
- if ( producer.is_valid( ) && playlist.is_valid( ) )
- {
- playlist.lock( );
- playlist.clear( );
- playlist.append( producer );
- playlist.seek( 0 );
- playlist.set_speed( 1 );
- playlist.unlock( );
- return new Response( 200, "OK" );
- }
- return new Response( 400, "Invalid" );
- }
-
- // Custom command execution
- Response *execute( char *command )
- {
- Response *response = NULL;
-
- if ( !strcmp( command, "debug" ) )
- {
- // Example of a custom command
- response = new Response( 200, "Diagnostics output" );
- for( int i = 0; unit( i ) != NULL; i ++ )
- {
- Properties *properties = unit( i );
- stringstream output;
- output << string( "Unit " ) << i << endl;
- for ( int j = 0; j < properties->count( ); j ++ )
- output << properties->get_name( j ) << " = " << properties->get( j ) << endl;
- response->write( output.str( ).c_str( ) );
- }
- }
- else
- {
- // Use the default command processing
- response = Miracle::execute( command );
- }
-
- // If no event exists and the first unit has been added...
- if ( event == NULL && unit( 0 ) != NULL )
- {
- // Set up the event handling
- Consumer consumer( ( mlt_consumer )( unit( 0 )->get_data( "consumer" ) ) );
- event = consumer.listen( "consumer-frame-render", this, ( mlt_listener )frame_render );
-
- // In this custom case, we'll loop everything on the unit
- Playlist playlist( ( mlt_playlist )( unit( 0 )->get_data( "playlist" ) ) );
- playlist.set( "eof", "loop" );
- }
-
- return response;
- }
-
- // Callback for frame render notification
- static void frame_render( mlt_consumer, Custom *self, mlt_frame frame_ptr )
- {
- Frame frame( frame_ptr );
- self->frame_render_event( frame );
- }
-
- // Remove all supers and attributes
- void frame_render_event( Frame &frame )
- {
- // Fetch the c double ended queue structure
- mlt_deque deque = ( mlt_deque )frame.get_data( "data_queue" );
-
- // While the deque isn't empty
- while( deque != NULL && mlt_deque_peek_back( deque ) != NULL )
- {
- // Fetch the c properties structure
- mlt_properties cprops = ( mlt_properties )mlt_deque_pop_back( deque );
-
- // For fun, convert it to c++ and output it :-)
- Properties properties( cprops );
- properties.debug( );
-
- // Wipe it
- mlt_properties_close( cprops );
- }
- }
-};
-
-int main( int, char** )
-{
- Custom server( "Server" );
- server.start( );
- server.execute( "uadd sdl" );
- server.execute( "play u0" );
- server.wait_for_shutdown( );
- return 0;
-}
-
+++ /dev/null
-
-Name: mlt-miracle
-Description: MLT Miracle server API
-Version: ${version}
-Requires:
-Libs: -L${libdir} ${libs}
-Cflags: ${cflags}
+++ /dev/null
-
-Name: mlt-valerie
-Description: MLT Valerie client API
-Version: ${version}
-Requires:
-Libs: -L${libdir} ${libs}
-Cflags: ${cflags}
+++ /dev/null
-include ../../config.mak
-
-TARGET = albino
-
-OBJS = albino.o
-
-CFLAGS += -I.. $(RDYNAMIC)
-
-LDFLAGS += -L../miracle -lmiracle
-LDFLAGS += -L../valerie -lvalerie
-LDFLAGS += -L../framework -lmlt -lpthread
-
-SRCS := $(OBJS:.o=.c)
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- $(CC) -o $@ $(OBJS) $(LDFLAGS)
-
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
-
-distclean: clean
- rm -f .depend
-
-clean:
- rm -f $(OBJS) $(TARGET)
-
-install: all
- install -d "$(DESTDIR)$(bindir)"
- install -c -s -m 755 $(TARGET) "$(DESTDIR)$(bindir)"
-
-uninstall:
- rm -f "$(DESTDIR)$(bindir)/$(TARGET)"
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+++ /dev/null
-/*
- * albino.c -- Local Valerie/Miracle Test Utility
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sched.h>
-
-#ifdef __DARWIN__
-#include <SDL.h>
-#endif
-
-/* Application header files */
-#include <miracle/miracle_local.h>
-#include <valerie/valerie_remote.h>
-#include <valerie/valerie_util.h>
-
-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( "Miracle Client Instance\n" );
- parser = valerie_parser_init_remote( argv[ 2 ], 5250 );
- response = valerie_parser_connect( parser );
- index = 3;
- }
- else
- {
- printf( "Miracle 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 Miracle instance.\n" );
- }
-
- printf( "\n" );
- valerie_parser_close( parser );
-
- return 0;
-}
+++ /dev/null
-include ../../config.mak
-
-TARGET = humperdink
-
-OBJS = client.o \
- io.o \
- remote.o
-
-CFLAGS += -I.. $(RDYNAMIC)
-
-LDFLAGS += -L../valerie -lvalerie
-LDFLAGS += -L../framework -lmlt -lpthread
-
-SRCS := $(OBJS:.o=.c)
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- $(CC) -o $@ $(OBJS) $(LDFLAGS)
-
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
-
-distclean: clean
- rm -f .depend
-
-clean:
- rm -f $(OBJS) $(TARGET)
-
-install: all
- install -d "$(DESTDIR)$(bindir)"
- install -c -s -m 755 $(TARGET) "$(DESTDIR)$(bindir)"
-
-uninstall:
- rm -f "$(DESTDIR)$(bindir)/$(TARGET)"
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+++ /dev/null
-/*
- * client.c -- Valerie client demo
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* 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
-{
- const char *description;
- struct menu_item
- {
- const 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 ), " %9d %9d %9d ", 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( "Miracle Shell\n" );
- printf( "Enter an empty command to exit.\n\n" );
-
- while ( !terminated )
- {
- terminated = 1;
- printf( "Command> " );
-
- if ( chomp( io_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 )
- {
- const 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 )
-{
- const 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 );
-}
+++ /dev/null
-/*
- * client.h -- Valerie client demo
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <pthread.h>
-#include <valerie/valerie.h>
-
-/** 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
+++ /dev/null
-/*
- * io.c -- Valerie client demo input/output
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-/* 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 *io_get_string( char *output, int maxlength, const 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( const 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 );
-}
+++ /dev/null
-/*
- * io.h -- Valerie client demo input/output
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 *io_get_string( char *, int, const 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( const char * );
-extern void beep( );
-
-#endif
+++ /dev/null
-/*
- * remote.c -- Remote Valerie client demo
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdint.h>
-
-#include <valerie/valerie_remote.h>
-
-/* 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 ( io_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;
-}
+++ /dev/null
-include ../../config.mak
-
-TARGET = miracle
-
-ifneq ($(targetos), Darwin)
-LIBNAME = libmiracle$(LIBSUF)
-LIBTARGET = $(LIBNAME).$(version)
-LIBSONAME = $(LIBNAME).$(soversion)
-SHFLAGS += -Wl,-soname,$(LIBSONAME)
-else
-LIBNAME = libmiracle$(LIBSUF)
-LIBTARGET = libmiracle.$(version)$(LIBSUF)
-LIBSONAME = libmiracle.$(soversion)$(LIBSUF)
-SHFLAGS += -install_name $(libdir)/$(LIBSONAME) -current_version $(version) -compatibility_version $(soversion)
-endif
-
-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
-
-INCS = miracle_server.h \
- miracle_local.h \
- miracle_log.h
-
-OBJS = $(APP_OBJS) $(LIB_OBJS)
-
-CFLAGS += -I.. $(RDYNAMIC)
-
-LDFLAGS += -L../valerie -lvalerie
-LDFLAGS += -L../framework -lmlt -lpthread
-
-SRCS := $(OBJS:.o=.c)
-
-all: $(TARGET)
-
-$(TARGET): $(APP_OBJS) $(LIBTARGET)
- $(CC) -o $@ $(APP_OBJS) -L. -lmiracle $(LDFLAGS)
-
-$(LIBTARGET): $(LIB_OBJS)
- $(CC) $(SHFLAGS) -o $@ $(LIB_OBJS) $(LDFLAGS)
- ln -sf $(LIBTARGET) $(LIBNAME)
- ln -sf $(LIBTARGET) $(LIBSONAME)
-
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
-
-distclean: clean
- rm -f .depend
-
-clean:
- rm -f $(OBJS) $(TARGET) $(LIBNAME) $(LIBTARGET)
-
-install: all
- install -d "$(DESTDIR)$(bindir)"
- install -c -s -m 755 $(TARGET) "$(DESTDIR)$(bindir)"
- install -m 755 $(LIBTARGET) $(DESTDIR)$(libdir)
- ln -sf $(LIBTARGET) $(DESTDIR)$(libdir)/$(LIBSONAME)
- ln -sf $(LIBTARGET) $(DESTDIR)$(libdir)/$(LIBNAME)
- mkdir -p "$(DESTDIR)$(prefix)/include/mlt/miracle"
- install -m 644 $(INCS) "$(DESTDIR)$(prefix)/include/mlt/miracle"
-
-uninstall:
- rm -f "$(DESTDIR)$(bindir)/$(TARGET)"
- rm -f "$(DESTDIR)$(libdir)/$(LIBTARGET)"
- rm -f "$(DESTDIR)$(libdir)/$(LIBSONAME)"
- rm -f "$(DESTDIR)$(libdir)/$(LIBNAME)"
- rm -rf "$(DESTDIR)$(prefix)/include/mlt/miracle"
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+++ /dev/null
-#!/bin/sh
-echo "miracle -I$prefix/include/mlt -D_REENTRANT -L$libdir -lmiracle" >> ../../packages.dat
+++ /dev/null
-/*
- * miracle.c -- MLT Video TCP Server
- *
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Authors:
- * Dan Dennedy <dan@dennedy.org>
- * Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <time.h>
-#include <sched.h>
-
-#include <framework/mlt.h>
-
-/* 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_close( 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 };
- struct sched_param scp;
-
- // Use realtime scheduling if possible
- memset( &scp, '\0', sizeof( scp ) );
- scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1;
-#ifndef __DARWIN__
- sched_setscheduler( 0, SCHED_FIFO, &scp );
-#endif
-
- mlt_factory_init( NULL );
-
- 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 );
-
- /* Set the config script */
- miracle_server_set_config( server, "/etc/miracle.conf" );
-
- /* Execute the server */
- error = miracle_server_execute( server );
-
- /* We need to wait until we're exited.. */
- while ( !server->shutdown )
- nanosleep( &tm, NULL );
-
- return error;
-}
+++ /dev/null
-/*
- * global_commands.c
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/poll.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <pthread.h>
-
-#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 );
- valerie_response_printf( cmd_arg->response, 10, "U%1d\n\n", i );
- }
- return g_units[ i ] != NULL ? RESPONSE_SUCCESS_N : RESPONSE_ERROR;
- }
- valerie_response_printf( cmd_arg->response, 1024, "no more units can be created\n\n" );
-
- 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 );
- }
- }
- valerie_response_printf( cmd_arg->response, 1024, "\n" );
-
- 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 ( len && 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;
-}
-
-
+++ /dev/null
-/*
- * global_commands.h
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <valerie/valerie_status.h>
-#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
+++ /dev/null
-/*
- * miracle_connection.c -- DV Connection Handler
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <config.h>
-#endif
-
-/* System header files */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <time.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-
-#include <valerie/valerie_socket.h>
-
-/* 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 ), "" ) )
- if ( write( fd, "\r\n", 2 ) != 2 )
- miracle_log( LOG_ERR, "write(\"\\r\\n\") failed!" );
- }
- else
- {
- const char *message = "500 Empty Response\r\n\r\n";
- if ( write( fd, message, strlen( message ) ) != strlen( message ))
- miracle_log( LOG_ERR, "write(%s) failed!", 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;
- mlt_properties owner = connection->owner;
- 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 ) )
- {
- response = NULL;
-
- if ( !strncmp( command, "PUSH ", 5 ) )
- {
- char temp[ 20 ];
- int bytes;
- char *buffer = NULL;
- int total = 0;
- mlt_service service = NULL;
-
- connection_read( fd, temp, 20 );
- bytes = atoi( temp );
- buffer = malloc( bytes + 1 );
- while ( total < bytes )
- {
- int count = read( fd, buffer + total, bytes - total );
- if ( count >= 0 )
- total += count;
- else
- break;
- }
- buffer[ bytes ] = '\0';
- if ( bytes > 0 && total == bytes )
- {
- if ( mlt_properties_get( owner, "push-parser-off" ) == 0 )
- {
- service = ( mlt_service )mlt_factory_producer( NULL, "westley-xml", buffer );
- mlt_events_fire( owner, "push-received", &response, command, service, NULL );
- if ( response == NULL )
- response = valerie_parser_push( parser, command, service );
- }
- else
- {
- response = valerie_parser_received( parser, command, buffer );
- }
- }
- error = connection_send( fd, response );
- valerie_response_close( response );
- mlt_service_close( service );
- free( buffer );
- }
- else if ( strncmp( command, "STATUS", 6 ) )
- {
- mlt_events_fire( owner, "command-received", &response, command, NULL );
- if ( response == NULL )
- 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;
-}
+++ /dev/null
-/*
- * miracle_connection.h -- DV Connection Handler
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <valerie/valerie_parser.h>
-#include <valerie/valerie_tokeniser.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/** Connection structure
-*/
-
-typedef struct
-{
- mlt_properties owner;
- 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
+++ /dev/null
-/*
- * miracle_local.c -- Local Miracle Parser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <config.h>
-#endif
-
-/* System header files */
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-/* Needed for backtrace on linux */
-#ifdef linux
-#include <execinfo.h>
-#endif
-
-/* Valerie header files */
-#include <valerie/valerie_util.h>
-
-/* MLT header files. */
-#include <framework/mlt_factory.h>
-
-/* 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 valerie_response miracle_local_push( miracle_local, char *, mlt_service );
-static valerie_response miracle_local_receive( miracle_local, char *, 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->push = (parser_push)miracle_local_push;
- parser->received = (parser_received)miracle_local_receive;
- 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;
- const 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,
- ATYPE_PAIR
-}
-arguments_types;
-
-/** A command definition.
-*/
-
-typedef struct
-{
-/* The command string corresponding to this operation (e.g. "play") */
- const 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 */
- const 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_PAIR, "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."},
- {"WIPE", miracle_wipe, 1, ATYPE_NONE, "Clean a unit by removing everything before the currently playing clip."},
- {"CLEAR", miracle_clear, 1, ATYPE_NONE, "Clear a unit by removing all clips."},
- {"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_PAIR, "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 <dan@dennedy.org>\n"
- " Charles Yates <charles.yates@pandora.be>\n"
- "Available commands:\n";
-
-/** Lookup the response message for a status code.
-*/
-
-inline const 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);
- }
-}
-
-static void sigsegv_handler()
-{
-#ifdef linux
- void *array[ 10 ];
- size_t size;
- char **strings;
- size_t i;
-
- miracle_log( LOG_CRIT, "\a\nMiracle experienced a segmentation fault.\n"
- "Dumping stack from the offending thread\n\n" );
- size = backtrace( array, 10 );
- strings = backtrace_symbols( array, size );
-
- miracle_log( LOG_CRIT, "Obtained %zd stack frames.\n", size );
-
- for ( i = 0; i < size; i++ )
- miracle_log( LOG_CRIT, "%s", strings[ i ] );
-
- free( strings );
-
- miracle_log( LOG_CRIT, "\nDone dumping - exiting.\n" );
-#else
- miracle_log( LOG_CRIT, "\a\nMiracle experienced a segmentation fault.\n" );
-#endif
- exit( EXIT_FAILURE );
-}
-
-
-
-/** 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 );
- if ( getenv( "MLT_SIGSEGV" ) )
- signal( SIGSEGV, sigsegv_handler );
-
- 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, char *command )
-{
- 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_PAIR:
- if ( strchr( command, '=' ) )
- {
- char *ptr = strchr( command, '=' );
- while ( *( ptr - 1 ) != ' ' )
- ptr --;
- ret = strdup( ptr );
- ptr = ret;
- while( ptr[ strlen( ptr ) - 1 ] == ' ' )
- ptr[ strlen( ptr ) - 1 ] = '\0';
- }
- 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, command );
- 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;
-}
-
-static valerie_response miracle_local_receive( miracle_local local, char *command, char *doc )
-{
- 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_SUCCESS );
-
- /* Parse the command */
- if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 )
- {
- int index = 0;
- int position = 1;
-
- /* 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 ), '\"' );
-
- cmd.unit = miracle_command_parse_unit( &cmd, position );
- if ( cmd.unit == -1 )
- miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG );
- position ++;
-
- miracle_receive( &cmd, doc );
- miracle_command_set_error( &cmd, RESPONSE_SUCCESS );
-
- free( cmd.argument );
- }
-
- valerie_tokeniser_close( cmd.tokeniser );
-
- return cmd.response;
-}
-
-static valerie_response miracle_local_push( miracle_local local, char *command, mlt_service service )
-{
- 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_SUCCESS );
-
- /* Parse the command */
- if ( valerie_tokeniser_parse_new( cmd.tokeniser, command, " " ) > 0 )
- {
- int index = 0;
- int position = 1;
-
- /* 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 ), '\"' );
-
- cmd.unit = miracle_command_parse_unit( &cmd, position );
- if ( cmd.unit == -1 )
- miracle_command_set_error( &cmd, RESPONSE_MISSING_ARG );
- position ++;
-
- miracle_push( &cmd, service );
- miracle_command_set_error( &cmd, RESPONSE_SUCCESS );
-
- 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();
-#ifdef linux
- //pthread_kill_other_threads_np();
- miracle_log( LOG_DEBUG, "Clean shutdown." );
- //free( local );
- //mlt_factory_close( );
-#endif
-}
+++ /dev/null
-/*
- * miracle_local.h -- Local Miracle Parser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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_LOCAL_H_
-#define _MIRACLE_LOCAL_H_
-
-/* Application header files */
-#include <valerie/valerie_parser.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/** Local parser API.
-*/
-
-extern valerie_parser miracle_parser_init_local( );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * miracle_log.c -- logging facility implementation
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <stdarg.h>
-#include <syslog.h>
-#include <stdio.h>
-
-#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, const 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 );
-}
+++ /dev/null
-/*
- * miracle_log.h -- logging facility header
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <syslog.h>
-
-#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, const char *format, ... );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * miracle_server.c
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include <fcntl.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <string.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <errno.h>
-#include <arpa/inet.h>
-
-/* Application header files */
-#include "miracle_server.h"
-#include "miracle_connection.h"
-#include "miracle_local.h"
-#include "miracle_log.h"
-#include "miracle_commands.h"
-#include <valerie/valerie_remote.h>
-#include <valerie/valerie_tokeniser.h>
-
-#define VERSION "0.0.1"
-
-static void miracle_command_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args )
-{
- if ( listener != NULL )
- listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ] );
-}
-
-static void miracle_doc_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args )
-{
- if ( listener != NULL )
- listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ], ( char * )args[ 2 ] );
-}
-
-static void miracle_push_received( mlt_listener listener, mlt_properties owner, miracle_server this, void **args )
-{
- if ( listener != NULL )
- listener( owner, this, ( valerie_response ** )args[ 0 ], ( char * )args[ 1 ], ( mlt_service )args[ 2 ] );
-}
-
-/** 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 ) );
- if ( server != NULL && mlt_properties_init( &server->parent, server ) == 0 )
- {
- server->id = id;
- server->port = DEFAULT_TCP_PORT;
- server->socket = -1;
- server->shutdown = 1;
- mlt_events_init( &server->parent );
- mlt_events_register( &server->parent, "command-received", ( mlt_transmitter )miracle_command_received );
- mlt_events_register( &server->parent, "doc-received", ( mlt_transmitter )miracle_doc_received );
- mlt_events_register( &server->parent, "push-received", ( mlt_transmitter )miracle_push_received );
- }
- return server;
-}
-
-const char *miracle_server_id( miracle_server server )
-{
- return server != NULL && server->id != NULL ? server->id : "miracle";
-}
-
-void miracle_server_set_config( miracle_server server, const char *config )
-{
- if ( server != NULL )
- {
- free( server->config );
- server->config = config != NULL ? strdup( config ) : NULL;
- }
-}
-
-/** 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;
- socklen_t 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 );
-
- 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->owner = &server->parent;
- 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;
-
- server->shutdown = 0;
-
- 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 && server->config != NULL )
- {
- valerie_response_close( response );
- response = valerie_parser_run( server->parser, server->config );
-
- 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 )
- {
- int result;
- valerie_response_close( response );
- result = pthread_create( &server->thread, NULL, 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;
-}
-
-/** Fetch a units properties
-*/
-
-mlt_properties miracle_server_fetch_unit( miracle_server server, int index )
-{
- miracle_unit unit = miracle_get_unit( index );
- return unit != NULL ? unit->properties : NULL;
-}
-
-/** Shutdown the server.
-*/
-
-void miracle_server_shutdown( miracle_server server )
-{
- if ( server != NULL && !server->shutdown )
- {
- server->shutdown = 1;
- pthread_join( server->thread, NULL );
- miracle_server_set_config( server, NULL );
- valerie_parser_close( server->parser );
- server->parser = NULL;
- close( server->socket );
- }
-}
-
-/** Close the server.
-*/
-
-void miracle_server_close( miracle_server server )
-{
- if ( server != NULL && mlt_properties_dec_ref( &server->parent ) <= 0 )
- {
- mlt_properties_close( &server->parent );
- miracle_server_shutdown( server );
- free( server );
- }
-}
+++ /dev/null
-/*
- * miracle_server.h
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU 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 <pthread.h>
-
-/* Application header files */
-#include <valerie/valerie_parser.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/** Servers default port
-*/
-
-#define DEFAULT_TCP_PORT 5250
-
-/** Structure for the server
-*/
-
-typedef struct
-{
- struct mlt_properties_s parent;
- char *id;
- int port;
- int socket;
- valerie_parser parser;
- pthread_t thread;
- int shutdown;
- int proxy;
- char remote_server[ 50 ];
- int remote_port;
- char *config;
-}
-*miracle_server, miracle_server_t;
-
-/** API for the server
-*/
-
-extern miracle_server miracle_server_init( char * );
-extern const char *miracle_server_id( miracle_server );
-extern void miracle_server_set_config( miracle_server, const 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 mlt_properties miracle_server_fetch_unit( miracle_server, int );
-extern void miracle_server_shutdown( miracle_server );
-extern void miracle_server_close( miracle_server );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * miracle_unit.c -- Transmission Unit Implementation
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <config.h>
-#endif
-
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/poll.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <signal.h>
-#include <limits.h>
-
-#include <sys/mman.h>
-
-#include "miracle_unit.h"
-#include "miracle_log.h"
-#include "miracle_local.h"
-
-#include <framework/mlt.h>
-
-/* 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( NULL, id, arg );
-
- if ( consumer != NULL )
- {
- mlt_playlist playlist = mlt_playlist_init( );
- this = calloc( sizeof( miracle_unit_t ), 1 );
- this->properties = 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;
-}
-
-static char *strip_root( miracle_unit unit, char *file )
-{
- mlt_properties properties = unit->properties;
- char *root = mlt_properties_get( properties, "root" );
- if ( file != NULL && root != NULL )
- {
- int length = strlen( root );
- if ( root[ length - 1 ] == '/' )
- length --;
- if ( !strncmp( file, root, length ) )
- file += length;
- }
- return file;
-}
-
-/** 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 locate_producer( miracle_unit unit, char *file )
-{
- // Try to get the profile from the consumer
- mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
- mlt_profile profile = NULL;
-
- if ( consumer != NULL )
- {
- profile = mlt_service_profile( MLT_CONSUMER_SERVICE( consumer ) );
- }
- return mlt_factory_producer( profile, "fezzik", file );
-}
-
-/** 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_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_clear( playlist );
- mlt_producer_seek( producer, 0 );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
-
- update_generation( unit );
-}
-
-/** Wipe all but the playing clip from the unit.
-*/
-
-static void clean_unit( miracle_unit unit )
-{
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- mlt_playlist_clip_info info;
- int current = mlt_playlist_current_clip( playlist );
- mlt_producer producer = MLT_PLAYLIST_PRODUCER( playlist );
- mlt_position position = mlt_producer_frame( producer );
- double speed = mlt_producer_get_speed( producer );
- mlt_playlist_get_clip_info( playlist, &info, current );
-
- if ( info.producer != NULL )
- {
- mlt_properties_inc_ref( MLT_PRODUCER_PROPERTIES( info.producer ) );
- position -= info.start;
- clear_unit( unit );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_append_io( playlist, info.producer, info.frame_in, info.frame_out );
- mlt_producer_seek( producer, position );
- mlt_producer_set_speed( producer, speed );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_producer_close( info.producer );
- }
-
- update_generation( unit );
-}
-
-/** Remove everything up to the current clip from the unit.
-*/
-
-static void wipe_unit( miracle_unit unit )
-{
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- mlt_playlist_clip_info info;
- int current = mlt_playlist_current_clip( playlist );
- mlt_playlist_get_clip_info( playlist, &info, current );
-
- if ( info.producer != NULL && info.start > 0 )
- {
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_remove_region( playlist, 0, info.start - 1 );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- }
-
- 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;
- char *title;
- mlt_playlist_get_clip_info( playlist , &info, i );
- title = mlt_properties_get( MLT_PRODUCER_PROPERTIES( info.producer ), "title" );
- if ( title == NULL )
- title = strip_root( unit, info.resource );
- valerie_response_printf( response, 10240, "%d \"%s\" %d %d %d %d %.2f\n",
- i,
- title,
- info.frame_in,
- info.frame_out,
- info.frame_count,
- info.length,
- info.fps );
- }
- valerie_response_printf( response, 1024, "\n" );
-}
-
-/** 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, int32_t in, int32_t out, int flush )
-{
- // Now try to create a producer
- mlt_producer instance = locate_producer( unit, clip );
-
- if ( instance != NULL )
- {
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- int original = mlt_producer_get_playtime( MLT_PLAYLIST_PRODUCER( playlist ) );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_append_io( playlist, instance, in, out );
- mlt_playlist_remove_region( playlist, 0, original );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- miracle_log( LOG_DEBUG, "loaded clip %s", clip );
- update_generation( unit );
- miracle_unit_status_communicate( unit );
- mlt_producer_close( instance );
- return valerie_ok;
- }
-
- return valerie_invalid_file;
-}
-
-valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out )
-{
- mlt_producer instance = locate_producer( unit, clip );
-
- if ( instance != NULL )
- {
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- fprintf( stderr, "inserting clip %s before %d\n", clip, index );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_insert( playlist, instance, index, in, out );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- miracle_log( LOG_DEBUG, "inserted clip %s at %d", clip, index );
- update_generation( unit );
- miracle_unit_status_communicate( unit );
- mlt_producer_close( instance );
- 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_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_remove( playlist, index );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- 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 )
-{
- clean_unit( unit );
- miracle_log( LOG_DEBUG, "Cleaned playlist" );
- miracle_unit_status_communicate( unit );
- return valerie_ok;
-}
-
-valerie_error_code miracle_unit_wipe( miracle_unit unit )
-{
- wipe_unit( unit );
- miracle_log( LOG_DEBUG, "Wiped playlist" );
- miracle_unit_status_communicate( unit );
- return valerie_ok;
-}
-
-valerie_error_code miracle_unit_clear( miracle_unit unit )
-{
- mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
- clear_unit( unit );
- mlt_consumer_purge( consumer );
- miracle_log( LOG_DEBUG, "Cleared 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_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_move( playlist, src, dest );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- 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, int32_t in, int32_t out )
-{
- mlt_producer instance = locate_producer( unit, clip );
-
- if ( instance != NULL )
- {
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_append_io( playlist, instance, in, out );
- miracle_log( LOG_DEBUG, "appended clip %s", clip );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- update_generation( unit );
- miracle_unit_status_communicate( unit );
- mlt_producer_close( instance );
- return valerie_ok;
- }
-
- return valerie_invalid_file;
-}
-
-/** Add an mlt_service to the playlist
-
- \param unit A miracle_unit handle.
- \param service the service to add
-*/
-
-valerie_error_code miracle_unit_append_service( miracle_unit unit, mlt_service service )
-{
- mlt_properties properties = unit->properties;
- mlt_playlist playlist = mlt_properties_get_data( properties, "playlist", NULL );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- mlt_playlist_append( playlist, ( mlt_producer )service );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- miracle_log( LOG_DEBUG, "appended clip" );
- update_generation( unit );
- miracle_unit_status_communicate( unit );
- return valerie_ok;
-}
-
-/** 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_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL );
- mlt_producer producer = MLT_PLAYLIST_PRODUCER( playlist );
- mlt_producer_set_speed( producer, 0 );
- 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 )
-{
- int i;
- mlt_properties dest_properties = dest_unit->properties;
- mlt_playlist dest_playlist = mlt_properties_get_data( dest_properties, "playlist", NULL );
- mlt_properties src_properties = src_unit->properties;
- mlt_playlist src_playlist = mlt_properties_get_data( src_properties, "playlist", NULL );
- mlt_playlist tmp_playlist = mlt_playlist_init( );
-
- for ( i = 0; i < mlt_playlist_count( src_playlist ); i ++ )
- {
- mlt_playlist_clip_info info;
- mlt_playlist_get_clip_info( src_playlist, &info, i );
- if ( info.producer != NULL )
- mlt_playlist_append_io( tmp_playlist, info.producer, info.frame_in, info.frame_out );
- }
-
- clear_unit( src_unit );
-
- mlt_service_lock( MLT_PLAYLIST_SERVICE( dest_playlist ) );
-
- for ( i = 0; i < mlt_playlist_count( tmp_playlist ); i ++ )
- {
- mlt_playlist_clip_info info;
- mlt_playlist_get_clip_info( tmp_playlist, &info, i );
- if ( info.producer != NULL )
- mlt_playlist_append_io( dest_playlist, info.producer, info.frame_in, info.frame_out );
- }
-
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( dest_playlist ) );
-
- update_generation( dest_unit );
- miracle_unit_status_communicate( dest_unit );
-
- mlt_playlist_close( tmp_playlist );
-
- 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, "" ) )
- {
- char *title = mlt_properties_get( MLT_PRODUCER_PROPERTIES( info.producer ), "title" );
- if ( title == NULL )
- title = strip_root( unit, info.resource );
- strncpy( status->clip, title, 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_frame( clip );
- status->length = mlt_producer_get_length( clip );
- strncpy( status->tail_clip, title, sizeof( status->tail_clip ) );
- status->tail_in = info.frame_in;
- status->tail_out = info.frame_out;
- status->tail_position = mlt_producer_frame( 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, int32_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 = INT_MAX;
- }
-
- if ( mlt_playlist_get_clip_info( playlist, &info, clip ) == 0 )
- {
- int32_t frame_start = info.start;
- int32_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, int32_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 );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- error = mlt_playlist_resize_clip( playlist, index, position, info.frame_out );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- 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, int32_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 );
- mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist ) );
- error = mlt_playlist_resize_clip( playlist, index, info.frame_in, position );
- mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist ) );
- 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, int32_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_properties properties = NULL;
-
- if ( strncmp( name_value, "consumer.", 9 ) )
- {
- mlt_playlist playlist = mlt_properties_get_data( unit->properties, "playlist", NULL );
- properties = MLT_PLAYLIST_PROPERTIES( playlist );
- }
- else
- {
- mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
- properties = MLT_CONSUMER_PROPERTIES( consumer );
- name_value += 9;
- }
-
- 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..." );
- miracle_unit_terminate( unit );
- mlt_properties_close( unit->properties );
- free( unit );
- miracle_log( LOG_DEBUG, "... unit closed." );
- }
-}
-
+++ /dev/null
-/*
- * dvunit.h -- Transmission Unit Header
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <pthread.h>
-
-#include <framework/mlt_properties.h>
-#include <valerie/valerie.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef struct
-{
- mlt_properties properties;
-}
-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, int32_t in, int32_t out, int flush );
-extern valerie_error_code miracle_unit_insert( miracle_unit unit, char *clip, int index, int32_t in, int32_t out );
-extern valerie_error_code miracle_unit_append( miracle_unit unit, char *clip, int32_t in, int32_t out );
-extern valerie_error_code miracle_unit_append_service( miracle_unit unit, mlt_service service );
-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_wipe( miracle_unit unit );
-extern valerie_error_code miracle_unit_clear( 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, int32_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, int32_t position );
-extern int miracle_unit_set_clip_out( miracle_unit unit, int index, int32_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, int32_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
+++ /dev/null
-/*
- * unit_commands.c
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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 <config.h>
-#endif
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#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;
- char *service;
-
- if ( filename[0] == '!' )
- {
- flush = 0;
- filename ++;
- }
-
- service = strchr( filename, ':' );
- if ( service != NULL )
- {
- service = filename;
- filename = strchr( service, ':' );
- *filename ++ = '\0';
-
- if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
- filename++;
-
- snprintf( fullname, 1023, "%s:%s%s", service, cmd_arg->root_dir, filename );
- }
- else
- {
- if ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
- filename++;
-
- snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
- }
-
- if (unit == NULL)
- return RESPONSE_INVALID_UNIT;
- else
- {
- int32_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 ( strlen( cmd_arg->root_dir ) && 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_wipe( command_argument cmd_arg )
-{
- miracle_unit unit = miracle_get_unit(cmd_arg->unit);
-
- if (unit == NULL)
- return RESPONSE_INVALID_UNIT;
- else
- {
- if ( miracle_unit_wipe( unit ) != valerie_ok )
- return RESPONSE_BAD_FILE;
- }
- return RESPONSE_SUCCESS;
-}
-
-int miracle_clear( command_argument cmd_arg )
-{
- miracle_unit unit = miracle_get_unit(cmd_arg->unit);
-
- if (unit == NULL)
- return RESPONSE_INVALID_UNIT;
- else
- {
- if ( miracle_unit_clear( 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 ( strlen( cmd_arg->root_dir ) && filename[0] == '/' )
- filename++;
-
- snprintf( fullname, 1023, "%s%s", cmd_arg->root_dir, filename );
-
- if (unit == NULL)
- return RESPONSE_INVALID_UNIT;
- else
- {
- int32_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_push( command_argument cmd_arg, mlt_service service )
-{
- miracle_unit unit = miracle_get_unit(cmd_arg->unit);
- if ( unit != NULL && service != NULL )
- if ( miracle_unit_append_service( unit, service ) == valerie_ok )
- return RESPONSE_SUCCESS;
- return RESPONSE_BAD_FILE;
-}
-
-int miracle_receive( command_argument cmd_arg, char *doc )
-{
- miracle_unit unit = miracle_get_unit(cmd_arg->unit);
- if ( unit != NULL )
- {
- // Get the consumer's profile
- mlt_consumer consumer = mlt_properties_get_data( unit->properties, "consumer", NULL );
- mlt_profile profile = mlt_service_profile( MLT_CONSUMER_SERVICE( consumer ) );
- mlt_producer producer = mlt_factory_producer( profile, "westley-xml", doc );
- if ( producer != NULL )
- {
- if ( miracle_unit_append_service( unit, MLT_PRODUCER_SERVICE( producer ) ) == valerie_ok )
- {
- mlt_producer_close( producer );
- return RESPONSE_SUCCESS;
- }
- mlt_producer_close( producer );
- }
- }
- return RESPONSE_BAD_FILE;
-}
-
-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_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 )
-{
- miracle_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 )
- {
- miracle_unit dest_unit = miracle_get_unit( dest_unit_id );
- if ( dest_unit != NULL && !miracle_unit_is_offline(dest_unit) && dest_unit != src_unit )
- {
- miracle_unit_transfer( dest_unit, src_unit );
- return RESPONSE_SUCCESS;
- }
- }
- return RESPONSE_INVALID_UNIT;
-}
+++ /dev/null
-/*
- * unit_commands.h
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Dan Dennedy <dan@dennedy.org>
- *
- * 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_wipe( command_argument );
-extern response_codes miracle_clear( 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 );
-extern response_codes miracle_push( command_argument, mlt_service );
-extern response_codes miracle_receive( command_argument, char * );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-include ../../config.mak
-
-ifneq ($(targetos), Darwin)
-NAME = libvalerie$(LIBSUF)
-TARGET = $(NAME).$(version)
-SONAME = $(NAME).$(soversion)
-SHFLAGS += -Wl,-soname,$(SONAME)
-else
-NAME = libvalerie$(LIBSUF)
-TARGET = libvalerie.$(version)$(LIBSUF)
-SONAME = libvalerie.$(soversion)$(LIBSUF)
-SHFLAGS += -install_name $(libdir)/$(SONAME) -current_version $(version) -compatibility_version $(soversion)
-endif
-
-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
-
-INCS = valerie.h \
- valerie_notifier.h \
- valerie_parser.h \
- valerie_remote.h \
- valerie_response.h \
- valerie_socket.h \
- valerie_status.h \
- valerie_tokeniser.h \
- valerie_util.h
-
-SRCS := $(OBJS:.o=.c)
-
-CFLAGS += -I.. $(RDYNAMIC)
-
-LDFLAGS += -L../framework -lmlt -lpthread
-
-all: $(TARGET)
-
-$(TARGET): $(OBJS)
- $(CC) $(SHFLAGS) -o $@ $(OBJS) $(LDFLAGS)
- ln -sf $(TARGET) $(NAME)
- ln -sf $(TARGET) $(SONAME)
-
-depend: $(SRCS)
- $(CC) -MM $(CFLAGS) $^ 1>.depend
-
-distclean: clean
- rm -f .depend
-
-clean:
- rm -f $(OBJS) $(TARGET) $(NAME)
-
-install: all
- install -m 755 $(TARGET) $(DESTDIR)$(libdir)
- ln -sf $(TARGET) $(DESTDIR)$(libdir)/$(SONAME)
- ln -sf $(TARGET) $(DESTDIR)$(libdir)/$(NAME)
- mkdir -p "$(DESTDIR)$(prefix)/include/mlt/valerie"
- install -m 644 $(INCS) "$(DESTDIR)$(prefix)/include/mlt/valerie"
-
-uninstall:
- rm -f "$(DESTDIR)$(libdir)/$(TARGET)"
- rm -f "$(DESTDIR)$(libdir)/$(SONAME)"
- rm -f "$(DESTDIR)$(libdir)/$(NAME)"
- rm -rf "$(DESTDIR)$(prefix)/include/mlt/valerie"
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
+++ /dev/null
-#!/bin/sh
-echo "valerie -I$prefix/include/mlt -D_REENTRANT -L$libdir -lvalerie" >> ../../packages.dat
+++ /dev/null
-/*
- * valerie.c -- High Level Client API for miracle
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-
-/* 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, const 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;
-}
-
-/** Execute a command.
-*/
-
-valerie_error_code valerie_receive( valerie this, char *doc, size_t size, const 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_received( this->parser, command, doc );
- 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;
-}
-
-/** Execute a command.
-*/
-
-valerie_error_code valerie_push( valerie this, mlt_service service, size_t size, const 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_push( this->parser, command, service );
- 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 - 1 );
- 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, int32_t in, int32_t out )
-{
- return valerie_execute( this, 10240, "LOAD U%d \"%s\" %d %d", 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, int32_t in, int32_t out )
-{
- return valerie_execute( this, 10240, "LOAD U%d \"!%s\" %d %d", unit, file, in, out );
-}
-
-/** Append a file on the specified unit.
-*/
-
-valerie_error_code valerie_unit_append( valerie this, int unit, char *file, int32_t in, int32_t out )
-{
- return valerie_execute( this, 10240, "APND U%d \"%s\" %d %d", unit, file, in, out );
-}
-
-/** Push a service on to a unit.
-*/
-
-valerie_error_code valerie_unit_receive( valerie this, int unit, char *command, char *doc )
-{
- return valerie_receive( this, doc, 10240, "PUSH U%d %s", unit, command );
-}
-
-/** Push a service on to a unit.
-*/
-
-valerie_error_code valerie_unit_push( valerie this, int unit, char *command, mlt_service service )
-{
- return valerie_push( this, service, 10240, "PUSH U%d %s", unit, command );
-}
-
-/** 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 );
-}
-
-/** Clear the unit - this function removes all clips.
-*/
-
-valerie_error_code valerie_unit_clear( valerie this, int unit )
-{
- return valerie_execute( this, 1024, "CLEAR U%d", unit );
-}
-
-/** Wipe the unit - this function removes all clips before the current one.
-*/
-
-valerie_error_code valerie_unit_wipe( valerie this, int unit )
-{
- return valerie_execute( this, 1024, "WIPE 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, int32_t in, int32_t out )
-{
- char temp[ 100 ];
- valerie_interpret_clip_offset( temp, offset, clip );
- return valerie_execute( this, 1024, "INSERT U%d \"%s\" %s %d %d", 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, int32_t step )
-{
- return valerie_execute( this, 1024, "STEP U%d %d", unit, step );
-}
-
-/** Goto the specified frame on the specified unit.
-*/
-
-valerie_error_code valerie_unit_goto( valerie this, int unit, int32_t position )
-{
- return valerie_execute( this, 1024, "GOTO U%d %d", 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, int32_t position )
-{
- char temp[ 100 ];
- valerie_interpret_clip_offset( temp, offset, clip );
- return valerie_execute( this, 1024, "GOTO U%d %d %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, int32_t in )
-{
- return valerie_execute( this, 1024, "SIN U%d %d", 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, int32_t in )
-{
- char temp[ 100 ];
- valerie_interpret_clip_offset( temp, offset, clip );
- return valerie_execute( this, 1024, "SIN U%d %d %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, int32_t out )
-{
- return valerie_execute( this, 1024, "SOUT U%d %d", 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, int32_t in )
-{
- char temp[ 100 ];
- valerie_interpret_clip_offset( temp, offset, clip );
- return valerie_execute( this, 1024, "SOUT U%d %d %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, const char *name, const 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, const 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.
-*/
-
-const char *valerie_error_description( valerie_error_code error )
-{
- const 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 );
- }
-}
+++ /dev/null
-/*
- * valerie.h -- High Level Client API for miracle
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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_H_
-#define _VALERIE_H_
-
-/* System header files */
-#include <limits.h>
-
-/* MLT Header files. */
-#include <framework/mlt.h>
-
-/* 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 *, int32_t, int32_t );
-extern valerie_error_code valerie_unit_load_back( valerie, int, char * );
-extern valerie_error_code valerie_unit_load_back_clipped( valerie, int, char *, int32_t, int32_t );
-extern valerie_error_code valerie_unit_append( valerie, int, char *, int32_t, int32_t );
-extern valerie_error_code valerie_unit_receive( valerie, int, char *, char * );
-extern valerie_error_code valerie_unit_push( valerie, int, char *, mlt_service );
-extern valerie_error_code valerie_unit_clean( valerie, int );
-extern valerie_error_code valerie_unit_wipe( valerie, int );
-extern valerie_error_code valerie_unit_clear( 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 *, int32_t, int32_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, int32_t );
-extern valerie_error_code valerie_unit_goto( valerie, int, int32_t );
-extern valerie_error_code valerie_unit_clip_goto( valerie, int, valerie_clip_offset, int, int32_t );
-extern valerie_error_code valerie_unit_clip_set_in( valerie, int, valerie_clip_offset, int, int32_t );
-extern valerie_error_code valerie_unit_clip_set_out( valerie, int, valerie_clip_offset, int, int32_t );
-extern valerie_error_code valerie_unit_set_in( valerie, int, int32_t );
-extern valerie_error_code valerie_unit_set_out( valerie, int, int32_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, const char *, const 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, const 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 ];
- int32_t in;
- int32_t out;
- int32_t max;
- int32_t size;
- int32_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 const char *valerie_error_description( valerie_error_code );
-
-/* Courtesy functions. */
-extern valerie_error_code valerie_execute( valerie, size_t, const char *, ... );
-extern valerie_error_code valerie_push( valerie, mlt_service, size_t, const char *, ... );
-
-/* Close function. */
-extern void valerie_close( valerie );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * valerie_notifier.c -- Unit Status Notifier Handling
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <config.h>
-#endif
-
-/* System header files */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/time.h>
-
-/* Application header files */
-#include "valerie_notifier.h"
-
-/** Notifier initialisation.
-*/
-
-valerie_notifier valerie_notifier_init( )
-{
- valerie_notifier this = calloc( 1, sizeof( valerie_notifier_t ) );
- if ( this != NULL )
- {
- int index = 0;
- pthread_mutex_init( &this->mutex, NULL );
- pthread_cond_init( &this->cond, 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 ) );
- gettimeofday( &now, NULL );
- timeout.tv_sec = now.tv_sec + 1;
- timeout.tv_nsec = now.tv_usec * 1000;
- pthread_mutex_lock( &this->mutex );
- pthread_cond_timedwait( &this->cond, &this->mutex, &timeout );
- valerie_status_copy( status, &this->last );
- pthread_mutex_unlock( &this->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_cond_destroy( &this->cond );
- free( this );
- }
-}
+++ /dev/null
-/*
- * valerie_notifier.h -- Unit Status Notifier Handling
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <pthread.h>
-
-/* 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_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
+++ /dev/null
-/*
- * valerie_parser.c -- Valerie Parser for Miracle
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* 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 );
-}
-
-/** Push a service via the parser.
-*/
-
-valerie_response valerie_parser_received( valerie_parser parser, char *command, char *doc )
-{
- return parser->received != NULL ? parser->received( parser->real, command, doc ) : NULL;
-}
-
-/** Push a service via the parser.
-*/
-
-valerie_response valerie_parser_push( valerie_parser parser, char *command, mlt_service service )
-{
- return parser->push( parser->real, command, service );
-}
-
-/** Execute a formatted command via the parser.
-*/
-
-valerie_response valerie_parser_executef( valerie_parser parser, const 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 );
- }
-}
+++ /dev/null
-/*
- * valerie_parser.h -- Valerie Parser for Miracle Server
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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_
-
-/* MLT Header files */
-#include <framework/mlt.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 valerie_response (*parser_received)( void *, char *, char * );
-typedef valerie_response (*parser_push)( void *, char *, mlt_service );
-typedef void (*parser_close)( void * );
-
-/** Structure for the valerie parser.
-*/
-
-typedef struct
-{
- parser_connect connect;
- parser_execute execute;
- parser_push push;
- parser_received received;
- 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_push( valerie_parser, char *, mlt_service );
-extern valerie_response valerie_parser_received( valerie_parser, char *, char * );
-extern valerie_response valerie_parser_execute( valerie_parser, char * );
-extern valerie_response valerie_parser_executef( valerie_parser, const 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
+++ /dev/null
-/*
- * valerie_remote.c -- Remote Parser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-#include <errno.h>
-#include <pthread.h>
-
-/* Application header files */
-#include <framework/mlt.h>
-#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 valerie_response valerie_remote_receive( valerie_remote, char *, char * );
-static valerie_response valerie_remote_push( valerie_remote, char *, mlt_service );
-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 = calloc( 1, sizeof( valerie_parser_t ) );
- valerie_remote remote = calloc( 1, sizeof( valerie_remote_t ) );
-
- if ( parser != NULL )
- {
- parser->connect = (parser_connect)valerie_remote_connect;
- parser->execute = (parser_execute)valerie_remote_execute;
- parser->push = (parser_push)valerie_remote_push;
- parser->received = (parser_received)valerie_remote_receive;
- parser->close = (parser_close)valerie_remote_close;
- parser->real = remote;
-
- if ( remote != NULL )
- {
- 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;
-}
-
-/** Push a westley document to the server.
-*/
-
-static valerie_response valerie_remote_receive( valerie_remote remote, char *command, char *buffer )
-{
- valerie_response response = NULL;
- pthread_mutex_lock( &remote->mutex );
- if ( valerie_socket_write_data( remote->socket, command, strlen( command ) ) == strlen( command ) )
- {
- char temp[ 20 ];
- int length = strlen( buffer );
- response = valerie_response_init( );
- valerie_socket_write_data( remote->socket, "\r\n", 2 );
- sprintf( temp, "%d", length );
- valerie_socket_write_data( remote->socket, temp, strlen( temp ) );
- valerie_socket_write_data( remote->socket, "\r\n", 2 );
- valerie_socket_write_data( remote->socket, buffer, length );
- valerie_socket_write_data( remote->socket, "\r\n", 2 );
- valerie_remote_read_response( remote->socket, response );
- }
- pthread_mutex_unlock( &remote->mutex );
- return response;
-}
-
-/** Push a producer to the server.
-*/
-
-static valerie_response valerie_remote_push( valerie_remote remote, char *command, mlt_service service )
-{
- valerie_response response = NULL;
- if ( service != NULL )
- {
- mlt_consumer consumer = mlt_factory_consumer( NULL, "westley", "buffer" );
- mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
- char *buffer = NULL;
- // Temporary hack
- mlt_properties_set( properties, "store", "nle_" );
- mlt_consumer_connect( consumer, service );
- mlt_consumer_start( consumer );
- buffer = mlt_properties_get( properties, "buffer" );
- response = valerie_remote_receive( remote, command, buffer );
- mlt_consumer_close( consumer );
- }
- return response;
-}
-
-/** Disconnect.
-*/
-
-static void valerie_remote_disconnect( valerie_remote remote )
-{
- if ( remote != NULL && remote->terminated )
- {
- if ( remote->connected )
- 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;
-}
+++ /dev/null
-/*
- * valerie_remote.h -- Remote Parser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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
+++ /dev/null
-/*
- * valerie_response.c -- Response
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-
-/* 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.
-*/
-
-const char *valerie_response_get_error_string( valerie_response response )
-{
- const 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, const 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, const 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, const char *text, int size )
-{
- int ret = 0;
- const char *ptr = text;
-
- while ( size > 0 )
- {
- int index = response->count - 1;
- const 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 );
- }
-}
+++ /dev/null
-/*
- * valerie_response.h -- Response
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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_
-
-#include <stdio.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 const 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, const char * );
-extern int valerie_response_printf( valerie_response, size_t, const char *, ... );
-extern int valerie_response_write( valerie_response, const char *, int );
-extern void valerie_response_close( valerie_response );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * valerie_socket.c -- Client Socket
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <config.h>
-#endif
-
-/* System header files */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <netinet/in.h>
-#include <sys/time.h>
-
-/* 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, const 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 );
-}
+++ /dev/null
-/*
- * valerie_socket.h -- Client Socket
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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, const char *, int );
-extern void valerie_socket_close( valerie_socket );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-/*
- * valerie_status.c -- Unit Status Handling
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* 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 )
-{
- const 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\" %d %d %.2f %d %d %d \"%s\" %d %d %d %d %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 ) );
-}
+++ /dev/null
-/*
- * valerie_status.h -- Unit Status Handling
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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_
-
-#include <stdint.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 ];
- int32_t position;
- int speed;
- double fps;
- int32_t in;
- int32_t out;
- int32_t length;
- char tail_clip[ 2048 ];
- int32_t tail_position;
- int32_t tail_in;
- int32_t tail_out;
- int32_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
+++ /dev/null
-/*
- * valerie_tokeniser.c -- String tokeniser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <stdlib.h>
-#include <string.h>
-
-/* 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, const 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 );
-}
+++ /dev/null
-/*
- * valerie_tokeniser.h -- String tokeniser
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 *, const 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
+++ /dev/null
-/*
- * valerie_util.c -- General Purpose Client Utilities
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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 <string.h>
-#include <ctype.h>
-
-/* 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;
-}
+++ /dev/null
-/*
- * valerie_util.h -- General Purpose Client Utilities
- * Copyright (C) 2002-2003 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
- *
- * 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