1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "framegrabber.hxx"
23 #include <tools/stream.hxx>
24 #include <vcl/graph.hxx>
25 #include <vcl/cvtgrf.hxx>
26 #include <unotools/localfilehelper.hxx>
28 #define AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_Quicktime"
29 #define AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_Quicktime"
31 using namespace ::com::sun::star;
33 SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.9
35 namespace avmedia { namespace quicktime {
41 FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
44 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
45 mpMovie = [QTMovie movie];
53 FrameGrabber::~FrameGrabber()
67 bool FrameGrabber::create( const ::rtl::OUString& rURL )
71 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
72 NSString* aNSStr = [[[NSString alloc] initWithCharacters: rURL.getStr() length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
73 NSURL* aURL = [NSURL URLWithString:aNSStr ];
77 mpMovie = [mpMovie initWithURL:aURL error:nil];
91 uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
92 throw (uno::RuntimeException)
94 uno::Reference< graphic::XGraphic > xRet;
96 NSImage* pImage = [mpMovie frameImageAtTime: QTMakeTimeWithTimeInterval(fMediaTime)];
97 NSData *pBitmap = [pImage TIFFRepresentation];
98 long nSize = [pBitmap length];
99 const void* pBitmapData = [pBitmap bytes];
100 SvMemoryStream aMemStm( const_cast<void *>(pBitmapData), nSize, StreamMode::READ | StreamMode::WRITE );
102 if ( GraphicConverter::Import( aMemStm, aGraphic, CVT_TIF ) == ERRCODE_NONE )
104 xRet = aGraphic.GetXGraphic();
112 ::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
113 throw (uno::RuntimeException)
115 return ::rtl::OUString( AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME );
120 sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
121 throw (uno::RuntimeException)
123 return ( ServiceName == AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME );
128 uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( )
129 throw (uno::RuntimeException)
131 uno::Sequence< ::rtl::OUString > aRet(1);
132 aRet[0] = AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME;
137 } // namespace quicktime
138 } // namespace avmedia
140 SAL_WNODEPRECATED_DECLARATIONS_POP
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */