Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
0fad0762
Commit
0fad0762
authored
4 years ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Move audio decoders for easier copy/paste
parent
f7546a73
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
thumbnailing/i/flac.go
+13
-4
13 additions, 4 deletions
thumbnailing/i/flac.go
thumbnailing/i/mp3.go
+12
-4
12 additions, 4 deletions
thumbnailing/i/mp3.go
thumbnailing/i/ogg.go
+13
-4
13 additions, 4 deletions
thumbnailing/i/ogg.go
thumbnailing/i/wav.go
+13
-4
13 additions, 4 deletions
thumbnailing/i/wav.go
with
51 additions
and
16 deletions
thumbnailing/i/flac.go
+
13
−
4
View file @
0fad0762
...
...
@@ -3,6 +3,7 @@ package i
import
(
"errors"
"github.com/faiface/beep"
"github.com/faiface/beep/flac"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/thumbnailing/m"
...
...
@@ -24,10 +25,18 @@ func (d flacGenerator) matches(img []byte, contentType string) bool {
return
contentType
==
"audio/flac"
}
func
(
d
flacGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
func
(
d
flacGenerator
)
decode
(
b
[]
byte
)
(
beep
.
StreamSeekCloser
,
beep
.
Format
,
error
)
{
audio
,
format
,
err
:=
flac
.
Decode
(
util
.
ByteCloser
(
b
))
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"flac: error decoding audio: "
+
err
.
Error
())
return
audio
,
format
,
errors
.
New
(
"flac: error decoding audio: "
+
err
.
Error
())
}
return
audio
,
format
,
nil
}
func
(
d
flacGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
defer
audio
.
Close
()
...
...
@@ -35,9 +44,9 @@ func (d flacGenerator) GenerateThumbnail(b []byte, contentType string, width int
}
func
(
d
flacGenerator
)
GetAudioData
(
b
[]
byte
,
nKeys
int
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
AudioInfo
,
error
)
{
audio
,
format
,
err
:=
flac
.
Decode
(
util
.
ByteCloser
(
b
)
)
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
ors
.
New
(
"flac: error decoding audio: "
+
err
.
Error
())
return
nil
,
err
}
defer
audio
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
thumbnailing/i/mp3.go
+
12
−
4
View file @
0fad0762
...
...
@@ -32,10 +32,18 @@ func (d mp3Generator) matches(img []byte, contentType string) bool {
return
contentType
==
"audio/mpeg"
}
func
(
d
mp3Generator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
func
(
d
mp3Generator
)
decode
(
b
[]
byte
)
(
beep
.
StreamSeekCloser
,
beep
.
Format
,
error
)
{
audio
,
format
,
err
:=
mp3
.
Decode
(
util
.
ByteCloser
(
b
))
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"mp3: error decoding audio: "
+
err
.
Error
())
return
audio
,
format
,
errors
.
New
(
"mp3: error decoding audio: "
+
err
.
Error
())
}
return
audio
,
format
,
nil
}
func
(
d
mp3Generator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
defer
audio
.
Close
()
...
...
@@ -43,9 +51,9 @@ func (d mp3Generator) GenerateThumbnail(b []byte, contentType string, width int,
}
func
(
d
mp3Generator
)
GetAudioData
(
b
[]
byte
,
nKeys
int
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
AudioInfo
,
error
)
{
audio
,
format
,
err
:=
mp3
.
D
ecode
(
util
.
ByteCloser
(
b
)
)
audio
,
format
,
err
:=
d
.
d
ecode
(
b
)
if
err
!=
nil
{
return
nil
,
err
ors
.
New
(
"mp3: error decoding audio: "
+
err
.
Error
())
return
nil
,
err
}
defer
audio
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
thumbnailing/i/ogg.go
+
13
−
4
View file @
0fad0762
...
...
@@ -3,6 +3,7 @@ package i
import
(
"errors"
"github.com/faiface/beep"
"github.com/faiface/beep/vorbis"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/thumbnailing/m"
...
...
@@ -24,10 +25,18 @@ func (d oggGenerator) matches(img []byte, contentType string) bool {
return
contentType
==
"audio/ogg"
}
func
(
d
oggGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
func
(
d
oggGenerator
)
decode
(
b
[]
byte
)
(
beep
.
StreamSeekCloser
,
beep
.
Format
,
error
)
{
audio
,
format
,
err
:=
vorbis
.
Decode
(
util
.
ByteCloser
(
b
))
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"ogg: error decoding audio: "
+
err
.
Error
())
return
audio
,
format
,
errors
.
New
(
"ogg: error decoding audio: "
+
err
.
Error
())
}
return
audio
,
format
,
nil
}
func
(
d
oggGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
defer
audio
.
Close
()
...
...
@@ -35,9 +44,9 @@ func (d oggGenerator) GenerateThumbnail(b []byte, contentType string, width int,
}
func
(
d
oggGenerator
)
GetAudioData
(
b
[]
byte
,
nKeys
int
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
AudioInfo
,
error
)
{
audio
,
format
,
err
:=
vorbis
.
Decode
(
util
.
ByteCloser
(
b
)
)
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
ors
.
New
(
"ogg: error decoding audio: "
+
err
.
Error
())
return
nil
,
err
}
defer
audio
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
thumbnailing/i/wav.go
+
13
−
4
View file @
0fad0762
...
...
@@ -3,6 +3,7 @@ package i
import
(
"errors"
"github.com/faiface/beep"
"github.com/faiface/beep/wav"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/thumbnailing/m"
...
...
@@ -24,10 +25,18 @@ func (d wavGenerator) matches(img []byte, contentType string) bool {
return
contentType
==
"audio/wav"
}
func
(
d
wavGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
func
(
d
wavGenerator
)
decode
(
b
[]
byte
)
(
beep
.
StreamSeekCloser
,
beep
.
Format
,
error
)
{
audio
,
format
,
err
:=
wav
.
Decode
(
util
.
ByteCloser
(
b
))
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"wav: error decoding audio: "
+
err
.
Error
())
return
audio
,
format
,
errors
.
New
(
"wav: error decoding audio: "
+
err
.
Error
())
}
return
audio
,
format
,
nil
}
func
(
d
wavGenerator
)
GenerateThumbnail
(
b
[]
byte
,
contentType
string
,
width
int
,
height
int
,
method
string
,
animated
bool
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
Thumbnail
,
error
)
{
audio
,
format
,
err
:=
d
.
decode
(
b
)
if
err
!=
nil
{
return
nil
,
err
}
defer
audio
.
Close
()
...
...
@@ -35,9 +44,9 @@ func (d wavGenerator) GenerateThumbnail(b []byte, contentType string, width int,
}
func
(
d
wavGenerator
)
GetAudioData
(
b
[]
byte
,
nKeys
int
,
ctx
rcontext
.
RequestContext
)
(
*
m
.
AudioInfo
,
error
)
{
audio
,
format
,
err
:=
wav
.
D
ecode
(
util
.
ByteCloser
(
b
)
)
audio
,
format
,
err
:=
d
.
d
ecode
(
b
)
if
err
!=
nil
{
return
nil
,
err
ors
.
New
(
"wav: error decoding audio: "
+
err
.
Error
())
return
nil
,
err
}
defer
audio
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment