Skip to content

Commit 2077a05

Browse files
authored
[flutter_webrtc] Update flutter_webrtc to 0.9.23 (#530)
1 parent 638b0e7 commit 2077a05

20 files changed

+508
-431
lines changed

packages/flutter_webrtc/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.1.1
2+
3+
* Update flutter_webrtc to 0.9.23.
4+
* Fix coredump issue when exit app.
5+
16
## 0.1.0
27

38
* Initial release.

packages/flutter_webrtc/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ For other Tizen devices :
4040

4141
```yaml
4242
dependencies:
43-
flutter_webrtc: ^0.9.18
44-
flutter_webrtc_tizen: ^0.1.0
43+
flutter_webrtc: ^0.9.23
44+
flutter_webrtc_tizen: ^0.1.1
4545
```
4646
4747
## Functionality

packages/flutter_webrtc/example/flutter_webrtc_demo/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
cupertino_icons: ^1.0.3
1212
flutter:
1313
sdk: flutter
14-
flutter_webrtc: ^0.9.18
14+
flutter_webrtc: ^0.9.23
1515
flutter_webrtc_tizen:
1616
path: ../../
1717
http: ^0.13.3

packages/flutter_webrtc/example/flutter_webrtc_example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
flutter:
1313
sdk: flutter
1414
flutter_background: ^1.0.0
15-
flutter_webrtc: ^0.9.18
15+
flutter_webrtc: ^0.9.23
1616
flutter_webrtc_tizen:
1717
path: ../../
1818
# Required for MediaRecorder example

packages/flutter_webrtc/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flutter_webrtc_tizen
22
homepage: https://github.com/flutter-tizen/plugins
33
description: Flutter WebRTC plugin for Tizen, based on GoogleWebRTC.
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/flutter_webrtc
5-
version: 0.1.0
5+
version: 0.1.1
66

77
flutter:
88
plugin:

packages/flutter_webrtc/tizen/inc/flutter_peerconnection.h

+17-16
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FlutterPeerConnection {
7575
std::unique_ptr<MethodResultProxy> result);
7676

7777
void GetRemoteDescription(RTCPeerConnection* pc,
78-
std::unique_ptr<MethodResultProxy> resulte);
78+
std::unique_ptr<MethodResultProxy> result);
7979

8080
scoped_refptr<RTCRtpTransceiverInit> mapToRtpTransceiverInit(
8181
const EncodableMap& transceiverInit);
@@ -89,56 +89,57 @@ class FlutterPeerConnection {
8989
void AddTransceiver(RTCPeerConnection* pc, const std::string& trackId,
9090
const std::string& mediaType,
9191
const EncodableMap& transceiverInit,
92-
std::unique_ptr<MethodResultProxy> resulte);
92+
std::unique_ptr<MethodResultProxy> result);
9393

9494
void GetTransceivers(RTCPeerConnection* pc,
95-
std::unique_ptr<MethodResultProxy> resulte);
95+
std::unique_ptr<MethodResultProxy> result);
9696

9797
void GetReceivers(RTCPeerConnection* pc,
98-
std::unique_ptr<MethodResultProxy> resulte);
99-
100-
void RtpSenderDispose(RTCPeerConnection* pc, std::string rtpSenderId,
101-
std::unique_ptr<MethodResultProxy> resulte);
98+
std::unique_ptr<MethodResultProxy> result);
10299

103100
void RtpSenderSetTrack(RTCPeerConnection* pc, RTCMediaTrack* track,
104101
std::string rtpSenderId,
105-
std::unique_ptr<MethodResultProxy> resulte);
102+
std::unique_ptr<MethodResultProxy> result);
106103

107104
void RtpSenderReplaceTrack(RTCPeerConnection* pc, RTCMediaTrack* track,
108105
std::string rtpSenderId,
109-
std::unique_ptr<MethodResultProxy> resulte);
106+
std::unique_ptr<MethodResultProxy> result);
110107

111108
scoped_refptr<RTCRtpParameters> updateRtpParameters(
112109
EncodableMap newParameters, scoped_refptr<RTCRtpParameters> parameters);
113110

114111
void RtpSenderSetParameters(RTCPeerConnection* pc, std::string rtpSenderId,
115112
const EncodableMap& parameters,
116-
std::unique_ptr<MethodResultProxy> resulte);
113+
std::unique_ptr<MethodResultProxy> result);
117114

118115
void RtpTransceiverStop(RTCPeerConnection* pc, std::string rtpTransceiverId,
119-
std::unique_ptr<MethodResultProxy> resulte);
116+
std::unique_ptr<MethodResultProxy> result);
120117

121118
void RtpTransceiverGetCurrentDirection(
122119
RTCPeerConnection* pc, std::string rtpTransceiverId,
123-
std::unique_ptr<MethodResultProxy> resulte);
120+
std::unique_ptr<MethodResultProxy> result);
124121

125122
void SetConfiguration(RTCPeerConnection* pc,
126123
const EncodableMap& configuration,
127-
std::unique_ptr<MethodResultProxy> resulte);
124+
std::unique_ptr<MethodResultProxy> result);
128125

129126
void CaptureFrame(RTCVideoTrack* track, std::string path,
130-
std::unique_ptr<MethodResultProxy> resulte);
127+
std::unique_ptr<MethodResultProxy> result);
131128

132129
scoped_refptr<RTCRtpTransceiver> getRtpTransceiverById(RTCPeerConnection* pc,
133130
std::string id);
134131

135132
void RtpTransceiverSetDirection(RTCPeerConnection* pc,
136133
std::string rtpTransceiverId,
137134
std::string direction,
138-
std::unique_ptr<MethodResultProxy> resulte);
135+
std::unique_ptr<MethodResultProxy> result);
136+
137+
void RtpTransceiverSetCodecPreferences(
138+
RTCPeerConnection* pc, std::string rtpTransceiverId,
139+
const EncodableList codecs, std::unique_ptr<MethodResultProxy> result);
139140

140141
void GetSenders(RTCPeerConnection* pc,
141-
std::unique_ptr<MethodResultProxy> resulte);
142+
std::unique_ptr<MethodResultProxy> result);
142143

143144
void AddIceCandidate(RTCIceCandidate* candidate, RTCPeerConnection* pc,
144145
std::unique_ptr<MethodResultProxy> result);
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/flutter_webrtc/tizen/src/flutter_common.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class MethodCallProxyImpl : public MethodCallProxy {
99
public:
10-
MethodCallProxyImpl(const MethodCall& method_call)
10+
explicit MethodCallProxyImpl(const MethodCall& method_call)
1111
: method_call_(method_call) {}
1212

1313
~MethodCallProxyImpl() {}
@@ -34,7 +34,7 @@ std::unique_ptr<MethodCallProxy> MethodCallProxy::Create(
3434

3535
class MethodResultProxyImpl : public MethodResultProxy {
3636
public:
37-
MethodResultProxyImpl(std::unique_ptr<MethodResult> method_result)
37+
explicit MethodResultProxyImpl(std::unique_ptr<MethodResult> method_result)
3838
: method_result_(std::move(method_result)) {}
3939
~MethodResultProxyImpl() {}
4040

packages/flutter_webrtc/tizen/src/flutter_media_stream.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ void FlutterMediaStream::GetSources(std::unique_ptr<MethodResultProxy> result) {
301301
EncodableList sources;
302302

303303
int nb_audio_devices = base_->audio_device_->RecordingDevices();
304-
char strNameUTF8[128];
305-
char strGuidUTF8[128];
304+
char strNameUTF8[RTCAudioDevice::kAdmMaxDeviceNameSize + 1] = {0};
305+
char strGuidUTF8[RTCAudioDevice::kAdmMaxGuidSize + 1] = {0};
306306

307307
for (uint16_t i = 0; i < nb_audio_devices; i++) {
308308
base_->audio_device_->RecordingDeviceName(i, strNameUTF8, strGuidUTF8);

packages/flutter_webrtc/tizen/src/flutter_peerconnection.cc

+45-25
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ EncodableMap rtpParametersToMap(
7979
map[EncodableValue("minBitrate")] =
8080
EncodableValue(encoding->min_bitrate_bps());
8181
map[EncodableValue("maxFramerate")] =
82-
EncodableValue(encoding->max_framerate());
82+
EncodableValue(static_cast<int>(encoding->max_framerate()));
8383
map[EncodableValue("scaleResolutionDownBy")] =
8484
EncodableValue(encoding->scale_resolution_down_by());
85-
map[EncodableValue("ssrc")] = EncodableValue((int)encoding->ssrc());
85+
map[EncodableValue("ssrc")] =
86+
EncodableValue(static_cast<int>(encoding->ssrc()));
8687
encodings_info.push_back(EncodableValue(map));
8788
}
8889
info[EncodableValue("encodings")] = EncodableValue(encodings_info);
@@ -519,27 +520,13 @@ void FlutterPeerConnection::GetReceivers(
519520
result_ptr->Success(EncodableValue(map));
520521
}
521522

522-
void FlutterPeerConnection::RtpSenderDispose(
523-
RTCPeerConnection* pc, std::string rtpSenderId,
524-
std::unique_ptr<MethodResultProxy> result) {
525-
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
526-
527-
auto sender = GetRtpSenderById(pc, rtpSenderId);
528-
if (nullptr == sender.get()) {
529-
result_ptr->Error("rtpSenderDispose", "sender is null");
530-
return;
531-
}
532-
// TODO RtpSenderDispose
533-
result_ptr->Success();
534-
}
535-
536523
void FlutterPeerConnection::RtpSenderSetTrack(
537524
RTCPeerConnection* pc, RTCMediaTrack* track, std::string rtpSenderId,
538525
std::unique_ptr<MethodResultProxy> result) {
539526
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
540527
auto sender = GetRtpSenderById(pc, rtpSenderId);
541528
if (nullptr == sender.get()) {
542-
result_ptr->Error("rtpSenderDispose", "sender is null");
529+
result_ptr->Error("rtpSenderSetTrack", "sender is null");
543530
return;
544531
}
545532
sender->set_track(track);
@@ -552,7 +539,7 @@ void FlutterPeerConnection::RtpSenderReplaceTrack(
552539
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
553540
auto sender = GetRtpSenderById(pc, rtpSenderId);
554541
if (nullptr == sender.get()) {
555-
result_ptr->Error("rtpSenderDispose", "sender is null");
542+
result_ptr->Error("rtpSenderReplaceTrack", "sender is null");
556543
return;
557544
}
558545

@@ -611,15 +598,17 @@ void FlutterPeerConnection::RtpSenderSetParameters(
611598

612599
auto sender = GetRtpSenderById(pc, rtpSenderId);
613600
if (nullptr == sender.get()) {
614-
result_ptr->Error("rtpSenderDispose", "sender is null");
601+
result_ptr->Error("rtpSenderSetParameters", "sender is null");
615602
return;
616603
}
617604

618605
auto param = sender->parameters();
619606
param = updateRtpParameters(parameters, param);
620-
sender->set_parameters(param);
607+
bool success = sender->set_parameters(param);
621608

622-
result_ptr->Success();
609+
EncodableMap map;
610+
map[EncodableValue("result")] = EncodableValue(success);
611+
result_ptr->Success(EncodableValue(map));
623612
}
624613

625614
void FlutterPeerConnection::RtpTransceiverStop(
@@ -703,6 +692,35 @@ void FlutterPeerConnection::RtpTransceiverSetDirection(
703692
}
704693
}
705694

695+
void FlutterPeerConnection::RtpTransceiverSetCodecPreferences(
696+
RTCPeerConnection* pc, std::string rtpTransceiverId,
697+
const EncodableList codecs, std::unique_ptr<MethodResultProxy> result) {
698+
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
699+
auto transceiver = getRtpTransceiverById(pc, rtpTransceiverId);
700+
if (nullptr == transceiver.get()) {
701+
result_ptr->Error("RtpTransceiverSetCodecPreferences",
702+
" transceiver is null ");
703+
return;
704+
}
705+
std::vector<scoped_refptr<RTCRtpCodecCapability>> codecList;
706+
for (auto codec : codecs) {
707+
auto codecMap = GetValue<EncodableMap>(codec);
708+
auto codecMimeType = findString(codecMap, "mimeType");
709+
auto codecClockRate = findInt(codecMap, "clockRate");
710+
auto codecNumChannels = findInt(codecMap, "channels");
711+
auto codecSdpFmtpLine = findString(codecMap, "sdpFmtpLine");
712+
auto codecCapability = RTCRtpCodecCapability::Create();
713+
if (codecSdpFmtpLine != std::string())
714+
codecCapability->set_sdp_fmtp_line(codecSdpFmtpLine);
715+
codecCapability->set_clock_rate(codecClockRate);
716+
if (codecNumChannels != -1) codecCapability->set_channels(codecNumChannels);
717+
codecCapability->set_mime_type(codecMimeType);
718+
codecList.push_back(codecCapability);
719+
}
720+
transceiver->SetCodecPreferences(codecList);
721+
result_ptr->Success();
722+
}
723+
706724
void FlutterPeerConnection::GetSenders(
707725
RTCPeerConnection* pc, std::unique_ptr<MethodResultProxy> result) {
708726
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
@@ -732,7 +750,7 @@ EncodableMap statsToMap(const scoped_refptr<MediaRTCStats>& stats) {
732750
report_map[EncodableValue("type")] =
733751
EncodableValue(stats->type().std_string());
734752
report_map[EncodableValue("timestamp")] =
735-
EncodableValue(double(stats->timestamp_us()));
753+
EncodableValue(static_cast<double>(stats->timestamp_us()));
736754
EncodableMap values;
737755
auto members = stats->Members();
738756
for (int i = 0; i < members.size(); i++) {
@@ -782,7 +800,7 @@ void FlutterPeerConnection::GetStats(
782800
std::unique_ptr<MethodResultProxy> result) {
783801
std::shared_ptr<MethodResultProxy> result_ptr(result.release());
784802
scoped_refptr<RTCMediaTrack> track = base_->MediaTracksForId(track_id);
785-
if (track != nullptr) {
803+
if (track != nullptr && track_id != "") {
786804
bool found = false;
787805
auto receivers = pc->receivers();
788806
for (auto receiver : receivers.std_vector()) {
@@ -885,13 +903,15 @@ void FlutterPeerConnection::AddTrack(
885903
streamids.push_back(item.c_str());
886904
}
887905
if (0 == kind.compare("audio")) {
888-
auto sender = pc->AddTrack((RTCAudioTrack*)track.get(), streamids);
906+
auto sender =
907+
pc->AddTrack(reinterpret_cast<RTCVideoTrack*>(track.get()), streamids);
889908
if (sender.get() != nullptr) {
890909
result_ptr->Success(EncodableValue(rtpSenderToMap(sender)));
891910
return;
892911
}
893912
} else if (0 == kind.compare("video")) {
894-
auto sender = pc->AddTrack((RTCVideoTrack*)track.get(), streamids);
913+
auto sender =
914+
pc->AddTrack(reinterpret_cast<RTCVideoTrack*>(track.get()), streamids);
895915
if (sender.get() != nullptr) {
896916
result_ptr->Success(EncodableValue(rtpSenderToMap(sender)));
897917
return;

packages/flutter_webrtc/tizen/src/flutter_video_renderer.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const FlutterDesktopPixelBuffer* FlutterVideoRenderer::CopyPixelBuffer(
3838
}
3939

4040
frame_->ConvertToARGB(RTCVideoFrame::Type::kABGR, rgb_buffer_.get(), 0,
41-
(int)pixel_buffer_->width,
42-
(int)pixel_buffer_->height);
41+
static_cast<int>(pixel_buffer_->width),
42+
static_cast<int>(pixel_buffer_->height));
4343

4444
pixel_buffer_->buffer = rgb_buffer_.get();
4545
mutex_.unlock();
@@ -158,4 +158,4 @@ void FlutterVideoRendererManager::VideoRendererDispose(
158158
"VideoRendererDispose() texture not found!");
159159
}
160160

161-
} // namespace flutter_webrtc_plugin
161+
} // namespace flutter_webrtc_plugin

0 commit comments

Comments
 (0)