Add H264 send/receive and packetization support

This commit is contained in:
John Bradley
2018-07-05 16:39:38 -05:00
committed by John R. Bradley
parent dfd08a5ac4
commit cfba14cfea
5 changed files with 138 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ type TrackType int
const (
VP8 TrackType = iota + 1
VP9
H264
Opus
)
@@ -43,6 +44,8 @@ func (t TrackType) String() string {
return "VP8"
case VP9:
return "VP9"
case H264:
return "H264"
case Opus:
return "Opus"
default:
@@ -127,7 +130,7 @@ func (r *RTCPeerConnection) CreateAnswer() error {
// This function returns a channel to push buffers on, and an error if the channel can't be added
// Closing the channel ends this stream
func (r *RTCPeerConnection) AddTrack(mediaType TrackType, clockRate uint32) (samples chan<- RTCSample, err error) {
if mediaType != VP8 && mediaType != Opus {
if mediaType != VP8 && mediaType != H264 && mediaType != Opus {
panic("TODO Discarding packet, need media parsing")
}
@@ -202,6 +205,8 @@ func (r *RTCPeerConnection) generateChannel(ssrc uint32, payloadType uint8) (buf
codec = VP9
case "opus":
codec = Opus
case "H264":
codec = H264
default:
fmt.Printf("Codec %s in not supported by pion-WebRTC \n", codecStr)
return nil