This commit is contained in:
Gregory Casamento 2025-03-25 07:15:35 +00:00 committed by GitHub
commit 298e62c828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 9333 additions and 42 deletions

4
.gitignore vendored
View file

@ -18,6 +18,10 @@ Source/Info-gnustep.plist
Tests/gui/*/GNUmakefile
Tools/speech/GSSpeechServer.app
Tools/speech_recognizer/GSSpeechRecognitionServer.app
Tools/sound/AudioOutput.nssound
Tools/sound/Sndfile.nssound
Tools/video/VideoFile.nsmovie
Tools/video/VideoOutput.nsmovie
*~
*.nssound
*.nsmovie

View file

@ -291,6 +291,26 @@
* Source/NSImageCell.m: subclass initImageCell, so that
RefusesFirstResponder can be set, matching Mac.
2022-03-27 Gregory John Casamento <greg.casamento@gmail.com>
* config.make.in: Add video flag
* configure.ac: Update to detect avformat.h
* Headers/Additions/GNUstepGUI/GSVideoSink.h
* Headers/Additions/GNUstepGUI/GSVideoSource.h: Add protocol
methods for reading and playing video.
* Headers/AppKit/NSMovie.h: Minor formatting changes.
* Headers/AppKit/NSMovieView.h: Minor formatting changes.
* Headers/AppKit/NSSound.h: Minor formatting changes
* Source/NSMovie.m: Fixes.
* Source/NSMovieView.m: Implement _stream method
* Source/NSSound.m: Minor formatting changes
* Tools/GNUmakefile: Cleanup
* Tools/video/GNUmakefile: Minor fixes
* Tools/video/VideoFileSource.m: Implementation of
readBytes:length: method for reading from the NSData.
* Tools/video/VideoOutputSink.m: Implementation of
playBytes:length: for playing the bytes as a movie.
2022-02-26 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSPopUpButtonCell.m(setMenu:): Select the first item of

View file

@ -0,0 +1,83 @@
/*
GSVideoSink.h
Sink video data.
Copyright (C) 2022 Free Software Foundation, Inc.
Written by: Gregory John Casamento <greg.casamento@gmail.com>
Date: Mar 2022
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_GSVideoSink
#define _GNUstep_H_GSVideoSink
#import <Foundation/NSByteOrder.h>
#import <Foundation/NSObject.h>
@class NSMovie;
@class NSMovieView;
@protocol GSVideoSink <NSObject>
+ (BOOL) canInitWithData: (NSData *)d;
/**
* Opens the device for output, called by [NSMovie-play].
*/
- (BOOL) open;
/** Closes the device, called by [NSMovie-stop].
*/
- (void) close;
/**
* Play the entire video
*/
- (void) play;
/**
* Plays the data in bytes
*/
- (BOOL) playBytes: (void *)bytes length: (NSUInteger)length;
/** Called by [NSMovieView -setVolume:], and corresponds to it. Parameter volume
* is between the values 0.0 and 1.0.
*/
- (void) setVolume: (float)volume;
/** Called by [NSMovieView -volume].
*/
- (CGFloat) volume;
/**
* Sets the view to output to.
*/
- (void) setMovieView: (NSMovieView *)view;
/**
* The movie view
*/
- (NSMovieView *) movieView;
@end
#endif // _GNUstep_H_GSVideoSink

View file

@ -0,0 +1,76 @@
/*
GSVideoSource.h
Load and read video data.
Copyright (C) 2022 Free Software Foundation, Inc.
Written by: Gregory John Casamento <greg.casamento@gmail.com>
Date: Mar 2022
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_GSVideoSource
#define _GNUstep_H_GSVideoSource
#import <Foundation/NSByteOrder.h>
#import <Foundation/NSObject.h>
@class NSArray;
@protocol GSVideoSource <NSObject>
/** Returns an array of the file types supported by the class.
*/
+ (NSArray *)videoUnfilteredFileTypes;
/** Returns an array of UTIs identifying the file types the class understands.
*/
+ (NSArray *)videoUnfilteredTypes;
/** Returns YES if the class can understand data and NO otherwise.
*/
+ (BOOL)canInitWithData: (NSData *)data;
/** <init />
* Initilizes the reciever for output.
*/
- (id)initWithData: (NSData *)data;
/** Reads data provided in -initWithData:. Parameter bytes must be big enough
* to hold length bytes.
*/
- (NSUInteger)readBytes: (void *)bytes length: (NSUInteger)length;
/** Returns the duration, in seconds. Equivalent to [NSMovieView-duration].
*/
- (NSTimeInterval)duration;
/** Called by [NSSound-setCurrentTime:].
*/
- (void)setCurrentTime: (NSTimeInterval)currentTime;
/** Called by [NSSound-currentTime].
*/
- (NSTimeInterval)currentTime;
@end
#endif // _GNUstep_H_GSVideoSource

View file

@ -7,6 +7,9 @@
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2003
Author: Gregory John Casamento <greg.casamento@gmail.com>
Date: March 2022
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -28,7 +31,11 @@
#ifndef _GNUstep_H_NSMovie
#define _GNUstep_H_NSMovie
#import <AppKit/AppKitDefines.h>
#import <GNUstepBase/GSVersionMacros.h>
#import <GNUstepGUI/GSVideoSource.h>
#import <GNUstepGUI/GSVideoSink.h>
#import <Foundation/NSObject.h>
@ -41,20 +48,53 @@ APPKIT_EXPORT_CLASS
@interface NSMovie : NSObject <NSCopying, NSCoding>
{
@private
NSData* _movie;
NSURL* _url;
NSData *_movieData;
NSURL *_url;
void *_movie;
id< GSVideoSource > _source;
id< GSVideoSink > _sink;
}
+ (NSArray*) movieUnfilteredFileTypes;
+ (NSArray*) movieUnfilteredPasteboardTypes;
+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard;
/**
* Returns the array of file types/extensions that NSMovie can handle
*/
+ (NSArray *) movieUnfilteredFileTypes;
- (id) initWithMovie: (void*)movie;
- (id) initWithURL: (NSURL*)url byReference: (BOOL)byRef;
- (id) initWithPasteboard: (NSPasteboard*)pasteboard;
/**
* Returns the array of pasteboard types that NSMovie can handle
*/
+ (NSArray *) movieUnfilteredPasteboardTypes;
- (void*) QTMovie;
- (NSURL*) URL;
/**
* Returns YES, if NSMovie can initialize with the data on the pasteboard
*/
+ (BOOL) canInitWithPasteboard: (NSPasteboard *)pasteboard;
/**
* Accepts a Carbon movie and uses it to init NSMovie (non-functional on GNUstep).
*/
- (id) initWithMovie: (void *)movie;
/**
* Retrieves the data from url and initializes with it, does so by references depending
* on byRef
*/
- (id) initWithURL: (NSURL *)url byReference: (BOOL)byRef;
/**
* Pulls the data from the pasteboard and initializes NSMovie.
*/
- (id) initWithPasteboard: (NSPasteboard *)pasteboard;
/**
* Return QTMovie
*/
- (void *) QTMovie;
/**
* The URL used to initialize NSMovie
*/
- (NSURL *) URL;
@end

View file

@ -33,6 +33,8 @@
#import <AppKit/NSView.h>
@class NSMovie;
@class NSConditionLock;
@class NSLock;
typedef enum {
NSQTMovieNormalPlayback,
@ -44,9 +46,13 @@ APPKIT_EXPORT_CLASS
@interface NSMovieView : NSView
{
@protected
NSMovie* _movie;
float _rate;
float _volume;
NSMovie *_movie;
CGFloat _rate;
CGFloat _volume;
NSConditionLock *_readLock;
NSLock *_playbackLock;
BOOL _shouldLoop;
BOOL _shouldStop;
struct NSMovieViewFlags {
unsigned int muted: 1;
unsigned int loopMode: 3;
@ -58,50 +64,186 @@ APPKIT_EXPORT_CLASS
} _flags;
}
/**
* Set the NSMovie object to play
*/
- (void) setMovie: (NSMovie*)movie;
/**
* the NSMovie object this view is to display
*/
- (NSMovie*) movie;
/**
* Start playback
*/
- (void) start: (id)sender;
/**
* Stop playback
*/
- (void) stop: (id)sender;
/**
* Returns YES if movie is playing
*/
- (BOOL) isPlaying;
/**
* Goes to the poster frame for the movie
*/
- (void) gotoPosterFrame: (id)sender;
/**
* Goes to the beginning of the NSMovie
*/
- (void) gotoBeginning: (id)sender;
/**
* Goes to the end of the NSMovie
*/
- (void) gotoEnd: (id)sender;
/**
* Steps one frame forward
*/
- (void) stepForward: (id)sender;
/**
* Steps one frame backward
*/
- (void) stepBack: (id)sender;
/**
* A range from 0.0 to 1.0 (or more) determine the rate at which
* the movie will be played. More than 1.0 means faster than normal
*/
- (void) setRate: (float)rate;
/**
* The current rate the movie is being played at
*/
- (float) rate;
/**
* A range from 0.0 (mute) to 1.0 (full) volume.
*/
- (void) setVolume: (float)volume;
/**
* Current volume
*/
- (float) volume;
/**
* Mute the volume
*/
- (void) setMuted: (BOOL)mute;
/**
* Returns YES if movie is muted
*/
- (BOOL) isMuted;
/**
* Sets the loop mode
*/
- (void) setLoopMode: (NSQTMovieLoopMode)mode;
/**
* Returns the loop mode
*/
- (NSQTMovieLoopMode) loopMode;
/**
* If this flag is true then NSMovieView only plays the selected portion of the movie
*/
- (void) setPlaysSelectionOnly: (BOOL)flag;
/**
* Returns YES if the view is playing a selection
*/
- (BOOL) playsSelectionOnly;
/**
* The view plays every single frame in the movie
*/
- (void) setPlaysEveryFrame: (BOOL)flag;
/**
* Returns YES if the view plays every frame.
*/
- (BOOL) playsEveryFrame;
/**
* Shows the controller with the play, stop, pause, and slider
*/
- (void) showController: (BOOL)show adjustingSize: (BOOL)adjustSize;
/**
* Returns the movie controller
*/
- (void*) movieController;
/**
* Returns YES if the controller is visible
*/
- (BOOL) isControllerVisible;
/**
* NSRect for the NSMovie
*/
- (NSRect) movieRect;
/**
* Resizes the view for the given magnification factor
*/
- (void) resizeWithMagnification: (float)magnification;
/**
* Resizes the view for the given magnification factor, returns NSSize
*/
- (NSSize) sizeForMagnification: (float)magnification;
/**
* Makes the NSMovieView editable
*/
- (void) setEditable: (BOOL)editable;
/**
* return YES if editable
*/
- (BOOL) isEditable;
/**
* Cut existing selection
*/
- (void) cut: (id)sender;
/**
* Copy existing selection
*/
- (void) copy: (id)sender;
/**
* Paste info into movie
*/
- (void) paste: (id)sender;
/**
* Clear existing selection
*/
- (void) clear: (id)sender;
/**
* Undo previous action
*/
- (void) undo: (id)sender;
/**
* Select the entire movie
*/
- (void) selectAll: (id)sender;
@end

View file

@ -68,7 +68,7 @@ APPKIT_EXPORT_CLASS
id<GSSoundSource> _source;
id<GSSoundSink> _sink;
NSConditionLock *_readLock;
NSLock * _playbackLock;
NSLock *_playbackLock;
BOOL _shouldStop;
BOOL _shouldLoop;
}

View file

@ -689,6 +689,8 @@ GSImageMagickImageRep.h \
GSInstantiator.h \
GSSoundSink.h \
GSSoundSource.h \
GSVideoSink.h \
GSVideoSource.h \
GSWindowDecorationView.h \
GSXibElement.h \
GSXibLoading.h \

View file

@ -7,6 +7,9 @@
Author: Fred Kiefer <FredKiefer@gmx.de>
Date: March 2003
Author: Gregory John Casamento <greg.casamento@gmail.com>
Date: March 2022
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
@ -27,23 +30,94 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSBundle.h>
#import <Foundation/NSCoder.h>
#import <Foundation/NSData.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSURL.h>
#import "AppKit/NSMovie.h"
#import "AppKit/NSPasteboard.h"
@implementation NSMovie
#import "GNUstepGUI/GSVideoSource.h"
#import "GNUstepGUI/GSVideoSink.h"
+ (NSArray*) movieUnfilteredFileTypes
#import "GSFastEnumeration.h"
/* Class variables and functions for class methods */
static NSArray *__videoSourcePlugIns = nil;
static NSArray *__videoSinkPlugIns = nil;
static inline void _loadNSMoviePlugIns (void)
{
return [NSArray arrayWithObject: @"mov"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
NSAllDomainsMask, YES);
NSMutableArray *all = [NSMutableArray array];
NSMutableArray *sourcePlugins = [NSMutableArray array];
NSMutableArray *sinkPlugins = [NSMutableArray array];
// Collect paths...
FOR_IN(NSString*, path, paths)
{
NSBundle *bundle = [NSBundle bundleWithPath: path];
paths = [bundle pathsForResourcesOfType: @"nsmovie"
inDirectory: @"Bundles"];
[all addObjectsFromArray: paths];
}
END_FOR_IN(paths);
// Check all paths for bundles conforming to the protocol...
FOR_IN(NSString*, path, all)
{
NSBundle *bundle = [NSBundle bundleWithPath: path];
Class plugInClass = [bundle principalClass];
if ([plugInClass conformsToProtocol: @protocol(GSVideoSource)])
{
[sourcePlugins addObject:plugInClass];
}
else if ([plugInClass conformsToProtocol: @protocol(GSVideoSink)])
{
[sinkPlugins addObject:plugInClass];
}
else
{
NSLog (@"Bundle %@ does not conform to GSVideoSource or GSVideoSink",
path);
}
}
END_FOR_IN(all);
__videoSourcePlugIns = [[NSArray alloc] initWithArray: sourcePlugins];
__videoSinkPlugIns = [[NSArray alloc] initWithArray: sinkPlugins];
}
+ (NSArray*) movieUnfilteredPasteboardTypes
@implementation NSMovie
+ (void) initialize
{
// FIXME
return [NSArray arrayWithObject: @"QuickTimeMovie"];
if (self == [NSMovie class])
{
[self setVersion: 2];
_loadNSMoviePlugIns();
}
}
+ (NSArray *) movieUnfilteredFileTypes
{
NSMutableArray *array = [NSMutableArray arrayWithCapacity: 10];
FOR_IN(Class, sourceClass, __videoSourcePlugIns)
{
[array addObjectsFromArray: [sourceClass movieUnfilteredFileTypes]];
}
END_FOR_IN(__videoSourcePlugIns);
return array;
}
+ (NSArray *) movieUnfilteredPasteboardTypes
{
return [NSArray arrayWithObjects: @"NSGeneralPboardType", nil];
}
+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard
@ -54,24 +128,51 @@
return ([pbTypes firstObjectCommonWithArray: myTypes] != nil);
}
- (id) initWithData: (NSData *)movie
- (id) initWithData: (NSData *)movieData
{
if (movie == nil)
self = [super init];
if (self != nil)
{
RELEASE(self);
return nil;
if (movieData != nil)
{
ASSIGN(_movieData, movieData);
// Choose video sink...
FOR_IN(Class, pluginClass, __videoSinkPlugIns)
{
if ([pluginClass canInitWithData: movieData])
{
_sink = [[pluginClass alloc] init];
}
}
END_FOR_IN(__videoSinkPlugIns);
// Choose video source...
FOR_IN(Class, pluginClass, __videoSourcePlugIns)
{
if ([pluginClass canInitWithData: movieData])
{
_source = [[pluginClass alloc] initWithData: movieData];
}
}
END_FOR_IN(__videoSourcePlugIns);
}
else
{
RELEASE(self);
}
}
[super init];
ASSIGN(_movie, movie);
return self;
}
- (id) initWithMovie: (void*)movie
{
//FIXME
self = [super init];
if (self != nil)
{
_movie = movie;
}
return self;
}
@ -80,7 +181,6 @@
NSData* data = [url resourceDataUsingCache: YES];
self = [self initWithData: data];
if (byRef)
{
ASSIGN(_url, url);
@ -98,7 +198,7 @@
[object_getClass(self) movieUnfilteredPasteboardTypes]];
if (type == nil)
{
//NSArray *array = [pasteboard propertyListForType: NSFilenamesPboardType];
// NSArray *array = [pasteboard propertyListForType: NSFilenamesPboardType];
// FIXME
data = nil;
}
@ -121,14 +221,15 @@
- (void) dealloc
{
TEST_RELEASE(_url);
TEST_RELEASE(_movie);
TEST_RELEASE(_movieData);
_movie = nil;
[super dealloc];
}
- (void*) QTMovie
{
return (void*)[_movie bytes];
return (void*)[_movieData bytes];
}
- (NSURL*) URL
@ -141,8 +242,10 @@
{
NSMovie *new = (NSMovie*)NSCopyObject (self, 0, zone);
new->_movie = [_movie copyWithZone: zone];
new->_movie = _movie;
new->_movieData = [_movieData copyWithZone: zone];
new->_url = [_url copyWithZone: zone];
return new;
}
@ -155,7 +258,7 @@
}
else
{
[aCoder encodeObject: _movie];
[aCoder encodeObject: _movieData];
[aCoder encodeObject: _url];
}
}
@ -168,7 +271,7 @@
}
else
{
ASSIGN (_movie, [aDecoder decodeObject]);
ASSIGN (_movieData, [aDecoder decodeObject]);
ASSIGN (_url, [aDecoder decodeObject]);
}
return self;

View file

@ -28,16 +28,131 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSData.h>
#import <Foundation/NSLock.h>
#import <Foundation/NSURL.h>
#import "AppKit/NSMovie.h"
#import "AppKit/NSMovieView.h"
#import "AppKit/NSPasteboard.h"
enum
{
MOVIE_SHOULD_PLAY = 1,
MOVIE_SHOULD_PAUSE
};
#define BUFFER_SIZE 4096
@interface NSMovie (NSMovieViewPrivate)
- (id<GSVideoSource>) _source;
- (id<GSVideoSink>) _sink;
@end
@implementation NSMovie (NSMovieViewPrivate)
- (id< GSVideoSource >) _source
{
return _source;
}
- (id< GSVideoSink >) _sink
{
return _sink;
}
@end
@interface NSMovieView (PrivateMethods)
- (void) _stream;
- (void) _finished: (NSNumber *)finishedPlaying;
@end
@implementation NSMovieView (PrivateMethods)
- (void) _stream
{
/*
NSUInteger bytesRead;
BOOL success = NO;
void *buffer;
id <GSVideoSink> sink = [[self movie] _sink];
id <GSVideoSource> source = [[self movie] _source];
// Exit with success = NO if device could not be open.
if ([sink open])
{
// Allocate space for buffer and start writing.
buffer = NSZoneMalloc(NSDefaultMallocZone(), BUFFER_SIZE);
do
{
do
{
// If not MOVIE_SHOULD_PLAY block thread
[_readLock lockWhenCondition: MOVIE_SHOULD_PLAY];
if (_shouldStop)
{
[_readLock unlock];
break;
}
bytesRead = [source readBytes: buffer
length: BUFFER_SIZE];
[_readLock unlock];
[_playbackLock lock];
success = [sink playBytes: buffer length: bytesRead];
[_playbackLock unlock];
} while ((!_shouldStop) && (bytesRead > 0) && success);
[source setCurrentTime: 0.0];
} while (_shouldLoop == YES && _shouldStop == NO);
[sink close];
NSZoneFree (NSDefaultMallocZone(), buffer);
}
RETAIN(self);
[self performSelectorOnMainThread: @selector(_finished:)
withObject: [NSNumber numberWithBool: success]
waitUntilDone: YES];
RELEASE(self);
*/
[[_movie _sink] play];
// video_main(_movie, self);
}
- (void) _finished: (NSNumber *)finishedPlaying
{
DESTROY(_readLock);
DESTROY(_playbackLock);
}
@end
@implementation NSMovieView
- (void) setMovie: (NSMovie*)movie
- (instancetype) init
{
self = [super init];
if (self != nil)
{
_movie = nil;
_rate = 1.0;
_volume = 1.0;
_flags.muted = NO;
_flags.loopMode = NSQTMovieNormalPlayback;
_flags.plays_selection_only = NO;
_flags.plays_every_frame = YES;
_flags.is_controller_visible = NO;
_flags.editable = NO;
_flags.reserved = 0;
}
return self;
}
- (void) setMovie: (NSMovie *)movie
{
ASSIGN(_movie, movie);
if (_movie != nil)
{
[[movie _sink] setMovieView: self];
}
}
- (NSMovie*) movie
@ -47,18 +162,58 @@
- (void) start: (id)sender
{
//FIXME
/*
// If the locks exists this instance is already playing
if (_readLock != nil && _playbackLock != nil)
{
return;
}
_readLock = [[NSConditionLock alloc] initWithCondition: MOVIE_SHOULD_PAUSE];
_playbackLock = [[NSLock alloc] init];
if ([_readLock tryLock] != YES)
{
return;
}
*/
_shouldStop = NO;
[NSThread detachNewThreadSelector: @selector(_stream)
toTarget: self
withObject: nil];
// [_readLock unlockWithCondition: MOVIE_SHOULD_PLAY];
}
- (void) stop: (id)sender
{
//FIXME
if (_readLock == nil)
{
return;
}
if ([_readLock tryLock] != YES)
{
return;
}
_shouldStop = YES;
// Set to MOVIE_SHOULD_PLAY so that thread isn't blocked.
[_readLock unlockWithCondition: MOVIE_SHOULD_PLAY];
}
- (BOOL) isPlaying
{
//FIXME
return NO;
if (_readLock == nil)
{
return NO;
}
if ([_readLock condition] == MOVIE_SHOULD_PLAY)
{
return YES;
}
return NO;
}
- (void) gotoPosterFrame: (id)sender

View file

@ -413,6 +413,7 @@ static inline void _loadNSSoundPlugIns (void)
return NO;
}
_shouldStop = YES;
// Set to SOUND_SHOULD_PLAY so that thread isn't blocked.
[_readLock unlockWithCondition: SOUND_SHOULD_PLAY];

View file

@ -28,7 +28,8 @@ include ../config.make
include ../Version
SUBPROJECTS = $(BUILD_SPEECH) $(BUILD_SOUND) $(BUILD_SPEECH_RECOGNIZER)
SUBPROJECTS = $(BUILD_SPEECH) $(BUILD_SOUND) $(BUILD_SPEECH_RECOGNIZER) \
$(BUILD_VIDEO)
TOOL_NAME = make_services set_show_service gopen gclose gcloseall
SERVICE_NAME = GSspell

32
Tools/video/GNUmakefile Normal file
View file

@ -0,0 +1,32 @@
PACKAGE_NAME = gnustep-gui
include $(GNUSTEP_MAKEFILES)/common.make
BUNDLE_NAME = VideoFile VideoOutput
BUNDLE_EXTENSION = .nsmovie
# These are here in case GNUstep is not installed,
# otherwise compilation will fail.
VideoFile_INCLUDE_DIRS += -I../../Headers \
-I../../Headers/Additions
VideoFile_LIB_DIRS += \
-L../../Source/$(GNUSTEP_OBJ_DIR)
VideoOutput_INCLUDE_DIRS += -I../../Headers \
-I../../Headers/Additions
VideoOutput_LIB_DIRS += \
-L../../Source/$(GNUSTEP_OBJ_DIR)
# Build the bundles.
VideoFile_OBJC_FILES = VideoFileSource.m
VideoOutput_OBJC_FILES = VideoOutputSink.m ffplay.m
VideoOutlet_C_FILES = cmdutils.c
VideoFile_PRINCIPAL_CLASS = VideoFileSource
VideoOutput_PRINCIPAL_CLASS = VidioOutputSink
VideoFile_BUNDLE_LIBS =
VideoOutput_BUNDLE_LIBS = -lavformat -lavcodec -lSDL2
include $(GNUSTEP_MAKEFILES)/bundle.make

View file

@ -0,0 +1,158 @@
/*
VideofileSource.m
Load and read video data using libvideofile.
Copyright (C) 2009 Free Software Foundation, Inc.
Written by: Stefan Bidigaray <stefanbidi@gmail.com>
Date: Jun 2009
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <Foundation/Foundation.h>
#include "GNUstepGUI/GSVideoSource.h"
#include <libavcodec/avcodec.h>
#define INBUF_SIZE 4096 + AV_INPUT_BUFFER_PADDING_SIZE
@interface VideofileSource : NSObject <GSVideoSource>
{
NSData *_data;
NSUInteger _currentPosition;
NSTimeInterval _dur;
int _encoding;
}
- (NSData *)data;
- (NSUInteger)currentPosition;
- (void)setCurrentPosition: (NSUInteger)curPos;
@end
@implementation VideofileSource
+ (NSArray *)videoUnfilteredFileTypes
{
return [NSArray arrayWithObjects: @"aa", @"aac", @"apng", @"asf", @"concat",
@"dash", @"imf", @"flv", @"live_flv", @"kux", @"git", @"hls", @"image2",
@"mov", @"mp4", @"3gp", @"mpegts", @"mpjpeg", @"rawvideo", @"sbg",
@"tedcaptions", @"vapoursynth",nil];
}
+ (NSArray *)videoUnfilteredTypes
{
/* FIXME: I'm not sure what the UTI for all the types above are. */
return [self videoUnfilteredFileTypes];
}
+ (BOOL)canInitWithData: (NSData *)data
{
return YES;
}
- (void)dealloc
{
TEST_RELEASE (_data);
[super dealloc];
}
- (id)initWithData: (NSData *)data
{
self = [super init];
if (self == nil)
{
return nil;
}
ASSIGN(_data, data);
return self;
}
- (NSUInteger) readBytes: (void *)bytes length: (NSUInteger)length
{
NSRange range;
NSUInteger len = length; //- 1;
if (_currentPosition >= [_data length] - 1)
{
return 0;
}
if (length > [_data length] - _currentPosition)
{
len = [_data length] - _currentPosition;
}
range = NSMakeRange(_currentPosition, len);
[_data getBytes: bytes range: range];
_currentPosition += len;
return len;
}
- (NSTimeInterval)duration
{
return _dur;
}
- (void)setCurrentTime: (NSTimeInterval)currentTime
{
}
- (NSTimeInterval)currentTime
{
return 0.0; // (NSTimeInterval)((double)frames / (double)_info.samplerate);
}
- (int)encoding
{
return _encoding;
}
- (NSUInteger)sampleRate;
{
return 0; // (NSUInteger)_info.samplerate;
}
- (NSByteOrder)byteOrder
{
// Equivalent to sending native byte order...
// Videofile always reads as native format.
return NS_UnknownByteOrder;
}
- (NSData *)data
{
return _data;
}
- (NSUInteger)currentPosition
{
return _currentPosition;
}
- (void)setCurrentPosition: (NSUInteger)curPos
{
_currentPosition = curPos;
}
@end

View file

@ -0,0 +1,318 @@
/*
VideoOutputSink.m
Sink video data to libavcodec.
Copyright (C) 2022 Free Software Foundation, Inc.
Written by: Gregory John Casamento <greg.casamento@gmail.com>
Date: Mar 2022
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <Foundation/Foundation.h>
#include <AppKit/NSMovie.h>
#include <AppKit/NSMovieView.h>
#include <GNUstepGUI/GSVideoSink.h>
// Portions of this code have been taken from an example in avcodec by Fabrice Bellard
/*
* Copyright (c) 2001 Fabrice Bellard
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <libavcodec/avcodec.h>
#include "cmdutils.h"
#define INBUF_SIZE 4096
/*
AVDictionary *codec_opts;
AVDictionary *format_opts;
AVDictionary *swr_opts;
AVDictionary *sws_dict;
*/
int video_main(NSMovie *movie, NSMovieView *view);
@interface VideoOutputSink : NSObject <GSVideoSink>
{
/*
AVCodec *_codec;
AVCodecParserContext *_parser;
AVCodecContext *_context; // = NULL;
AVPacket *_pkt;
AVFrame *_frame;
*/
NSMovieView *_movieView;
}
@end
@implementation VideoOutputSink
+ (BOOL) canInitWithData: (NSData *)data
{
return YES; // for now just say yes...
}
- (void) display: (unsigned char *) buf
wrap: (int) wrap
xsize: (int) xsize
ysize: (int) ysize
{
/*
FILE *f;
int i;
f = fopen(filename,"wb");
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
for (i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
fclose(f);
*/
NSLog(@"Playing... %d, %d, %d", wrap, xsize, ysize);
}
- (void) decode
{
/*
int ret;
ret = avcodec_send_packet(_context, _pkt);
if (ret < 0)
{
NSLog(@"Error sending a packet for decoding\n");
return;
}
while (ret >= 0)
{
ret = avcodec_receive_frame(_context, _frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
{
return;
}
else if (ret < 0)
{
NSLog(@"Error during decoding\n");
return;
}
NSLog(@"saving frame %3d\n", _context->frame_number);
fflush(stdout);
// the picture is allocated by the decoder. no need to
// free it
// snprintf(buf, sizeof(buf), "%d", _context->frame_number);
[self display: _frame->data[0]
wrap: _frame->linesize[0]
xsize: _frame->width
ysize: _frame->height];
// pgm_save(frame->data[0], frame->linesize[0],
// frame->width, frame->height, buf);
}
*/
}
- (void)dealloc
{
[self close];
_movieView = nil;
//_pkt = NULL;
//_context = NULL;
//_parser = NULL;
//_frame = NULL;
[super dealloc];
}
- (id)init
{
self = [super init];
if (self != nil)
{
_movieView = nil;
// _pkt = NULL;
//_context = NULL;
//_parser = NULL;
//_frame = NULL;
}
return self;
}
- (void) setMovieView: (NSMovieView *)view
{
_movieView = view; // weak, don't retain since the view is retained by its parent view.
}
- (NSMovieView *) movieView
{
return _movieView;
}
- (BOOL)open
{
/*
_pkt = av_packet_alloc();
if (!_pkt)
{
NSLog(@"Could not allocate packet");
return NO;
}
_codec = avcodec_find_decoder(AV_CODEC_ID_MPEG4); // will set this based on file type.
if (!_codec)
{
NSLog(@"Could not find decoder for type");
return NO;
}
_parser = av_parser_init(_codec->id);
if (!_parser)
{
NSLog(@"Could not init parser");
return NO;
}
_context = avcodec_alloc_context3(_codec);
if (!_context)
{
NSLog(@"Could not allocate video coder context");
return NO;
}
if (avcodec_open2(_context, _codec, NULL) < 0)
{
NSLog(@"Could not open codec\n");
return NO;
}
_frame = av_frame_alloc();
if (!_frame)
{
NSLog(@"Could not allocate video frame\n");
return NO;
}
return YES;
*/
return NO;
}
- (void)close
{
/*
if (_parser != NULL)
{
av_parser_close(_parser);
}
if (_context != NULL)
{
avcodec_free_context(&_context);
}
if (_frame != NULL)
{
av_frame_free(&_frame);
}
if (_pkt != NULL)
{
av_packet_free(&_pkt);
}
*/
}
- (void) play
{
video_main([_movieView movie], _movieView);
}
- (BOOL)playBytes: (void *)bytes length: (NSUInteger)length
{
/*
int ret = av_parser_parse2(_parser, _context, &_pkt->data, &_pkt->size,
bytes, length, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);
if (ret < 0)
{
NSLog(@"Error encountered while parsing data");
return NO;
}
if (_pkt != NULL)
{
if (_pkt->size)
{
[self decode];
}
else
{
NSLog(@"Packet size is 0");
}
}
else
{
NSLog(@"Invalid packet, can't play data");
return NO;
}
return YES;
*/
return NO;
}
- (void)setVolume: (float)volume
{
}
- (CGFloat)volume
{
return 1.0;
}
@end

1012
Tools/video/cmdutils.c Normal file

File diff suppressed because it is too large Load diff

648
Tools/video/cmdutils.h Normal file
View file

@ -0,0 +1,648 @@
/*
* Various utilities for command line tools
* copyright (c) 2003 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFTOOLS_CMDUTILS_H
#define FFTOOLS_CMDUTILS_H
#include <stdint.h>
#include "ffmpeg_config.h"
#include <libavcodec/avcodec.h>
#include <libavfilter/avfilter.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
#ifdef _WIN32
#undef main /* We don't want SDL to override our main() */
#endif
/**
* program name, defined by the program for show_version().
*/
extern const char program_name[];
/**
* program birth year, defined by the program for show_banner()
*/
extern const int program_birth_year;
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
extern AVFormatContext *avformat_opts;
extern AVDictionary *sws_dict;
extern AVDictionary *swr_opts;
extern AVDictionary *format_opts, *codec_opts, *resample_opts;
extern int hide_banner;
/**
* Register a program-specific cleanup routine.
*/
void register_exit(void (*cb)(int ret));
/**
* Wraps exit with a program-specific cleanup routine.
*/
void exit_program(int ret) av_noreturn;
/**
* Initialize dynamic library loading
*/
void init_dynload(void);
/**
* Initialize the cmdutils option system, in particular
* allocate the *_opts contexts.
*/
void init_opts(void);
/**
* Uninitialize the cmdutils option system, in particular
* free the *_opts contexts and their contents.
*/
void uninit_opts(void);
/**
* Trivial log callback.
* Only suitable for opt_help and similar since it lacks prefix handling.
*/
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl);
/**
* Override the cpuflags.
*/
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
/**
* Fallback for options that are not explicitly handled, these will be
* parsed through AVOptions.
*/
int opt_default(void *optctx, const char *opt, const char *arg);
/**
* Set the libav* libraries log level.
*/
int opt_loglevel(void *optctx, const char *opt, const char *arg);
int opt_report(void *optctx, const char *opt, const char *arg);
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
/**
* Limit the execution time.
*/
int opt_timelimit(void *optctx, const char *opt, const char *arg);
/**
* Parse a string and return its corresponding value as a double.
* Exit from the application if the string cannot be correctly
* parsed or the corresponding value is invalid.
*
* @param context the context of the value to be set (e.g. the
* corresponding command line option name)
* @param numstr the string to be parsed
* @param type the type (OPT_INT64 or OPT_FLOAT) as which the
* string should be parsed
* @param min the minimum valid accepted value
* @param max the maximum valid accepted value
*/
double parse_number_or_die(const char *context, const char *numstr, int type,
double min, double max);
/**
* Parse a string specifying a time and return its corresponding
* value as a number of microseconds. Exit from the application if
* the string cannot be correctly parsed.
*
* @param context the context of the value to be set (e.g. the
* corresponding command line option name)
* @param timestr the string to be parsed
* @param is_duration a flag which tells how to interpret timestr, if
* not zero timestr is interpreted as a duration, otherwise as a
* date
*
* @see av_parse_time()
*/
int64_t parse_time_or_die(const char *context, const char *timestr,
int is_duration);
typedef struct SpecifierOpt {
char *specifier; /**< stream/chapter/program/... specifier */
union {
uint8_t *str;
int i;
int64_t i64;
uint64_t ui64;
float f;
double dbl;
} u;
} SpecifierOpt;
typedef struct OptionDef {
const char *name;
int flags;
#define HAS_ARG 0x0001
#define OPT_BOOL 0x0002
#define OPT_EXPERT 0x0004
#define OPT_STRING 0x0008
#define OPT_VIDEO 0x0010
#define OPT_AUDIO 0x0020
#define OPT_INT 0x0080
#define OPT_FLOAT 0x0100
#define OPT_SUBTITLE 0x0200
#define OPT_INT64 0x0400
#define OPT_EXIT 0x0800
#define OPT_DATA 0x1000
#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only).
implied by OPT_OFFSET or OPT_SPEC */
#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */
#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt.
Implies OPT_OFFSET. Next element after the offset is
an int containing element count in the array. */
#define OPT_TIME 0x10000
#define OPT_DOUBLE 0x20000
#define OPT_INPUT 0x40000
#define OPT_OUTPUT 0x80000
union {
void *dst_ptr;
int (*func_arg)(void *, const char *, const char *);
size_t off;
} u;
const char *help;
const char *argname;
} OptionDef;
/**
* Print help for all options matching specified flags.
*
* @param options a list of options
* @param msg title of this group. Only printed if at least one option matches.
* @param req_flags print only options which have all those flags set.
* @param rej_flags don't print options which have any of those flags set.
* @param alt_flags print only options that have at least one of those flags set
*/
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
int rej_flags, int alt_flags);
#if CONFIG_AVDEVICE
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \
"list sources of the input device", "device" }, \
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \
"list sinks of the output device", "device" }, \
#else
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE
#endif
#define CMDUTILS_COMMON_OPTIONS \
{ "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \
{ "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \
{ "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \
{ "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \
{ "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \
{ "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \
{ "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \
{ "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \
{ "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \
{ "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \
{ "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \
{ "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \
{ "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \
{ "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \
{ "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \
{ "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \
{ "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \
{ "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
{ "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
{ "report", 0, { .func_arg = opt_report }, "generate a report" }, \
{ "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \
{ "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \
{ "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \
CMDUTILS_COMMON_OPTIONS_AVDEVICE \
/**
* Show help for all options with given flags in class and all its
* children.
*/
void show_help_children(const AVClass *class, int flags);
/**
* Per-fftool specific help handler. Implemented in each
* fftool, called by show_help().
*/
void show_help_default(const char *opt, const char *arg);
/**
* Generic -h handler common to all fftools.
*/
int show_help(void *optctx, const char *opt, const char *arg);
/**
* Parse the command line arguments.
*
* @param optctx an opaque options context
* @param argc number of command line arguments
* @param argv values of command line arguments
* @param options Array with the definitions required to interpret every
* option of the form: -option_name [argument]
* @param parse_arg_function Name of the function called to process every
* argument without a leading option name flag. NULL if such arguments do
* not have to be processed.
*/
void parse_options(void *optctx, int argc, char **argv, const OptionDef *options,
void (* parse_arg_function)(void *optctx, const char*));
/**
* Parse one given option.
*
* @return on success 1 if arg was consumed, 0 otherwise; negative number on error
*/
int parse_option(void *optctx, const char *opt, const char *arg,
const OptionDef *options);
/**
* An option extracted from the commandline.
* Cannot use AVDictionary because of options like -map which can be
* used multiple times.
*/
typedef struct Option {
const OptionDef *opt;
const char *key;
const char *val;
} Option;
typedef struct OptionGroupDef {
/**< group name */
const char *name;
/**
* Option to be used as group separator. Can be NULL for groups which
* are terminated by a non-option argument (e.g. ffmpeg output files)
*/
const char *sep;
/**
* Option flags that must be set on each option that is
* applied to this group
*/
int flags;
} OptionGroupDef;
typedef struct OptionGroup {
const OptionGroupDef *group_def;
const char *arg;
Option *opts;
int nb_opts;
AVDictionary *codec_opts;
AVDictionary *format_opts;
AVDictionary *resample_opts;
AVDictionary *sws_dict;
AVDictionary *swr_opts;
} OptionGroup;
/**
* A list of option groups that all have the same group type
* (e.g. input files or output files)
*/
typedef struct OptionGroupList {
const OptionGroupDef *group_def;
OptionGroup *groups;
int nb_groups;
} OptionGroupList;
typedef struct OptionParseContext {
OptionGroup global_opts;
OptionGroupList *groups;
int nb_groups;
/* parsing state */
OptionGroup cur_group;
} OptionParseContext;
/**
* Parse an options group and write results into optctx.
*
* @param optctx an app-specific options context. NULL for global options group
*/
int parse_optgroup(void *optctx, OptionGroup *g);
/**
* Split the commandline into an intermediate form convenient for further
* processing.
*
* The commandline is assumed to be composed of options which either belong to a
* group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global
* (everything else).
*
* A group (defined by an OptionGroupDef struct) is a sequence of options
* terminated by either a group separator option (e.g. -i) or a parameter that
* is not an option (doesn't start with -). A group without a separator option
* must always be first in the supplied groups list.
*
* All options within the same group are stored in one OptionGroup struct in an
* OptionGroupList, all groups with the same group definition are stored in one
* OptionGroupList in OptionParseContext.groups. The order of group lists is the
* same as the order of group definitions.
*/
int split_commandline(OptionParseContext *octx, int argc, char *argv[],
const OptionDef *options,
const OptionGroupDef *groups, int nb_groups);
/**
* Free all allocated memory in an OptionParseContext.
*/
void uninit_parse_context(OptionParseContext *octx);
/**
* Find the '-loglevel' option in the command line args and apply it.
*/
void parse_loglevel(int argc, char **argv, const OptionDef *options);
/**
* Return index of option opt in argv or 0 if not found.
*/
int locate_option(int argc, char **argv, const OptionDef *options,
const char *optname);
/**
* Check if the given stream matches a stream specifier.
*
* @param s Corresponding format context.
* @param st Stream from s to be checked.
* @param spec A stream specifier of the [v|a|s|d]:[\<stream index\>] form.
*
* @return 1 if the stream matches, 0 if it doesn't, <0 on error
*/
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec);
/**
* Filter out options for given codec.
*
* Create a new options dictionary containing only the options from
* opts which apply to the codec with ID codec_id.
*
* @param opts dictionary to place options in
* @param codec_id ID of the codec that should be filtered for
* @param s Corresponding format context.
* @param st A stream from s for which the options should be filtered.
* @param codec The particular codec for which the options should be filtered.
* If null, the default one is looked up according to the codec id.
* @return a pointer to the created dictionary
*/
AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
AVFormatContext *s, AVStream *st, AVCodec *codec);
/**
* Setup AVCodecContext options for avformat_find_stream_info().
*
* Create an array of dictionaries, one dictionary for each stream
* contained in s.
* Each dictionary will contain the options from codec_opts which can
* be applied to the corresponding stream codec context.
*
* @return pointer to the created array of dictionaries, NULL if it
* cannot be created
*/
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
AVDictionary *codec_opts);
/**
* Print an error message to stderr, indicating filename and a human
* readable description of the error code err.
*
* If strerror_r() is not available the use of this function in a
* multithreaded application may be unsafe.
*
* @see av_strerror()
*/
void print_error(const char *filename, int err);
/**
* Print the program banner to stderr. The banner contents depend on the
* current version of the repository and of the libav* libraries used by
* the program.
*/
void show_banner(int argc, char **argv, const OptionDef *options);
/**
* Print the version of the program to stdout. The version message
* depends on the current versions of the repository and of the libav*
* libraries.
* This option processing function does not utilize the arguments.
*/
int show_version(void *optctx, const char *opt, const char *arg);
/**
* Print the build configuration of the program to stdout. The contents
* depend on the definition of FFMPEG_CONFIGURATION.
* This option processing function does not utilize the arguments.
*/
int show_buildconf(void *optctx, const char *opt, const char *arg);
/**
* Print the license of the program to stdout. The license depends on
* the license of the libraries compiled into the program.
* This option processing function does not utilize the arguments.
*/
int show_license(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the formats supported by the
* program (including devices).
* This option processing function does not utilize the arguments.
*/
int show_formats(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the muxers supported by the
* program (including devices).
* This option processing function does not utilize the arguments.
*/
int show_muxers(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the demuxer supported by the
* program (including devices).
* This option processing function does not utilize the arguments.
*/
int show_demuxers(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the devices supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_devices(void *optctx, const char *opt, const char *arg);
#if CONFIG_AVDEVICE
/**
* Print a listing containing autodetected sinks of the output device.
* Device name with options may be passed as an argument to limit results.
*/
int show_sinks(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing autodetected sources of the input device.
* Device name with options may be passed as an argument to limit results.
*/
int show_sources(void *optctx, const char *opt, const char *arg);
#endif
/**
* Print a listing containing all the codecs supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_codecs(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the decoders supported by the
* program.
*/
int show_decoders(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the encoders supported by the
* program.
*/
int show_encoders(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the filters supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_filters(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the bit stream filters supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_bsfs(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the protocols supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_protocols(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the pixel formats supported by the
* program.
* This option processing function does not utilize the arguments.
*/
int show_pix_fmts(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the standard channel layouts supported by
* the program.
* This option processing function does not utilize the arguments.
*/
int show_layouts(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the sample formats supported by the
* program.
*/
int show_sample_fmts(void *optctx, const char *opt, const char *arg);
/**
* Print a listing containing all the color names and values recognized
* by the program.
*/
int show_colors(void *optctx, const char *opt, const char *arg);
/**
* Return a positive value if a line read from standard input
* starts with [yY], otherwise return 0.
*/
int read_yesno(void);
/**
* Get a file corresponding to a preset file.
*
* If is_path is non-zero, look for the file in the path preset_name.
* Otherwise search for a file named arg.ffpreset in the directories
* $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined
* at configuration time or in a "ffpresets" folder along the executable
* on win32, in that order. If no such file is found and
* codec_name is defined, then search for a file named
* codec_name-preset_name.avpreset in the above-mentioned directories.
*
* @param filename buffer where the name of the found filename is written
* @param filename_size size in bytes of the filename buffer
* @param preset_name name of the preset to search
* @param is_path tell if preset_name is a filename path
* @param codec_name name of the codec for which to look for the
* preset, may be NULL
*/
FILE *get_preset_file(char *filename, size_t filename_size,
const char *preset_name, int is_path, const char *codec_name);
/**
* Realloc array to hold new_size elements of elem_size.
* Calls exit() on failure.
*
* @param array array to reallocate
* @param elem_size size in bytes of each element
* @param size new element count will be written here
* @param new_size number of elements to place in reallocated array
* @return reallocated array
*/
void *grow_array(void *array, int elem_size, int *size, int new_size);
#define media_type_string av_get_media_type_string
#define GROW_ARRAY(array, nb_elems)\
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
#define GET_PIX_FMT_NAME(pix_fmt)\
const char *name = av_get_pix_fmt_name(pix_fmt);
#define GET_CODEC_NAME(id)\
const char *name = avcodec_descriptor_get(id)->name;
#define GET_SAMPLE_FMT_NAME(sample_fmt)\
const char *name = av_get_sample_fmt_name(sample_fmt)
#define GET_SAMPLE_RATE_NAME(rate)\
char name[16];\
snprintf(name, sizeof(name), "%d", rate);
#define GET_CH_LAYOUT_NAME(ch_layout)\
char name[16];\
snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout);
#define GET_CH_LAYOUT_DESC(ch_layout)\
char name[128];\
av_get_channel_layout_string(name, sizeof(name), 0, ch_layout);
double get_rotation(AVStream *st);
#endif /* FFTOOLS_CMDUTILS_H */

2608
Tools/video/ffmpeg_config.h Normal file

File diff suppressed because it is too large Load diff

3801
Tools/video/ffplay.m Normal file

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,7 @@ BUILD_SOUND=@BUILD_SOUND@
RECOGNIZER_BASE_LIBS=@RECOGNIZER_BASE_LIBS@
RECOGNIZER_BASE_CFLAGS=@RECOGNIZER_BASE_CFLAGS@
RECOGNIZER_ENGINE_CLASS=@RECOGNIZER_ENGINE_CLASS@
BUILD_VIDEO=@BUILD_VIDEO@
# CUPS
GSCUPS_CFLAGS = @GSCUPS_CFLAGS@

66
configure vendored
View file

@ -637,6 +637,7 @@ GSCUPS_LIBS
GSCUPS_LDFLAGS
GSCUPS_CFLAGS
have_cups
BUILD_VIDEO
RECOGNIZER_ENGINE_CLASS
RECOGNIZER_BASE_CFLAGS
RECOGNIZER_BASE_LIBS
@ -740,6 +741,7 @@ enable_aspell
enable_sound
enable_speech
enable_speech_recognizer
enable_video
enable_cups
'
ac_precious_vars='build_alias
@ -1389,6 +1391,7 @@ Optional Features:
--disable-sound Disable sound
--disable-speech Disable speech server
--disable-speech-recognizer Disable speech recognition server
--disable-video Disable video
--disable-cups Disable cups printing support
Optional Packages:
@ -6087,6 +6090,69 @@ fi
#--------------------------------------------------------------------
# NSMovie
#--------------------------------------------------------------------
# Check whether --enable-video was given.
if test "${enable_video+set}" = set; then :
enableval=$enable_video;
else
enable_video=yes
fi
# Initialize to nothing...
BUILD_VIDEO=
# Check for the headers...
for ac_header in libavcodec/avcodec.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "libavcodec/avcodec.h" "ac_cv_header_libavcodec_avcodec_h" "$ac_includes_default"
if test "x$ac_cv_header_libavcodec_avcodec_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBAVCODEC_AVCODEC_H 1
_ACEOF
have_codec=yes
else
have_codec=no
fi
done
for ac_header in libavformat/avformat.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "libavformat/avformat.h" "ac_cv_header_libavformat_avformat_h" "$ac_includes_default"
if test "x$ac_cv_header_libavformat_avformat_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBAVFORMAT_AVFORMAT_H 1
_ACEOF
have_format=yes
else
have_format=no
fi
done
for ac_header in SDL2/SDL.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "SDL2/SDL.h" "ac_cv_header_SDL2_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SDL2_SDL_H 1
_ACEOF
have_sdl=yes
else
have_sdl=no
fi
done
# Only if we have both and enabled, then build video
if test $have_codec = yes -a $have_format -a $have_sdl -a $enable_video = yes; then
BUILD_VIDEO="video"
fi
#--------------------------------------------------------------------
# Find CUPS
#--------------------------------------------------------------------

View file

@ -589,6 +589,26 @@ AC_SUBST(RECOGNIZER_BASE_LIBS)
AC_SUBST(RECOGNIZER_BASE_CFLAGS)
AC_SUBST(RECOGNIZER_ENGINE_CLASS)
#--------------------------------------------------------------------
# NSMovie
#--------------------------------------------------------------------
AC_ARG_ENABLE(video,
[ --disable-video Disable video],,
enable_video=yes)
# Initialize to nothing...
BUILD_VIDEO=
# Check for the headers...
AC_CHECK_HEADERS(libavcodec/avcodec.h, have_codec=yes, have_codec=no)
AC_CHECK_HEADERS(libavformat/avformat.h, have_format=yes, have_format=no)
AC_CHECK_HEADERS(SDL2/SDL.h, have_sdl=yes, have_sdl=no)
# Only if we have both and enabled, then build video
if test $have_codec = yes -a $have_format -a $have_sdl -a $enable_video = yes; then
BUILD_VIDEO="video"
fi
AC_SUBST(BUILD_VIDEO)
#--------------------------------------------------------------------
# Find CUPS
#--------------------------------------------------------------------