Index: webrtc/video/video_send_stream.cc |
diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc |
index 2f8241e28ed1c6b0e273d982a83ef09a0ce35f1f..3a4f1e01dee3376fa7ee900ba447036d0055b454 100644 |
--- a/webrtc/video/video_send_stream.cc |
+++ b/webrtc/video/video_send_stream.cc |
@@ -16,6 +16,7 @@ |
#include <vector> |
#include "webrtc/base/checks.h" |
+#include "webrtc/base/file.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/base/trace_event.h" |
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
@@ -267,6 +268,10 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, |
void SignalEncoderConfigurationChanged(const VideoEncoderConfig& config); |
VideoSendStream::RtpStateMap GetRtpStates() const; |
+ void SetLogFiles(rtc::PlatformFile file1 = rtc::kInvalidPlatformFileValue, |
+ rtc::PlatformFile file2 = rtc::kInvalidPlatformFileValue, |
+ rtc::PlatformFile file3 = rtc::kInvalidPlatformFileValue); |
+ |
private: |
class CheckEncoderActivityTask; |
@@ -311,9 +316,10 @@ class VideoSendStreamImpl : public webrtc::BitrateAllocatorObserver, |
BitrateAllocator* const bitrate_allocator_; |
VieRemb* const remb_; |
- static const bool kEnableFrameRecording = false; |
+ rtc::CriticalSection ivf_writers_crit_; |
static const int kMaxLayers = 3; |
- std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers]; |
+ std::unique_ptr<IvfFileWriter> file_writers_[kMaxLayers] GUARDED_BY( |
+ ivf_writers_crit_); |
int max_padding_bitrate_; |
int encoder_min_bitrate_bps_; |
@@ -598,6 +604,12 @@ bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
return send_stream_->DeliverRtcp(packet, length); |
} |
+void VideoSendStream::SetLogFiles(rtc::PlatformFile file1, |
+ rtc::PlatformFile file2, |
+ rtc::PlatformFile file3) { |
+ send_stream_->SetLogFiles(file1, file2, file3); |
+} |
+ |
VideoSendStreamImpl::VideoSendStreamImpl( |
SendStatisticsProxy* stats_proxy, |
rtc::TaskQueue* worker_queue, |
@@ -864,25 +876,16 @@ EncodedImageCallback::Result VideoSendStreamImpl::OnEncodedImage( |
EncodedImageCallback::Result result = payload_router_.OnEncodedImage( |
encoded_image, codec_specific_info, fragmentation); |
- if (kEnableFrameRecording) { |
- int layer = codec_specific_info->codecType == kVideoCodecVP8 |
- ? codec_specific_info->codecSpecific.VP8.simulcastIdx |
- : 0; |
- IvfFileWriter* file_writer; |
- { |
- if (file_writers_[layer] == nullptr) { |
- std::ostringstream oss; |
- oss << "send_bitstream_ssrc"; |
- for (uint32_t ssrc : config_->rtp.ssrcs) |
- oss << "_" << ssrc; |
- oss << "_layer" << layer << ".ivf"; |
- file_writers_[layer] = |
- IvfFileWriter::Open(oss.str(), codec_specific_info->codecType); |
- } |
- file_writer = file_writers_[layer].get(); |
- } |
- if (file_writer) { |
- bool ok = file_writer->WriteFrame(encoded_image); |
+ RTC_DCHECK(codec_specific_info); |
+ |
+ int layer = codec_specific_info->codecType == kVideoCodecVP8 |
+ ? codec_specific_info->codecSpecific.VP8.simulcastIdx |
+ : 0; |
+ { |
+ rtc::CritScope lock(&ivf_writers_crit_); |
+ if (file_writers_[layer].get()) { |
+ bool ok = file_writers_[layer]->WriteFrame( |
+ encoded_image, codec_specific_info->codecType); |
RTC_DCHECK(ok); |
} |
} |
@@ -1037,6 +1040,37 @@ uint32_t VideoSendStreamImpl::OnBitrateUpdated(uint32_t bitrate_bps, |
return protection_bitrate; |
} |
+void VideoSendStreamImpl::SetLogFiles(rtc::PlatformFile file1, |
+ rtc::PlatformFile file2, |
+ rtc::PlatformFile file3) { |
+ { |
+ rtc::CritScope lock(&ivf_writers_crit_); |
+ if (file1 == rtc::kInvalidPlatformFileValue) { |
+ file_writers_[0].reset(); |
+ } else { |
+ file_writers_[0] = IvfFileWriter::Wrap(rtc::File(file1)); |
+ } |
+ |
+ if (file2 == rtc::kInvalidPlatformFileValue) { |
+ file_writers_[1].reset(); |
+ } else { |
+ file_writers_[1] = IvfFileWriter::Wrap(rtc::File(file2)); |
+ } |
+ |
+ if (file3 == rtc::kInvalidPlatformFileValue) { |
+ file_writers_[2].reset(); |
+ } else { |
+ file_writers_[2] = IvfFileWriter::Wrap(rtc::File(file3)); |
+ } |
+ } |
+ |
+ if (file1 != rtc::kInvalidPlatformFileValue || |
+ file2 != rtc::kInvalidPlatformFileValue || |
+ file3 != rtc::kInvalidPlatformFileValue) { |
+ vie_encoder_->SendKeyFrame(); |
+ } |
+} |
+ |
int VideoSendStreamImpl::ProtectionRequest( |
const FecProtectionParams* delta_params, |
const FecProtectionParams* key_params, |