summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/video/video_stream_decoder2.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /third_party/libwebrtc/video/video_stream_decoder2.cc
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/video/video_stream_decoder2.cc')
-rw-r--r--third_party/libwebrtc/video/video_stream_decoder2.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/third_party/libwebrtc/video/video_stream_decoder2.cc b/third_party/libwebrtc/video/video_stream_decoder2.cc
new file mode 100644
index 0000000000..1ef2d0ecd0
--- /dev/null
+++ b/third_party/libwebrtc/video/video_stream_decoder2.cc
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "video/video_stream_decoder2.h"
+
+#include "api/video_codecs/video_decoder.h"
+#include "modules/video_coding/video_receiver2.h"
+#include "rtc_base/checks.h"
+#include "video/receive_statistics_proxy2.h"
+
+namespace webrtc {
+namespace internal {
+
+VideoStreamDecoder::VideoStreamDecoder(
+ VideoReceiver2* video_receiver,
+ ReceiveStatisticsProxy* receive_statistics_proxy,
+ rtc::VideoSinkInterface<VideoFrame>* incoming_video_stream)
+ : video_receiver_(video_receiver),
+ receive_stats_callback_(receive_statistics_proxy),
+ incoming_video_stream_(incoming_video_stream) {
+ RTC_DCHECK(video_receiver_);
+
+ video_receiver_->RegisterReceiveCallback(this);
+}
+
+VideoStreamDecoder::~VideoStreamDecoder() {
+ // Note: There's an assumption at this point that the decoder thread is
+ // *not* running. If it was, then there could be a race for each of these
+ // callbacks.
+
+ // Unset all the callback pointers that we set in the ctor.
+ video_receiver_->RegisterReceiveCallback(nullptr);
+}
+
+// Do not acquire the lock of `video_receiver_` in this function. Decode
+// callback won't necessarily be called from the decoding thread. The decoding
+// thread may have held the lock when calling VideoDecoder::Decode, Reset, or
+// Release. Acquiring the same lock in the path of decode callback can deadlock.
+int32_t VideoStreamDecoder::FrameToRender(VideoFrame& video_frame,
+ absl::optional<uint8_t> qp,
+ TimeDelta decode_time,
+ VideoContentType content_type) {
+ receive_stats_callback_->OnDecodedFrame(video_frame, qp, decode_time,
+ content_type);
+ incoming_video_stream_->OnFrame(video_frame);
+ return 0;
+}
+
+void VideoStreamDecoder::OnDroppedFrames(uint32_t frames_dropped) {
+ receive_stats_callback_->OnDroppedFrames(frames_dropped);
+}
+
+void VideoStreamDecoder::OnIncomingPayloadType(int payload_type) {
+ receive_stats_callback_->OnIncomingPayloadType(payload_type);
+}
+
+void VideoStreamDecoder::OnDecoderInfoChanged(
+ const VideoDecoder::DecoderInfo& decoder_info) {
+ receive_stats_callback_->OnDecoderInfo(decoder_info);
+}
+
+} // namespace internal
+} // namespace webrtc