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.
23 #include "kino_wrapper.h"
24 #include "filehandler.h"
29 #include <framework/mlt_pool.h>
37 kino_wrapper
kino_wrapper_init( )
39 kino_wrapper self
= ( kino_wrapper
)malloc( sizeof( kino_wrapper_s
) );
45 int kino_wrapper_open( kino_wrapper self
, char *src
)
49 // Rough file determination based on file type
50 if ( strncasecmp( strrchr( src
, '.' ), ".avi", 4 ) == 0 )
51 self
->handler
= new AVIHandler( );
52 else if ( strncasecmp( strrchr( src
, '.' ), ".dv", 3 ) == 0 || strncasecmp( strrchr( src
, '.' ), ".dif", 4 ) == 0 )
53 self
->handler
= new RawHandler( );
54 #ifdef HAVE_LIBQUICKTIME
55 else if ( strncasecmp( strrchr( src
, '.' ), ".mov", 4 ) == 0 )
56 self
->handler
= new QtHandler( );
59 // Open the file if we have a handler
60 if ( self
->handler
!= NULL
)
61 if ( !self
->handler
->Open( src
) )
64 // Check the first frame to see if it's PAL or NTSC
65 if ( self
!= NULL
&& self
->handler
!= NULL
)
67 uint8_t *data
= ( uint8_t * )mlt_pool_alloc( 144000 );
68 if ( self
->handler
->GetFrame( data
, 0 ) == 0 )
69 self
->is_pal
= data
[3] & 0x80;
72 mlt_pool_release( data
);
76 return kino_wrapper_is_open( self
);
79 int kino_wrapper_get_frame_count( kino_wrapper self
)
81 return self
!= NULL
&& self
->handler
!= NULL ? self
->handler
->GetTotalFrames( ) : 0;
84 int kino_wrapper_is_open( kino_wrapper self
)
86 return self
!= NULL
&& self
->handler
!= NULL ? self
->handler
->FileIsOpen( ) : 0;
89 int kino_wrapper_is_pal( kino_wrapper self
)
91 return self
!= NULL ? self
->is_pal
: 0;
94 int kino_wrapper_get_frame( kino_wrapper self
, uint8_t *data
, int index
)
96 return self
!= NULL
&& self
->handler
!= NULL ?
!self
->handler
->GetFrame( data
, index
) : 0;
99 void kino_wrapper_close( kino_wrapper self
)
102 delete self
->handler
;