mirror of https://bitbucket.org/ausocean/av.git
Just cleaning stuff up before testing
This commit is contained in:
parent
bfb31136c8
commit
57d416563a
|
@ -32,7 +32,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
|
||||
/*
|
||||
// Test revidInst with a file input
|
||||
func TestFileInput(t *testing.T){
|
||||
config := Config{
|
||||
|
@ -166,3 +166,25 @@ func TestRtmpOutputUsingLibRtmp(t *testing.T){
|
|||
time.Sleep(120*time.Second)
|
||||
revidInst.Stop()
|
||||
}
|
||||
*/
|
||||
|
||||
// Test revidInst with a Raspivid h264 input
|
||||
func TestRaspividToRtmp(t *testing.T){
|
||||
config := Config{
|
||||
Input: Raspivid,
|
||||
Output: Rtmp,
|
||||
RtmpMethod: LibRtmp,
|
||||
RtmpUrl: "rtmp://a.rtmp.youtube.com/live2/w44c-mkuu-aezg-ceb1",
|
||||
FramesPerClip: 1,
|
||||
Packetization: Flv,
|
||||
FrameRate: "25",
|
||||
}
|
||||
revidInst, err := NewRevidInstance(config)
|
||||
if err != nil {
|
||||
t.Errorf("Should not have got an error!")
|
||||
return
|
||||
}
|
||||
revidInst.Start()
|
||||
time.Sleep(120*time.Second)
|
||||
revidInst.Stop()
|
||||
}
|
||||
|
|
16
rtmp/RTMP.go
16
rtmp/RTMP.go
|
@ -1,16 +1,15 @@
|
|||
/*
|
||||
NAME
|
||||
RtpToTsConverter.go - provides utilities for the conversion of Rtp packets
|
||||
to equivalent MpegTs packets.
|
||||
RTMP.go
|
||||
|
||||
DESCRIPTION
|
||||
See Readme.md
|
||||
|
||||
AUTHOR
|
||||
Saxon Nelson-Milton <saxon.milton@gmail.com>
|
||||
Saxon Nelson-Milton <saxon@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
RtpToTsConverter.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
||||
RTMP.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
||||
|
||||
It is free software: you can redistribute it and/or modify them
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
@ -41,12 +40,14 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
// RTMPSession provides a crude interface for sending flv tags over rtmp
|
||||
type RTMPSession interface {
|
||||
StartSession() error
|
||||
WriteFrame(data []byte, dataLength uint) error
|
||||
EndSession() error
|
||||
}
|
||||
|
||||
// rtmpSession provides parameters required for an rtmp communication session
|
||||
type rtmpSession struct {
|
||||
url string
|
||||
timeout uint
|
||||
|
@ -54,6 +55,7 @@ type rtmpSession struct {
|
|||
mutex *sync.Mutex
|
||||
}
|
||||
|
||||
// NewRTMPSession returns a new instance of an rtmpSession struct
|
||||
func NewRTMPSession(url string, connectTimeout uint) (session *rtmpSession){
|
||||
session = new(rtmpSession)
|
||||
session.url = url
|
||||
|
@ -62,6 +64,8 @@ func NewRTMPSession(url string, connectTimeout uint) (session *rtmpSession){
|
|||
return
|
||||
}
|
||||
|
||||
// StartSession establishes an rtmp connection with the url passed into the
|
||||
// constructor
|
||||
func (s *rtmpSession) StartSession() error {
|
||||
if !s.running {
|
||||
if !uintToBool(uint(C.RTMP_start_session(C.CString(s.url), C.uint(s.timeout)))) {
|
||||
|
@ -74,6 +78,7 @@ func (s *rtmpSession) StartSession() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// WriteFrame writes a frame (flv tag) to the rtmp connection
|
||||
// TODO: Remove mutex
|
||||
func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error {
|
||||
s.mutex.Lock()
|
||||
|
@ -90,6 +95,7 @@ func (s *rtmpSession) WriteFrame(data []byte, dataLength uint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// EndSession terminates the rtmp connection
|
||||
func (s *rtmpSession) EndSession() error {
|
||||
if s.running {
|
||||
if !uintToBool(uint(C.RTMP_end_session())) {
|
||||
|
@ -101,7 +107,7 @@ func (s *rtmpSession) EndSession() error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// uintToBool takes a uint and returns the bool equivalent
|
||||
func uintToBool(x uint) bool {
|
||||
return x != 0
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/*
|
||||
NAME
|
||||
RtpToTsConverter.go - provides utilities for the conversion of Rtp packets
|
||||
to equivalent MpegTs packets.
|
||||
RTMPWrapper.c
|
||||
|
||||
DESCRIPTION
|
||||
See Readme.md
|
||||
|
||||
AUTHOR
|
||||
Saxon Nelson-Milton <saxon.milton@gmail.com>
|
||||
Saxon Nelson-Milton <saxon@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
RtpToTsConverter.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
||||
RTMPWrapper.c is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
|
||||
|
||||
It is free software: you can redistribute it and/or modify them
|
||||
under the terms of the GNU General Public License as published by the
|
||||
|
|
Loading…
Reference in New Issue