mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-15 14:50:39 +01:00

This cl move VideoEncoderConfig from api/ to video/config. VideoStreamEncoderInterface and VideoStreamEncoderObserver are moved as collateral. brandt@ think that the reason these were in api/ in the first place had to downstream project. Functionality wise, this is a NOP, but it makes it easier to modify the encoder (config). Bug: webrtc:14451 Change-Id: I2610d815aeb186298498e7102cac773ecac8cd36 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/277002 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38242}
92 lines
3 KiB
C++
92 lines
3 KiB
C++
/*
|
|
* Copyright 2018 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 <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "api/video/video_frame.h"
|
|
#include "api/video/video_sink_interface.h"
|
|
#include "call/rtp_config.h"
|
|
#include "call/video_receive_stream.h"
|
|
#include "call/video_send_stream.h"
|
|
#include "rtc_base/event.h"
|
|
#include "test/frame_generator_capturer.h"
|
|
#include "test/gtest.h"
|
|
#include "video/config/video_encoder_config.h"
|
|
#include "video/end_to_end_tests/multi_stream_tester.h"
|
|
|
|
namespace webrtc {
|
|
// Each renderer verifies that it receives the expected resolution, and as soon
|
|
// as every renderer has received a frame, the test finishes.
|
|
TEST(MultiStreamEndToEndTest, SendsAndReceivesMultipleStreams) {
|
|
class VideoOutputObserver : public rtc::VideoSinkInterface<VideoFrame> {
|
|
public:
|
|
VideoOutputObserver(const MultiStreamTester::CodecSettings& settings,
|
|
uint32_t ssrc,
|
|
test::FrameGeneratorCapturer** frame_generator)
|
|
: settings_(settings), ssrc_(ssrc), frame_generator_(frame_generator) {}
|
|
|
|
void OnFrame(const VideoFrame& video_frame) override {
|
|
EXPECT_EQ(settings_.width, video_frame.width());
|
|
EXPECT_EQ(settings_.height, video_frame.height());
|
|
(*frame_generator_)->Stop();
|
|
done_.Set();
|
|
}
|
|
|
|
uint32_t Ssrc() { return ssrc_; }
|
|
|
|
bool Wait() { return done_.Wait(TimeDelta::Seconds(30)); }
|
|
|
|
private:
|
|
const MultiStreamTester::CodecSettings& settings_;
|
|
const uint32_t ssrc_;
|
|
test::FrameGeneratorCapturer** const frame_generator_;
|
|
rtc::Event done_;
|
|
};
|
|
|
|
class Tester : public MultiStreamTester {
|
|
public:
|
|
Tester() = default;
|
|
~Tester() override = default;
|
|
|
|
protected:
|
|
void Wait() override {
|
|
for (const auto& observer : observers_) {
|
|
EXPECT_TRUE(observer->Wait())
|
|
<< "Time out waiting for from on ssrc " << observer->Ssrc();
|
|
}
|
|
}
|
|
|
|
void UpdateSendConfig(
|
|
size_t stream_index,
|
|
VideoSendStream::Config* send_config,
|
|
VideoEncoderConfig* encoder_config,
|
|
test::FrameGeneratorCapturer** frame_generator) override {
|
|
observers_[stream_index] = std::make_unique<VideoOutputObserver>(
|
|
codec_settings[stream_index], send_config->rtp.ssrcs.front(),
|
|
frame_generator);
|
|
}
|
|
|
|
void UpdateReceiveConfig(
|
|
size_t stream_index,
|
|
VideoReceiveStreamInterface::Config* receive_config) override {
|
|
receive_config->renderer = observers_[stream_index].get();
|
|
}
|
|
|
|
private:
|
|
std::unique_ptr<VideoOutputObserver> observers_[kNumStreams];
|
|
} tester;
|
|
|
|
tester.RunTest();
|
|
}
|
|
} // namespace webrtc
|