@@ -79,10 +79,11 @@ EncodableMap rtpParametersToMap(
79
79
map[EncodableValue (" minBitrate" )] =
80
80
EncodableValue (encoding->min_bitrate_bps ());
81
81
map[EncodableValue (" maxFramerate" )] =
82
- EncodableValue (encoding->max_framerate ());
82
+ EncodableValue (static_cast < int >( encoding->max_framerate () ));
83
83
map[EncodableValue (" scaleResolutionDownBy" )] =
84
84
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 ()));
86
87
encodings_info.push_back (EncodableValue (map));
87
88
}
88
89
info[EncodableValue (" encodings" )] = EncodableValue (encodings_info);
@@ -519,27 +520,13 @@ void FlutterPeerConnection::GetReceivers(
519
520
result_ptr->Success (EncodableValue (map));
520
521
}
521
522
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
-
536
523
void FlutterPeerConnection::RtpSenderSetTrack (
537
524
RTCPeerConnection* pc, RTCMediaTrack* track, std::string rtpSenderId,
538
525
std::unique_ptr<MethodResultProxy> result) {
539
526
std::shared_ptr<MethodResultProxy> result_ptr (result.release ());
540
527
auto sender = GetRtpSenderById (pc, rtpSenderId);
541
528
if (nullptr == sender.get ()) {
542
- result_ptr->Error (" rtpSenderDispose " , " sender is null" );
529
+ result_ptr->Error (" rtpSenderSetTrack " , " sender is null" );
543
530
return ;
544
531
}
545
532
sender->set_track (track);
@@ -552,7 +539,7 @@ void FlutterPeerConnection::RtpSenderReplaceTrack(
552
539
std::shared_ptr<MethodResultProxy> result_ptr (result.release ());
553
540
auto sender = GetRtpSenderById (pc, rtpSenderId);
554
541
if (nullptr == sender.get ()) {
555
- result_ptr->Error (" rtpSenderDispose " , " sender is null" );
542
+ result_ptr->Error (" rtpSenderReplaceTrack " , " sender is null" );
556
543
return ;
557
544
}
558
545
@@ -611,15 +598,17 @@ void FlutterPeerConnection::RtpSenderSetParameters(
611
598
612
599
auto sender = GetRtpSenderById (pc, rtpSenderId);
613
600
if (nullptr == sender.get ()) {
614
- result_ptr->Error (" rtpSenderDispose " , " sender is null" );
601
+ result_ptr->Error (" rtpSenderSetParameters " , " sender is null" );
615
602
return ;
616
603
}
617
604
618
605
auto param = sender->parameters ();
619
606
param = updateRtpParameters (parameters, param);
620
- sender->set_parameters (param);
607
+ bool success = sender->set_parameters (param);
621
608
622
- result_ptr->Success ();
609
+ EncodableMap map;
610
+ map[EncodableValue (" result" )] = EncodableValue (success);
611
+ result_ptr->Success (EncodableValue (map));
623
612
}
624
613
625
614
void FlutterPeerConnection::RtpTransceiverStop (
@@ -703,6 +692,35 @@ void FlutterPeerConnection::RtpTransceiverSetDirection(
703
692
}
704
693
}
705
694
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
+
706
724
void FlutterPeerConnection::GetSenders (
707
725
RTCPeerConnection* pc, std::unique_ptr<MethodResultProxy> result) {
708
726
std::shared_ptr<MethodResultProxy> result_ptr (result.release ());
@@ -732,7 +750,7 @@ EncodableMap statsToMap(const scoped_refptr<MediaRTCStats>& stats) {
732
750
report_map[EncodableValue (" type" )] =
733
751
EncodableValue (stats->type ().std_string ());
734
752
report_map[EncodableValue (" timestamp" )] =
735
- EncodableValue (double (stats->timestamp_us ()));
753
+ EncodableValue (static_cast < double > (stats->timestamp_us ()));
736
754
EncodableMap values;
737
755
auto members = stats->Members ();
738
756
for (int i = 0 ; i < members.size (); i++) {
@@ -782,7 +800,7 @@ void FlutterPeerConnection::GetStats(
782
800
std::unique_ptr<MethodResultProxy> result) {
783
801
std::shared_ptr<MethodResultProxy> result_ptr (result.release ());
784
802
scoped_refptr<RTCMediaTrack> track = base_->MediaTracksForId (track_id);
785
- if (track != nullptr ) {
803
+ if (track != nullptr && track_id != " " ) {
786
804
bool found = false ;
787
805
auto receivers = pc->receivers ();
788
806
for (auto receiver : receivers.std_vector ()) {
@@ -885,13 +903,15 @@ void FlutterPeerConnection::AddTrack(
885
903
streamids.push_back (item.c_str ());
886
904
}
887
905
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);
889
908
if (sender.get () != nullptr ) {
890
909
result_ptr->Success (EncodableValue (rtpSenderToMap (sender)));
891
910
return ;
892
911
}
893
912
} 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);
895
915
if (sender.get () != nullptr ) {
896
916
result_ptr->Success (EncodableValue (rtpSenderToMap (sender)));
897
917
return ;
0 commit comments