m3u8 icon indicating copy to clipboard operation
m3u8 copied to clipboard

Feature Request: m3u8.MediaSegment implements fmt.Stringer

Open keizo042 opened this issue 8 years ago • 5 comments
trafficstars

hello dev. Thanks you for your great work. the library is very useful :-)

I'd like to implement (m MediaSegment) String()string for testing like below. When failing test, I'd like to report as m3u8 text.

package something

import (
	"github.com/grafov/m3u8"
	"testing"
)

func TestXXX(t *testing.T) {
	var expected, actual m3u8.MediaSegment

        actual = do_something()
	if expected.SeqId != actual.SeqId {
		t.Fatalf("expected:%s,  but actual:%s\n", expected.String(), actual.String())
	}
}

there are already (p *MediaPlaylist) String() string and it converts m3u8.MeidaSegment to string. We can use the procedure to implement function I request.

If you agree to the issue but don't have enough time, I'd like to send PR.

keizo042 avatar Nov 15 '17 01:11 keizo042

This sounds reasonable, but there's a lot to output, what do you think it would show?

If you agree to the issue but don't have enough time, I'd like to send PR.

This would be great, thanks.

bradleyfalzon avatar Nov 15 '17 02:11 bradleyfalzon

It would be good it is same result to media segment part of (p *m3u8.MediaPlaylist) String() string

When all m3u8.MediaSegment field is presense, (p *m3u8.MediaPlaylist) Decode()(byte.Buffer, error) and (p *m3u8.MediaPlaylist) String() string dump like this .

#EXT-SCTE35:CUE="base64==",ID="identify",TIME=30
#EXT-X-KEY:METHOD=,URI="http://example.com/key",IV=iv
#EXT-X-DISCONTINUITY
#EXT-X-MAP:URI="http;//url",BYTERANGE=10@0
#EXT-X-BYTERANGE:10@0
#EXTINF:10.000,hogehoge
http://example.com/media.ts

I suppose it is not so a lot.

keizo042 avatar Nov 15 '17 03:11 keizo042

That looks good to me.

bradleyfalzon avatar Nov 15 '17 03:11 bradleyfalzon

@grafov thoughts?

bradleyfalzon avatar Nov 15 '17 03:11 bradleyfalzon

@bradleyfalzon I think it is ok to implement such method. @keizo042 would you create PR?

grafov avatar Nov 15 '17 21:11 grafov