[*] 优化
This commit is contained in:
@@ -124,17 +124,22 @@ class VideoCapturer: public Capturer<acgist::TaoyaoVideoTrackSource> {
|
||||
|
||||
public:
|
||||
// ================ Vulkan ================
|
||||
// VK实例
|
||||
VkInstance vkInstance = VK_NULL_HANDLE;
|
||||
// VK Surface
|
||||
VkSurfaceKHR vkSurfaceKHR = VK_NULL_HANDLE;
|
||||
// VK应用
|
||||
VkApplicationInfo vkApplicationInfo = {};
|
||||
// VK实例配置
|
||||
VkInstanceCreateInfo vkInstanceCreateInfo = {};
|
||||
// VK Surface配置
|
||||
VkSurfaceCreateInfoOHOS vkSurfaceCreateInfoOHOS = {};
|
||||
// ================ OpenGL ES ================
|
||||
// SurfaceId
|
||||
// OpenGL ES SurfaceId
|
||||
uint64_t surfaceId = 0;
|
||||
// OpenGL纹理指针
|
||||
// OpenGL ES纹理指针
|
||||
GLuint textureId = 0;
|
||||
// OpenGL纹理数量
|
||||
// OpenGL ES纹理数量
|
||||
GLsizei textureSize = 1;
|
||||
// EGL显示设备
|
||||
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
|
||||
@@ -167,9 +172,13 @@ public:
|
||||
virtual ~VideoCapturer() override;
|
||||
|
||||
public:
|
||||
// 加载VK
|
||||
void initVulkan();
|
||||
// 释放VK
|
||||
void releaseVulkan();
|
||||
// 加载OpenGL ES
|
||||
void initOpenGLES();
|
||||
// 释放OpenGL ES
|
||||
void releaseOpenGLES();
|
||||
virtual bool start() override;
|
||||
virtual bool stop() override;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace acgist {
|
||||
/**
|
||||
* 音频轨道来源
|
||||
*
|
||||
* TODO: 媒体转发
|
||||
* TODO: 如果需要自行实现
|
||||
*/
|
||||
class TaoyaoAudioTrackSource : public webrtc::AudioTrackSinkInterface, public webrtc::Notifier<webrtc::AudioSourceInterface> {
|
||||
|
||||
@@ -135,6 +135,8 @@ public:
|
||||
|
||||
/**
|
||||
* 视频解码器
|
||||
*
|
||||
* TODO: 如果需要自行实现
|
||||
*/
|
||||
class TaoyaoVideoDecoder : public webrtc::VideoDecoder {
|
||||
|
||||
@@ -143,7 +145,9 @@ public:
|
||||
virtual ~TaoyaoVideoDecoder() override;
|
||||
|
||||
public:
|
||||
// 开始解码
|
||||
virtual bool start();
|
||||
// 停止解码
|
||||
virtual bool stop();
|
||||
virtual int32_t Release() override;
|
||||
virtual int32_t RegisterDecodeCompleteCallback(webrtc::DecodedImageCallback* callback) override;
|
||||
@@ -152,6 +156,9 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 视频编码工厂
|
||||
*/
|
||||
class TaoyaoVideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
||||
|
||||
public:
|
||||
@@ -164,6 +171,9 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* 视频解码工厂
|
||||
*/
|
||||
class TaoyaoVideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
||||
|
||||
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());
|
||||
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);
|
||||
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());
|
||||
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);
|
||||
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());
|
||||
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);
|
||||
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) {
|
||||
// TODO: 转发媒体
|
||||
}
|
||||
|
||||
acgist::TaoyaoVideoTrackSource::TaoyaoVideoTrackSource() {
|
||||
@@ -57,7 +56,7 @@ absl::optional<bool> acgist::TaoyaoVideoTrackSource::needs_denoising() const {
|
||||
}
|
||||
|
||||
void acgist::TaoyaoVideoTrackSource::OnData(const webrtc::VideoFrame& videoFrame) {
|
||||
// TODO
|
||||
this->OnFrame(videoFrame);
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
return std::unique_ptr<webrtc::VideoDecoder>(new acgist::TaoyaoVideoDecoder());
|
||||
|
||||
Reference in New Issue
Block a user