2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2010 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef MEDIA_ENGINE_FAKE_WEBRTC_VIDEO_ENGINE_H_
|
|
|
|
|
#define MEDIA_ENGINE_FAKE_WEBRTC_VIDEO_ENGINE_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
#include <memory>
|
2017-04-05 03:02:20 -07:00
|
|
|
#include <string>
|
2018-05-03 11:28:29 +02:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-06-28 15:19:43 +02:00
|
|
|
#include "api/fec_controller_override.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "api/video/encoded_image.h"
|
|
|
|
|
#include "api/video/video_bitrate_allocation.h"
|
|
|
|
|
#include "api/video/video_frame.h"
|
|
|
|
|
#include "api/video_codecs/sdp_video_format.h"
|
|
|
|
|
#include "api/video_codecs/video_codec.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video_codecs/video_decoder.h"
|
2018-05-03 11:28:29 +02:00
|
|
|
#include "api/video_codecs/video_decoder_factory.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
2018-05-03 11:28:29 +02:00
|
|
|
#include "api/video_codecs/video_encoder_factory.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "modules/video_coding/include/video_codec_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/critical_section.h"
|
2018-05-03 11:28:29 +02:00
|
|
|
#include "rtc_base/event.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace cricket {
|
2018-05-03 11:28:29 +02:00
|
|
|
|
|
|
|
|
class FakeWebRtcVideoDecoderFactory;
|
|
|
|
|
class FakeWebRtcVideoEncoderFactory;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Fake class for mocking out webrtc::VideoDecoder
|
|
|
|
|
class FakeWebRtcVideoDecoder : public webrtc::VideoDecoder {
|
|
|
|
|
public:
|
2018-05-03 11:28:29 +02:00
|
|
|
explicit FakeWebRtcVideoDecoder(FakeWebRtcVideoDecoderFactory* factory);
|
|
|
|
|
~FakeWebRtcVideoDecoder();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-05-14 09:48:06 +02:00
|
|
|
int32_t InitDecode(const webrtc::VideoCodec*, int32_t) override;
|
|
|
|
|
int32_t Decode(const webrtc::EncodedImage&, bool, int64_t) override;
|
|
|
|
|
int32_t RegisterDecodeCompleteCallback(
|
|
|
|
|
webrtc::DecodedImageCallback*) override;
|
|
|
|
|
int32_t Release() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
int GetNumFramesReceived() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int num_frames_received_;
|
2018-05-03 11:28:29 +02:00
|
|
|
FakeWebRtcVideoDecoderFactory* factory_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
// Fake class for mocking out webrtc::VideoDecoderFactory.
|
|
|
|
|
class FakeWebRtcVideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2018-05-03 11:28:29 +02:00
|
|
|
FakeWebRtcVideoDecoderFactory();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
|
|
|
|
|
std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(
|
|
|
|
|
const webrtc::SdpVideoFormat& format) override;
|
2016-06-22 00:46:15 -07:00
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
void DecoderDestroyed(FakeWebRtcVideoDecoder* decoder);
|
|
|
|
|
void AddSupportedVideoCodecType(const webrtc::SdpVideoFormat& format);
|
|
|
|
|
int GetNumCreatedDecoders();
|
|
|
|
|
const std::vector<FakeWebRtcVideoDecoder*>& decoders();
|
2016-06-22 00:46:15 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private:
|
2018-05-03 11:28:29 +02:00
|
|
|
std::vector<webrtc::SdpVideoFormat> supported_codec_formats_;
|
2013-07-10 00:45:36 +00:00
|
|
|
std::vector<FakeWebRtcVideoDecoder*> decoders_;
|
|
|
|
|
int num_created_decoders_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Fake class for mocking out webrtc::VideoEnoder
|
|
|
|
|
class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder {
|
|
|
|
|
public:
|
2018-05-03 11:28:29 +02:00
|
|
|
explicit FakeWebRtcVideoEncoder(FakeWebRtcVideoEncoderFactory* factory);
|
|
|
|
|
~FakeWebRtcVideoEncoder();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-06-28 15:19:43 +02:00
|
|
|
void SetFecControllerOverride(
|
|
|
|
|
webrtc::FecControllerOverride* fec_controller_override) override;
|
2016-11-16 16:41:30 +01:00
|
|
|
int32_t InitEncode(const webrtc::VideoCodec* codecSettings,
|
2019-06-11 14:57:57 +02:00
|
|
|
const VideoEncoder::Settings& settings) override;
|
2019-03-07 10:18:23 +01:00
|
|
|
int32_t Encode(
|
|
|
|
|
const webrtc::VideoFrame& inputImage,
|
|
|
|
|
const std::vector<webrtc::VideoFrameType>* frame_types) override;
|
2016-11-16 16:41:30 +01:00
|
|
|
int32_t RegisterEncodeCompleteCallback(
|
2018-05-03 11:28:29 +02:00
|
|
|
webrtc::EncodedImageCallback* callback) override;
|
|
|
|
|
int32_t Release() override;
|
2019-04-12 13:59:09 +02:00
|
|
|
void SetRates(const RateControlParameters& parameters) override;
|
2019-01-15 12:42:18 +01:00
|
|
|
webrtc::VideoEncoder::EncoderInfo GetEncoderInfo() const override;
|
2014-10-14 04:25:33 +00:00
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
bool WaitForInitEncode();
|
|
|
|
|
webrtc::VideoCodec GetCodecSettings();
|
|
|
|
|
int GetNumEncodedFrames();
|
2014-10-14 04:25:33 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
rtc::CriticalSection crit_;
|
2016-04-20 06:35:56 -07:00
|
|
|
rtc::Event init_encode_event_;
|
2017-09-09 04:17:22 -07:00
|
|
|
int num_frames_encoded_ RTC_GUARDED_BY(crit_);
|
|
|
|
|
webrtc::VideoCodec codec_settings_ RTC_GUARDED_BY(crit_);
|
2018-05-03 11:28:29 +02:00
|
|
|
FakeWebRtcVideoEncoderFactory* factory_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2018-05-03 11:28:29 +02:00
|
|
|
// Fake class for mocking out webrtc::VideoEncoderFactory.
|
|
|
|
|
class FakeWebRtcVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2018-05-03 11:28:29 +02:00
|
|
|
FakeWebRtcVideoEncoderFactory();
|
|
|
|
|
|
|
|
|
|
std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
|
|
|
|
|
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(
|
|
|
|
|
const webrtc::SdpVideoFormat& format) override;
|
2018-12-10 09:47:34 +00:00
|
|
|
CodecInfo QueryVideoEncoder(
|
|
|
|
|
const webrtc::SdpVideoFormat& format) const override;
|
2018-05-03 11:28:29 +02:00
|
|
|
|
|
|
|
|
bool WaitForCreatedVideoEncoders(int num_encoders);
|
|
|
|
|
void EncoderDestroyed(FakeWebRtcVideoEncoder* encoder);
|
|
|
|
|
void set_encoders_have_internal_sources(bool internal_source);
|
|
|
|
|
void AddSupportedVideoCodec(const webrtc::SdpVideoFormat& format);
|
|
|
|
|
void AddSupportedVideoCodecType(const std::string& name);
|
|
|
|
|
int GetNumCreatedEncoders();
|
|
|
|
|
const std::vector<FakeWebRtcVideoEncoder*> encoders();
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
2016-04-20 06:35:56 -07:00
|
|
|
rtc::CriticalSection crit_;
|
|
|
|
|
rtc::Event created_video_encoder_event_;
|
2018-05-03 11:28:29 +02:00
|
|
|
std::vector<webrtc::SdpVideoFormat> formats_;
|
2017-09-09 04:17:22 -07:00
|
|
|
std::vector<FakeWebRtcVideoEncoder*> encoders_ RTC_GUARDED_BY(crit_);
|
|
|
|
|
int num_created_encoders_ RTC_GUARDED_BY(crit_);
|
2015-03-18 02:24:43 +00:00
|
|
|
bool encoders_have_internal_sources_;
|
2018-05-03 11:28:29 +02:00
|
|
|
bool vp8_factory_mode_;
|
2015-03-18 02:24:43 +00:00
|
|
|
};
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace cricket
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // MEDIA_ENGINE_FAKE_WEBRTC_VIDEO_ENGINE_H_
|