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

Commit 0c22b84

Browse files
committed
HW video acceleration using Media SDK refactoring.
1 parent 4e18cf7 commit 0c22b84

22 files changed

+1291
-82
lines changed

talk/owt/BUILD.gn

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static_library("owt_sdk_base") {
179179

180180
if (owt_msdk_header_root != "") {
181181
include_dirs += [ owt_msdk_header_root ]
182+
defines += [ "OWT_USE_MSDK" ]
182183
}
183184

184185
if (rtc_include_internal_audio_device) {
@@ -187,6 +188,7 @@ static_library("owt_sdk_base") {
187188
if (rtc_use_x11) {
188189
defines += [ "WEBRTC_USE_X11" ]
189190
}
191+
190192
if (!rtc_use_h265) {
191193
defines += [ "DISABLE_H265" ]
192194
} else {
@@ -214,7 +216,11 @@ static_library("owt_sdk_base") {
214216
"sdk/base/win/base_allocator.h",
215217
"sdk/base/win/d3d_allocator.cc",
216218
"sdk/base/win/d3d_allocator.h",
219+
"sdk/base/win/d3d11_allocator.cc",
220+
"sdk/base/win/d3d11_allocator.h",
217221
"sdk/base/win/d3dnativeframe.h",
222+
"sdk/base/win/mediacapabilities.cc",
223+
"sdk/base/win/mediacapabilities.h",
218224
"sdk/base/win/msdkvideobase.cc",
219225
"sdk/base/win/msdkvideobase.h",
220226
"sdk/base/win/msdkvideodecoder.cc",
@@ -229,10 +235,12 @@ static_library("owt_sdk_base") {
229235
"sdk/base/win/sysmem_allocator.h",
230236
"sdk/base/win/videorendererwin.cc",
231237
"sdk/base/win/videorendererwin.h",
238+
"sdk/base/win/videorendererd3d11.cc",
239+
"sdk/base/win/videorendererd3d11.h",
232240
"sdk/base/win/vp9ratecontrol.cc",
233241
"sdk/base/win/vp9ratecontrol.h",
234-
#"sdk/base/win/vp9temporallayers.cc",
235-
#"sdk/base/win/vp9temporallayers.h",
242+
"sdk/base/win/vp9temporallayers.cc",
243+
"sdk/base/win/vp9temporallayers.h",
236244
"sdk/base/windowcapturer.cc",
237245
]
238246
public_deps += [ "//third_party/webrtc/modules/audio_device:audio_device_module_from_input_and_output" ]

talk/owt/sdk/base/mediautils.cc

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,42 @@
99
#include "webrtc/common_video/h264/prefix_parser.h"
1010
#include "webrtc/rtc_base/checks.h"
1111
#include "webrtc/rtc_base/bit_buffer.h"
12+
#include "webrtc/rtc_base/string_to_number.h"
1213
#include "system_wrappers/include/field_trial.h"
1314
#include "talk/owt/sdk/base/mediautils.h"
15+
#include "talk/owt/sdk/base/win/mediacapabilities.h"
1416

1517
namespace owt {
1618
namespace base {
19+
20+
const char kAV1FmtpProfileId[] = "profile";
21+
const char kAV1FmtpLevelId[] = "level-idx";
22+
23+
const char kHEVCFmtpProfileId[] = "profile-id";
24+
const char kHEVCFmtpLevelId[] = "level-id";
25+
1726
static const std::map<const std::string, const Resolution> resolution_name_map = {
1827
{"cif", Resolution(352, 288)},
1928
{"vga", Resolution(640, 480)},
2029
{"hd720p", Resolution(1280, 720)},
21-
{"hd1080p", Resolution(1920, 1080)}};
30+
{"hd1080p", Resolution(1920, 1080)},
31+
{"4k", Resolution(3840, 2160)},
32+
{"8k", Resolution(7680, 4320)}};
33+
2234
static const std::map<const std::string, const AudioCodec>
2335
audio_codec_names = {
2436
{"opus", AudioCodec::kOpus}, {"isac", AudioCodec::kIsac},
2537
{"g722", AudioCodec::kG722}, {"pcmu", AudioCodec::kPcmu},
2638
{"pcma", AudioCodec::kPcma}, {"ilbc", AudioCodec::kIlbc},
2739
{"aac", AudioCodec::kAac}, {"ac3", AudioCodec::kAc3},
2840
{"asao", AudioCodec::kAsao}, {"unknown", AudioCodec::kUnknown}};
41+
2942
static const std::map<const std::string, const VideoCodec>
3043
video_codec_names = {{"vp8", VideoCodec::kVp8},
3144
{"vp9", VideoCodec::kVp9},
3245
{"h264", VideoCodec::kH264},
3346
{"h265", VideoCodec::kH265}};
47+
3448
std::string MediaUtils::GetResolutionName(const Resolution& resolution) {
3549
for (auto it = resolution_name_map.begin(); it != resolution_name_map.end();
3650
++it) {
@@ -40,6 +54,7 @@ std::string MediaUtils::GetResolutionName(const Resolution& resolution) {
4054
}
4155
return "";
4256
}
57+
4358
AudioCodec MediaUtils::GetAudioCodecFromString(const std::string& codec_name) {
4459
auto it = audio_codec_names.find(codec_name);
4560
if (it != audio_codec_names.end()) {
@@ -127,5 +142,33 @@ bool MediaUtils::GetH264TemporalInfo(uint8_t* buffer, size_t buffer_length,
127142
}
128143
return prefix_nal_found;
129144
}
145+
146+
absl::optional<AV1Profile> StringToAV1Profile(const std::string& str) {
147+
const absl::optional<int> i = rtc::StringToNumber<int>(str);
148+
if (!i.has_value())
149+
return absl::nullopt;
150+
151+
switch (i.value()) {
152+
case 0:
153+
return AV1Profile::kMain;
154+
case 1:
155+
return AV1Profile::kHigh;
156+
case 2:
157+
return AV1Profile::kProfessional;
158+
default:
159+
return absl::nullopt;
160+
}
161+
return absl::nullopt;
162+
}
163+
164+
absl::optional<AV1Profile> MediaUtils::ParseSdpForAV1Profile(
165+
const webrtc::SdpVideoFormat::Parameters& params) {
166+
const auto profile_it = params.find(kAV1FmtpProfileId);
167+
if (profile_it == params.end())
168+
return AV1Profile::kMain;
169+
const std::string& profile_str = profile_it->second;
170+
return StringToAV1Profile(profile_str);
171+
}
172+
130173
} // namespace base
131174
} // namespace owt

talk/owt/sdk/base/mediautils.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Copyright (C) <2018> Intel Corporation
22
//
33
// SPDX-License-Identifier: Apache-2.0
4+
45
#ifndef OWT_BASE_MEDIAUTILS_H_
56
#define OWT_BASE_MEDIAUTILS_H_
7+
68
#include "absl/types/optional.h"
9+
#include "api/video_codecs/sdp_video_format.h"
10+
#include <string>
11+
#include "talk/owt/sdk/base/win/mediacapabilities.h"
712
#include "talk/owt/sdk/include/cpp/owt/base/commontypes.h"
813

914
namespace owt {
1015
namespace base {
16+
17+
1118
class MediaUtils {
1219
public:
1320
static std::string GetResolutionName(const Resolution& resolution);
@@ -21,6 +28,8 @@ class MediaUtils {
2128
int& temporal_id,
2229
int& priority_id,
2330
bool& is_idr);
31+
static absl::optional<AV1Profile> ParseSdpForAV1Profile(
32+
const webrtc::SdpVideoFormat::Parameters& params);
2433
};
2534
}
2635
}

talk/owt/sdk/base/sysinfo.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#include <sys/utsname.h>
66
#endif // WEBRTC_LINUX
77
#include "webrtc/rtc_base/checks.h"
8+
#if defined(WEBRTC_WIN)
9+
#include <memory>
10+
#include "webrtc/rtc_base/win/windows_version.h"
11+
#endif
812
#include "talk/owt/sdk/base/sysinfo.h"
913
namespace owt {
1014
namespace base {
@@ -20,7 +24,40 @@ std::string SysInfo::SdkType() {
2024
#endif
2125
}
2226
#if defined(WEBRTC_WIN)
27+
using namespace rtc::rtc_win;
2328
std::string SysInfo::OsName() {
29+
Version version = GetVersion();
30+
switch (version) {
31+
case VERSION_PRE_XP:
32+
return "Pre-Windows XP";
33+
case VERSION_XP:
34+
return "Windows XP";
35+
case VERSION_SERVER_2003:
36+
return "Windows Server 2003";
37+
case VERSION_VISTA:
38+
return "Windows Vista";
39+
case VERSION_WIN7:
40+
return "Windows 7";
41+
case VERSION_WIN8:
42+
return "Windows 8";
43+
case VERSION_WIN8_1:
44+
return "Windows 8.1"; // May also be Windows Server 2012 R1.
45+
// Be noted if the application is not manifest for Win8.1 or Win10, it will aways
46+
// Win8 for version higher than that.
47+
case VERSION_WIN10: // TH 10586
48+
case VERSION_WIN10_TH2: // TH 14393
49+
return "Windows 10 Threshold";
50+
case VERSION_WIN10_RS1:
51+
return "Windows 10 RS1"; // Redstone 1
52+
case VERSION_WIN10_RS2:
53+
return "Windows 10 RS2"; // Redstone 2
54+
case VERSION_WIN10_RS3:
55+
return "Windows 10 RS3"; // Redstone 3, Build 16299
56+
case VERSION_WIN10_RS4:
57+
return "Windows 10 RS4"; // Redstone 4, Version 1803.
58+
default:
59+
return kUnknown;
60+
}
2461
return "Windows NT";
2562
}
2663
std::string SysInfo::OsVersion() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ struct NativeD3DSurfaceHandle {
1717
int width_; // width of the frame passing from decoder
1818
int height_; // height of the frame passing from decoder
1919
};
20-
}
20+
2121
}
2222
#endif // OWT_BASE_WIN_D3DNATIVEFRAME_H

0 commit comments

Comments
 (0)