Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 1974360

Browse files
committed
Upgrade sdk to m88 for webrtc node
1 parent a142518 commit 1974360

File tree

9 files changed

+56
-51
lines changed

9 files changed

+56
-51
lines changed

scripts/installWebrtc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ download_and_build(){
6868
if [ -d src ]; then
6969
echo "src already exists."
7070
else
71-
git clone -b 79-sdk https://github.com/open-webrtc-toolkit/owt-deps-webrtc.git src
71+
git clone -b 88-sdk https://github.com/open-webrtc-toolkit/owt-deps-webrtc.git src
7272
mkdir -p src/build_overrides/ssl
7373
echo $SSL_GNI > src/build_overrides/ssl/ssl.gni
7474
echo $GCLIENT_CONFIG > .gclient

source/agent/webrtc/rtcFrame/binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
'variables': {
6464
'source_rel_dir': '../../..', # relative source dir path
6565
'source_abs_dir%': '<(module_root_dir)/../../..', # absolute source dir path
66-
'webrtc_abs_dir%': '<(module_root_dir)/../../../../third_party/webrtc-m79' # absolute webrtc dir path
66+
'webrtc_abs_dir%': '<(module_root_dir)/../../../../third_party/webrtc-m88' # absolute webrtc dir path
6767
},
6868
'sources': [
6969
'<(source_rel_dir)/core/rtc_adapter/RtcAdapter.cc',

source/core/owt_base/SsrcGenerator.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,29 @@ SsrcGenerator* SsrcGenerator::GetSsrcGenerator() {
1414
}
1515

1616
uint32_t SsrcGenerator::CreateSsrc() {
17-
rtc::CritScope lock(&crit_);
17+
mutex_.Lock();
1818

1919
while (true) { // Try until get a new ssrc.
2020
uint32_t ssrc = random_.Rand(1u, 0xfffffffe);
2121
if (ssrcs_.insert(ssrc).second) {
22+
mutex_.Unlock();
2223
return ssrc;
2324
}
2425
}
26+
mutex_.Unlock();
2527
}
2628

2729
void SsrcGenerator::RegisterSsrc(uint32_t ssrc) {
28-
rtc::CritScope lock(&crit_);
30+
mutex_.Lock();
2931
ssrcs_.insert(ssrc);
32+
mutex_.Unlock();
33+
3034
}
3135

3236
void SsrcGenerator::ReturnSsrc(uint32_t ssrc) {
33-
rtc::CritScope lock(&crit_);
37+
mutex_.Lock();
3438
ssrcs_.erase(ssrc);
39+
mutex_.Unlock();
3540
}
3641

3742
SsrcGenerator::SsrcGenerator() : random_(rtc::TimeMicros()) {}

source/core/owt_base/SsrcGenerator.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
#include <set>
99

10-
#include "rtc_base/critical_section.h"
10+
#include "rtc_base/synchronization/mutex.h"
11+
#include "rtc_base/thread_annotations.h"
1112
#include "rtc_base/random.h"
12-
#include "base/thread_annotations.h"
1313

1414
namespace owt_base {
1515

@@ -26,9 +26,9 @@ class SsrcGenerator {
2626
~SsrcGenerator();
2727

2828
private:
29-
rtc::CriticalSection crit_;
30-
webrtc::Random random_ GUARDED_BY(crit_);
31-
std::set<uint32_t> ssrcs_ GUARDED_BY(crit_);
29+
mutable webrtc::Mutex mutex_;
30+
webrtc::Random random_ RTC_GUARDED_BY(mutex_);
31+
std::set<uint32_t> ssrcs_ RTC_GUARDED_BY(mutex_);
3232
};
3333
} // namespace owt_base
3434

source/core/rtc_adapter/RtcAdapter.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ class RTCProcessThread {
3737
std::unique_ptr<webrtc::ProcessThread> m_processThread;
3838
};
3939

40-
static std::unique_ptr<RTCProcessThread> g_moduleThread
41-
= std::make_unique<RTCProcessThread>("ModuleProcessThread");
40+
static rtc::scoped_refptr<webrtc::SharedModuleThread> g_moduleThread =
41+
webrtc::SharedModuleThread::Create(
42+
webrtc::ProcessThread::Create("ModuleProcessThread"), nullptr);
43+
4244
static std::unique_ptr<RTCProcessThread> g_pacerThread
4345
= std::make_unique<RTCProcessThread>("PacerThread");
4446

47+
static std::unique_ptr<webrtc::FieldTrialBasedConfig> g_fieldTrial=
48+
std::make_unique<webrtc::FieldTrialBasedConfig>();
49+
4550
class RtcAdapterImpl : public RtcAdapter,
4651
public CallOwner {
4752
public:
@@ -96,14 +101,13 @@ void RtcAdapterImpl::initCall()
96101
if (!m_call) {
97102
webrtc::Call::Config call_config(m_eventLog.get());
98103
call_config.task_queue_factory = m_taskQueueFactory.get();
104+
call_config.trials = g_fieldTrial.get();
99105

100-
std::unique_ptr<webrtc::ProcessThread> moduleThreadProxy =
101-
std::make_unique<ProcessThreadProxy>(g_moduleThread->unwrap());
102106
std::unique_ptr<webrtc::ProcessThread> pacerThreadProxy =
103107
std::make_unique<ProcessThreadProxy>(g_pacerThread->unwrap());
104108
m_call.reset(webrtc::Call::Create(
105109
call_config, webrtc::Clock::GetRealTimeClock(),
106-
std::move(moduleThreadProxy),
110+
g_moduleThread,
107111
std::move(pacerThreadProxy)));
108112
}
109113
});

source/core/rtc_adapter/VideoReceiveAdapter.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "VideoReceiveAdapter.h"
66

7-
#include <common_types.h>
87
#include <future>
98
#include <modules/video_coding/include/video_error_codes.h>
109
#include <modules/video_coding/timing.h>
@@ -210,6 +209,7 @@ void VideoReceiveAdapterImpl::CreateReceiveVideo()
210209
default_config.renderer = this;
211210

212211
webrtc::VideoReceiveStream::Config video_recv_config(default_config.Copy());
212+
video_recv_config.decoder_factory = this;
213213
video_recv_config.decoders.clear();
214214
/*
215215
if (!video_send_config.rtp.rtx.ssrcs.empty()) {
@@ -219,7 +219,6 @@ void VideoReceiveAdapterImpl::CreateReceiveVideo()
219219
}
220220
*/
221221
webrtc::VideoReceiveStream::Decoder decoder;
222-
decoder.decoder_factory = this;
223222
// Add VP8 decoder
224223
decoder.payload_type = VP8_90000_PT;
225224
decoder.video_format = webrtc::SdpVideoFormat(

source/core/rtc_adapter/VideoSendAdapter.cc

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ bool VideoSendAdapterImpl::init()
179179
configuration.event_log = m_eventLog.get();
180180
configuration.retransmission_rate_limiter = m_retransmissionRateLimiter.get();
181181
configuration.local_media_ssrc = m_ssrc; //rtp_config.ssrcs[i];
182+
// TODO: enable UlpfecGenerator
183+
/*
184+
std::make_unique<UlpfecGenerator>(
185+
rtp.ulpfec.red_payload_type, rtp.ulpfec.ulpfec_payload_type, clock);
186+
configuration.fec_generator = fec_generator.get();
187+
*/
182188

183189
m_rtpRtcp = webrtc::RtpRtcp::Create(configuration);
184190
m_rtpRtcp->SetSendingStatus(true);
@@ -202,21 +208,15 @@ bool VideoSendAdapterImpl::init()
202208
m_rtpRtcp->SetMaxRtpPacketSize(kMaxRtpPacketSize);
203209

204210
webrtc::RTPSenderVideo::Config video_config;
205-
m_playoutDelayOracle = std::make_unique<webrtc::PlayoutDelayOracle>();
206211
m_fieldTrialConfig = std::make_unique<webrtc::FieldTrialBasedConfig>();
207212
video_config.clock = configuration.clock;
208213
video_config.rtp_sender = m_rtpRtcp->RtpSender();
209214
video_config.field_trials = m_fieldTrialConfig.get();
210-
video_config.playout_delay_oracle = m_playoutDelayOracle.get();
211215
if (m_config.red_payload) {
212216
video_config.red_payload_type = m_config.red_payload;
213217
}
214-
if (m_config.ulpfec_payload) {
215-
video_config.ulpfec_payload_type = m_config.ulpfec_payload;
216-
}
217218

218219
m_senderVideo = std::make_unique<webrtc::RTPSenderVideo>(video_config);
219-
// m_params = std::make_unique<RtpPayloadParams>(m_ssrc, nullptr);
220220
m_taskRunner->RegisterModule(m_rtpRtcp.get());
221221

222222
return true;
@@ -279,9 +279,9 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
279279
timeStamp,
280280
timeStamp,
281281
rtc::ArrayView<const uint8_t>(frame.payload, frame.length),
282-
nullptr,
283282
h,
284-
m_rtpRtcp->ExpectedRetransmissionTimeMs());
283+
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
284+
0);
285285
} else if (frame.format == FRAME_FORMAT_VP9) {
286286
h.codec = webrtc::VideoCodecType::kVideoCodecVP9;
287287
auto& vp9_header = h.video_type_header.emplace<RTPVideoHeaderVP9>();
@@ -294,9 +294,10 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
294294
timeStamp,
295295
timeStamp,
296296
rtc::ArrayView<const uint8_t>(frame.payload, frame.length),
297-
nullptr,
298297
h,
299-
m_rtpRtcp->ExpectedRetransmissionTimeMs());
298+
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
299+
0);
300+
300301
} else if (frame.format == FRAME_FORMAT_H264 || frame.format == FRAME_FORMAT_H265) {
301302
int frame_length = frame.length;
302303
if (m_enableDump) {
@@ -315,24 +316,10 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
315316
int nalu_start_offset = 0;
316317
int nalu_end_offset = 0;
317318
int sc_len = 0;
318-
RTPFragmentationHeader frag_info;
319-
320-
h.codec = (frame.format == FRAME_FORMAT_H264) ? webrtc::VideoCodecType::kVideoCodecH264 : webrtc::VideoCodecType::kVideoCodecH265;
321-
while (buffer_length > 0) {
322-
nalu_found_length = findNALU(buffer_start, buffer_length, &nalu_start_offset, &nalu_end_offset, &sc_len);
323-
if (nalu_found_length < 0) {
324-
/* Error, should never happen */
325-
break;
326-
} else {
327-
/* SPS, PPS, I, P*/
328-
uint16_t last = frag_info.fragmentationVectorSize;
329-
frag_info.VerifyAndAllocateFragmentationHeader(last + 1);
330-
frag_info.fragmentationOffset[last] = nalu_start_offset + (buffer_start - frame.payload);
331-
frag_info.fragmentationLength[last] = nalu_found_length;
332-
buffer_start += (nalu_start_offset + nalu_found_length);
333-
buffer_length -= (nalu_start_offset + nalu_found_length);
334-
}
335-
}
319+
320+
h.codec = (frame.format == FRAME_FORMAT_H264) ?
321+
webrtc::VideoCodecType::kVideoCodecH264 :
322+
webrtc::VideoCodecType::kVideoCodecH265;
336323

337324
boost::shared_lock<boost::shared_mutex> lock(m_rtpRtcpMutex);
338325
if (frame.format == FRAME_FORMAT_H264) {
@@ -343,9 +330,9 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
343330
timeStamp,
344331
timeStamp,
345332
rtc::ArrayView<const uint8_t>(frame.payload, frame.length),
346-
&frag_info,
347333
h,
348-
m_rtpRtcp->ExpectedRetransmissionTimeMs());
334+
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
335+
0);
349336
} else {
350337
h.video_type_header.emplace<RTPVideoHeaderH265>();
351338
m_senderVideo->SendVideo(
@@ -354,9 +341,9 @@ void VideoSendAdapterImpl::onFrame(const Frame& frame)
354341
timeStamp,
355342
timeStamp,
356343
rtc::ArrayView<const uint8_t>(frame.payload, frame.length),
357-
&frag_info,
358344
h,
359-
m_rtpRtcp->ExpectedRetransmissionTimeMs());
345+
m_rtpRtcp->ExpectedRetransmissionTimeMs(),
346+
0);
360347
}
361348
}
362349
}

source/core/rtc_adapter/VideoSendAdapter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ class VideoSendAdapterImpl : public VideoSendAdapter,
8282

8383
std::unique_ptr<webrtc::RtcEventLog> m_eventLog;
8484
std::unique_ptr<webrtc::RTPSenderVideo> m_senderVideo;
85-
std::unique_ptr<webrtc::PlayoutDelayOracle> m_playoutDelayOracle;
8685
std::unique_ptr<webrtc::FieldTrialBasedConfig> m_fieldTrialConfig;
8786

8887
// Listeners

source/core/rtc_adapter/thread/ProcessThreadProxy.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,31 @@ class ProcessThreadProxy : public webrtc::ProcessThread {
2727
// Stop() has no effect on proxy
2828
virtual void Stop() override {}
2929

30+
// Implements webrtc::TaskQueueBase
31+
virtual void Delete() override {}
32+
3033
// Implements ProcessThread
3134
// Call actual ProcessThread's WakeUp
3235
virtual void WakeUp(webrtc::Module* module) override
3336
{
3437
m_processThread->WakeUp(module);
3538
}
3639

37-
// Implements ProcessThread
40+
// Implements webrtc::TaskQueueBase
3841
// Call actual ProcessThread's PostTask
3942
virtual void PostTask(std::unique_ptr<webrtc::QueuedTask> task) override
4043
{
4144
m_processThread->PostTask(std::move(task));
4245
}
4346

47+
// Implements webrtc::TaskQueueBase
48+
// Call actual ProcessThread's PostDelayedTask
49+
virtual void PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
50+
uint32_t milliseconds) override
51+
{
52+
m_processThread->PostDelayedTask(std::move(task), milliseconds);
53+
}
54+
4455
// Implements ProcessThread
4556
// Call actual ProcessThread's RegisterModule
4657
virtual void RegisterModule(webrtc::Module* module, const rtc::Location& from) override

0 commit comments

Comments
 (0)