Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Dr. Michael Petter
Teleteaching Webclient
Commits
949072d9
Commit
949072d9
authored
Aug 13, 2014
by
daFischer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a few minor fixes and more comments
parent
e32350e0
Changes
114
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
114 changed files
with
551 additions
and
322 deletions
+551
-322
Audio.cpp
Audio.cpp
+9
-7
Audio.h
Audio.h
+2
-1
AudioInterface.cpp
AudioInterface.cpp
+4
-1
AudioInterface.h
AudioInterface.h
+3
-2
AudioJS.cpp
AudioJS.cpp
+7
-1
AudioJS.h
AudioJS.h
+2
-1
ColorConverter.cpp
ColorConverter.cpp
+1
-1
ColorConverter.h
ColorConverter.h
+1
-1
Constants.cpp
Constants.cpp
+1
-1
Constants.h
Constants.h
+2
-2
Controls.cpp
Controls.cpp
+88
-30
Controls.h
Controls.h
+7
-1
Index.cpp
Index.cpp
+3
-3
Index.h
Index.h
+1
-1
IndexEntry.cpp
IndexEntry.cpp
+3
-1
IndexEntry.h
IndexEntry.h
+1
-1
Inflater.cpp
Inflater.cpp
+50
-41
Inflater.h
Inflater.h
+3
-2
Messages/Annotation.cpp
Messages/Annotation.cpp
+2
-2
Messages/Annotation.h
Messages/Annotation.h
+1
-1
Messages/CursorMessage.cpp
Messages/CursorMessage.cpp
+1
-1
Messages/CursorMessage.h
Messages/CursorMessage.h
+1
-1
Messages/CursorPositionMessage.cpp
Messages/CursorPositionMessage.cpp
+1
-1
Messages/CursorPositionMessage.h
Messages/CursorPositionMessage.h
+1
-1
Messages/DeleteAllAnnotation.cpp
Messages/DeleteAllAnnotation.cpp
+1
-1
Messages/DeleteAllAnnotation.h
Messages/DeleteAllAnnotation.h
+1
-1
Messages/DeleteAnnotation.cpp
Messages/DeleteAnnotation.cpp
+1
-2
Messages/DeleteAnnotation.h
Messages/DeleteAnnotation.h
+1
-1
Messages/EmptyMessage.cpp
Messages/EmptyMessage.cpp
+1
-1
Messages/EmptyMessage.h
Messages/EmptyMessage.h
+1
-1
Messages/FreehandAnnotation.cpp
Messages/FreehandAnnotation.cpp
+1
-1
Messages/FreehandAnnotation.h
Messages/FreehandAnnotation.h
+1
-1
Messages/HextileMessage.cpp
Messages/HextileMessage.cpp
+1
-1
Messages/HextileMessage.h
Messages/HextileMessage.h
+1
-1
Messages/HighlightAnnotation.cpp
Messages/HighlightAnnotation.cpp
+1
-1
Messages/HighlightAnnotation.h
Messages/HighlightAnnotation.h
+1
-1
Messages/LineAnnotation.cpp
Messages/LineAnnotation.cpp
+1
-1
Messages/LineAnnotation.h
Messages/LineAnnotation.h
+1
-1
Messages/Message.cpp
Messages/Message.cpp
+2
-2
Messages/Message.h
Messages/Message.h
+1
-1
Messages/RawMessage.cpp
Messages/RawMessage.cpp
+1
-1
Messages/RawMessage.h
Messages/RawMessage.h
+1
-1
Messages/RectangleAnnotation.cpp
Messages/RectangleAnnotation.cpp
+1
-1
Messages/RectangleAnnotation.h
Messages/RectangleAnnotation.h
+1
-1
Messages/WhiteboardMessage.cpp
Messages/WhiteboardMessage.cpp
+1
-1
Messages/WhiteboardMessage.h
Messages/WhiteboardMessage.h
+1
-1
Player.cpp
Player.cpp
+20
-11
Player.h
Player.h
+2
-2
ProtocolPreferences.cpp
ProtocolPreferences.cpp
+1
-1
ProtocolPreferences.h
ProtocolPreferences.h
+1
-1
SizedArray.cpp
SizedArray.cpp
+1
-1
SizedArray.h
SizedArray.h
+1
-1
Video.cpp
Video.cpp
+92
-35
Video.h
Video.h
+7
-7
build/Debug/GNU-Linux-x86/Audio.o
build/Debug/GNU-Linux-x86/Audio.o
+0
-0
build/Debug/GNU-Linux-x86/AudioInterface.o
build/Debug/GNU-Linux-x86/AudioInterface.o
+0
-0
build/Debug/GNU-Linux-x86/Controls.o
build/Debug/GNU-Linux-x86/Controls.o
+0
-0
build/Debug/GNU-Linux-x86/Controls.o.d
build/Debug/GNU-Linux-x86/Controls.o.d
+3
-1
build/Debug/GNU-Linux-x86/Index.o
build/Debug/GNU-Linux-x86/Index.o
+0
-0
build/Debug/GNU-Linux-x86/Index.o.d
build/Debug/GNU-Linux-x86/Index.o.d
+5
-2
build/Debug/GNU-Linux-x86/IndexEntry.o
build/Debug/GNU-Linux-x86/IndexEntry.o
+0
-0
build/Debug/GNU-Linux-x86/Inflater.o
build/Debug/GNU-Linux-x86/Inflater.o
+0
-0
build/Debug/GNU-Linux-x86/Inflater.o.d
build/Debug/GNU-Linux-x86/Inflater.o.d
+3
-1
build/Debug/GNU-Linux-x86/Messages/Annotation.o
build/Debug/GNU-Linux-x86/Messages/Annotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/Annotation.o.d
build/Debug/GNU-Linux-x86/Messages/Annotation.o.d
+9
-7
build/Debug/GNU-Linux-x86/Messages/CursorMessage.o
build/Debug/GNU-Linux-x86/Messages/CursorMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/CursorMessage.o.d
build/Debug/GNU-Linux-x86/Messages/CursorMessage.o.d
+3
-1
build/Debug/GNU-Linux-x86/Messages/CursorPositionMessage.o
build/Debug/GNU-Linux-x86/Messages/CursorPositionMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/CursorPositionMessage.o.d
build/Debug/GNU-Linux-x86/Messages/CursorPositionMessage.o.d
+5
-2
build/Debug/GNU-Linux-x86/Messages/DeleteAllAnnotation.o
build/Debug/GNU-Linux-x86/Messages/DeleteAllAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/DeleteAllAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/DeleteAllAnnotation.o.d
+5
-2
build/Debug/GNU-Linux-x86/Messages/DeleteAnnotation.o
build/Debug/GNU-Linux-x86/Messages/DeleteAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/DeleteAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/DeleteAnnotation.o.d
+5
-2
build/Debug/GNU-Linux-x86/Messages/EmptyMessage.o
build/Debug/GNU-Linux-x86/Messages/EmptyMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/EmptyMessage.o.d
build/Debug/GNU-Linux-x86/Messages/EmptyMessage.o.d
+3
-1
build/Debug/GNU-Linux-x86/Messages/FreehandAnnotation.o
build/Debug/GNU-Linux-x86/Messages/FreehandAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/FreehandAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/FreehandAnnotation.o.d
+5
-2
build/Debug/GNU-Linux-x86/Messages/HextileMessage.o
build/Debug/GNU-Linux-x86/Messages/HextileMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/HextileMessage.o.d
build/Debug/GNU-Linux-x86/Messages/HextileMessage.o.d
+6
-3
build/Debug/GNU-Linux-x86/Messages/HighlightAnnotation.o
build/Debug/GNU-Linux-x86/Messages/HighlightAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/HighlightAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/HighlightAnnotation.o.d
+5
-2
build/Debug/GNU-Linux-x86/Messages/LineAnnotation.o
build/Debug/GNU-Linux-x86/Messages/LineAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/LineAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/LineAnnotation.o.d
+3
-1
build/Debug/GNU-Linux-x86/Messages/Message.o
build/Debug/GNU-Linux-x86/Messages/Message.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/Message.o.d
build/Debug/GNU-Linux-x86/Messages/Message.o.d
+10
-7
build/Debug/GNU-Linux-x86/Messages/RawMessage.o
build/Debug/GNU-Linux-x86/Messages/RawMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/RawMessage.o.d
build/Debug/GNU-Linux-x86/Messages/RawMessage.o.d
+5
-3
build/Debug/GNU-Linux-x86/Messages/RectangleAnnotation.o
build/Debug/GNU-Linux-x86/Messages/RectangleAnnotation.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/RectangleAnnotation.o.d
build/Debug/GNU-Linux-x86/Messages/RectangleAnnotation.o.d
+6
-3
build/Debug/GNU-Linux-x86/Messages/WhiteboardMessage.o
build/Debug/GNU-Linux-x86/Messages/WhiteboardMessage.o
+0
-0
build/Debug/GNU-Linux-x86/Messages/WhiteboardMessage.o.d
build/Debug/GNU-Linux-x86/Messages/WhiteboardMessage.o.d
+9
-6
build/Debug/GNU-Linux-x86/Player.o
build/Debug/GNU-Linux-x86/Player.o
+0
-0
build/Debug/GNU-Linux-x86/Player.o.d
build/Debug/GNU-Linux-x86/Player.o.d
+4
-2
build/Debug/GNU-Linux-x86/Video.o
build/Debug/GNU-Linux-x86/Video.o
+0
-0
build/Debug/GNU-Linux-x86/Video.o.d
build/Debug/GNU-Linux-x86/Video.o.d
+3
-1
build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o
+0
-0
build/Debug/GNU-Linux-x86/main.o.d
build/Debug/GNU-Linux-x86/main.o.d
+3
-1
dist/Debug/GNU-Linux-x86/tttplayer
dist/Debug/GNU-Linux-x86/tttplayer
+0
-0
emBuild/Assets/speed.bmp
emBuild/Assets/speed.bmp
+0
-0
emBuild/Assets/speed.png
emBuild/Assets/speed.png
+0
-0
emBuild/Assets/speed2.bmp
emBuild/Assets/speed2.bmp
+0
-0
emBuild/Audio.js
emBuild/Audio.js
+13
-14
emBuild/Audiocontrols.html
emBuild/Audiocontrols.html
+0
-7
emBuild/Makefile
emBuild/Makefile
+3
-6
emBuild/fileplayer.html
emBuild/fileplayer.html
+5
-2
emBuild/fileplayer.js
emBuild/fileplayer.js
+28
-23
emBuild/fileplayer.phtml
emBuild/fileplayer.phtml
+29
-22
emBuild/index.html
emBuild/index.html
+2
-1
emBuild/index.html~
emBuild/index.html~
+8
-0
emBuild/pre.js
emBuild/pre.js
+6
-3
emBuild/zlib.bc
emBuild/zlib.bc
+0
-0
main.cpp
main.cpp
+10
-2
main.h
main.h
+3
-3
nbproject/private/private.xml
nbproject/private/private.xml
+1
-1
No files found.
Audio.cpp
View file @
949072d9
/*
* File: Audio.cpp
* Author: user
* http://wiki.delphigl.com/index.php/OpenAL-Funktions%C3%BCbersicht
* http://www.codeproject.com/Articles/656543/The-LAME-wrapper-An-audio-converter
* https://github.com/sopel39/audioconverter.js
* Author: Johannes Fischer
* Created on April 30, 2014, 3:39 PM
*/
...
...
@@ -94,13 +91,13 @@ int Audio::getPosition()
if
((
error
=
alGetError
())
!=
AL_NO_ERROR
)
printf
(
"getTime error: %d
\n
"
,
error
);
//printf("%f\n",(float) time);
return
(
int
)
time
;
return
(
int
)
(
time
*
1000
)
;
}
void
Audio
::
setPosition
(
int
pos
)
{
ALfloat
time
=
(
ALfloat
)
pos
;
ALfloat
time
=
(
ALfloat
)
(
pos
/
1000
)
;
alSourcef
(
source
,
AL_SEC_OFFSET
,
time
);
uint
error
;
if
((
error
=
alGetError
())
!=
AL_NO_ERROR
)
...
...
@@ -112,6 +109,11 @@ void Audio::changeVolume(float volume){
alSourcef
(
source
,
AL_GAIN
,
v
);
}
void
Audio
::
changeSpeed
(
float
speed
){
ALfloat
s
=
speed
;
alSourcef
(
source
,
AL_PITCH
,
s
);
}
int
Audio
::
getDuration
()
{
ALint
numBytes
;
...
...
@@ -132,7 +134,7 @@ int Audio::getDuration()
if
(
alGetError
()
!=
AL_NO_ERROR
)
printf
(
"getDuration error
\n
"
);
return
(
int
)
seconds
;
return
(
int
)
(
seconds
*
1000
)
;
}
bool
Audio
::
hasFailed
()
...
...
Audio.h
View file @
949072d9
/*
* File: Audio.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on April 30, 2014, 3:39 PM
*/
...
...
@@ -42,6 +42,7 @@ public:
int
getDuration
();
bool
hasFailed
();
void
changeVolume
(
float
volume
);
void
changeSpeed
(
float
volume
);
bool
isPlaying
();
private:
...
...
AudioInterface.cpp
View file @
949072d9
/*
* File: AudioInterface.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 2:15 PM
*/
...
...
@@ -28,6 +28,9 @@ void AudioInterface::setPosition(int pos){
void
AudioInterface
::
changeVolume
(
float
volume
){
}
void
AudioInterface
::
changeSpeed
(
float
volume
){
}
bool
AudioInterface
::
hasFailed
(){
return
true
;
}
...
...
AudioInterface.h
View file @
949072d9
/*
* File: AudioInterface.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 2:15 PM
*/
...
...
@@ -8,7 +8,7 @@
#ifndef AUDIOINTERFACE_H
#define AUDIOINTERFACE_H
using
namespace
std
;
//
using namespace std;
class
AudioInterface
{
public:
...
...
@@ -20,6 +20,7 @@ public:
virtual
int
getDuration
();
virtual
bool
hasFailed
();
virtual
void
changeVolume
(
float
volume
);
virtual
void
changeSpeed
(
float
volume
);
virtual
bool
isPlaying
();
};
...
...
AudioJS.cpp
View file @
949072d9
/*
* File: AudioJS.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 2:51 PM
*/
...
...
@@ -49,6 +49,12 @@ void AudioJS::changeVolume(float volume){
},
volume
);
}
void
AudioJS
::
changeSpeed
(
float
speed
){
EM_ASM_INT
({
x_changeSpeed
(
$
0
);
},
speed
);
}
bool
AudioJS
::
isPlaying
(){
return
EM_ASM_INT
({
return
x_audio
.
paused
;
...
...
AudioJS.h
View file @
949072d9
/*
* File: AudioJS.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 2:51 PM
*/
...
...
@@ -30,6 +30,7 @@ public:
int
getDuration
();
bool
hasFailed
();
void
changeVolume
(
float
volume
);
void
changeSpeed
(
float
volume
);
bool
isPlaying
();
private:
int
duration
;
...
...
ColorConverter.cpp
View file @
949072d9
/*
* File: ColorConverter.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on June 4, 2014, 3:55 PM
*/
...
...
ColorConverter.h
View file @
949072d9
/*
* File: ColorConverter.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on June 4, 2014, 3:55 PM
*/
...
...
Constants.cpp
View file @
949072d9
/*
* File: Constants.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on May 5, 2014, 5:39 PM
*/
...
...
Constants.h
View file @
949072d9
/*
* File: Constants.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Original by Fabian Petter on 10/11/10.
* https://www2.in.tum.de/repos/ttt/branches/iOS/viewer/1.0/Classes/Constants.h
...
...
@@ -22,7 +22,7 @@
//message kinds
#define ANNOTATION 'a'
#define EMPTY '0'
#define RA
W
'r'
#define
F
RA
MEBUFFER
'r'
#define CURSOR 'c'
//message types
...
...
Controls.cpp
View file @
949072d9
/*
* File: Controls.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 6:40 PM
*/
...
...
@@ -10,6 +10,7 @@
#include "Player.h"
bool
mouseOnFullScreenButton
;
bool
mouseOnPlayButton
;
Controls
::
Controls
(
Video
*
video
,
AudioInterface
*
audio
)
{
this
->
video
=
video
;
...
...
@@ -19,36 +20,41 @@ Controls::Controls(Video* video, AudioInterface* audio) {
ProtocolPreferences
prefs
;
progress
=
0
;
//TODO: m
ight
make these relative to
video
's height
//TODO: m
aybe
make these relative to
the screen
's height
timeLineHeight
=
16
;
height
=
timeLineHeight
+
32
;
width
=
prefs
.
framebufferWidth
;
screenHeight
=
prefs
.
framebufferHeight
;
y
=
screenHeight
;
visible
=
false
;
y
=
screenHeight
-
height
;
visible
=
true
;
//In the beginning, the whole screen should be redrawn
redefineRect
(
&
videoUpdate
,
0
,
0
,
width
,
screenHeight
);
timeLineClicked
=
false
;
volumeClicked
=
false
;
volume
=
1
;
speedClicked
=
false
;
speed
=
1
;
mouseOnFullScreenButton
=
false
;
mouseOnPlayButton
=
false
;
#ifdef EMSCRIPTEN
//Make Fullscreen and starting the <audio> element possible
EM_ASM
(
x_setup
FullScreen
();
x_setup
Listener
();
);
#endif
surfPlay
=
SDL_LoadBMP
(
"Assets/PlayPause.bmp"
);
surfVolume
=
SDL_LoadBMP
(
"Assets/volume.bmp"
);
surfVolume2
=
SDL_LoadBMP
(
"Assets/volume2.bmp"
);
surfFullscreen
=
SDL_LoadBMP
(
"Assets/fullscreen.bmp"
);
#else
surfPlay
=
SDL_LoadBMP
(
"/home/user/NetBeansProjects/TTTPlayer/emBuild/Assets/PlayPause.bmp"
);
surfVolume
=
SDL_LoadBMP
(
"/home/user/NetBeansProjects/TTTPlayer/emBuild/Assets/volume.bmp"
);
surfVolume2
=
SDL_LoadBMP
(
"/home/user/NetBeansProjects/TTTPlayer/emBuild/Assets/volume2.bmp"
);
surfFullscreen
=
SDL_LoadBMP
(
"/home/user/NetBeansProjects/TTTPlayer/emBuild/Assets/fullscreen.bmp"
);
#endif
if
(
surfPlay
==
NULL
||
surfVolume
==
NULL
||
surfVolume2
==
NULL
||
surfFullscreen
==
NULL
)
surfSpeed
=
SDL_LoadBMP
(
"Assets/speed.bmp"
);
surfSpeed2
=
SDL_LoadBMP
(
"Assets/speed2.bmp"
);
if
(
surfPlay
==
NULL
||
surfVolume
==
NULL
||
surfVolume2
==
NULL
||
surfFullscreen
==
NULL
||
surfSpeed
==
NULL
||
surfSpeed2
==
NULL
)
printf
(
"BMPs ARE NULL
\n
"
);
}
...
...
@@ -56,11 +62,16 @@ Controls::~Controls() {
SDL_FreeSurface
(
surfPlay
);
SDL_FreeSurface
(
surfVolume
);
SDL_FreeSurface
(
surfVolume2
);
SDL_FreeSurface
(
surfSpeed
);
SDL_FreeSurface
(
surfSpeed2
);
SDL_FreeSurface
(
surfFullscreen
);
audio
=
NULL
;
video
=
NULL
;
}
/**
* Will be called after the user presses the left mouse button
*/
void
Controls
::
registerClick
(
Uint16
mx
,
Uint16
my
){
if
(
my
<
y
)
return
;
...
...
@@ -70,45 +81,66 @@ void Controls::registerClick(Uint16 mx, Uint16 my){
}
else
{
#ifndef EMSCRIPTEN
if
(
mx
<
48
)
togglePlay
();
else
if
(
mx
>=
width
-
48
)
toggleFullscreen
();
else
if
(
mx
<=
128
&&
mx
>=
64
)
else
#endif
if
(
mx
<=
128
&&
mx
>=
64
)
volumeClicked
=
true
;
else
if
(
mx
<=
196
&&
mx
>=
160
)
speedClicked
=
true
;
}
registerMovement
(
mx
,
my
);
}
/**
* Will be called after the user releases the left mouse button
*/
void
Controls
::
registerMouseUp
(){
if
(
timeLineClicked
)
{
redefineRect
(
&
videoUpdate
,
0
,
0
,
width
,
screenHeight
-
height
);
skipTo
(
duration
*
mouseX
/
width
);
skipTo
(
duration
/
width
*
mouseX
);
}
timeLineClicked
=
false
;
volumeClicked
=
false
;
speedClicked
=
false
;
}
/**
* Will be called whenever the mouse has moved
*/
void
Controls
::
registerMovement
(
Uint16
mx
,
Uint16
my
)
{
visible
=
(
my
>=
screenHeight
-
height
)
||
timeLineClicked
||
volumeClicked
;
visible
=
(
my
>=
screenHeight
-
height
)
||
timeLineClicked
||
volumeClicked
||
speedClicked
;
mouseX
=
mx
;
mouseY
=
my
;
if
(
volumeClicked
)
changeVolume
(
max
(
min
((
float
)(
mx
-
64
),(
float
)
64
),(
float
)
0
)
/
64
);
if
(
speedClicked
)
changeSpeed
(
max
(
min
((
float
)(
mx
-
160
),(
float
)
36
),(
float
)
0
)
/
72
+
1
);
//#ifdef EMSCRIPTEN
mouseOnFullScreenButton
=
(
mx
>=
width
-
48
&&
my
>=
y
+
timeLineHeight
);
mouseOnPlayButton
=
(
mx
<
48
&&
my
>=
y
+
timeLineHeight
);
//#endif
}
//
#ifdef EMSCRIPTEN
#ifdef EMSCRIPTEN
extern
"C"
bool
getOnFullScreenButton
(){
return
mouseOnFullScreenButton
;
}
//#endif
extern
"C"
bool
getOnPlayButton
(){
return
mouseOnPlayButton
;
}
#endif
/**
* When the mouse is not hovering over Controls' position, Controls moves out of the screen
*/
void
Controls
::
update
(){
if
(
visible
)
{
...
...
@@ -155,7 +187,6 @@ void Controls::draw(SDL_Surface *screen, bool hasDrawn){
//play/pause
redefineRect
(
&
rect
,
0
,
y
+
timeLineHeight
,
48
,
height
-
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x338844
));
if
(
surfPlay
!=
NULL
)
{
if
(
audio
->
isPlaying
())
...
...
@@ -166,24 +197,31 @@ void Controls::draw(SDL_Surface *screen, bool hasDrawn){
}
//volume
redefineRect
(
&
rect
,
64
,
y
+
timeLineHeight
,
64
,
height
-
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x333333
));
redefineRect
(
&
rect
,
64
,
y
+
timeLineHeight
,
(
int
)(
volume
*
64.0
),
height
-
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x00ff00
));
if
(
surfVolume
!=
NULL
&&
surfVolume2
!=
NULL
)
{
redefineRect
(
&
rect
,
64
,
y
+
timeLineHeight
,
64
,
32
);
redefineRect
(
&
srcRect
,
0
,
0
,
64
,
32
);
SDL_BlitSurface
(
surfVolume2
,
&
srcRect
,
screen
,
&
rect
);
redefineRect
(
&
srcRect
,
0
,
0
,(
int
)(
volume
*
64.0
),
32
);
redefineRect
(
&
rect
,
64
,
y
+
timeLineHeight
,
(
int
)(
volume
*
64.0
)
,
32
);
if
(
(
int
)(
volume
*
64.0
)
>=
1
)
redefineRect
(
&
rect
,
64
,
y
+
timeLineHeight
,
srcRect
.
w
,
32
);
if
(
srcRect
.
w
>=
1
)
SDL_BlitSurface
(
surfVolume
,
&
srcRect
,
screen
,
&
rect
);
}
//speed
if
(
surfSpeed
!=
NULL
&&
surfSpeed2
!=
NULL
)
{
redefineRect
(
&
rect
,
160
,
y
+
timeLineHeight
,
36
,
32
);
redefineRect
(
&
srcRect
,
0
,
0
,
36
,
32
);
SDL_BlitSurface
(
surfSpeed2
,
&
srcRect
,
screen
,
&
rect
);
redefineRect
(
&
srcRect
,
0
,
0
,(
int
)(
speed
*
72.0
)
-
72
,
32
);
redefineRect
(
&
rect
,
160
,
y
+
timeLineHeight
,
srcRect
.
w
,
32
);
if
(
srcRect
.
w
>=
1
)
SDL_BlitSurface
(
surfSpeed
,
&
srcRect
,
screen
,
&
rect
);
}
//fullscreen button
redefineRect
(
&
rect
,
width
-
48
,
y
+
timeLineHeight
,
48
,
height
-
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x338844
));
if
(
surfFullscreen
!=
NULL
)
{
redefineRect
(
&
srcRect
,
0
,
0
,
48
,
32
);
...
...
@@ -195,14 +233,14 @@ void Controls::draw(SDL_Surface *screen, bool hasDrawn){
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x333333
));
if
(
progress
>=
0
)
{
redefineRect
(
&
rect
,
progress
/
1000
*
width
/
duration
,
y
,
width
-
progress
/
1000
*
width
/
duration
,
timeLineHeight
);
redefineRect
(
&
rect
,
(
progress
/
1000
)
*
width
/
(
duration
/
1000
)
,
y
,
width
-
(
progress
/
1000
)
*
width
/
(
duration
/
1000
)
,
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0x000000
));
}
int
currentPosition
=
audio
->
getPosition
();
//timeLine foreground
if
(
!
timeLineClicked
)
redefineRect
(
&
rect
,
0
,
y
,
currentPosition
*
width
/
duration
,
timeLineHeight
);
redefineRect
(
&
rect
,
0
,
y
,
(
currentPosition
/
1000
)
*
width
/
(
duration
/
1000
)
,
timeLineHeight
);
else
redefineRect
(
&
rect
,
0
,
y
,
mouseX
,
timeLineHeight
);
SDL_FillRect
(
screen
,
&
rect
,
emColor
(
0xaa0000
));
...
...
@@ -210,7 +248,7 @@ void Controls::draw(SDL_Surface *screen, bool hasDrawn){
//draw "time / duration"
SDL_Color
white
=
{
0xff
,
0xff
,
0xff
,
0xff
};
ostringstream
oss
;
oss
<<
currentPosition
/
60
<<
":"
<<
((
currentPosition
%
60
<
10
)
?
"0"
:
""
)
<<
currentPosition
%
60
<<
"/"
<<
duration
/
60
<<
":"
<<
((
duration
%
60
<
10
)
?
"0"
:
""
)
<<
duration
%
60
;
oss
<<
(
currentPosition
/
1000
)
/
60
<<
":"
<<
(
((
currentPosition
/
1000
)
%
60
<
10
)
?
"0"
:
""
)
<<
(
currentPosition
/
1000
)
%
60
<<
"/"
<<
(
duration
/
1000
)
/
60
<<
":"
<<
((
(
duration
/
1000
)
%
60
<
10
)
?
"0"
:
""
)
<<
(
duration
/
1000
)
%
60
;
SDL_Surface
*
times
=
TTF_RenderText_Solid
(
Player
::
font
,
oss
.
str
().
c_str
(),
white
);
#ifdef EMSCRIPTEN
...
...
@@ -223,10 +261,10 @@ void Controls::draw(SDL_Surface *screen, bool hasDrawn){
if
(
mouseY
>=
y
&&
mouseY
<
y
+
timeLineHeight
)
{
video
->
drawThumbnail
(
duration
*
mouseX
/
width
*
1000
,
mouseX
,
y
);
video
->
drawThumbnail
(
duration
/
width
*
mouseX
,
mouseX
,
y
);
//draw time at cursor position
ostringstream
oss2
;
oss2
<<
duration
*
mouseX
/
width
/
60
<<
":"
<<
(((
duration
*
mouseX
/
width
)
%
60
<
10
)
?
"0"
:
""
)
<<
(
duration
*
mouseX
/
width
)
%
60
;
oss2
<<
(
duration
/
1000
)
*
mouseX
/
width
/
60
<<
":"
<<
(((
(
duration
/
1000
)
*
mouseX
/
width
)
%
60
<
10
)
?
"0"
:
""
)
<<
(
(
duration
/
1000
)
*
mouseX
/
width
)
%
60
;
SDL_Color
black
=
{
0
,
0
,
0
,
0xff
};
/*TTF_SetFontOutline(Player::font,2);
times=TTF_RenderText_Solid(Player::font,oss2.str().c_str(),black);
...
...
@@ -260,6 +298,13 @@ Uint32 Controls::emColor(unsigned int color){
#endif
}
/**
* Needed to draw the text indicating the times scaled
* @param source source text image
* @param x
* @param y
* @return Color in the source images color format
*/
Uint32
Controls
::
readPixel
(
SDL_Surface
*
source
,
int
x
,
int
y
){
switch
(
source
->
format
->
BytesPerPixel
)
{
...
...
@@ -272,6 +317,14 @@ Uint32 Controls::readPixel(SDL_Surface* source, int x, int y){
}
}
/**
* Font size doesn't work right with Emscripten. Therefore we have to scale it up manually
* @param screen the target surface
* @param text the original (small) text image
* @param x
* @param y
* @param factor how strong the image should be upscaled
*/
void
Controls
::
drawScaledText
(
SDL_Surface
*
screen
,
SDL_Surface
*
text
,
short
x
,
short
y
,
char
factor
)
{
SDL_Rect
rect
=
{
0
,
0
,
factor
,
factor
};
SDL_LockSurface
(
text
);
...
...
@@ -301,3 +354,8 @@ void Controls::changeVolume(float volume){
this
->
volume
=
volume
;
audio
->
changeVolume
(
volume
);
}
void
Controls
::
changeSpeed
(
float
speed
){
this
->
speed
=
speed
;
audio
->
changeSpeed
(
speed
);
}
Controls.h
View file @
949072d9
/*
* File: Controls.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 13, 2014, 6:40 PM
*/
...
...
@@ -47,6 +47,7 @@ private:
Uint32
emColor
(
Uint32
);
void
redefineRect
(
SDL_Rect
*
rect
,
int
x
,
int
y
,
int
w
,
int
h
);
void
changeVolume
(
float
volume
);
void
changeSpeed
(
float
volume
);
void
drawScaledText
(
SDL_Surface
*
screen
,
SDL_Surface
*
text
,
short
x
,
short
y
,
char
factor
);
Uint32
readPixel
(
SDL_Surface
*
source
,
int
x
,
int
y
);
...
...
@@ -60,16 +61,21 @@ private:
int
mouseX
,
mouseY
;
bool
volumeClicked
;
float
volume
;
bool
speedClicked
;
float
speed
;
int
duration
;
SDL_Surface
*
surfPlay
;
SDL_Surface
*
surfVolume
;
SDL_Surface
*
surfVolume2
;
SDL_Surface
*
surfFullscreen
;
SDL_Surface
*
surfSpeed
;
SDL_Surface
*
surfSpeed2
;
};
//#ifdef EMSCRIPTEN
extern
"C"
bool
getOnFullScreenButton
();
extern
"C"
bool
getOnPlayButton
();
//#endif
...
...
Index.cpp
View file @
949072d9
/*
* File: Index.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 23, 2014, 10:10 PM
*/
...
...
@@ -40,7 +40,7 @@ Index::Index(Message** messages, int numMessages) {
Message
*
message
=
messages
[
i
];
// sum up area(s)
if
(
message
->
type
==
RA
W
)
{
if
(
message
->
type
==
F
RA
MEBUFFER
)
{
area
+=
message
->
getArea
();
//printf("%d,",area);
}
else
if
(
area
==
0
)
...
...
@@ -196,7 +196,7 @@ bool Index::fillSurface(SDL_Surface* screen, Message** messages, int numMessages
while
(
currentMessage
<
numMessages
)
{
if
(
messages
[
currentMessage
]
->
timestamp
>
(
*
it
)
->
timestamp
)
break
;
if
(
messages
[
currentMessage
]
->
type
==
RA
W
)
if
(
messages
[
currentMessage
]
->
type
==
F
RA
MEBUFFER
)
messages
[
currentMessage
]
->
paint
(
waypoint
,
prefs
);
currentMessage
++
;
}
...
...
Index.h
View file @
949072d9
/*
* File: Index.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 23, 2014, 10:10 PM
*/
...
...
IndexEntry.cpp
View file @
949072d9
/*
* File: IndexEntry.cpp
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 24, 2014, 12:54 AM
*/
...
...
@@ -89,6 +89,7 @@ void writePixel(SDL_Surface* target, int x, int y, Uint32 color){
SDL_Surface
*
IndexEntry
::
scaleDownSurface
(
SDL_Surface
*
source
,
char
factor
)
{
SDL_Surface
*
result
=
SDL_CreateRGBSurface
(
0
,
source
->
w
/
factor
,
source
->
h
/
factor
,
source
->
format
->
BitsPerPixel
,
source
->
format
->
Rmask
,
source
->
format
->
Gmask
,
source
->
format
->
Bmask
,
source
->
format
->
Amask
);
SDL_LockSurface
(
result
);
Uint32
alpha
,
red
,
green
,
blue
;
Uint32
color
,
colorPart
;
for
(
int
i
=
0
;
i
<
result
->
w
;
i
++
)
...
...
@@ -102,5 +103,6 @@ SDL_Surface* IndexEntry::scaleDownSurface(SDL_Surface* source, char factor) {
readPixel(source,i+k,j+l);
}*/
}
SDL_UnlockSurface
(
result
);
return
result
;
}
IndexEntry.h
View file @
949072d9
/*
* File: IndexEntry.h
* Author:
us
er
* Author:
Johannes Fisch
er
*
* Created on July 24, 2014, 12:54 AM
*/
...
...
Inflater.cpp
View file @
949072d9
/*
* File: Inflater.cpp
* Author: user
* using http://zlib.net/zlib_how.html
* Author: Johannes Fischer
*
* Created on May 8, 2014, 12:46 PM
*
* Credits to http://zlib.net/zlib_how.html
*/
#include "Inflater.h"
Inflater
::
Inflater
(
FILE
*
f
)
{
//printf("Constructor of Inflater\n");
source
=
f
;
outOffset
=
0
;
/*fseek(source,0,SEEK_END);
printf("Inflater file size: %ld\n",ftell(source));
fseek(source,0,SEEK_SET);*/
// allocate inflate state
strm
.
zalloc
=
Z_NULL
;
strm
.
zfree
=
Z_NULL
;
strm
.
zalloc
=
Z_NULL
;
strm
.
opaque
=
Z_NULL
;
strm
.
avail_in
=
0