Skip to content

Commit db245f2

Browse files
authored
Gstreamer AppSource Implementation for AV playback on the desktop (#36)
* extract video pipeline into separate method, run go fmt * added an example of a failure * use a waveparser, works with an oggmux, just not hearing anything with an audiosink * added vorbis hack, and now it works * added queues to the video pipeline * works * use vtdec to bring down cpu usage * add comments * add fix for NSThread mainloop problem * minor clean ups, add mac os only compile flag * minor clean ups, add mac os only compile flag * add linux adapter * set sync to false for faster playback * minor fixes
1 parent 60a9d7b commit db245f2

File tree

8 files changed

+490
-126
lines changed

8 files changed

+490
-126
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
99
github.com/google/gousb v0.0.0-20190812193832-18f4c1d8a750
1010
github.com/lijo-jose/glib v0.0.0-20191012030101-93ee72d7d646
11+
github.com/lijo-jose/gst v0.0.0-20191012030143-e3a5557394c7
1112
github.com/pion/rtp v1.1.4
1213
github.com/pion/webrtc/v2 v2.1.11
1314
github.com/sirupsen/logrus v1.4.2

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
2323
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
2424
github.com/lijo-jose/glib v0.0.0-20191012030101-93ee72d7d646 h1:7I8sylThkL59rDoHMANuIxtB490DvrLAIZosNY9fDMM=
2525
github.com/lijo-jose/glib v0.0.0-20191012030101-93ee72d7d646/go.mod h1:wzypjnJX+g/LKnKDVvJni/u0gNlQestTwv6Kt/Qf3fk=
26+
github.com/lijo-jose/gst v0.0.0-20191012030143-e3a5557394c7 h1:ZrDIsE60UtVmeYnTVzcarL+pCmk9KFoQebBDzyMm71o=
27+
github.com/lijo-jose/gst v0.0.0-20191012030143-e3a5557394c7/go.mod h1:CAqd8DUUbXc086paYmyPzUF0K42o6tFpIzoelwMioEI=
2628
github.com/lucas-clemente/quic-go v0.7.1-0.20190401152353-907071221cf9/go.mod h1:PpMmPfPKO9nKJ/psF49ESTAGQSdfXxlg1otPbEB2nOw=
2729
github.com/marten-seemann/qtls v0.2.3/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
2830
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

qvh

-3.6 MB
Binary file not shown.

screencapture/coremedia/wav_format.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,34 @@ func writeWavDataSubChunkHeader(target *bytes.Buffer, dataLength int) error {
113113
//WriteWavHeader creates a wave file header using the given length and writes it at the BEGINNING of the wavFile.
114114
//Please make sure that the file has enough zero bytes before the audio data.
115115
func WriteWavHeader(length int, wavFile *os.File) error {
116+
headerBytes, err := GetWavHeaderBytes(length)
117+
if err != nil {
118+
return err
119+
}
120+
_, err = wavFile.WriteAt(headerBytes, 0)
121+
return err
122+
}
123+
124+
//GetWavHeaderBytes creates a byte slice containing a valid wav header using the supplied length.
125+
func GetWavHeaderBytes(length int) ([]byte, error) {
116126
buffer := bytes.NewBuffer(make([]byte, 100))
117127
buffer.Reset()
118128

119129
riffHeader := newRiffHeader(length)
120130
err := riffHeader.serialize(buffer)
121131
if err != nil {
122-
return err
132+
return nil, err
123133
}
124134

125135
fmtSubChunk := newFmtSubChunk()
126136
err = fmtSubChunk.serialize(buffer)
127137
if err != nil {
128-
return err
138+
return nil, err
129139
}
130140

131141
err = writeWavDataSubChunkHeader(buffer, length)
132142
if err != nil {
133-
return err
143+
return nil, err
134144
}
135-
_, err = wavFile.WriteAt(buffer.Bytes(), 0)
136-
return err
145+
return buffer.Bytes(), nil
137146
}

screencapture/frameextractor.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ func (fe *LengthFieldBasedFrameExtractor) ExtractFrame(bytes []byte) ([]byte, bo
3232
return fe.handleNewFrame(bytes)
3333
}
3434
if fe.readyForNextFrame && fe.frameBuffer.Len() != 0 {
35-
if fe.frameBuffer.Len()<4{
36-
log.Fatal("wtf:"+hex.Dump(fe.frameBuffer.Bytes()))
35+
if fe.frameBuffer.Len() < 4 {
36+
/* examples:
37+
FATA[0032] wtf:00000000 ac 10 |..|
38+
*/
39+
/*
40+
{"level":"fatal","msg":"wtf:00000000 ac |.|\n","time":"2019-11-18T12:09:10+01:00"}
41+
*/
42+
/*
43+
{"level":"fatal","msg":"wtf:00000000 ac 10 00 |...|\n","time":"2019-11-18T12:12:11+01:00"}
44+
*/
45+
log.Fatal("wtf:" + hex.Dump(fe.frameBuffer.Bytes()))
3746
}
3847
fe.nextFrameSize = int(binary.LittleEndian.Uint32(fe.frameBuffer.Next(4))) - 4
3948
fe.readyForNextFrame = false

screencapture/gstadapter/gst_adapter.go

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)