Commit d4a87d8e authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework: Merge Enrique Osuna's work on the Framework.

parent bed5264a
...@@ -26,18 +26,22 @@ ...@@ -26,18 +26,22 @@
#import <pthread.h> #import <pthread.h>
/* This object is here to ensure safe inter thread communication */ /* This object is here to ensure safe inter thread communication */
@interface VLCEventManager : NSObject @interface VLCEventManager : NSObject
{ {
NSMutableArray * messageQueue; NSMutableArray *messageQueue;
pthread_t dispatcherThread; pthread_t dispatcherThread;
pthread_mutex_t queueLock; pthread_mutex_t queueLock;
pthread_cond_t signalData; pthread_cond_t signalData;
} }
/* Return the default manager */ /* Return the default manager */
+ (id)sharedManager; + (id)sharedManager;
- (void)callOnMainThreadDelegateOfObject:(id)aTarget withDelegateMethod:(SEL)aSelector withNotificationName:(NSString *)aNotificationName; - (void)callOnMainThreadDelegateOfObject:(id)aTarget
- (void)callOnMainThreadObject:(id)aTarget withMethod:(SEL)aSelector withArgumentAsObject: (id)arg; withDelegateMethod:(SEL)aSelector
withNotificationName:(NSString *)aNotificationName;
- (void)callOnMainThreadObject:(id)aTarget
withMethod:(SEL)aSelector
withArgumentAsObject:(id)arg;
@end @end
/*****************************************************************************
* VLCLibVLCbridging.h: VLC.framework VLCLibVLCBridging header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCEventManager.h 21564 2007-08-29 21:09:27Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
// TODO: Documentation
@interface VLCMediaList (LibVLCBridging)
+ (id)medialistWithLibVLCMediaList:(void *)p_new_mlist;
- (id)initWithLibVLCMediaList:(void *)p_new_mlist;
- (void *)libVLCMediaList;
@end
/**
* Bridges functionality between libvlc and VLCMedia implementation.
*/
@interface VLCMedia (LibVLCBridging)
/* Object Factory */
/**
* Manufactures new object wrapped around specified media descriptor.
* \param md LibVLC media descriptor pointer.
* \return Newly created media instance using specified descriptor.
*/
+ (id)mediaWithLibVLCMediaDescriptor:(void *)md;
/**
* Initializes new object wrapped around specified media descriptor.
* \param md LibVLC media descriptor pointer.
* \return Newly created media instance using specified descriptor.
*/
- (id)initWithLibVLCMediaDescriptor:(void *)md;
/**
* Returns the receiver's internal media descriptor pointer.
* \return The receiver's internal media descriptor pointer.
*/
- (void *)libVLCMediaDescriptor;
@end
// TODO: Documentation
@interface VLCMedia (VLCMediaPlayerBridging)
- (void)setLength:(VLCTime *)value;
@end
// TODO: Documentation
@interface VLCLibrary (VLCAudioBridging)
- (void)setAudio:(VLCAudio *)value;
@end
...@@ -22,47 +22,36 @@ ...@@ -22,47 +22,36 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "VLCAudio.h"
#import "VLCMediaList.h"
#import "VLCMedia.h"
#include <vlc/libvlc.h> @class VLCAudio;
#include <vlc/libvlc_structures.h>
#import <VLC/VLCPlaylist.h>
/*
* VLCLibrary object
*/
@interface VLCLibrary : NSObject
+ (libvlc_instance_t *)sharedInstance;
@end
/* /*
* Utility function * VLCLibrary object. Internal use only.
*/ */
#define quit_on_exception( ex ) __quit_on_exception( ex, __FUNCTION__, __FILE__, __LINE__ ) // TODO: Documentation
static inline void __quit_on_exception( libvlc_exception_t * ex, const char * function, const char * file, int line_number ) @interface VLCLibrary : NSObject
{ {
if (libvlc_exception_raised( ex )) void *instance;
{ VLCAudio *audio;
/* XXX: localization */
NSRunCriticalAlertPanel( @"Error", [NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)", libvlc_exception_get_message(ex), file, line_number, function], @"Quit", nil, nil );
exit( ex->i_code );
}
} }
/* /* Factories */
* LibVLCBridging category + (VLCLibrary *)sharedLibrary;
*/ + (void *)sharedInstance;
@interface VLCPlaylist (LibVLCBridging) /* Properties */
+ (id) playlistWithLibVLCMediaList: (libvlc_media_list_t *)p_new_mlist; - (void *)instance;
- (libvlc_media_list_t *) libVLCMediaList; - (VLCAudio *)audio;
@end
@interface VLCMedia (LibVLCBridging)
- (id) initWithLibVLCMediaDescriptor: (libvlc_media_descriptor_t *)p_md;
+ (id) mediaWithLibVLCMediaDescriptor: (libvlc_media_descriptor_t *)p_md;
- (libvlc_media_descriptor_t *) libVLCMediaDescriptor;
@end @end
/*
* Utility function
*/
// TODO: Figure out a better way to raise error messages
#define quit_on_exception( ex ) __quit_on_exception( (void*)(ex), __FUNCTION__, __FILE__, __LINE__ )
extern void __quit_on_exception( void* e, const char *function, const char *file, int line_number );
\ No newline at end of file
...@@ -25,15 +25,16 @@ ...@@ -25,15 +25,16 @@
#ifndef VLC_FRAMEWORK_VLC_H #ifndef VLC_FRAMEWORK_VLC_H
#define VLC_FRAMEWORK_VLC_H #define VLC_FRAMEWORK_VLC_H
typedef void * _opaque_ptr;
#import <VLC/VLCMedia.h> #import <VLC/VLCMedia.h>
#import <VLC/VLCMediaDiscoverer.h>
#import <VLC/VLCMediaLibrary.h> #import <VLC/VLCMediaLibrary.h>
#import <VLC/VLCPlaylist.h> #import <VLC/VLCMediaList.h>
#import <VLC/VLCPlaylistDataSource.h>
#import <VLC/VLCServicesDiscoverer.h>
#import <VLC/VLCTime.h> #import <VLC/VLCTime.h>
#import <VLC/VLCVideoView.h> #import <VLC/VLCVideoView.h>
@class VLCMedia;
@class VLCMediaLibrary;
@class VLCMediaList;
@class VLCTime;
@class VLCVideoView;
#endif /* VLC_FRAMEWORK_VLC_H */ #endif /* VLC_FRAMEWORK_VLC_H */
/*****************************************************************************
* VLCAudio.h: VLC.framework VLCAudio header
*****************************************************************************
* Copyright (C) 2007 Faustino E. Osuna
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Faustino E. Osuna <enrique.osuna # gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCLibrary.h"
/* Notification Messages */
/**
* Standard notification messages that are emitted by VLCMedia object.
*/
extern NSString *VLCMediaPlayerVolumeChanged;
@class VLCLibrary;
// TODO: Documentation
@interface VLCAudio : NSObject
{
VLCLibrary *library; //< Library to control audio for
}
/* Initializers */
- (id)initWithLibrary:(VLCLibrary *)library;
/* Properties */
- (void)setMute:(BOOL)value;
- (BOOL)isMuted;
- (void)setVolume:(int)value;
- (int)volume;
@end
/*****************************************************************************
* VLCMedia.h: VLC.framework VLCMedia header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCMediaList.h"
#import "VLCTime.h"
/* Meta Dictionary Keys */
/**
* Standard dictionary keys for retreiving meta data.
*/
extern NSString *VLCMetaInformationTitle; /* NSString */
extern NSString *VLCMetaInformationArtist; /* NSString */
extern NSString *VLCMetaInformationTitle; /* NSString */
extern NSString *VLCMetaInformationArtist; /* NSString */
extern NSString *VLCMetaInformationGenre; /* NSString */
extern NSString *VLCMetaInformationCopyright; /* NSString */
extern NSString *VLCMetaInformationAlbum; /* NSString */
extern NSString *VLCMetaInformationTrackNumber; /* NSString */
extern NSString *VLCMetaInformationDescription; /* NSString */
extern NSString *VLCMetaInformationRating; /* NSString */
extern NSString *VLCMetaInformationDate; /* NSString */
extern NSString *VLCMetaInformationSetting; /* NSString */
extern NSString *VLCMetaInformationURL; /* NSString */
extern NSString *VLCMetaInformationLanguage; /* NSString */
extern NSString *VLCMetaInformationNowPlaying; /* NSString */
extern NSString *VLCMetaInformationPublisher; /* NSString */
extern NSString *VLCMetaInformationEncodedBy; /* NSString */
extern NSString *VLCMetaInformationArtworkURL; /* NSString */
extern NSString *VLCMetaInformationArtwork; /* NSImage */
extern NSString *VLCMetaInformationTrackID; /* NSString */
/* Notification Messages */
/**
* Available notification messages.
*/
extern NSString *VLCMediaMetaChanged; //< Notification message for when the media's meta data has changed
// Forward declarations, supresses compiler error messages
@class VLCMediaList;
@class VLCMedia;
/**
* Informal protocol declaration for VLCMedia delegates. Allows data changes to be
* trapped.
*/
@protocol VLCMediaDelegate
// TODO: SubItemAdded/SubItemRemoved implementation. Not sure if we really want to implement this.
///**
// * Delegate method called whenever a sub item has been added to the specified VLCMedia.
// * \param aMedia The media resource that has received the new sub item.
// * \param childMedia The new sub item added.
// * \param index Location of the new subitem in the aMedia's sublist.
// */
// - (void)media:(VLCMedia *)media addedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
///**
// * Delegate method called whenever a sub item has been removed from the specified VLCMedia.
// * \param aMedia The media resource that has had a sub item removed from.
// * \param childMedia The sub item removed.
// * \param index The previous location of the recently removed sub item.
// */
// - (void)media:(VLCMedia *)aMedia removedSubItem:(VLCMedia *)childMedia atIndex:(int)index;
/**
* Delegate method called whenever the meta has changed for the receiver.
* \param aMedia The media resource whose meta data has been changed.
* \param oldValue The old meta data value.
* \param key The key of the value that was changed.
*/
- (void)media:(VLCMedia *)aMedia metaValueChangedFrom:(id)oldValue forKey:(NSString *)key;
@end
/**
* Defines files and streams as a managed object. Each media object can be
* administered seperately. VLCMediaPlayer or VLCMediaControl must be used
* to execute the appropriate playback functions.
* \see VLCMediaPlayer
* \see VLCMediaControl
*/
@interface VLCMedia : NSObject
{
void *p_md; //< Internal media descriptor instance
NSString *url; //< URL for this media resource
VLCMediaList *subitems; //< Sub list of items
VLCTime *length; //< Duration of the media
NSMutableDictionary *metaDictionary; //< Meta data storage
id delegate; //< Delegate object
BOOL preparsed; //< Value used to determine of the file has been preparsed
}
/* Object Factories */
/**
* Manufactures a new VLCMedia object using the URL specified. Will return nil if
* the specified URL references a directory that does not comply with DVD file
* structure.
* \param anURL URL to media to be accessed.
* \return A new VLCMedia object, only if there were no errors. This object
* will be automatically released.
* \see initWithMediaURL
*/
+ (id)mediaWithURL:(NSString *)anURL;
/* Initializers */
/**
* Initializes a new VLCMedia object to use the specified URL. Will return nil if
* the specified URL references a directory that does not comply with DVD file
* structure.
* \param anURL URL to media to be accessed.
* \return A new VLCMedia object, only if there were no errors.
*/
- (id)initWithURL:(NSString *)anURL;
/**
* Returns an NSComparisonResult value that indicates the lexical ordering of
* the receiver and a given meda.
* \param media The media with which to compare with the receiver.
* \return NSOrderedAscending if the URL of the receiver precedes media in
* lexical ordering, NSOrderedSame if the URL of the receiver and media are
* equivalent in lexical value, and NSOrderedDescending if the URL of the
* receiver follows media. If media is nil, returns NSOrderedDescending.
*/
- (NSComparisonResult)compare:(VLCMedia *)media;
/* Properties */
/**
* Sets the receiver's delegate.
* \param delegate The delegate for the receiver.
*/
- (void)setDelegate:(id)delegate;
/**
* Returns the receiver's delegate
* \return The receiver's delegate
*/
- (id)delegate;
/**
* Returns a VLCTime object describing the length of the media resource.
* \return The length of the media resource.
*/
- (VLCTime *)length;
/**
* Returns a VLCTime object describing the length of the media resource,
* however, this is a blocking operation and will wait until the preparsing is
* completed before returning anything.
* \param aDate Time for operation to wait until, if there are no results
* before specified date then nil is returned.
* \return The length of the media resource, nil if it couldn't wait for it.
*/
- (VLCTime *)lengthWaitUntilDate:(NSDate *)aDate;
- (BOOL)isPreparsed;
/**
* Returns the URL for the receiver's media resource.
* \return The URL for the receiver's media resource.
*/
- (NSString *)url;
/**
* Returns the receiver's sub list.
* \return The receiver's sub list.
*/
- (VLCMediaList *)subitems;
/**
* Returns the receiver's meta data as a NSDictionary object.
* \return The receiver's meta data as a NSDictionary object.
*/
- (NSDictionary *)metaDictionary;
@end
\ No newline at end of file
...@@ -23,20 +23,19 @@ ...@@ -23,20 +23,19 @@
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <VLC/VLCPlaylist.h> #import "VLCMediaList.h"
@class VLCPlaylist; @class VLCMediaList;
@interface VLCMediaLibrary : NSObject @interface VLCMediaLibrary : NSObject
{ {
VLCPlaylist * allMedia; void *mlib;
void * mlib; VLCMediaList *allMedia;
} }
+ (id)sharedMediaLibrary; + (id)sharedMediaLibrary;
- (VLCPlaylist *)allMedia; - (VLCMediaList *)allMedia;
- (NSArray *)playlists;
- (NSArray *) playlists;
@end @end
/***************************************************************************** /*****************************************************************************
* VLCMedia.h: VLC.framework VLCMedia header * VLCMediaList.h: VLC.framework VLCMediaList header
***************************************************************************** *****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont * Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team * Copyright (C) 2007 the VideoLAN team
* $Id$ * $Id: VLCMediaList.h 21564 2007-08-29 21:09:27Z pdherbemont $
* *
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org> * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
* *
...@@ -22,35 +22,47 @@ ...@@ -22,35 +22,47 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import "VLCMedia.h"
#import <VLC/VLCPlaylist.h>
/* Meta */ /* Notification Messages */
extern NSString * VLCMetaInformationTitle; /* Associated to an NSString */ extern NSString *VLCMediaListItemAdded;
extern NSString * VLCMetaInformationAuthor; /* Associated to an NSString */ extern NSString *VLCMediaListItemDeleted;
extern NSString * VLCMetaInformationArtwork; /* Associated to an NSImage */
/* Notification */ @class VLCMedia;
extern NSString * VLCMediaSubItemAdded; @class VLCMediaList;
@class VLCPlaylist; // TODO: Documentation
@protocol VLCMediaListDelegate
@interface VLCMedia : NSObject - (void)mediaList:(VLCMediaList *) mediaAdded:(VLCMedia *)media atIndex:(int)index;
- (void)mediaList:(VLCMediaList *) mediaRemovedAtIndex:(int)index;
@end
// TODO: Documentation
@interface VLCMediaList : NSObject
{ {
void * md; void *p_mlist; //< Internal instance of media list
NSString * url; id delegate; //< Delegate object
VLCPlaylist *subitems;
NSMutableDictionary *metaInformation;
} }
- (id)initWithURL:(NSString *)anURL; /* Properties */
+ (id)mediaWithURL:(NSString *)anURL; - (void)setDelegate:(id)value;
- (id)delegate;
- (void) dealloc; /* Operations */
- (void)lock;
- (void)unlock;
- (NSString *)url; - (int)addMedia:(VLCMedia *)media;
- (VLCPlaylist *)subitems; - (void)insertMedia:(VLCMedia *)media atIndex:(int)index;
- (void)removeMediaAtIndex:(int)index;
- (VLCMedia *)mediaAtIndex:(int)index;
- (int)indexOfMedia:(VLCMedia *)media;
- (int)count;
/* Returns a dictionary with corresponding object associated with a meta */ - (NSArray *)sublists; // I don't see why this would be useful
- (NSDictionary *)metaInformation; //- (VLCMediaList *)flatPlaylist; // nore this one
@end //- (VLCMedia *)providerMedia; // I have no clue what this does
@end
\ No newline at end of file
/*****************************************************************************
* VLCMediaPlayer.h: VLC.framework VLCMediaPlayer header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "VLCMedia.h"
/* Notification Messages */
extern NSString *VLCMediaPlayerTimeChanged;
extern NSString *VLCMediaPlayerStateChanged;
// TODO: Documentation
typedef enum VLCMediaPlayerState
{
VLCMediaPlayerStateStopped, //< Player has stopped
VLCMediaPlayerStateOpening, //< Stream is opening
VLCMediaPlayerStateBuffering, //< Stream is buffering
VLCMediaPlayerStateEnded, //< Stream has ended
VLCMediaPlayerStateError, //< Player has generated an error
VLCMediaPlayerStatePlaying, //< Stream is playing
VLCMediaPlayerStatePaused //< Stream is paused
} VLCMediaPlayerState;
extern NSString *VLCMediaPlayerStateToString(VLCMediaPlayerState state);
/**
* Formal protocol declaration for playback delegates. Allows playback messages
* to be trapped by delegated objects.
*/
@protocol VLCMediaPlayerDelegate
- (void)mediaPlayerTimeChanged:(NSNotification *)aNotification;
- (void)mediaPlayerStateChanged:(NSNotification *)aNotification;
@end
// TODO: Should we use medialist_player or our own flavor of media player?
@interface VLCMediaPlayer : NSObject
{
id delegate; //< Object delegate
VLCVideoView *videoView;//< NSView instance where media is rendered to
void *instance; // Internal
VLCMedia *media; //< Current media being played
}
/* Initializers */
- (id)initWithVideoView:(VLCVideoView *)aVideoView;
/* Properties */
- (void)setDelegate:(id)value;
- (id)delegate;
/* Video View Options */
// TODO: Should be it's own object?
// TODO: use VLCVideoView instead of NSView
- (void)setVideoView:(VLCVideoView *)value;
- (VLCVideoView *)videoView;
- (void)setFullscreen:(BOOL)value;
- (BOOL)fullscreen;
- (void)setVideoAspectRatio:(char *)value;
- (char *)videoAspectRatio;
- (void)setVideoSubTitles:(int)value;
- (int)videoSubTitles;
- (void)setVideoCropGeometry:(char *)value;
- (char *)videoCropGeometry;
- (void)setVideoTeleText:(int)value;
- (int)videoTeleText;
- (void)setRate:(int)value;
- (int)rate;
/* Video Information */
- (NSSize)videoSize;
- (BOOL)hasVideoOut;
- (float)framesPerSecond;
/**
* Sets the current position (or time) of the feed.
* \param value New time to set the current position to. If time is [VLCTime nullTime], 0 is assumed.
*/
- (void)setTime:(VLCTime *)value;
/**
* Returns the current position (or time) of the feed.
* \return VLCTIme object with current time.
*/
- (VLCTime *)time;
/* Audio Options */
- (void)setAudioTrack:(int)value;
- (int)audioTrack;
- (void)setAudioChannel:(int)value;
- (int)audioChannel;
/* Media Options */
- (void)setMedia:(VLCMedia *)value;
- (VLCMedia *)media;
/* Playback Operations */
/**
* Plays a media resource using the currently selected media controller (or
* default controller. If feed was paused then the feed resumes at the position
* it was paused in.
* \return A Boolean determining whether the stream was played or not.
*/
- (BOOL)play;
/**
* Toggle's the pause state of the feed.
*/
- (void)pause;
/**
* Fast forwards through the feed at the standard 1x rate.
*/
//- (void)fastForward;
/**
* Fast forwards through the feed at the rate specified.
* \param rate Rate at which the feed should be fast forwarded.
*/
//- (void)fastForwardAtRate:(int)rate;
/**
* Rewinds through the feed at the standard 1x rate.
*/
//- (void)rewind;
/**
* Rewinds through the feed at the rate specified.
* \param rate Rate at which the feed should be fast rewound.
*/
//- (void)rewindAtRate:(int)rate;
/* Playback Information */
/**
* Playback state flag identifying that the stream is currently playing.
* \return TRUE if the feed is playing, FALSE if otherwise.
*/
- (BOOL)isPlaying;
/**
* Playback state flag identifying wheather the stream will play.
* \return TRUE if the feed is ready for playback, FALSE if otherwise.
*/
- (BOOL)willPlay;
/**
* Playback's current state.
* \see VLCMediaState
*/
- (VLCMediaPlayerState)state;
@end
...@@ -26,10 +26,19 @@ ...@@ -26,10 +26,19 @@
@interface VLCTime : NSObject @interface VLCTime : NSObject
{ {
NSNumber * value; NSNumber *value;
} }
+ (VLCTime *)nullTime;
+ (VLCTime *)timeWithNumber:(NSNumber *)aNumber;
//+ (VLCTime *)timeWithString:(NSString *)aString;
- (id)initWithNumber:(NSNumber *)aNumber; - (id)initWithNumber:(NSNumber *)aNumber;
//- (id)initWithString:(NSString *)aString;
- (NSNumber *)numberValue;
- (NSString *)stringValue;
- (NSComparisonResult)compare:(VLCTime *)aTime;
- (NSNumber *)numberRepresentation;
- (NSString *)stringRepresentation;
@end @end
/*****************************************************************************
* VLCVideoView.h: VLC.framework VLCVideoView header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
/* Notifications */
extern NSString *VLCVideoViewEnteredFullScreen;
extern NSString *VLCVideoViewLeftFullScreen;
@protocol VLCVideoViewDelegate
// Notifications defined in VLCVideoView.h
- (void)videoEnteredFullscreen:(NSNotification *)aNotification;
- (void)videoLeftFullscreen:(NSNotification *)aNotification;
@end
@protocol VLCOpenGLVoutEmbedding
- (void)addVoutSubview:(NSView *)view;
- (void)removeVoutSubview:(NSView *)view;
- (void)enterFullscreen;
- (void)leaveFullscreen;
- (BOOL)stretchesVideo;
//- (void)setOnTop: (BOOL)ontop; /* Do we really want that in protocol? */
@end
@interface VLCVideoView : NSView <VLCOpenGLVoutEmbedding>
{
id delegate;
NSColor *backColor;
BOOL stretchesVideo;
// TODO: Allow for view to report transparency to do some cool effects
// with the video?
}
- (void)setDelegate:(id)value;
- (id)delegate;
- (void)setBackColor:(NSColor *)value;
- (NSColor *)backColor;
- (void)setStretchesVideo:(BOOL)value;
- (BOOL)stretchesVideo;
- (void)addVoutSubview:(NSView *)aView;
- (void)removeVoutSubview:(NSView *)aView;
- (void)enterFullscreen;
- (void)leaveFullscreen;
//- (void)setOnTop: (BOOL)ontop; /* Do we really want that in protocol? */
// The media controls that were here previously should be moved elsewhere. This
// View is just that, a view not a controller. -- Moved to VLCMediaPlayer
@end
/*****************************************************************************
* VLCVideoView.h: VLC.framework VLCVideoView header
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <VLC/VLCTime.h>
#import <VLC/VLCPlaylist.h>
@protocol VLCVideoViewDelegate;
/* Notification */
extern NSString * VLCVideoDidChangeVolume;
extern NSString * VLCVideoDidChangeTime;
extern NSString * VLCVideoDidChangeCurrentlyPlayingItem;
extern NSString * VLCVideoDidStop;
extern NSString * VLCVideoDidPause;
extern NSString * VLCVideoDidPlay;
@interface VLCVideoView : NSView
{
VLCPlaylist * playlist;
NSConnection * connection;
id delegate;
BOOL stretchVideo;
void * p_mi;
void * p_mlp;
}
- (id)initWithFrame:(NSRect)frameRect;
- (void)dealloc;
- (void)setPlaylist: (VLCPlaylist *)newPlaylist;
- (VLCPlaylist *)playlist;
/* Play */
- (void)play;
- (void)playItemAtIndex:(int)index;
- (void)playMedia:(VLCMedia *)media;
- (void)pause;
- (void)setCurrentTime:(VLCTime *)timeObj;
/* State */
- (BOOL)isPlaying;
- (BOOL)isPaused;
- (VLCTime *)currentTime;
- (id)currentPlaylistItem;
/* Video output property */
- (void)setStretchesVideo:(BOOL)flag;
- (BOOL)stretchesVideo;
/* Fullscreen */
- (void)enterFullscreen;
- (void)leaveFullscreen;
/* Delegate */
- (void)setDelegate: (id)newDelegate;
- (id)delegate;
@end
@protocol VLCVideoViewDelegate
- (void)videoDidStop:(NSNotification *)notification;
- (void)videoDidPlay:(NSNotification *)notification;
- (void)videoDidPause:(NSNotification *)notification;
- (void)videoDidPlayNextPlaylistElement:(NSNotification *)notification;
- (void)videoDidChangeVolume:(NSNotification *)notification;
/* Returns NO if the Video shouldn't be paused */
- (BOOL)videoWillPause:(NSNotification *)notification;
/* Returns NO if the Video shouldn't play next playlist element */
- (BOOL)videoWillPlayNextPlaylistElement:(NSNotification *)notification;
/* Posted when the progress of the video has reached a new step
* (every second?).
* The -object contained in the notification is the new VLCTime */
- (void)videoDidChangeTime:(NSNotification *)notification;
@end
CC=gcc all:
CFLAGS=-g -O2 xcodebuild
OBJCFLAGS=-fobjc-exceptions
LDFLAGS=-single_module -read_only_relocs suppress
# We should set this properly.
top_srcdir=../../..
top_builddir=../../..
LIBVLC_HEADERS=$(top_srcdir)/include
VLCCONFIG=$(top_srcdir)/vlc-config
MODULES = $(patsubst %,$(SRC_DIR)/%,$(_MODULES))
HEADERS_DIR = Headers
_EXPORTED_HEADERS= \
VLC/VLC.h \
VLC/VLCMedia.h \
VLC/VLCMediaDiscoverer.h \
VLC/VLCMediaLibrary.h \
VLC/VLCPlaylist.h \
VLC/VLCPlaylistDataSource.h \
VLC/VLCServicesDiscoverer.h \
VLC/VLCTime.h \
VLC/VLCVideoView.h
EXPORTED_HEADERS = $(patsubst %,$(HEADERS_DIR)/%,$(_EXPORTED_HEADERS))
EXPORTED_RESOURCES= \
Resources/Info.plist \
Resources/version.plist
SRC_DIR = Sources
_SRC = \
test.m \
VLCEventManager.m \
VLCLibrary.m \
VLCMedia.m \
VLCMediaLibrary.m \
VLCMediaDiscoverer.m \
VLCPlaylist.m \
VLCPlaylistDataSource.m \
VLCServicesDiscoverer.m \
VLCTime.m \
VLCVideoView.m
SRC = $(patsubst %,$(SRC_DIR)/%,$(_SRC))
HEADERS = $(EXPORTED_HEADERS)
INCLUDES= -I . -I $(LIBVLC_HEADERS) -I $(HEADERS_DIR) -I $(HEADERS_DIR)/Internal
FRAMEWORKS= -framework Cocoa
OBJECTS=$(SRC:.m=.o)
all: VLC.framework
$(OBJECTS): $(HEADERS)
.m.o: $<
$(CC) -c $(CFLAGS) $(OBJCFLAGS) $(INCLUDES) $< -o $@
DIR = VLC.framework \
VLC.framework/Version/Current/Framework \
VLC.framework/Version/Current/Headers \
VLC.framework/lib/libvlc.dylib: $(top_builddir)/src/.libs/libvlc.dylib VLC.framework/lib
cp -f $(top_builddir)/src/.libs/libvlc.1.dylib VLC.framework/lib/libvlc.dylib && \
install_name_tool -id `pwd`/VLC.framework/lib/libvlc.1.dylib \
VLC.framework/lib/libvlc.dylib
install_name_tool -change @executable_path/lib/vlc_libintl.dylib \
`pwd`/VLC.framework/lib/vlc_libintl.dylib $@
VLC.framework/lib/libvlc-control.dylib: $(top_builddir)/src/.libs/libvlc-control.dylib VLC.framework/lib
mkdir -p VLC.framework/Version/Current/lib && \
cp -f $< $@ && \
install_name_tool -id `pwd`/$@ $@ && \
install_name_tool -change /usr/local/lib/libvlc.1.dylib \
`pwd`/VLC.framework/lib/libvlc.dylib $@
install_name_tool -change @executable_path/lib/vlc_libintl.dylib \
`pwd`/VLC.framework/lib/vlc_libintl.dylib $@
VLC.framework/Headers: $(HEADERS)
mkdir -p VLC.framework/Version/Current/Headers && \
cp -f $(EXPORTED_HEADERS) VLC.framework/Version/Current/Headers && \
ln -sf Version/Current/Headers VLC.framework
VLC.framework/Resources:
mkdir -p VLC.framework/Version/Current/Resources && \
cp -f $(EXPORTED_RESOURCES) VLC.framework/Version/Current/Resources && \
ln -sf Version/Current/Resources VLC.framework
VLC.framework/modules:
/usr/bin/install -c -d ./VLC.framework/Version/Current/modules && \
for i in `top_builddir="$(top_builddir)" $(VLCCONFIG) --target plugin` ; do \
if test -n "$$i" ; \
then \
cp "`pwd`/`dirname $$i`/.libs/`basename $$i`.dylib" \
"./VLC.framework/Version/Current/modules" ; \
module="./VLC.framework/Version/Current/modules/`basename $$i`.dylib"; \
install_name_tool -change /usr/local/lib/libvlc.1.dylib \
@loader_path/../lib/libvlc.dylib \
"$$module"; \
echo "changing install name of $$module";\
for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
install_name_tool -change "$$lib" \
`echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
"$$module"; \
done; \
fi \
done && \
ln -sf Version/Current/modules VLC.framework
VLC.framework/share:
cp -R $(top_builddir)/share ./VLC.framework/Version/Current && \
ln -sf Version/Current/share ./VLC.framework
VLC.framework/lib:
mkdir -p VLC.framework/Version/Current/lib && \
if test -d $(top_builddir)/extras/contrib/vlc-lib; then \
for i in $(top_builddir)/extras/contrib/vlc-lib/*.dylib ; do \
module="VLC.framework/Version/Current/lib/`basename $${i}`"; \
cp `pwd`/$${i} $${module} ; \
install_name_tool -change /usr/local/lib/libvlc.1 @loader_path/../lib/libvlc.dylib \
$${module}; \
echo "changing install name of $$module";\
for lib in `otool -L "$$module" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do \
install_name_tool -change "$$lib" \
`echo "$$lib" | sed 's:executable_path:loader_path/../:'` \
"$$module"; \
done; \
done \
fi && \
ln -sf Version/Current/lib VLC.framework
VLC.framework/VLC:
ln -sf Version/Current/VLC VLC.framework
VLC.framework/Version/Current/VLC: $(OBJECTS) VLC.framework/Headers VLC.framework/Resources VLC.framework/lib/libvlc-control.dylib VLC.framework/lib/libvlc.dylib VLC.framework/modules VLC.framework/share VLC.framework/VLC
mkdir -p VLC.framework/Version/Current/Framework && \
$(CXX) -dynamiclib $(LDFLAGS) $(OBJECTS) $(FRAMEWORKS) -LVLC.framework/lib -lvlc -lvlc-control $(MODULES) $(LIBS) -install_name @loader_path/../Frameworks/VLC.framework/Version/Current/VLC -o VLC.framework/Version/Current/VLC && \
install_name_tool -change `pwd`/VLC.framework/lib/libvlc-control.0.dylib \
`pwd`/VLC.framework/lib/libvlc-control.dylib \
VLC.framework/Version/Current/VLC && \
install_name_tool -change `pwd`/VLC.framework/lib/libvlc.1.dylib \
`pwd`/VLC.framework/lib/libvlc.dylib \
VLC.framework/Version/Current/VLC && \
touch VLC.framework
VLC.framework:: VLC.framework/Version/Current/VLC
.PHONY: clean
clean:
rm -Rf VLC.framework
rm -Rf $(OBJECTS) *.o $(SRC_DIR)/*.o
if [ ${ACTION} = "" ]; then
# Debug --
TARGET_BUILD_DIR="."
FULL_PRODUCT_NAME="VLC.framework"
CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
VLC_BUILD_DIR="../../.."
VLC_SRC_DIR="../../.."
# Debug --
fi
if [ ${ACTION} = "build" ]; then
vlc_config="${VLC_SRC_DIR}/vlc-config"
lib="lib"
modules="modules"
target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
##########################
# @function install_library(src_lib, dest_dir)
# @description Installs the specified library into the destination folder, automatically changes the references to dependencies
# @param src_lib source library to copy to the destination directory
# @param dest_dir destination directory where the src_lib should be copied to
install_library() {
if [ ${3} = "library" ]; then
install_name="@loader_path/lib"
else
install_name="@loader_path/modules"
fi
if [ "${4}" != "" ]; then
lib_dest="${2}/${4}"
else
lib_dest="${2}/`basename ${1}`"
fi
if test -e ${1} && ! test -e ${lib_dest}; then
mkdir -p ${2}
# Lets copy the library from the source folder to our new destination folder
cp ${1} ${lib_dest}
# Update the dynamic library so it will know where to look for the other libraries
echo "Installing ${3} `basename ${lib_dest}`"
# Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
# Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
for linked_lib in `otool -L "${lib_dest}" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do
ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
done
fi
}
# @function install_library
##########################
##########################
# Create a symbolic link in the root of the framework
mkdir -p ${target_lib}
mkdir -p ${target_modules}
pushd `pwd` > /dev/null
cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
ln -sf Versions/Current/${lib} .
ln -sf Versions/Current/${modules} .
popd > /dev/null
# Create a symbolic link in the root of the framework
##########################
##########################
# Build the library folder (Same as VLC.framework/lib in Makefile)
echo "Building library folder..."
# Check to see if there are any vlc libraries available
echo "Copying VLC libraries..."
if test -d ${VLC_BUILD_DIR}/extras/contrib/vlc-lib; then
# Iterate through the dyanmic libraries available
for lib_src in ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/*.dylib ; do
install_library ${lib_src} ${target_lib} "library"
done
fi
# Check to see if there are any core libraries available
echo "Copying core libraries..."
# if test -d ${VLC_BUILD_DIR}/src/.libs; then
# # Iterate through all the core libraries
# for lib_src = ${VLC_BUILD_DIR}/src/.libs/*.dylib; do
# # Only install the library if it is not a symbolic link
# if ! test -L ${lib_src}; then
# echo "install_library ${lib_src} ${target_lib} `echo "${lib_src}" | sed 's:(.\d+)+.dylib:.dylib:'`"
# fi
# done
# fi
install_library "${VLC_BUILD_DIR}/src/.libs/libvlc.dylib" ${target_lib} "library"
install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"
install_library "${VLC_BUILD_DIR}/extras/contrib/vlc-lib/vlc_libintl.dylib" ${target_lib} "library"
# Build the library folder
##########################
##########################
# Build the modules folder (Same as VLC.framework/modules in Makefile)
echo "Building modules folder..."
# Figure out what modules are available to install
for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
# Check to see that the reported module actually exists
if test -n ${module}; then
module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
install_library ${module_src} ${target_modules} "module"
fi
done
# Build the modules folder
##########################
fi
if [ ${ACTION} = "" ]; then
# Debug --
TARGET_BUILD_DIR="."
FULL_PRODUCT_NAME="VLC.framework"
CONTENTS_FOLDER_PATH="${FULL_PRODUCT_NAME}/Versions/A"
VLC_BUILD_DIR="../../.."
VLC_SRC_DIR="../../.."
# Debug --
fi
if [ ${ACTION} = "build" ]; then
vlc_config="${VLC_SRC_DIR}/vlc-config"
lib="lib"
modules="modules"
target="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}"
target_lib="${target}/${lib}" # Should we consider using a different well-known folder like shared resources?
target_modules="${target}/${modules}" # Should we consider using a different well-known folder like shared resources?
##########################
# @function install_library(src_lib, dest_dir)
# @description Installs the specified library into the destination folder, automatically changes the references to dependencies
# @param src_lib source library to copy to the destination directory
# @param dest_dir destination directory where the src_lib should be copied to
install_library() {
if [ ${3} = "library" ]; then
install_name="@loader_path/lib"
else
install_name="@loader_path/modules"
fi
if [ "${4}" != "" ]; then
lib_dest="${2}/${4}"
else
lib_dest="${2}/`basename ${1}`"
fi
if test -e ${1} && ! test -e ${lib_dest}; then
mkdir -p ${2}
# Lets copy the library from the source folder to our new destination folder
cp ${1} ${lib_dest}
# Update the dynamic library so it will know where to look for the other libraries
echo "Installing ${3} `basename ${lib_dest}`"
# Change the reference of libvlc.1 stored in the usr directory to libvlc.dylib in the framework's library directory
install_name_tool -change /usr/local/lib/libvlc.1.dylib @loader_path/../lib/libvlc.dylib ${lib_dest}
install_name_tool -change @executable_path/lib/vlc_libintl.dylib @loader_path/../lib/vlc_libintl.dylib ${lib_dest}
install_name_tool -id "${install_name}/`basename ${lib_dest}`" ${lib_dest}
# Iterate through each installed library and modify the references to other dynamic libraries to match the framework's library directory
for linked_lib in `otool -L "${lib_dest}" | grep @executable_path | sed 's/(\([0-z]*\ *\.*\,*\)*)//g'` ; do
ref_lib=`echo "${linked_lib}" | sed 's:executable_path/:loader_path/../:'`
install_name_tool -change ${linked_lib} ${ref_lib} ${lib_dest}
done
fi
}
# @function install_library
##########################
##########################
# Create a symbolic link in the root of the framework
mkdir -p ${target_lib}
mkdir -p ${target_modules}
pushd `pwd` > /dev/null
cd ${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}
ln -sf Versions/Current/${lib} .
ln -sf Versions/Current/${modules} .
popd > /dev/null
# Create a symbolic link in the root of the framework
##########################
##########################
# Build the library folder (Same as VLC.framework/lib in Makefile)
echo "Building library folder..."
# Check to see if there are any vlc libraries available
echo "Copying VLC libraries..."
if test -d ${VLC_BUILD_DIR}/extras/contrib/vlc-lib; then
# Iterate through the dyanmic libraries available
for lib_src in ${VLC_BUILD_DIR}/extras/contrib/vlc-lib/*.dylib ; do
install_library ${lib_src} ${target_lib} "library"
done
fi
# Check to see if there are any core libraries available
echo "Copying core libraries..."
# if test -d ${VLC_BUILD_DIR}/src/.libs; then
# # Iterate through all the core libraries
# for lib_src = ${VLC_BUILD_DIR}/src/.libs/*.dylib; do
# # Only install the library if it is not a symbolic link
# if ! test -L ${lib_src}; then
# echo "install_library ${lib_src} ${target_lib} `echo "${lib_src}" | sed 's:(.\d+)+.dylib:.dylib:'`"
# fi
# done
# fi
install_library "${VLC_BUILD_DIR}/src/.libs/libvlc.dylib" ${target_lib} "library"
install_library "${VLC_BUILD_DIR}/src/.libs/libvlc-control.dylib" ${target_lib} "library"
install_library "${VLC_BUILD_DIR}/extras/contrib/vlc-lib/vlc_libintl.dylib" ${target_lib} "library"
# Build the library folder
##########################
##########################
# Build the modules folder (Same as VLC.framework/modules in Makefile)
echo "Building modules folder..."
# Figure out what modules are available to install
for module in `top_builddir="${VLC_BUILD_DIR}" ${vlc_config} --target plugin` ; do
# Check to see that the reported module actually exists
if test -n ${module}; then
module_src="`dirname ${module}`/.libs/`basename ${module}`.dylib"
install_library ${module_src} ${target_modules} "module"
fi
done
# Build the modules folder
##########################
fi
\ No newline at end of file
/*****************************************************************************
* VLCAudio.m: VLC.framework VLCAudio implementation
*****************************************************************************
* Copyright (C) 2007 Faustino E. Osuna
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Faustino E. Osuna <enrique.osuna # gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "VLCAudio.h"
#import "VLCLibVLCBridging.h"
/* Notification Messages */
NSString *VLCMediaPlayerVolumeChanged = @"VLCMediaPlayerVolumeChanged";
/* libvlc event callback */
// TODO: Callbacks
@implementation VLCAudio
- (id)init
{
return nil;
}
- (id)initWithLibrary:(VLCLibrary *)aLibrary
{
if (![library audio] && (self = [super init]))
{
library = aLibrary;
[library setAudio:self];
}
return self;
}
- (void)setMute:(BOOL)value
{
libvlc_audio_set_mute([library instance], value, NULL);
}
- (BOOL)isMuted
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
BOOL result = libvlc_audio_get_mute([library instance], &ex);
quit_on_exception(&ex);
return result;
}
- (void)setVolume:(int)value
{
if (value < 0)
value = 0;
else if (value > 200)
value = 200;
libvlc_audio_set_volume([library instance], value, NULL);
}
- (int)volume
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
int result = libvlc_audio_get_volume([library instance], &ex);
quit_on_exception(&ex);
return result;
}
@end
\ No newline at end of file
...@@ -44,13 +44,15 @@ struct message { ...@@ -44,13 +44,15 @@ struct message {
enum message_type_t type; enum message_type_t type;
}; };
@interface VLCEventManager (Private) @interface VLCEventManager (PrivateAPI)
- (void)callDelegateOfObjectAndSendNotificationWithArgs:(NSData*)data; - (void)callDelegateOfObjectAndSendNotificationWithArgs:(NSData*)data;
- (void)callObjectMethodWithArgs:(NSData*)data; - (void)callObjectMethodWithArgs:(NSData*)data;
- (void)callDelegateOfObject:(id) aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName; - (void)callDelegateOfObject:(id) aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName;
- (pthread_cond_t *)signalData; - (pthread_cond_t *)signalData;
- (pthread_mutex_t *)queueLock; - (pthread_mutex_t *)queueLock;
- (NSMutableArray *)messageQueue; - (NSMutableArray *)messageQueue;
@end @end
static void * EventDispatcherMainLoop(void * user_data) static void * EventDispatcherMainLoop(void * user_data)
...@@ -68,10 +70,10 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -68,10 +70,10 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
/* Wait until we have something on the queue */ /* Wait until we have something on the queue */
if ([[self messageQueue] count] <= 0 ) do { while([[self messageQueue] count] <= 0 )
{
pthread_cond_wait( [self signalData], [self queueLock] ); pthread_cond_wait( [self signalData], [self queueLock] );
} while([[self messageQueue] count] <= 0 ); }
message = (struct message *)[(NSData *)[[self messageQueue] lastObject] bytes]; message = (struct message *)[(NSData *)[[self messageQueue] lastObject] bytes];
/* Don't send the same notification twice */ /* Don't send the same notification twice */
...@@ -82,6 +84,7 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -82,6 +84,7 @@ static void * EventDispatcherMainLoop(void * user_data)
message_newer = (struct message *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes]; message_newer = (struct message *)[(NSData *)[[self messageQueue] objectAtIndex: i] bytes];
if( message_newer->type != VLCNotification ) if( message_newer->type != VLCNotification )
continue; continue;
if( message_newer->target == message->target && message_newer->target == message->target && [message_newer->u.name isEqualToString:message->u.name] ) if( message_newer->target == message->target && message_newer->target == message->target && [message_newer->u.name isEqualToString:message->u.name] )
{ {
[message_newer->target release]; [message_newer->target release];
...@@ -106,10 +109,12 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -106,10 +109,12 @@ static void * EventDispatcherMainLoop(void * user_data)
pthread_mutex_unlock( [self queueLock] ); pthread_mutex_unlock( [self queueLock] );
[pool release]; [pool release];
} };
return nil;
} }
@implementation VLCEventManager @implementation VLCEventManager
+ (id)sharedManager + (id)sharedManager
{ {
/* We do want a lock here to avoid leaks */ /* We do want a lock here to avoid leaks */
...@@ -137,33 +142,54 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -137,33 +142,54 @@ static void * EventDispatcherMainLoop(void * user_data)
{ {
pthread_kill( dispatcherThread, SIGKILL ); pthread_kill( dispatcherThread, SIGKILL );
pthread_join( dispatcherThread, NULL ); pthread_join( dispatcherThread, NULL );
[messageQueue release];
[super dealloc]; [super dealloc];
} }
- (void)callOnMainThreadDelegateOfObject:(id)aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName - (void)callOnMainThreadDelegateOfObject:(id)aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
struct message message = { [aTarget retain], aSelector, [aNotificationName retain], VLCNotification };
struct message message =
{
[aTarget retain],
aSelector,
[aNotificationName retain],
VLCNotification
};
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
pthread_cond_signal( [self signalData] ); pthread_cond_signal( [self signalData] );
pthread_mutex_unlock( [self queueLock] ); pthread_mutex_unlock( [self queueLock] );
[pool release]; [pool release];
} }
- (void)callOnMainThreadObject:(id)aTarget withMethod:(SEL)aSelector withArgumentAsObject: (id)arg - (void)callOnMainThreadObject:(id)aTarget withMethod:(SEL)aSelector withArgumentAsObject: (id)arg
{ {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
struct message message = { [aTarget retain], aSelector, [arg retain], VLCObjectMethodWithObjectArg };
struct message message =
{
[aTarget retain],
aSelector,
[arg retain],
VLCObjectMethodWithObjectArg
};
pthread_mutex_lock( [self queueLock] ); pthread_mutex_lock( [self queueLock] );
[[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0]; [[self messageQueue] insertObject:[NSData dataWithBytes:&message length:sizeof(struct message)] atIndex:0];
pthread_cond_signal( [self signalData] ); pthread_cond_signal( [self signalData] );
pthread_mutex_unlock( [self queueLock] ); pthread_mutex_unlock( [self queueLock] );
[pool release]; [pool release];
} }
@end @end
@implementation VLCEventManager (Private) @implementation VLCEventManager (PrivateAPI)
- (void)callDelegateOfObjectAndSendNotificationWithArgs:(NSData*)data - (void)callDelegateOfObjectAndSendNotificationWithArgs:(NSData*)data
{ {
struct message * message = (struct message *)[data bytes]; struct message * message = (struct message *)[data bytes];
...@@ -185,11 +211,11 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -185,11 +211,11 @@ static void * EventDispatcherMainLoop(void * user_data)
[data release]; [data release];
} }
- (NSMutableArray *)messageQueue - (NSMutableArray *)messageQueue
{ {
return messageQueue; return messageQueue;
} }
- (pthread_cond_t *)signalData - (pthread_cond_t *)signalData
{ {
return &signalData; return &signalData;
...@@ -202,17 +228,13 @@ static void * EventDispatcherMainLoop(void * user_data) ...@@ -202,17 +228,13 @@ static void * EventDispatcherMainLoop(void * user_data)
- (void)callDelegateOfObject:(id) aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName - (void)callDelegateOfObject:(id) aTarget withDelegateMethod:(SEL)aSelector withNotificationName: (NSString *)aNotificationName
{ {
NSMethodSignature * aSignature; // [[NSNotificationCenter defaultCenter] postNotification: [NSNotification notificationWithName:aNotificationName object:aTarget]];
NSInvocation * anInvocation;
[[NSNotificationCenter defaultCenter] postNotification: [NSNotification notificationWithName:aNotificationName object:aTarget]];
if (![aTarget delegate] || ![[aTarget delegate] respondsToSelector: aSelector]) if (![aTarget delegate] || ![[aTarget delegate] respondsToSelector: aSelector])
return; return;
/* NSInvocation could maybe be prefered here */
void (*method)(id, SEL, id) = (void (*)(id, SEL, id))[[aTarget delegate] methodForSelector: aSelector]; void (*method)(id, SEL, id) = (void (*)(id, SEL, id))[[aTarget delegate] methodForSelector: aSelector];
method( [aTarget delegate], aSelector, [NSNotification notificationWithName:aNotificationName object:aTarget]); method( [aTarget delegate], aSelector, [NSNotification notificationWithName:aNotificationName object:aTarget]);
} }
@end @end
...@@ -24,23 +24,129 @@ ...@@ -24,23 +24,129 @@
#import "VLCLibrary.h" #import "VLCLibrary.h"
static libvlc_instance_t * shared_instance = NULL; #include <vlc/vlc.h>
#include <vlc/libvlc_structures.h>
static VLCLibrary *sharedLibrary = nil;
// TODO: Change from a terminal error to raising an exception?
void __quit_on_exception( void * e, const char * function, const char * file, int line_number )
{
libvlc_exception_t *ex = (libvlc_exception_t *)e;
if (libvlc_exception_raised( ex ))
{
/* XXX: localization */
NSRunCriticalAlertPanel( @"Error", [NSString stringWithFormat:@"libvlc has thrown us an error: %s (%s:%d %s)",
libvlc_exception_get_message(ex), file, line_number, function], @"Quit", nil, nil );
exit( ex->i_code );
}
}
static void *DestroySharedLibraryAtExit()
{
// Destroy the shared library
if (sharedLibrary)
[sharedLibrary release];
sharedLibrary = nil;
return nil;
}
@implementation VLCLibrary @implementation VLCLibrary
+ (libvlc_instance_t *)sharedInstance
+ (VLCLibrary *)sharedLibrary
{
if (!sharedLibrary)
{
// Initialize a shared instance
[[self alloc] init];
// Register a function to gracefully destroy the shared library on exit.
atexit((void*)DestroySharedLibraryAtExit);
}
return sharedLibrary;
}
+ (void *)sharedInstance
{
return [[self sharedLibrary] instance];
}
- (id)init
{ {
if(!shared_instance) if (self = [super init])
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
char *lib_vlc_params[] = { "vlc", "-I", "dummy",
"--opengl-provider=minimal_macosx",
"-vvvvvv" };
libvlc_exception_init( &ex ); libvlc_exception_init( &ex );
shared_instance = libvlc_new( 5, lib_vlc_params, &ex ); // Figure out the frameworks path
char *applicationPath = strdup([[NSString stringWithFormat:@"%@/Versions/Current/VLC",
[[NSBundle bundleForClass:[VLCLibrary class]] bundlePath]] UTF8String]);
// TODO: Raise error if there is no memory available
char *lib_vlc_params[] = {
applicationPath, "-I", "dummy", "-vvvv",
"--opengl-provider", "minimal_macosx",
"--no-video-title-show", NULL
};
instance = (void *)libvlc_new(7, lib_vlc_params, &ex);
quit_on_exception( &ex ); quit_on_exception( &ex );
if (!sharedLibrary)
sharedLibrary = [[self retain] autorelease];
// Assignment unneeded, as the audio unit will do it for us
/*audio = */ [[VLCAudio alloc] initWithLibrary:self];
// free allocated resources
free(applicationPath);
} }
return shared_instance; return self;
} }
- (void)dealloc
{
// TODO: libvlc core locks up or has segfaults while shutting down, the
// following code allows for the framework to be removed without crashing
// the host application.
@try
{
if (instance)
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_destroy(instance, &ex);
}
}
@finally
{
instance = nil;
[audio release];
[super dealloc];
}
}
- (void *)instance
{
return instance;
}
- (VLCAudio *)audio
{
return audio;
}
@end
@implementation VLCLibrary (VLCAudioBridging)
- (void)setAudio:(VLCAudio *)value
{
if (!audio)
audio = value;
}
@end @end
This diff is collapsed.
...@@ -23,17 +23,19 @@ ...@@ -23,17 +23,19 @@
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <VLC/VLCMediaLibrary.h> #import "VLCMediaLibrary.h"
#import "VLCLibrary.h" #import "VLCLibrary.h"
#import "VLCLibVLCBridging.h"
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
static VLCMediaLibrary * sharedMediaLibrary = NULL; static VLCMediaLibrary * sharedMediaLibrary = nil;
@implementation VLCMediaLibrary @implementation VLCMediaLibrary
+ (id)sharedMediaLibrary + (id)sharedMediaLibrary
{ {
if( !sharedMediaLibrary ) if(!sharedMediaLibrary)
{ {
sharedMediaLibrary = [[VLCMediaLibrary alloc] init]; sharedMediaLibrary = [[VLCMediaLibrary alloc] init];
} }
...@@ -48,8 +50,9 @@ static VLCMediaLibrary * sharedMediaLibrary = NULL; ...@@ -48,8 +50,9 @@ static VLCMediaLibrary * sharedMediaLibrary = NULL;
libvlc_exception_init( &p_e ); libvlc_exception_init( &p_e );
mlib = libvlc_media_library_new( [VLCLibrary sharedInstance], &p_e ); mlib = libvlc_media_library_new( [VLCLibrary sharedInstance], &p_e );
quit_on_exception( &p_e ); quit_on_exception( &p_e );
libvlc_media_library_load( mlib, &p_e );
quit_on_exception( &p_e ); libvlc_media_library_load(mlib, &p_e);
quit_on_exception(&p_e);
allMedia = nil; allMedia = nil;
} }
return self; return self;
...@@ -57,31 +60,34 @@ static VLCMediaLibrary * sharedMediaLibrary = NULL; ...@@ -57,31 +60,34 @@ static VLCMediaLibrary * sharedMediaLibrary = NULL;
- (void)dealloc - (void)dealloc
{ {
if (allMedia) [allMedia release];
[allMedia release];
libvlc_media_library_release( mlib ); libvlc_media_library_release(mlib);
mlib = nil; // make sure that the pointer is dead
[super dealloc]; [super dealloc];
} }
- (VLCPlaylist *)allMedia - (VLCMediaList *)allMedia
{ {
if (!allMedia) if (!allMedia)
{ {
libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib, NULL ); // libvlc_media_list_t *p_mlist = libvlc_media_library_media_list(mlib, NULL);
libvlc_media_list_t * p_flat_mlist = libvlc_media_list_flat_media_list( p_mlist, NULL ); // libvlc_media_list_t * p_flat_mlist = libvlc_media_list_flat_media_list(p_mlist, NULL);
allMedia = [[VLCPlaylist playlistWithLibVLCMediaList: p_flat_mlist] retain]; // allMedia = [[VLCMediaList medialistWithLibVLCMediaList: p_flat_mlist] retain];
libvlc_media_list_release( p_flat_mlist ); // libvlc_media_list_release(p_flat_mlist);
libvlc_media_list_release( p_mlist ); // libvlc_media_list_release(p_mlist);
} }
return allMedia; return allMedia;
} }
- (NSArray *) playlists - (NSArray *)playlists
{ {
libvlc_media_list_t * p_mlist = libvlc_media_library_media_list( mlib, NULL ); libvlc_media_list_t *p_mlist = libvlc_media_library_media_list( mlib, NULL );
VLCPlaylist * playlist = [VLCPlaylist playlistWithLibVLCMediaList: p_mlist]; VLCMediaList *medialist = [VLCMediaList medialistWithLibVLCMediaList:p_mlist];
libvlc_media_list_release( p_mlist ); libvlc_media_list_release(p_mlist);
NSArray * ret = [playlist sublists]; NSArray *ret = [medialist sublists];
return ret; return ret;
} }
@end @end
/*****************************************************************************
* VLCMediaList.m: VLC.framework VLCMediaList implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "VLCMediaList.h"
#import "VLCLibrary.h"
#import "VLCEventManager.h"
#import "VLCLibVLCBridging.h"
#include <vlc/vlc.h>
#include <vlc/libvlc.h>
/* Notification Messages */
NSString *VLCMediaListItemAdded = @"VLCMediaListItemAdded";
NSString *VLCMediaListItemDeleted = @"VLCMediaListItemDeleted";
// TODO: Documentation
@interface VLCMediaList (PrivateAPI)
/* Initializers */
- (void)initInternalMediaList;
/* Libvlc event bridges */
- (void)mediaListItemAdded:(NSArray *)args;
- (void)mediaListItemRemoved:(NSNumber *)index;
@end
/* libvlc event callback */
static void HandleMediaListItemAdded(const libvlc_event_t *event, void *user_data)
{
id self = user_data;
// Check to see if the last item added is this item we're trying to introduce
// If no, then add the item to the local list, otherwise, the item has already
// been added
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemAdded:)
withArgumentAsObject:[NSArray arrayWithObjects:[VLCMedia mediaWithLibVLCMediaDescriptor:event->u.media_list_item_added.item],
[NSNumber numberWithInt:event->u.media_list_item_added.index], nil]];
}
static void HandleMediaListItemDeleted( const libvlc_event_t * event, void * user_data)
{
id self = user_data;
// Check to see if the last item deleted is this item we're trying delete now.
// If no, then delete the item from the local list, otherwise, the item has already
// been deleted
[[VLCEventManager sharedManager] callOnMainThreadObject:self
withMethod:@selector(mediaListItemRemoved:)
withArgumentAsObject:[NSNumber numberWithInt:event->u.media_list_item_deleted.index]];
}
@implementation VLCMediaList
- (id)init
{
if (self = [super init])
{
// Create a new libvlc media list instance
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
p_mlist = libvlc_media_list_new([VLCLibrary sharedInstance], &p_e);
quit_on_exception(&p_e);
// Initialize internals to defaults
delegate = nil;
[self initInternalMediaList];
}
return self;
}
- (void)release
{
@synchronized(self)
{
if([self retainCount] <= 1)
{
/* We must make sure we won't receive new event after an upcoming dealloc
* We also may receive a -retain in some event callback that may occcur
* Before libvlc_event_detach. So this can't happen in dealloc */
libvlc_event_manager_t * p_em = libvlc_media_list_event_manager(p_mlist, NULL);
libvlc_event_detach(p_em, libvlc_MediaListItemDeleted, HandleMediaListItemDeleted, self, NULL);
libvlc_event_detach(p_em, libvlc_MediaListItemAdded, HandleMediaListItemAdded, self, NULL);
}
[super release];
}
}
- (void)dealloc
{
// Release allocated memory
libvlc_media_list_release(p_mlist);
[super dealloc];
}
- (void)setDelegate:(id)value
{
delegate = value;
}
- (id)delegate
{
return delegate;
}
- (void)lock
{
libvlc_media_list_lock(p_mlist);
}
- (void)unlock
{
libvlc_media_list_unlock(p_mlist);
}
- (int)addMedia:(VLCMedia *)media
{
int index = [self count];
[self insertMedia:media atIndex:index];
return index;
}
- (void)insertMedia:(VLCMedia *)media atIndex: (int)index
{
[media retain];
// Add it to the libvlc's medialist
libvlc_exception_t p_e;
libvlc_exception_init( &p_e );
libvlc_media_list_insert_media_descriptor(p_mlist, [media libVLCMediaDescriptor], index, &p_e);
quit_on_exception(&p_e);
}
- (void)removeMediaAtIndex:(int)index
{
[[self mediaAtIndex:index] release];
// Remove it from the libvlc's medialist
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
libvlc_media_list_remove_index(p_mlist, index, &p_e);
quit_on_exception(&p_e);
}
- (VLCMedia *)mediaAtIndex:(int)index
{
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
libvlc_media_descriptor_t *p_md = libvlc_media_list_item_at_index(p_mlist, index, &p_e);
quit_on_exception(&p_e);
// Returns local object for media descriptor, searchs for user data first. If not found it creates a
// new cocoa object representation of the media descriptor.
return [VLCMedia mediaWithLibVLCMediaDescriptor:p_md];
}
- (int)count
{
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
int result = libvlc_media_list_count(p_mlist, &p_e);
quit_on_exception(&p_e);
return result;
}
- (int)indexOfMedia:(VLCMedia *)media
{
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
int result = libvlc_media_list_index_of_item(p_mlist, [media libVLCMediaDescriptor], &p_e);
quit_on_exception(&p_e);
return result;
}
- (NSArray *)sublists
{
NSMutableArray *ret = [[NSMutableArray alloc] initWithCapacity: 0];
int i, count;
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
count = libvlc_media_list_count(p_mlist, &p_e);
quit_on_exception(&p_e);
for(i = 0; i < count; i++)
{
libvlc_media_descriptor_t *p_md;
libvlc_media_list_t *p_submlist;
p_md = libvlc_media_list_item_at_index(p_mlist, i, NULL);
p_submlist = libvlc_media_descriptor_subitems(p_md, NULL);
if(p_submlist)
{
[ret addObject:[VLCMediaList medialistWithLibVLCMediaList:p_submlist]];
libvlc_media_list_release(p_submlist);
}
libvlc_media_descriptor_release(p_md);
}
return [ret autorelease];
}
//- (VLCMediaList *)flatPlaylist
//{
// VLCMediaList * flatPlaylist;
// libvlc_exception_t p_e;
// libvlc_exception_init( &p_e );
// libvlc_media_list_t * p_flat_mlist = libvlc_media_list_flat_media_list( p_mlist, &p_e );
// quit_on_exception( &p_e );
// flatPlaylist = [VLCMediaList medialistWithLibVLCMediaList: p_flat_mlist];
// libvlc_media_list_release( p_flat_mlist );
// return flatPlaylist;
//}
//
//- (VLCMedia *)providerMedia
//{
// VLCMedia * ret;
// libvlc_exception_t p_e;
// libvlc_exception_init( &p_e );
// libvlc_media_descriptor_t * p_md = libvlc_media_list_media_descriptor( p_mlist, &p_e );
// ret = [VLCMedia mediaWithLibVLCMediaDescriptor: p_md];
// libvlc_media_descriptor_release( p_md );
// quit_on_exception( &p_e );
// return ret;
//}
@end
@implementation VLCMediaList (LibVLCBridging)
+ (id)medialistWithLibVLCMediaList:(void *)p_new_mlist;
{
return [[[VLCMediaList alloc] initWithLibVLCMediaList:p_new_mlist] autorelease];
}
- (id)initWithLibVLCMediaList:(void *)p_new_mlist;
{
if( self = [super init] )
{
p_mlist = p_new_mlist;
libvlc_media_list_retain(p_mlist);
[self initInternalMediaList];
}
return self;
}
- (void *)libVLCMediaList
{
return p_mlist;
}
@end
@implementation VLCMediaList (PrivateAPI)
- (void)initInternalMediaList
{
// Add event callbacks
[self lock];
libvlc_exception_t p_e;
libvlc_exception_init(&p_e);
libvlc_event_manager_t *p_em = libvlc_media_list_event_manager(p_mlist, &p_e);
libvlc_event_attach(p_em, libvlc_MediaListItemAdded, HandleMediaListItemAdded, self, &p_e);
libvlc_event_attach(p_em, libvlc_MediaListItemDeleted, HandleMediaListItemDeleted, self, &p_e);
[self unlock];
quit_on_exception( &p_e );
}
- (void)mediaListItemAdded:(NSArray *)args
{
VLCMedia *media = [args objectAtIndex:0];
NSNumber *index = [args objectAtIndex:1];
// Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemAdded
object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
media, @"media",
index, @"index",
nil]];
// Let the delegate know that the item was added
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaAdded:atIndex:)])
[delegate mediaList:self mediaAdded:media atIndex:[index intValue]];
}
- (void)mediaListItemRemoved:(NSNumber *)index
{
// Post the notification
[[NSNotificationCenter defaultCenter] postNotificationName:VLCMediaListItemDeleted
object:self
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
index, @"index",
nil]];
// Let the delegate know that the item is being removed
if (delegate && [delegate respondsToSelector:@selector(mediaList:mediaRemovedAtIndex:)])
[delegate mediaList:self mediaRemovedAtIndex:index];
}
@end
This diff is collapsed.
...@@ -22,35 +22,97 @@ ...@@ -22,35 +22,97 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#import <VLC/VLCTime.h> #import <VLCTime.h>
static VLCTime *nullTime = nil;
@implementation VLCTime @implementation VLCTime
+ (VLCTime *)nullTime
{
if (!nullTime)
nullTime = [VLCTime timeWithNumber:[NSNumber numberWithInt:0]];
return nullTime;
}
+ (VLCTime *)timeWithNumber:(NSNumber *)aNumber
{
return [[[VLCTime alloc] initWithNumber:aNumber] autorelease];
}
// TODO: Implement [VLCTime timeWithString]
//+ (VLCTime *)timeWithString:(NSString *)aString
//{
// return [[[VLCTime alloc] initWithString:aString] autorelease];
//}
- (id)initWithNumber:(NSNumber *)aNumber - (id)initWithNumber:(NSNumber *)aNumber
{ {
if (self = [super init]) if (self = [super init])
{ {
value = [aNumber copy]; if (aNumber)
value = [[aNumber copy] retain];
else
value = nil;
} }
return self; return self;
} }
// TODO: Implement [VLCTime initWithString]
//- (id)initWithString:(NSString *)aString
//{
// // Sounds like a good idea but I really don't think there is any value added
// if (self = [super init])
// {
// // convert value
// }
// return self;
//}
- (void)dealloc - (void)dealloc
{ {
[value release]; [value release];
[super dealloc]; [super dealloc];
} }
- (NSNumber *)numberRepresentation - (NSNumber *)numberValue
{ {
[[value copy] autorelease]; if (value)
return [value copy];
else
return nil;
} }
- (NSString *)stringRepresentation - (NSString *)stringValue
{ {
int hours = [value intValue] / (3600*1000); if (value)
int minutes = ([value intValue] - hours * 3600) / (60*1000); {
int seconds = ([value intValue] - hours * 3600 * 1000 - minutes * 60 * 1000)/1000; long long duration = [value longLongValue] / 1000000;
return [NSString stringWithFormat:@"%02d:%02d:%02d",
(long) (duration / 3600),
(long)((duration / 60) % 60),
(long) (duration % 60)];
}
else
{
// Return a string that represents an undefined time.
return @"--:--:--";
}
}
return [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds]; - (NSComparisonResult)compare:(VLCTime *)aTime
{
if (!aTime && !value)
return NSOrderedSame;
else if (!aTime)
return NSOrderedDescending;
else
return [value compare:[aTime numberValue]];
} }
- (NSString *)description
{
return [self stringValue];
}
@end @end
//
// test.m - Nothing useful yet
// VLC.framework
//
// Created by Pierre d'Herbemont on 13/04/07.
// Copyright __MyCompanyName__ 2007. All rights reserved.
//
#include <VLC/VLC.h>
int test_vlc_framework()
{
return 0xbabe;
}
TODO List:
- Add user data into media_descriptor to reference internal VLC object -- fix not committed to SVN.
- Fix stream.c to recognize VLC_ENOOBJECT
- Easy way to tell the length of the movie without having to instiate the demuxer. Maybe cached info?
- Hook into "length" variable for media streams vs. using intf-change as a hook.
- Figure out a better way to raise error messages versus quit_on_exception
- Have VLCMedia search for playable files when directories are referenced.
- Only fetch meta data that has been requested. Just don't fetch it, just because.
- md callback to notify VLCMedia that it is about to be destroyed.
- add media_list_player
Changelog
- VLCMediaControl eliminated
- setView/view renamed to setVideoView/videoView
- VLCMediaPlayer NSView *view changed to VLCVideoView *videoView
- VLCMediaPlayer initWithView changed to initWithVideoView:(VLCVideoView *)aVideoView
- Updated VLCMediaPlayer.videoSize from NSRect to NSSize
- Updated Pre-Compile.sh script to create symbolic links based on relative pathes
- More issues with VLCTime length, released object by setting to nil
- Added VLCMedia.h to VLCMediaPlayer.h.
- Static linked libvlc-control.a and libvlc.a -- dynamically linked libiconv (system file) and vlc_libintl.dylib
eliminates errors and warning messages when framework linked against other applications.
This diff is collapsed.
//
// Prefix header for all source files of the 'VLC' target in the 'VLC' project.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
#include <vlc/vlc.h>
#ifndef VLC_PUBLIC_API
// For some reason Xcode refuses to read vlc/vlc.h contents -- so we have to do
// this so we can supress the errors
#define VLC_PUBLIC_API extern
typedef int vlc_bool_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef signed long long vlc_int64_t;
#endif
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc.h>
//
// Prefix header for all source files of the 'VLC' target in the 'VLC' project.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
#include <vlc/vlc.h>
#ifndef VLC_PUBLIC_API
// For some reason Xcode refuses to read vlc/vlc.h contents -- so we have to do
// this so we can supress the errors
#define VLC_PUBLIC_API extern
typedef int vlc_bool_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef signed long long vlc_int64_t;
#endif
#include <vlc/libvlc_structures.h>
#include <vlc/libvlc.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment