[*] 优化
This commit is contained in:
@@ -124,17 +124,22 @@ class VideoCapturer: public Capturer<acgist::TaoyaoVideoTrackSource> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// ================ Vulkan ================
|
// ================ Vulkan ================
|
||||||
|
// VK实例
|
||||||
VkInstance vkInstance = VK_NULL_HANDLE;
|
VkInstance vkInstance = VK_NULL_HANDLE;
|
||||||
|
// VK Surface
|
||||||
VkSurfaceKHR vkSurfaceKHR = VK_NULL_HANDLE;
|
VkSurfaceKHR vkSurfaceKHR = VK_NULL_HANDLE;
|
||||||
|
// VK应用
|
||||||
VkApplicationInfo vkApplicationInfo = {};
|
VkApplicationInfo vkApplicationInfo = {};
|
||||||
|
// VK实例配置
|
||||||
VkInstanceCreateInfo vkInstanceCreateInfo = {};
|
VkInstanceCreateInfo vkInstanceCreateInfo = {};
|
||||||
|
// VK Surface配置
|
||||||
VkSurfaceCreateInfoOHOS vkSurfaceCreateInfoOHOS = {};
|
VkSurfaceCreateInfoOHOS vkSurfaceCreateInfoOHOS = {};
|
||||||
// ================ OpenGL ES ================
|
// ================ OpenGL ES ================
|
||||||
// SurfaceId
|
// OpenGL ES SurfaceId
|
||||||
uint64_t surfaceId = 0;
|
uint64_t surfaceId = 0;
|
||||||
// OpenGL纹理指针
|
// OpenGL ES纹理指针
|
||||||
GLuint textureId = 0;
|
GLuint textureId = 0;
|
||||||
// OpenGL纹理数量
|
// OpenGL ES纹理数量
|
||||||
GLsizei textureSize = 1;
|
GLsizei textureSize = 1;
|
||||||
// EGL显示设备
|
// EGL显示设备
|
||||||
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
|
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
|
||||||
@@ -167,9 +172,13 @@ public:
|
|||||||
virtual ~VideoCapturer() override;
|
virtual ~VideoCapturer() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// 加载VK
|
||||||
void initVulkan();
|
void initVulkan();
|
||||||
|
// 释放VK
|
||||||
void releaseVulkan();
|
void releaseVulkan();
|
||||||
|
// 加载OpenGL ES
|
||||||
void initOpenGLES();
|
void initOpenGLES();
|
||||||
|
// 释放OpenGL ES
|
||||||
void releaseOpenGLES();
|
void releaseOpenGLES();
|
||||||
virtual bool start() override;
|
virtual bool start() override;
|
||||||
virtual bool stop() override;
|
virtual bool stop() override;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace acgist {
|
|||||||
/**
|
/**
|
||||||
* 音频轨道来源
|
* 音频轨道来源
|
||||||
*
|
*
|
||||||
* TODO: 媒体转发
|
* TODO: 如果需要自行实现
|
||||||
*/
|
*/
|
||||||
class TaoyaoAudioTrackSource : public webrtc::AudioTrackSinkInterface, public webrtc::Notifier<webrtc::AudioSourceInterface> {
|
class TaoyaoAudioTrackSource : public webrtc::AudioTrackSinkInterface, public webrtc::Notifier<webrtc::AudioSourceInterface> {
|
||||||
|
|
||||||
@@ -135,6 +135,8 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 视频解码器
|
* 视频解码器
|
||||||
|
*
|
||||||
|
* TODO: 如果需要自行实现
|
||||||
*/
|
*/
|
||||||
class TaoyaoVideoDecoder : public webrtc::VideoDecoder {
|
class TaoyaoVideoDecoder : public webrtc::VideoDecoder {
|
||||||
|
|
||||||
@@ -143,7 +145,9 @@ public:
|
|||||||
virtual ~TaoyaoVideoDecoder() override;
|
virtual ~TaoyaoVideoDecoder() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// 开始解码
|
||||||
virtual bool start();
|
virtual bool start();
|
||||||
|
// 停止解码
|
||||||
virtual bool stop();
|
virtual bool stop();
|
||||||
virtual int32_t Release() override;
|
virtual int32_t Release() override;
|
||||||
virtual int32_t RegisterDecodeCompleteCallback(webrtc::DecodedImageCallback* callback) override;
|
virtual int32_t RegisterDecodeCompleteCallback(webrtc::DecodedImageCallback* callback) override;
|
||||||
@@ -152,6 +156,9 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频编码工厂
|
||||||
|
*/
|
||||||
class TaoyaoVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
class TaoyaoVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -164,6 +171,9 @@ public:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频解码工厂
|
||||||
|
*/
|
||||||
class TaoyaoVideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
class TaoyaoVideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -426,7 +426,7 @@ int acgist::Room::closeConsumer(const std::string& consumerId) {
|
|||||||
OH_LOG_INFO(LOG_APP, "关闭消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
OH_LOG_INFO(LOG_APP, "关闭消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
OH_LOG_INFO(LOG_APP, "关闭消费者:%s %s", consumerId.data(), client->second.data());
|
OH_LOG_INFO(LOG_APP, "关闭消费者:%s %s", consumerId.data(), clientId->second.data());
|
||||||
client->second->closeConsumer(consumerId);
|
client->second->closeConsumer(consumerId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -443,7 +443,7 @@ int acgist::Room::pauseConsumer(const std::string& consumerId) {
|
|||||||
OH_LOG_INFO(LOG_APP, "暂停消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
OH_LOG_INFO(LOG_APP, "暂停消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
OH_LOG_INFO(LOG_APP, "暂停消费者:%s %s", consumerId.data(), client->second.data());
|
OH_LOG_INFO(LOG_APP, "暂停消费者:%s %s", consumerId.data(), clientId->second.data());
|
||||||
client->second->pauseConsumer(consumerId);
|
client->second->pauseConsumer(consumerId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -460,7 +460,7 @@ int acgist::Room::resumeConsumer(const std::string& consumerId) {
|
|||||||
OH_LOG_INFO(LOG_APP, "恢复消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
OH_LOG_INFO(LOG_APP, "恢复消费者无效:%s %s", consumerId.data(), clientId->second.data());
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
OH_LOG_INFO(LOG_APP, "恢复消费者:%s %s", consumerId.data(), client->second.data());
|
OH_LOG_INFO(LOG_APP, "恢复消费者:%s %s", consumerId.data(), clientId->second.data());
|
||||||
client->second->resumeConsumer(consumerId);
|
client->second->resumeConsumer(consumerId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ bool acgist::TaoyaoAudioTrackSource::remote() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void acgist::TaoyaoAudioTrackSource::OnData(const void* audio_data, int bits_per_sample, int sample_rate, size_t number_of_channels, size_t number_of_frames) {
|
void acgist::TaoyaoAudioTrackSource::OnData(const void* audio_data, int bits_per_sample, int sample_rate, size_t number_of_channels, size_t number_of_frames) {
|
||||||
// TODO: 转发媒体
|
|
||||||
}
|
}
|
||||||
|
|
||||||
acgist::TaoyaoVideoTrackSource::TaoyaoVideoTrackSource() {
|
acgist::TaoyaoVideoTrackSource::TaoyaoVideoTrackSource() {
|
||||||
@@ -57,7 +56,7 @@ absl::optional<bool> acgist::TaoyaoVideoTrackSource::needs_denoising() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void acgist::TaoyaoVideoTrackSource::OnData(const webrtc::VideoFrame& videoFrame) {
|
void acgist::TaoyaoVideoTrackSource::OnData(const webrtc::VideoFrame& videoFrame) {
|
||||||
// TODO
|
this->OnFrame(videoFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
acgist::TaoyaoVideoEncoderFactory::TaoyaoVideoEncoderFactory() {
|
acgist::TaoyaoVideoEncoderFactory::TaoyaoVideoEncoderFactory() {
|
||||||
@@ -86,7 +85,7 @@ std::vector<webrtc::SdpVideoFormat> acgist::TaoyaoVideoEncoderFactory::GetSuppor
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<webrtc::VideoEncoder> acgist::TaoyaoVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format) {
|
std::unique_ptr<webrtc::VideoEncoder> acgist::TaoyaoVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format) {
|
||||||
OH_LOG_DEBUG(LOG_APP, "返回WebRTC编码器:%s", format.name.data());
|
OH_LOG_DEBUG(LOG_APP, "创建WebRTC编码器:%s", format.name.data());
|
||||||
// 硬编
|
// 硬编
|
||||||
if (absl::EqualsIgnoreCase(format.name.data(), "H264") == 0) {
|
if (absl::EqualsIgnoreCase(format.name.data(), "H264") == 0) {
|
||||||
return std::unique_ptr<webrtc::VideoEncoder>(new acgist::TaoyaoVideoEncoder());
|
return std::unique_ptr<webrtc::VideoEncoder>(new acgist::TaoyaoVideoEncoder());
|
||||||
@@ -132,7 +131,7 @@ std::vector<webrtc::SdpVideoFormat> acgist::TaoyaoVideoDecoderFactory::GetSuppor
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<webrtc::VideoDecoder> acgist::TaoyaoVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format) {
|
std::unique_ptr<webrtc::VideoDecoder> acgist::TaoyaoVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format) {
|
||||||
OH_LOG_DEBUG(LOG_APP, "返回WebRTC解码器:%s", format.name.data());
|
OH_LOG_DEBUG(LOG_APP, "创建WebRTC解码器:%s", format.name.data());
|
||||||
// 硬解
|
// 硬解
|
||||||
if (absl::EqualsIgnoreCase(format.name.data(), "H264") == 0) {
|
if (absl::EqualsIgnoreCase(format.name.data(), "H264") == 0) {
|
||||||
return std::unique_ptr<webrtc::VideoDecoder>(new acgist::TaoyaoVideoDecoder());
|
return std::unique_ptr<webrtc::VideoDecoder>(new acgist::TaoyaoVideoDecoder());
|
||||||
|
|||||||
Reference in New Issue
Block a user