RegisterCodec adds codec to the MediaEngine These are the list of codecs supported by this PeerConnection.
(codec RTPCodecParameters, typ RTPCodecType)
| 255 | // RegisterCodec adds codec to the MediaEngine |
| 256 | // These are the list of codecs supported by this PeerConnection. |
| 257 | func (m *MediaEngine) RegisterCodec(codec RTPCodecParameters, typ RTPCodecType) error { |
| 258 | m.mu.Lock() |
| 259 | defer m.mu.Unlock() |
| 260 | |
| 261 | var err error |
| 262 | codec.statsID = fmt.Sprintf("RTPCodec-%d", time.Now().UnixNano()) |
| 263 | switch typ { |
| 264 | case RTPCodecTypeAudio: |
| 265 | m.audioCodecs, err = m.addCodec(m.audioCodecs, codec) |
| 266 | case RTPCodecTypeVideo: |
| 267 | m.videoCodecs, err = m.addCodec(m.videoCodecs, codec) |
| 268 | default: |
| 269 | return ErrUnknownType |
| 270 | } |
| 271 | |
| 272 | return err |
| 273 | } |
| 274 | |
| 275 | // RegisterHeaderExtension adds a header extension to the MediaEngine |
| 276 | // To determine the negotiated value use `GetHeaderExtensionID` after signaling is complete. |