Skip to content

Create files to support NSMovie and NSMovieView #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9664cd4
Code compiles, now working on getting configure.ac fixed
gcasa May 25, 2025
31f0b8e
Update to be able to play content using NSMovie, add configure.ac cha…
gcasa May 25, 2025
472550e
Add new subclass to encapsulate the libav code
gcasa May 26, 2025
dd2ab8f
Update configure, GNUmakefile, NSMovieView
gcasa May 26, 2025
0b28f09
Add subclass
gcasa May 26, 2025
0191af1
Update NSMovieView to instantiate GSMovieView subclass
gcasa May 26, 2025
65f6ef3
Update memory management in the GSMovieView/NSMovieView classes
gcasa May 26, 2025
924bf25
Update comments
gcasa May 26, 2025
92d6782
Update comments
gcasa May 26, 2025
5cdb5ff
NSMovieView documentation
gcasa May 26, 2025
cb9838b
Initial changes to get audio working, may not compile
gcasa May 26, 2025
8ded625
Add initial changes for sound
gcasa May 26, 2025
3ba1f14
Decode audio packets
gcasa May 26, 2025
bece0a9
Add code that plays sound from the video
gcasa May 27, 2025
2cf7378
Slight improvements to sound handling
gcasa May 27, 2025
0a8e508
Move sound to a thread to stop it from being unsteady
gcasa May 27, 2025
8c595f4
Try to sync up audio output
gcasa May 27, 2025
01a68ce
Remove 2.0 conventions from code, add volume setting, initialization …
gcasa May 27, 2025
bc2d382
Fix warnings, and make audio a little smoother
gcasa May 27, 2025
b123e82
Use GNUstep define for RELEASE
gcasa May 28, 2025
672ff2a
Refactor NSMovieView to delegate certain methods to the subclass, in …
gcasa May 29, 2025
410713a
Add a delay of 1000 frames before we start the player thread.
gcasa May 29, 2025
c8ffb3c
Add audio support
gcasa May 29, 2025
5b3afb8
Rename Audio class, initialize it in the code if there is an audio st…
gcasa May 29, 2025
dd02d4f
Re-integrate audio
gcasa May 29, 2025
61bd0c8
Add logging when sound stream is found
gcasa May 29, 2025
4b9e6c3
Add other methods
gcasa May 30, 2025
a2e54de
Update actions, add implementation for some actions
gcasa May 30, 2025
ad69f77
Add proper declaration
gcasa May 30, 2025
1150ab0
Add code to return list of supported video types
gcasa May 30, 2025
8392360
Add audio buffer using NSData
gcasa May 31, 2025
9a7ac68
Add pasteboard types, clean up NSMovie
gcasa May 31, 2025
f87e261
Add ring buffer class
gcasa May 31, 2025
36b8414
Make sure swr_init is checked to see if it returns 0
gcasa Jun 3, 2025
fbf447a
Remove ring buffer
gcasa Jun 3, 2025
4de05f2
Fix memory leak
gcasa Jun 3, 2025
2f24c56
Whitespace cleanup
gcasa Jun 3, 2025
725a127
Add thread_count and thread_type
gcasa Jun 4, 2025
04414e9
Cleanup and add some missing methods
gcasa Jun 4, 2025
2e5ec16
Remove uneeded retain calls
gcasa Jun 4, 2025
a047612
Get the size on the main thread instead of getting it from prepare...
gcasa Jun 5, 2025
c8d40f5
Minor cleanup
gcasa Jun 5, 2025
708a2da
terminate the thread, cleanup
gcasa Jun 5, 2025
c775466
Add stream indexes to the object
gcasa Jun 5, 2025
39d05ce
Implement gotoEnd, gotoBeginning, etc
gcasa Jun 5, 2025
7243804
Improve methods, add debugging info
gcasa Jun 5, 2025
67f8966
Fixing stop/start/goto methods
gcasa Jun 7, 2025
60cf0fd
Add notification handler to shut down the threads
gcasa Jun 7, 2025
e467716
Add TextField so that status can be shown. This is a GS extension
gcasa Jun 7, 2025
cc24648
Add support for status field
gcasa Jun 7, 2025
dff017a
Skip any corrupt packets
gcasa Jun 7, 2025
08c88d6
Add renderFrame: method
gcasa Jun 8, 2025
e339494
Add renderFrame: method
gcasa Jun 8, 2025
03f591c
Separate concerns into different methods so that setup, loop, and clo…
gcasa Jun 8, 2025
79ba3c7
Add logic to skip forward
gcasa Jun 9, 2025
3f49929
Cleanup, and cache stream
gcasa Jun 9, 2025
c92347e
Initial changes for pause
gcasa Jun 10, 2025
cf8e6be
Add pause
gcasa Jun 10, 2025
0e6caac
Separate out audio player and utilities, update GNUmakefile
gcasa Jun 10, 2025
aa13204
Pause sound and video when movie is paused
gcasa Jun 10, 2025
61967d6
Optimize some of the code, change logging
gcasa Jun 12, 2025
e071451
Cleanup, refactor
gcasa Jun 14, 2025
ad634be
Streamline getting the movieRect so that it doesn't need to get the s…
gcasa Jun 14, 2025
1bd131d
Remove lock
gcasa Jun 14, 2025
0fd1bf3
Implement frameRateForStream:
gcasa Jun 15, 2025
b8450b7
Use new method to get frameRateForStream: to get the framerate
gcasa Jun 15, 2025
fd42688
Set rate to 1.0
gcasa Jun 23, 2025
3ed1985
Initial add of timer
gcasa Jun 23, 2025
6bce08c
Reimplement as a synchronous process
gcasa Jun 24, 2025
14c894f
Add else for audio
gcasa Jun 24, 2025
56eec20
Re-integrate sound, video, make synchronous
gcasa Jun 25, 2025
e984fbd
Refactor into methods
gcasa Jun 25, 2025
0eaf4d9
Refactor image rendering into renderFrame:
gcasa Jun 25, 2025
64f8a6a
Move decoding into a thread for each packet
gcasa Jun 25, 2025
0fde3d5
Add code to decode to data for audio
gcasa Jun 26, 2025
098e0d8
Add cache ivars
gcasa Jun 27, 2025
7cd00aa
Remove uneedeed code
gcasa Jun 27, 2025
5789283
Factor out rendering image to other methods
gcasa Jun 27, 2025
da4131e
Beginning implementation of buildCache
gcasa Jun 27, 2025
ab3c0a7
Basic cache system implemented
gcasa Jun 30, 2025
c15a39f
Add ring buffer implementation
gcasa Jun 30, 2025
2b4df47
Reduce imports in GSRingBuffer
gcasa Jun 30, 2025
da2a7b0
Code cleanup
gcasa Jun 30, 2025
56a4ebd
Add headers
gcasa Jul 1, 2025
13ea205
Ring buffer to video playback logic
gcasa Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2025-05-29 Gregory John Casamento <[email protected]>

* config.make.in
* configure
* configure.ac
* Headers/Additions/GNUstepGUI/config.h.in
* Headers/AppKit/NSMovie.h
* Headers/AppKit/NSMovieView.h
* Source/GNUmakefile
* Source/GNUmakefile.preamble
* Source/GSMovieView.h
* Source/GSMovieView.m
* Source/NSMovie.m
* Source/NSMovieView.m
* Source/NSSound.m: Cleanup NSSound, add support for playing ffmpeg
movies using NSMovie, NSMovieView.

2025-04-30 Gregory John Casamento <[email protected]>

* Headers/AppKit/NSColorSpace.h: Add NSColorSpaceModel* enumerated values.
Expand Down
3 changes: 3 additions & 0 deletions Headers/Additions/GNUstepGUI/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
/* MagickCore >= 7 */
#undef MAGICKCORE_7_OR_NEWER

/* avcodec */
#undef HAVE_AVCODEC

/* mntent structure member name */
#undef MNT_FSNAME

Expand Down
42 changes: 37 additions & 5 deletions Headers/AppKit/NSMovie.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Copyright <copy>(C) 2003 Free Software Foundation, Inc.</copy>

Author: Gregory John Casamento <[email protected]>
Date: May 2025
Author: Fred Kiefer <[email protected]>
Date: March 2003

Expand Down Expand Up @@ -41,19 +43,49 @@ APPKIT_EXPORT_CLASS
@interface NSMovie : NSObject <NSCopying, NSCoding>
{
@private
NSData* _movie;
NSURL* _url;
NSData* _movie;
NSURL* _url;
BOOL _tmp;
}

/**
* An array of all of the types NSMovie can support.
*/
+ (NSArray*) movieUnfilteredFileTypes;

/**
* An array of all of the pasteboard types NSMovie can support.
*/
+ (NSArray*) movieUnfilteredPasteboardTypes;

/**
* Returns YES, if the object can be initialized with the given pasteboard.
*/
+ (BOOL) canInitWithPasteboard: (NSPasteboard*)pasteboard;

- (id) initWithMovie: (void*)movie;
- (id) initWithURL: (NSURL*)url byReference: (BOOL)byRef;
- (id) initWithPasteboard: (NSPasteboard*)pasteboard;
/**
* Returns an NSMovie with the raw data pointed to by movie.
*/
- (instancetype) initWithMovie: (void*)movie;

/**
* Returns an NSMovie with the given URL. byRef should be YES if it is by reference.
*/
- (instancetype) initWithURL: (NSURL*)url byReference: (BOOL)byRef;

/**
* Returns an NSMovie initialized with the pasteboard passed in.
*/
- (instancetype) initWithPasteboard: (NSPasteboard*)pasteboard;

/**
* Returns the raw data for the movie.
*/
- (void*) QTMovie;

/**
* Returns the URL of the movie to be played.
*/
- (NSURL*) URL;

@end
Expand Down
202 changes: 175 additions & 27 deletions Headers/AppKit/NSMovieView.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Copyright <copy>(C) 2003 Free Software Foundation, Inc.</copy>

Author: Gregory John Casamento <[email protected]>
Date: May 2025
Author: Fred Kiefer <[email protected]>
Date: March 2003

Expand All @@ -28,10 +30,12 @@

#ifndef _GNUstep_H_NSMovieView
#define _GNUstep_H_NSMovieView
#import <AppKit/AppKitDefines.h>

#import <AppKit/AppKitDefines.h>
#import <AppKit/NSNibDeclarations.h>
#import <AppKit/NSView.h>

@class NSTextField;
@class NSMovie;

typedef enum {
Expand All @@ -43,66 +47,210 @@ typedef enum {
APPKIT_EXPORT_CLASS
@interface NSMovieView : NSView
{
@protected
NSMovie* _movie;
float _rate;
float _volume;
struct NSMovieViewFlags {
unsigned int muted: 1;
unsigned int loopMode: 3;
unsigned int plays_selection_only: 1;
unsigned int plays_every_frame: 1;
unsigned int is_controller_visible: 1;
unsigned int editable: 1;
unsigned int reserved: 24;
} _flags;
IBOutlet NSTextField *_statusField;
NSMovie* _movie;

float _rate;
float _volume;
BOOL _playing;
struct NSMovieViewFlags {
unsigned int muted: 1;
unsigned int loopMode: 3;
unsigned int plays_selection_only: 1;
unsigned int plays_every_frame: 1;
unsigned int is_controller_visible: 1;
unsigned int editable: 1;
unsigned int reserved: 24;
} _flags;
}

/**
* Set the movie to be displayed in the view.
*/
- (void) setMovie: (NSMovie*)movie;

/**
* Get the current movie displayed in the view.
*/
- (NSMovie*) movie;

- (void) start: (id)sender;
- (void) stop: (id)sender;
/**
* Start movie playback.
*/
- (IBAction) start: (id)sender;

/**
* Stop movie playback.
*/
- (IBAction) stop: (id)sender;

/**
* Check whether the movie is currently playing.
*/
- (BOOL) isPlaying;

- (void) gotoPosterFrame: (id)sender;
- (void) gotoBeginning: (id)sender;
- (void) gotoEnd: (id)sender;
- (void) stepForward: (id)sender;
- (void) stepBack: (id)sender;
/**
* Go to the movie's poster frame.
*/
- (IBAction) gotoPosterFrame: (id)sender;

/**
* Move to the beginning of the movie.
*/
- (IBAction) gotoBeginning: (id)sender;

/**
* Move to the end of the movie.
*/
- (IBAction) gotoEnd: (id)sender;

/**
* Step forward one frame in the movie.
*/
- (IBAction) stepForward: (id)sender;

/**
* Step backward one frame in the movie.
*/
- (IBAction) stepBack: (id)sender;

/**
* Set the playback rate for the movie.
*/
- (void) setRate: (float)rate;

/**
* Get the current playback rate.
*/
- (float) rate;

/**
* Set the playback volume.
*/
- (void) setVolume: (float)volume;

/**
* Get the current playback volume.
*/
- (float) volume;

/**
* Mute or unmute the playback.
*/
- (void) setMuted: (BOOL)mute;

/**
* Return whether the playback is muted.
*/
- (BOOL) isMuted;

/**
* Set the loop mode for playback.
*/
- (void) setLoopMode: (NSQTMovieLoopMode)mode;

/**
* Get the current loop mode.
*/
- (NSQTMovieLoopMode) loopMode;

/**
* Set whether only the selected portion should play.
*/
- (void) setPlaysSelectionOnly: (BOOL)flag;

/**
* Return whether only the selection is played.
*/
- (BOOL) playsSelectionOnly;

/**
* Set whether to play every frame regardless of timing.
*/
- (void) setPlaysEveryFrame: (BOOL)flag;

/**
* Return whether every frame is being played.
*/
- (BOOL) playsEveryFrame;

/**
* Show or hide the movie controller and optionally adjust view size.
*/
- (void) showController: (BOOL)show adjustingSize: (BOOL)adjustSize;

/**
* Get a pointer to the movie controller.
*/
- (void*) movieController;

/**
* Check whether the controller is currently visible.
*/
- (BOOL) isControllerVisible;

/**
* Get the rectangle in which the movie is displayed.
*/
- (NSRect) movieRect;

/**
* Resize the view based on a magnification factor.
*/
- (void) resizeWithMagnification: (float)magnification;

/**
* Calculate the size of the view at a given magnification.
*/
- (NSSize) sizeForMagnification: (float)magnification;

/**
* Set whether the movie view is editable.
*/
- (void) setEditable: (BOOL)editable;

/**
* Return whether the movie view is editable.
*/
- (BOOL) isEditable;

- (void) cut: (id)sender;
- (void) copy: (id)sender;
- (void) paste: (id)sender;
- (void) clear: (id)sender;
- (void) undo: (id)sender;
- (void) selectAll: (id)sender;
/**
* Cut the selected movie content.
*/
- (IBAction) cut: (id)sender;

/**
* Copy the selected movie content.
*/
- (IBAction) copy: (id)sender;

/**
* Paste movie content from the pasteboard.
*/
- (IBAction) paste: (id)sender;

/**
* Clear the selected movie content.
*/
- (IBAction) clear: (id)sender;

/**
* Undo the last operation.
*/
- (IBAction) undo: (id)sender;

/**
* Select all content in the movie view.
*/
- (IBAction) selectAll: (id)sender;

/**
* GNUstep extension, this allows the user to set a
* text field to monitor the status of the movie view.
*
- (void) setStatusField: (id)field;
- (id) statusField;
*/

@end

Expand Down
9 changes: 8 additions & 1 deletion Source/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,14 @@ GSCSStrength.m \
GSCSEditInfo.m \
GSCSEditVariableManager.m \
GSCSTableau.m \
GSColorSliderCell.m
GSColorSliderCell.m \
GSRingBuffer.m

ifeq ($(BUILD_MOVIE), yes)
libgnustep-gui_OBJC_FILES += GSMovieView.m
libgnustep-gui_OBJC_FILES += GSAudioPlayer.m
libgnustep-gui_OBJC_FILES += GSAVUtils.m
endif

# Turn off NSMenuItem warning that NSMenuItem conforms to <NSObject>,
# but does not implement <NSObject>'s methods itself (it inherits
Expand Down
4 changes: 2 additions & 2 deletions Source/GNUmakefile.preamble
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ endif
ADDITIONAL_OBJCFLAGS = -Wall

# Additional flags to pass to the C compiler
# ADDITIONAL_CFLAGS =
ADDITIONAL_CFLAGS += $(MOVIE_BASE_CFLAGS) $(SOUND_CFLAGS)

# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../Headers/Additions -I../Headers \
Expand All @@ -62,7 +62,7 @@ ADDITIONAL_INCLUDE_DIRS += -I../Headers/Additions -I../Headers \
# ADDITIONAL_LDFLAGS =

# Additional library directories the linker should search
# ADDITIONAL_LIB_DIRS =
ADDITIONAL_LIB_DIRS += $(MOVIE_BASE_LIBS) $(SOUND_LIBS)

#
# Sparc systems cannot load tiff files due to some problem compiling
Expand Down
Loading