mirror of
				https://github.com/pion/webrtc.git
				synced 2025-10-31 10:46:39 +08:00 
			
		
		
		
	 5655d151b1
			
		
	
	5655d151b1
	
	
	
		
			
			This will be returned by Unmarhsal when an unknown type is seen in the packet stream, avoiding an error and allowing the user to write their own packet handling code for that type if desired. Relates to #119
		
			
				
	
	
		
			45 lines
		
	
	
		
			906 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			906 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package rtcp
 | |
| 
 | |
| // Packet represents an RTCP packet, a protocol used for out-of-band statistics and control information for an RTP session
 | |
| type Packet interface {
 | |
| 	Marshal() ([]byte, error)
 | |
| 	Unmarshal(rawPacket []byte) error
 | |
| }
 | |
| 
 | |
| // Unmarshal is a factory a polymorphic RTCP packet, and its header,
 | |
| func Unmarshal(rawPacket []byte) (Packet, Header, error) {
 | |
| 	var h Header
 | |
| 	var p Packet
 | |
| 
 | |
| 	err := h.Unmarshal(rawPacket)
 | |
| 	if err != nil {
 | |
| 		return nil, h, err
 | |
| 	}
 | |
| 
 | |
| 	switch h.Type {
 | |
| 	case TypeSenderReport:
 | |
| 		p = new(SenderReport)
 | |
| 
 | |
| 	case TypeReceiverReport:
 | |
| 		p = new(ReceiverReport)
 | |
| 
 | |
| 	case TypeSourceDescription:
 | |
| 		p = new(SourceDescription)
 | |
| 
 | |
| 	case TypeGoodbye:
 | |
| 		p = new(Goodbye)
 | |
| 
 | |
| 	case TypeTransportSpecificFeedback:
 | |
| 		p = new(RapidResynchronizationRequest)
 | |
| 
 | |
| 	case TypePayloadSpecificFeedback:
 | |
| 		p = new(PictureLossIndication)
 | |
| 
 | |
| 	default:
 | |
| 		p = new(RawPacket)
 | |
| 	}
 | |
| 
 | |
| 	err = p.Unmarshal(rawPacket)
 | |
| 	return p, h, err
 | |
| }
 |