2 * melted_unit.c -- Playout Implementation
3 * Copyright (C) 2002-2009 Ushodaya Enterprises Limited
4 * Author: Dan Dennedy <dan@dennedy.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 #include <sys/ioctl.h>
30 #include <sys/types.h>
41 #include "melted_unit.h"
42 #include "melted_log.h"
43 #include "melted_local.h"
45 #include <framework/mlt.h>
47 /* Forward references */
48 static void melted_unit_status_communicate( melted_unit
);
50 /** Allocate a new playout unit.
52 \return A new melted_unit handle.
55 melted_unit
melted_unit_init( int index
, char *constructor
)
57 melted_unit
this = NULL
;
58 mlt_consumer consumer
= NULL
;
60 char *id
= strdup( constructor
);
61 char *arg
= strchr( id
, ':' );
66 consumer
= mlt_factory_consumer( NULL
, id
, arg
);
68 if ( consumer
!= NULL
)
70 mlt_playlist playlist
= mlt_playlist_init( );
71 this = calloc( sizeof( melted_unit_t
), 1 );
72 this->properties
= mlt_properties_new( );
73 mlt_properties_init( this->properties
, this );
74 mlt_properties_set_int( this->properties
, "unit", index
);
75 mlt_properties_set_int( this->properties
, "generation", 0 );
76 mlt_properties_set( this->properties
, "constructor", constructor
);
77 mlt_properties_set( this->properties
, "id", id
);
78 mlt_properties_set( this->properties
, "arg", arg
);
79 mlt_properties_set_data( this->properties
, "consumer", consumer
, 0, ( mlt_destructor
)mlt_consumer_close
, NULL
);
80 mlt_properties_set_data( this->properties
, "playlist", playlist
, 0, ( mlt_destructor
)mlt_playlist_close
, NULL
);
81 mlt_consumer_connect( consumer
, MLT_PLAYLIST_SERVICE( playlist
) );
87 static char *strip_root( melted_unit unit
, char *file
)
89 mlt_properties properties
= unit
->properties
;
90 char *root
= mlt_properties_get( properties
, "root" );
91 if ( file
!= NULL
&& root
!= NULL
)
93 int length
= strlen( root
);
94 if ( root
[ length
- 1 ] == '/' )
96 if ( !strncmp( file
, root
, length
) )
102 /** Communicate the current status to all threads waiting on the notifier.
105 static void melted_unit_status_communicate( melted_unit unit
)
109 mlt_properties properties
= unit
->properties
;
110 char *root_dir
= mlt_properties_get( properties
, "root" );
111 mvcp_notifier notifier
= mlt_properties_get_data( properties
, "notifier", NULL
);
112 mvcp_status_t status
;
114 if ( root_dir
!= NULL
&& notifier
!= NULL
)
116 if ( melted_unit_get_status( unit
, &status
) == 0 )
117 /* if ( !( ( status.status == unit_playing || status.status == unit_paused ) &&
118 strcmp( status.clip, "" ) &&
119 !strcmp( status.tail_clip, "" ) &&
120 status.position == 0 &&
122 status.out == 0 ) ) */
123 mvcp_notifier_put( notifier
, &status
);
128 /** Set the notifier info
131 void melted_unit_set_notifier( melted_unit
this, mvcp_notifier notifier
, char *root_dir
)
133 mlt_properties properties
= this->properties
;
134 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
135 mlt_properties playlist_properties
= MLT_PLAYLIST_PROPERTIES( playlist
);
137 mlt_properties_set( properties
, "root", root_dir
);
138 mlt_properties_set_data( properties
, "notifier", notifier
, 0, NULL
, NULL
);
139 mlt_properties_set_data( playlist_properties
, "notifier_arg", this, 0, NULL
, NULL
);
140 mlt_properties_set_data( playlist_properties
, "notifier", melted_unit_status_communicate
, 0, NULL
, NULL
);
142 melted_unit_status_communicate( this );
145 /** Create or locate a producer for the file specified.
148 static mlt_producer
locate_producer( melted_unit unit
, char *file
)
150 // Try to get the profile from the consumer
151 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
152 mlt_profile profile
= NULL
;
154 if ( consumer
!= NULL
)
156 profile
= mlt_service_profile( MLT_CONSUMER_SERVICE( consumer
) );
158 return mlt_factory_producer( profile
, NULL
, file
);
161 /** Update the generation count.
164 static void update_generation( melted_unit unit
)
166 mlt_properties properties
= unit
->properties
;
167 int generation
= mlt_properties_get_int( properties
, "generation" );
168 mlt_properties_set_int( properties
, "generation", ++ generation
);
171 /** Wipe all clips on the playlist for this unit.
174 static void clear_unit( melted_unit unit
)
176 mlt_properties properties
= unit
->properties
;
177 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
178 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
180 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
181 mlt_playlist_clear( playlist
);
182 mlt_producer_seek( producer
, 0 );
183 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
185 update_generation( unit
);
188 /** Wipe all but the playing clip from the unit.
191 static void clean_unit( melted_unit unit
)
193 mlt_properties properties
= unit
->properties
;
194 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
195 mlt_playlist_clip_info info
;
196 int current
= mlt_playlist_current_clip( playlist
);
197 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
198 mlt_position position
= mlt_producer_frame( producer
);
199 double speed
= mlt_producer_get_speed( producer
);
200 mlt_playlist_get_clip_info( playlist
, &info
, current
);
202 if ( info
.producer
!= NULL
)
204 mlt_properties_inc_ref( MLT_PRODUCER_PROPERTIES( info
.producer
) );
205 position
-= info
.start
;
207 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
208 mlt_playlist_append_io( playlist
, info
.producer
, info
.frame_in
, info
.frame_out
);
209 mlt_producer_seek( producer
, position
);
210 mlt_producer_set_speed( producer
, speed
);
211 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
212 mlt_producer_close( info
.producer
);
215 update_generation( unit
);
218 /** Remove everything up to the current clip from the unit.
221 static void wipe_unit( melted_unit unit
)
223 mlt_properties properties
= unit
->properties
;
224 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
225 mlt_playlist_clip_info info
;
226 int current
= mlt_playlist_current_clip( playlist
);
227 mlt_playlist_get_clip_info( playlist
, &info
, current
);
229 if ( info
.producer
!= NULL
&& info
.start
> 0 )
231 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
232 mlt_playlist_remove_region( playlist
, 0, info
.start
- 1 );
233 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
236 update_generation( unit
);
239 /** Generate a report on all loaded clips.
242 void melted_unit_report_list( melted_unit unit
, mvcp_response response
)
245 mlt_properties properties
= unit
->properties
;
246 int generation
= mlt_properties_get_int( properties
, "generation" );
247 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
249 mvcp_response_printf( response
, 1024, "%d\n", generation
);
251 for ( i
= 0; i
< mlt_playlist_count( playlist
); i
++ )
253 mlt_playlist_clip_info info
;
255 mlt_playlist_get_clip_info( playlist
, &info
, i
);
256 title
= mlt_properties_get( MLT_PRODUCER_PROPERTIES( info
.producer
), "title" );
258 title
= strip_root( unit
, info
.resource
);
259 mvcp_response_printf( response
, 10240, "%d \"%s\" %d %d %d %d %.2f\n",
268 mvcp_response_printf( response
, 1024, "\n" );
271 /** Load a clip into the unit clearing existing play list.
274 \param unit A melted_unit handle.
275 \param clip The absolute file name of the clip to load.
276 \param in The starting frame (-1 for 0)
277 \param out The ending frame (-1 for maximum)
280 mvcp_error_code
melted_unit_load( melted_unit unit
, char *clip
, int32_t in
, int32_t out
, int flush
)
282 // Now try to create a producer
283 mlt_producer instance
= locate_producer( unit
, clip
);
285 if ( instance
!= NULL
)
287 mlt_properties properties
= unit
->properties
;
288 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
289 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
290 int original
= mlt_producer_get_playtime( producer
);
291 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
292 double speed
= mlt_producer_get_speed( producer
);
293 struct timespec tm
= { 1, 0 };
295 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
296 mlt_playlist_append_io( playlist
, instance
, in
, out
);
297 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
298 // We try to ensure all frames from producers that will be removed are closed.
299 mlt_producer_seek( producer
, original
);
300 mlt_consumer_purge( consumer
);
302 melted_log( LOG_DEBUG
, "loaded clip %s", clip
);
303 update_generation( unit
);
304 melted_unit_status_communicate( unit
);
305 mlt_producer_close( instance
);
307 // Give more time for those frames to be closed - there could still be some
308 // in the consumer plugin that were not purged from the base consumer buffer.
309 nanosleep( &tm
, NULL
);
310 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
311 mlt_playlist_remove_region( playlist
, 0, original
);
312 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
317 return mvcp_invalid_file
;
320 mvcp_error_code
melted_unit_insert( melted_unit unit
, char *clip
, int index
, int32_t in
, int32_t out
)
322 mlt_producer instance
= locate_producer( unit
, clip
);
324 if ( instance
!= NULL
)
326 mlt_properties properties
= unit
->properties
;
327 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
328 fprintf( stderr
, "inserting clip %s before %d\n", clip
, index
);
329 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
330 mlt_playlist_insert( playlist
, instance
, index
, in
, out
);
331 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
332 melted_log( LOG_DEBUG
, "inserted clip %s at %d", clip
, index
);
333 update_generation( unit
);
334 melted_unit_status_communicate( unit
);
335 mlt_producer_close( instance
);
339 return mvcp_invalid_file
;
342 mvcp_error_code
melted_unit_remove( melted_unit unit
, int index
)
344 mlt_properties properties
= unit
->properties
;
345 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
346 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
347 mlt_playlist_remove( playlist
, index
);
348 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
349 melted_log( LOG_DEBUG
, "removed clip at %d", index
);
350 update_generation( unit
);
351 melted_unit_status_communicate( unit
);
355 mvcp_error_code
melted_unit_clean( melted_unit unit
)
358 melted_log( LOG_DEBUG
, "Cleaned playlist" );
359 melted_unit_status_communicate( unit
);
363 mvcp_error_code
melted_unit_wipe( melted_unit unit
)
366 melted_log( LOG_DEBUG
, "Wiped playlist" );
367 melted_unit_status_communicate( unit
);
371 mvcp_error_code
melted_unit_clear( melted_unit unit
)
373 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
375 mlt_consumer_purge( consumer
);
376 melted_log( LOG_DEBUG
, "Cleared playlist" );
377 melted_unit_status_communicate( unit
);
381 mvcp_error_code
melted_unit_move( melted_unit unit
, int src
, int dest
)
383 mlt_properties properties
= unit
->properties
;
384 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
385 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
386 mlt_playlist_move( playlist
, src
, dest
);
387 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
388 melted_log( LOG_DEBUG
, "moved clip %d to %d", src
, dest
);
389 update_generation( unit
);
390 melted_unit_status_communicate( unit
);
394 /** Add a clip to the unit play list.
397 \param unit A melted_unit handle.
398 \param clip The absolute file name of the clip to load.
399 \param in The starting frame (-1 for 0)
400 \param out The ending frame (-1 for maximum)
403 mvcp_error_code
melted_unit_append( melted_unit unit
, char *clip
, int32_t in
, int32_t out
)
405 mlt_producer instance
= locate_producer( unit
, clip
);
407 if ( instance
!= NULL
)
409 mlt_properties properties
= unit
->properties
;
410 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
411 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
412 mlt_playlist_append_io( playlist
, instance
, in
, out
);
413 melted_log( LOG_DEBUG
, "appended clip %s", clip
);
414 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
415 update_generation( unit
);
416 melted_unit_status_communicate( unit
);
417 mlt_producer_close( instance
);
421 return mvcp_invalid_file
;
424 /** Add an mlt_service to the playlist
426 \param unit A melted_unit handle.
427 \param service the service to add
430 mvcp_error_code
melted_unit_append_service( melted_unit unit
, mlt_service service
)
432 mlt_properties properties
= unit
->properties
;
433 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
434 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
435 mlt_playlist_append( playlist
, ( mlt_producer
)service
);
436 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
437 melted_log( LOG_DEBUG
, "appended clip" );
438 update_generation( unit
);
439 melted_unit_status_communicate( unit
);
443 /** Start playing the unit.
446 \param unit A melted_unit handle.
447 \param speed An integer that specifies the playback rate as a
448 percentage multiplied by 100.
451 void melted_unit_play( melted_unit_t
*unit
, int speed
)
453 mlt_properties properties
= unit
->properties
;
454 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
455 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
456 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
457 mlt_producer_set_speed( producer
, ( double )speed
/ 1000 );
458 mlt_consumer_start( consumer
);
459 melted_unit_status_communicate( unit
);
464 Terminates the consumer and halts playout.
466 \param unit A melted_unit handle.
469 void melted_unit_terminate( melted_unit unit
)
471 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
472 mlt_playlist playlist
= mlt_properties_get_data( unit
->properties
, "playlist", NULL
);
473 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
474 mlt_producer_set_speed( producer
, 0 );
475 mlt_consumer_stop( consumer
);
476 melted_unit_status_communicate( unit
);
479 /** Query the status of unit playback.
481 \param unit A melted_unit handle.
482 \return 1 if the unit is not playing, 0 if playing.
485 int melted_unit_has_terminated( melted_unit unit
)
487 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
488 return mlt_consumer_is_stopped( consumer
);
491 /** Transfer the currently loaded clip to another unit
494 int melted_unit_transfer( melted_unit dest_unit
, melted_unit src_unit
)
497 mlt_properties dest_properties
= dest_unit
->properties
;
498 mlt_playlist dest_playlist
= mlt_properties_get_data( dest_properties
, "playlist", NULL
);
499 mlt_properties src_properties
= src_unit
->properties
;
500 mlt_playlist src_playlist
= mlt_properties_get_data( src_properties
, "playlist", NULL
);
501 mlt_playlist tmp_playlist
= mlt_playlist_init( );
503 for ( i
= 0; i
< mlt_playlist_count( src_playlist
); i
++ )
505 mlt_playlist_clip_info info
;
506 mlt_playlist_get_clip_info( src_playlist
, &info
, i
);
507 if ( info
.producer
!= NULL
)
508 mlt_playlist_append_io( tmp_playlist
, info
.producer
, info
.frame_in
, info
.frame_out
);
511 clear_unit( src_unit
);
513 mlt_service_lock( MLT_PLAYLIST_SERVICE( dest_playlist
) );
515 for ( i
= 0; i
< mlt_playlist_count( tmp_playlist
); i
++ )
517 mlt_playlist_clip_info info
;
518 mlt_playlist_get_clip_info( tmp_playlist
, &info
, i
);
519 if ( info
.producer
!= NULL
)
520 mlt_playlist_append_io( dest_playlist
, info
.producer
, info
.frame_in
, info
.frame_out
);
523 mlt_service_unlock( MLT_PLAYLIST_SERVICE( dest_playlist
) );
525 update_generation( dest_unit
);
526 melted_unit_status_communicate( dest_unit
);
528 mlt_playlist_close( tmp_playlist
);
533 /** Determine if unit is offline.
536 int melted_unit_is_offline( melted_unit unit
)
541 /** Obtain the status for a given unit
544 int melted_unit_get_status( melted_unit unit
, mvcp_status status
)
546 int error
= unit
== NULL
;
548 memset( status
, 0, sizeof( mvcp_status_t
) );
552 mlt_properties properties
= unit
->properties
;
553 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
554 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
555 mlt_producer clip
= mlt_playlist_current( playlist
);
557 mlt_playlist_clip_info info
;
558 int clip_index
= mlt_playlist_current_clip( playlist
);
559 mlt_playlist_get_clip_info( playlist
, &info
, clip_index
);
561 if ( info
.resource
!= NULL
&& strcmp( info
.resource
, "" ) )
563 char *title
= mlt_properties_get( MLT_PRODUCER_PROPERTIES( info
.producer
), "title" );
565 title
= strip_root( unit
, info
.resource
);
566 strncpy( status
->clip
, title
, sizeof( status
->clip
) );
567 status
->speed
= (int)( mlt_producer_get_speed( producer
) * 1000.0 );
568 status
->fps
= mlt_producer_get_fps( producer
);
569 status
->in
= info
.frame_in
;
570 status
->out
= info
.frame_out
;
571 status
->position
= mlt_producer_frame( clip
);
572 status
->length
= mlt_producer_get_length( clip
);
573 strncpy( status
->tail_clip
, title
, sizeof( status
->tail_clip
) );
574 status
->tail_in
= info
.frame_in
;
575 status
->tail_out
= info
.frame_out
;
576 status
->tail_position
= mlt_producer_frame( clip
);
577 status
->tail_length
= mlt_producer_get_length( clip
);
578 status
->clip_index
= mlt_playlist_current_clip( playlist
);
579 status
->seek_flag
= 1;
582 status
->generation
= mlt_properties_get_int( properties
, "generation" );
584 if ( melted_unit_has_terminated( unit
) )
585 status
->status
= unit_stopped
;
586 else if ( !strcmp( status
->clip
, "" ) )
587 status
->status
= unit_not_loaded
;
588 else if ( status
->speed
== 0 )
589 status
->status
= unit_paused
;
591 status
->status
= unit_playing
;
595 status
->status
= unit_undefined
;
598 status
->unit
= mlt_properties_get_int( unit
->properties
, "unit" );
603 /** Change position in the playlist.
606 void melted_unit_change_position( melted_unit unit
, int clip
, int32_t position
)
608 mlt_properties properties
= unit
->properties
;
609 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
610 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
611 mlt_playlist_clip_info info
;
618 else if ( clip
>= mlt_playlist_count( playlist
) )
620 clip
= mlt_playlist_count( playlist
) - 1;
624 if ( mlt_playlist_get_clip_info( playlist
, &info
, clip
) == 0 )
626 int32_t frame_start
= info
.start
;
627 int32_t frame_offset
= position
;
629 if ( frame_offset
< 0 )
630 frame_offset
= info
.frame_out
;
631 if ( frame_offset
< info
.frame_in
)
632 frame_offset
= info
.frame_in
;
633 if ( frame_offset
>= info
.frame_out
)
634 frame_offset
= info
.frame_out
;
636 mlt_producer_seek( producer
, frame_start
+ frame_offset
- info
.frame_in
);
639 melted_unit_status_communicate( unit
);
642 /** Get the index of the current clip.
645 int melted_unit_get_current_clip( melted_unit unit
)
647 mlt_properties properties
= unit
->properties
;
648 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
649 int clip_index
= mlt_playlist_current_clip( playlist
);
653 /** Set a clip's in point
656 int melted_unit_set_clip_in( melted_unit unit
, int index
, int32_t position
)
658 mlt_properties properties
= unit
->properties
;
659 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
660 mlt_playlist_clip_info info
;
661 int error
= mlt_playlist_get_clip_info( playlist
, &info
, index
);
665 melted_unit_play( unit
, 0 );
666 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
667 error
= mlt_playlist_resize_clip( playlist
, index
, position
, info
.frame_out
);
668 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
669 update_generation( unit
);
670 melted_unit_change_position( unit
, index
, 0 );
676 /** Set a clip's out point.
679 int melted_unit_set_clip_out( melted_unit unit
, int index
, int32_t position
)
681 mlt_properties properties
= unit
->properties
;
682 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
683 mlt_playlist_clip_info info
;
684 int error
= mlt_playlist_get_clip_info( playlist
, &info
, index
);
688 melted_unit_play( unit
, 0 );
689 mlt_service_lock( MLT_PLAYLIST_SERVICE( playlist
) );
690 error
= mlt_playlist_resize_clip( playlist
, index
, info
.frame_in
, position
);
691 mlt_service_unlock( MLT_PLAYLIST_SERVICE( playlist
) );
692 update_generation( unit
);
693 melted_unit_status_communicate( unit
);
694 melted_unit_change_position( unit
, index
, -1 );
700 /** Step by specified position.
703 void melted_unit_step( melted_unit unit
, int32_t offset
)
705 mlt_properties properties
= unit
->properties
;
706 mlt_playlist playlist
= mlt_properties_get_data( properties
, "playlist", NULL
);
707 mlt_producer producer
= MLT_PLAYLIST_PRODUCER( playlist
);
708 mlt_position position
= mlt_producer_frame( producer
);
709 mlt_producer_seek( producer
, position
+ offset
);
712 /** Set the unit's clip mode regarding in and out points.
715 //void melted_unit_set_mode( melted_unit unit, dv_player_clip_mode mode )
717 //dv_player player = melted_unit_get_dv_player( unit );
718 //if ( player != NULL )
719 //dv_player_set_clip_mode( player, mode );
720 //melted_unit_status_communicate( unit );
723 /** Get the unit's clip mode regarding in and out points.
726 //dv_player_clip_mode melted_unit_get_mode( melted_unit unit )
728 //dv_player player = melted_unit_get_dv_player( unit );
729 //return dv_player_get_clip_mode( player );
732 /** Set the unit's clip mode regarding eof handling.
735 //void melted_unit_set_eof_action( melted_unit unit, dv_player_eof_action action )
737 //dv_player player = melted_unit_get_dv_player( unit );
738 //dv_player_set_eof_action( player, action );
739 //melted_unit_status_communicate( unit );
742 /** Get the unit's clip mode regarding eof handling.
745 //dv_player_eof_action melted_unit_get_eof_action( melted_unit unit )
747 //dv_player player = melted_unit_get_dv_player( unit );
748 //return dv_player_get_eof_action( player );
751 int melted_unit_set( melted_unit unit
, char *name_value
)
753 mlt_properties properties
= NULL
;
755 if ( strncmp( name_value
, "consumer.", 9 ) )
757 mlt_playlist playlist
= mlt_properties_get_data( unit
->properties
, "playlist", NULL
);
758 properties
= MLT_PLAYLIST_PROPERTIES( playlist
);
762 mlt_consumer consumer
= mlt_properties_get_data( unit
->properties
, "consumer", NULL
);
763 properties
= MLT_CONSUMER_PROPERTIES( consumer
);
767 return mlt_properties_parse( properties
, name_value
);
770 char *melted_unit_get( melted_unit unit
, char *name
)
772 mlt_playlist playlist
= mlt_properties_get_data( unit
->properties
, "playlist", NULL
);
773 mlt_properties properties
= MLT_PLAYLIST_PROPERTIES( playlist
);
774 return mlt_properties_get( properties
, name
);
780 \param unit A melted_unit handle.
783 void melted_unit_close( melted_unit unit
)
787 melted_log( LOG_DEBUG
, "closing unit..." );
788 melted_unit_terminate( unit
);
789 mlt_properties_close( unit
->properties
);
791 melted_log( LOG_DEBUG
, "... unit closed." );