Skip to content

Commit 78d5359

Browse files
committed
Breaking change: rename to Gleed
1 parent 6d22739 commit 78d5359

13 files changed

+626
-626
lines changed

CMakeLists.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set(CMAKE_BUILD_TYPE Debug)
1212
set(MAJOR_VERSION 1)
1313
set(MINOR_VERSION 0)
1414
set(MICRO_VERSION 0)
15-
project(SDL3_movie
15+
project(Gleed
1616
LANGUAGES C CXX
1717
VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}"
1818
)
@@ -70,28 +70,28 @@ FetchContent_MakeAvailable(libopus)
7070
include(libvpx.cmake)
7171

7272
set(LIB_SOURCES
73-
src/SDL_movie_webm.cpp
74-
src/SDL_movie_vpx.c
75-
src/SDL_movie.c
76-
src/SDL_movie_vorbis.c
77-
src/SDL_movie_player.c
78-
src/SDL_movie_opus.c
73+
src/gleed_movie_webm.cpp
74+
src/gleed_movie_vpx.c
75+
src/gleed_movie.c
76+
src/gleed_movie_vorbis.c
77+
src/gleed_movie_player.c
78+
src/gleed_movie_opus.c
7979
)
8080

8181
# TODO: add shared library support
8282
add_library(
83-
SDL_movie
83+
Gleed
8484
STATIC
8585
${LIB_SOURCES}
8686
)
8787

88-
target_link_libraries(SDL_movie PUBLIC SDL3::SDL3 webm libvpx vorbis opus)
89-
target_include_directories(SDL_movie PRIVATE ${libwebm_SOURCE_DIR}/webm_parser/include)
88+
target_link_libraries(Gleed PUBLIC SDL3::SDL3 webm libvpx vorbis opus)
89+
target_include_directories(Gleed PRIVATE ${libwebm_SOURCE_DIR}/webm_parser/include)
9090

91-
target_include_directories(SDL_movie PUBLIC include/)
91+
target_include_directories(Gleed PUBLIC include/)
9292

93-
option(SDL_MOVIE_BUILD_EXAMPLES "Build SDL_Movie examples" ON)
93+
option(GLEED_BUILD_EXAMPLES "Build Gleed examples" ON)
9494

95-
if (SDL_MOVIE_BUILD_EXAMPLES)
95+
if (GLEED_BUILD_EXAMPLES)
9696
add_subdirectory(examples/)
9797
endif()

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# SDL_movie
1+
# GleedSDL
22

33
![Screenshot of Bunny Demo](examples/bunny_screenshot.png)
44

55
This is a simple library for playing **.webm** movies with SDL3. It is intended to be mostly used for playing short cinematics in games, but cautious usage for other purposes is also possible.
66

77
⚡️ Experimental until said elsewise. 😜
88

9+
Note: library was renamed from SDL_Movie to Gleed to avoid confusion with official SDL satellite libraries.
10+
911
## Features
1012

1113
- Provides SDL-like C API
@@ -31,58 +33,58 @@ Note: you will need a C++ compiler to build this library, as `libwebm` parser is
3133

3234
## Usage
3335

34-
See [basic.cpp](examples/basic.cpp) for a simple example playing Big Buck Bunny short trailer using more low-level `SDL_Movie` object.
36+
See [basic.cpp](examples/basic.cpp) for a simple example playing Big Buck Bunny short trailer using more low-level `GleedMovie` object.
3537

36-
See another [player.cpp](examples/player.cpp) with more high-level `SDL_MoviePlayer` object, which handles all the timing and synchronization for you and is the **recommended way** to use the library, unless you have specific needs.
38+
See another [player.cpp](examples/player.cpp) with more high-level `GleedMoviePlayer` object, which handles all the timing and synchronization for you and is the **recommended way** to use the library, unless you have specific needs.
3739
It allows also selecting a movie out of different codec variants.
3840

3941
The API is documented in the header file itself: [SDL_movie.h](include/SDL_movie.h).
4042

41-
The general workflow for `SDL_Movie` is the following:
43+
The general workflow for `GleedMovie` is the following:
4244

43-
1. Open a .webm file with `SDLMovie_Open(path)` or `SDLMovie_OpenIO(io_stream)`, obtaining a `SDLMovie*` handle.
44-
2. Optionally, select an audio or video track with `SDLMovie_SelectTrack`. If not called, the first video and audio tracks are selected by default.
45-
3. In the application loop, call `SDLMovie_DecodeVideoFrame` to decode video frame, and `SDLMovie_DecodeAudioFrame` to decode audio frame.
46-
4. On success, do useful rendering with video pixels (`SDLMovie_GetVideoFrameSurface`) and audio samples (`SDLMovie_GetAudioSamples`)
47-
5. Call `SDLMovie_NextVideoFrame` and `SDLMovie_NextAudioFrame` to advance to the next frame. Use `SDLMovie_HasNextVideoFrame` and `SDLMovie_HasNextAudioFrame` to check if there are more frames to decode.
48-
6. When done, call `SDLMovie_FreeMovie` to free resources.
45+
1. Open a .webm file with `GleedOpen(path)` or `GleedOpenIO(io_stream)`, obtaining a `GleedMovie*` handle.
46+
2. Optionally, select an audio or video track with `GleedSelectTrack`. If not called, the first video and audio tracks are selected by default.
47+
3. In the application loop, call `GleedDecodeVideoFrame` to decode video frame, and `GleedDecodeAudioFrame` to decode audio frame.
48+
4. On success, do useful rendering with video pixels (`GleedGetVideoFrameSurface`) and audio samples (`GleedGetAudioSamples`)
49+
5. Call `GleedNextVideoFrame` and `GleedNextAudioFrame` to advance to the next frame. Use `GleedHasNextVideoFrame` and `GleedHasNextAudioFrame` to check if there are more frames to decode.
50+
6. When done, call `GleedFreeMovie` to free resources.
4951

5052
**However**, the main problem with that workflow is that it all timing and synchronization is left to the user. Doing the process above at a frame rate higher than the movie's original will cause inconsistent playback speed and audio desync.
5153

52-
Therefore, it's advised to use `SDL_MoviePlayer`. Aside from handling timing for you, it also supports:
54+
Therefore, it's advised to use `GleedMoviePlayer`. Aside from handling timing for you, it also supports:
5355

5456
- Directly feeding audio output to your SDL_AudioDevice.
5557
- Pausing
5658
- Disabling audio or video playback, if needed
5759
- Automatic frame rate adjustment
58-
- Automatic calculation of time delta (pass `SDL_MOVIE_PLAYER_TIME_DELTA_AUTO` as second argument to `SDLMovie_UpdatePlayer`)
60+
- Automatic calculation of time delta (pass `GLEED_PLAYER_TIME_DELTA_AUTO` as second argument to `GleedUpdatePlayer`)
5961
- _Probably will support seeking in future_
6062

6163
Very quick example with the player (no error checking):
6264

6365
```cpp
6466
// Initialization
6567

66-
SDL_Movie* movie = SDLMovie_Open("bunny.webm");
68+
GleedMovie* movie = GleedOpen("bunny.webm");
6769

68-
SDL_MoviePlayer* player = SDLMovie_CreatePlayer(movie);
70+
GleedMoviePlayer* player = GleedCreatePlayer(movie);
6971

70-
SDL_Texture *video_frame = SDLMovie_CreatePlaybackTexture(
72+
SDL_Texture *video_frame = GleedCreatePlaybackTexture(
7173
movie, renderer);
7274

73-
SDLMovie_SetPlayerVideoOutputTexture(player, video_frame);
74-
SDLMovie_SetPlayerAudioOutput(player, audio_device); // your SDL_AudioDevice, already opened
75+
GleedSetPlayerVideoOutputTexture(player, video_frame);
76+
GleedSetPlayerAudioOutput(player, audio_device); // your SDL_AudioDevice, already opened
7577

7678
// Update loop
77-
SDLMovie_UpdatePlayer(player, SDL_MOVIE_PLAYER_TIME_DELTA_AUTO); //second argument is time delta, you can provide your own
79+
GleedUpdatePlayer(player, GLEED_PLAYER_TIME_DELTA_AUTO); //second argument is time delta, you can provide your own
7880

7981
// Rendering
8082
SDL_RenderCopy(renderer, video_frame, NULL, NULL); // render video frame
8183

8284
// Cleanup
83-
SDLMovie_FreePlayer(player);
84-
SDLMovie_FreeMovie(movie, true);
85-
SDLMovie_DestroyTexture(video_frame);
85+
GleedFreePlayer(player);
86+
GleedFreeMovie(movie, true);
87+
GleedDestroyTexture(video_frame);
8688
```
8789
8890
## Why WebM?
@@ -96,7 +98,7 @@ I have 2 reasons for that:
9698
1. ffmpeg is _big_ and kinda-overkill when you have control over the input format for your video assets, allowing you to choose one.
9799
2. I wanted to learn how low-level codecs APIs and struggle a bit :D
98100
99-
## How can I convert my video to WebM for SDL_Movie?
101+
## How can I convert my video to WebM for Gleed?
100102
101103
Use `ffmpeg`:
102104
@@ -122,7 +124,7 @@ For now, it does not support it, only accelerations available are implemented by
122124

123125
This library uses quite a lot of dynamic memory allocations, but in general it should not have much impact on memory usage, as most allocations are for one-frame buffers.
124126

125-
Although, as an option, you may explicitly call `SDLMovie_PreloadAudioStream` to preload whole audio track into memory for a smoother playback at a cost of longer loading time and higher memory usage.
127+
Although, as an option, you may explicitly call `GleedPreloadAudioStream` to preload whole audio track into memory for a smoother playback at a cost of longer loading time and higher memory usage.
126128

127129
## License
128130

examples/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
add_executable(sdl_movie_basic basic.cpp)
4-
add_executable(sdl_movie_player player.cpp)
3+
add_executable(gleed_basic basic.cpp)
4+
add_executable(gleed_player player.cpp)
55

6-
target_link_libraries(sdl_movie_basic PRIVATE SDL3::SDL3 SDL_movie)
7-
target_link_libraries(sdl_movie_player PRIVATE SDL3::SDL3 SDL_movie)
6+
target_link_libraries(gleed_basic PRIVATE SDL3::SDL3 Gleed)
7+
target_link_libraries(gleed_player PRIVATE SDL3::SDL3 Gleed)

examples/basic.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/*
2-
SDL_Movie Example
2+
GleedMovie Example
33
44
It plays a classical Big Buck Bunny trailer in WebM format (bunny.webm)
55
66
You can press '0' on the keyboard to restart the movie from the beginning.
77
8-
This example only show usage of lower-level SDL_Movie API
8+
This example only show usage of lower-level GleedMovie API
99
and does not handle time synchronization between audio and video tracks.
1010
11-
For more advanced features and the recommended way to play movies, see SDL_MoviePlayer example (player.cpp)
11+
For more advanced features and the recommended way to play movies, see GleedMoviePlayer example (player.cpp)
1212
*/
1313

1414
#include <iostream>
1515
#include <fstream>
1616
#include <SDL3/SDL.h>
1717

18-
#include <SDL_movie.h>
18+
#include <gleed.h>
1919

2020
int main()
2121
{
@@ -26,7 +26,7 @@ int main()
2626
return 1;
2727
}
2828

29-
SDL_Window *window = SDL_CreateWindow("SDL_movie Example", 800, 600, 0);
29+
SDL_Window *window = SDL_CreateWindow("Gleed Example", 800, 600, 0);
3030

3131
if (!window)
3232
{
@@ -47,16 +47,16 @@ int main()
4747
4848
This will parse the WebM file, and pre-select first available video and audio tracks.
4949
*/
50-
SDL_Movie *movie = SDLMovie_Open("bunny.webm");
50+
GleedMovie *movie = GleedOpen("bunny.webm");
5151

5252
if (!movie)
5353
{
54-
/* Any SDL_Movie error can be retrieved with SDLMovie_GetError() */
55-
std::cerr << SDLMovie_GetError() << std::endl;
54+
/* Any GleedMovie error can be retrieved with GleedGetError() */
55+
std::cerr << GleedGetError() << std::endl;
5656
return 1;
5757
}
5858

59-
const SDL_AudioSpec *movie_audio_spec = SDLMovie_GetAudioSpec(movie);
59+
const SDL_AudioSpec *movie_audio_spec = GleedGetAudioSpec(movie);
6060

6161
/*
6262
Here we open an audio stream and device, matching the audio spec of the movie.
@@ -81,7 +81,7 @@ int main()
8181
8282
Note that it's users responsibility to destroy the texture when it's no longer needed.
8383
*/
84-
SDL_Texture *movieFrameTexture = SDLMovie_CreatePlaybackTexture(
84+
SDL_Texture *movieFrameTexture = GleedCreatePlaybackTexture(
8585
movie,
8686
renderer);
8787

@@ -101,41 +101,41 @@ int main()
101101
if (ev.key.key == SDLK_0)
102102
{
103103
/* Seek to start */
104-
SDLMovie_SeekFrame(movie, 0);
104+
GleedSeekFrame(movie, 0);
105105
}
106106
}
107107
}
108108

109109
/* Video decoding*/
110-
if (SDLMovie_HasNextVideoFrame(movie))
110+
if (GleedHasNextVideoFrame(movie))
111111
{
112112
/* Decode current frame */
113-
if (!SDLMovie_DecodeVideoFrame(movie))
113+
if (!GleedDecodeVideoFrame(movie))
114114
{
115-
std::cerr << "Failed to decode next frame: " << SDLMovie_GetError() << std::endl;
115+
std::cerr << "Failed to decode next frame: " << GleedGetError() << std::endl;
116116
return 1;
117117
}
118118

119-
printf("Frame %d decoded in %d ms\n", SDLMovie_GetCurrentFrame(movie), SDLMovie_GetLastFrameDecodeTime(movie));
119+
printf("Frame %d decoded in %d ms\n", GleedGetCurrentFrame(movie), GleedGetLastFrameDecodeTime(movie));
120120

121121
/* Update playback texture */
122-
if (!SDLMovie_UpdatePlaybackTexture(movie, movieFrameTexture))
122+
if (!GleedUpdatePlaybackTexture(movie, movieFrameTexture))
123123
{
124-
std::cerr << "Failed to update playback texture: " << SDLMovie_GetError() << std::endl;
124+
std::cerr << "Failed to update playback texture: " << GleedGetError() << std::endl;
125125
return 1;
126126
}
127127

128128
/* Advance to next frame */
129-
SDLMovie_NextVideoFrame(movie);
129+
GleedNextVideoFrame(movie);
130130
}
131131

132132
/* Audio decoding */
133-
if (SDLMovie_HasNextAudioFrame(movie))
133+
if (GleedHasNextAudioFrame(movie))
134134
{
135135
/* Decode current audio frame*/
136-
if (!SDLMovie_DecodeAudioFrame(movie))
136+
if (!GleedDecodeAudioFrame(movie))
137137
{
138-
std::cerr << "Failed to decode next audio frame: " << SDLMovie_GetError() << std::endl;
138+
std::cerr << "Failed to decode next audio frame: " << GleedGetError() << std::endl;
139139
return 1;
140140
}
141141

@@ -145,15 +145,15 @@ int main()
145145
/*
146146
Obtain audio samples from the movie and send them to audio stream.
147147
*/
148-
const SDL_MovieAudioSample *samples = SDLMovie_GetAudioSamples(movie, &sz, &samples_count);
148+
const GleedMovieAudioSample *samples = GleedGetAudioSamples(movie, &sz, &samples_count);
149149

150150
if (samples)
151151
{
152152
SDL_PutAudioStreamData(audio_stream, samples, sz);
153153
}
154154

155155
/* Advance to next audio frame */
156-
SDLMovie_NextAudioFrame(movie);
156+
GleedNextAudioFrame(movie);
157157
}
158158

159159
SDL_RenderClear(renderer);
@@ -165,7 +165,7 @@ int main()
165165
}
166166

167167
/* Don't forget to free movie resources after finishing playback */
168-
SDLMovie_FreeMovie(movie, true);
168+
GleedFreeMovie(movie, true);
169169
SDL_DestroyTexture(movieFrameTexture);
170170
SDL_DestroyRenderer(renderer);
171171
SDL_FlushAudioStream(audio_stream);

0 commit comments

Comments
 (0)