Feature/ffmpeg video endpoint source#1694
Merged
Merged
Conversation
FFmpegVideoEndPoint was declared IVideoSink only, with the source/encode half left commented out - inconsistent with the other video endpoints (Vp8NetVideoEncoderEndPoint and WindowsVideoEndPoint), which implement both IVideoSource and IVideoSink so one class encodes outgoing and decodes incoming media for the same codec. This completes the source half: - declares IVideoSource as well as IVideoSink; - ExternalVideoSourceRawSample / ExternalVideoSourceRawSampleFaster now encode the supplied raw frame via the encoder's managed EncodeVideo / EncodeVideoFaster and raise OnVideoSourceEncodedSample (with a shared RaiseEncodedSample helper computing the RTP duration from the selected format's clock rate); - adds the source events (OnVideoSourceEncodedSample raised; the raw and error events are part of the contract but not produced by an encoder); - ForceKeyFrame now delegates to the encoder's own ForceKeyFrame (which the encode path honours) instead of a dead local flag; - HasEncodedVideoSubscribers reports OnVideoSourceEncodedSample subscribers (it previously, incorrectly, reported the sink event); - ToMediaEndPoints now exposes VideoSource = this. The single FFmpegVideoEncoder instance handles both directions (separate encode/decode contexts internally). The change is additive; existing sink-only consumers are unaffected. WebRTCDaemon already wires the endpoint's ExternalVideoSourceRawSample, confirming the intended usage. Builds across all target frameworks. Not unit-tested here as the encode path requires the native FFmpeg libraries at runtime. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…th the fixed FFmpegVideoEndPoint.
| _videoDecoder?.Pause(); | ||
| if (_videoDecoder != null) | ||
| { | ||
| _videoDecoder?.Pause(); |
|
|
||
| double firts_dpts = 0; | ||
| bool canContinue = true; | ||
| bool managePacket = true; |
| if (firts_dpts == 0) | ||
| firts_dpts = dpts; | ||
| dpts = _audioTimebase * avFrame->pts; | ||
| original_dpts = dpts; |
| if (ffmpeg.avformat_seek_file(_fmtCtx, _audioStreamIndex, 0, 0, _fmtCtx->streams[_audioStreamIndex]->duration, ffmpeg.AVSEEK_FLAG_ANY) < 0) | ||
| { | ||
| // We can't easily go back to the beginning of the file ... | ||
| canContinue = false; |
| } | ||
| catch { } | ||
| } | ||
| catch { } |
| } | ||
| catch { } | ||
| } | ||
| catch { } |
| private Task? _sourceTask; | ||
| private string _sourceUrl; | ||
| private bool _repeat; | ||
| private bool _isMicrophone; |
| public class FFmpegAudioDecoder : IDisposable | ||
| { | ||
| private ILogger logger = SIPSorcery.LogFactory.CreateLogger<FFmpegAudioDecoder>(); | ||
| private ILogger logger = SIPSorcery.LogFactory.CreateLogger<FFmpegAudioDecoder>(); |
| private ILogger logger = SIPSorcery.LogFactory.CreateLogger<FFmpegAudioDecoder>(); | ||
|
|
||
| unsafe private AVInputFormat* _inputFormat = null; | ||
| unsafe private AVInputFormat* _inputFormat = null; |
# Conflicts: # src/SIPSorceryMedia.FFmpeg/FFmpegAudioDecoder.cs # src/SIPSorceryMedia.FFmpeg/FFmpegFileSource.cs # src/SIPSorceryMedia.FFmpeg/FFmpegVideoEndPoint.cs
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.