2 * kino_wrapper.cc -- c wrapper for kino file handler
3 * Copyright (C) 2005 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@gmail.com>
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.
26 #include "kino_wrapper.h"
27 #include "filehandler.h"
32 #include <framework/mlt_pool.h>
40 kino_wrapper
kino_wrapper_init( )
42 kino_wrapper self
= ( kino_wrapper
)malloc( sizeof( kino_wrapper_s
) );
48 int kino_wrapper_open( kino_wrapper self
, char *src
)
52 // Rough file determination based on file type
53 if ( strncasecmp( strrchr( src
, '.' ), ".avi", 4 ) == 0 )
54 self
->handler
= new AVIHandler( );
55 else if ( strncasecmp( strrchr( src
, '.' ), ".dv", 3 ) == 0 || strncasecmp( strrchr( src
, '.' ), ".dif", 4 ) == 0 )
56 self
->handler
= new RawHandler( );
57 #ifdef HAVE_LIBQUICKTIME
58 else if ( strncasecmp( strrchr( src
, '.' ), ".mov", 4 ) == 0 )
59 self
->handler
= new QtHandler( );
62 // Open the file if we have a handler
63 if ( self
->handler
!= NULL
)
64 if ( !self
->handler
->Open( src
) )
67 // Check the first frame to see if it's PAL or NTSC
68 if ( self
!= NULL
&& self
->handler
!= NULL
)
70 uint8_t *data
= ( uint8_t * )mlt_pool_alloc( 144000 );
71 if ( self
->handler
->GetFrame( data
, 0 ) == 0 )
72 self
->is_pal
= data
[3] & 0x80;
75 mlt_pool_release( data
);
79 return kino_wrapper_is_open( self
);
82 int kino_wrapper_get_frame_count( kino_wrapper self
)
84 return self
!= NULL
&& self
->handler
!= NULL ? self
->handler
->GetTotalFrames( ) : 0;
87 int kino_wrapper_is_open( kino_wrapper self
)
89 return self
!= NULL
&& self
->handler
!= NULL ? self
->handler
->FileIsOpen( ) : 0;
92 int kino_wrapper_is_pal( kino_wrapper self
)
94 return self
!= NULL ? self
->is_pal
: 0;
97 int kino_wrapper_get_frame( kino_wrapper self
, uint8_t *data
, int index
)
99 return self
!= NULL
&& self
->handler
!= NULL ?
!self
->handler
->GetFrame( data
, index
) : 0;
102 void kino_wrapper_close( kino_wrapper self
)
105 delete self
->handler
;