Skip to content

Commit e2da5b2

Browse files
committed
Updated packet code
1 parent ee936d1 commit e2da5b2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packet.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package media
22

33
import (
4+
"encoding/json"
5+
46
// Packages
57
ff "github.com/mutablelogic/go-media/sys/ffmpeg61"
68
)
@@ -9,8 +11,7 @@ import (
911
// TYPES
1012

1113
type packet struct {
12-
X string `json:"type"`
13-
*ff.AVPacket
14+
ctx *ff.AVPacket
1415
}
1516

1617
var _ Packet = (*packet)(nil)
@@ -19,5 +20,17 @@ var _ Packet = (*packet)(nil)
1920
// LIFECYCLE
2021

2122
func newPacket(ctx *ff.AVPacket) *packet {
22-
return &packet{"X", ctx}
23+
return &packet{ctx}
24+
}
25+
26+
////////////////////////////////////////////////////////////////////////////////
27+
// STRINGIFY
28+
29+
func (packet *packet) MarshalJSON() ([]byte, error) {
30+
return json.Marshal(packet.ctx)
31+
}
32+
33+
func (packet *packet) String() string {
34+
data, _ := json.MarshalIndent(packet, "", " ")
35+
return string(data)
2336
}

0 commit comments

Comments
 (0)