media: decode waveform TG -> Matrix

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-06-25 11:02:55 -06:00
parent 7437240f2f
commit 6bd2ef5b34
+3 -2
View File
@@ -19,6 +19,7 @@ import (
"go.mau.fi/mautrix-telegram/pkg/connector/download" "go.mau.fi/mautrix-telegram/pkg/connector/download"
"go.mau.fi/mautrix-telegram/pkg/connector/ids" "go.mau.fi/mautrix-telegram/pkg/connector/ids"
"go.mau.fi/mautrix-telegram/pkg/connector/util" "go.mau.fi/mautrix-telegram/pkg/connector/util"
"go.mau.fi/mautrix-telegram/pkg/connector/waveform"
) )
type spoilable interface { type spoilable interface {
@@ -191,8 +192,8 @@ func (mc *MessageConverter) convertMediaRequiringUpload(ctx context.Context, por
audio = &event.MSC1767Audio{ audio = &event.MSC1767Audio{
Duration: a.Duration * 1000, Duration: a.Duration * 1000,
} }
if waveform, ok := a.GetWaveform(); ok { if wf, ok := a.GetWaveform(); ok {
for _, v := range waveform { for _, v := range waveform.Decode(wf) {
audio.Waveform = append(audio.Waveform, int(v)<<5) audio.Waveform = append(audio.Waveform, int(v)<<5)
} }
} }