Remove QTKit support from wxMediaCtrl for OS X

QTKit has been removed from OS X 10.12 SDK.
QTKit has been superseded by AVFoundation since OS X 10.7.
Since wxWidgets >= 3.1 requires 10.7 anyway there is no reason to support the old API.

Additionally the AVFoundation implementation may use AVKit (available since 10.9). It will be used when available and the deployment target is met.

Closes https://github.com/wxWidgets/wxWidgets/pull/337
This commit is contained in:
TcT2k 2016-10-19 13:56:29 +02:00 committed by VZ
parent ec45fc5ae0
commit 065135adcc
4 changed files with 10 additions and 462 deletions

23
configure vendored
View File

@ -35364,27 +35364,11 @@ fi
fi
elif test "$wxUSE_MAC" = 1; then
if test "$wxUSE_OSX_IPHONE" = 1; then
GST_LIBS="-framework AVFoundation -framework CoreMedia"
else
old_CPPFLAGS="$CPPFLAGS"
if test "$wxUSE_OSX_IPHONE" != 1; then
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-x objective-c++ $CPPFLAGS"
ac_fn_c_check_header_mongrel "$LINENO" "QTKit/QTKit.h" "ac_cv_header_QTKit_QTKit_h" "$ac_includes_default"
if test "x$ac_cv_header_QTKit_QTKit_h" = xyes; then :
GST_LIBS="-framework QTKit"
else
$as_echo "#define wxOSX_USE_QTKIT 0" >>confdefs.h
GST_LIBS="-framework AVFoundation -framework CoreMedia"
fi
ac_fn_c_check_header_mongrel "$LINENO" "AVKit/AVKit.h" "ac_cv_header_AVKit_AVKit_h" "$ac_includes_default"
ac_fn_c_check_header_mongrel "$LINENO" "AVKit/AVKit.h" "ac_cv_header_AVKit_AVKit_h" "$ac_includes_default"
if test "x$ac_cv_header_AVKit_AVKit_h" = xyes; then :
GST_LIBS="$GST_LIBS -framework AVKit"
@ -35393,7 +35377,6 @@ fi
CPPFLAGS="$old_CPPFLAGS"
fi
fi

View File

@ -7405,31 +7405,19 @@ if test "$wxUSE_MEDIACTRL" = "yes" -o "$wxUSE_MEDIACTRL" = "auto"; then
fi
elif test "$wxUSE_MAC" = 1; then
if test "$wxUSE_OSX_IPHONE" = 1; then
dnl this will also be used for cocoa in the future
GST_LIBS="-framework AVFoundation -framework CoreMedia"
else
dnl We always have the necessary libraries under Mac
dnl but we need to link with it explicitly.
dnl QTKit is no longer available as of 10.12 SDK
dnl We always have the necessary libraries under Mac
dnl but we need to link with it explicitly.
GST_LIBS="-framework AVFoundation -framework CoreMedia"
if test "$wxUSE_OSX_IPHONE" != 1; then
dnl In addition to AVFoundation AVKit may be used when available
dnl AVKit is only available since OS X 10.9
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-x objective-c++ $CPPFLAGS"
AC_CHECK_HEADER([QTKit/QTKit.h],
[
GST_LIBS="-framework QTKit"
],
[
AC_DEFINE(wxOSX_USE_QTKIT,0)
GST_LIBS="-framework AVFoundation -framework CoreMedia"
])
dnl AVKit is only available since OS X 10.9
AC_CHECK_HEADER([AVKit/AVKit.h],
[
GST_LIBS="$GST_LIBS -framework AVKit"
])
CPPFLAGS="$old_CPPFLAGS"
fi
fi

View File

@ -877,11 +877,6 @@
*/
#define wxUSE_WEBKIT 0
/*
* wxMediaCtrl on OS X
*/
#undef wxOSX_USE_QTKIT
/*
* Objective-C class name uniquifying
*/

View File

@ -30,29 +30,9 @@
#include "wx/mediactrl.h"
#ifndef WX_PRECOMP
#include "wx/timer.h"
#endif
#include "wx/osx/private.h"
#ifndef wxOSX_USE_QTKIT
#if wxOSX_USE_IPHONE
#define wxOSX_USE_QTKIT 0
#define wxOSX_USE_AVFOUNDATION 1
#else
#define wxOSX_USE_QTKIT 1
#define wxOSX_USE_AVFOUNDATION 0
#endif
#else
#if wxOSX_USE_QTKIT
#define wxOSX_USE_AVFOUNDATION 0
#else
#define wxOSX_USE_AVFOUNDATION 1
#endif
#endif
#if wxOSX_USE_AVFOUNDATION && wxOSX_USE_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
#if wxOSX_USE_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
#define wxOSX_USE_AVKIT 1
#else
#define wxOSX_USE_AVKIT 0
@ -62,402 +42,6 @@
// BACKEND DECLARATIONS
//===========================================================================
#if wxOSX_USE_QTKIT
//---------------------------------------------------------------------------
//
// wxQTMediaBackend
//
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// QT Includes
//---------------------------------------------------------------------------
#include <QTKit/QTKit.h>
class WXDLLIMPEXP_FWD_MEDIA wxQTMediaBackend;
@interface wxQTMovie : QTMovie {
wxQTMediaBackend* m_backend;
}
-(BOOL)isPlaying;
@end
class WXDLLIMPEXP_MEDIA wxQTMediaBackend : public wxMediaBackendCommonBase
{
public:
wxQTMediaBackend();
~wxQTMediaBackend();
virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name) wxOVERRIDE;
virtual bool Play() wxOVERRIDE;
virtual bool Pause() wxOVERRIDE;
virtual bool Stop() wxOVERRIDE;
virtual bool Load(const wxString& fileName) wxOVERRIDE;
virtual bool Load(const wxURI& location) wxOVERRIDE;
virtual wxMediaState GetState() wxOVERRIDE;
virtual bool SetPosition(wxLongLong where) wxOVERRIDE;
virtual wxLongLong GetPosition() wxOVERRIDE;
virtual wxLongLong GetDuration() wxOVERRIDE;
virtual void Move(int x, int y, int w, int h) wxOVERRIDE;
wxSize GetVideoSize() const wxOVERRIDE;
virtual double GetPlaybackRate() wxOVERRIDE;
virtual bool SetPlaybackRate(double dRate) wxOVERRIDE;
virtual double GetVolume() wxOVERRIDE;
virtual bool SetVolume(double dVolume) wxOVERRIDE;
void Cleanup();
void FinishLoad();
virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags) wxOVERRIDE;
private:
void DoShowPlayerControls(wxMediaCtrlPlayerControls flags);
wxSize m_bestSize; //Original movie size
wxQTMovie* m_movie; //QTMovie handle/instance
QTMovieView* m_movieview; //QTMovieView instance
wxMediaCtrlPlayerControls m_interfaceflags; // Saved interface flags
wxDECLARE_DYNAMIC_CLASS(wxQTMediaBackend);
};
// --------------------------------------------------------------------------
// wxQTMovie
// --------------------------------------------------------------------------
@implementation wxQTMovie
- (id)initWithURL:(NSURL *)url error:(NSError **)errorPtr
{
if ( [super initWithURL:url error:errorPtr] != nil )
{
m_backend = NULL;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(movieDidEnd:)
name:QTMovieDidEndNotification object:nil];
[nc addObserver:self selector:@selector(movieRateChanged:)
name:QTMovieRateDidChangeNotification object:nil];
[nc addObserver:self selector:@selector(loadStateChanged:)
name:QTMovieLoadStateDidChangeNotification object:nil];
return self;
}
else
return nil;
}
-(void)dealloc
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
[super dealloc];
}
-(wxQTMediaBackend*) backend
{
return m_backend;
}
-(void) setBackend:(wxQTMediaBackend*) backend
{
m_backend = backend;
}
- (void)movieDidEnd:(NSNotification *)notification
{
if ( m_backend )
{
if ( m_backend->SendStopEvent() )
m_backend->QueueFinishEvent();
}
}
- (void)movieRateChanged:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
NSNumber *newRate = [userInfo objectForKey:QTMovieRateDidChangeNotificationParameter];
if ([newRate intValue] == 0)
{
m_backend->QueuePauseEvent();
}
else if ( [self isPlaying] == NO )
{
m_backend->QueuePlayEvent();
}
}
-(void)loadStateChanged:(NSNotification *)notification
{
QTMovie *movie = [notification object];
long loadState = [[movie attributeForKey:QTMovieLoadStateAttribute] longValue];
if ( loadState == QTMovieLoadStateError )
{
// error occurred
}
else if (loadState >= QTMovieLoadStatePlayable)
{
// the movie has loaded enough media data to begin playing, but we don't have an event for that yet
}
else if (loadState >= QTMovieLoadStateComplete) // we might use QTMovieLoadStatePlaythroughOK
{
m_backend->FinishLoad();
}
}
-(BOOL)isPlaying
{
if ([self rate] == 0)
{
return NO;
}
return YES;
}
@end
// --------------------------------------------------------------------------
// wxQTMediaBackend
// --------------------------------------------------------------------------
wxIMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend);
wxQTMediaBackend::wxQTMediaBackend() :
m_movie(nil), m_movieview(nil),
m_interfaceflags(wxMEDIACTRLPLAYERCONTROLS_NONE)
{
}
wxQTMediaBackend::~wxQTMediaBackend()
{
Cleanup();
}
bool wxQTMediaBackend::CreateControl(wxControl* inctrl, wxWindow* parent,
wxWindowID wid,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
wxMediaCtrl* mediactrl = (wxMediaCtrl*) inctrl;
mediactrl->DontCreatePeer();
if ( !mediactrl->wxControl::Create(
parent, wid, pos, size,
wxWindow::MacRemoveBordersFromStyle(style),
validator, name))
{
return false;
}
NSRect r = wxOSXGetFrameForControl( mediactrl, pos , size ) ;
QTMovieView* theView = [[QTMovieView alloc] initWithFrame: r];
wxWidgetCocoaImpl* impl = new wxWidgetCocoaImpl(mediactrl,theView);
mediactrl->SetPeer(impl);
m_movieview = theView;
// will be set up after load
[theView setControllerVisible:NO];
m_ctrl = mediactrl;
return true;
}
bool wxQTMediaBackend::Load(const wxString& fileName)
{
return Load(
wxURI(
wxString( wxT("file://") ) + fileName
)
);
}
bool wxQTMediaBackend::Load(const wxURI& location)
{
wxCFStringRef uri(location.BuildURI());
NSURL *url = [NSURL URLWithString: uri.AsNSString()];
if (! [wxQTMovie canInitWithURL:url])
return false;
[m_movie release];
wxQTMovie* movie = [[wxQTMovie alloc] initWithURL:url error: nil ];
m_movie = movie;
if (movie != nil)
{
[m_movie setBackend:this];
[m_movieview setMovie:movie];
// If the media file is able to be loaded quickly then there may not be
// any QTMovieLoadStateDidChangeNotification message sent, so we need to
// also check the load state here and finish our initialization if it has
// been loaded.
long loadState = [[m_movie attributeForKey:QTMovieLoadStateAttribute] longValue];
if (loadState >= QTMovieLoadStateComplete)
{
FinishLoad();
}
}
return movie != nil;
}
void wxQTMediaBackend::FinishLoad()
{
DoShowPlayerControls(m_interfaceflags);
NSSize s = [[m_movie attributeForKey:QTMovieNaturalSizeAttribute] sizeValue];
m_bestSize = wxSize(s.width, s.height);
NotifyMovieLoaded();
}
bool wxQTMediaBackend::Play()
{
[m_movieview play:nil];
return true;
}
bool wxQTMediaBackend::Pause()
{
[m_movieview pause:nil];
return true;
}
bool wxQTMediaBackend::Stop()
{
[m_movieview pause:nil];
[m_movieview gotoBeginning:nil];
return true;
}
double wxQTMediaBackend::GetVolume()
{
return [m_movie volume];
}
bool wxQTMediaBackend::SetVolume(double dVolume)
{
[m_movie setVolume:dVolume];
return true;
}
double wxQTMediaBackend::GetPlaybackRate()
{
return [m_movie rate];
}
bool wxQTMediaBackend::SetPlaybackRate(double dRate)
{
[m_movie setRate:dRate];
return true;
}
bool wxQTMediaBackend::SetPosition(wxLongLong where)
{
QTTime position;
position = [m_movie currentTime];
position.timeValue = (where.GetValue() / 1000.0) * position.timeScale;
[m_movie setCurrentTime:position];
return true;
}
wxLongLong wxQTMediaBackend::GetPosition()
{
QTTime position = [m_movie currentTime];
return ((double) position.timeValue) / position.timeScale * 1000;
}
wxLongLong wxQTMediaBackend::GetDuration()
{
QTTime duration = [m_movie duration];
return ((double) duration.timeValue) / duration.timeScale * 1000;
}
wxMediaState wxQTMediaBackend::GetState()
{
if ( [m_movie isPlaying] )
return wxMEDIASTATE_PLAYING;
else
{
if ( GetPosition() == 0 )
return wxMEDIASTATE_STOPPED;
else
return wxMEDIASTATE_PAUSED;
}
}
void wxQTMediaBackend::Cleanup()
{
[m_movieview setMovie:NULL];
[m_movie release];
m_movie = nil;
}
wxSize wxQTMediaBackend::GetVideoSize() const
{
return m_bestSize;
}
void wxQTMediaBackend::Move(int x, int y, int w, int h)
{
// as we have a native player, no need to move the video area
}
bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
{
if ( m_interfaceflags != flags )
DoShowPlayerControls(flags);
m_interfaceflags = flags;
return true;
}
void wxQTMediaBackend::DoShowPlayerControls(wxMediaCtrlPlayerControls flags)
{
if (flags == wxMEDIACTRLPLAYERCONTROLS_NONE )
{
[m_movieview setControllerVisible:NO];
}
else
{
[m_movieview setControllerVisible:YES];
[m_movieview setStepButtonsVisible:(flags & wxMEDIACTRLPLAYERCONTROLS_STEP) ? YES:NO];
[m_movieview setVolumeButtonVisible:(flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME) ? YES:NO];
}
}
#endif
#if wxOSX_USE_AVFOUNDATION
//---------------------------------------------------------------------------
//
// wxAVMediaBackend
@ -993,8 +577,6 @@ void wxAVMediaBackend::DoShowPlayerControls(wxMediaCtrlPlayerControls flags)
#endif
}
#endif
//in source file that contains stuff you don't directly use
#include "wx/html/forcelnk.h"
FORCE_LINK_ME(basewxmediabackends);