summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc')
-rw-r--r--third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc44
1 files changed, 37 insertions, 7 deletions
diff --git a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc
index 0f85216e92..2eea0d2387 100644
--- a/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc
+++ b/third_party/libwebrtc/audio/channel_send_frame_transformer_delegate.cc
@@ -11,6 +11,7 @@
#include "audio/channel_send_frame_transformer_delegate.h"
#include <utility>
+#include <vector>
namespace webrtc {
namespace {
@@ -55,13 +56,17 @@ class TransformableOutgoingAudioFrame
const uint8_t* payload_data,
size_t payload_size,
absl::optional<uint64_t> absolute_capture_timestamp_ms,
- uint32_t ssrc)
+ uint32_t ssrc,
+ std::vector<uint32_t> csrcs,
+ const std::string& codec_mime_type)
: frame_type_(frame_type),
payload_type_(payload_type),
rtp_timestamp_with_offset_(rtp_timestamp_with_offset),
payload_(payload_data, payload_size),
absolute_capture_timestamp_ms_(absolute_capture_timestamp_ms),
- ssrc_(ssrc) {}
+ ssrc_(ssrc),
+ csrcs_(std::move(csrcs)),
+ codec_mime_type_(codec_mime_type) {}
~TransformableOutgoingAudioFrame() override = default;
rtc::ArrayView<const uint8_t> GetData() const override { return payload_; }
void SetData(rtc::ArrayView<const uint8_t> data) override {
@@ -76,9 +81,10 @@ class TransformableOutgoingAudioFrame
uint8_t GetPayloadType() const override { return payload_type_; }
Direction GetDirection() const override { return Direction::kSender; }
+ std::string GetMimeType() const override { return codec_mime_type_; }
rtc::ArrayView<const uint32_t> GetContributingSources() const override {
- return {};
+ return csrcs_;
}
const absl::optional<uint16_t> SequenceNumber() const override {
@@ -100,6 +106,8 @@ class TransformableOutgoingAudioFrame
rtc::Buffer payload_;
absl::optional<uint64_t> absolute_capture_timestamp_ms_;
uint32_t ssrc_;
+ std::vector<uint32_t> csrcs_;
+ std::string codec_mime_type_;
};
} // namespace
@@ -131,11 +139,23 @@ void ChannelSendFrameTransformerDelegate::Transform(
const uint8_t* payload_data,
size_t payload_size,
int64_t absolute_capture_timestamp_ms,
- uint32_t ssrc) {
+ uint32_t ssrc,
+ const std::string& codec_mimetype) {
+ {
+ MutexLock lock(&send_lock_);
+ if (short_circuit_) {
+ send_frame_callback_(
+ frame_type, payload_type, rtp_timestamp,
+ rtc::ArrayView<const uint8_t>(payload_data, payload_size),
+ absolute_capture_timestamp_ms, /*csrcs=*/{});
+ return;
+ }
+ }
frame_transformer_->Transform(
std::make_unique<TransformableOutgoingAudioFrame>(
frame_type, payload_type, rtp_timestamp, payload_data, payload_size,
- absolute_capture_timestamp_ms, ssrc));
+ absolute_capture_timestamp_ms, ssrc,
+ /*csrcs=*/std::vector<uint32_t>(), codec_mimetype));
}
void ChannelSendFrameTransformerDelegate::OnTransformedFrame(
@@ -150,6 +170,11 @@ void ChannelSendFrameTransformerDelegate::OnTransformedFrame(
});
}
+void ChannelSendFrameTransformerDelegate::StartShortCircuiting() {
+ MutexLock lock(&send_lock_);
+ short_circuit_ = true;
+}
+
void ChannelSendFrameTransformerDelegate::SendFrame(
std::unique_ptr<TransformableFrameInterface> frame) const {
MutexLock lock(&send_lock_);
@@ -164,16 +189,21 @@ void ChannelSendFrameTransformerDelegate::SendFrame(
transformed_frame->GetData(),
transformed_frame->AbsoluteCaptureTimestamp()
? *transformed_frame->AbsoluteCaptureTimestamp()
- : 0);
+ : 0,
+ transformed_frame->GetContributingSources());
}
std::unique_ptr<TransformableAudioFrameInterface> CloneSenderAudioFrame(
TransformableAudioFrameInterface* original) {
+ std::vector<uint32_t> csrcs;
+ csrcs.assign(original->GetContributingSources().begin(),
+ original->GetContributingSources().end());
return std::make_unique<TransformableOutgoingAudioFrame>(
InterfaceFrameTypeToInternalFrameType(original->Type()),
original->GetPayloadType(), original->GetTimestamp(),
original->GetData().data(), original->GetData().size(),
- original->AbsoluteCaptureTimestamp(), original->GetSsrc());
+ original->AbsoluteCaptureTimestamp(), original->GetSsrc(),
+ std::move(csrcs), original->GetMimeType());
}
} // namespace webrtc