Skip to content

Commit

Permalink
Reworked Video module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Apr 6, 2021
1 parent 41f44da commit d0bdfda
Show file tree
Hide file tree
Showing 10 changed files with 391 additions and 444 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LIBS = -lcurl -lssl -lcrypto -lvorbisfile -lvorbis -logg -lsndfile -lvita2d -lSc
-ljpeg -lfreetype -lc -lScePower_stub -lSceCommonDialog_stub -lpng16 -lz -lSceCamera_stub \
-lspeexdsp -lmpg123 -lSceAudio_stub -lSceGxm_stub -lSceDisplay_stub -lSceShellSvc_stub \
-lopusfile -lopus -lSceHttp_stub -lSceAudioIn_stub -lluajit -ldl -ltaihen_stub -lSceSysmodule_stub \
-lSceVideodec_stub -lSceShutterSound_stub -lSceSsl_stub -lSceVshBridge_stub
-lSceShutterSound_stub -lSceSsl_stub -lSceVshBridge_stub -lSceAvPlayer_stub

CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp))
Expand Down Expand Up @@ -42,7 +42,7 @@ endif
cp $< $<.unstripped_sys.elf
$(PREFIX)-strip -g $<
vita-elf-create $< $@
vita-make-fself -c -at 0x0E -m 0x10000 -a 0x2800000000000001 $@ eboot_unsafe_sys.bin
vita-make-fself -c -at 0x0E -m 0x12800 -pm 0x8000 -a 0x2800000000000001 $@ eboot_unsafe_sys.bin

%.velf: %.elf
cp $< $<.unstripped.elf
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Official documentation: http://rinnegatamante.github.io/lpp-vita/
* Moving Picture Expert Group-1/2 Audio Layer 3 audio files (**.mp3**) with MPEG-1 Audio Layer III/MPEG-2 Audio Layer III codecs.
* Musical Instrument Digital Interface audio files (**.midi**).
* Ogg Media audio files (**.ogg/.opus**) with Vorbis/Opus codecs.
* Native support to PSHV video files.
* Native support to MP4 video files with support for **.srt** and **.vtt** subtitles files.

##### Controls

Expand All @@ -57,6 +57,7 @@ Official documentation: http://rinnegatamante.github.io/lpp-vita/
* Native support to ZIP archives.
* Native support to SFO file descriptors.
* Native support to SQLite databases.
* Native support to apps installation/uninstallation.

##### Utilities

Expand Down Expand Up @@ -132,5 +133,6 @@ Lua Player Plus Vita supports different flags to enables some features:<br>
* **hyln9** for vita-luajit.
* **frangarcj** for the help during 3D rendering feature addition.
* **TheFloW** for some snippets i used and some ideas i borrowed.
* Misledz for the Lua Player Plus logo.
* EasyRPG Team for the Audio Decoder used for Sound module.
* **Misledz** for the Lua Player Plus logo.
* **Arkanite** for providing a sample for sceAvPlayer used to implement the Video module.
* **EasyRPG Team** for the Audio Decoder used for Sound module.
2 changes: 1 addition & 1 deletion doc/luaSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Sound {
int open(string filename);

/**
* Plays a sound.
* Play a sound.
* \ingroup Sound
*
* @par Usage example:
Expand Down
94 changes: 92 additions & 2 deletions doc/luaVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
* Module that handles video files playback.
*/

/**
* Play modes for video playback.
* \ingroup Video
*/
enum PlayMode{
NORMAL_MODE, //!< Normal speed with audio
FAST_FORWARD_2X_MODE, //!< Fast Forward at 2x speed without audio
FAST_FORWARD_4X_MODE, //!< Fast Forward at 4x speed without audio
FAST_FORWARD_8X_MODE, //!< Fast Forward at 8x speed without audio
FAST_FORWARD_16X_MODE, //!< Fast Forward at 16x speed without audio
FAST_FORWARD_32X_MODE, //!< Fast Forward at 32x speed without audio
};

class Video {

public:
Expand Down Expand Up @@ -30,12 +43,12 @@ class Video {
void term(void);

/**
* Open a PSHV video file.
* Open an MP4 video file.
* \ingroup Video
*
* @par Usage example:
* @code
* Video.open("app0:/video.pshv", false)
* Video.open("app0:/video.mp4", false)
* @endcode
*
* @param filename - Filepath of the file to reproduce.
Expand Down Expand Up @@ -137,4 +150,81 @@ class Video {
*/
int getVolume(void);

/**
* Get current time for current video playback.
* \ingroup Video
*
* @par Usage example:
* @code
* t = Volume.getTime()
* @endcode
*
* @return Current time position in the video playback in milliseconds.
*/
number getTime(void);

/**
* Jump to a specific position for current video playback.
* \ingroup Video
*
* @par Usage example:
* @code
* Video.jumpToTime(Video.getTime() + 5000)
* @endcode
*
* @param time - The position in milliseconds where to jump in the video playback.
*/
void jumpToTime(number time);

/**
* Set play mode for current video playback.
* \ingroup Video
*
* @par Usage example:
* @code
* Video.setPlayMode(FAST_FORWARD_16X_MODE)
* @endcode
*
* @param mode - The mode to set.
*/
void setPlayMode(PlayMode mode);

/**
* Open a subtitles file for current video playback.
* \ingroup Video
*
* @par Usage example:
* @code
* Video.openSubs("ux0:data/subtitles.vtt")
* @endcode
*
* @param fname - The file to use as subtitles source.
*
* @note Supported subtitles formats: .srt, .vtt.
*/
void openSubs(string fname);

/**
* Close currently opened subtitles file.
* \ingroup Video
*
* @par Usage example:
* @code
* Video.closeSubs()
* @endcode
*/
void closeSubs();

/**
* Get current available subtitles for the video playback.
* \ingroup Video
*
* @par Usage example:
* @code
* Graphics.debugPrint(20, 20, Video.getSubs(), Color.new(255, 255, 255))
* @endcode
*
* @return Subtitles matching current video playtime from the opened subtitles file.
*/
string getSubs(void);
}
1 change: 0 additions & 1 deletion source/include/luaplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ struct DecodedMusic{
char title[256];
char author[256];
bool tempBlock;
bool isVideoTrack;
};

#endif
116 changes: 0 additions & 116 deletions source/include/videodec.cpp

This file was deleted.

18 changes: 0 additions & 18 deletions source/include/videodec.h

This file was deleted.

6 changes: 1 addition & 5 deletions source/luaSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@
#include "include/luaplayer.h"
#include "include/audiodec/audio_decoder.h"
#define stringify(str) #str
#define BooleanRegister(lua, value) do { lua_pushboolean(lua, value); lua_setglobal (lua, stringify(value)); } while(0)
#define VariableRegister(lua, value) do { lua_pushinteger(lua, value); lua_setglobal (lua, stringify(value)); } while(0)

#define BUFSIZE 8192 // Max dimension of audio buffer size
#define BUFSIZE_MONO 4096 // Dimension of audio buffer files for mono tracks
#define NSAMPLES 2048 // Number of samples for output
#define AUDIO_CHANNELS 8 // PSVITA has 8 available audio channels
#define AUDIO_CHANNELS 8 // PSVITA has 8 available MAIN audio channels

SceUID AudioThreads[AUDIO_CHANNELS], MicThread, Audio_Mutex, NewTrack_Mutex;
DecodedMusic* new_track = NULL;
Expand Down Expand Up @@ -174,7 +173,6 @@ static int audioThread(unsigned int args, void* arg){

}

if ((!mus->isPlaying) && mus->isVideoTrack) video_audio_tick = 0.0f;
mus->isPlaying = !mus->isPlaying;
mus->pauseTrigger = false;

Expand All @@ -197,7 +195,6 @@ static int audioThread(unsigned int args, void* arg){
else mus->cur_audiobuf = mus->audiobuf;
audio_decoder[id]->Decode(mus->cur_audiobuf, (chns > 1) ? BUFSIZE : BUFSIZE_MONO);
sceAudioOutOutput(ch, mus->cur_audiobuf);
if ((mus->isVideoTrack) && (video_audio_tick == 0.0f)) video_audio_tick = sceKernelGetProcessTimeWide() / 1000000.0f;

}else{

Expand Down Expand Up @@ -500,7 +497,6 @@ static int lua_opensound(lua_State *L){
memblock->isPlaying = false;
memblock->audioThread = 0xFF;
memblock->tempBlock = false;
memblock->isVideoTrack = false;
sprintf(memblock->filepath, "%s", path);
lua_pushinteger(L,(uint32_t)memblock);
return 1;
Expand Down

0 comments on commit d0bdfda

Please sign in to comment.