Skip to content

Commit 1a832ee

Browse files
committed
feat: add WebRTC publisher Pacer to improve playback quality
1 parent 48b716f commit 1a832ee

13 files changed

Lines changed: 519 additions & 329 deletions

File tree

src/projects/config/items/virtual_hosts/applications/publishers/webrtc_publisher.h

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,30 @@ namespace cfg
3636
}
3737
};
3838

39+
struct Pacer : public Item
40+
{
41+
protected:
42+
bool _enable = false;
43+
int _min_ms = 20;
44+
int _max_ms = 500;
45+
46+
public:
47+
CFG_DECLARE_CONST_REF_GETTER_OF(IsEnabled, _enable)
48+
CFG_DECLARE_CONST_REF_GETTER_OF(GetMinMs, _min_ms)
49+
CFG_DECLARE_CONST_REF_GETTER_OF(GetMaxMs, _max_ms)
50+
51+
// Used by deprecated <JitterBuffer>true</JitterBuffer> migration.
52+
void SetEnable(bool enable) { _enable = enable; }
53+
54+
protected:
55+
void MakeList() override
56+
{
57+
Register<Optional>("Enable", &_enable);
58+
Register<Optional>("Min", &_min_ms);
59+
Register<Optional>("Max", &_max_ms);
60+
}
61+
};
62+
3963
struct WebrtcPublisher : public Publisher
4064
{
4165
PublisherType GetType() const override
@@ -46,7 +70,7 @@ namespace cfg
4670
CFG_DECLARE_CONST_REF_GETTER_OF(GetTimeout, _timeout)
4771
CFG_DECLARE_CONST_REF_GETTER_OF(IsRtxEnabled, _rtx)
4872
CFG_DECLARE_CONST_REF_GETTER_OF(IsUlpfecEnalbed, _ulpfec)
49-
CFG_DECLARE_CONST_REF_GETTER_OF(IsJitterBufferEnabled, _jitter_buffer)
73+
CFG_DECLARE_CONST_REF_GETTER_OF(GetPacer, _pacer)
5074
CFG_DECLARE_CONST_REF_GETTER_OF(GetPlayoutDelay, _playout_delay)
5175
CFG_DECLARE_CONST_REF_GETTER_OF(GetBandwidthEstimationType, _bandwidth_estimation_type)
5276
CFG_DECLARE_CONST_REF_GETTER_OF(ShouldCreateDefaultPlaylist, _create_default_playlist)
@@ -57,10 +81,23 @@ namespace cfg
5781
Publisher::MakeList();
5882

5983
Register<Optional>("Timeout", &_timeout);
60-
Register<Optional>("JitterBuffer", &_jitter_buffer);
6184
Register<Optional>("Rtx", &_rtx);
6285
Register<Optional>("Ulpfec", &_ulpfec);
6386
Register<Optional>("PlayoutDelay", &_playout_delay);
87+
Register<Optional>("Pacer", &_pacer);
88+
// Deprecated: replaced by <Pacer>. Accepted as a boolean for
89+
// backward compatibility — when set to true, Pacer is enabled
90+
// with default Min/Max values and a deprecation warning is logged.
91+
Register<Optional>("JitterBuffer", &_deprecated_jitter_buffer,
92+
nullptr,
93+
[=]() -> std::shared_ptr<ConfigError> {
94+
logw("Config", "<JitterBuffer> is deprecated. Please use <Pacer> instead.");
95+
if (_deprecated_jitter_buffer)
96+
{
97+
_pacer.SetEnable(true);
98+
}
99+
return nullptr;
100+
});
64101
Register<Optional>("CreateDefaultPlaylist", &_create_default_playlist);
65102
Register<Optional>("BandwidthEstimation", &_bwe, [=]() -> std::shared_ptr<ConfigError> { return nullptr; }, [=]() -> std::shared_ptr<ConfigError> {
66103
if (_bwe.UpperCaseString() == "REMB")
@@ -83,15 +120,16 @@ namespace cfg
83120
return nullptr; });
84121
}
85122

86-
int _timeout = 30000;
87-
bool _rtx = false;
88-
bool _ulpfec = false;
89-
bool _jitter_buffer = false;
123+
int _timeout = 30000;
124+
bool _rtx = false;
125+
bool _ulpfec = false;
90126
ov::String _bwe;
91127

92128
RtcBWEType _bandwidth_estimation_type = RtcBWEType::All;
93129
PlayoutDelay _playout_delay;
94-
bool _create_default_playlist = true;
130+
Pacer _pacer;
131+
bool _deprecated_jitter_buffer = false;
132+
bool _create_default_playlist = true;
95133
};
96134
} // namespace pub
97135
} // namespace app

src/projects/modules/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ add_subdirectory(containers)
1414
add_subdirectory(origin_map_client)
1515
add_subdirectory(cpix_client)
1616
add_subdirectory(transcode_webhook)
17-
add_subdirectory(jitter_buffer)
17+
add_subdirectory(pacer)
1818
add_subdirectory(rtsp)
1919
add_subdirectory(sdp)
2020
add_subdirectory(rtp_rtcp)

src/projects/modules/jitter_buffer/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/projects/modules/jitter_buffer/jitter_buffer.cpp

Lines changed: 0 additions & 187 deletions
This file was deleted.

src/projects/modules/jitter_buffer/jitter_buffer.h

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ome_add_static_library(pacer)

0 commit comments

Comments
 (0)