Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: webrtc/video/end_to_end_tests.cc

Issue 2303273002: Expose Ivf logging through the native API (Closed)
Patch Set: Nit Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_encoder.cc ('k') | webrtc/video/screenshare_loopback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <algorithm> 10 #include <algorithm>
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/event.h" 21 #include "webrtc/base/event.h"
22 #include "webrtc/base/file.h"
22 #include "webrtc/base/optional.h" 23 #include "webrtc/base/optional.h"
23 #include "webrtc/base/rate_limiter.h" 24 #include "webrtc/base/rate_limiter.h"
24 #include "webrtc/call.h" 25 #include "webrtc/call.h"
25 #include "webrtc/call/transport_adapter.h" 26 #include "webrtc/call/transport_adapter.h"
26 #include "webrtc/common_video/include/frame_callback.h" 27 #include "webrtc/common_video/include/frame_callback.h"
27 #include "webrtc/modules/include/module_common_types.h" 28 #include "webrtc/modules/include/module_common_types.h"
28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
29 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 30 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
30 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" 31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h"
(...skipping 3711 matching lines...) Expand 10 before | Expand all | Expand 10 after
3743 3744
3744 private: 3745 private:
3745 bool video_observed_; 3746 bool video_observed_;
3746 bool audio_observed_; 3747 bool audio_observed_;
3747 SequenceNumberUnwrapper unwrapper_; 3748 SequenceNumberUnwrapper unwrapper_;
3748 std::set<int64_t> received_packet_ids_; 3749 std::set<int64_t> received_packet_ids_;
3749 } test; 3750 } test;
3750 3751
3751 RunBaseTest(&test); 3752 RunBaseTest(&test);
3752 } 3753 }
3754
3755 class EndToEndLogTest : public EndToEndTest {
3756 void SetUp() { paths_.clear(); }
3757 void TearDown() {
3758 for (const auto& path : paths_) {
3759 rtc::RemoveFile(path);
3760 }
3761 }
3762
3763 public:
3764 int AddFile() {
3765 paths_.push_back(test::TempFilename(test::OutputPath(), "test_file"));
3766 return static_cast<int>(paths_.size()) - 1;
3767 }
3768
3769 rtc::PlatformFile OpenFile(int idx) {
3770 return rtc::OpenPlatformFile(paths_[idx]);
3771 }
3772
3773 void LogSend(bool open) {
3774 if (open) {
3775 video_send_stream_->EnableEncodedFrameRecording(
3776 std::vector<rtc::PlatformFile>(1, OpenFile(AddFile())), 0);
3777 } else {
3778 video_send_stream_->DisableEncodedFrameRecording();
3779 }
3780 }
3781 void LogReceive(bool open) {
3782 if (open) {
3783 video_receive_streams_[0]->EnableEncodedFrameRecording(
3784 OpenFile(AddFile()), 0);
3785 } else {
3786 video_receive_streams_[0]->DisableEncodedFrameRecording();
3787 }
3788 }
3789
3790 std::vector<std::string> paths_;
3791 };
3792
3793 TEST_F(EndToEndLogTest, LogsEncodedFramesWhenRequested) {
3794 static const int kNumFramesToRecord = 10;
3795 class LogEncodingObserver : public test::EndToEndTest,
3796 public EncodedFrameObserver {
3797 public:
3798 explicit LogEncodingObserver(EndToEndLogTest* fixture)
3799 : EndToEndTest(kDefaultTimeoutMs),
3800 fixture_(fixture),
3801 recorded_frames_(0) {}
3802
3803 void PerformTest() override {
3804 fixture_->LogSend(true);
3805 fixture_->LogReceive(true);
3806 ASSERT_TRUE(Wait()) << "Timed out while waiting for frame logging.";
3807 }
3808
3809 void ModifyVideoConfigs(
3810 VideoSendStream::Config* send_config,
3811 std::vector<VideoReceiveStream::Config>* receive_configs,
3812 VideoEncoderConfig* encoder_config) override {
3813 encoder_.reset(VideoEncoder::Create(VideoEncoder::kVp8));
3814 decoder_.reset(VP8Decoder::Create());
3815
3816 send_config->post_encode_callback = this;
3817 send_config->encoder_settings.payload_name = "VP8";
3818 send_config->encoder_settings.encoder = encoder_.get();
3819
3820 (*receive_configs)[0].decoders.resize(1);
3821 (*receive_configs)[0].decoders[0].payload_type =
3822 send_config->encoder_settings.payload_type;
3823 (*receive_configs)[0].decoders[0].payload_name =
3824 send_config->encoder_settings.payload_name;
3825 (*receive_configs)[0].decoders[0].decoder = decoder_.get();
3826 }
3827
3828 void EncodedFrameCallback(const EncodedFrame& encoded_frame) override {
3829 rtc::CritScope lock(&crit_);
3830 if (recorded_frames_++ > kNumFramesToRecord) {
3831 fixture_->LogSend(false);
3832 fixture_->LogReceive(false);
3833 rtc::File send_file(fixture_->OpenFile(0));
3834 rtc::File receive_file(fixture_->OpenFile(1));
3835 uint8_t out[100];
3836 // If logging has worked correctly neither file should be empty, i.e.
3837 // we should be able to read something from them.
3838 EXPECT_LT(0u, send_file.Read(out, 100));
3839 EXPECT_LT(0u, receive_file.Read(out, 100));
3840 observation_complete_.Set();
3841 }
3842 }
3843
3844 private:
3845 EndToEndLogTest* const fixture_;
3846 std::unique_ptr<VideoEncoder> encoder_;
3847 std::unique_ptr<VideoDecoder> decoder_;
3848 rtc::CriticalSection crit_;
3849 int recorded_frames_ GUARDED_BY(crit_);
3850 } test(this);
3851
3852 RunBaseTest(&test);
3853 }
3854
3753 } // namespace webrtc 3855 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_encoder.cc ('k') | webrtc/video/screenshare_loopback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698