github.com/pion/webrtc/v4@v4.0.1/pkg/media/media.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  // Package media provides media writer and filters
     5  package media
     6  
     7  import (
     8  	"time"
     9  
    10  	"github.com/pion/rtp"
    11  )
    12  
    13  // A Sample contains encoded media and timing information
    14  type Sample struct {
    15  	Data               []byte
    16  	Timestamp          time.Time
    17  	Duration           time.Duration
    18  	PacketTimestamp    uint32
    19  	PrevDroppedPackets uint16
    20  	Metadata           interface{}
    21  
    22  	// RTP headers of RTP packets forming this Sample. (Optional)
    23  	// Useful for accessing RTP extensions associated to the Sample.
    24  	RTPHeaders []*rtp.Header
    25  }
    26  
    27  // Writer defines an interface to handle
    28  // the creation of media files
    29  type Writer interface {
    30  	// Add the content of an RTP packet to the media
    31  	WriteRTP(packet *rtp.Packet) error
    32  	// Close the media
    33  	// Note: Close implementation must be idempotent
    34  	Close() error
    35  }