Nagram/TMessagesProj/jni/voip/tgcalls/VideoCaptureInterfaceImpl.h

62 lines
2.1 KiB
C
Raw Normal View History

2020-08-14 16:58:22 +00:00
#ifndef TGCALLS_VIDEO_CAPTURE_INTERFACE_IMPL_H
#define TGCALLS_VIDEO_CAPTURE_INTERFACE_IMPL_H
#include "VideoCaptureInterface.h"
#include <memory>
#include "ThreadLocalObject.h"
#include "api/media_stream_interface.h"
#include "platform/PlatformInterface.h"
namespace tgcalls {
class VideoCapturerInterface;
class VideoCaptureInterfaceObject {
public:
2020-10-01 01:59:32 +00:00
VideoCaptureInterfaceObject(std::string deviceId, std::shared_ptr<PlatformContext> platformContext);
2020-08-14 16:58:22 +00:00
~VideoCaptureInterfaceObject();
2020-10-01 01:59:32 +00:00
void switchToDevice(std::string deviceId);
2020-08-14 16:58:22 +00:00
void setState(VideoState state);
void setPreferredAspectRatio(float aspectRatio);
void setOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink);
void setStateUpdated(std::function<void(VideoState)> stateUpdated);
2020-10-01 01:59:32 +00:00
webrtc::VideoTrackSourceInterface *source();
2020-08-14 16:58:22 +00:00
private:
2020-10-01 01:59:32 +00:00
void updateAspectRateAdaptation();
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> _videoSource;
2020-08-14 16:58:22 +00:00
std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> _currentUncroppedSink;
std::shared_ptr<PlatformContext> _platformContext;
2020-08-15 21:06:36 +00:00
std::pair<int, int> _videoCapturerResolution;
2020-08-14 16:58:22 +00:00
std::unique_ptr<VideoCapturerInterface> _videoCapturer;
std::function<void(VideoState)> _stateUpdated;
VideoState _state = VideoState::Active;
2020-10-01 01:59:32 +00:00
float _preferredAspectRatio = 0.0f;
bool _shouldBeAdaptedToReceiverAspectRate = true;
2020-08-14 16:58:22 +00:00
};
class VideoCaptureInterfaceImpl : public VideoCaptureInterface {
public:
2020-10-01 01:59:32 +00:00
VideoCaptureInterfaceImpl(std::string deviceId, std::shared_ptr<PlatformContext> platformContext);
2020-08-14 16:58:22 +00:00
virtual ~VideoCaptureInterfaceImpl();
2020-10-01 01:59:32 +00:00
void switchToDevice(std::string deviceId) override;
2020-08-14 16:58:22 +00:00
void setState(VideoState state) override;
void setPreferredAspectRatio(float aspectRatio) override;
void setOutput(std::shared_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink) override;
2020-08-21 23:59:49 +00:00
std::shared_ptr<PlatformContext> getPlatformContext() override;
2020-08-14 16:58:22 +00:00
ThreadLocalObject<VideoCaptureInterfaceObject> *object();
private:
ThreadLocalObject<VideoCaptureInterfaceObject> _impl;
2020-08-21 23:59:49 +00:00
std::shared_ptr<PlatformContext> _platformContext;
2020-08-14 16:58:22 +00:00
};
} // namespace tgcalls
#endif