Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Meonardo committed Dec 15, 2022
1 parent c01b1a5 commit 7bfbe4e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
20 changes: 10 additions & 10 deletions src/janus_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void VideoFeederImpl::FeedVideoPacket(OBSVideoPacket *pkt, int width,
JanusConnection::JanusConnection(bool send_encoded_data)
: ws_client_(nullptr),
rtc_client_(nullptr),
video_framer_(nullptr),
video_feeder_(nullptr),
room_(0),
session_id_(0),
handle_id_(0),
Expand Down Expand Up @@ -187,8 +187,9 @@ void JanusConnection::Unpublish()
// destory RTCClient
DestoryRTCClient();
// release the `VideoFrameFeeder`
if (video_framer_) {
video_framer_ = nullptr;
if (video_feeder_) {
delete video_feeder_;
video_feeder_ = nullptr;
}
}

Expand Down Expand Up @@ -227,13 +228,13 @@ rtc::RTCClient *JanusConnection::GetRTCClient() const
void JanusConnection::SendVideoFrame(OBSVideoFrame *frame, int width,
int height)
{
video_framer_->FeedVideoFrame(frame, width, height);
video_feeder_->FeedVideoFrame(frame, width, height);
}

void JanusConnection::SendVideoPacket(OBSVideoPacket *pkt, int width,
int height)
{
video_framer_->FeedVideoPacket(pkt, width, height);
video_feeder_->FeedVideoPacket(pkt, width, height);
}

void JanusConnection::DestoryRTCClient()
Expand Down Expand Up @@ -267,19 +268,18 @@ void JanusConnection::CreateHandle()
void JanusConnection::CreateOffer()
{
// create video framer if necessary
if (video_framer_ == nullptr) {
video_framer_ = new VideoFeederImpl();
if (video_feeder_ == nullptr) {
video_feeder_ = new VideoFeederImpl();
}

if (rtc_client_ == nullptr)
return;

// create media sender
if (use_encoded_data_) {
rtc_client_->CreateMediaSender(video_framer_);
rtc_client_->CreateMediaSender(video_feeder_, true);
} else {
rtc_client_->CreateMediaSender(
std::unique_ptr<VideoFeederImpl>(video_framer_));
rtc_client_->CreateMediaSender(video_feeder_);
}

// create offer
Expand Down
2 changes: 1 addition & 1 deletion src/janus_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class JanusConnection : public signaling::WebsocketClientInterface,

signaling::WebsocketClient *ws_client_;
rtc::RTCClient *rtc_client_;
VideoFeederImpl *video_framer_;
VideoFeederImpl *video_feeder_;

// websocket events
void Connect(const char *url);
Expand Down
10 changes: 5 additions & 5 deletions src/rtc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,19 @@ bool RTCClient::ToggleMute(bool mute)
return audio_track_->set_enabled(!mute);
}

void RTCClient::CreateMediaSender(
std::unique_ptr<owt::base::VideoFrameGeneratorInterface> video)
void RTCClient::CreateMediaSender(owt::base::VideoFrameGeneratorInterface* video)
{
string video_label("obsrtc_video");
local_video_track_ = pcf_->CreateVideoTrack(std::move(video), video_label);
local_video_track_ = pcf_->CreateVideoTrack(video, video_label);

scoped_refptr<RTCMediaStream> stream = pcf_->CreateStream("obs-rtc-raw");
if (local_video_track_)
stream->AddTrack(local_video_track_);
pc_->AddStream(stream);
}

void RTCClient::CreateMediaSender(owt::base::VideoEncoderInterface *encoder)
void RTCClient::CreateMediaSender(owt::base::VideoEncoderInterface *encoder,
bool encoded)
{
string video_label("obsrtc_video");
local_video_track_ = pcf_->CreateVideoTrack(encoder, video_label);
Expand Down Expand Up @@ -420,7 +420,7 @@ RTCClient *CreateClient(
{
if (g_pcf_ == nullptr) {
// Default log level is none
UpdateRTCLogLevel(kError);
UpdateRTCLogLevel(kNone);
// SetVideoHardwareAccelerationEnabled(true);
SetCustomizedVideoEncoderEnabled(true);

Expand Down
5 changes: 2 additions & 3 deletions src/rtc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ class RTCClient : public libwebrtc::RTCPeerConnectionObserver {
// Media
bool ToggleMute(bool mute);
// customized raw frame sender
void CreateMediaSender(
std::unique_ptr<owt::base::VideoFrameGeneratorInterface> video);
void CreateMediaSender(owt::base::VideoFrameGeneratorInterface* video);
// customized encoded packet sender
void CreateMediaSender(owt::base::VideoEncoderInterface *encoder);
void CreateMediaSender(owt::base::VideoEncoderInterface *encoder, bool encoded);

// PC Observer & callback
void AddPeerconnectionEventsObserver(RTCClientConnectionObserver *cb);
Expand Down

0 comments on commit 7bfbe4e

Please sign in to comment.