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

Commit b644f68

Browse files
committed
Resolve review comments.
1 parent bb23064 commit b644f68

File tree

11 files changed

+126
-113
lines changed

11 files changed

+126
-113
lines changed

talk/owt/sdk/base/deviceutils.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ std::vector<Resolution> DeviceUtils::VideoCapturerSupportedResolutions(
102102
return resolutions;
103103
}
104104

105-
std::vector<CameraCapability> DeviceUtils::VideoCapturerSupportedCapabilities(
105+
std::vector<VideoTrackCapabilities>
106+
DeviceUtils::VideoCapturerSupportedCapabilities(
106107
const std::string& id) {
107-
std::vector<CameraCapability> resolutions;
108+
std::vector<VideoTrackCapabilities> resolutions;
108109
webrtc::VideoCaptureCapability capability;
109110
std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info(
110111
webrtc::VideoCaptureFactory::CreateDeviceInfo());
@@ -113,7 +114,7 @@ std::vector<CameraCapability> DeviceUtils::VideoCapturerSupportedCapabilities(
113114
} else {
114115
for (int32_t i = 0; i < info->NumberOfCapabilities(id.c_str()); i++) {
115116
if (info->GetCapability(id.c_str(), i, capability) == 0) {
116-
resolutions.push_back(CameraCapability(
117+
resolutions.push_back(VideoTrackCapabilities(
117118
capability.width, capability.height, capability.maxFPS));
118119
} else {
119120
RTC_LOG(LS_WARNING) << "Failed to get capability.";
@@ -141,7 +142,7 @@ std::vector<CameraCapability> DeviceUtils::VideoCapturerSupportedCapabilities(
141142
if (found) {
142143
for (int32_t i = 0; i < info->NumberOfCapabilities(vcm_id); i++) {
143144
if (info->GetCapability(vcm_id, i, capability) == 0) {
144-
resolutions.push_back(CameraCapability(
145+
resolutions.push_back(VideoTrackCapabilities(
145146
capability.width, capability.height, capability.maxFPS));
146147
} else {
147148
RTC_LOG(LS_WARNING) << "Failed to get capability.";

talk/owt/sdk/base/globalconfiguration.cc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ AudioProcessingSettings GlobalConfiguration::audio_processing_settings_ = {
2121
AudioProcessingSettings GlobalConfiguration::audio_processing_settings_ = {
2222
true, true, true, true};
2323
#endif
24-
int GlobalConfiguration::audio_min_ = 0;
25-
int GlobalConfiguration::audio_max_ = 0;
26-
int GlobalConfiguration::video_min_ = 0;
27-
int GlobalConfiguration::video_max_ = 0;
28-
int GlobalConfiguration::screen_min_ = 0;
29-
int GlobalConfiguration::screen_max_ = 0;
30-
int GlobalConfiguration::data_min_ = 0;
31-
int GlobalConfiguration::data_max_ = 0;
24+
IcePortRanges GlobalConfiguration::ice_port_ranges_ = {
25+
{0, 0},
26+
{0, 0},
27+
{0, 0},
28+
{0, 0}};
3229
bool GlobalConfiguration::pre_decode_dump_enabled_ = false;
3330
bool GlobalConfiguration::post_encode_dump_enabled_ = false;
3431
} // namespace base

talk/owt/sdk/base/peerconnectiondependencyfactory.cc

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ void PeerConnectionDependencyFactory::
100100
field_trial_ += "OWT-EchoCanceller3/Enabled/";
101101
}
102102
// Handle port ranges.
103-
int audio_min, audio_max, video_min, video_max, screen_min, screen_max,
104-
data_min, data_max;
105-
GlobalConfiguration::GetPortRanges(audio_min, audio_max, video_min, video_max,
106-
screen_min, screen_max, data_min,
107-
data_max);
108-
RTC_LOG(LS_INFO) << "Port ranges:"
109-
<< "audio_min:" << audio_min << ",audio_max:" << audio_max;
110-
if ((audio_min > 0 && audio_max > audio_min) || (video_min > 0 &&
111-
video_max > video_min) || (screen_min > 0 && screen_max > screen_min) ||
112-
(data_min > 0 && data_max > data_min)) {
103+
IcePortRanges ice_port_ranges;
104+
GlobalConfiguration::GetPortRanges(ice_port_ranges);
105+
if ((ice_port_ranges.audio.min > 0 &&
106+
ice_port_ranges.audio.max > ice_port_ranges.audio.min) ||
107+
(ice_port_ranges.video.min > 0 &&
108+
ice_port_ranges.video.max > ice_port_ranges.video.min) ||
109+
(ice_port_ranges.screen.min > 0 &&
110+
ice_port_ranges.screen.max > ice_port_ranges.screen.min) ||
111+
(ice_port_ranges.data.min > 0 &&
112+
ice_port_ranges.data.max > ice_port_ranges.data.min)) {
113113
field_trial_ += "OWT-IceUnbundle/Enabled/";
114114
}
115115
bool pre_decode_dump = GlobalConfiguration::GetPreDecodeDumpEnabled();
@@ -236,22 +236,27 @@ PeerConnectionDependencyFactory::CreatePeerConnectionOnCurrentThread(
236236
port_allocator.reset(new cricket::BasicPortAllocator(
237237
network_manager_.get(), packet_socket_factory_.get()));
238238
// Handle port ranges.
239-
int audio_min, audio_max, video_min, video_max, screen_min, screen_max,
240-
data_min, data_max;
241-
GlobalConfiguration::GetPortRanges(audio_min, audio_max, video_min, video_max,
242-
screen_min, screen_max, data_min,
243-
data_max);
244-
if (audio_min > 0 && audio_max > audio_min) {
245-
port_allocator->SetAudioPortRange(audio_min, audio_max);
239+
IcePortRanges ice_port_ranges;
240+
GlobalConfiguration::GetPortRanges(ice_port_ranges);
241+
if (ice_port_ranges.audio.min > 0 &&
242+
ice_port_ranges.audio.max > ice_port_ranges.audio.min) {
243+
port_allocator->SetAudioPortRange(ice_port_ranges.audio.min,
244+
ice_port_ranges.audio.max);
246245
}
247-
if (video_min > 0 && video_max > video_min) {
248-
port_allocator->SetVideoPortRange(video_min, video_max);
246+
if (ice_port_ranges.video.min > 0 &&
247+
ice_port_ranges.video.max > ice_port_ranges.video.min) {
248+
port_allocator->SetVideoPortRange(ice_port_ranges.video.min,
249+
ice_port_ranges.video.max);
249250
}
250-
if (screen_min > 0 && screen_max > screen_min) {
251-
port_allocator->SetScreenPortRange(screen_min, screen_max);
251+
if (ice_port_ranges.screen.min > 0 &&
252+
ice_port_ranges.screen.max > ice_port_ranges.screen.min) {
253+
port_allocator->SetScreenPortRange(ice_port_ranges.screen.min,
254+
ice_port_ranges.screen.max);
252255
}
253-
if (data_min > 0 && data_max > data_min) {
254-
port_allocator->SetDataPortRange(data_min, data_max);
256+
if (ice_port_ranges.data.min > 0 &&
257+
ice_port_ranges.data.max > ice_port_ranges.data.min) {
258+
port_allocator->SetDataPortRange(ice_port_ranges.data.min,
259+
ice_port_ranges.data.max);
255260
}
256261
return (pc_factory_->CreatePeerConnection(config, std::move(port_allocator),
257262
nullptr, observer))

talk/owt/sdk/base/sdputils.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ std::string SdpUtils::SetPreferAudioCodecs(const std::string& original_sdp,
4242
return cur_sdp;
4343
}
4444
std::string SdpUtils::SetPreferVideoCodecs(const std::string& original_sdp,
45-
std::vector<VideoCodec>& codec, bool set_quality) {
45+
std::vector<VideoCodec>& codec, bool qos_mode) {
4646
std::string cur_sdp(original_sdp);
47-
if (codec.size() == 0 && !set_quality)
47+
if (codec.size() == 0 && !qos_mode)
4848
return cur_sdp;
4949
std::vector<VideoCodec> rcodecs(codec.rbegin(), codec.rend());
5050
std::vector<std::string> codec_names;
@@ -56,7 +56,7 @@ std::string SdpUtils::SetPreferVideoCodecs(const std::string& original_sdp,
5656
}
5757
codec_names.push_back(codec_it->second);
5858
}
59-
cur_sdp = SdpUtils::SetPreferCodecs(cur_sdp, codec_names, false, set_quality);
59+
cur_sdp = SdpUtils::SetPreferCodecs(cur_sdp, codec_names, false, qos_mode);
6060
return cur_sdp;
6161
}
6262

@@ -82,7 +82,7 @@ std::vector<std::string> SdpUtils::GetCodecValues(const std::string& sdp,
8282
// TODO: unify to std::regex impl for Linux builds.
8383
std::string SdpUtils::SetPreferCodecs(const std::string& sdp,
8484
std::vector<std::string>& codec_names,
85-
bool is_audio, bool set_quality) {
85+
bool is_audio, bool qos_mode) {
8686
// Search all rtx maps in the sdp.
8787
std::regex reg_fmtp_apt(
8888
"a=fmtp:(\\d+) apt=(\\d+)(?=[\r]?[\n]?)",
@@ -204,7 +204,7 @@ std::string SdpUtils::SetPreferCodecs(const std::string& sdp,
204204
std::regex_replace(sdp, reg_m_line, m_line_stream.str());
205205
after_strip = before_strip;
206206

207-
if (!is_audio && set_quality) {
207+
if (!is_audio && qos_mode) {
208208
// Search for c-line and add a=priority line after it.
209209
std::regex reg_c_line("c=IN .*\\r\\n");
210210
std::smatch c_line_match;
@@ -243,7 +243,7 @@ std::string SdpUtils::SetPreferCodecs(const std::string& sdp,
243243
}
244244
}
245245
} else {
246-
if (!is_audio && set_quality) {
246+
if (!is_audio && qos_mode) {
247247
// Search for c-line and add a=priority line after it.
248248
std::regex reg_c_line("c=IN .*\\r\\n");
249249
std::smatch c_line_match;

talk/owt/sdk/base/sdputils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ class SdpUtils {
1414
static std::string SetPreferAudioCodecs(const std::string& sdp,
1515
std::vector<AudioCodec>& codec);
1616
static std::string SetPreferVideoCodecs(const std::string& sdp,
17-
std::vector<VideoCodec>& codec, bool set_quality = false);
17+
std::vector<VideoCodec>& codec, bool qos_mode = false);
1818
private:
1919
/**
2020
@brief Replace SDP for preferred codec.
2121
@param sdp Original SDP.
2222
@param codec_names Codec names in SDP.
2323
@param is_audio True if prefer audio codec, false if prefer video codec.
24+
@param set_quality If true will configure the a=quality SDP line for all codecs. This
25+
is used to differentiate a track for higher QoS.
2426
*/
2527
static std::string SetPreferCodecs(const std::string& sdp,
2628
std::vector<std::string>& codec_name,
27-
bool is_audio, bool set_quality = false);
29+
bool is_audio, bool qos_mode = false);
2830
static std::vector<std::string> GetCodecValues(const std::string& sdp,
2931
std::string& codec_name,
3032
bool is_audio);

talk/owt/sdk/base/win/mediacapabilities.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ MediaCapabilities::SupportedCapabilitiesForVideoDecoder(
276276
VideoDecoderCapability vp9_cap;
277277
vp9_cap.codec_type = owt::base::VideoCodec::kVp9;
278278
vp9_cap.hardware_accelerated = true;
279-
vp9_cap.max_resolution = VideoResolutionMax::k8K;
279+
vp9_cap.max_resolution = {7680, 4320};
280280
// Starting from KBL we support both 8-bit and 10-bit,so
281281
// not speficying profiles here. BXT/APL only supports
282282
// 8-bit but not enabled for Windows SDK.
@@ -291,7 +291,7 @@ MediaCapabilities::SupportedCapabilitiesForVideoDecoder(
291291
VideoDecoderCapability avc_cap;
292292
avc_cap.codec_type = owt::base::VideoCodec::kH264;
293293
avc_cap.hardware_accelerated = true;
294-
avc_cap.max_resolution = VideoResolutionMax::k4K;
294+
avc_cap.max_resolution = {3840, 2160};
295295
capabilities.push_back(avc_cap);
296296
}
297297
}
@@ -308,7 +308,7 @@ MediaCapabilities::SupportedCapabilitiesForVideoDecoder(
308308
h265_cap.hardware_accelerated = true;
309309
// Starting from KBL we support both 8-bit and 10-bit, so
310310
// not specifying profiles here.
311-
h265_cap.max_resolution = VideoResolutionMax::k8K;
311+
h265_cap.max_resolution = {7680, 4320};
312312
capabilities.push_back(h265_cap);
313313
}
314314
}
@@ -329,7 +329,7 @@ MediaCapabilities::SupportedCapabilitiesForVideoDecoder(
329329
VideoDecoderCapability av1_cap;
330330
av1_cap.codec_type = owt::base::VideoCodec::kAv1;
331331
av1_cap.hardware_accelerated = true;
332-
av1_cap.max_resolution = VideoResolutionMax::k8K;
332+
av1_cap.max_resolution = {7680, 4320};
333333
// We support all 3 profiles so not specifying them here.
334334
capabilities.push_back(av1_cap);
335335
}
@@ -347,7 +347,7 @@ MediaCapabilities::SupportedCapabilitiesForVideoDecoder(
347347
vp8_cap.hardware_accelerated = true;
348348
// Starting from KBL we support both 8-bit and 10-bit, so
349349
// not specifying profiles here.
350-
vp8_cap.max_resolution = VideoResolutionMax::k4K;
350+
vp8_cap.max_resolution = {3840, 2160};
351351
capabilities.push_back(vp8_cap);
352352
}
353353
}

talk/owt/sdk/base/win/mediacapabilities.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,12 @@ struct VideoEncoderCapability {
3535
std::vector<SamplingMode> sampling_modes;
3636
};
3737

38-
enum class VideoResolutionMax : int {
39-
kHD = 0, // 720p
40-
kFullHD, // 1080p
41-
k2K,
42-
k4K,
43-
k8K,
44-
k16K,
45-
k32K
46-
};
47-
4838
struct VideoDecoderCapability {
4939
owt::base::VideoCodec codec_type;
5040
bool hardware_accelerated;
5141
// Use by decoder factory to generate a subset of
5242
// profiles supported for each codec.
53-
VideoResolutionMax max_resolution;
43+
owt::base::Resolution max_resolution;
5444
CodecSpecificInfoUnion codec_specific;
5545
};
5646

talk/owt/sdk/include/cpp/owt/base/commontypes.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ struct Resolution {
5959
};
6060

6161
/// This class represents a camera capability.
62-
struct CameraCapability {
62+
struct VideoTrackCapabilities {
6363
/// Construct an instance with width and height equal to 0.
64-
explicit CameraCapability() : width(0), height(0), fps(0) {}
64+
explicit VideoTrackCapabilities() : width(0), height(0), frameRate(0) {}
6565
/// Construct an instance with specify width and height.
66-
CameraCapability(unsigned long w, unsigned long h, int fps)
67-
: width(w), height(h), fps(fps) {}
68-
bool operator==(const CameraCapability& rhs) const {
66+
VideoTrackCapabilities(unsigned long w, unsigned long h, int fps)
67+
: width(w), height(h), frameRate(fps) {}
68+
bool operator==(const VideoTrackCapabilities& rhs) const {
6969
return this->width == rhs.width && this->height == rhs.height &&
70-
this->fps == rhs.fps ;
70+
this->frameRate == rhs.frameRate;
7171
}
7272
unsigned long width;
7373
unsigned long height;
74-
int32_t fps;
74+
int32_t frameRate;
7575
};
7676

7777
/// Audio codec parameters for an audio track.
@@ -119,6 +119,7 @@ struct RtpEncodingParameters {
119119
// Called "encodingId" in ORTC.
120120
std::string rid = "";
121121

122+
// The RTPSender/RTPReceiver's priority. Will impact the DSCP flag on Linux.
122123
NetworkPriority priority = NetworkPriority::kDefault;
123124
};
124125

talk/owt/sdk/include/cpp/owt/base/deviceutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DeviceUtils {
2424
static int GetVideoCaptureDeviceIndex(const std::string& id);
2525
/// Get camera device's user friendly name by index.
2626
static std::string GetDeviceNameByIndex(int index);
27-
static std::vector<CameraCapability> VideoCapturerSupportedCapabilities(
27+
static std::vector<VideoTrackCapabilities> VideoCapturerSupportedCapabilities(
2828
const std::string& id);
2929
};
3030
}

0 commit comments

Comments
 (0)