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 {
38 FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
41 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
42 mpMovie = [QTMovie movie];
49 FrameGrabber::~FrameGrabber()
62 bool FrameGrabber::create( const ::rtl::OUString& rURL )
66 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
67 NSString* aNSStr = [[[NSString alloc] initWithCharacters: reinterpret_cast<unichar const *>(rURL.getStr()) length: rURL.getLength()]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
68 NSURL* aURL = [NSURL URLWithString:aNSStr ];
72 mpMovie = [mpMovie initWithURL:aURL error:nil];
85 uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMediaTime )
87 uno::Reference< graphic::XGraphic > xRet;
89 NSImage* pImage = [mpMovie frameImageAtTime: QTMakeTimeWithTimeInterval(fMediaTime)];
90 NSData *pBitmap = [pImage TIFFRepresentation];
91 long nSize = [pBitmap length];
92 const void* pBitmapData = [pBitmap bytes];
93 SvMemoryStream aMemStm( const_cast<void *>(pBitmapData), nSize, StreamMode::READ | StreamMode::WRITE );
95 if ( GraphicConverter::Import( aMemStm, aGraphic, ConvertDataFormat::TIF ) == ERRCODE_NONE )
97 xRet = aGraphic.GetXGraphic();
104 ::rtl::OUString SAL_CALL FrameGrabber::getImplementationName( )
106 return ::rtl::OUString( AVMEDIA_QUICKTIME_FRAMEGRABBER_IMPLEMENTATIONNAME );
110 sal_Bool SAL_CALL FrameGrabber::supportsService( const ::rtl::OUString& ServiceName )
112 return ( ServiceName == AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME );
116 uno::Sequence< ::rtl::OUString > SAL_CALL FrameGrabber::getSupportedServiceNames( )
118 return { AVMEDIA_QUICKTIME_FRAMEGRABBER_SERVICENAME };
121 } // namespace quicktime
122 } // namespace avmedia
124 SAL_WNODEPRECATED_DECLARATIONS_POP
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */